diff options
| author | V1K1NGbg <victor@ilchev.com> | 2024-08-22 23:10:57 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2024-10-21 13:30:51 -0300 |
| commit | 2b6429ead0c88dc60a1c99743e2c4d92b91fe7ca (patch) | |
| tree | da41a1ef5a7f3aebe581007debc72bb1f9bb03e3 | |
| parent | e31ed7ee6be8430272947caf84c41595a3030f5c (diff) | |
| download | luarocks-2b6429ead0c88dc60a1c99743e2c4d92b91fe7ca.tar.gz luarocks-2b6429ead0c88dc60a1c99743e2c4d92b91fe7ca.tar.bz2 luarocks-2b6429ead0c88dc60a1c99743e2c4d92b91fe7ca.zip | |
import type definitions for dependencies from teal-types
| -rw-r--r-- | types/lfs.d.tl | 82 | ||||
| -rw-r--r-- | types/ltn12.d.tl | 45 | ||||
| -rw-r--r-- | types/mimetypes.d.tl | 5 | ||||
| -rw-r--r-- | types/socket.d.tl | 158 | ||||
| -rw-r--r-- | types/socket/http.d.tl | 28 | ||||
| -rw-r--r-- | types/ssl.d.tl | 113 | ||||
| -rw-r--r-- | types/ssl/https.d.tl | 50 | ||||
| -rw-r--r-- | types/zlib.d.tl | 10 |
8 files changed, 491 insertions, 0 deletions
diff --git a/types/lfs.d.tl b/types/lfs.d.tl new file mode 100644 index 00000000..12535ca4 --- /dev/null +++ b/types/lfs.d.tl | |||
| @@ -0,0 +1,82 @@ | |||
| 1 | local record lfs | ||
| 2 | |||
| 3 | enum FileMode | ||
| 4 | "file" | ||
| 5 | "directory" | ||
| 6 | "link" | ||
| 7 | "socket" | ||
| 8 | "named pipe" | ||
| 9 | "char device" | ||
| 10 | "block device" | ||
| 11 | "other" | ||
| 12 | end | ||
| 13 | |||
| 14 | record Attributes | ||
| 15 | dev: number | ||
| 16 | ino: number | ||
| 17 | mode: FileMode | ||
| 18 | nlink: number | ||
| 19 | uid: number | ||
| 20 | gid: number | ||
| 21 | rdev: number | ||
| 22 | access: number | ||
| 23 | modification: number | ||
| 24 | change: number | ||
| 25 | size: number | ||
| 26 | permissions: string | ||
| 27 | blocks: number | ||
| 28 | blksize: number | ||
| 29 | end | ||
| 30 | |||
| 31 | enum OpenFileMode | ||
| 32 | "binary" | ||
| 33 | "text" | ||
| 34 | end | ||
| 35 | |||
| 36 | enum LockMode | ||
| 37 | "r" | ||
| 38 | "w" | ||
| 39 | end | ||
| 40 | |||
| 41 | record Lock | ||
| 42 | free: function() | ||
| 43 | end | ||
| 44 | |||
| 45 | dir: function(string): function(): string | ||
| 46 | |||
| 47 | chdir: function(string): boolean, string | ||
| 48 | |||
| 49 | lock_dir: function(string, number): Lock, string | ||
| 50 | |||
| 51 | -- returns number on success, really!? this should be fixed in the lfs library | ||
| 52 | link: function(string, string, boolean): number, string | ||
| 53 | |||
| 54 | mkdir: function(string): boolean, string | ||
| 55 | |||
| 56 | rmdir: function(string): boolean, string | ||
| 57 | |||
| 58 | setmode: function(string, OpenFileMode): boolean, string | ||
| 59 | |||
| 60 | currentdir: function(): string | ||
| 61 | |||
| 62 | attributes: function(string): Attributes | ||
| 63 | attributes: function(string, string): string | ||
| 64 | attributes: function(string, string): number | ||
| 65 | attributes: function(string, string): FileMode | ||
| 66 | attributes: function(string, Attributes): Attributes | ||
| 67 | |||
| 68 | symlinkattributes: function(string): Attributes | ||
| 69 | symlinkattributes: function(string, string): string | ||
| 70 | symlinkattributes: function(string, string): number | ||
| 71 | symlinkattributes: function(string, string): FileMode | ||
| 72 | symlinkattributes: function(string, Attributes): Attributes | ||
| 73 | |||
| 74 | touch: function(string, number, number): boolean, string | ||
| 75 | |||
| 76 | -- TODO: FILE needs to be renamed to io.FILE in tl itself | ||
| 77 | lock: function(FILE, LockMode, number, number): boolean, string | ||
| 78 | unlock: function(FILE, number, number): boolean, string | ||
| 79 | |||
| 80 | end | ||
| 81 | |||
| 82 | return lfs | ||
diff --git a/types/ltn12.d.tl b/types/ltn12.d.tl new file mode 100644 index 00000000..cd2375fc --- /dev/null +++ b/types/ltn12.d.tl | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | |||
| 2 | local record ltn12 | ||
| 3 | type Filter = function(string): string, string | ||
| 4 | type Sink = function(string, string): boolean, string | ||
| 5 | type Source = function(): string, string | ||
| 6 | |||
| 7 | type FancySink = function(string, string): boolean, string | FancySink | ||
| 8 | type FancySource = function(): string, string | FancySource | ||
| 9 | |||
| 10 | -- Docs just say returns a truthy value on success | ||
| 11 | -- Since this value should really only be | ||
| 12 | -- used to check for truthiness, any seems fine here | ||
| 13 | type Pump = function(Source, Sink): any, string | ||
| 14 | |||
| 15 | record filter | ||
| 16 | chain: function(Filter, Filter, ...: Filter): Filter | ||
| 17 | |||
| 18 | cycle: function(string, string, any): Filter | ||
| 19 | end | ||
| 20 | record pump | ||
| 21 | all: Pump | ||
| 22 | step: Pump | ||
| 23 | end | ||
| 24 | record sink | ||
| 25 | chain: function(Filter, Sink): Sink | ||
| 26 | error: function(string): Sink | ||
| 27 | file: function(FILE, string): Sink | ||
| 28 | null: function(): Sink | ||
| 29 | simplify: function(FancySink): Sink | ||
| 30 | table: function({string}): Sink, {string} | ||
| 31 | end | ||
| 32 | record source | ||
| 33 | cat: function(Source, ...: Source): Source | ||
| 34 | chain: function(Source, Filter): Source | ||
| 35 | empty: function(): Source | ||
| 36 | error: function(string): Source | ||
| 37 | file: function(FILE): Source | ||
| 38 | file: function(FILE, string): Source | ||
| 39 | simplify: function(FancySource): Source | ||
| 40 | string: function(string): Source | ||
| 41 | table: function({string}): Source, {string} | ||
| 42 | end | ||
| 43 | end | ||
| 44 | |||
| 45 | return ltn12 \ No newline at end of file | ||
diff --git a/types/mimetypes.d.tl b/types/mimetypes.d.tl new file mode 100644 index 00000000..a735225d --- /dev/null +++ b/types/mimetypes.d.tl | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | local record mimetypes | ||
| 2 | guess: function(string): string | ||
| 3 | end | ||
| 4 | |||
| 5 | return mimetypes \ No newline at end of file | ||
diff --git a/types/socket.d.tl b/types/socket.d.tl new file mode 100644 index 00000000..e62e907b --- /dev/null +++ b/types/socket.d.tl | |||
| @@ -0,0 +1,158 @@ | |||
| 1 | local ltn12 = require("ltn12") | ||
| 2 | local Sink = ltn12.Sink | ||
| 3 | local Source = ltn12.Source | ||
| 4 | |||
| 5 | local record socket | ||
| 6 | record TCP | ||
| 7 | -- master methods | ||
| 8 | bind: function(TCP, string, integer) | ||
| 9 | connect: function(TCP, string, integer): integer, string | ||
| 10 | listen: function(TCP, integer): integer, string | ||
| 11 | |||
| 12 | -- client methods | ||
| 13 | getpeername: function(TCP): string, integer | ||
| 14 | |||
| 15 | enum TCPReceivePattern | ||
| 16 | "*l" | ||
| 17 | "*a" | ||
| 18 | end | ||
| 19 | enum TCPReceiveError | ||
| 20 | "closed" | ||
| 21 | "timeout" | ||
| 22 | end | ||
| 23 | receive: function(TCP, TCPReceivePattern|integer, string): string, TCPReceiveError | ||
| 24 | |||
| 25 | send: function(TCP, string, integer, integer): integer, string, integer | ||
| 26 | |||
| 27 | enum TCPShutdownMode | ||
| 28 | "both" | ||
| 29 | "send" | ||
| 30 | "receive" | ||
| 31 | end | ||
| 32 | shutdown: function(TCP, TCPShutdownMode): integer | ||
| 33 | |||
| 34 | -- server methods | ||
| 35 | accept: function(TCP): TCP, string | ||
| 36 | |||
| 37 | -- client and server methods | ||
| 38 | enum TCPOption | ||
| 39 | "keepalive" | ||
| 40 | "reuseaddr" | ||
| 41 | "tcp-nodelay" | ||
| 42 | end | ||
| 43 | enum TCPLinger | ||
| 44 | "linger" | ||
| 45 | end | ||
| 46 | record TCPLingerOption | ||
| 47 | on: boolean | ||
| 48 | timeout: integer | ||
| 49 | end | ||
| 50 | setoption: function(TCP, TCPOption): integer | ||
| 51 | setoption: function(TCP, TCPLinger, TCPLingerOption): integer | ||
| 52 | |||
| 53 | -- master, client, and server methods | ||
| 54 | close: function(TCP) | ||
| 55 | |||
| 56 | getsockname: function(TCP): string, integer | ||
| 57 | |||
| 58 | getstats: function(TCP): integer, integer, integer | ||
| 59 | |||
| 60 | setstats: function(TCP, integer, integer, integer): integer | ||
| 61 | |||
| 62 | enum TCPTimeoutMode | ||
| 63 | "b" | ||
| 64 | "t" | ||
| 65 | end | ||
| 66 | settimeout: function(TCP, integer, TCPTimeoutMode) | ||
| 67 | end | ||
| 68 | record UDP | ||
| 69 | close: function(UDP) | ||
| 70 | |||
| 71 | getpeername: function(UDP): string, integer | ||
| 72 | |||
| 73 | getsockname: function(UDP): string, integer | ||
| 74 | |||
| 75 | enum UDPTimeout | ||
| 76 | "timeout" | ||
| 77 | end | ||
| 78 | receive: function(UDP, integer): string, UDPTimeout | ||
| 79 | |||
| 80 | receivefrom: function(UDP, integer): string, string, integer, UDPTimeout | ||
| 81 | |||
| 82 | send: function(UDP, string): integer, string | ||
| 83 | |||
| 84 | sendto: function(UDP, string, string, integer): integer, string | ||
| 85 | |||
| 86 | setpeername: function(UDP, string, integer): integer, string | ||
| 87 | |||
| 88 | setsockname: function(UDP, string, integer): integer, string | ||
| 89 | |||
| 90 | enum UDPOptions | ||
| 91 | "dontroute" | ||
| 92 | "broadcast" | ||
| 93 | end | ||
| 94 | setoption: function(UDP, UDPOptions, boolean): integer, string | ||
| 95 | |||
| 96 | settimeout: function(UDP, integer) | ||
| 97 | end | ||
| 98 | tcp: function(): TCP, string | ||
| 99 | |||
| 100 | udp: function(): UDP, string | ||
| 101 | |||
| 102 | record dns | ||
| 103 | record DNSResolved | ||
| 104 | name: string | ||
| 105 | alias: {string} | ||
| 106 | ip: {string} | ||
| 107 | end | ||
| 108 | toip: function(): string | ||
| 109 | tohostname: function(string): string, DNSResolved|string | ||
| 110 | gethostname: function(string): string, DNSResolved|string | ||
| 111 | end | ||
| 112 | |||
| 113 | bind: function(string, integer, integer): TCP | ||
| 114 | |||
| 115 | connect: function(string, integer, string, integer): TCP | ||
| 116 | |||
| 117 | _DEBUG: boolean | ||
| 118 | |||
| 119 | newtry: function(function): function | ||
| 120 | |||
| 121 | protect: function(function): function | ||
| 122 | |||
| 123 | -- tagged records/Table Union types would be nice here, | ||
| 124 | -- as this should be {TCP|UDP} | ||
| 125 | -- but I imagine this should be fine for most uses | ||
| 126 | select: function({UDP}, {UDP}, integer): {UDP}, {UDP}, string | ||
| 127 | select: function({TCP}, {TCP}, integer): {TCP}, {TCP}, string | ||
| 128 | |||
| 129 | enum SinkMode | ||
| 130 | "http-chunked" | ||
| 131 | "close-when-done" | ||
| 132 | "keep-open" | ||
| 133 | end | ||
| 134 | |||
| 135 | sink: function(SinkMode, UDP): Sink | ||
| 136 | sink: function(SinkMode, TCP): Sink | ||
| 137 | |||
| 138 | skip: function(integer, ...: any): any... | ||
| 139 | |||
| 140 | sleep: function(integer) | ||
| 141 | |||
| 142 | enum SourceMode | ||
| 143 | "http-chunked" | ||
| 144 | "by-length" | ||
| 145 | "until-closed" | ||
| 146 | end | ||
| 147 | |||
| 148 | source: function(SourceMode, TCP, integer): Source | ||
| 149 | source: function(SourceMode, UDP, integer): Source | ||
| 150 | |||
| 151 | gettime: function(): integer | ||
| 152 | |||
| 153 | try: function(...: any): any... | ||
| 154 | |||
| 155 | _VERSION: string | ||
| 156 | end | ||
| 157 | |||
| 158 | return socket \ No newline at end of file | ||
diff --git a/types/socket/http.d.tl b/types/socket/http.d.tl new file mode 100644 index 00000000..2a64872e --- /dev/null +++ b/types/socket/http.d.tl | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | local ltn12 = require("ltn12") | ||
| 2 | local type Pump = ltn12.Pump | ||
| 3 | local type Sink = ltn12.Sink | ||
| 4 | local type Source = ltn12.Source | ||
| 5 | |||
| 6 | local record http | ||
| 7 | request: function(string): string, integer|string, string, string | ||
| 8 | request: function(string, string): string, integer|string, string, string | ||
| 9 | record HTTPRequest | ||
| 10 | url: string | ||
| 11 | sink: Sink | ||
| 12 | method: string | ||
| 13 | headers: {string:string} | ||
| 14 | source: Source | ||
| 15 | step: Pump | ||
| 16 | proxy: string | ||
| 17 | redirect: boolean | ||
| 18 | create: function | ||
| 19 | end | ||
| 20 | request: function(HTTPRequest): string, integer|string, string, string | ||
| 21 | |||
| 22 | PORT: integer | ||
| 23 | PROXY: string | ||
| 24 | TIMEOUT: integer | ||
| 25 | USERAGENT: string | ||
| 26 | end | ||
| 27 | |||
| 28 | return http \ No newline at end of file | ||
diff --git a/types/ssl.d.tl b/types/ssl.d.tl new file mode 100644 index 00000000..1bd40348 --- /dev/null +++ b/types/ssl.d.tl | |||
| @@ -0,0 +1,113 @@ | |||
| 1 | local socket = require("socket") | ||
| 2 | local TCP = socket.TCP | ||
| 3 | |||
| 4 | local record ssl | ||
| 5 | record SSLCertificate | ||
| 6 | certificate: string | ||
| 7 | key: string | ||
| 8 | password: string|function | ||
| 9 | end | ||
| 10 | record SSLContext | ||
| 11 | mode: string | ||
| 12 | protocol: string | ||
| 13 | key: string | ||
| 14 | password: string|function | ||
| 15 | certificate: string | ||
| 16 | certificates: {SSLCertificate} | ||
| 17 | cafile: string | ||
| 18 | capath: string | ||
| 19 | verify: string|{string} | ||
| 20 | options: string|{string} | ||
| 21 | ciphers: string | ||
| 22 | ciphersuites: string | ||
| 23 | depth: number | ||
| 24 | dhparam: function | ||
| 25 | curve: string | ||
| 26 | curves_list: string | ||
| 27 | verifyext: string|{string} | ||
| 28 | alpn: string|function|{string} | ||
| 29 | dane: boolean | ||
| 30 | end | ||
| 31 | record X509Certificate | ||
| 32 | enum Algorithm | ||
| 33 | "sha1" | ||
| 34 | "sha256" | ||
| 35 | "sha512" | ||
| 36 | end | ||
| 37 | digest: function(X509Certificate, Algorithm): string | ||
| 38 | extensions: function(X509Certificate): {string} | ||
| 39 | issued: function(X509Certificate, X509Certificate): string | ||
| 40 | issuer: function(X509Certificate): string | ||
| 41 | notbefore: function(X509Certificate): string | ||
| 42 | notafter: function(X509Certificate): string | ||
| 43 | pem: function(X509Certificate): string | ||
| 44 | pubkey: function(X509Certificate): string | ||
| 45 | serial: function(X509Certificate): string | ||
| 46 | enum Encoding | ||
| 47 | "ai5" | ||
| 48 | "utf8" | ||
| 49 | end | ||
| 50 | setencode: function(X509Certificate, Encoding): string | ||
| 51 | subject: function(X509Certificate): string | ||
| 52 | validat: function(X509Certificate, string): boolean | ||
| 53 | end | ||
| 54 | record SSLConnection | ||
| 55 | close: function(SSLConnection) | ||
| 56 | dohandshake: function(SSLConnection): boolean, string | ||
| 57 | getalpn: function(SSLConnection): string | ||
| 58 | getfinished: function(SSLConnection): string | ||
| 59 | getpeercertificate: function(SSLConnection): X509Certificate | ||
| 60 | getpeercertificate: function(SSLConnection, number): X509Certificate | ||
| 61 | getpeerchain: function(SSLConnection): X509Certificate | ||
| 62 | getpeerverification: function(SSLConnection): string | ||
| 63 | getpeerfinished: function(SSLConnection): string | ||
| 64 | getsniname: function(SSLConnection): string | ||
| 65 | getstats: function(SSLConnection): number, number, number | ||
| 66 | info: function(SSLConnection): table | ||
| 67 | info: function(SSLConnection, string): string | ||
| 68 | enum ReceivePattern | ||
| 69 | "*a" | ||
| 70 | "*l" | ||
| 71 | end | ||
| 72 | receive: function(SSLConnection, number|ReceivePattern): string, string | ||
| 73 | receive: function(SSLConnection, number|ReceivePattern, string): string, string | ||
| 74 | send: function(SSLConnection): number, number|string, number | ||
| 75 | send: function(SSLConnection, number): number, number|string, number | ||
| 76 | send: function(SSLConnection, number, number): number, number|string, number | ||
| 77 | setdane: function(SSLConnection, string) | ||
| 78 | setstats: function(SSLConnection, number, number, number): number | ||
| 79 | enum TimeoutMode | ||
| 80 | "b" | ||
| 81 | "t" | ||
| 82 | end | ||
| 83 | settimeout: function(SSLConnection, number) | ||
| 84 | settimeout: function(SSLConnection, number, TimeoutMode) | ||
| 85 | settlsa: function(SSLConnection, number, number, number, number) | ||
| 86 | sni: function(SSLConnection, string) | ||
| 87 | sni: function(SSLConnection, {string:SSLContext}) | ||
| 88 | sni: function(SSLConnection, {string:SSLContext}, boolean) | ||
| 89 | enum Reason | ||
| 90 | "read" | ||
| 91 | "write" | ||
| 92 | "nothing" | ||
| 93 | end | ||
| 94 | want: function(SSLConnection): Reason | ||
| 95 | end | ||
| 96 | |||
| 97 | record config | ||
| 98 | protocols: {string:boolean} | ||
| 99 | curves: {string:boolean} | ||
| 100 | capabilities: {string:boolean} | ||
| 101 | options: {string:boolean} | ||
| 102 | algorithms: {string:boolean} | ||
| 103 | end | ||
| 104 | |||
| 105 | newcontext: function(SSLContext): SSLContext | ||
| 106 | wrap: function(TCP, SSLContext): SSLConnection | ||
| 107 | loadcertificate: function(string): X509Certificate | ||
| 108 | |||
| 109 | _COPYRIGHT: string | ||
| 110 | _VERSION: string | ||
| 111 | end | ||
| 112 | |||
| 113 | return ssl \ No newline at end of file | ||
diff --git a/types/ssl/https.d.tl b/types/ssl/https.d.tl new file mode 100644 index 00000000..94c38df6 --- /dev/null +++ b/types/ssl/https.d.tl | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | local ssl = require("ssl") | ||
| 2 | local SSLCertificate = ssl.SSLCertificate | ||
| 3 | local SSLConnection = ssl.SSLConnection | ||
| 4 | |||
| 5 | local ltn12 = require("ltn12") | ||
| 6 | local Pump = ltn12.Pump | ||
| 7 | local Sink = ltn12.Sink | ||
| 8 | local Source = ltn12.Source | ||
| 9 | |||
| 10 | local record https | ||
| 11 | record HTTPSRequest | ||
| 12 | -- HTTP options | ||
| 13 | url: string|{string} | ||
| 14 | sink: Sink<string> | ||
| 15 | method: string | ||
| 16 | headers: {string:string} | ||
| 17 | source: Source<string> | ||
| 18 | step: Pump<string> | ||
| 19 | -- proxy: string -- not supported | ||
| 20 | -- redirect: boolean -- not supported | ||
| 21 | -- create: function -- https implements its own | ||
| 22 | |||
| 23 | -- SSL options | ||
| 24 | mode: string | ||
| 25 | protocol: string | ||
| 26 | key: string | ||
| 27 | password: string|function | ||
| 28 | certificate: string | ||
| 29 | certificates: {SSLCertificate} | ||
| 30 | cafile: string | ||
| 31 | capath: string | ||
| 32 | verify: string|{string} | ||
| 33 | options: string|{string} | ||
| 34 | ciphers: string | ||
| 35 | ciphersuites: string | ||
| 36 | depth: number | ||
| 37 | dhparam: function | ||
| 38 | curve: string | ||
| 39 | curves_list: string | ||
| 40 | verifyext: string|{string} | ||
| 41 | alpn: string|function|{string} | ||
| 42 | dane: boolean | ||
| 43 | end | ||
| 44 | request: function(string): string, number, {string:string}, string | ||
| 45 | request: function(string, string): string, number, {string:string}, string | ||
| 46 | request: function(HTTPSRequest): string, number, {string:string}, string | ||
| 47 | tcp: function(): function(): SSLConnection | ||
| 48 | end | ||
| 49 | |||
| 50 | return https \ No newline at end of file | ||
diff --git a/types/zlib.d.tl b/types/zlib.d.tl new file mode 100644 index 00000000..cd08a721 --- /dev/null +++ b/types/zlib.d.tl | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | local record zlib | ||
| 2 | _VERSION: string | ||
| 3 | deflate: function(integer, integer): function(string, string): string | ||
| 4 | inflate: function(integer): function(string): string | ||
| 5 | crc32: function(): function(string): integer | ||
| 6 | compress: function(string, integer, integer, integer): string | ||
| 7 | decompress: function(string, integer): string | ||
| 8 | crc32: function((function(string): integer), string): integer | ||
| 9 | end | ||
| 10 | return zlib \ No newline at end of file | ||
