proteum 1.0.2 → 2.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/AGENTS.md +101 -0
- package/agents/codex/AGENTS.md +95 -0
- package/agents/codex/CODING_STYLE.md +71 -0
- package/agents/codex/agents.md.zip +0 -0
- package/agents/codex/client/AGENTS.md +102 -0
- package/agents/codex/client/pages/AGENTS.md +35 -0
- package/agents/codex/server/routes/AGENTS.md +12 -0
- package/agents/codex/server/services/AGENTS.md +137 -0
- package/agents/codex/tests/AGENTS.md +8 -0
- package/cli/app/config.ts +13 -11
- package/cli/app/index.ts +74 -82
- package/cli/bin.js +1 -1
- package/cli/commands/build.ts +51 -14
- package/cli/commands/check.ts +19 -0
- package/cli/commands/deploy/app.ts +4 -8
- package/cli/commands/deploy/web.ts +16 -20
- package/cli/commands/dev.ts +189 -64
- package/cli/commands/devEvents.ts +106 -0
- package/cli/commands/init.ts +63 -57
- package/cli/commands/lint.ts +21 -0
- package/cli/commands/refresh.ts +18 -0
- package/cli/commands/typecheck.ts +18 -0
- package/cli/compiler/client/identite.ts +80 -53
- package/cli/compiler/client/index.ts +139 -213
- package/cli/compiler/common/bundleAnalysis.ts +94 -0
- package/cli/compiler/common/clientManifest.ts +67 -0
- package/cli/compiler/common/controllers.ts +288 -0
- package/cli/compiler/common/files/autres.ts +7 -18
- package/cli/compiler/common/files/images.ts +40 -37
- package/cli/compiler/common/files/style.ts +11 -22
- package/cli/compiler/common/generatedRouteModules.ts +368 -0
- package/cli/compiler/common/index.ts +31 -65
- package/cli/compiler/common/loaders/forbid-ssr-import.js +13 -0
- package/cli/compiler/common/rspackAliases.ts +13 -0
- package/cli/compiler/common/scripts.ts +37 -0
- package/cli/compiler/index.ts +781 -230
- package/cli/compiler/server/index.ts +59 -75
- package/cli/compiler/writeIfChanged.ts +21 -0
- package/cli/index.ts +71 -72
- package/cli/paths.ts +51 -57
- package/cli/print.ts +17 -11
- package/cli/tsconfig.json +5 -4
- package/cli/utils/agents.ts +100 -0
- package/cli/utils/check.ts +71 -0
- package/cli/utils/index.ts +1 -3
- package/cli/utils/keyboard.ts +8 -25
- package/cli/utils/runProcess.ts +30 -0
- package/client/app/component.tsx +29 -29
- package/client/app/index.ts +36 -57
- package/client/app/service.ts +7 -12
- package/client/app.tsconfig.json +2 -2
- package/client/components/Dialog/Manager.ssr.tsx +40 -0
- package/client/components/Dialog/Manager.tsx +119 -150
- package/client/components/Dialog/status.tsx +3 -3
- package/client/components/index.ts +1 -1
- package/client/components/types.d.ts +1 -3
- package/client/dev/hmr.ts +65 -0
- package/client/global.d.ts +2 -2
- package/client/hooks.ts +6 -9
- package/client/index.ts +2 -1
- package/client/islands/index.ts +7 -0
- package/client/islands/useDeferredModule.ts +199 -0
- package/client/pages/_layout/index.tsx +4 -12
- package/client/pages/useHeader.tsx +14 -21
- package/client/router.ts +27 -0
- package/client/services/router/components/Link.tsx +34 -27
- package/client/services/router/components/Page.tsx +6 -14
- package/client/services/router/components/router.ssr.tsx +36 -0
- package/client/services/router/components/router.tsx +63 -83
- package/client/services/router/index.tsx +185 -220
- package/client/services/router/request/api.ts +97 -119
- package/client/services/router/request/history.ts +2 -2
- package/client/services/router/request/index.ts +13 -12
- package/client/services/router/request/multipart.ts +72 -62
- package/client/services/router/response/index.tsx +68 -61
- package/client/services/router/response/page.ts +28 -32
- package/client/utils/dom.ts +17 -33
- package/common/app/index.ts +3 -3
- package/common/data/chaines/index.ts +22 -23
- package/common/data/dates.ts +35 -70
- package/common/data/markdown.ts +42 -39
- package/common/dev/serverHotReload.ts +26 -0
- package/common/errors/index.tsx +110 -142
- package/common/router/contracts.ts +29 -0
- package/common/router/index.ts +89 -108
- package/common/router/layouts.ts +34 -47
- package/common/router/pageSetup.ts +50 -0
- package/common/router/register.ts +53 -24
- package/common/router/request/api.ts +30 -36
- package/common/router/request/index.ts +2 -8
- package/common/router/response/index.ts +8 -15
- package/common/router/response/page.ts +70 -58
- package/common/utils.ts +1 -1
- package/doc/TODO.md +1 -1
- package/eslint.js +62 -0
- package/package.json +14 -49
- package/prettier.config.cjs +9 -0
- package/scripts/cleanup-generated-controllers.ts +62 -0
- package/scripts/fix-reference-app-typing.ts +490 -0
- package/scripts/refactor-client-app-imports.ts +244 -0
- package/scripts/refactor-client-pages.ts +587 -0
- package/scripts/refactor-server-controllers.ts +470 -0
- package/scripts/refactor-server-runtime-aliases.ts +360 -0
- package/scripts/restore-client-app-import-files.ts +41 -0
- package/scripts/restore-files-from-git-head.ts +20 -0
- package/scripts/update-codex-agents.ts +35 -0
- package/server/app/commands.ts +35 -64
- package/server/app/container/config.ts +48 -59
- package/server/app/container/console/index.ts +202 -248
- package/server/app/container/index.ts +33 -71
- package/server/app/controller/index.ts +61 -0
- package/server/app/index.ts +39 -105
- package/server/app/service/container.ts +41 -42
- package/server/app/service/index.ts +120 -147
- package/server/context.ts +1 -1
- package/server/index.ts +25 -1
- package/server/services/auth/index.ts +75 -115
- package/server/services/auth/router/index.ts +31 -32
- package/server/services/auth/router/request.ts +14 -16
- package/server/services/cron/CronTask.ts +13 -26
- package/server/services/cron/index.ts +14 -36
- package/server/services/disks/driver.ts +40 -58
- package/server/services/disks/drivers/local/index.ts +79 -90
- package/server/services/disks/drivers/s3/index.ts +116 -163
- package/server/services/disks/index.ts +23 -38
- package/server/services/email/index.ts +45 -104
- package/server/services/email/utils.ts +14 -27
- package/server/services/fetch/index.ts +53 -85
- package/server/services/prisma/Facet.ts +39 -91
- package/server/services/prisma/index.ts +74 -110
- package/server/services/router/generatedRuntime.ts +29 -0
- package/server/services/router/http/index.ts +78 -73
- package/server/services/router/http/multipart.ts +19 -42
- package/server/services/router/index.ts +378 -365
- package/server/services/router/request/api.ts +26 -25
- package/server/services/router/request/index.ts +44 -51
- package/server/services/router/request/service.ts +7 -11
- package/server/services/router/request/validation/zod.ts +111 -148
- package/server/services/router/response/index.ts +110 -125
- package/server/services/router/response/mask/Filter.ts +31 -72
- package/server/services/router/response/mask/index.ts +8 -15
- package/server/services/router/response/mask/selecteurs.ts +11 -25
- package/server/services/router/response/page/clientManifest.ts +25 -0
- package/server/services/router/response/page/document.tsx +199 -127
- package/server/services/router/response/page/index.tsx +89 -94
- package/server/services/router/service.ts +13 -15
- package/server/services/schema/index.ts +17 -26
- package/server/services/schema/request.ts +19 -33
- package/server/services/schema/router/index.ts +8 -11
- package/server/services/security/encrypt/aes/index.ts +15 -35
- package/server/utils/slug.ts +29 -35
- package/skills/clean-project-code/SKILL.md +63 -0
- package/skills/clean-project-code/agents/openai.yaml +4 -0
- package/tsconfig.common.json +4 -3
- package/tsconfig.json +4 -1
- package/types/aliases.d.ts +17 -21
- package/types/controller-input.test.ts +48 -0
- package/types/express-extra.d.ts +6 -0
- package/types/global/constants.d.ts +13 -0
- package/types/global/express-extra.d.ts +6 -0
- package/types/global/modules.d.ts +13 -16
- package/types/global/utils.d.ts +17 -49
- package/types/global/vendors.d.ts +62 -0
- package/types/icons.d.ts +65 -1
- package/types/uuid.d.ts +3 -0
- package/types/vendors.d.ts +62 -0
- package/cli/compiler/common/babel/index.ts +0 -170
- package/cli/compiler/common/babel/plugins/index.ts +0 -0
- package/cli/compiler/common/babel/plugins/services.ts +0 -586
- package/cli/compiler/common/babel/routes/imports.ts +0 -127
- package/cli/compiler/common/babel/routes/routes.ts +0 -1130
- package/client/services/captcha/index.ts +0 -67
- package/client/services/socket/index.ts +0 -147
- package/common/data/rte/nodes.ts +0 -83
- package/common/data/stats.ts +0 -90
- package/common/utils/rte.ts +0 -183
- package/server/services/auth/old.ts +0 -277
- package/server/services/cache/commands.ts +0 -41
- package/server/services/cache/index.ts +0 -297
- package/server/services/cache/service.json +0 -6
- package/server/services/socket/index.ts +0 -162
- package/server/services/socket/scope.ts +0 -226
- package/server/services/socket/service.json +0 -6
- package/server/services_old/SocketClient.ts +0 -92
- package/server/services_old/Token.old.ts +0 -97
package/common/data/markdown.ts
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
import markdownIt from 'markdown-it';
|
|
2
2
|
const md = markdownIt({
|
|
3
|
-
html: false,
|
|
4
|
-
xhtmlOut: false,
|
|
5
|
-
breaks: true,
|
|
6
|
-
langPrefix: 'language-',
|
|
7
|
-
linkify: false,
|
|
3
|
+
html: false, // Enable HTML tags in source
|
|
4
|
+
xhtmlOut: false, // Use '/' to close single tags (<br />). This is only for full CommonMark compatibility.
|
|
5
|
+
breaks: true, // Convert '\n' in paragraphs into <br>
|
|
6
|
+
langPrefix: 'language-', // CSS language prefix for fenced blocks. Can be useful for external highlighters.
|
|
7
|
+
linkify: false, // Autoconvert URL-like text to links
|
|
8
8
|
});
|
|
9
9
|
|
|
10
10
|
const rules = md.renderer.rules;
|
|
11
11
|
|
|
12
12
|
// ------------------------
|
|
13
13
|
|
|
14
|
-
var link_open_default =
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
var link_open_default =
|
|
15
|
+
rules.link_open ||
|
|
16
|
+
function (tokens, idx, options, env, self) {
|
|
17
|
+
return self.renderToken(tokens, idx, options);
|
|
18
|
+
};
|
|
17
19
|
|
|
18
20
|
// Target = _blank
|
|
19
21
|
rules.link_open = function (tokens, idx, options, env, self) {
|
|
20
|
-
|
|
21
22
|
const aIndex = tokens[idx].attrIndex('target');
|
|
22
23
|
if (aIndex < 0) {
|
|
23
24
|
tokens[idx].attrPush(['target', '_blank']);
|
|
24
|
-
} else {
|
|
25
|
-
tokens[idx].attrs[
|
|
25
|
+
} else if (tokens[idx].attrs) {
|
|
26
|
+
tokens[idx].attrs[aIndex][1] = '_blank';
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
return link_open_default(tokens, idx, options, env, self);
|
|
@@ -30,44 +31,46 @@ rules.link_open = function (tokens, idx, options, env, self) {
|
|
|
30
31
|
|
|
31
32
|
// ------------------------
|
|
32
33
|
|
|
33
|
-
var image_default =
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
var image_default =
|
|
35
|
+
rules.image ||
|
|
36
|
+
function (tokens, idx, options, env, self) {
|
|
37
|
+
return self.renderToken(tokens, idx, options);
|
|
38
|
+
};
|
|
36
39
|
|
|
37
40
|
// img => figure
|
|
38
41
|
rules.image = function (tokens, idx, options, env, self) {
|
|
39
|
-
|
|
40
42
|
const rendu = image_default(tokens, idx, options, env, self);
|
|
41
43
|
|
|
42
|
-
return `<figure>${rendu}</figure
|
|
44
|
+
return `<figure>${rendu}</figure>`;
|
|
43
45
|
};
|
|
44
46
|
|
|
45
47
|
// ------------------------
|
|
46
48
|
|
|
47
|
-
md.block.ruler.after(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
token.attrs
|
|
49
|
+
md.block.ruler.after(
|
|
50
|
+
'list',
|
|
51
|
+
'test',
|
|
52
|
+
(state, startLine, endLine, silent) => {
|
|
53
|
+
for (const token of state.tokens) {
|
|
54
|
+
if (token.type === 'bullet_list_open') {
|
|
55
|
+
const aIndex = token.attrIndex('class');
|
|
56
|
+
if (aIndex < 0) {
|
|
57
|
+
token.attrPush(['class', 'liste']); // add new attribute
|
|
58
|
+
} else if (token.attrs) {
|
|
59
|
+
token.attrs[aIndex][1] = 'liste'; // replace value of existing attr
|
|
60
|
+
}
|
|
61
|
+
} else if (token.type === 'ordered_list_open') {
|
|
62
|
+
const aIndex = token.attrIndex('class');
|
|
63
|
+
if (aIndex < 0) {
|
|
64
|
+
token.attrPush(['class', 'steps']); // add new attribute
|
|
65
|
+
} else if (token.attrs) {
|
|
66
|
+
token.attrs[aIndex][1] = 'steps'; // replace value of existing attr
|
|
67
|
+
}
|
|
57
68
|
}
|
|
58
|
-
|
|
59
|
-
} else if (token.type === 'ordered_list_open') {
|
|
60
|
-
|
|
61
|
-
const aIndex = token.attrIndex('class');
|
|
62
|
-
if (aIndex < 0) {
|
|
63
|
-
token.attrPush(['class', 'steps']); // add new attribute
|
|
64
|
-
} else {
|
|
65
|
-
token.attrs[ aIndex ][1] = 'steps'; // replace value of existing attr
|
|
66
|
-
}
|
|
67
|
-
|
|
68
69
|
}
|
|
69
|
-
}
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
return false;
|
|
72
|
+
},
|
|
73
|
+
{ alt: ['paragraph', 'reference', 'blockquote'] },
|
|
74
|
+
);
|
|
72
75
|
|
|
73
|
-
export default md;
|
|
76
|
+
export default md;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const serverHotReloadMessageType = {
|
|
2
|
+
request: 'proteum:router-reload',
|
|
3
|
+
succeeded: 'proteum:router-reload-succeeded',
|
|
4
|
+
failed: 'proteum:router-reload-failed',
|
|
5
|
+
} as const;
|
|
6
|
+
|
|
7
|
+
export type TServerHotReloadRequest = { type: typeof serverHotReloadMessageType.request; changedFiles: string[] };
|
|
8
|
+
|
|
9
|
+
export type TServerHotReloadResult = {
|
|
10
|
+
type: typeof serverHotReloadMessageType.succeeded | typeof serverHotReloadMessageType.failed;
|
|
11
|
+
changedFiles: string[];
|
|
12
|
+
error?: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const isServerHotReloadRequest = (value: unknown): value is TServerHotReloadRequest =>
|
|
16
|
+
typeof value === 'object' &&
|
|
17
|
+
value !== null &&
|
|
18
|
+
(value as TServerHotReloadRequest).type === serverHotReloadMessageType.request &&
|
|
19
|
+
Array.isArray((value as TServerHotReloadRequest).changedFiles);
|
|
20
|
+
|
|
21
|
+
export const isServerHotReloadResult = (value: unknown): value is TServerHotReloadResult =>
|
|
22
|
+
typeof value === 'object' &&
|
|
23
|
+
value !== null &&
|
|
24
|
+
((value as TServerHotReloadResult).type === serverHotReloadMessageType.succeeded ||
|
|
25
|
+
(value as TServerHotReloadResult).type === serverHotReloadMessageType.failed) &&
|
|
26
|
+
Array.isArray((value as TServerHotReloadResult).changedFiles);
|
package/common/errors/index.tsx
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import type { ComponentChild } from 'preact';
|
|
3
2
|
|
|
4
|
-
import type { TJsonLog } from '@server/app/container/console';
|
|
5
3
|
import type ServerRequest from '@server/services/router/request';
|
|
6
4
|
import type { TBasicUser } from '@server/services/auth';
|
|
7
5
|
|
|
@@ -9,64 +7,59 @@ import type { TBasicUser } from '@server/services/auth';
|
|
|
9
7
|
- TYPES
|
|
10
8
|
----------------------------------*/
|
|
11
9
|
|
|
12
|
-
export type TListeErreursSaisie<TClesDonnees extends string = string> = {[champ in TClesDonnees]: string[]}
|
|
10
|
+
export type TListeErreursSaisie<TClesDonnees extends string = string> = { [champ in TClesDonnees]: string[] };
|
|
13
11
|
|
|
14
12
|
export type TJsonError = {
|
|
15
|
-
code: number
|
|
16
|
-
origin?: string
|
|
17
|
-
message: string
|
|
13
|
+
code: number;
|
|
14
|
+
origin?: string;
|
|
15
|
+
message: string;
|
|
18
16
|
// Form fields
|
|
19
|
-
errors?: TListeErreursSaisie
|
|
20
|
-
} & TErrorDetails
|
|
17
|
+
errors?: TListeErreursSaisie;
|
|
18
|
+
} & TErrorDetails;
|
|
21
19
|
|
|
22
20
|
type TErrorDetails = {
|
|
23
|
-
|
|
24
21
|
// Allow to identify the error catched (ex: displaying custop content, running custom actions, ...)
|
|
25
|
-
id?: string
|
|
26
|
-
data?: {}
|
|
22
|
+
id?: string;
|
|
23
|
+
data?: {};
|
|
27
24
|
|
|
28
|
-
cta?: {
|
|
29
|
-
label: string,
|
|
30
|
-
link: string,
|
|
31
|
-
},
|
|
25
|
+
cta?: { label: string; link: string };
|
|
32
26
|
|
|
33
27
|
// For debugging
|
|
34
|
-
stack?: string
|
|
35
|
-
origin?: string
|
|
36
|
-
}
|
|
28
|
+
stack?: string;
|
|
29
|
+
origin?: string;
|
|
30
|
+
};
|
|
37
31
|
|
|
38
32
|
/*----------------------------------
|
|
39
33
|
- TYPES: BUG REPORT
|
|
40
34
|
----------------------------------*/
|
|
41
35
|
|
|
42
36
|
export type ServerBug = {
|
|
43
|
-
|
|
44
37
|
// Context
|
|
45
|
-
hash: string
|
|
46
|
-
isDuplicate: boolean
|
|
47
|
-
date: Date
|
|
48
|
-
channelType?: string
|
|
49
|
-
channelId?: string
|
|
38
|
+
hash: string;
|
|
39
|
+
isDuplicate: boolean;
|
|
40
|
+
date: Date; // Timestamp
|
|
41
|
+
channelType?: string;
|
|
42
|
+
channelId?: string;
|
|
50
43
|
|
|
51
44
|
// User
|
|
52
|
-
user?: TBasicUser | null
|
|
53
|
-
ip?: string | null
|
|
45
|
+
user?: TBasicUser | null;
|
|
46
|
+
ip?: string | null;
|
|
54
47
|
|
|
55
48
|
// Request
|
|
56
49
|
request?: {
|
|
57
|
-
method: ServerRequest[
|
|
58
|
-
url: ServerRequest[
|
|
59
|
-
data: ServerRequest[
|
|
60
|
-
validatedData: ServerRequest[
|
|
61
|
-
headers: ServerRequest[
|
|
62
|
-
cookies: ServerRequest[
|
|
63
|
-
}
|
|
64
|
-
|
|
50
|
+
method: ServerRequest['method'];
|
|
51
|
+
url: ServerRequest['url'];
|
|
52
|
+
data: ServerRequest['data'];
|
|
53
|
+
validatedData: ServerRequest['validatedData'];
|
|
54
|
+
headers: ServerRequest['headers'];
|
|
55
|
+
cookies: ServerRequest['cookies'];
|
|
56
|
+
};
|
|
57
|
+
|
|
65
58
|
// Error
|
|
66
|
-
title?: string
|
|
67
|
-
stacktraces: string[]
|
|
68
|
-
context: object[]
|
|
69
|
-
}
|
|
59
|
+
title?: string;
|
|
60
|
+
stacktraces: string[];
|
|
61
|
+
context: object[];
|
|
62
|
+
};
|
|
70
63
|
|
|
71
64
|
export type TCatchedError = Error | CoreError | Anomaly;
|
|
72
65
|
|
|
@@ -74,11 +67,10 @@ export type TCatchedError = Error | CoreError | Anomaly;
|
|
|
74
67
|
- ERREURS
|
|
75
68
|
----------------------------------*/
|
|
76
69
|
export abstract class CoreError extends Error {
|
|
77
|
-
|
|
78
70
|
public static msgDefaut: string;
|
|
79
71
|
|
|
80
72
|
public abstract http: number;
|
|
81
|
-
public title: string =
|
|
73
|
+
public title: string = 'Uh Oh ...';
|
|
82
74
|
public message: string;
|
|
83
75
|
public details: TErrorDetails = {};
|
|
84
76
|
|
|
@@ -87,25 +79,17 @@ export abstract class CoreError extends Error {
|
|
|
87
79
|
//public stack?: string;
|
|
88
80
|
|
|
89
81
|
public constructor(message?: string, details?: TErrorDetails) {
|
|
90
|
-
|
|
91
82
|
super(message);
|
|
92
83
|
|
|
93
84
|
this.message = message || (this.constructor as typeof CoreError).msgDefaut;
|
|
94
|
-
this.details = details || {};
|
|
85
|
+
this.details = details || {};
|
|
95
86
|
|
|
96
87
|
// Inject stack
|
|
97
|
-
if (details !== undefined)
|
|
98
|
-
this.stack = details.stack;
|
|
99
|
-
|
|
88
|
+
if (details !== undefined) this.stack = details.stack;
|
|
100
89
|
}
|
|
101
90
|
|
|
102
91
|
public json(): TJsonError {
|
|
103
|
-
|
|
104
|
-
return {
|
|
105
|
-
code: this.http,
|
|
106
|
-
message: this.message,
|
|
107
|
-
...this.details
|
|
108
|
-
}
|
|
92
|
+
return { code: this.http, message: this.message, ...this.details };
|
|
109
93
|
}
|
|
110
94
|
|
|
111
95
|
public toString() {
|
|
@@ -117,191 +101,175 @@ export abstract class CoreError extends Error {
|
|
|
117
101
|
|
|
118
102
|
export class InputError extends CoreError {
|
|
119
103
|
public http = 400;
|
|
120
|
-
public title =
|
|
121
|
-
public static msgDefaut =
|
|
104
|
+
public title = 'Bad Request';
|
|
105
|
+
public static msgDefaut = 'Bad Request.';
|
|
122
106
|
}
|
|
123
107
|
|
|
124
108
|
export class InputErrorSchema extends CoreError {
|
|
125
|
-
|
|
126
109
|
public http = 400;
|
|
127
|
-
public title =
|
|
128
|
-
public static msgDefaut =
|
|
110
|
+
public title = 'Bad Request';
|
|
111
|
+
public static msgDefaut = 'Bad Request.';
|
|
129
112
|
|
|
130
113
|
private static listeToString(liste: TListeErreursSaisie) {
|
|
131
|
-
let chaines: string[] = []
|
|
132
|
-
for (const champ in liste)
|
|
133
|
-
chaines.push(champ + ': ' + liste[champ].join('. '));
|
|
114
|
+
let chaines: string[] = [];
|
|
115
|
+
for (const champ in liste) chaines.push(champ + ': ' + liste[champ].join('. '));
|
|
134
116
|
return chaines.join('; ');
|
|
135
117
|
}
|
|
136
118
|
|
|
137
|
-
public constructor(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
119
|
+
public constructor(
|
|
120
|
+
public errors: TListeErreursSaisie,
|
|
121
|
+
details?: TErrorDetails,
|
|
122
|
+
) {
|
|
123
|
+
super(InputErrorSchema.listeToString(errors), details);
|
|
141
124
|
}
|
|
142
125
|
|
|
143
126
|
public json(): TJsonError {
|
|
144
|
-
return {
|
|
145
|
-
...super.json(),
|
|
146
|
-
errors: this.errors,
|
|
147
|
-
}
|
|
127
|
+
return { ...super.json(), errors: this.errors };
|
|
148
128
|
}
|
|
149
129
|
|
|
150
130
|
public render(): ComponentChild {
|
|
151
131
|
return (
|
|
152
132
|
<ul class="col al-left">
|
|
153
|
-
{Object.keys(this.errors).map(
|
|
154
|
-
<li>
|
|
133
|
+
{Object.keys(this.errors).map((champ) => (
|
|
134
|
+
<li>
|
|
135
|
+
{champ}: {this.errors[champ].join('. ')}
|
|
136
|
+
</li>
|
|
155
137
|
))}
|
|
156
138
|
</ul>
|
|
157
|
-
)
|
|
139
|
+
);
|
|
158
140
|
}
|
|
159
141
|
}
|
|
160
142
|
|
|
161
143
|
export class AuthRequired<FeatureKeys extends string> extends CoreError {
|
|
162
144
|
public http = 401;
|
|
163
|
-
public title =
|
|
164
|
-
public static msgDefaut =
|
|
145
|
+
public title = 'Authentication Required';
|
|
146
|
+
public static msgDefaut = 'Please Login to Continue.';
|
|
165
147
|
|
|
166
|
-
public constructor(
|
|
167
|
-
message: string,
|
|
148
|
+
public constructor(
|
|
149
|
+
message: string,
|
|
168
150
|
public feature: FeatureKeys,
|
|
169
151
|
public action: string,
|
|
170
|
-
details?: TErrorDetails
|
|
152
|
+
details?: TErrorDetails,
|
|
171
153
|
) {
|
|
172
154
|
super(message, details);
|
|
173
155
|
}
|
|
174
156
|
|
|
175
|
-
public json(): TJsonError & { feature: string
|
|
176
|
-
return {
|
|
177
|
-
...super.json(),
|
|
178
|
-
feature: this.feature,
|
|
179
|
-
action: this.action,
|
|
180
|
-
}
|
|
157
|
+
public json(): TJsonError & { feature: string; action: string } {
|
|
158
|
+
return { ...super.json(), feature: this.feature, action: this.action };
|
|
181
159
|
}
|
|
182
160
|
}
|
|
183
161
|
|
|
184
162
|
export class UpgradeRequired<FeatureKeys extends string> extends CoreError {
|
|
185
163
|
public http = 402;
|
|
186
|
-
public title =
|
|
187
|
-
public static msgDefaut =
|
|
164
|
+
public title = 'Upgrade Required';
|
|
165
|
+
public static msgDefaut = 'Please Upgrade to Continue.';
|
|
188
166
|
|
|
189
|
-
public constructor(
|
|
190
|
-
message: string,
|
|
167
|
+
public constructor(
|
|
168
|
+
message: string,
|
|
191
169
|
public feature: FeatureKeys,
|
|
192
170
|
public action: string,
|
|
193
|
-
details?: TErrorDetails
|
|
171
|
+
details?: TErrorDetails,
|
|
194
172
|
) {
|
|
195
173
|
super(message, details);
|
|
196
174
|
}
|
|
197
175
|
|
|
198
|
-
public json(): TJsonError & { feature: string
|
|
199
|
-
return {
|
|
200
|
-
...super.json(),
|
|
201
|
-
feature: this.feature,
|
|
202
|
-
action: this.action,
|
|
203
|
-
}
|
|
176
|
+
public json(): TJsonError & { feature: string; action: string } {
|
|
177
|
+
return { ...super.json(), feature: this.feature, action: this.action };
|
|
204
178
|
}
|
|
205
179
|
}
|
|
206
180
|
|
|
207
181
|
export class Forbidden extends CoreError {
|
|
208
182
|
public http = 403;
|
|
209
|
-
public title =
|
|
210
|
-
public static msgDefaut =
|
|
183
|
+
public title = 'Access Denied';
|
|
184
|
+
public static msgDefaut = 'You do not have sufficient permissions to access this content.';
|
|
211
185
|
}
|
|
212
186
|
|
|
213
187
|
export class NotFound extends CoreError {
|
|
214
188
|
public http = 404;
|
|
215
|
-
public title =
|
|
216
|
-
public static msgDefaut =
|
|
189
|
+
public title = 'Not Found';
|
|
190
|
+
public static msgDefaut = 'The resource you asked for was not found.';
|
|
217
191
|
}
|
|
218
192
|
|
|
219
193
|
export class Gone extends CoreError {
|
|
220
194
|
public http = 410;
|
|
221
|
-
public title =
|
|
222
|
-
public static msgDefaut =
|
|
195
|
+
public title = 'Gone';
|
|
196
|
+
public static msgDefaut = 'The resource you asked for has been removed.';
|
|
223
197
|
}
|
|
224
198
|
|
|
225
199
|
export class RateLimit extends CoreError {
|
|
226
200
|
public http = 429;
|
|
227
201
|
public title = "You're going too fast";
|
|
228
|
-
public static msgDefaut =
|
|
202
|
+
public static msgDefaut = 'Please slow down a bit and retry again later.';
|
|
229
203
|
}
|
|
230
204
|
|
|
231
205
|
export class Anomaly extends CoreError {
|
|
232
|
-
|
|
233
206
|
public http = 500;
|
|
234
|
-
public title =
|
|
235
|
-
public static msgDefaut =
|
|
207
|
+
public title = 'Technical Error';
|
|
208
|
+
public static msgDefaut = 'A technical error has occurred. A notification has just been sent to the admin.';
|
|
236
209
|
|
|
237
|
-
public constructor(
|
|
238
|
-
message: string,
|
|
210
|
+
public constructor(
|
|
211
|
+
message: string,
|
|
239
212
|
public dataForDebugging?: object,
|
|
240
|
-
public originalError?: Error,
|
|
213
|
+
public originalError?: Error,
|
|
241
214
|
) {
|
|
242
215
|
super(message);
|
|
243
216
|
}
|
|
244
217
|
}
|
|
245
218
|
|
|
246
219
|
export class NotAvailable extends CoreError {
|
|
247
|
-
|
|
248
220
|
// TODO: page erreur pour code 503
|
|
249
221
|
public http = 404;
|
|
250
|
-
public title =
|
|
251
|
-
public static msgDefaut =
|
|
222
|
+
public title = 'Not Available';
|
|
223
|
+
public static msgDefaut = 'Sorry, the service is currently not available.';
|
|
252
224
|
}
|
|
253
225
|
|
|
254
226
|
export class NetworkError extends Error {
|
|
255
|
-
public title =
|
|
227
|
+
public title = 'Network Error';
|
|
256
228
|
}
|
|
257
229
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
message: string,
|
|
262
|
-
details?: TErrorDetails
|
|
263
|
-
): CoreError => {
|
|
264
|
-
return fromJson({
|
|
265
|
-
code,
|
|
266
|
-
message,
|
|
267
|
-
...details
|
|
268
|
-
});
|
|
269
|
-
}
|
|
230
|
+
export const viaHttpCode = (code: number, message: string, details?: TErrorDetails): CoreError => {
|
|
231
|
+
return fromJson({ code, message, ...details });
|
|
232
|
+
};
|
|
270
233
|
|
|
271
234
|
export const toJson = (e: Error | CoreError): TJsonError => {
|
|
235
|
+
if ('json' in e && typeof e.json === 'function') return e.json();
|
|
272
236
|
|
|
273
|
-
|
|
274
|
-
return e.json();
|
|
275
|
-
|
|
276
|
-
const details = ('details' in e)
|
|
277
|
-
? e.details
|
|
278
|
-
: { stack: e.stack };
|
|
237
|
+
const details = 'details' in e ? e.details : { stack: e.stack };
|
|
279
238
|
|
|
280
|
-
return { code: 500, message: e.message, ...details }
|
|
281
|
-
}
|
|
239
|
+
return { code: 500, message: e.message, ...details };
|
|
240
|
+
};
|
|
282
241
|
|
|
283
242
|
export const fromJson = ({ code, message, ...details }: TJsonError) => {
|
|
243
|
+
const errorDetails = details as Record<string, unknown>;
|
|
284
244
|
|
|
285
245
|
switch (code) {
|
|
286
|
-
case 400:
|
|
287
|
-
if (details.errors)
|
|
288
|
-
|
|
289
|
-
else
|
|
290
|
-
return new InputError( message, details );
|
|
246
|
+
case 400:
|
|
247
|
+
if (details.errors) return new InputErrorSchema(details.errors, details);
|
|
248
|
+
else return new InputError(message, details);
|
|
291
249
|
|
|
292
|
-
case 401:
|
|
250
|
+
case 401:
|
|
251
|
+
return new AuthRequired(message, errorDetails.feature as FeatureKeys, errorDetails.action as string, details);
|
|
293
252
|
|
|
294
|
-
case 402:
|
|
253
|
+
case 402:
|
|
254
|
+
return new UpgradeRequired(
|
|
255
|
+
message,
|
|
256
|
+
errorDetails.feature as FeatureKeys,
|
|
257
|
+
errorDetails.action as string,
|
|
258
|
+
details,
|
|
259
|
+
);
|
|
295
260
|
|
|
296
|
-
case 403:
|
|
261
|
+
case 403:
|
|
262
|
+
return new Forbidden(message, details);
|
|
297
263
|
|
|
298
|
-
case 404:
|
|
264
|
+
case 404:
|
|
265
|
+
return new NotFound(message, details);
|
|
299
266
|
|
|
300
|
-
case 429:
|
|
267
|
+
case 429:
|
|
268
|
+
return new RateLimit(message, details);
|
|
301
269
|
|
|
302
|
-
default:
|
|
270
|
+
default:
|
|
271
|
+
return new Anomaly(message, details);
|
|
303
272
|
}
|
|
304
|
-
|
|
305
|
-
}
|
|
273
|
+
};
|
|
306
274
|
|
|
307
275
|
export default CoreError;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*----------------------------------
|
|
2
|
+
- DEPENDANCES
|
|
3
|
+
----------------------------------*/
|
|
4
|
+
|
|
5
|
+
// Core
|
|
6
|
+
import type { TFrontRenderer, TPageSetup } from './response/page';
|
|
7
|
+
import type { TRouteOptions } from '.';
|
|
8
|
+
|
|
9
|
+
/*----------------------------------
|
|
10
|
+
- PUBLIC API
|
|
11
|
+
----------------------------------*/
|
|
12
|
+
|
|
13
|
+
// Supported `Router.page(...)` registration signatures shared by client and compiler code.
|
|
14
|
+
export type TRegisterPageArgs<TProvidedData extends {} = {}, TPageOptions extends {} = TRouteOptions> =
|
|
15
|
+
| [path: string, renderer: TFrontRenderer<TProvidedData>]
|
|
16
|
+
| [path: string, setup: TPageSetup<TProvidedData>, renderer: TFrontRenderer<TProvidedData>]
|
|
17
|
+
| [path: string, options: Partial<TPageOptions>, renderer: TFrontRenderer<TProvidedData>]
|
|
18
|
+
| [
|
|
19
|
+
path: string,
|
|
20
|
+
options: Partial<TPageOptions>,
|
|
21
|
+
setup: TPageSetup<TProvidedData>,
|
|
22
|
+
renderer: TFrontRenderer<TProvidedData>,
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
// Serialized SSR route description exchanged between build output and runtime.
|
|
26
|
+
export type TSsrUnresolvedRoute<TKey = number | string> = { chunk: string } & (
|
|
27
|
+
| { regex: string; keys: TKey[] }
|
|
28
|
+
| { code: number }
|
|
29
|
+
);
|