@quenty/httppromise 10.10.1 → 10.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [10.10.2](https://github.com/Quenty/NevermoreEngine/compare/@quenty/httppromise@10.10.1...@quenty/httppromise@10.10.2) (2025-04-05)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Add types to packages ([2374fb2](https://github.com/Quenty/NevermoreEngine/commit/2374fb2b043cfbe0e9b507b3316eec46a4e353a0))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [10.10.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/httppromise@10.10.0...@quenty/httppromise@10.10.1) (2025-03-21)
7
18
 
8
19
  **Note:** Version bump only for package @quenty/httppromise
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/httppromise",
3
- "version": "10.10.1",
3
+ "version": "10.10.2",
4
4
  "description": "HttpPromise - Wrapper functions around http requests in Roblox.",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -27,11 +27,11 @@
27
27
  "Quenty"
28
28
  ],
29
29
  "dependencies": {
30
- "@quenty/loader": "^10.8.0",
31
- "@quenty/promise": "^10.10.1"
30
+ "@quenty/loader": "^10.8.1",
31
+ "@quenty/promise": "^10.10.2"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
- "gitHead": "6b7c3e15e60cdb185986207b574e2b5591261e7a"
36
+ "gitHead": "78c3ac0ab08dd18085b6e6e6e4f745e76ed99f68"
37
37
  }
@@ -1,3 +1,4 @@
1
+ --!strict
1
2
  --[=[
2
3
  Provides a wrapper around HttpService with a promise API
3
4
 
@@ -32,6 +33,22 @@ local DEBUG_RESPONSE = false
32
33
 
33
34
  local HttpPromise = {}
34
35
 
36
+ export type HTTPRequest = {
37
+ Url: string,
38
+ Method: "POST" | "GET" | "PUT" | "DELETE",
39
+ Headers: { [string]: string }?,
40
+ Body: string?,
41
+ Compress: Enum.HttpCompression?,
42
+ }
43
+
44
+ export type HTTPResponse = {
45
+ Success: boolean,
46
+ StatusCode: number,
47
+ StatusMessage: string,
48
+ Headers: { [string]: string },
49
+ Body: string,
50
+ }
51
+
35
52
  --[=[
36
53
  Decodes JSON from the response
37
54
 
@@ -46,10 +63,10 @@ local HttpPromise = {}
46
63
  })
47
64
  ```
48
65
 
49
- @param request table
66
+ @param request HTTPRequest
50
67
  @return Promise<table>
51
68
  ]=]
52
- function HttpPromise.request(request)
69
+ function HttpPromise.request(request: HTTPRequest): Promise.Promise<()>
53
70
  if DEBUG_REQUEST then
54
71
  print("Sending request", HttpService:JSONEncode(request))
55
72
  end
@@ -85,7 +102,7 @@ end
85
102
  @param value any
86
103
  @return boolean
87
104
  ]=]
88
- function HttpPromise.isHttpResponse(value)
105
+ function HttpPromise.isHttpResponse(value: any): boolean
89
106
  return type(value) == "table"
90
107
  and type(value.Success) == "boolean"
91
108
  and type(value.StatusCode) == "number"
@@ -100,7 +117,7 @@ end
100
117
  @param value HttpResponse
101
118
  @return string
102
119
  ]=]
103
- function HttpPromise.convertHttpResponseToString(value)
120
+ function HttpPromise.convertHttpResponseToString(value: HTTPResponse): string
104
121
  assert(HttpPromise.isHttpResponse(value), "Bad value")
105
122
 
106
123
  return string.format("%d: %s - %s", value.StatusCode, value.StatusMessage, value.Body)
@@ -117,16 +134,18 @@ end
117
134
  @param request table | string
118
135
  @return Promise<table>
119
136
  ]=]
120
- function HttpPromise.json(request)
137
+ function HttpPromise.json(request: HTTPRequest | string): Promise.Promise<any>
138
+ local finalRequest: HTTPRequest
121
139
  if type(request) == "string" then
122
- request = {
123
- Method = "GET";
124
- Url = request;
140
+ finalRequest = {
141
+ Method = "GET",
142
+ Url = request,
125
143
  }
144
+ else
145
+ finalRequest = request
126
146
  end
127
147
 
128
- return HttpPromise.request(request)
129
- :Then(HttpPromise.decodeJson)
148
+ return HttpPromise.request(finalRequest):Then(HttpPromise.decodeJson)
130
149
  end
131
150
 
132
151
  --[=[
@@ -140,7 +159,7 @@ end
140
159
  @param ... any -- A list of requests to retrieve. Meant to be used
141
160
  ]=]
142
161
  function HttpPromise.logFailedRequests(...)
143
- for _, item in pairs({...}) do
162
+ for _, item in { ... } do
144
163
  if type(item) == "string" then
145
164
  warn(item)
146
165
  elseif type(item) == "table" and type(item.StatusCode) == "number" then
@@ -155,7 +174,7 @@ end
155
174
  @param response { Body: string }
156
175
  @return table
157
176
  ]=]
158
- function HttpPromise.decodeJson(response)
177
+ function HttpPromise.decodeJson(response: HTTPResponse)
159
178
  assert(response, "Bad response")
160
179
 
161
180
  if type(response.Body) ~= "string" then