@torpor/build 0.4.14 → 1.0.0

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.
Files changed (176) hide show
  1. package/README.md +20 -2
  2. package/dist/Jsonify-Dg6gChd3.d.mts +10 -0
  3. package/dist/Jsonify-Dg6gChd3.d.mts.map +1 -0
  4. package/dist/ParseRouteParams-DBmqlmLh.d.mts +42 -0
  5. package/dist/ParseRouteParams-DBmqlmLh.d.mts.map +1 -0
  6. package/dist/{RouteType-B6BMOyYw.mjs → Router-C4ADUfhv.mjs} +30 -42
  7. package/dist/Router-C4ADUfhv.mjs.map +1 -0
  8. package/dist/{Server-CF5wDJp6.d.mts → Server-C_IKav_e.d.mts} +44 -16
  9. package/dist/Server-C_IKav_e.d.mts.map +1 -0
  10. package/dist/{ServerEvent-CxPwA4lH.mjs → ServerEvent-Dljn5i7A.mjs} +37 -11
  11. package/dist/ServerEvent-Dljn5i7A.mjs.map +1 -0
  12. package/dist/Site-CMa153FA.d.mts +565 -0
  13. package/dist/Site-CMa153FA.d.mts.map +1 -0
  14. package/dist/StandardSchema-D28L8_zZ.d.mts +100 -0
  15. package/dist/StandardSchema-D28L8_zZ.d.mts.map +1 -0
  16. package/dist/TypedResponse-6lznqN4U.d.mts +22 -0
  17. package/dist/TypedResponse-6lznqN4U.d.mts.map +1 -0
  18. package/dist/{_page-BQs4WvCO.mjs → _page-4cQKs_Dn.mjs} +3 -5
  19. package/dist/_page-4cQKs_Dn.mjs.map +1 -0
  20. package/dist/bin/index.d.mts +1 -1
  21. package/dist/bin/index.js +15 -11
  22. package/dist/bin/index.js.map +1 -1
  23. package/dist/flattenHeaders-C_YYLdOq.mjs +114 -0
  24. package/dist/flattenHeaders-C_YYLdOq.mjs.map +1 -0
  25. package/dist/form.d.mts +35 -0
  26. package/dist/form.d.mts.map +1 -0
  27. package/dist/form.mjs +48 -0
  28. package/dist/form.mjs.map +1 -0
  29. package/dist/index.d.mts +72 -156
  30. package/dist/index.d.mts.map +1 -1
  31. package/dist/index.mjs +158 -26
  32. package/dist/index.mjs.map +1 -1
  33. package/dist/nav.d.mts +58 -5
  34. package/dist/nav.d.mts.map +1 -1
  35. package/dist/nav.mjs +116 -38
  36. package/dist/nav.mjs.map +1 -1
  37. package/dist/openapi.d.mts +144 -0
  38. package/dist/openapi.d.mts.map +1 -0
  39. package/dist/openapi.mjs +2 -0
  40. package/dist/pathTrie-D4Ax2Mu9.mjs +160 -0
  41. package/dist/pathTrie-D4Ax2Mu9.mjs.map +1 -0
  42. package/dist/plugin-D8Www11B.mjs +202 -0
  43. package/dist/plugin-D8Www11B.mjs.map +1 -0
  44. package/dist/{response-C5TtAsh1.mjs → response-Bg4w2S1q.mjs} +16 -39
  45. package/dist/response-Bg4w2S1q.mjs.map +1 -0
  46. package/dist/response.d.mts +309 -289
  47. package/dist/response.d.mts.map +1 -1
  48. package/dist/response.mjs +3 -4
  49. package/dist/run.d.mts +11 -4
  50. package/dist/run.d.mts.map +1 -1
  51. package/dist/run.mjs +2 -8
  52. package/dist/runOpenApi-BUi1RH1l.mjs +1381 -0
  53. package/dist/runOpenApi-BUi1RH1l.mjs.map +1 -0
  54. package/dist/schema.d.mts +32 -0
  55. package/dist/schema.d.mts.map +1 -0
  56. package/dist/schema.mjs +2 -0
  57. package/dist/server.d.mts +10 -8
  58. package/dist/server.d.mts.map +1 -1
  59. package/dist/server.mjs +132 -4
  60. package/dist/server.mjs.map +1 -0
  61. package/dist/state.d.mts.map +1 -1
  62. package/dist/state.mjs +2 -3
  63. package/dist/test.d.mts +8 -10
  64. package/dist/test.d.mts.map +1 -1
  65. package/dist/test.mjs +283 -79
  66. package/dist/test.mjs.map +1 -1
  67. package/dist/{seeOther-B4Yhu9iq.mjs → unprocessable-DAZbrDeR.mjs} +34 -13
  68. package/dist/unprocessable-DAZbrDeR.mjs.map +1 -0
  69. package/dist/validate-Ok4krlkX.mjs +40 -0
  70. package/dist/validate-Ok4krlkX.mjs.map +1 -0
  71. package/package.json +28 -17
  72. package/src/bin/index.ts +13 -2
  73. package/src/dev.ts +10 -0
  74. package/src/form/formDataToRecord.ts +23 -0
  75. package/src/form/readForm.ts +71 -0
  76. package/src/form.ts +4 -0
  77. package/src/index.ts +53 -1
  78. package/src/nav/api.test-d.ts +79 -0
  79. package/src/nav/api.ts +104 -0
  80. package/src/nav/formSubmit.ts +18 -4
  81. package/src/nav/navigate.ts +40 -15
  82. package/src/nav/route.ts +38 -0
  83. package/src/nav.ts +3 -1
  84. package/src/openapi/docsHtml.ts +25 -0
  85. package/src/openapi/document.ts +154 -0
  86. package/src/openapi/plugin.ts +78 -0
  87. package/src/openapi/types.ts +82 -0
  88. package/src/openapi.ts +14 -0
  89. package/src/response/TypedResponse.ts +17 -0
  90. package/src/response/badRequest.ts +14 -2
  91. package/src/response/created.ts +13 -2
  92. package/src/response/found.ts +2 -2
  93. package/src/response/movedPermanently.ts +2 -2
  94. package/src/response/notModified.ts +2 -2
  95. package/src/response/ok.ts +13 -4
  96. package/src/response/response.ts +4 -4
  97. package/src/response/unprocessable.ts +14 -2
  98. package/src/run/depCache.ts +175 -0
  99. package/src/run/devPlugin.ts +128 -0
  100. package/src/run/prepareTemplate.ts +6 -3
  101. package/src/run/run.ts +63 -39
  102. package/src/run/runBuild.ts +63 -12
  103. package/src/run/runDev.ts +146 -58
  104. package/src/run/runOpenApi.ts +52 -0
  105. package/src/run/runPreview.ts +17 -26
  106. package/src/run/staleTorpCopies.ts +100 -0
  107. package/src/run.ts +2 -1
  108. package/src/schema.ts +7 -0
  109. package/src/server/CookieHelper.ts +17 -7
  110. package/src/server/Server.ts +54 -30
  111. package/src/server/ServerEvent.ts +24 -1
  112. package/src/server/connect/connectMiddleware.ts +44 -40
  113. package/src/server/connect/flattenHeaders.ts +1 -23
  114. package/src/server/connect/requestToNodeMessage.ts +6 -3
  115. package/src/server/types/MiddlewareFunction.ts +18 -4
  116. package/src/site/Router.ts +52 -41
  117. package/src/site/Site.ts +184 -10
  118. package/src/site/checkLayoutSlots.ts +114 -0
  119. package/src/site/checkRoutes.ts +435 -0
  120. package/src/site/clientEntry.ts +22 -9
  121. package/src/site/layoutSlots.ts +53 -0
  122. package/src/site/manifest.ts +125 -6
  123. package/src/site/serverEntry.ts +341 -132
  124. package/src/state/$page.ts +2 -1
  125. package/src/state/$serverPage.ts +22 -0
  126. package/src/test/runTest.ts +306 -118
  127. package/src/types/Adapter.ts +12 -0
  128. package/src/types/Jsonify.ts +20 -0
  129. package/src/types/PageData.test-d.ts +136 -0
  130. package/src/types/PageData.ts +35 -0
  131. package/src/types/PageEndPoint.ts +25 -9
  132. package/src/types/PageForm.test-d.ts +78 -0
  133. package/src/types/PageForm.ts +29 -0
  134. package/src/types/PageLoadEvent.ts +16 -4
  135. package/src/types/PageLoadReturn.ts +13 -0
  136. package/src/types/PageProps.ts +14 -0
  137. package/src/types/PageServerAction.ts +8 -2
  138. package/src/types/PageServerEndPoint.test-d.ts +105 -0
  139. package/src/types/PageServerEndPoint.ts +99 -5
  140. package/src/types/PageServerLoad.ts +11 -3
  141. package/src/types/ParseRouteParams.test-d.ts +84 -0
  142. package/src/types/ParseRouteParams.ts +64 -0
  143. package/src/types/Route.ts +20 -1
  144. package/src/types/RouteHandler.ts +8 -1
  145. package/src/types/ServerEndPoint.test-d.ts +77 -0
  146. package/src/types/ServerEndPoint.ts +148 -16
  147. package/src/types/ServerHook.ts +10 -3
  148. package/src/types/ServerLoadEvent.ts +48 -3
  149. package/src/types/ServerRequest.ts +10 -2
  150. package/src/types/SitePlugin.ts +24 -0
  151. package/src/types/StandardSchema.ts +109 -0
  152. package/src/utils/pathToRegex.ts +4 -2
  153. package/src/utils/pathTrie.ts +182 -0
  154. package/src/utils/searchParamsToRecord.ts +18 -0
  155. package/src/utils/torporPackages.ts +150 -0
  156. package/src/utils/tsconfigAliases.ts +90 -0
  157. package/src/validation/ValidationError.ts +18 -0
  158. package/src/validation/endpoint.ts +83 -0
  159. package/src/validation/validate.ts +26 -0
  160. package/dist/RouteType-B6BMOyYw.mjs.map +0 -1
  161. package/dist/Server-CF5wDJp6.d.mts.map +0 -1
  162. package/dist/ServerEvent-CxPwA4lH.mjs.map +0 -1
  163. package/dist/Site-DgC6WWn1.d.mts +0 -78
  164. package/dist/Site-DgC6WWn1.d.mts.map +0 -1
  165. package/dist/_page-BQs4WvCO.mjs.map +0 -1
  166. package/dist/connectMiddleware-D7nehjj3.mjs +0 -252
  167. package/dist/connectMiddleware-D7nehjj3.mjs.map +0 -1
  168. package/dist/pathToRegex-TUAMc3zS.mjs +0 -11
  169. package/dist/pathToRegex-TUAMc3zS.mjs.map +0 -1
  170. package/dist/response-C5TtAsh1.mjs.map +0 -1
  171. package/dist/run-BPFtSYA3.mjs +0 -332
  172. package/dist/run-BPFtSYA3.mjs.map +0 -1
  173. package/dist/seeOther-B4Yhu9iq.mjs.map +0 -1
  174. package/src/server/Routerx.ts +0 -72
  175. package/src/server/connect/bufferToArrayBuffer.ts +0 -8
  176. package/src/server/connect/readableToBuffer.ts +0 -16
