@periodic/obsidian 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.
@@ -0,0 +1,162 @@
1
+ import { Request, ErrorRequestHandler } from 'express';
2
+
3
+ interface HttpErrorOptions {
4
+ code?: string;
5
+ details?: unknown;
6
+ }
7
+ interface HttpErrorJSON {
8
+ status: number;
9
+ message: string;
10
+ code?: string;
11
+ details?: unknown;
12
+ }
13
+
14
+ declare class HttpError extends Error {
15
+ readonly status: number;
16
+ readonly code?: string;
17
+ readonly details?: unknown;
18
+ constructor(status: number, message: string, options?: HttpErrorOptions);
19
+ toJSON(): HttpErrorJSON;
20
+ static getDefaultMessage(status: number): string;
21
+ }
22
+
23
+ declare const HttpStatusCode: {
24
+ readonly CONTINUE: 100;
25
+ readonly SWITCHING_PROTOCOLS: 101;
26
+ readonly PROCESSING: 102;
27
+ readonly EARLY_HINTS: 103;
28
+ readonly OK: 200;
29
+ readonly CREATED: 201;
30
+ readonly ACCEPTED: 202;
31
+ readonly NON_AUTHORITATIVE_INFORMATION: 203;
32
+ readonly NO_CONTENT: 204;
33
+ readonly RESET_CONTENT: 205;
34
+ readonly PARTIAL_CONTENT: 206;
35
+ readonly MULTI_STATUS: 207;
36
+ readonly ALREADY_REPORTED: 208;
37
+ readonly IM_USED: 226;
38
+ readonly MULTIPLE_CHOICES: 300;
39
+ readonly MOVED_PERMANENTLY: 301;
40
+ readonly FOUND: 302;
41
+ readonly SEE_OTHER: 303;
42
+ readonly NOT_MODIFIED: 304;
43
+ readonly USE_PROXY: 305;
44
+ readonly TEMPORARY_REDIRECT: 307;
45
+ readonly PERMANENT_REDIRECT: 308;
46
+ readonly BAD_REQUEST: 400;
47
+ readonly UNAUTHORIZED: 401;
48
+ readonly PAYMENT_REQUIRED: 402;
49
+ readonly FORBIDDEN: 403;
50
+ readonly NOT_FOUND: 404;
51
+ readonly METHOD_NOT_ALLOWED: 405;
52
+ readonly NOT_ACCEPTABLE: 406;
53
+ readonly PROXY_AUTHENTICATION_REQUIRED: 407;
54
+ readonly REQUEST_TIMEOUT: 408;
55
+ readonly CONFLICT: 409;
56
+ readonly GONE: 410;
57
+ readonly LENGTH_REQUIRED: 411;
58
+ readonly PRECONDITION_FAILED: 412;
59
+ readonly PAYLOAD_TOO_LARGE: 413;
60
+ readonly URI_TOO_LONG: 414;
61
+ readonly UNSUPPORTED_MEDIA_TYPE: 415;
62
+ readonly RANGE_NOT_SATISFIABLE: 416;
63
+ readonly EXPECTATION_FAILED: 417;
64
+ readonly IM_A_TEAPOT: 418;
65
+ readonly MISDIRECTED_REQUEST: 421;
66
+ readonly UNPROCESSABLE_ENTITY: 422;
67
+ readonly LOCKED: 423;
68
+ readonly FAILED_DEPENDENCY: 424;
69
+ readonly TOO_EARLY: 425;
70
+ readonly UPGRADE_REQUIRED: 426;
71
+ readonly PRECONDITION_REQUIRED: 428;
72
+ readonly TOO_MANY_REQUESTS: 429;
73
+ readonly REQUEST_HEADER_FIELDS_TOO_LARGE: 431;
74
+ readonly UNAVAILABLE_FOR_LEGAL_REASONS: 451;
75
+ readonly INTERNAL_SERVER_ERROR: 500;
76
+ readonly NOT_IMPLEMENTED: 501;
77
+ readonly BAD_GATEWAY: 502;
78
+ readonly SERVICE_UNAVAILABLE: 503;
79
+ readonly GATEWAY_TIMEOUT: 504;
80
+ readonly HTTP_VERSION_NOT_SUPPORTED: 505;
81
+ readonly VARIANT_ALSO_NEGOTIATES: 506;
82
+ readonly INSUFFICIENT_STORAGE: 507;
83
+ readonly LOOP_DETECTED: 508;
84
+ readonly NOT_EXTENDED: 510;
85
+ readonly NETWORK_AUTHENTICATION_REQUIRED: 511;
86
+ };
87
+ declare const HttpStatusMessage: Record<number, string>;
88
+
89
+ interface ExpressErrorHandlerOptions {
90
+ includeStack?: boolean;
91
+ logger?: (error: Error, req: Request) => void;
92
+ transform?: (error: HttpError) => Record<string, unknown>;
93
+ }
94
+ declare function errorHandler(options?: ExpressErrorHandlerOptions): ErrorRequestHandler;
95
+ declare function simpleErrorHandler(): ErrorRequestHandler;
96
+
97
+ declare const obsidian: {
98
+ readonly continue: (message?: string, options?: HttpErrorOptions) => HttpError;
99
+ readonly switchingProtocols: (message?: string, options?: HttpErrorOptions) => HttpError;
100
+ readonly processing: (message?: string, options?: HttpErrorOptions) => HttpError;
101
+ readonly earlyHints: (message?: string, options?: HttpErrorOptions) => HttpError;
102
+ readonly ok: (message?: string, options?: HttpErrorOptions) => HttpError;
103
+ readonly created: (message?: string, options?: HttpErrorOptions) => HttpError;
104
+ readonly accepted: (message?: string, options?: HttpErrorOptions) => HttpError;
105
+ readonly nonAuthoritativeInformation: (message?: string, options?: HttpErrorOptions) => HttpError;
106
+ readonly noContent: (message?: string, options?: HttpErrorOptions) => HttpError;
107
+ readonly resetContent: (message?: string, options?: HttpErrorOptions) => HttpError;
108
+ readonly partialContent: (message?: string, options?: HttpErrorOptions) => HttpError;
109
+ readonly multiStatus: (message?: string, options?: HttpErrorOptions) => HttpError;
110
+ readonly alreadyReported: (message?: string, options?: HttpErrorOptions) => HttpError;
111
+ readonly imUsed: (message?: string, options?: HttpErrorOptions) => HttpError;
112
+ readonly multipleChoices: (message?: string, options?: HttpErrorOptions) => HttpError;
113
+ readonly movedPermanently: (message?: string, options?: HttpErrorOptions) => HttpError;
114
+ readonly found: (message?: string, options?: HttpErrorOptions) => HttpError;
115
+ readonly seeOther: (message?: string, options?: HttpErrorOptions) => HttpError;
116
+ readonly notModified: (message?: string, options?: HttpErrorOptions) => HttpError;
117
+ readonly useProxy: (message?: string, options?: HttpErrorOptions) => HttpError;
118
+ readonly temporaryRedirect: (message?: string, options?: HttpErrorOptions) => HttpError;
119
+ readonly permanentRedirect: (message?: string, options?: HttpErrorOptions) => HttpError;
120
+ readonly badRequest: (message?: string, options?: HttpErrorOptions) => HttpError;
121
+ readonly unauthorized: (message?: string, options?: HttpErrorOptions) => HttpError;
122
+ readonly paymentRequired: (message?: string, options?: HttpErrorOptions) => HttpError;
123
+ readonly forbidden: (message?: string, options?: HttpErrorOptions) => HttpError;
124
+ readonly notFound: (message?: string, options?: HttpErrorOptions) => HttpError;
125
+ readonly methodNotAllowed: (message?: string, options?: HttpErrorOptions) => HttpError;
126
+ readonly notAcceptable: (message?: string, options?: HttpErrorOptions) => HttpError;
127
+ readonly proxyAuthenticationRequired: (message?: string, options?: HttpErrorOptions) => HttpError;
128
+ readonly requestTimeout: (message?: string, options?: HttpErrorOptions) => HttpError;
129
+ readonly conflict: (message?: string, options?: HttpErrorOptions) => HttpError;
130
+ readonly gone: (message?: string, options?: HttpErrorOptions) => HttpError;
131
+ readonly lengthRequired: (message?: string, options?: HttpErrorOptions) => HttpError;
132
+ readonly preconditionFailed: (message?: string, options?: HttpErrorOptions) => HttpError;
133
+ readonly payloadTooLarge: (message?: string, options?: HttpErrorOptions) => HttpError;
134
+ readonly uriTooLong: (message?: string, options?: HttpErrorOptions) => HttpError;
135
+ readonly unsupportedMediaType: (message?: string, options?: HttpErrorOptions) => HttpError;
136
+ readonly rangeNotSatisfiable: (message?: string, options?: HttpErrorOptions) => HttpError;
137
+ readonly expectationFailed: (message?: string, options?: HttpErrorOptions) => HttpError;
138
+ readonly imATeapot: (message?: string, options?: HttpErrorOptions) => HttpError;
139
+ readonly misdirectedRequest: (message?: string, options?: HttpErrorOptions) => HttpError;
140
+ readonly unprocessableEntity: (message?: string, options?: HttpErrorOptions) => HttpError;
141
+ readonly locked: (message?: string, options?: HttpErrorOptions) => HttpError;
142
+ readonly failedDependency: (message?: string, options?: HttpErrorOptions) => HttpError;
143
+ readonly tooEarly: (message?: string, options?: HttpErrorOptions) => HttpError;
144
+ readonly upgradeRequired: (message?: string, options?: HttpErrorOptions) => HttpError;
145
+ readonly preconditionRequired: (message?: string, options?: HttpErrorOptions) => HttpError;
146
+ readonly tooManyRequests: (message?: string, options?: HttpErrorOptions) => HttpError;
147
+ readonly requestHeaderFieldsTooLarge: (message?: string, options?: HttpErrorOptions) => HttpError;
148
+ readonly unavailableForLegalReasons: (message?: string, options?: HttpErrorOptions) => HttpError;
149
+ readonly internalServerError: (message?: string, options?: HttpErrorOptions) => HttpError;
150
+ readonly badGateway: (message?: string, options?: HttpErrorOptions) => HttpError;
151
+ readonly serviceUnavailable: (message?: string, options?: HttpErrorOptions) => HttpError;
152
+ readonly gatewayTimeout: (message?: string, options?: HttpErrorOptions) => HttpError;
153
+ readonly notImplemented: (message?: string, options?: HttpErrorOptions) => HttpError;
154
+ readonly httpVersionNotSupported: (message?: string, options?: HttpErrorOptions) => HttpError;
155
+ readonly variantAlsoNegotiates: (message?: string, options?: HttpErrorOptions) => HttpError;
156
+ readonly insufficientStorage: (message?: string, options?: HttpErrorOptions) => HttpError;
157
+ readonly loopDetected: (message?: string, options?: HttpErrorOptions) => HttpError;
158
+ readonly notExtended: (message?: string, options?: HttpErrorOptions) => HttpError;
159
+ readonly networkAuthenticationRequired: (message?: string, options?: HttpErrorOptions) => HttpError;
160
+ };
161
+
162
+ export { type ExpressErrorHandlerOptions, HttpError, type HttpErrorJSON, type HttpErrorOptions, HttpStatusCode, HttpStatusMessage, errorHandler, obsidian, simpleErrorHandler, obsidian as titanium };
@@ -0,0 +1,162 @@
1
+ import { Request, ErrorRequestHandler } from 'express';
2
+
3
+ interface HttpErrorOptions {
4
+ code?: string;
5
+ details?: unknown;
6
+ }
7
+ interface HttpErrorJSON {
8
+ status: number;
9
+ message: string;
10
+ code?: string;
11
+ details?: unknown;
12
+ }
13
+
14
+ declare class HttpError extends Error {
15
+ readonly status: number;
16
+ readonly code?: string;
17
+ readonly details?: unknown;
18
+ constructor(status: number, message: string, options?: HttpErrorOptions);
19
+ toJSON(): HttpErrorJSON;
20
+ static getDefaultMessage(status: number): string;
21
+ }
22
+
23
+ declare const HttpStatusCode: {
24
+ readonly CONTINUE: 100;
25
+ readonly SWITCHING_PROTOCOLS: 101;
26
+ readonly PROCESSING: 102;
27
+ readonly EARLY_HINTS: 103;
28
+ readonly OK: 200;
29
+ readonly CREATED: 201;
30
+ readonly ACCEPTED: 202;
31
+ readonly NON_AUTHORITATIVE_INFORMATION: 203;
32
+ readonly NO_CONTENT: 204;
33
+ readonly RESET_CONTENT: 205;
34
+ readonly PARTIAL_CONTENT: 206;
35
+ readonly MULTI_STATUS: 207;
36
+ readonly ALREADY_REPORTED: 208;
37
+ readonly IM_USED: 226;
38
+ readonly MULTIPLE_CHOICES: 300;
39
+ readonly MOVED_PERMANENTLY: 301;
40
+ readonly FOUND: 302;
41
+ readonly SEE_OTHER: 303;
42
+ readonly NOT_MODIFIED: 304;
43
+ readonly USE_PROXY: 305;
44
+ readonly TEMPORARY_REDIRECT: 307;
45
+ readonly PERMANENT_REDIRECT: 308;
46
+ readonly BAD_REQUEST: 400;
47
+ readonly UNAUTHORIZED: 401;
48
+ readonly PAYMENT_REQUIRED: 402;
49
+ readonly FORBIDDEN: 403;
50
+ readonly NOT_FOUND: 404;
51
+ readonly METHOD_NOT_ALLOWED: 405;
52
+ readonly NOT_ACCEPTABLE: 406;
53
+ readonly PROXY_AUTHENTICATION_REQUIRED: 407;
54
+ readonly REQUEST_TIMEOUT: 408;
55
+ readonly CONFLICT: 409;
56
+ readonly GONE: 410;
57
+ readonly LENGTH_REQUIRED: 411;
58
+ readonly PRECONDITION_FAILED: 412;
59
+ readonly PAYLOAD_TOO_LARGE: 413;
60
+ readonly URI_TOO_LONG: 414;
61
+ readonly UNSUPPORTED_MEDIA_TYPE: 415;
62
+ readonly RANGE_NOT_SATISFIABLE: 416;
63
+ readonly EXPECTATION_FAILED: 417;
64
+ readonly IM_A_TEAPOT: 418;
65
+ readonly MISDIRECTED_REQUEST: 421;
66
+ readonly UNPROCESSABLE_ENTITY: 422;
67
+ readonly LOCKED: 423;
68
+ readonly FAILED_DEPENDENCY: 424;
69
+ readonly TOO_EARLY: 425;
70
+ readonly UPGRADE_REQUIRED: 426;
71
+ readonly PRECONDITION_REQUIRED: 428;
72
+ readonly TOO_MANY_REQUESTS: 429;
73
+ readonly REQUEST_HEADER_FIELDS_TOO_LARGE: 431;
74
+ readonly UNAVAILABLE_FOR_LEGAL_REASONS: 451;
75
+ readonly INTERNAL_SERVER_ERROR: 500;
76
+ readonly NOT_IMPLEMENTED: 501;
77
+ readonly BAD_GATEWAY: 502;
78
+ readonly SERVICE_UNAVAILABLE: 503;
79
+ readonly GATEWAY_TIMEOUT: 504;
80
+ readonly HTTP_VERSION_NOT_SUPPORTED: 505;
81
+ readonly VARIANT_ALSO_NEGOTIATES: 506;
82
+ readonly INSUFFICIENT_STORAGE: 507;
83
+ readonly LOOP_DETECTED: 508;
84
+ readonly NOT_EXTENDED: 510;
85
+ readonly NETWORK_AUTHENTICATION_REQUIRED: 511;
86
+ };
87
+ declare const HttpStatusMessage: Record<number, string>;
88
+
89
+ interface ExpressErrorHandlerOptions {
90
+ includeStack?: boolean;
91
+ logger?: (error: Error, req: Request) => void;
92
+ transform?: (error: HttpError) => Record<string, unknown>;
93
+ }
94
+ declare function errorHandler(options?: ExpressErrorHandlerOptions): ErrorRequestHandler;
95
+ declare function simpleErrorHandler(): ErrorRequestHandler;
96
+
97
+ declare const obsidian: {
98
+ readonly continue: (message?: string, options?: HttpErrorOptions) => HttpError;
99
+ readonly switchingProtocols: (message?: string, options?: HttpErrorOptions) => HttpError;
100
+ readonly processing: (message?: string, options?: HttpErrorOptions) => HttpError;
101
+ readonly earlyHints: (message?: string, options?: HttpErrorOptions) => HttpError;
102
+ readonly ok: (message?: string, options?: HttpErrorOptions) => HttpError;
103
+ readonly created: (message?: string, options?: HttpErrorOptions) => HttpError;
104
+ readonly accepted: (message?: string, options?: HttpErrorOptions) => HttpError;
105
+ readonly nonAuthoritativeInformation: (message?: string, options?: HttpErrorOptions) => HttpError;
106
+ readonly noContent: (message?: string, options?: HttpErrorOptions) => HttpError;
107
+ readonly resetContent: (message?: string, options?: HttpErrorOptions) => HttpError;
108
+ readonly partialContent: (message?: string, options?: HttpErrorOptions) => HttpError;
109
+ readonly multiStatus: (message?: string, options?: HttpErrorOptions) => HttpError;
110
+ readonly alreadyReported: (message?: string, options?: HttpErrorOptions) => HttpError;
111
+ readonly imUsed: (message?: string, options?: HttpErrorOptions) => HttpError;
112
+ readonly multipleChoices: (message?: string, options?: HttpErrorOptions) => HttpError;
113
+ readonly movedPermanently: (message?: string, options?: HttpErrorOptions) => HttpError;
114
+ readonly found: (message?: string, options?: HttpErrorOptions) => HttpError;
115
+ readonly seeOther: (message?: string, options?: HttpErrorOptions) => HttpError;
116
+ readonly notModified: (message?: string, options?: HttpErrorOptions) => HttpError;
117
+ readonly useProxy: (message?: string, options?: HttpErrorOptions) => HttpError;
118
+ readonly temporaryRedirect: (message?: string, options?: HttpErrorOptions) => HttpError;
119
+ readonly permanentRedirect: (message?: string, options?: HttpErrorOptions) => HttpError;
120
+ readonly badRequest: (message?: string, options?: HttpErrorOptions) => HttpError;
121
+ readonly unauthorized: (message?: string, options?: HttpErrorOptions) => HttpError;
122
+ readonly paymentRequired: (message?: string, options?: HttpErrorOptions) => HttpError;
123
+ readonly forbidden: (message?: string, options?: HttpErrorOptions) => HttpError;
124
+ readonly notFound: (message?: string, options?: HttpErrorOptions) => HttpError;
125
+ readonly methodNotAllowed: (message?: string, options?: HttpErrorOptions) => HttpError;
126
+ readonly notAcceptable: (message?: string, options?: HttpErrorOptions) => HttpError;
127
+ readonly proxyAuthenticationRequired: (message?: string, options?: HttpErrorOptions) => HttpError;
128
+ readonly requestTimeout: (message?: string, options?: HttpErrorOptions) => HttpError;
129
+ readonly conflict: (message?: string, options?: HttpErrorOptions) => HttpError;
130
+ readonly gone: (message?: string, options?: HttpErrorOptions) => HttpError;
131
+ readonly lengthRequired: (message?: string, options?: HttpErrorOptions) => HttpError;
132
+ readonly preconditionFailed: (message?: string, options?: HttpErrorOptions) => HttpError;
133
+ readonly payloadTooLarge: (message?: string, options?: HttpErrorOptions) => HttpError;
134
+ readonly uriTooLong: (message?: string, options?: HttpErrorOptions) => HttpError;
135
+ readonly unsupportedMediaType: (message?: string, options?: HttpErrorOptions) => HttpError;
136
+ readonly rangeNotSatisfiable: (message?: string, options?: HttpErrorOptions) => HttpError;
137
+ readonly expectationFailed: (message?: string, options?: HttpErrorOptions) => HttpError;
138
+ readonly imATeapot: (message?: string, options?: HttpErrorOptions) => HttpError;
139
+ readonly misdirectedRequest: (message?: string, options?: HttpErrorOptions) => HttpError;
140
+ readonly unprocessableEntity: (message?: string, options?: HttpErrorOptions) => HttpError;
141
+ readonly locked: (message?: string, options?: HttpErrorOptions) => HttpError;
142
+ readonly failedDependency: (message?: string, options?: HttpErrorOptions) => HttpError;
143
+ readonly tooEarly: (message?: string, options?: HttpErrorOptions) => HttpError;
144
+ readonly upgradeRequired: (message?: string, options?: HttpErrorOptions) => HttpError;
145
+ readonly preconditionRequired: (message?: string, options?: HttpErrorOptions) => HttpError;
146
+ readonly tooManyRequests: (message?: string, options?: HttpErrorOptions) => HttpError;
147
+ readonly requestHeaderFieldsTooLarge: (message?: string, options?: HttpErrorOptions) => HttpError;
148
+ readonly unavailableForLegalReasons: (message?: string, options?: HttpErrorOptions) => HttpError;
149
+ readonly internalServerError: (message?: string, options?: HttpErrorOptions) => HttpError;
150
+ readonly badGateway: (message?: string, options?: HttpErrorOptions) => HttpError;
151
+ readonly serviceUnavailable: (message?: string, options?: HttpErrorOptions) => HttpError;
152
+ readonly gatewayTimeout: (message?: string, options?: HttpErrorOptions) => HttpError;
153
+ readonly notImplemented: (message?: string, options?: HttpErrorOptions) => HttpError;
154
+ readonly httpVersionNotSupported: (message?: string, options?: HttpErrorOptions) => HttpError;
155
+ readonly variantAlsoNegotiates: (message?: string, options?: HttpErrorOptions) => HttpError;
156
+ readonly insufficientStorage: (message?: string, options?: HttpErrorOptions) => HttpError;
157
+ readonly loopDetected: (message?: string, options?: HttpErrorOptions) => HttpError;
158
+ readonly notExtended: (message?: string, options?: HttpErrorOptions) => HttpError;
159
+ readonly networkAuthenticationRequired: (message?: string, options?: HttpErrorOptions) => HttpError;
160
+ };
161
+
162
+ export { type ExpressErrorHandlerOptions, HttpError, type HttpErrorJSON, type HttpErrorOptions, HttpStatusCode, HttpStatusMessage, errorHandler, obsidian, simpleErrorHandler, obsidian as titanium };