@pikku/core 0.6.9

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 (167) hide show
  1. package/CHANGELOG.md +339 -0
  2. package/README.md +5 -0
  3. package/dist/channel/channel-handler.d.ts +3 -0
  4. package/dist/channel/channel-handler.js +97 -0
  5. package/dist/channel/channel-runner.d.ts +26 -0
  6. package/dist/channel/channel-runner.js +86 -0
  7. package/dist/channel/channel-store.d.ts +14 -0
  8. package/dist/channel/channel-store.js +2 -0
  9. package/dist/channel/channel.types.d.ts +106 -0
  10. package/dist/channel/channel.types.js +1 -0
  11. package/dist/channel/eventhub-forwarder.d.ts +17 -0
  12. package/dist/channel/eventhub-forwarder.js +1 -0
  13. package/dist/channel/eventhub-service.d.ts +23 -0
  14. package/dist/channel/eventhub-service.js +1 -0
  15. package/dist/channel/eventhub-store.d.ts +5 -0
  16. package/dist/channel/eventhub-store.js +2 -0
  17. package/dist/channel/index.d.ts +9 -0
  18. package/dist/channel/index.js +9 -0
  19. package/dist/channel/local/index.d.ts +3 -0
  20. package/dist/channel/local/index.js +3 -0
  21. package/dist/channel/local/local-channel-handler.d.ts +17 -0
  22. package/dist/channel/local/local-channel-handler.js +41 -0
  23. package/dist/channel/local/local-channel-runner.d.ts +3 -0
  24. package/dist/channel/local/local-channel-runner.js +46 -0
  25. package/dist/channel/local/local-eventhub-service.d.ts +44 -0
  26. package/dist/channel/local/local-eventhub-service.js +81 -0
  27. package/dist/channel/log-channels.d.ts +6 -0
  28. package/dist/channel/log-channels.js +17 -0
  29. package/dist/channel/pikku-abstract-channel-handler.d.ts +15 -0
  30. package/dist/channel/pikku-abstract-channel-handler.js +33 -0
  31. package/dist/channel/serverless/index.d.ts +1 -0
  32. package/dist/channel/serverless/index.js +1 -0
  33. package/dist/channel/serverless/serverless-channel-runner.d.ts +10 -0
  34. package/dist/channel/serverless/serverless-channel-runner.js +98 -0
  35. package/dist/errors/error-handler.d.ts +39 -0
  36. package/dist/errors/error-handler.js +54 -0
  37. package/dist/errors/errors.d.ts +190 -0
  38. package/dist/errors/errors.js +315 -0
  39. package/dist/errors/index.d.ts +2 -0
  40. package/dist/errors/index.js +2 -0
  41. package/dist/http/http-route-runner.d.ts +30 -0
  42. package/dist/http/http-route-runner.js +208 -0
  43. package/dist/http/http-routes.types.d.ts +127 -0
  44. package/dist/http/http-routes.types.js +1 -0
  45. package/dist/http/http-session-service.d.ts +15 -0
  46. package/dist/http/http-session-service.js +1 -0
  47. package/dist/http/index.d.ts +6 -0
  48. package/dist/http/index.js +5 -0
  49. package/dist/http/log-http-routes.d.ts +6 -0
  50. package/dist/http/log-http-routes.js +17 -0
  51. package/dist/http/pikku-http-abstract-request.d.ts +57 -0
  52. package/dist/http/pikku-http-abstract-request.js +69 -0
  53. package/dist/http/pikku-http-abstract-response.d.ts +58 -0
  54. package/dist/http/pikku-http-abstract-response.js +54 -0
  55. package/dist/http/pikku-http-session-service.d.ts +45 -0
  56. package/dist/http/pikku-http-session-service.js +92 -0
  57. package/dist/index.d.ts +14 -0
  58. package/dist/index.js +14 -0
  59. package/dist/permissions.d.ts +10 -0
  60. package/dist/permissions.js +32 -0
  61. package/dist/pikku-request.d.ts +14 -0
  62. package/dist/pikku-request.js +21 -0
  63. package/dist/pikku-response.d.ts +6 -0
  64. package/dist/pikku-response.js +6 -0
  65. package/dist/scheduler/index.d.ts +3 -0
  66. package/dist/scheduler/index.js +3 -0
  67. package/dist/scheduler/log-schedulers.d.ts +6 -0
  68. package/dist/scheduler/log-schedulers.js +17 -0
  69. package/dist/scheduler/scheduler-runner.d.ts +21 -0
  70. package/dist/scheduler/scheduler-runner.js +73 -0
  71. package/dist/scheduler/scheduler.types.d.ts +21 -0
  72. package/dist/scheduler/scheduler.types.js +1 -0
  73. package/dist/schema.d.ts +26 -0
  74. package/dist/schema.js +100 -0
  75. package/dist/services/content-service.d.ts +55 -0
  76. package/dist/services/content-service.js +1 -0
  77. package/dist/services/index.d.ts +12 -0
  78. package/dist/services/index.js +14 -0
  79. package/dist/services/jwt-service.d.ts +29 -0
  80. package/dist/services/jwt-service.js +1 -0
  81. package/dist/services/local-content.d.ts +33 -0
  82. package/dist/services/local-content.js +6 -0
  83. package/dist/services/local-secrets.d.ts +26 -0
  84. package/dist/services/local-secrets.js +39 -0
  85. package/dist/services/local-variables.d.ts +7 -0
  86. package/dist/services/local-variables.js +12 -0
  87. package/dist/services/logger-console.d.ts +52 -0
  88. package/dist/services/logger-console.js +82 -0
  89. package/dist/services/logger.d.ts +48 -0
  90. package/dist/services/logger.js +9 -0
  91. package/dist/services/schema-service.d.ts +24 -0
  92. package/dist/services/schema-service.js +1 -0
  93. package/dist/services/secret-service.d.ts +17 -0
  94. package/dist/services/secret-service.js +1 -0
  95. package/dist/services/user-session-service.d.ts +6 -0
  96. package/dist/services/user-session-service.js +1 -0
  97. package/dist/services/variables-service.d.ts +4 -0
  98. package/dist/services/variables-service.js +1 -0
  99. package/dist/types/core.types.d.ts +109 -0
  100. package/dist/types/core.types.js +1 -0
  101. package/dist/types/functions.types.d.ts +27 -0
  102. package/dist/types/functions.types.js +1 -0
  103. package/dist/utils.d.ts +2 -0
  104. package/dist/utils.js +15 -0
  105. package/package.json +48 -0
  106. package/run-tests.sh +53 -0
  107. package/src/channel/channel-handler.ts +179 -0
  108. package/src/channel/channel-runner.ts +156 -0
  109. package/src/channel/channel-store.ts +32 -0
  110. package/src/channel/channel.types.ts +202 -0
  111. package/src/channel/eventhub-forwarder.ts +25 -0
  112. package/src/channel/eventhub-service.ts +30 -0
  113. package/src/channel/eventhub-store.ts +8 -0
  114. package/src/channel/index.ts +9 -0
  115. package/src/channel/local/index.ts +3 -0
  116. package/src/channel/local/local-channel-handler.ts +56 -0
  117. package/src/channel/local/local-channel-runner.test.ts +128 -0
  118. package/src/channel/local/local-channel-runner.ts +94 -0
  119. package/src/channel/local/local-eventhub-service.test.ts +95 -0
  120. package/src/channel/local/local-eventhub-service.ts +95 -0
  121. package/src/channel/log-channels.ts +20 -0
  122. package/src/channel/pikku-abstract-channel-handler.test.ts +77 -0
  123. package/src/channel/pikku-abstract-channel-handler.ts +44 -0
  124. package/src/channel/serverless/index.ts +1 -0
  125. package/src/channel/serverless/serverless-channel-runner.ts +190 -0
  126. package/src/errors/error-handler.ts +74 -0
  127. package/src/errors/error.test.ts +54 -0
  128. package/src/errors/errors.ts +340 -0
  129. package/src/errors/index.ts +2 -0
  130. package/src/http/http-route-runner.test.ts +193 -0
  131. package/src/http/http-route-runner.ts +365 -0
  132. package/src/http/http-routes.types.ts +189 -0
  133. package/src/http/http-session-service.ts +19 -0
  134. package/src/http/index.ts +16 -0
  135. package/src/http/log-http-routes.ts +20 -0
  136. package/src/http/pikku-http-abstract-request.ts +95 -0
  137. package/src/http/pikku-http-abstract-response.ts +79 -0
  138. package/src/http/pikku-http-session-service.test.ts +106 -0
  139. package/src/http/pikku-http-session-service.ts +135 -0
  140. package/src/index.ts +15 -0
  141. package/src/permissions.test.ts +58 -0
  142. package/src/permissions.ts +45 -0
  143. package/src/pikku-request.ts +19 -0
  144. package/src/pikku-response.ts +5 -0
  145. package/src/scheduler/index.ts +11 -0
  146. package/src/scheduler/log-schedulers.ts +20 -0
  147. package/src/scheduler/scheduler-runner.ts +132 -0
  148. package/src/scheduler/scheduler.types.ts +27 -0
  149. package/src/schema.test.ts +57 -0
  150. package/src/schema.ts +124 -0
  151. package/src/services/content-service.ts +69 -0
  152. package/src/services/index.ts +16 -0
  153. package/src/services/jwt-service.ts +36 -0
  154. package/src/services/local-content.ts +39 -0
  155. package/src/services/local-secrets.ts +43 -0
  156. package/src/services/local-variables.ts +17 -0
  157. package/src/services/logger-console.ts +97 -0
  158. package/src/services/logger.ts +57 -0
  159. package/src/services/schema-service.ts +26 -0
  160. package/src/services/secret-service.ts +17 -0
  161. package/src/services/user-session-service.ts +7 -0
  162. package/src/services/variables-service.ts +6 -0
  163. package/src/types/core.types.ts +162 -0
  164. package/src/types/functions.types.ts +44 -0
  165. package/src/utils.ts +21 -0
  166. package/tsconfig.json +13 -0
  167. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,190 @@