@@ -1,351 +1,371 @@
1
+ import { t as TypedResponse } from "./TypedResponse-6lznqN4U.mjs";
2
+ import { t as Jsonify } from "./Jsonify-Dg6gChd3.mjs";
1
3
  //#region src/response/badRequest.d.ts
4
+ type BadRequestResponse<T extends object | string | undefined> = T extends object ? TypedResponse<Jsonify<T>> : Response;
2
5
  /**
3
- * 400 Bad Request
4
- *
5
- * The HTTP 400 Bad Request client error response status code indicates that the
6
- * server would not process the request due to something the server considered
7
- * to be a client error. The reason for a 400 response is typically due to
8
- * malformed request syntax, invalid request message framing, or deceptive
9
- * request routing.
10
- *
11
- * Clients that receive a 400 response should expect that repeating the request
12
- * without modification will fail with the same error.
13
- *
14
- * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/400
15
- */
16
- declare function badRequest(body?: object | string): Response;
6
+ * 400 Bad Request
7
+ *
8
+ * The HTTP 400 Bad Request client error response status code indicates that the
9
+ * server would not process the request due to something the server considered
10
+ * to be a client error. The reason for a 400 response is typically due to
11
+ * malformed request syntax, invalid request message framing, or deceptive
12
+ * request routing.
13
+ *
14
+ * Clients that receive a 400 response should expect that repeating the request
15
+ * without modification will fail with the same error.
16
+ *
17
+ * An object body is typed: it becomes the page's `$props.form` (with its JSON
18
+ * form) after a form submit, so validation errors can be surfaced with their
19
+ * field types via `PageForm`.
20
+ *
21
+ * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/400
22
+ */
23
+ declare function badRequest<T extends object | string | undefined>(body?: T): BadRequestResponse<T>;
17
24
  //#endregion
