@design-edito/publisher-core 0.0.1
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/README.md +265 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5105 -0
- package/dist/index.js.map +7 -0
- package/dist/public/empty.txt +0 -0
- package/dist/types/api/admin/temp/flush/index.d.ts +6 -0
- package/dist/types/api/admin/users/create/index.d.ts +23 -0
- package/dist/types/api/admin/users/delete/index.d.ts +12 -0
- package/dist/types/api/admin/users/get/index.d.ts +18 -0
- package/dist/types/api/admin/users/get-upload-quota/index.d.ts +12 -0
- package/dist/types/api/admin/users/list/index.d.ts +24 -0
- package/dist/types/api/admin/users/reset-upload-quota/index.d.ts +15 -0
- package/dist/types/api/admin/users/revoke-auth-tokens/index.d.ts +10 -0
- package/dist/types/api/admin/users/revoke-email-validation-tokens/index.d.ts +10 -0
- package/dist/types/api/admin/users/revoke-pasword-renewal-tokens/index.d.ts +10 -0
- package/dist/types/api/admin/users/update/index.d.ts +23 -0
- package/dist/types/api/auth/login/index.d.ts +15 -0
- package/dist/types/api/auth/logout/index.d.ts +5 -0
- package/dist/types/api/auth/logout-everywhere/index.d.ts +5 -0
- package/dist/types/api/auth/refresh-token/index.d.ts +5 -0
- package/dist/types/api/auth/request-email-verification-token/index.d.ts +9 -0
- package/dist/types/api/auth/request-new-password/index.d.ts +9 -0
- package/dist/types/api/auth/signup/index.d.ts +13 -0
- package/dist/types/api/auth/submit-new-password/index.d.ts +11 -0
- package/dist/types/api/auth/verify-email/index.d.ts +12 -0
- package/dist/types/api/auth/whoami/index.d.ts +8 -0
- package/dist/types/api/csrf/get-token/index.d.ts +8 -0
- package/dist/types/api/image/format/index.d.ts +28 -0
- package/dist/types/api/image/transform/index.d.ts +11 -0
- package/dist/types/api/index.d.ts +102 -0
- package/dist/types/api/internals.d.ts +270 -0
- package/dist/types/api/system/kill/index.d.ts +3 -0
- package/dist/types/api/system/ping/index.d.ts +6 -0
- package/dist/types/api/system/send-mail/index.d.ts +11 -0
- package/dist/types/api/system/status-check/index.d.ts +22 -0
- package/dist/types/auth/index.d.ts +11 -0
- package/dist/types/csrf/index.d.ts +5 -0
- package/dist/types/database/index.d.ts +69 -0
- package/dist/types/dto/index.d.ts +25 -0
- package/dist/types/email/index.d.ts +6 -0
- package/dist/types/env/index.d.ts +83 -0
- package/dist/types/errors/index.d.ts +295 -0
- package/dist/types/fs/index.d.ts +110 -0
- package/dist/types/index.d.ts +21 -0
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +7 -0
- package/dist/types/init/index.d.ts +1 -0
- package/dist/types/jwt/index.d.ts +7 -0
- package/dist/types/logs/index.d.ts +46 -0
- package/dist/types/plugins/index.d.ts +3 -0
- package/dist/types/plugins/internals.d.ts +177 -0
- package/dist/types/schema/index.d.ts +156 -0
- package/dist/types/temp/index.d.ts +7 -0
- package/dist/types/transformers/index.d.ts +3 -0
- package/dist/types/transformers/user/index.d.ts +5 -0
- package/dist/types/transformers/user-upload-quota/index.d.ts +3 -0
- package/dist/types/uploads/index.d.ts +73 -0
- package/dist/types/validation/index.d.ts +4 -0
- package/package.json +280 -0
@@ -0,0 +1,295 @@
|
|
1
|
+
import type { Outcome } from '@design-edito/tools/agnostic/misc/outcome/index.js';
|
2
|
+
export declare enum Codes {
|
3
|
+
HTTP_FORBIDDEN = "http-forbidden",
|
4
|
+
UNKNOWN_ERROR = "unknown-error",
|
5
|
+
DB_ERROR = "db-error",
|
6
|
+
DB_NO_DOCUMENT_MATCHES_FILTER = "db-no-document-matches-filter",
|
7
|
+
DB_RECURSION_LIMIT_REACHED = "db-recursion-limit-reached",
|
8
|
+
RESPONSE_STREAM_FAILED = "response-stream-failed",
|
9
|
+
USER_NOT_AUTHENTICATED = "user-not-authenticated",
|
10
|
+
USER_NOT_AUTHORIZED = "user-not-authorized",
|
11
|
+
USER_DOES_NOT_EXIST = "user-does-not-exist",
|
12
|
+
USER_EMAIL_DOES_NOT_EXIST = "user-email-does-not-exist",
|
13
|
+
USERNAME_ALREADY_TAKEN = "username-already-taken",
|
14
|
+
EMAIL_ADDRESS_ALREADY_TAKEN = "email-address-already-taken",
|
15
|
+
USER_EMAIL_VERIFICATION_TOKEN_NOT_PROVIDED = "user-email-verification-token-not-provided",
|
16
|
+
USER_EMAIL_VERIFICATION_TOKEN_DOES_NOT_EXIST = "user-email-verification-token-does-not-exist",
|
17
|
+
USER_EMAIL_VERIFICATION_PROCESS_FAILED = "user-email-verification-process-failed",
|
18
|
+
USER_EMAIL_ALREADY_VERIFIED = "user-email-already-verified",
|
19
|
+
INVALID_CREDENTIALS = "invalid-credentials",
|
20
|
+
USER_PASSWORD_RENEWAL_TOKEN_DOES_NOT_EXIST = "user-password-renewal-token-does-not-exist",
|
21
|
+
USER_REFRESH_TOKEN_MISSING = "user-refresh-token-missing",
|
22
|
+
USER_REFRESH_TOKEN_REVOKED = "user-refresh-token-revoked",
|
23
|
+
USER_REFRESH_TOKEN_MALFORMED = "user-refresh-token-malformed",
|
24
|
+
USER_REFRESH_TOKEN_EXPIRED = "user-refresh-token-expired",
|
25
|
+
USER_TOKENS_REVOCATION_FAILED = "user-tokens-revocation-failed",
|
26
|
+
USER_ACCESS_TOKEN_GENERATION_FAILED = "user-access-token-generation-failed",
|
27
|
+
USER_REFRESH_TOKEN_GENERATION_FAILED = "user-refresh-token-generation-failed",
|
28
|
+
INVALID_CSRF_TOKEN = "invalid-csrf-token",
|
29
|
+
INVALID_REQUEST_BODY = "invalid-request-body",
|
30
|
+
INVALID_REQUEST_QUERY = "invalid-request-query",
|
31
|
+
INVALID_REQUEST_FILES = "invalid-request-files",
|
32
|
+
INVALID_RESPONSE_BODY = "invalid-response-body",
|
33
|
+
TOO_MANY_REQUESTS = "too-many-requests",
|
34
|
+
USER_DAILY_UPLOAD_QUOTA_EXCEEDED = "user-daily-upload-quota-exceeded",
|
35
|
+
USER_MONTHLY_UPLOAD_QUOTA_EXCEEDED = "user-monthly-upload-quota-exceeded",
|
36
|
+
USER_TOTAL_UPLOAD_QUOTA_EXCEEDED = "user-total-upload-quota-exceeded",
|
37
|
+
USER_UPLOAD_QUOTA_EXCEEDED = "user-upload-quota-exceeded",
|
38
|
+
UPLOAD_FAILED = "upload-failed",
|
39
|
+
FILE_PATH_CIRCULAR_PATTERN_DETECTED = "file-path-circular-pattern-detected",
|
40
|
+
FILE_NOT_FOUND = "file-not-found",
|
41
|
+
FILE_ALREADY_IN_TRASH = "file-already-in-trash",
|
42
|
+
FILE_NOT_IN_TRASH = "file-not-in-trash",
|
43
|
+
FILE_CORRUPTED = "file-corrupted",
|
44
|
+
FILE_INFECTED = "file-infected",
|
45
|
+
FILE_EMPTY = "file-empty",
|
46
|
+
FILE_TOO_LARGE = "file-too-large",
|
47
|
+
FILE_HASH_FAILED = "file-hash-failed",
|
48
|
+
FILE_SCANNER_NOT_REACHABLE = "file-scanner-not-reachable",
|
49
|
+
IMAGE_FORMAT_FAILED = "image-format-failed",
|
50
|
+
IMAGE_TRANSFORM_FAILED = "image-transform-failed",
|
51
|
+
NOT_FOUND = "not-found"
|
52
|
+
}
|
53
|
+
export declare const register: {
|
54
|
+
readonly "http-forbidden": {
|
55
|
+
readonly message: "The connection must be made over HTTPS";
|
56
|
+
readonly detailsMaker: () => undefined;
|
57
|
+
};
|
58
|
+
readonly "unknown-error": {
|
59
|
+
readonly message: "An unknown error occured";
|
60
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
61
|
+
};
|
62
|
+
readonly "db-error": {
|
63
|
+
readonly message: "The database returned an error";
|
64
|
+
readonly detailsMaker: (dbError: string) => {
|
65
|
+
dbError: string;
|
66
|
+
};
|
67
|
+
};
|
68
|
+
readonly "db-no-document-matches-filter": {
|
69
|
+
readonly message: "No document matches the provided filter";
|
70
|
+
readonly detailsMaker: (collectionName: string, filter: any) => {
|
71
|
+
collection: string;
|
72
|
+
filter: string;
|
73
|
+
};
|
74
|
+
};
|
75
|
+
readonly "db-recursion-limit-reached": {
|
76
|
+
readonly message: "The recursion limit has been reached";
|
77
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
78
|
+
};
|
79
|
+
readonly "response-stream-failed": {
|
80
|
+
readonly message: "Failed to stream the file";
|
81
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
82
|
+
};
|
83
|
+
readonly "user-not-authenticated": {
|
84
|
+
readonly message: "User must be authenticated";
|
85
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
86
|
+
};
|
87
|
+
readonly "user-not-authorized": {
|
88
|
+
readonly message: "User has not sufficient permissions";
|
89
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
90
|
+
};
|
91
|
+
readonly "user-does-not-exist": {
|
92
|
+
readonly message: "Impossible to retreive user information";
|
93
|
+
readonly detailsMaker: (userId: string) => {
|
94
|
+
userId: string;
|
95
|
+
};
|
96
|
+
};
|
97
|
+
readonly "user-email-does-not-exist": {
|
98
|
+
readonly message: "This email is not tied to any user account";
|
99
|
+
readonly detailsMaker: (email: string) => {
|
100
|
+
email: string;
|
101
|
+
};
|
102
|
+
};
|
103
|
+
readonly "username-already-taken": {
|
104
|
+
readonly message: "This username is already taken";
|
105
|
+
readonly detailsMaker: (username: string) => {
|
106
|
+
username: string;
|
107
|
+
};
|
108
|
+
};
|
109
|
+
readonly "email-address-already-taken": {
|
110
|
+
readonly message: "This email address is already taken";
|
111
|
+
readonly detailsMaker: (email: string) => {
|
112
|
+
email: string;
|
113
|
+
};
|
114
|
+
};
|
115
|
+
readonly "user-email-verification-token-not-provided": {
|
116
|
+
readonly message: "This endpoint expects a token in the URL to process the validation";
|
117
|
+
readonly detailsMaker: () => undefined;
|
118
|
+
};
|
119
|
+
readonly "user-email-verification-token-does-not-exist": {
|
120
|
+
readonly message: "The email verification token provided does not exist";
|
121
|
+
readonly detailsMaker: () => undefined;
|
122
|
+
};
|
123
|
+
readonly "user-email-verification-process-failed": {
|
124
|
+
readonly message: "Something went wrong while updating the user verification status";
|
125
|
+
readonly detailsMaker: (details: string) => string;
|
126
|
+
};
|
127
|
+
readonly "user-email-already-verified": {
|
128
|
+
readonly message: "This user already verified their email";
|
129
|
+
readonly detailsMaker: (email: string) => {
|
130
|
+
email: string;
|
131
|
+
};
|
132
|
+
};
|
133
|
+
readonly "invalid-credentials": {
|
134
|
+
readonly message: "The provided credentials are invalid";
|
135
|
+
readonly detailsMaker: () => undefined;
|
136
|
+
};
|
137
|
+
readonly "user-password-renewal-token-does-not-exist": {
|
138
|
+
readonly message: "The password renewal token provided does not exist";
|
139
|
+
readonly detailsMaker: (email: string, token: string) => {
|
140
|
+
email: string;
|
141
|
+
token: string;
|
142
|
+
};
|
143
|
+
};
|
144
|
+
readonly "user-refresh-token-missing": {
|
145
|
+
readonly message: "No refresh token provided";
|
146
|
+
readonly detailsMaker: () => undefined;
|
147
|
+
};
|
148
|
+
readonly "user-refresh-token-revoked": {
|
149
|
+
readonly message: "The refresh token provided has been revoked";
|
150
|
+
readonly detailsMaker: () => undefined;
|
151
|
+
};
|
152
|
+
readonly "user-refresh-token-malformed": {
|
153
|
+
readonly message: "The refresh token provided is malformed";
|
154
|
+
readonly detailsMaker: () => undefined;
|
155
|
+
};
|
156
|
+
readonly "user-refresh-token-expired": {
|
157
|
+
readonly message: "The refresh token provided has expired";
|
158
|
+
readonly detailsMaker: () => undefined;
|
159
|
+
};
|
160
|
+
readonly "user-tokens-revocation-failed": {
|
161
|
+
readonly message: "The user tokens revocation failed";
|
162
|
+
readonly detailsMaker: (userId: string, tokens: string[]) => {
|
163
|
+
userId: string;
|
164
|
+
tokens: string[];
|
165
|
+
};
|
166
|
+
};
|
167
|
+
readonly "user-access-token-generation-failed": {
|
168
|
+
readonly message: "The user access token generation failed";
|
169
|
+
readonly detailsMaker: (userId: string, error?: string) => {
|
170
|
+
userId: string;
|
171
|
+
error: string | undefined;
|
172
|
+
};
|
173
|
+
};
|
174
|
+
readonly "user-refresh-token-generation-failed": {
|
175
|
+
readonly message: "The user refresh token generation failed";
|
176
|
+
readonly detailsMaker: (userId: string, error?: string) => {
|
177
|
+
userId: string;
|
178
|
+
error: string | undefined;
|
179
|
+
};
|
180
|
+
};
|
181
|
+
readonly "invalid-csrf-token": {
|
182
|
+
readonly message: "The CSRF token provided is invalid";
|
183
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
184
|
+
};
|
185
|
+
readonly "invalid-request-body": {
|
186
|
+
readonly message: "The request body provided could not be used for the operation";
|
187
|
+
readonly detailsMaker: (body: any, error: string) => {
|
188
|
+
body: any;
|
189
|
+
error: string;
|
190
|
+
};
|
191
|
+
};
|
192
|
+
readonly "invalid-request-query": {
|
193
|
+
readonly message: "The request query provided could not be used for the operation";
|
194
|
+
readonly detailsMaker: (query: any, error: string) => {
|
195
|
+
query: any;
|
196
|
+
error: string;
|
197
|
+
};
|
198
|
+
};
|
199
|
+
readonly "invalid-request-files": {
|
200
|
+
readonly message: "The files provided in the request are not valid";
|
201
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
202
|
+
};
|
203
|
+
readonly "invalid-response-body": {
|
204
|
+
readonly message: "Internal server error: The response body provided could was not allowoed to be sent";
|
205
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
206
|
+
};
|
207
|
+
readonly "too-many-requests": {
|
208
|
+
readonly message: "Too many requests";
|
209
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
210
|
+
};
|
211
|
+
readonly "user-daily-upload-quota-exceeded": {
|
212
|
+
readonly message: "The user daily upload quota has been exceeded";
|
213
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
214
|
+
};
|
215
|
+
readonly "user-monthly-upload-quota-exceeded": {
|
216
|
+
readonly message: "The user monthly upload quota has been exceeded";
|
217
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
218
|
+
};
|
219
|
+
readonly "user-total-upload-quota-exceeded": {
|
220
|
+
readonly message: "The user total upload quota has been exceeded";
|
221
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
222
|
+
};
|
223
|
+
readonly "user-upload-quota-exceeded": {
|
224
|
+
readonly message: "The user upload quota has been exceeded";
|
225
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
226
|
+
};
|
227
|
+
readonly "upload-failed": {
|
228
|
+
readonly message: "The upload failed";
|
229
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
230
|
+
};
|
231
|
+
readonly "file-path-circular-pattern-detected": {
|
232
|
+
readonly message: "The file path contains a circular pattern";
|
233
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
234
|
+
};
|
235
|
+
readonly "file-not-found": {
|
236
|
+
readonly message: "The file could not be found";
|
237
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
238
|
+
};
|
239
|
+
readonly "file-already-in-trash": {
|
240
|
+
readonly message: "The file is already in the trash";
|
241
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
242
|
+
};
|
243
|
+
readonly "file-not-in-trash": {
|
244
|
+
readonly message: "The file is not in the trash";
|
245
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
246
|
+
};
|
247
|
+
readonly "file-corrupted": {
|
248
|
+
readonly message: "The file has been damaged and cannot be read";
|
249
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
250
|
+
};
|
251
|
+
readonly "file-infected": {
|
252
|
+
readonly message: "The file is infected";
|
253
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
254
|
+
};
|
255
|
+
readonly "file-empty": {
|
256
|
+
readonly message: "The file is empty";
|
257
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
258
|
+
};
|
259
|
+
readonly "file-too-large": {
|
260
|
+
readonly message: "The file is too large";
|
261
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
262
|
+
};
|
263
|
+
readonly "file-hash-failed": {
|
264
|
+
readonly message: "The file hash failed";
|
265
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
266
|
+
};
|
267
|
+
readonly "file-scanner-not-reachable": {
|
268
|
+
readonly message: "The file scanner is not reachable";
|
269
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
270
|
+
};
|
271
|
+
readonly "image-format-failed": {
|
272
|
+
readonly message: "The formatting of the image failed";
|
273
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
274
|
+
};
|
275
|
+
readonly "image-transform-failed": {
|
276
|
+
readonly message: "The image transform failed";
|
277
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
278
|
+
};
|
279
|
+
readonly "not-found": {
|
280
|
+
readonly message: "The requested resource was not found";
|
281
|
+
readonly detailsMaker: (details?: string) => string | undefined;
|
282
|
+
};
|
283
|
+
};
|
284
|
+
type Register = typeof register;
|
285
|
+
export type MessageOf<C extends Codes> = Register[C]['message'];
|
286
|
+
export type DetailsMaker<C extends Codes> = Register[C]['detailsMaker'];
|
287
|
+
export type DetailsOf<C extends Codes> = ReturnType<DetailsMaker<C>>;
|
288
|
+
export type ErrorData<C extends Codes> = {
|
289
|
+
code: C;
|
290
|
+
message: MessageOf<C>;
|
291
|
+
details: DetailsOf<C>;
|
292
|
+
};
|
293
|
+
export type MakeError = <C extends Codes>(code: C, ...params: Parameters<DetailsMaker<C>>) => ErrorData<C>;
|
294
|
+
export type MakeFailureOutcome = <Code extends Codes>(code: Code, ...params: Parameters<DetailsMaker<Code>>) => Outcome.Failure<ErrorData<Code>>;
|
295
|
+
export {};
|
@@ -0,0 +1,110 @@
|
|
1
|
+
import type { Readable } from 'node:stream';
|
2
|
+
import { Bucket as GCSBucket } from '@google-cloud/storage';
|
3
|
+
import { S3Client } from '@aws-sdk/client-s3';
|
4
|
+
import { Client as FtpsClient } from 'basic-ftp';
|
5
|
+
import SftpClient from 'ssh2-sftp-client';
|
6
|
+
import { Outcome } from '@design-edito/tools/agnostic/misc/outcome/index.js';
|
7
|
+
export type FileDescriptor = {
|
8
|
+
path: string;
|
9
|
+
hash: string;
|
10
|
+
byteSize: number;
|
11
|
+
mimeType: string;
|
12
|
+
description: string;
|
13
|
+
scannedFile: Buffer | Readable;
|
14
|
+
};
|
15
|
+
export type Client = GCSBucket | {
|
16
|
+
bucketName: string;
|
17
|
+
client: S3Client;
|
18
|
+
} | FtpsClient | SftpClient;
|
19
|
+
export type GetClient = () => Promise<Outcome.Either<Client, string>>;
|
20
|
+
export declare enum UploadFileErrCode {
|
21
|
+
CLIENT_NOT_AVAILABLE = "client-not-available",
|
22
|
+
UPLOAD_FAILED = "upload-failed",
|
23
|
+
PATH_NOT_AllLOWED = "path-not-allowed"
|
24
|
+
}
|
25
|
+
export type UploadFile = (fileDescriptor: FileDescriptor, overwrite: boolean) => Promise<Outcome.Either<true, {
|
26
|
+
code: UploadFileErrCode;
|
27
|
+
details?: string;
|
28
|
+
}>>;
|
29
|
+
export declare enum CopyFileErrCode {
|
30
|
+
CLIENT_NOT_AVAILABLE = "client-not-available",
|
31
|
+
COPY_FAILED = "copy-failed",
|
32
|
+
DEST_PATH_NOT_AllLOWED = "dest-path-not-allowed"
|
33
|
+
}
|
34
|
+
export type CopyFile = (srcPath: string, destPath: string, overwrite: boolean) => Promise<Outcome.Either<true, {
|
35
|
+
code: CopyFileErrCode;
|
36
|
+
details?: string;
|
37
|
+
}>>;
|
38
|
+
export declare enum MoveFileErrCode {
|
39
|
+
CLIENT_NOT_AVAILABLE = "client-not-available",
|
40
|
+
MOVE_FAILED = "move-failed",
|
41
|
+
DEST_PATH_NOT_AllLOWED = "dest-path-not-allowed"
|
42
|
+
}
|
43
|
+
export type MoveFile = (srcPath: string, destPath: string, overwrite: boolean) => Promise<Outcome.Either<true, {
|
44
|
+
code: MoveFileErrCode;
|
45
|
+
details?: string;
|
46
|
+
}>>;
|
47
|
+
export declare enum DownloadFileErrCode {
|
48
|
+
CLIENT_NOT_AVAILABLE = "client-not-available",
|
49
|
+
DOWNLOAD_FAILED = "download-failed",
|
50
|
+
PATH_NOT_AllLOWED = "path-not-allowed"
|
51
|
+
}
|
52
|
+
export type DownloadFile = (targetPath: string) => Promise<Outcome.Either<boolean, {
|
53
|
+
code: DownloadFileErrCode;
|
54
|
+
}>>;
|
55
|
+
export declare enum ExistsFileErrCode {
|
56
|
+
CLIENT_NOT_AVAILABLE = "client-not-available",
|
57
|
+
EXISTS_FAILED = "exists-failed",
|
58
|
+
PATH_NOT_AllLOWED = "path-not-allowed"
|
59
|
+
}
|
60
|
+
export type ExistsFile = (targetPath: string) => Promise<Outcome.Either<boolean, {
|
61
|
+
code: ExistsFileErrCode;
|
62
|
+
}>>;
|
63
|
+
export declare enum StatFileErrCode {
|
64
|
+
CLIENT_NOT_AVAILABLE = "client-not-available",
|
65
|
+
STAT_FAILED = "stat-failed",
|
66
|
+
PATH_NOT_AllLOWED = "path-not-allowed"
|
67
|
+
}
|
68
|
+
export type StatFile = (targetPath: string) => Promise<Outcome.Either<boolean, {
|
69
|
+
code: StatFileErrCode;
|
70
|
+
}>>;
|
71
|
+
export declare enum RemoveFileErrCode {
|
72
|
+
CLIENT_NOT_AVAILABLE = "client-not-available",
|
73
|
+
REMOVE_FAILED = "remove-failed",
|
74
|
+
PATH_NOT_AllLOWED = "path-not-allowed"
|
75
|
+
}
|
76
|
+
export type RemoveFile = (targetPath: string) => Promise<Outcome.Either<true, {
|
77
|
+
code: RemoveFileErrCode;
|
78
|
+
}>>;
|
79
|
+
export declare enum CopyDirErrCode {
|
80
|
+
CLIENT_NOT_AVAILABLE = "client-not-available",
|
81
|
+
COPY_FAILED = "copy-failed",
|
82
|
+
DEST_PATH_NOT_AllLOWED = "dest-path-not-allowed"
|
83
|
+
}
|
84
|
+
export type CopyDir = (srcPath: string, destPath: string, overwrite: boolean) => Promise<Outcome.Either<true, {
|
85
|
+
code: CopyDirErrCode;
|
86
|
+
}>>;
|
87
|
+
export declare enum MoveDirErrCode {
|
88
|
+
CLIENT_NOT_AVAILABLE = "client-not-available",
|
89
|
+
MOVE_FAILED = "move-failed",
|
90
|
+
DEST_PATH_NOT_AllLOWED = "dest-path-not-allowed"
|
91
|
+
}
|
92
|
+
export type MoveDir = (srcPath: string, destPath: string, overwrite: boolean) => Promise<Outcome.Either<true, {
|
93
|
+
code: MoveDirErrCode;
|
94
|
+
}>>;
|
95
|
+
export declare enum ListDirErrCode {
|
96
|
+
CLIENT_NOT_AVAILABLE = "client-not-available",
|
97
|
+
LIST_FAILED = "list-failed",
|
98
|
+
PATH_NOT_AllLOWED = "path-not-allowed"
|
99
|
+
}
|
100
|
+
export type ListDir = (targetPath: string) => Promise<Outcome.Either<string[], {
|
101
|
+
code: ListDirErrCode;
|
102
|
+
}>>;
|
103
|
+
export declare enum RemoveDirErrCode {
|
104
|
+
CLIENT_NOT_AVAILABLE = "client-not-available",
|
105
|
+
REMOVE_FAILED = "remove-failed",
|
106
|
+
PATH_NOT_AllLOWED = "path-not-allowed"
|
107
|
+
}
|
108
|
+
export type RemoveDir = (targetPath: string) => Promise<Outcome.Either<true, {
|
109
|
+
code: RemoveDirErrCode;
|
110
|
+
}>>;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import type * as Api from './api/index.js';
|
2
|
+
import type * as ApiInternals from './api/internals.js';
|
3
|
+
import type * as Auth from './auth/index.js';
|
4
|
+
import type * as Csrf from './csrf/index.js';
|
5
|
+
import type * as Database from './database/index.js';
|
6
|
+
import type * as Dto from './dto/index.js';
|
7
|
+
import type * as Email from './email/index.js';
|
8
|
+
import type * as Env from './env/index.js';
|
9
|
+
import type * as Errors from './errors/index.js';
|
10
|
+
import type * as Fs from './fs/index.js';
|
11
|
+
import type * as Init from './init/index.js';
|
12
|
+
import type * as Jwt from './jwt/index.js';
|
13
|
+
import type * as Logs from './logs/index.js';
|
14
|
+
import type * as Plugins from './plugins/index.js';
|
15
|
+
import type * as PluginsInternals from './plugins/internals.js';
|
16
|
+
import type * as Schema from './schema/index.js';
|
17
|
+
import type * as Temp from './temp/index.js';
|
18
|
+
import type * as Transformers from './transformers/index.js';
|
19
|
+
import type * as Uploads from './uploads/index.js';
|
20
|
+
import type * as Validation from './validation/index.js';
|
21
|
+
export { Api, ApiInternals, Auth, Csrf, Database, Dto, Email, Env, Errors, Fs, Init, Jwt, Logs, Plugins, PluginsInternals, Schema, Temp, Transformers, Uploads, Validation };
|
@@ -0,0 +1 @@
|
|
1
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
export type Shutdown = (code: number) => Promise<void>;
|
@@ -0,0 +1,46 @@
|
|
1
|
+
export declare enum Level {
|
2
|
+
FATAL = "fatal",
|
3
|
+
ERROR = "error",
|
4
|
+
WARN = "warn",
|
5
|
+
INFO = "info",
|
6
|
+
HTTP = "http",
|
7
|
+
DEBUG = "debug"
|
8
|
+
}
|
9
|
+
export declare enum Category {
|
10
|
+
REQUEST = "request",
|
11
|
+
REQUEST_AUTH_DENIED = "request-auth-denied",
|
12
|
+
USER_SIGNUP = "user-creation",
|
13
|
+
USER_LOGIN = "user-login",
|
14
|
+
USER_LOGOUT = "user-logout",
|
15
|
+
USER_TOKENS_RENEWAL = "user-tokens-renewal",
|
16
|
+
USER_PASSWORD_RENEWAL = "user-password-renewal",
|
17
|
+
USER_LOOKUP = "user-lookup",
|
18
|
+
USER_ACCESS_TOKEN_GENERATION = "user-access-token-generation",
|
19
|
+
USER_REFRESH_TOKEN_GENERATION = "user-refresh-token-generation",
|
20
|
+
USER_TOKENS_REVOCATION = "user-tokens-revocation",
|
21
|
+
USER_ACCESS_TOKEN_VERIFICATION = "user-access-token-verification",
|
22
|
+
CRON = "cron",
|
23
|
+
DB = "db",
|
24
|
+
EMAIL = "email",
|
25
|
+
ENV = "env",
|
26
|
+
FS = "fs",
|
27
|
+
INIT = "init",
|
28
|
+
SSL = "ssl",
|
29
|
+
TEMP = "temp",
|
30
|
+
UPLOAD = "upload",
|
31
|
+
WWW = "www",
|
32
|
+
SHUTDOWN = "shutdown",
|
33
|
+
SECURITY = "security",
|
34
|
+
FILE_RESPONSE_STREAM = "file-response-stream",
|
35
|
+
REQUEST_CATCHALL = "request-catchall",
|
36
|
+
USER_EMAIL_VERIFICATION = "email-validation-token-deletion",
|
37
|
+
FILE_PROCESSING = "file-processing"
|
38
|
+
}
|
39
|
+
export type LogFatal = (category: Category, message: string, details?: {
|
40
|
+
[key: string]: unknown;
|
41
|
+
}) => void;
|
42
|
+
export type LogError = LogFatal;
|
43
|
+
export type LogWarning = LogFatal;
|
44
|
+
export type LogInfo = LogFatal;
|
45
|
+
export type LogHttp = LogFatal;
|
46
|
+
export type LogDebug = LogFatal;
|
@@ -0,0 +1,177 @@
|
|
1
|
+
import type { StorageEngine } from 'multer';
|
2
|
+
import type { ProcessContract, WorkerErrorResponseMaker, WorkerFileResponseMaker, WorkerJsonResponseMaker, WorkerListResponseMaker, WorkerVoidResponseMaker } from '../api/internals.js';
|
3
|
+
import type { Allower } from '../auth/index.js';
|
4
|
+
import type { DeleteMany, DeleteOne, FindMany, FindOne, InsertMany, InsertOne, UpdateMany, UpdateOne } from '../database/index.js';
|
5
|
+
import type { Send } from '../email/index.js';
|
6
|
+
import type { Env } from '../env/index.js';
|
7
|
+
import type { register, MakeError, MakeFailureOutcome } from '../errors/index.js';
|
8
|
+
import type { CopyDir, CopyFile, DownloadFile, ExistsFile, GetClient, ListDir, MoveDir, MoveFile, RemoveDir, RemoveFile, StatFile, UploadFile } from '../fs/index.js';
|
9
|
+
import type { Shutdown } from '../init/index.js';
|
10
|
+
import type { LogDebug, LogError, LogFatal, LogHttp, LogInfo, LogWarning } from '../logs/index.js';
|
11
|
+
import type { DiscriminateUser, IBaseUserCoreSchema, IBaseUserModel, IBaseUserSchema, IGoogleUserCoreSchema, IGoogleUserModel, IGoogleUserSchema, IHistoryItemSchema, ILocalUserCoreSchema, ILocalUserModel, ILocalUserSchema, IMetaSchema, IUserAuthTokenModel, IUserAuthTokenSchema, IUserEmailValidationTokenModel, IUserEmailValidationTokenSchema, IUserPasswordRenewalTokenModel, IUserPasswordRenewalTokenSchema, IUserRevokedAuthTokenModel, IUserRevokedAuthTokenSchema, IUserUploadQuotaModel, IUserUploadQuotaSchema, AddHistoryToSchema, AddMetaToSchema, AddPasswordToSchema, UserAuthTokenCollectionName, UserCollectionName, UserEmailValidationTokenCollectionName, UserPasswordRenewalTokenCollectionName, UserRevokedAuthTokenCollectionName, UserUploadQuotaCollectionName } from '../schema/index.js';
|
12
|
+
import type { CleanupOldFiles, Flush, GeneratePath, GetCurrentByteSize, GetRootPath, IncreaseCurrentByteSize, UpdateCurrentByteSize } from '../temp/index.js';
|
13
|
+
import type { BaseUserToDTO, GoogleUserToDTO, LocalUserToDTO } from '../transformers/user/index.js';
|
14
|
+
import type { UserUploadQuotaToDTO } from '../transformers/user-upload-quota/index.js';
|
15
|
+
import type { GetFileHash, IHttpClamScanner, ScanFile, UpdateUserUploadsQuota } from '../uploads/index.js';
|
16
|
+
import type { NoAuthNullValidation, StrongAuthNullValidation, WeakAuthNullValidation } from '../validation/index.js';
|
17
|
+
export type PluginGeneratorHooks = {
|
18
|
+
api: {
|
19
|
+
utils: {
|
20
|
+
errorResponse: WorkerErrorResponseMaker;
|
21
|
+
voidResponse: WorkerVoidResponseMaker;
|
22
|
+
jsonResponse: WorkerJsonResponseMaker;
|
23
|
+
listResponse: WorkerListResponseMaker;
|
24
|
+
fileResponse: WorkerFileResponseMaker;
|
25
|
+
};
|
26
|
+
};
|
27
|
+
auth: {
|
28
|
+
allow: Allower;
|
29
|
+
};
|
30
|
+
database: {
|
31
|
+
insertOne: InsertOne;
|
32
|
+
insertMany: InsertMany;
|
33
|
+
findOne: FindOne;
|
34
|
+
findMany: FindMany;
|
35
|
+
updateOne: UpdateOne;
|
36
|
+
updateMany: UpdateMany;
|
37
|
+
deleteOne: DeleteOne;
|
38
|
+
deleteMany: DeleteMany;
|
39
|
+
};
|
40
|
+
email: {
|
41
|
+
send: Send;
|
42
|
+
};
|
43
|
+
env: Env;
|
44
|
+
errors: {
|
45
|
+
register: typeof register;
|
46
|
+
makeError: MakeError;
|
47
|
+
makeFailureOutcome: MakeFailureOutcome;
|
48
|
+
};
|
49
|
+
fs: {
|
50
|
+
getClient: GetClient;
|
51
|
+
uploadFile: UploadFile;
|
52
|
+
copyFile: CopyFile;
|
53
|
+
moveFile: MoveFile;
|
54
|
+
downloadFile: DownloadFile;
|
55
|
+
existsFile: ExistsFile;
|
56
|
+
statFile: StatFile;
|
57
|
+
removeFile: RemoveFile;
|
58
|
+
copyDir: CopyDir;
|
59
|
+
moveDir: MoveDir;
|
60
|
+
listDir: ListDir;
|
61
|
+
removeDir: RemoveDir;
|
62
|
+
};
|
63
|
+
init: {
|
64
|
+
shutdown: Shutdown;
|
65
|
+
};
|
66
|
+
logs: {
|
67
|
+
logFatal: LogFatal;
|
68
|
+
logError: LogError;
|
69
|
+
logWarning: LogWarning;
|
70
|
+
logInfo: LogInfo;
|
71
|
+
logHttp: LogHttp;
|
72
|
+
logDebug: LogDebug;
|
73
|
+
};
|
74
|
+
schema: {
|
75
|
+
_history: {
|
76
|
+
HistoryItemSchema: IHistoryItemSchema;
|
77
|
+
addHistoryToSchema: AddHistoryToSchema;
|
78
|
+
};
|
79
|
+
_meta: {
|
80
|
+
MetaSchema: IMetaSchema;
|
81
|
+
addMetaToSchema: AddMetaToSchema;
|
82
|
+
};
|
83
|
+
_password: {
|
84
|
+
addPasswordToSchema: AddPasswordToSchema;
|
85
|
+
};
|
86
|
+
user: {
|
87
|
+
authToken: {
|
88
|
+
collectionName: UserAuthTokenCollectionName;
|
89
|
+
UserAuthTokenSchema: IUserAuthTokenSchema;
|
90
|
+
UserAuthTokenModel: IUserAuthTokenModel;
|
91
|
+
};
|
92
|
+
emailValidationToken: {
|
93
|
+
collectionName: UserEmailValidationTokenCollectionName;
|
94
|
+
UserEmailValidationTokenSchema: IUserEmailValidationTokenSchema;
|
95
|
+
UserEmailValidationTokenModel: IUserEmailValidationTokenModel;
|
96
|
+
};
|
97
|
+
passwordRenewalToken: {
|
98
|
+
collectionName: UserPasswordRenewalTokenCollectionName;
|
99
|
+
UserPasswordRenewalTokenSchema: IUserPasswordRenewalTokenSchema;
|
100
|
+
UserPasswordRenewalTokenModel: IUserPasswordRenewalTokenModel;
|
101
|
+
};
|
102
|
+
revokedAuthToken: {
|
103
|
+
collectionName: UserRevokedAuthTokenCollectionName;
|
104
|
+
UserRevokedAuthTokenSchema: IUserRevokedAuthTokenSchema;
|
105
|
+
UserRevokedAuthTokenModel: IUserRevokedAuthTokenModel;
|
106
|
+
};
|
107
|
+
uploadQuota: {
|
108
|
+
collectionName: UserUploadQuotaCollectionName;
|
109
|
+
UserUploadQuotaSchema: IUserUploadQuotaSchema;
|
110
|
+
UserUploadQuotaModel: IUserUploadQuotaModel;
|
111
|
+
};
|
112
|
+
user: {
|
113
|
+
collectionName: UserCollectionName;
|
114
|
+
BaseUserCoreSchema: IBaseUserCoreSchema;
|
115
|
+
LocalUserCoreSchema: ILocalUserCoreSchema;
|
116
|
+
GoogleUserCoreSchema: IGoogleUserCoreSchema;
|
117
|
+
BaseUserSchema: IBaseUserSchema;
|
118
|
+
LocalUserSchema: ILocalUserSchema;
|
119
|
+
GoogleUserSchema: IGoogleUserSchema;
|
120
|
+
BaseUserModel: IBaseUserModel;
|
121
|
+
LocalUserModel: ILocalUserModel;
|
122
|
+
GoogleUserModel: IGoogleUserModel;
|
123
|
+
discriminateUser: DiscriminateUser;
|
124
|
+
};
|
125
|
+
};
|
126
|
+
};
|
127
|
+
temp: {
|
128
|
+
getRootPath: GetRootPath;
|
129
|
+
generatePath: GeneratePath;
|
130
|
+
cleanupOldFiles: CleanupOldFiles;
|
131
|
+
updateCurrentByteSize: UpdateCurrentByteSize;
|
132
|
+
getCurrentByteSize: GetCurrentByteSize;
|
133
|
+
increaseCurrentByteSize: IncreaseCurrentByteSize;
|
134
|
+
flush: Flush;
|
135
|
+
};
|
136
|
+
transformers: {
|
137
|
+
user: {
|
138
|
+
baseUserToDTO: BaseUserToDTO;
|
139
|
+
localUserToDTO: LocalUserToDTO;
|
140
|
+
googleUserToDTO: GoogleUserToDTO;
|
141
|
+
};
|
142
|
+
userUploadQuota: {
|
143
|
+
userUploadQuotaToDTO: UserUploadQuotaToDTO;
|
144
|
+
};
|
145
|
+
};
|
146
|
+
upload: {
|
147
|
+
multerStorage: StorageEngine;
|
148
|
+
scanner: IHttpClamScanner;
|
149
|
+
scanFile: ScanFile;
|
150
|
+
getFileHash: GetFileHash;
|
151
|
+
updateUserUploadsQuota: UpdateUserUploadsQuota;
|
152
|
+
};
|
153
|
+
validation: {
|
154
|
+
noAuthNullValidation: NoAuthNullValidation;
|
155
|
+
weakAuthNullValidation: WeakAuthNullValidation;
|
156
|
+
strongAuthNullValidation: StrongAuthNullValidation;
|
157
|
+
};
|
158
|
+
};
|
159
|
+
export type Task = {
|
160
|
+
name: string;
|
161
|
+
interval: string;
|
162
|
+
cronTask: () => void | Promise<void>;
|
163
|
+
errHandler?: (err: unknown) => Promise<void> | void;
|
164
|
+
};
|
165
|
+
export type TaskGenerator = (hooks: PluginGeneratorHooks) => Promise<Task>;
|
166
|
+
export type Contract<T extends ProcessContract<any, any, any, any, any, any, any, any>> = T;
|
167
|
+
export type ContractGenerator<T extends ProcessContract<any, any, any, any, any, any, any, any>> = (hooks: PluginGeneratorHooks) => Promise<Contract<T>>;
|
168
|
+
export type Plugin<T extends Record<string, ProcessContract<any, any, any, any, any, any, any, any>>> = {
|
169
|
+
name: string;
|
170
|
+
contracts: T;
|
171
|
+
tasks: Task[];
|
172
|
+
};
|
173
|
+
export type PluginGenerator<T extends Record<string, ProcessContract<any, any, any, any, any, any, any, any>>> = {
|
174
|
+
name: string | ((hooks: PluginGeneratorHooks) => Promise<string> | string);
|
175
|
+
tasks: TaskGenerator[];
|
176
|
+
contracts: Record<keyof T, ContractGenerator<T[keyof T]>>;
|
177
|
+
};
|