@pikku/core 0.6.9 → 0.6.11
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 +13 -0
- package/dist/channel/channel-runner.d.ts +1 -1
- package/dist/channel/channel.types.d.ts +8 -8
- package/dist/errors/error-handler.d.ts +2 -2
- package/dist/errors/error-handler.js +2 -2
- package/dist/errors/errors.d.ts +32 -32
- package/dist/errors/errors.js +32 -32
- package/dist/http/http-route-runner.d.ts +1 -1
- package/dist/http/http-routes.types.d.ts +2 -2
- package/dist/scheduler/scheduler-runner.js +1 -1
- package/dist/types/core.types.d.ts +4 -3
- package/lcov.info +3729 -0
- package/package.json +2 -2
- package/src/channel/channel.types.ts +7 -8
- package/src/errors/error-handler.ts +2 -2
- package/src/errors/errors.ts +32 -32
- package/src/http/http-routes.types.ts +2 -2
- package/src/scheduler/scheduler-runner.ts +1 -1
- package/src/types/core.types.ts +4 -5
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
## 0.6
|
|
2
2
|
|
|
3
|
+
## 0.6.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7859b28: breaking: changing overrides for addRoute to wrap instead due to random conflict override errors
|
|
8
|
+
- 269a532: fix: fixing some typing issues
|
|
9
|
+
|
|
10
|
+
## 0.6.10
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 4a4a55d: refactor: renaming EError to PikkuError
|
|
15
|
+
|
|
3
16
|
## 0.6.9
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -16,7 +16,7 @@ export declare const setChannelsMeta: (_channelsMeta: ChannelsMeta) => void;
|
|
|
16
16
|
export declare const getMatchingChannelConfig: (request: string) => {
|
|
17
17
|
matchedPath: import("path-to-regexp").MatchResult<Partial<Record<string, string | string[]>>>;
|
|
18
18
|
params: Partial<Record<string, string | string[]>>;
|
|
19
|
-
channelConfig: CoreAPIChannel<any, string, import("./channel.types.js").CoreChannelConnection<any, unknown, import("../types/core.types.js").CoreServices,
|
|
19
|
+
channelConfig: CoreAPIChannel<any, string, import("./channel.types.js").CoreChannelConnection<any, unknown, import("../types/core.types.js").CoreServices, CoreUserSession>, import("./channel.types.js").CoreChannelDisconnection<any, import("../types/core.types.js").CoreServices, CoreUserSession>, import("./channel.types.js").CoreChannelMessage<unknown, unknown, unknown, import("../types/core.types.js").CoreServices, CoreUserSession>, import("./channel.types.js").CoreChannelMessage<unknown, unknown, unknown, import("../types/core.types.js").CoreServices, CoreUserSession>, import("../index.js").CoreAPIPermission<any>>;
|
|
20
20
|
schemaName: string | null | undefined;
|
|
21
21
|
} | null;
|
|
22
22
|
export declare const openChannel: ({ route, singletonServices, skipUserSession, coerceToArray, http, }: Pick<CoreAPIChannel<unknown, string>, "route"> & Omit<RunChannelParams<unknown>, "response" | "request"> & RunChannelOptions) => Promise<{
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PikkuError } from '../errors/error-handler.js';
|
|
2
2
|
import { HTTPFunctionMetaInputTypes, PikkuHTTP } from '../http/http-routes.types.js';
|
|
3
3
|
import { PikkuHTTPAbstractRequest } from '../http/pikku-http-abstract-request.js';
|
|
4
4
|
import { PikkuHTTPAbstractResponse } from '../http/pikku-http-abstract-response.js';
|
|
5
|
-
import { APIDocs, CoreServices, CoreSingletonServices, CoreUserSession, CreateSessionServices
|
|
5
|
+
import { APIDocs, CoreServices, CoreSingletonServices, CoreUserSession, CreateSessionServices } from '../types/core.types.js';
|
|
6
6
|
import { CoreAPIPermission } from '../types/functions.types.js';
|
|
7
7
|
import { PikkuRequest } from '../pikku-request.js';
|
|
8
8
|
import { PikkuResponse } from '../pikku-response.js';
|
|
@@ -15,7 +15,7 @@ export type RunChannelOptions = Partial<{
|
|
|
15
15
|
}>;
|
|
16
16
|
export type RunChannelParams<ChannelData> = {
|
|
17
17
|
channelId: string;
|
|
18
|
-
singletonServices:
|
|
18
|
+
singletonServices: CoreSingletonServices;
|
|
19
19
|
request?: PikkuRequest<ChannelData> | PikkuHTTPAbstractRequest<ChannelData>;
|
|
20
20
|
response?: PikkuResponse | PikkuHTTPAbstractResponse;
|
|
21
21
|
http?: PikkuHTTP;
|
|
@@ -43,8 +43,8 @@ export interface ChannelMeta {
|
|
|
43
43
|
docs?: APIDocs;
|
|
44
44
|
}
|
|
45
45
|
export type ChannelsMeta = ChannelMeta[];
|
|
46
|
-
export type CoreChannelConnection<ChannelData, Out = unknown, Services extends CoreServices = CoreServices, Session extends CoreUserSession = CoreUserSession> = (services:
|
|
47
|
-
export type CoreChannelDisconnection<ChannelData, Services extends CoreServices = CoreServices, Session extends CoreUserSession = CoreUserSession> = (services:
|
|
46
|
+
export type CoreChannelConnection<ChannelData, Out = unknown, Services extends CoreServices = CoreServices, Session extends CoreUserSession = CoreUserSession> = (services: Services, channel: PikkuChannel<Session, ChannelData, Out>) => Promise<void>;
|
|
47
|
+
export type CoreChannelDisconnection<ChannelData, Services extends CoreServices = CoreServices, Session extends CoreUserSession = CoreUserSession> = (services: Services, channel: PikkuChannel<Session, ChannelData, never>) => Promise<void>;
|
|
48
48
|
/**
|
|
49
49
|
* Represents a core channel function that performs an operation using core services and a user session.
|
|
50
50
|
*
|
|
@@ -52,12 +52,12 @@ export type CoreChannelDisconnection<ChannelData, Services extends CoreServices
|
|
|
52
52
|
* @template Services - The services type, defaults to `CoreServices`.
|
|
53
53
|
* @template Session - The session type, defaults to `CoreUserSession`.
|
|
54
54
|
*/
|
|
55
|
-
export type CoreChannelMessage<In, Out, ChannelData, Services extends CoreServices = CoreServices, Session extends CoreUserSession = CoreUserSession> = (services:
|
|
55
|
+
export type CoreChannelMessage<In, Out, ChannelData, Services extends CoreServices = CoreServices, Session extends CoreUserSession = CoreUserSession> = (services: Services, channel: PikkuChannel<Session, ChannelData, Out>, data: In) => Promise<void | Out>;
|
|
56
56
|
export type CoreAPIChannelMessage<ChannelFunctionMessage = CoreChannelMessage<unknown, unknown, unknown>> = {
|
|
57
57
|
func: ChannelFunctionMessage;
|
|
58
58
|
route: string;
|
|
59
59
|
};
|
|
60
|
-
export type CoreAPIChannel<ChannelData, Channel extends string, ChannelFunctionConnection = CoreChannelConnection<ChannelData>, ChannelFunctionDisconnection =
|
|
60
|
+
export type CoreAPIChannel<ChannelData, Channel extends string, ChannelFunctionConnection = CoreChannelConnection<ChannelData>, ChannelFunctionDisconnection = CoreChannelDisconnection<ChannelData>, ChannelFunctionDefaultMessage = CoreChannelMessage<unknown, unknown, unknown>, ChannelFunctionMessageRoute = CoreChannelMessage<unknown, unknown, unknown>, APIPermission = CoreAPIPermission<ChannelData>> = {
|
|
61
61
|
name: string;
|
|
62
62
|
route: Channel;
|
|
63
63
|
onConnect?: ChannelFunctionConnection;
|
|
@@ -77,7 +77,7 @@ export type CoreAPIChannel<ChannelData, Channel extends string, ChannelFunctionC
|
|
|
77
77
|
docs?: Partial<{
|
|
78
78
|
description: string;
|
|
79
79
|
response: string;
|
|
80
|
-
errors: Array<typeof
|
|
80
|
+
errors: Array<typeof PikkuError>;
|
|
81
81
|
tags: string[];
|
|
82
82
|
}>;
|
|
83
83
|
};
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Base class for custom errors.
|
|
3
3
|
* @extends {Error}
|
|
4
4
|
*/
|
|
5
|
-
export declare class
|
|
5
|
+
export declare class PikkuError extends Error {
|
|
6
6
|
/**
|
|
7
|
-
* Creates an instance of
|
|
7
|
+
* Creates an instance of PikkuError.
|
|
8
8
|
* @param message - The error message.
|
|
9
9
|
*/
|
|
10
10
|
constructor(message?: string);
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Base class for custom errors.
|
|
3
3
|
* @extends {Error}
|
|
4
4
|
*/
|
|
5
|
-
export class
|
|
5
|
+
export class PikkuError extends Error {
|
|
6
6
|
/**
|
|
7
|
-
* Creates an instance of
|
|
7
|
+
* Creates an instance of PikkuError.
|
|
8
8
|
* @param message - The error message.
|
|
9
9
|
*/
|
|
10
10
|
constructor(message = 'An error occurred') {
|
package/dist/errors/errors.d.ts
CHANGED
|
@@ -1,190 +1,190 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The server cannot or will not process the request due to client error (e.g., malformed request syntax).
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { PikkuError } from './error-handler.js';
|
|
5
5
|
/**
|
|
6
6
|
* The server cannot or will not process the request due to client error (e.g., malformed request syntax).
|
|
7
7
|
* @group Error
|
|
8
8
|
*/
|
|
9
|
-
export declare class BadRequestError extends
|
|
9
|
+
export declare class BadRequestError extends PikkuError {
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Authentication is required and has failed or has not yet been provided.
|
|
13
13
|
* @group Error
|
|
14
14
|
*/
|
|
15
|
-
export declare class UnauthorizedError extends
|
|
15
|
+
export declare class UnauthorizedError extends PikkuError {
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* More specific error to why it's unauthorized.
|
|
19
19
|
* @group Error
|
|
20
20
|
*/
|
|
21
|
-
export declare class MissingSessionError extends
|
|
21
|
+
export declare class MissingSessionError extends PikkuError {
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* More specific error to why it's unauthorized.
|
|
25
25
|
* @group Error
|
|
26
26
|
*/
|
|
27
|
-
export declare class InvalidSessionError extends
|
|
27
|
+
export declare class InvalidSessionError extends PikkuError {
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Reserved for future use, often related to digital payment or subscription services.
|
|
31
31
|
* @group Error
|
|
32
32
|
*/
|
|
33
|
-
export declare class PaymentRequiredError extends
|
|
33
|
+
export declare class PaymentRequiredError extends PikkuError {
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* The client does not have permission to access the requested resource.
|
|
37
37
|
* @group Error
|
|
38
38
|
*/
|
|
39
|
-
export declare class ForbiddenError extends
|
|
39
|
+
export declare class ForbiddenError extends PikkuError {
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* The request was made from an origin that is not permitted to access this resource.
|
|
43
43
|
* @group Error
|
|
44
44
|
*/
|
|
45
|
-
export declare class InvalidOriginError extends
|
|
45
|
+
export declare class InvalidOriginError extends PikkuError {
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* The server cannot find the requested resource.
|
|
49
49
|
* @group Error
|
|
50
50
|
*/
|
|
51
|
-
export declare class NotFoundError extends
|
|
51
|
+
export declare class NotFoundError extends PikkuError {
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* The request method is known by the server but is not supported by the resource.
|
|
55
55
|
* @group Error
|
|
56
56
|
*/
|
|
57
|
-
export declare class MethodNotAllowedError extends
|
|
57
|
+
export declare class MethodNotAllowedError extends PikkuError {
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* The requested resource cannot produce a response matching the list of acceptable values in the request's headers.
|
|
61
61
|
* @group Error
|
|
62
62
|
*/
|
|
63
|
-
export declare class NotAcceptableError extends
|
|
63
|
+
export declare class NotAcceptableError extends PikkuError {
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
66
|
* The client must authenticate itself to get the requested response.
|
|
67
67
|
* @group Error
|
|
68
68
|
*/
|
|
69
|
-
export declare class ProxyAuthenticationRequiredError extends
|
|
69
|
+
export declare class ProxyAuthenticationRequiredError extends PikkuError {
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
72
|
* The server did not receive a timely response from an upstream server.
|
|
73
73
|
* @group Error
|
|
74
74
|
*/
|
|
75
|
-
export declare class RequestTimeoutError extends
|
|
75
|
+
export declare class RequestTimeoutError extends PikkuError {
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
78
|
* The request could not be completed due to a conflict with the current state of the target resource.
|
|
79
79
|
* @group Error
|
|
80
80
|
*/
|
|
81
|
-
export declare class ConflictError extends
|
|
81
|
+
export declare class ConflictError extends PikkuError {
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
84
|
* The resource that is being accessed is no longer available and will not be available again.
|
|
85
85
|
* @group Error
|
|
86
86
|
*/
|
|
87
|
-
export declare class GoneError extends
|
|
87
|
+
export declare class GoneError extends PikkuError {
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
90
|
* The request did not specify the length of its content, which is required by the requested resource.
|
|
91
91
|
* @group Error
|
|
92
92
|
*/
|
|
93
|
-
export declare class LengthRequiredError extends
|
|
93
|
+
export declare class LengthRequiredError extends PikkuError {
|
|
94
94
|
}
|
|
95
95
|
/**
|
|
96
96
|
* The server does not meet one of the preconditions that the requester put on the request.
|
|
97
97
|
* @group Error
|
|
98
98
|
*/
|
|
99
|
-
export declare class PreconditionFailedError extends
|
|
99
|
+
export declare class PreconditionFailedError extends PikkuError {
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
102
|
* The request is larger than the server is willing or able to process.
|
|
103
103
|
* @group Error
|
|
104
104
|
*/
|
|
105
|
-
export declare class PayloadTooLargeError extends
|
|
105
|
+
export declare class PayloadTooLargeError extends PikkuError {
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
108
|
* The URI requested by the client is longer than the server is willing to interpret.
|
|
109
109
|
* @group Error
|
|
110
110
|
*/
|
|
111
|
-
export declare class URITooLongError extends
|
|
111
|
+
export declare class URITooLongError extends PikkuError {
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
114
114
|
* The server does not support the media format of the requested data.
|
|
115
115
|
* @group Error
|
|
116
116
|
*/
|
|
117
|
-
export declare class UnsupportedMediaTypeError extends
|
|
117
|
+
export declare class UnsupportedMediaTypeError extends PikkuError {
|
|
118
118
|
}
|
|
119
119
|
/**
|
|
120
120
|
* The client has asked for a portion of the file, but the server cannot supply that portion.
|
|
121
121
|
* @group Error
|
|
122
122
|
*/
|
|
123
|
-
export declare class RangeNotSatisfiableError extends
|
|
123
|
+
export declare class RangeNotSatisfiableError extends PikkuError {
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
126
|
* The server cannot meet the requirements of the Expect request-header field.
|
|
127
127
|
* @group Error
|
|
128
128
|
*/
|
|
129
|
-
export declare class ExpectationFailedError extends
|
|
129
|
+
export declare class ExpectationFailedError extends PikkuError {
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
132
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
133
|
* @group Error
|
|
134
134
|
*/
|
|
135
|
-
export declare class UnprocessableContentError extends
|
|
135
|
+
export declare class UnprocessableContentError extends PikkuError {
|
|
136
136
|
}
|
|
137
137
|
/**
|
|
138
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
139
|
* @group Error
|
|
140
140
|
*/
|
|
141
|
-
export declare class LockedError extends
|
|
141
|
+
export declare class LockedError extends PikkuError {
|
|
142
142
|
}
|
|
143
143
|
/**
|
|
144
144
|
* The user has sent too many requests in a given amount of time ("rate limiting").
|
|
145
145
|
* @group Error
|
|
146
146
|
*/
|
|
147
|
-
export declare class TooManyRequestsError extends
|
|
147
|
+
export declare class TooManyRequestsError extends PikkuError {
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
150
150
|
* A generic error message, given when no more specific message is suitable.
|
|
151
151
|
* @group Error
|
|
152
152
|
*/
|
|
153
|
-
export declare class InternalServerError extends
|
|
153
|
+
export declare class InternalServerError extends PikkuError {
|
|
154
154
|
}
|
|
155
155
|
/**
|
|
156
156
|
* The server does not recognize the request method and cannot support it.
|
|
157
157
|
* @group Error
|
|
158
158
|
*/
|
|
159
|
-
export declare class NotImplementedError extends
|
|
159
|
+
export declare class NotImplementedError extends PikkuError {
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
162
162
|
* The server was acting as a gateway or proxy and received an invalid response from the upstream server.
|
|
163
163
|
* @group Error
|
|
164
164
|
*/
|
|
165
|
-
export declare class BadGatewayError extends
|
|
165
|
+
export declare class BadGatewayError extends PikkuError {
|
|
166
166
|
}
|
|
167
167
|
/**
|
|
168
168
|
* The server is currently unavailable (overloaded or down).
|
|
169
169
|
* @group Error
|
|
170
170
|
*/
|
|
171
|
-
export declare class ServiceUnavailableError extends
|
|
171
|
+
export declare class ServiceUnavailableError extends PikkuError {
|
|
172
172
|
}
|
|
173
173
|
/**
|
|
174
174
|
* The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.
|
|
175
175
|
* @group Error
|
|
176
176
|
*/
|
|
177
|
-
export declare class GatewayTimeoutError extends
|
|
177
|
+
export declare class GatewayTimeoutError extends PikkuError {
|
|
178
178
|
}
|
|
179
179
|
/**
|
|
180
180
|
* The server does not support the HTTP protocol version used in the request.
|
|
181
181
|
* @group Error
|
|
182
182
|
*/
|
|
183
|
-
export declare class HTTPVersionNotSupportedError extends
|
|
183
|
+
export declare class HTTPVersionNotSupportedError extends PikkuError {
|
|
184
184
|
}
|
|
185
185
|
/**
|
|
186
186
|
* The server took too long to complete the request, reaching the maximum compute time allowed.
|
|
187
187
|
* @group Error
|
|
188
188
|
*/
|
|
189
|
-
export declare class MaxComputeTimeReachedError extends
|
|
189
|
+
export declare class MaxComputeTimeReachedError extends PikkuError {
|
|
190
190
|
}
|
package/dist/errors/errors.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The server cannot or will not process the request due to client error (e.g., malformed request syntax).
|
|
3
3
|
*/
|
|
4
|
-
import { addError,
|
|
4
|
+
import { addError, PikkuError } from './error-handler.js';
|
|
5
5
|
/**
|
|
6
6
|
* The server cannot or will not process the request due to client error (e.g., malformed request syntax).
|
|
7
7
|
* @group Error
|
|
8
8
|
*/
|
|
9
|
-
export class BadRequestError extends
|
|
9
|
+
export class BadRequestError extends PikkuError {
|
|
10
10
|
}
|
|
11
11
|
addError(BadRequestError, {
|
|
12
12
|
status: 400,
|
|
@@ -16,19 +16,19 @@ addError(BadRequestError, {
|
|
|
16
16
|
* Authentication is required and has failed or has not yet been provided.
|
|
17
17
|
* @group Error
|
|
18
18
|
*/
|
|
19
|
-
export class UnauthorizedError extends
|
|
19
|
+
export class UnauthorizedError extends PikkuError {
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* More specific error to why it's unauthorized.
|
|
23
23
|
* @group Error
|
|
24
24
|
*/
|
|
25
|
-
export class MissingSessionError extends
|
|
25
|
+
export class MissingSessionError extends PikkuError {
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* More specific error to why it's unauthorized.
|
|
29
29
|
* @group Error
|
|
30
30
|
*/
|
|
31
|
-
export class InvalidSessionError extends
|
|
31
|
+
export class InvalidSessionError extends PikkuError {
|
|
32
32
|
}
|
|
33
33
|
addError(UnauthorizedError, {
|
|
34
34
|
status: 401,
|
|
@@ -43,7 +43,7 @@ addError(InvalidSessionError, {
|
|
|
43
43
|
* Reserved for future use, often related to digital payment or subscription services.
|
|
44
44
|
* @group Error
|
|
45
45
|
*/
|
|
46
|
-
export class PaymentRequiredError extends
|
|
46
|
+
export class PaymentRequiredError extends PikkuError {
|
|
47
47
|
}
|
|
48
48
|
addError(PaymentRequiredError, {
|
|
49
49
|
status: 402,
|
|
@@ -53,7 +53,7 @@ addError(PaymentRequiredError, {
|
|
|
53
53
|
* The client does not have permission to access the requested resource.
|
|
54
54
|
* @group Error
|
|
55
55
|
*/
|
|
56
|
-
export class ForbiddenError extends
|
|
56
|
+
export class ForbiddenError extends PikkuError {
|
|
57
57
|
}
|
|
58
58
|
addError(ForbiddenError, {
|
|
59
59
|
status: 403,
|
|
@@ -63,7 +63,7 @@ addError(ForbiddenError, {
|
|
|
63
63
|
* The request was made from an origin that is not permitted to access this resource.
|
|
64
64
|
* @group Error
|
|
65
65
|
*/
|
|
66
|
-
export class InvalidOriginError extends
|
|
66
|
+
export class InvalidOriginError extends PikkuError {
|
|
67
67
|
}
|
|
68
68
|
addError(InvalidOriginError, {
|
|
69
69
|
status: 403,
|
|
@@ -73,7 +73,7 @@ addError(InvalidOriginError, {
|
|
|
73
73
|
* The server cannot find the requested resource.
|
|
74
74
|
* @group Error
|
|
75
75
|
*/
|
|
76
|
-
export class NotFoundError extends
|
|
76
|
+
export class NotFoundError extends PikkuError {
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
79
|
* The server cannot find the requested route.
|
|
@@ -87,7 +87,7 @@ addError(NotFoundError, {
|
|
|
87
87
|
* The request method is known by the server but is not supported by the resource.
|
|
88
88
|
* @group Error
|
|
89
89
|
*/
|
|
90
|
-
export class MethodNotAllowedError extends
|
|
90
|
+
export class MethodNotAllowedError extends PikkuError {
|
|
91
91
|
}
|
|
92
92
|
addError(MethodNotAllowedError, {
|
|
93
93
|
status: 405,
|
|
@@ -97,7 +97,7 @@ addError(MethodNotAllowedError, {
|
|
|
97
97
|
* The requested resource cannot produce a response matching the list of acceptable values in the request's headers.
|
|
98
98
|
* @group Error
|
|
99
99
|
*/
|
|
100
|
-
export class NotAcceptableError extends
|
|
100
|
+
export class NotAcceptableError extends PikkuError {
|
|
101
101
|
}
|
|
102
102
|
addError(NotAcceptableError, {
|
|
103
103
|
status: 406,
|
|
@@ -107,7 +107,7 @@ addError(NotAcceptableError, {
|
|
|
107
107
|
* The client must authenticate itself to get the requested response.
|
|
108
108
|
* @group Error
|
|
109
109
|
*/
|
|
110
|
-
export class ProxyAuthenticationRequiredError extends
|
|
110
|
+
export class ProxyAuthenticationRequiredError extends PikkuError {
|
|
111
111
|
}
|
|
112
112
|
addError(ProxyAuthenticationRequiredError, {
|
|
113
113
|
status: 407,
|
|
@@ -117,7 +117,7 @@ addError(ProxyAuthenticationRequiredError, {
|
|
|
117
117
|
* The server did not receive a timely response from an upstream server.
|
|
118
118
|
* @group Error
|
|
119
119
|
*/
|
|
120
|
-
export class RequestTimeoutError extends
|
|
120
|
+
export class RequestTimeoutError extends PikkuError {
|
|
121
121
|
}
|
|
122
122
|
addError(RequestTimeoutError, {
|
|
123
123
|
status: 408,
|
|
@@ -127,7 +127,7 @@ addError(RequestTimeoutError, {
|
|
|
127
127
|
* The request could not be completed due to a conflict with the current state of the target resource.
|
|
128
128
|
* @group Error
|
|
129
129
|
*/
|
|
130
|
-
export class ConflictError extends
|
|
130
|
+
export class ConflictError extends PikkuError {
|
|
131
131
|
}
|
|
132
132
|
addError(ConflictError, {
|
|
133
133
|
status: 409,
|
|
@@ -137,7 +137,7 @@ addError(ConflictError, {
|
|
|
137
137
|
* The resource that is being accessed is no longer available and will not be available again.
|
|
138
138
|
* @group Error
|
|
139
139
|
*/
|
|
140
|
-
export class GoneError extends
|
|
140
|
+
export class GoneError extends PikkuError {
|
|
141
141
|
}
|
|
142
142
|
addError(GoneError, {
|
|
143
143
|
status: 410,
|
|
@@ -147,7 +147,7 @@ addError(GoneError, {
|
|
|
147
147
|
* The request did not specify the length of its content, which is required by the requested resource.
|
|
148
148
|
* @group Error
|
|
149
149
|
*/
|
|
150
|
-
export class LengthRequiredError extends
|
|
150
|
+
export class LengthRequiredError extends PikkuError {
|
|
151
151
|
}
|
|
152
152
|
addError(LengthRequiredError, {
|
|
153
153
|
status: 411,
|
|
@@ -157,7 +157,7 @@ addError(LengthRequiredError, {
|
|
|
157
157
|
* The server does not meet one of the preconditions that the requester put on the request.
|
|
158
158
|
* @group Error
|
|
159
159
|
*/
|
|
160
|
-
export class PreconditionFailedError extends
|
|
160
|
+
export class PreconditionFailedError extends PikkuError {
|
|
161
161
|
}
|
|
162
162
|
addError(PreconditionFailedError, {
|
|
163
163
|
status: 412,
|
|
@@ -167,7 +167,7 @@ addError(PreconditionFailedError, {
|
|
|
167
167
|
* The request is larger than the server is willing or able to process.
|
|
168
168
|
* @group Error
|
|
169
169
|
*/
|
|
170
|
-
export class PayloadTooLargeError extends
|
|
170
|
+
export class PayloadTooLargeError extends PikkuError {
|
|
171
171
|
}
|
|
172
172
|
addError(PayloadTooLargeError, {
|
|
173
173
|
status: 413,
|
|
@@ -177,7 +177,7 @@ addError(PayloadTooLargeError, {
|
|
|
177
177
|
* The URI requested by the client is longer than the server is willing to interpret.
|
|
178
178
|
* @group Error
|
|
179
179
|
*/
|
|
180
|
-
export class URITooLongError extends
|
|
180
|
+
export class URITooLongError extends PikkuError {
|
|
181
181
|
}
|
|
182
182
|
addError(URITooLongError, {
|
|
183
183
|
status: 414,
|
|
@@ -187,7 +187,7 @@ addError(URITooLongError, {
|
|
|
187
187
|
* The server does not support the media format of the requested data.
|
|
188
188
|
* @group Error
|
|
189
189
|
*/
|
|
190
|
-
export class UnsupportedMediaTypeError extends
|
|
190
|
+
export class UnsupportedMediaTypeError extends PikkuError {
|
|
191
191
|
}
|
|
192
192
|
addError(UnsupportedMediaTypeError, {
|
|
193
193
|
status: 415,
|
|
@@ -197,7 +197,7 @@ addError(UnsupportedMediaTypeError, {
|
|
|
197
197
|
* The client has asked for a portion of the file, but the server cannot supply that portion.
|
|
198
198
|
* @group Error
|
|
199
199
|
*/
|
|
200
|
-
export class RangeNotSatisfiableError extends
|
|
200
|
+
export class RangeNotSatisfiableError extends PikkuError {
|
|
201
201
|
}
|
|
202
202
|
addError(RangeNotSatisfiableError, {
|
|
203
203
|
status: 416,
|
|
@@ -207,7 +207,7 @@ addError(RangeNotSatisfiableError, {
|
|
|
207
207
|
* The server cannot meet the requirements of the Expect request-header field.
|
|
208
208
|
* @group Error
|
|
209
209
|
*/
|
|
210
|
-
export class ExpectationFailedError extends
|
|
210
|
+
export class ExpectationFailedError extends PikkuError {
|
|
211
211
|
}
|
|
212
212
|
addError(ExpectationFailedError, {
|
|
213
213
|
status: 417,
|
|
@@ -217,7 +217,7 @@ addError(ExpectationFailedError, {
|
|
|
217
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
218
|
* @group Error
|
|
219
219
|
*/
|
|
220
|
-
export class UnprocessableContentError extends
|
|
220
|
+
export class UnprocessableContentError extends PikkuError {
|
|
221
221
|
}
|
|
222
222
|
addError(UnprocessableContentError, {
|
|
223
223
|
status: 422,
|
|
@@ -227,7 +227,7 @@ addError(UnprocessableContentError, {
|
|
|
227
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
228
|
* @group Error
|
|
229
229
|
*/
|
|
230
|
-
export class LockedError extends
|
|
230
|
+
export class LockedError extends PikkuError {
|
|
231
231
|
}
|
|
232
232
|
addError(LockedError, {
|
|
233
233
|
status: 423,
|
|
@@ -237,7 +237,7 @@ addError(LockedError, {
|
|
|
237
237
|
* The user has sent too many requests in a given amount of time ("rate limiting").
|
|
238
238
|
* @group Error
|
|
239
239
|
*/
|
|
240
|
-
export class TooManyRequestsError extends
|
|
240
|
+
export class TooManyRequestsError extends PikkuError {
|
|
241
241
|
}
|
|
242
242
|
addError(TooManyRequestsError, {
|
|
243
243
|
status: 429,
|
|
@@ -247,7 +247,7 @@ addError(TooManyRequestsError, {
|
|
|
247
247
|
* A generic error message, given when no more specific message is suitable.
|
|
248
248
|
* @group Error
|
|
249
249
|
*/
|
|
250
|
-
export class InternalServerError extends
|
|
250
|
+
export class InternalServerError extends PikkuError {
|
|
251
251
|
}
|
|
252
252
|
addError(InternalServerError, {
|
|
253
253
|
status: 500,
|
|
@@ -257,7 +257,7 @@ addError(InternalServerError, {
|
|
|
257
257
|
* The server does not recognize the request method and cannot support it.
|
|
258
258
|
* @group Error
|
|
259
259
|
*/
|
|
260
|
-
export class NotImplementedError extends
|
|
260
|
+
export class NotImplementedError extends PikkuError {
|
|
261
261
|
}
|
|
262
262
|
addError(NotImplementedError, {
|
|
263
263
|
status: 501,
|
|
@@ -267,7 +267,7 @@ addError(NotImplementedError, {
|
|
|
267
267
|
* The server was acting as a gateway or proxy and received an invalid response from the upstream server.
|
|
268
268
|
* @group Error
|
|
269
269
|
*/
|
|
270
|
-
export class BadGatewayError extends
|
|
270
|
+
export class BadGatewayError extends PikkuError {
|
|
271
271
|
}
|
|
272
272
|
addError(BadGatewayError, {
|
|
273
273
|
status: 502,
|
|
@@ -277,7 +277,7 @@ addError(BadGatewayError, {
|
|
|
277
277
|
* The server is currently unavailable (overloaded or down).
|
|
278
278
|
* @group Error
|
|
279
279
|
*/
|
|
280
|
-
export class ServiceUnavailableError extends
|
|
280
|
+
export class ServiceUnavailableError extends PikkuError {
|
|
281
281
|
}
|
|
282
282
|
addError(ServiceUnavailableError, {
|
|
283
283
|
status: 503,
|
|
@@ -287,7 +287,7 @@ addError(ServiceUnavailableError, {
|
|
|
287
287
|
* The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.
|
|
288
288
|
* @group Error
|
|
289
289
|
*/
|
|
290
|
-
export class GatewayTimeoutError extends
|
|
290
|
+
export class GatewayTimeoutError extends PikkuError {
|
|
291
291
|
}
|
|
292
292
|
addError(GatewayTimeoutError, {
|
|
293
293
|
status: 504,
|
|
@@ -297,7 +297,7 @@ addError(GatewayTimeoutError, {
|
|
|
297
297
|
* The server does not support the HTTP protocol version used in the request.
|
|
298
298
|
* @group Error
|
|
299
299
|
*/
|
|
300
|
-
export class HTTPVersionNotSupportedError extends
|
|
300
|
+
export class HTTPVersionNotSupportedError extends PikkuError {
|
|
301
301
|
}
|
|
302
302
|
addError(HTTPVersionNotSupportedError, {
|
|
303
303
|
status: 505,
|
|
@@ -307,7 +307,7 @@ addError(HTTPVersionNotSupportedError, {
|
|
|
307
307
|
* The server took too long to complete the request, reaching the maximum compute time allowed.
|
|
308
308
|
* @group Error
|
|
309
309
|
*/
|
|
310
|
-
export class MaxComputeTimeReachedError extends
|
|
310
|
+
export class MaxComputeTimeReachedError extends PikkuError {
|
|
311
311
|
}
|
|
312
312
|
addError(MaxComputeTimeReachedError, {
|
|
313
313
|
status: 524,
|
|
@@ -21,7 +21,7 @@ export declare const getRoutes: () => {
|
|
|
21
21
|
routesMeta: HTTPRoutesMeta;
|
|
22
22
|
};
|
|
23
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<
|
|
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<CoreUserSession | undefined>;
|
|
25
25
|
export declare const createHTTPInteraction: (request: PikkuRequest | undefined, response: PikkuResponse | undefined) => PikkuHTTP | undefined;
|
|
26
26
|
export declare const handleError: (e: any, http: PikkuHTTP | undefined, trackerId: string, logger: Logger, logWarningsForStatusCodes: number[], respondWith404: boolean, bubbleError: boolean) => void;
|
|
27
27
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PikkuError } from '../errors/error-handler.js';
|
|
2
2
|
import { APIDocs, CoreServices, CoreSingletonServices, CoreUserSession, CreateSessionServices } from '../types/core.types.js';
|
|
3
3
|
import { CoreAPIFunction, CoreAPIFunctionSessionless, CoreAPIPermission } from '../types/functions.types.js';
|
|
4
4
|
import { PikkuRequest } from '../pikku-request.js';
|
|
@@ -36,7 +36,7 @@ export type CoreHTTPFunction = {
|
|
|
36
36
|
docs?: Partial<{
|
|
37
37
|
description: string;
|
|
38
38
|
response: string;
|
|
39
|
-
errors: Array<typeof
|
|
39
|
+
errors: Array<typeof PikkuError>;
|
|
40
40
|
tags: string[];
|
|
41
41
|
}>;
|
|
42
42
|
};
|
|
@@ -49,7 +49,7 @@ export async function runScheduledTask({ name, session, singletonServices, creat
|
|
|
49
49
|
if (!task) {
|
|
50
50
|
throw new ScheduledTaskNotFoundError(`Scheduled task not found: ${name}`);
|
|
51
51
|
}
|
|
52
|
-
singletonServices.logger.info(`Running schedule task: ${name} | schedule: ${task.schedule}
|
|
52
|
+
singletonServices.logger.info(`Running schedule task: ${name} | schedule: ${task.schedule}`);
|
|
53
53
|
let allServices = singletonServices;
|
|
54
54
|
if (createSessionServices) {
|
|
55
55
|
const sessionServices = await createSessionServices(singletonServices, {}, session);
|
|
@@ -47,11 +47,12 @@ export type CoreConfig<Config extends Record<string, unknown> = {}> = {
|
|
|
47
47
|
/**
|
|
48
48
|
* Represents a core user session, which can be extended for more specific session information.
|
|
49
49
|
*/
|
|
50
|
-
export
|
|
50
|
+
export interface CoreUserSession {
|
|
51
|
+
}
|
|
51
52
|
/**
|
|
52
53
|
* Interface for core singleton services provided by Pikku.
|
|
53
54
|
*/
|
|
54
|
-
export
|
|
55
|
+
export interface CoreSingletonServices<Config extends CoreConfig = CoreConfig, UserSession extends CoreUserSession = CoreUserSession> {
|
|
55
56
|
/** The http permission service used for authorization (optional). */
|
|
56
57
|
enforceHTTPAccess?: enforceHTTPAccess;
|
|
57
58
|
/** The channel permission service used by the application (optional). */
|
|
@@ -72,7 +73,7 @@ export type CoreSingletonServices<Config extends CoreConfig = CoreConfig, UserSe
|
|
|
72
73
|
eventHub?: EventHubService<unknown>;
|
|
73
74
|
/** SecretServce */
|
|
74
75
|
secretService?: SecretService;
|
|
75
|
-
}
|
|
76
|
+
}
|
|
76
77
|
/**
|
|
77
78
|
* Represents different forms of interaction within Pikku and the outside world.
|
|
78
79
|
*/
|