18
25
  //#region src/response/created.d.ts
26
+ type CreatedResponse<T extends object | string | undefined> = T extends object ? TypedResponse<Jsonify<T>> : Response;
19
27
  /**
20
- * 201 Created
21
- *
22
- * The HTTP 201 Created successful response status code indicates that the HTTP
23
- * request has led to the creation of a resource. This status code is commonly
24
- * sent as the result of a POST request.
25
- *
26
- * The new resource, or a description and link to the new resource, is created
27
- * before the response is returned. The newly-created items can be returned in
28
- * the body of the response message, but must be locatable by the URL of the
29
- * initiating request or by the URL in the value of the Location header provided
30
- * with the response.
31
- *
32
- * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/201
33
- */
34
- declare function created(body?: object | string): Response;
28
+ * 201 Created
29
+ *
30
+ * The HTTP 201 Created successful response status code indicates that the HTTP
31
+ * request has led to the creation of a resource. This status code is commonly
32
+ * sent as the result of a POST request.
33
+ *
34
+ * The new resource, or a description and link to the new resource, is created
35
+ * before the response is returned. The newly-created items can be returned in
36
+ * the body of the response message, but must be locatable by the URL of the
37
+ * initiating request or by the URL in the value of the Location header provided
38
+ * with the response.
39
+ *
40
+ * An object body is typed: the client sees its JSON form through
41
+ * `makeApi`-created callers.
42
+ *
43
+ * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/201
44
+ */
45
+ declare function created<T extends object | string | undefined>(body?: T): CreatedResponse<T>;
35
46
  //#endregion
36
47
  //#region src/response/forbidden.d.ts