1
+ /**
2
+ * The server cannot or will not process the request due to client error (e.g., malformed request syntax).
3
+ */
4
+ import { EError } from './error-handler.js';
5
+ /**
6
+ * The server cannot or will not process the request due to client error (e.g., malformed request syntax).
7
+ * @group Error
8
+ */
9
+ export declare class BadRequestError extends EError {
10
+ }
11
+ /**
12
+ * Authentication is required and has failed or has not yet been provided.
13
+ * @group Error
14
+ */
15
+ export declare class UnauthorizedError extends EError {
16
+ }
17
+ /**
18
+ * More specific error to why it's unauthorized.
19
+ * @group Error
20
+ */
21
+ export declare class MissingSessionError extends EError {
22
+ }
23
+ /**
24
+ * More specific error to why it's unauthorized.
25
+ * @group Error
26
+ */
27
+ export declare class InvalidSessionError extends EError {
28
+ }
29
+ /**
30
+ * Reserved for future use, often related to digital payment or subscription services.
31
+ * @group Error
32
+ */
33
+ export declare class PaymentRequiredError extends EError {
34
+ }
35
+ /**
36
+ * The client does not have permission to access the requested resource.
37
+ * @group Error
38
+ */
39
+ export declare class ForbiddenError extends EError {
40
+ }
41
+ /**
42
+ * The request was made from an origin that is not permitted to access this resource.
43
+ * @group Error
44
+ */
45
+ export declare class InvalidOriginError extends EError {
46
+ }
47
+ /**
48
+ * The server cannot find the requested resource.
49
+ * @group Error
50
+ */
51
+ export declare class NotFoundError extends EError {
52
+ }
53
+ /**
54
+ * The request method is known by the server but is not supported by the resource.
55
+ * @group Error
56
+ */
57
+ export declare class MethodNotAllowedError extends EError {
58
+ }
59
+ /**
60
+ * The requested resource cannot produce a response matching the list of acceptable values in the request's headers.
61
+ * @group Error
62
+ */
63
+ export declare class NotAcceptableError extends EError {
64
+ }
65
+ /**
66
+ * The client must authenticate itself to get the requested response.
67
+ * @group Error
68
+ */
69
+ export declare class ProxyAuthenticationRequiredError extends EError {
70
+ }
71
+ /**
72
+ * The server did not receive a timely response from an upstream server.
73
+ * @group Error
74
+ */
75
+ export declare class RequestTimeoutError extends EError {
76
+ }
77
+ /**
78
+ * The request could not be completed due to a conflict with the current state of the target resource.
79
+ * @group Error
80
+ */
81
+ export declare class ConflictError extends EError {
82
+ }
83
+ /**
84
+ * The resource that is being accessed is no longer available and will not be available again.
85
+ * @group Error
86
+ */
87
+ export declare class GoneError extends EError {
88
+ }
89
+ /**
90
+ * The request did not specify the length of its content, which is required by the requested resource.
91
+ * @group Error
92
+ */
93
+ export declare class LengthRequiredError extends EError {
94
+ }
95
+ /**
96
+ * The server does not meet one of the preconditions that the requester put on the request.
97
+ * @group Error
98
+ */
99
+ export declare class PreconditionFailedError extends EError {
100
+ }
101
+ /**
102
+ * The request is larger than the server is willing or able to process.
103
+ * @group Error
104
+ */
105
+ export declare class PayloadTooLargeError extends EError {
106
+ }
107
+ /**
108
+ * The URI requested by the client is longer than the server is willing to interpret.
109
+ * @group Error
110
+ */
111
+ export declare class URITooLongError extends EError {
112
+ }
113
+ /**
114
+ * The server does not support the media format of the requested data.
115
+ * @group Error
116
+ */
117
+ export declare class UnsupportedMediaTypeError extends EError {
118
+ }
119
+ /**
120
+ * The client has asked for a portion of the file, but the server cannot supply that portion.
121
+ * @group Error
122
+ */
123
+ export declare class RangeNotSatisfiableError extends EError {
124
+ }
125
+ /**
126
+ * The server cannot meet the requirements of the Expect request-header field.
127
+ * @group Error
128
+ */
129
+ export declare class ExpectationFailedError extends EError {
130
+ }
131
+ /**
132
+ * Indicates that the server understood the content type of the request content, and the syntax of the request content was correct, but it was unable to process the contained instructions.
133
+ * @group Error
134
+ */
135
+ export declare class UnprocessableContentError extends EError {
136
+ }
137
+ /**
138
+ * Indicates that the server understood the content type of the request content, and the syntax of the request content was correct, but it was unable to process the contained instructions.
139
+ * @group Error
140
+ */
141
+ export declare class LockedError extends EError {
142
+ }
143
+ /**
144
+ * The user has sent too many requests in a given amount of time ("rate limiting").
145
+ * @group Error
146
+ */
147
+ export declare class TooManyRequestsError extends EError {
148
+ }
149
+ /**
150
+ * A generic error message, given when no more specific message is suitable.
151
+ * @group Error
152
+ */
153
+ export declare class InternalServerError extends EError {
154
+ }
155
+ /**
156
+ * The server does not recognize the request method and cannot support it.
157
+ * @group Error
158
+ */
159
+ export declare class NotImplementedError extends EError {
160
+ }
161
+ /**
162
+ * The server was acting as a gateway or proxy and received an invalid response from the upstream server.
163
+ * @group Error
164
+ */
165
+ export declare class BadGatewayError extends EError {
166
+ }
167
+ /**
168
+ * The server is currently unavailable (overloaded or down).
169
+ * @group Error
170
+ */
171
+ export declare class ServiceUnavailableError extends EError {
172
+ }
173
+ /**
174
+ * The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.
175
+ * @group Error
176
+ */
177
+ export declare class GatewayTimeoutError extends EError {
178
+ }
179
+ /**
180
+ * The server does not support the HTTP protocol version used in the request.
181
+ * @group Error
182
+ */
183
+ export declare class HTTPVersionNotSupportedError extends EError {
184
+ }
185
+ /**
186
+ * The server took too long to complete the request, reaching the maximum compute time allowed.
187
+ * @group Error
188
+ */
189
+ export declare class MaxComputeTimeReachedError extends EError {
190
+ }
@@ -0,0 +1,315 @@
1
+ /**
2
+ * The server cannot or will not process the request due to client error (e.g., malformed request syntax).
3
+ */
4
+ import { addError, EError } from './error-handler.js';
5
+ /**
6
+ * The server cannot or will not process the request due to client error (e.g., malformed request syntax).
7
+ * @group Error
8
+ */
9
+ export class BadRequestError extends EError {
10
+ }
11
+ addError(BadRequestError, {
12
+ status: 400,
13
+ message: 'The server cannot or will not process the request due to client error (e.g., malformed request syntax).',
14
+ });
15
+ /**
16
+ * Authentication is required and has failed or has not yet been provided.
17
+ * @group Error
18
+ */
19
+ export class UnauthorizedError extends EError {
20
+ }
21
+ /**
22
+ * More specific error to why it's unauthorized.
23
+ * @group Error
24
+ */
25
+ export class MissingSessionError extends EError {
26
+ }
27
+ /**
28
+ * More specific error to why it's unauthorized.
29
+ * @group Error
30
+ */
31
+ export class InvalidSessionError extends EError {
32
+ }
33
+ addError(UnauthorizedError, {
34
+ status: 401,
35
+ message: 'Authentication is required and has failed or has not yet been provided.',
36
+ });
37
+ addError(MissingSessionError, { status: 401, message: 'Session missing.' });
38
+ addError(InvalidSessionError, {
39
+ status: 401,
40
+ message: 'The session provided is not valid.',
41
+ });
42
+ /**
43
+ * Reserved for future use, often related to digital payment or subscription services.
44
+ * @group Error
45
+ */
46
+ export class PaymentRequiredError extends EError {
47
+ }
48
+ addError(PaymentRequiredError, {
49
+ status: 402,
50
+ message: 'Reserved for future use, often related to digital payment or subscription services.',
51
+ });
52
+ /**
53
+ * The client does not have permission to access the requested resource.
54
+ * @group Error
55
+ */
56
+ export class ForbiddenError extends EError {
57
+ }
58
+ addError(ForbiddenError, {
59
+ status: 403,
60
+ message: 'The client does not have permission to access the requested resource.',
61
+ });
62
+ /**
63
+ * The request was made from an origin that is not permitted to access this resource.
64
+ * @group Error
65
+ */
66
+ export class InvalidOriginError extends EError {
67
+ }
68
+ addError(InvalidOriginError, {
69
+ status: 403,
70
+ message: 'The request was made from an origin that is not permitted to access this resource.',
71
+ });
72
+ /**
73
+ * The server cannot find the requested resource.
74
+ * @group Error
75
+ */
76
+ export class NotFoundError extends EError {
77
+ }
78
+ /**
79
+ * The server cannot find the requested route.
80
+ * @group Error
81
+ */
82
+ addError(NotFoundError, {
83
+ status: 404,
84
+ message: 'The server cannot find the requested resource.',
85
+ });
86
+ /**
87
+ * The request method is known by the server but is not supported by the resource.
88
+ * @group Error
89
+ */
90
+ export class MethodNotAllowedError extends EError {
91
+ }
92
+ addError(MethodNotAllowedError, {
93
+ status: 405,
94
+ message: 'The request method is known by the server but is not supported by the resource.',
95
+ });
96
+ /**
97
+ * The requested resource cannot produce a response matching the list of acceptable values in the request's headers.
98
+ * @group Error
99
+ */
100
+ export class NotAcceptableError extends EError {
101
+ }
102
+ addError(NotAcceptableError, {
103
+ status: 406,
104
+ message: "The requested resource cannot produce a response matching the list of acceptable values in the request's headers.",
105
+ });
106
+ /**
107
+ * The client must authenticate itself to get the requested response.
108
+ * @group Error
109
+ */
110
+ export class ProxyAuthenticationRequiredError extends EError {
111
+ }
112
+ addError(ProxyAuthenticationRequiredError, {
113
+ status: 407,
114
+ message: 'The client must authenticate itself to get the requested response.',
115
+ });
116
+ /**
117
+ * The server did not receive a timely response from an upstream server.
118
+ * @group Error
119
+ */
120
+ export class RequestTimeoutError extends EError {
121
+ }
122
+ addError(RequestTimeoutError, {
123
+ status: 408,
124
+ message: 'The server did not receive a timely response from an upstream server.',
125
+ });
126
+ /**
127
+ * The request could not be completed due to a conflict with the current state of the target resource.
128
+ * @group Error
129
+ */
130
+ export class ConflictError extends EError {
131
+ }
132
+ addError(ConflictError, {
133
+ status: 409,
134
+ message: 'The request could not be completed due to a conflict with the current state of the target resource.',
135
+ });
136
+ /**
137
+ * The resource that is being accessed is no longer available and will not be available again.
138
+ * @group Error
139
+ */
140
+ export class GoneError extends EError {
141
+ }
142
+ addError(GoneError, {
143
+ status: 410,
144
+ message: 'The resource that is being accessed is no longer available and will not be available again.',
145
+ });
146
+ /**
147
+ * The request did not specify the length of its content, which is required by the requested resource.
148
+ * @group Error
149
+ */
150
+ export class LengthRequiredError extends EError {
151
+ }
152
+ addError(LengthRequiredError, {
153
+ status: 411,
154
+ message: 'The request did not specify the length of its content, which is required by the requested resource.',
155
+ });
156
+ /**
157
+ * The server does not meet one of the preconditions that the requester put on the request.
158
+ * @group Error
159
+ */
160
+ export class PreconditionFailedError extends EError {
161
+ }
162
+ addError(PreconditionFailedError, {
163
+ status: 412,
164
+ message: 'The server does not meet one of the preconditions that the requester put on the request.',
165
+ });
166
+ /**
167
+ * The request is larger than the server is willing or able to process.
168
+ * @group Error
169
+ */
170
+ export class PayloadTooLargeError extends EError {
171
+ }
172
+ addError(PayloadTooLargeError, {
173
+ status: 413,
174
+ message: 'The request is larger than the server is willing or able to process.',
175
+ });
176
+ /**
177
+ * The URI requested by the client is longer than the server is willing to interpret.
178
+ * @group Error
179
+ */
180
+ export class URITooLongError extends EError {
181
+ }
182
+ addError(URITooLongError, {
183
+ status: 414,
184
+ message: 'The URI requested by the client is longer than the server is willing to interpret.',
185
+ });
186
+ /**
187
+ * The server does not support the media format of the requested data.
188
+ * @group Error
189
+ */
190
+ export class UnsupportedMediaTypeError extends EError {
191
+ }
192
+ addError(UnsupportedMediaTypeError, {
193
+ status: 415,
194
+ message: 'The server does not support the media format of the requested data.',
195
+ });
196
+ /**
197
+ * The client has asked for a portion of the file, but the server cannot supply that portion.
198
+ * @group Error
199
+ */
200
+ export class RangeNotSatisfiableError extends EError {
201
+ }
202
+ addError(RangeNotSatisfiableError, {
203
+ status: 416,
204
+ message: 'The client has asked for a portion of the file, but the server cannot supply that portion.',
205
+ });
206
+ /**
207
+ * The server cannot meet the requirements of the Expect request-header field.
208
+ * @group Error
209
+ */
210
+ export class ExpectationFailedError extends EError {
211
+ }
212
+ addError(ExpectationFailedError, {
213
+ status: 417,
214
+ message: 'The server cannot meet the requirements of the Expect request-header field.',
215
+ });
216
+ /**
217
+ * Indicates that the server understood the content type of the request content, and the syntax of the request content was correct, but it was unable to process the contained instructions.
218
+ * @group Error
219
+ */
220
+ export class UnprocessableContentError extends EError {
221
+ }
222
+ addError(UnprocessableContentError, {
223
+ status: 422,
224
+ message: 'The server understood the content type of the request content, and the syntax of the request content was correct, but it was unable to process the contained instructions..',
225
+ });
226
+ /**
227
+ * Indicates that the server understood the content type of the request content, and the syntax of the request content was correct, but it was unable to process the contained instructions.
228
+ * @group Error
229
+ */
230
+ export class LockedError extends EError {
231
+ }
232
+ addError(LockedError, {
233
+ status: 423,
234
+ message: "The resource is locked, meaning it can't be accessed. Its response body should contain information in WebDAV's XML format.",
235
+ });
236
+ /**
237
+ * The user has sent too many requests in a given amount of time ("rate limiting").
238
+ * @group Error
239
+ */
240
+ export class TooManyRequestsError extends EError {
241
+ }
242
+ addError(TooManyRequestsError, {
243
+ status: 429,
244
+ message: 'The user has sent too many requests in a given amount of time ("rate limiting").',
245
+ });
246
+ /**
247
+ * A generic error message, given when no more specific message is suitable.
248
+ * @group Error
249
+ */
250
+ export class InternalServerError extends EError {
251
+ }
252
+ addError(InternalServerError, {
253
+ status: 500,
254
+ message: 'A generic error message, given when no more specific message is suitable.',
255
+ });
256
+ /**
257
+ * The server does not recognize the request method and cannot support it.
258
+ * @group Error
259
+ */
260
+ export class NotImplementedError extends EError {
261
+ }
262
+ addError(NotImplementedError, {
263
+ status: 501,
264
+ message: 'The server does not recognize the request method and cannot support it.',
265
+ });
266
+ /**
267
+ * The server was acting as a gateway or proxy and received an invalid response from the upstream server.
268
+ * @group Error
269
+ */
270
+ export class BadGatewayError extends EError {
271
+ }
272
+ addError(BadGatewayError, {
273
+ status: 502,
274
+ message: 'The server was acting as a gateway or proxy and received an invalid response from the upstream server.',
275
+ });
276
+ /**
277
+ * The server is currently unavailable (overloaded or down).
278
+ * @group Error
279
+ */
280
+ export class ServiceUnavailableError extends EError {
281
+ }
282
+ addError(ServiceUnavailableError, {
283
+ status: 503,
284
+ message: 'The server is currently unavailable (overloaded or down).',
285
+ });
286
+ /**
287
+ * The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.
288
+ * @group Error
289
+ */
290
+ export class GatewayTimeoutError extends EError {
291
+ }
292
+ addError(GatewayTimeoutError, {
293
+ status: 504,
294
+ message: 'The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.',
295
+ });
296
+ /**
297
+ * The server does not support the HTTP protocol version used in the request.
298
+ * @group Error
299
+ */
300
+ export class HTTPVersionNotSupportedError extends EError {
301
+ }
302
+ addError(HTTPVersionNotSupportedError, {
303
+ status: 505,
304
+ message: 'The server does not support the HTTP protocol version used in the request.',
305
+ });
306
+ /**
307
+ * The server took too long to complete the request, reaching the maximum compute time allowed.
308
+ * @group Error
309
+ */
310
+ export class MaxComputeTimeReachedError extends EError {
311
+ }
312
+ addError(MaxComputeTimeReachedError, {
313
+ status: 524,
314
+ message: 'The server took too long to complete the request, reaching the maximum compute time allowed.',
315
+ });
@@ -0,0 +1,2 @@
1
+ export * from './error-handler.js';
2
+ export * from './errors.js';
@@ -0,0 +1,2 @@
1
+ export * from './error-handler.js';
2
+ export * from './errors.js';
@@ -0,0 +1,30 @@
1
+ import { CoreHTTPFunctionRoute, HTTPRoutesMeta, RunRouteOptions, RunRouteParams, PikkuHTTP } from './http-routes.types.js';
2
+ import { CoreUserSession } from '../types/core.types.js';
3
+ import { PikkuHTTPAbstractRequest } from './pikku-http-abstract-request.js';
4
+ import { Logger } from '../services/index.js';
5
+ import { CoreAPIChannel } from '../channel/channel.types.js';
6
+ import { PikkuRequest } from '../pikku-request.js';
7
+ import { PikkuResponse } from '../pikku-response.js';
8
+ import { HTTPSessionService } from './http-session-service.js';
9
+ export declare const addRoute: <In, Out, Route extends string, APIFunction, APIFunctionSessionless, APIPermission>(route: CoreHTTPFunctionRoute<In, Out, Route, APIFunction, APIFunctionSessionless, APIPermission>) => void;
10
+ export declare const clearRoutes: () => void;
11
+ /**
12
+ * @ignore
13
+ */
14
+ export declare const setHTTPRoutesMeta: (_routeMeta: HTTPRoutesMeta) => void;
15
+ /**
16
+ * Returns all the registered routes and associated metadata.
17
+ * @internal
18
+ */
19
+ export declare const getRoutes: () => {
20
+ routes: CoreHTTPFunctionRoute<any, any, any>[];
21
+ routesMeta: HTTPRoutesMeta;
22
+ };
23
+ export declare const getUserSession: <UserSession extends CoreUserSession>(httpSessionService: HTTPSessionService<UserSession> | undefined, auth: boolean, request: PikkuHTTPAbstractRequest) => Promise<CoreUserSession | undefined>;
24
+ export declare const loadUserSession: (skipUserSession: boolean, requiresSession: boolean, http: PikkuHTTP | undefined, matchedPath: any, route: CoreHTTPFunctionRoute<unknown, unknown, any> | CoreAPIChannel<unknown, any>, logger: Logger, httpSessionService: HTTPSessionService | undefined) => Promise<unknown>;
25
+ export declare const createHTTPInteraction: (request: PikkuRequest | undefined, response: PikkuResponse | undefined) => PikkuHTTP | undefined;
26
+ export declare const handleError: (e: any, http: PikkuHTTP | undefined, trackerId: string, logger: Logger, logWarningsForStatusCodes: number[], respondWith404: boolean, bubbleError: boolean) => void;
27
+ /**
28
+ * @ignore
29
+ */
30
+ export declare const runHTTPRoute: <In, Out>({ singletonServices, request, response, createSessionServices, route: apiRoute, method: apiType, skipUserSession, respondWith404, logWarningsForStatusCodes, coerceToArray, bubbleErrors, }: Pick<CoreHTTPFunctionRoute<unknown, unknown, any>, "route" | "method"> & RunRouteOptions & RunRouteParams<In>) => Promise<Out | void>;