37
48
  /**
38
- * 403 Forbidden
39
- *
40
- * The HTTP 403 Forbidden client error response status code indicates that the
41
- * server understood the request but refused to process it. This status is
42
- * similar to 401, except that for 403 Forbidden responses, authenticating or
43
- * re-authenticating makes no difference. The request failure is tied to
44
- * application logic, such as insufficient permissions to a resource or action.
45
- *
46
- * Clients that receive a 403 response should expect that repeating the request
47
- * without modification will fail with the same error. Server owners may decide
48
- * to send a 404 response instead of a 403 if acknowledging the existence of a
49
- * resource to clients with insufficient privileges is not desired.
50
- *
51
- * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/403
52
- */
49
+ * 403 Forbidden
50
+ *
51
+ * The HTTP 403 Forbidden client error response status code indicates that the
52
+ * server understood the request but refused to process it. This status is
53
+ * similar to 401, except that for 403 Forbidden responses, authenticating or
54
+ * re-authenticating makes no difference. The request failure is tied to
55
+ * application logic, such as insufficient permissions to a resource or action.
56
+ *
57
+ * Clients that receive a 403 response should expect that repeating the request
58
+ * without modification will fail with the same error. Server owners may decide
59
+ * to send a 404 response instead of a 403 if acknowledging the existence of a
60
+ * resource to clients with insufficient privileges is not desired.
61
+ *
62
+ * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/403
63
+ */
53
64
  declare function forbidden(body?: object | string): Response;
54
65
  //#endregion
55
66
  //#region src/response/found.d.ts
56
67
  /**
57
- * 302 Found
58
- *
59
- * The HTTP 302 Found redirection response status code indicates that the
60
- * requested resource has been temporarily moved to the URL in the Location
61
- * header.
62
- *
63
- * A browser receiving this status will automatically request the resource at
64
- * the URL in the Location header, redirecting the user to the new page. Search
65
- * engines receiving this response will not attribute links to the original URL
66
- * to the new resource, meaning no SEO value is transferred to the new URL.
67
- *
68
- * > Note: In the Fetch Standard, when a user agent receives a 302 in response
69
- * > to a POST request, it uses the GET method in the subsequent redirection
70
- * > request, as permitted by the HTTP specification. To avoid user agents
71
- * > modifying the request, use 307 Temporary Redirect instead, as altering the
72
- * > method after a 307 response is prohibited.
73
- *
74
- * > In cases where you want any request method to be changed to GET, use 303
75
- * > See Other. This is useful when you want to give a response to a PUT method
76
- * > that is not the uploaded resource but a confirmation message such as: "you
77
- * > successfully uploaded XYZ".
78
- *
79
- * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/302
80
- */
81
- declare function permRedirect(location: string): Response;
68
+ * 302 Found
69
+ *
70
+ * The HTTP 302 Found redirection response status code indicates that the
71
+ * requested resource has been temporarily moved to the URL in the Location
72
+ * header.
73
+ *
74
+ * A browser receiving this status will automatically request the resource at
75
+ * the URL in the Location header, redirecting the user to the new page. Search
76
+ * engines receiving this response will not attribute links to the original URL
77
+ * to the new resource, meaning no SEO value is transferred to the new URL.
78
+ *
79
+ * > Note: In the Fetch Standard, when a user agent receives a 302 in response
80
+ * > to a POST request, it uses the GET method in the subsequent redirection
81
+ * > request, as permitted by the HTTP specification. To avoid user agents
82
+ * > modifying the request, use 307 Temporary Redirect instead, as altering the
83
+ * > method after a 307 response is prohibited.
84
+ *
85
+ * > In cases where you want any request method to be changed to GET, use 303
86
+ * > See Other. This is useful when you want to give a response to a PUT method
87
+ * > that is not the uploaded resource but a confirmation message such as: "you
88
+ * > successfully uploaded XYZ".
89
+ *
90
+ * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/302
91
+ */
92
+ declare function found(location: string): Response;
82
93
  //#endregion
83
94
  //#region src/response/methodNotAllowed.d.ts
84
95
  /**
85
- * 405 Method Not Allowed
86
- *
87
- * The HTTP 405 Method Not Allowed client error response status code indicates
88
- * that the server knows the request method, but the target resource doesn't
89
- * support this method. The server must generate an Allow header in a 405
90
- * response with a list of methods that the target resource currently supports.
91
- *
92
- * Improper server-side permissions set on files or directories may cause a 405
93
- * response when the request would otherwise be expected to succeed.
94
- *
95
- * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/405
96
- */
96
+ * 405 Method Not Allowed
97
+ *
98
+ * The HTTP 405 Method Not Allowed client error response status code indicates
99
+ * that the server knows the request method, but the target resource doesn't
100
+ * support this method. The server must generate an Allow header in a 405
101
+ * response with a list of methods that the target resource currently supports.
102
+ *
103
+ * Improper server-side permissions set on files or directories may cause a 405
104
+ * response when the request would otherwise be expected to succeed.
105
+ *
106
+ * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/405
107
+ */
97
108
  declare function methodNotAllowed(body?: object | string): Response;
98
109
  //#endregion
99
110
  //#region src/response/movedPermanently.d.ts
100
111
  /**
101
- * 301 Moved Permanently
102
- *
103
- * The HTTP 301 Moved Permanently redirection response status code indicates
104
- * that the requested resource has been permanently moved to the URL in the
105
- * Location header.
106
- *
107
- * A browser receiving this status will automatically request the resource at
108
- * the URL in the Location header, redirecting the user to the new page. Search
109
- * engines receiving this response will attribute links to the original URL to
110
- * the redirected resource, passing the SEO ranking to the new URL.
111
- *
112
- * > Note: In the Fetch Standard, when a user agent receives a 301 in response
113
- * > to a POST request, it uses the GET method in the subsequent redirection
114
- * > request, as permitted by the HTTP specification. To avoid user agents
115
- * > modifying the request, use 308 Permanent Redirect instead, as altering the
116
- * > method after a 308 response is prohibited.
117
- *
118
- * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/301
119
- */
120
- declare function permRedirect$1(location: string): Response;
112
+ * 301 Moved Permanently
113
+ *
114
+ * The HTTP 301 Moved Permanently redirection response status code indicates
115
+ * that the requested resource has been permanently moved to the URL in the
116
+ * Location header.
117
+ *
118
+ * A browser receiving this status will automatically request the resource at
119
+ * the URL in the Location header, redirecting the user to the new page. Search
120
+ * engines receiving this response will attribute links to the original URL to
121
+ * the redirected resource, passing the SEO ranking to the new URL.
122
+ *
123
+ * > Note: In the Fetch Standard, when a user agent receives a 301 in response
124
+ * > to a POST request, it uses the GET method in the subsequent redirection
125
+ * > request, as permitted by the HTTP specification. To avoid user agents
126
+ * > modifying the request, use 308 Permanent Redirect instead, as altering the
127
+ * > method after a 308 response is prohibited.
128
+ *
129
+ * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/301
130
+ */
131
+ declare function movedPermanently(location: string): Response;
121
132
  //#endregion
122
133
  //#region src/response/notFound.d.ts
123
134
  /**
124
- * 404 Not Found
125
- *
126
- * The HTTP 404 Not Found client error response status code indicates that the
127
- * server cannot find the requested resource. Links that lead to a 404 page are
128
- * often called broken or dead links and can be subject to link rot.
129
- *
130
- * A 404 status code only indicates that the resource is missing without
131
- * indicating if this is temporary or permanent. If a resource is permanently
132
- * removed, servers should send the 410 Gone status instead.
133
- *
134
- * 404 errors on a website can lead to a poor user experience for your visitors,
135
- * so the number of broken links (internal and external) should be minimized to
136
- * prevent frustration for readers. Common causes of 404 responses are mistyped
137
- * URLs or pages that are moved or deleted without redirection. For more
138
- * information, see the Redirections in HTTP guide.
139
- *
140
- * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/404
141
- */
135
+ * 404 Not Found
136
+ *
137
+ * The HTTP 404 Not Found client error response status code indicates that the
138
+ * server cannot find the requested resource. Links that lead to a 404 page are
139
+ * often called broken or dead links and can be subject to link rot.
140
+ *
141
+ * A 404 status code only indicates that the resource is missing without
142
+ * indicating if this is temporary or permanent. If a resource is permanently
143
+ * removed, servers should send the 410 Gone status instead.
144
+ *
145
+ * 404 errors on a website can lead to a poor user experience for your visitors,
146
+ * so the number of broken links (internal and external) should be minimized to
147
+ * prevent frustration for readers. Common causes of 404 responses are mistyped
148
+ * URLs or pages that are moved or deleted without redirection. For more
149
+ * information, see the Redirections in HTTP guide.
150
+ *
151
+ * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/404
152
+ */
142
153
  declare function notFound(body?: object | string): Response;
143
154
  //#endregion
144
155
  //#region src/response/notModified.d.ts
145
156
  /**
146
- * 304 Not Modified
147
- *
148
- * The HTTP 304 Not Modified redirection response status code indicates that
149
- * there is no need to retransmit the requested resources.
150
- *
151
- * This response code is sent when the request is a conditional GET or HEAD
152
- * request with an If-None-Match or an If-Modified-Since header and the
153
- * condition evaluates to 'false'. It confirms that the resource cached by the
154
- * client is still valid and that the server would have sent a 200 OK response
155
- * with the resource if the condition evaluated to 'true'. See HTTP caching for
156
- * more information.
157
- *
158
- * The response must not contain a body and must include the headers that would
159
- * have been sent in an equivalent 200 response, such as:
160
- *
161
- * - Cache-Control
162
- * - Content-Location
163
- * - Date
164
- * - ETag
165
- * - Expires
166
- * - Vary
167
- *
168
- * > Note: Many developer tools' network panels of browsers create extraneous
169
- * > requests leading to 304 responses, so that access to the local cache is
170
- * > visible to developers.
171
- *
172
- * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/304
173
- */
174
- declare function notModified(location: string): Response;
157
+ * 304 Not Modified
158
+ *
159
+ * The HTTP 304 Not Modified redirection response status code indicates that
160
+ * there is no need to retransmit the requested resources.
161
+ *
162
+ * This response code is sent when the request is a conditional GET or HEAD
163
+ * request with an If-None-Match or an If-Modified-Since header and the
164
+ * condition evaluates to 'false'. It confirms that the resource cached by the
165
+ * client is still valid and that the server would have sent a 200 OK response
166
+ * with the resource if the condition evaluated to 'true'. See HTTP caching for
167
+ * more information.
168
+ *
169
+ * The response must not contain a body and must include the headers that would
170
+ * have been sent in an equivalent 200 response, such as:
171
+ *
172
+ * - Cache-Control
173
+ * - Content-Location
174
+ * - Date
175
+ * - ETag
176
+ * - Expires
177
+ * - Vary
178
+ *
179
+ * > Note: Many developer tools' network panels of browsers create extraneous
180
+ * > requests leading to 304 responses, so that access to the local cache is
181
+ * > visible to developers.
182
+ *
183
+ * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/304
184
+ */
185
+ declare function notModified(): Response;
175
186
  //#endregion
176
187
  //#region src/response/ok.d.ts
188
+ type OkResponse<T extends object | string | undefined> = T extends object ? TypedResponse<Jsonify<T>> : Response;
177
189
  /**
178
- * 200 OK
179
- *
180
- * The HTTP 200 OK successful response status code indicates that a request has
181
- * succeeded. A 200 OK response is cacheable by default.
182
- *
183
- * A 200 OK response has a different meaning and format depending on the HTTP
184
- * request method. Here's how they vary for different methods:
185
- *
186
- * - GET: A resource was retrieved by the server and included in the response
187
- * body.
188
- * - POST: An action succeeded; the response has a message body describing the
189
- * result.
190
- * - HEAD: Identical to GET, except there is no message body.
191
- * - TRACE: The response has a message body containing the request as received
192
- * by the server.
193
- *
194
- * Although possible, successful PUT or DELETE requests often do not result in a
195
- * 200 OK response. It is more common to see 201 Created if the resource is
196
- * uploaded or created for the first time, or 204 No Content upon successful
197
- * deletion of a resource.
198
- *
199
- * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/200
200
- */
201
- declare function ok(body?: object | string): Response;
190
+ * 200 OK
191
+ *
192
+ * The HTTP 200 OK successful response status code indicates that a request has
193
+ * succeeded. A 200 OK response is cacheable by default.
194
+ *
195
+ * A 200 OK response has a different meaning and format depending on the HTTP
196
+ * request method. Here's how they vary for different methods:
197
+ *
198
+ * - GET: A resource was retrieved by the server and included in the response
199
+ * body.
200
+ * - POST: An action succeeded; the response has a message body describing the
201
+ * result.
202
+ * - HEAD: Identical to GET, except there is no message body.
203
+ * - TRACE: The response has a message body containing the request as received
204
+ * by the server.
205
+ *
206
+ * Although possible, successful PUT or DELETE requests often do not result in
207
+ * a 200 OK response. It is more common to see 201 Created if the resource is
208
+ * uploaded or created for the first time, or 204 No Content upon successful
209
+ * deletion of a resource.
210
+ *
211
+ * An object body is typed: the client sees its JSON form through
212
+ * `makeApi`-created callers.
213
+ *
214
+ * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/200
215
+ */
216
+ declare function ok<T extends object | string | undefined>(body?: T): OkResponse<T>;
202
217
  //#endregion
203
218
  //#region src/response/permanentRedirect.d.ts
204
219
  /**
205
- * 308 Permanent Redirect
206
- *
207
- * The HTTP 308 Permanent Redirect redirection response status code indicates
208
- * that the requested resource has been permanently moved to the URL given by
209
- * the Location header.
210
- *
211
- * A browser receiving this status will automatically request the resource at
212
- * the URL in the Location header, redirecting the user to the new page. Search
213
- * engines receiving this response will attribute links to the original URL to
214
- * the redirected resource, passing the SEO ranking to the new URL.
215
- *
216
- * The request method and the body will not be modified by the client in the
217
- * redirected request. A 301 Moved Permanently requires the request method and
218
- * the body to remain unchanged when redirection is performed, but this is
219
- * incorrectly handled by older clients to use the GET method instead.
220
- *
221
- * > Note: Some Web applications may use the 308 Permanent Redirect in a
222
- * > non-standard way and for different purposes. For example, Google Drive uses
223
- * > a 308 Resume Incomplete response to indicate to the client when an
224
- * > unfinished upload has stalled. See Perform a resumable download on the
225
- * > Google Drive documentation for more information.
226
- *
227
- * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/308
228
- */
220
+ * 308 Permanent Redirect
221
+ *
222
+ * The HTTP 308 Permanent Redirect redirection response status code indicates
223
+ * that the requested resource has been permanently moved to the URL given by
224
+ * the Location header.
225
+ *
226
+ * A browser receiving this status will automatically request the resource at
227
+ * the URL in the Location header, redirecting the user to the new page. Search
228
+ * engines receiving this response will attribute links to the original URL to
229
+ * the redirected resource, passing the SEO ranking to the new URL.
230
+ *
231
+ * The request method and the body will not be modified by the client in the
232
+ * redirected request. A 301 Moved Permanently requires the request method and
233
+ * the body to remain unchanged when redirection is performed, but this is
234
+ * incorrectly handled by older clients to use the GET method instead.
235
+ *
236
+ * > Note: Some Web applications may use the 308 Permanent Redirect in a
237
+ * > non-standard way and for different purposes. For example, Google Drive uses
238
+ * > a 308 Resume Incomplete response to indicate to the client when an
239
+ * > unfinished upload has stalled. See Perform a resumable download on the
240
+ * > Google Drive documentation for more information.
241
+ *
242
+ * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/308
243
+ */
229
244
  declare function permanentRedirect(location: string): Response;
230
245
  //#endregion
231
246
  //#region src/response/response.d.ts
232
247
  /**
233
- * Creates a response with the supplied status code and optional body.
234
- *
235
- * If the body is an object, it will be converted to JSON and the content-type
236
- * header set to "application/json". Otherwise, if the body is a string, the
237
- * content-type header will be set to "text/plain".
238
- */
248
+ * Creates a response with the supplied status code and optional body.
249
+ *
250
+ * If the body is an object, it will be converted to JSON and the Content-Type
251
+ * header set to "application/json". Otherwise, if the body is a string, the
252
+ * Content-Type header will be set to "text/plain".
253
+ */
239
254
  declare function response(status: number, body?: object | string): Response;
240
255
  //#endregion
241
256
  //#region src/response/seeOther.d.ts
242
257
  /**
243
- * 303 See Other
244
- *
245
- * The HTTP 303 See Other redirection response status code indicates that the
246
- * browser should redirect to the URL in the Location header instead of
247
- * rendering the requested resource.
248
- *
249
- * This response code is often sent back as a result of PUT or POST methods so
250
- * the client may retrieve a confirmation, or view a representation of a
251
- * real-world object (see HTTP range-14). The method to retrieve the redirected
252
- * resource is always GET.
253
- *
254
- * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/303
255
- */
258
+ * 303 See Other
259
+ *
260
+ * The HTTP 303 See Other redirection response status code indicates that the
261
+ * browser should redirect to the URL in the Location header instead of
262
+ * rendering the requested resource.
263
+ *
264
+ * This response code is often sent back as a result of PUT or POST methods so
265
+ * the client may retrieve a confirmation, or view a representation of a
266
+ * real-world object (see HTTP range-14). The method to retrieve the redirected
267
+ * resource is always GET.
268
+ *
269
+ * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/303
270
+ */
256
271
  declare function seeOther(location: string): Response;
257
272
  //#endregion
258
273
  //#region src/response/serverError.d.ts
259
274
  /**
260
- * 500 Server Error
261
- *
262
- * The HTTP 500 Internal Server Error server error response status code
263
- * indicates that the server encountered an unexpected condition that prevented
264
- * it from fulfilling the request. This error is a generic "catch-all" response
265
- * to server issues, indicating that the server cannot find a more appropriate
266
- * 5XX error to respond with.
267
- *
268
- * If you're a visitor seeing 500 errors on a web page, these issues require
269
- * investigation by server owners or administrators. There are many possible
270
- * causes of 500 errors, including: improper server configuration, out-of-memory
271
- * (OOM) issues, unhandled exceptions, improper file permissions, or other
272
- * complex factors. Server administrators may proactively log occurrences of
273
- * server error responses, like the 500 status code, with details about the
274
- * initiating requests to improve the stability of a service in the future.
275
- *
276
- * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/500
277
- */
275
+ * 500 Server Error
276
+ *
277
+ * The HTTP 500 Internal Server Error server error response status code
278
+ * indicates that the server encountered an unexpected condition that prevented
279
+ * it from fulfilling the request. This error is a generic "catch-all" response
280
+ * to server issues, indicating that the server cannot find a more appropriate
281
+ * 5XX error to respond with.
282
+ *
283
+ * If you're a visitor seeing 500 errors on a web page, these issues require
284
+ * investigation by server owners or administrators. There are many possible
285
+ * causes of 500 errors, including: improper server configuration, out-of-memory
286
+ * (OOM) issues, unhandled exceptions, improper file permissions, or other
287
+ * complex factors. Server administrators may proactively log occurrences of
288
+ * server error responses, like the 500 status code, with details about the
289
+ * initiating requests to improve the stability of a service in the future.
290
+ *
291
+ * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/500
292
+ */
278
293
  declare function serverError(body?: object | string): Response;
279
294
  //#endregion
280
295
  //#region src/response/temporaryRedirect.d.ts
281
296
  /**
282
- * 307 Temporary Redirect
283
- *
284
- * The HTTP 307 Temporary Redirect redirection response status code indicates
285
- * that the resource requested has been temporarily moved to the URL in the
286
- * Location header.
287
- *
288
- * A browser receiving this status will automatically request the resource at
289
- * the URL in the Location header, redirecting the user to the new page. Search
290
- * engines receiving this response will not attribute links to the original URL
291
- * to the new resource, meaning no SEO value is transferred to the new URL.
292
- *
293
- * The method and the body of the original request are reused to perform the
294
- * redirected request. In the cases where you want the request method to be
295
- * changed to GET, use 303 See Other instead. This is useful when you want to
296
- * give an answer to a successful PUT request that is not the uploaded resource,
297
- * but a status monitor or confirmation message like "You have successfully
298
- * uploaded XYZ".
299
- *
300
- * The difference between 307 and 302 is that 307 guarantees that the client
301
- * will not change the request method and body when the redirected request is
302
- * made. With 302, older clients incorrectly changed the method to GET. 307 and
303
- * 302 responses are identical when the request method is GET.
304
- *
305
- * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/307
306
- */
297
+ * 307 Temporary Redirect
298
+ *
299
+ * The HTTP 307 Temporary Redirect redirection response status code indicates
300
+ * that the resource requested has been temporarily moved to the URL in the
301
+ * Location header.
302
+ *
303
+ * A browser receiving this status will automatically request the resource at
304
+ * the URL in the Location header, redirecting the user to the new page. Search
305
+ * engines receiving this response will not attribute links to the original URL
306
+ * to the new resource, meaning no SEO value is transferred to the new URL.
307
+ *
308
+ * The method and the body of the original request are reused to perform the
309
+ * redirected request. In the cases where you want the request method to be
310
+ * changed to GET, use 303 See Other instead. This is useful when you want to
311
+ * give an answer to a successful PUT request that is not the uploaded resource,
312
+ * but a status monitor or confirmation message like "You have successfully
313
+ * uploaded XYZ".
314
+ *
315
+ * The difference between 307 and 302 is that 307 guarantees that the client
316
+ * will not change the request method and body when the redirected request is
317
+ * made. With 302, older clients incorrectly changed the method to GET. 307 and
318
+ * 302 responses are identical when the request method is GET.
319
+ *
320
+ * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/307
321
+ */
307
322
  declare function temporaryRedirect(location: string): Response;
308
323
  //#endregion
309
324
  //#region src/response/transfer.d.ts
310
325
  /**
311
- * Creates a redirect response with the supplied status code.
312
- */
326
+ * Creates a redirect response with the supplied status code.
327
+ */
313
328
  declare function transfer(status: 300 | 301 | 302 | 303 | 304 | 307 | 308, location: string): Response;
314
329
  //#endregion
315
330
  //#region src/response/unauthorized.d.ts
316
331
  /**
317
- * 401 Unauthorized
318
- *
319
- * The HTTP 401 Unauthorized client error response status code indicates that a
320
- * request was not successful because it lacks valid authentication credentials
321
- * for the requested resource. This status code is sent with an HTTP
322
- * WWW-Authenticate response header that contains information on the
323
- * authentication scheme the server expects the client to include to make the
324
- * request successfully.
325
- *
326
- * A 401 Unauthorized is similar to the 403 Forbidden response, except that a
327
- * 403 is returned when a request contains valid credentials, but the client
328
- * does not have permissions to perform a certain action.
329
- *
330
- * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/401
331
- */
332
+ * 401 Unauthorized
333
+ *
334
+ * The HTTP 401 Unauthorized client error response status code indicates that a
335
+ * request was not successful because it lacks valid authentication credentials
336
+ * for the requested resource. This status code is sent with an HTTP
337
+ * WWW-Authenticate response header that contains information on the
338
+ * authentication scheme the server expects the client to include to make the
339
+ * request successfully.
340
+ *
341
+ * A 401 Unauthorized is similar to the 403 Forbidden response, except that a
342
+ * 403 is returned when a request contains valid credentials, but the client
343
+ * does not have permissions to perform a certain action.
344
+ *
345
+ * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/401
346
+ */
332
347
  declare function unauthorized(body?: object | string): Response;
333
348
  //#endregion
334
349
  //#region src/response/unprocessable.d.ts
350
+ type UnprocessableResponse<T extends object | string | undefined> = T extends object ? TypedResponse<Jsonify<T>> : Response;
335
351
  /**
336
- * 422 Unprocessable Content
337
- *
338
- * The HTTP 422 Unprocessable Content client error response status code
339
- * indicates that the server understood the content type of the request content,
340
- * and the syntax of the request content was correct, but it was unable to
341
- * process the contained instructions.
342
- *
343
- * Clients that receive a 422 response should expect that repeating the request
344
- * without modification will fail with the same error.
345
- *
346
- * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/422
347
- */
348
- declare function unprocessable(body?: object | string): Response;
352
+ * 422 Unprocessable Content
353
+ *
354
+ * The HTTP 422 Unprocessable Content client error response status code
355
+ * indicates that the server understood the content type of the request content,
356
+ * and the syntax of the request content was correct, but it was unable to
357
+ * process the contained instructions.
358
+ *
359
+ * Clients that receive a 422 response should expect that repeating the request
360
+ * without modification will fail with the same error.
361
+ *
362
+ * An object body is typed: it becomes the page's `$props.form` (with its JSON
363
+ * form) after a form submit, so validation errors can be surfaced with their
364
+ * field types via `PageForm`.
365
+ *
366
+ * See https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/422
367
+ */
368
+ declare function unprocessable<T extends object | string | undefined>(body?: T): UnprocessableResponse<T>;
349
369
  //#endregion
350
- export { badRequest, created, forbidden, permRedirect as found, methodNotAllowed, permRedirect$1 as movedPermanently, notFound, notModified, ok, permanentRedirect, response, seeOther, serverError, temporaryRedirect, transfer, unauthorized, unprocessable };
370
+ export { badRequest, created, forbidden, found, methodNotAllowed, movedPermanently, notFound, notModified, ok, permanentRedirect, response, seeOther, serverError, temporaryRedirect, transfer, unauthorized, unprocessable };
351
371
  //# sourceMappingURL=response.d.mts.map