firstly 0.0.11 → 0.0.13
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 +16 -0
- package/esm/BaseEnum.d.ts +2 -0
- package/esm/BaseEnum.js +2 -0
- package/esm/FF_Fields.js +0 -1
- package/esm/ROUTES.d.ts +2 -2
- package/esm/ROUTES.js +10 -5
- package/esm/SqlDatabase/FF_LogToConsole.d.ts +1 -0
- package/esm/SqlDatabase/FF_LogToConsole.js +22 -16
- package/esm/api/index.d.ts +20 -21
- package/esm/api/index.js +74 -62
- package/esm/auth/{client/Auth.d.ts → AuthController.d.ts} +18 -25
- package/esm/auth/{client/Auth.js → AuthController.js} +48 -44
- package/esm/auth/{client/Entities.d.ts → Entities.d.ts} +4 -3
- package/esm/auth/{client/Entities.js → Entities.js} +7 -7
- package/esm/auth/README.md +0 -10
- package/esm/auth/index.d.ts +5 -149
- package/esm/auth/index.js +5 -316
- package/esm/auth/{AuthController.server.d.ts → server/AuthController.server.d.ts} +10 -10
- package/esm/auth/{AuthController.server.js → server/AuthController.server.js} +133 -171
- package/esm/auth/server/handleAuth.d.ts +2 -0
- package/esm/auth/server/handleAuth.js +140 -0
- package/esm/auth/server/handleGuard.d.ts +16 -0
- package/esm/auth/server/handleGuard.js +67 -0
- package/esm/auth/server/helperDb.d.ts +10 -0
- package/esm/auth/server/helperDb.js +56 -0
- package/esm/auth/server/helperFirstly.d.ts +1 -0
- package/esm/auth/server/helperFirstly.js +8 -0
- package/esm/auth/server/helperOslo.d.ts +7 -0
- package/esm/auth/server/helperOslo.js +24 -0
- package/esm/auth/server/helperRemultServer.d.ts +5 -0
- package/esm/auth/server/helperRemultServer.js +44 -0
- package/esm/auth/{RoleHelpers.d.ts → server/helperRole.d.ts} +1 -1
- package/esm/auth/{RoleHelpers.js → server/helperRole.js} +1 -1
- package/esm/auth/server/index.d.ts +7 -0
- package/esm/auth/server/index.js +7 -0
- package/esm/auth/server/module.d.ts +257 -0
- package/esm/auth/server/module.js +197 -0
- package/esm/auth/{providers → server/providers}/github.d.ts +6 -4
- package/esm/auth/{providers → server/providers}/github.js +29 -20
- package/esm/auth/{providers/index.d.ts → server/providers/helperProvider.d.ts} +0 -2
- package/esm/auth/{providers/index.js → server/providers/helperProvider.js} +5 -6
- package/esm/auth/static/assets/Page-BUfjaN-D.d.ts +5 -0
- package/esm/auth/static/assets/Page-BUfjaN-D.js +19 -0
- package/esm/auth/static/assets/Page-CJ58H1vl.css +1 -0
- package/esm/auth/static/assets/Page-CaDAqmBS.d.ts +5 -0
- package/esm/auth/static/assets/Page-CaDAqmBS.js +1 -0
- package/esm/auth/static/assets/Page-DhdZddzJ.d.ts +5 -0
- package/esm/auth/static/assets/Page-DhdZddzJ.js +1 -0
- package/esm/auth/static/assets/index-BDy4A_14.css +4 -0
- package/esm/auth/static/assets/index-D-Ztdt2o.d.ts +54 -0
- package/esm/auth/static/assets/index-D-Ztdt2o.js +2 -0
- package/esm/auth/static/index.html +11 -11
- package/esm/auth/types.d.ts +5 -0
- package/esm/bin/cmd.js +122 -54
- package/esm/cellsBuildor.js +7 -7
- package/esm/changeLog/index.d.ts +0 -36
- package/esm/changeLog/index.js +3 -43
- package/esm/changeLog/server/index.d.ts +36 -0
- package/esm/changeLog/server/index.js +42 -0
- package/esm/common.d.ts +5 -0
- package/esm/common.js +8 -0
- package/esm/cron/{index.d.ts → server/index.d.ts} +1 -1
- package/esm/cron/server/index.js +103 -0
- package/esm/feedback/FeedbackController.js +4 -5
- package/esm/feedback/index.d.ts +0 -16
- package/esm/feedback/index.js +0 -11
- package/esm/feedback/server/index.d.ts +17 -0
- package/esm/feedback/server/index.js +13 -0
- package/esm/feedback/ui/DialogIssue.svelte +52 -56
- package/esm/feedback/ui/DialogIssues.svelte +71 -71
- package/esm/feedback/ui/DialogMilestones.svelte +22 -22
- package/esm/helper.js +3 -3
- package/esm/index.d.ts +3 -20
- package/esm/index.js +3 -10
- package/esm/mail/index.d.ts +2 -30
- package/esm/mail/index.js +2 -79
- package/esm/mail/server/index.d.ts +31 -0
- package/esm/mail/server/index.js +88 -0
- package/esm/mail/templates/DefaultMail.svelte +17 -17
- package/esm/storeItem.js +8 -2
- package/esm/storeList.d.ts +1 -1
- package/esm/storeList.js +1 -1
- package/esm/sveltekit/server/index.d.ts +14 -0
- package/esm/sveltekit/server/index.js +24 -0
- package/esm/ui/Button.svelte +33 -33
- package/esm/ui/Button.svelte.d.ts +2 -2
- package/esm/ui/Clipboardable.svelte +11 -8
- package/esm/ui/Clipboardable.svelte.d.ts +4 -4
- package/esm/ui/Field.svelte +142 -149
- package/esm/ui/Field.svelte.d.ts +2 -2
- package/esm/ui/FieldGroup.svelte +38 -38
- package/esm/ui/Grid.svelte +212 -222
- package/esm/ui/GridLoading.svelte +18 -22
- package/esm/ui/GridPaginate.svelte +38 -38
- package/esm/ui/Icon.svelte +50 -49
- package/esm/ui/Icon.svelte.d.ts +18 -18
- package/esm/ui/Loading.svelte +5 -2
- package/esm/ui/Tooltip.svelte +16 -16
- package/esm/ui/dialog/DialogForm.svelte +23 -23
- package/esm/ui/dialog/DialogManagement.svelte +74 -74
- package/esm/ui/dialog/DialogPrimitive.svelte +50 -51
- package/esm/ui/dialog/FormEditAction.svelte +34 -34
- package/esm/ui/dialog/dialog.d.ts +2 -2
- package/esm/ui/dialog/dialog.js +1 -1
- package/esm/ui/internals/FieldContainer.svelte +11 -12
- package/esm/ui/internals/FieldContainer.svelte.d.ts +3 -3
- package/esm/ui/internals/Input.svelte +25 -25
- package/esm/ui/internals/Input.svelte.d.ts +1 -1
- package/esm/ui/internals/Textarea.svelte +21 -21
- package/esm/ui/internals/Textarea.svelte.d.ts +2 -2
- package/esm/ui/internals/select/MultiSelectMelt.svelte +69 -73
- package/esm/ui/internals/select/SelectMelt.svelte +86 -86
- package/esm/ui/internals/select/SelectRadio.svelte +22 -22
- package/esm/ui/link/Link.svelte +14 -14
- package/esm/ui/link/Link.svelte.d.ts +3 -4
- package/esm/ui/link/LinkPlus.svelte +33 -35
- package/esm/vite/index.js +24 -25
- package/package.json +50 -42
- package/esm/auth/Adapter.d.ts +0 -10
- package/esm/auth/Adapter.js +0 -50
- package/esm/auth/client/index.d.ts +0 -7
- package/esm/auth/client/index.js +0 -7
- package/esm/auth/helper.d.ts +0 -6
- package/esm/auth/helper.js +0 -14
- package/esm/auth/providers/strava.d.ts +0 -30
- package/esm/auth/providers/strava.js +0 -60
- package/esm/auth/static/assets/Page-BEFYPjis.d.ts +0 -4
- package/esm/auth/static/assets/Page-BEFYPjis.js +0 -1
- package/esm/auth/static/assets/Page-BGTO8LC5.css +0 -1
- package/esm/auth/static/assets/Page-Cfysx_UV.d.ts +0 -6
- package/esm/auth/static/assets/Page-Cfysx_UV.js +0 -18
- package/esm/auth/static/assets/Page-DtgkOCJs.d.ts +0 -4
- package/esm/auth/static/assets/Page-DtgkOCJs.js +0 -1
- package/esm/auth/static/assets/index-CR_3yNaJ.css +0 -4
- package/esm/auth/static/assets/index-QypqCYwC.d.ts +0 -63
- package/esm/auth/static/assets/index-QypqCYwC.js +0 -2
- package/esm/cron/index.js +0 -102
- package/esm/handle/index.d.ts +0 -7
- package/esm/handle/index.js +0 -40
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# firstly
|
|
2
2
|
|
|
3
|
+
## 0.0.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#66](https://github.com/jycouet/firstly/pull/66)
|
|
8
|
+
[`7d8b323`](https://github.com/jycouet/firstly/commit/7d8b323b49d7d76b6d59ec887ed2e37a2238f201)
|
|
9
|
+
Thanks [@jycouet](https://github.com/jycouet)! - prepare JYC 013
|
|
10
|
+
|
|
11
|
+
## 0.0.12
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#64](https://github.com/jycouet/firstly/pull/64)
|
|
16
|
+
[`782ef9c`](https://github.com/jycouet/firstly/commit/782ef9c8a1d967950e4c17de59b3225bc28df5c2)
|
|
17
|
+
Thanks [@jycouet](https://github.com/jycouet)! - prepare JYC 012
|
|
18
|
+
|
|
3
19
|
## 0.0.11
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/esm/BaseEnum.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export type BaseEnumOptions<Entity = any> = {
|
|
|
22
22
|
icon?: FF_Icon;
|
|
23
23
|
where?: FindOptionsBase<Entity>['where'];
|
|
24
24
|
class?: string;
|
|
25
|
+
hide?: boolean;
|
|
25
26
|
};
|
|
26
27
|
export declare class BaseEnum<Entity = any> {
|
|
27
28
|
id: string;
|
|
@@ -29,5 +30,6 @@ export declare class BaseEnum<Entity = any> {
|
|
|
29
30
|
icon?: FF_Icon;
|
|
30
31
|
where?: FindOptionsBase<Entity>['where'];
|
|
31
32
|
class?: string;
|
|
33
|
+
hide?: boolean;
|
|
32
34
|
constructor(_id: string | number, options?: BaseEnumOptions<Entity>);
|
|
33
35
|
}
|
package/esm/BaseEnum.js
CHANGED
|
@@ -4,12 +4,14 @@ export class BaseEnum {
|
|
|
4
4
|
icon;
|
|
5
5
|
where;
|
|
6
6
|
class;
|
|
7
|
+
hide;
|
|
7
8
|
constructor(_id, options) {
|
|
8
9
|
this.id = _id.toString();
|
|
9
10
|
this.caption = options?.caption ?? this.id;
|
|
10
11
|
this.icon = options?.icon;
|
|
11
12
|
this.where = options?.where;
|
|
12
13
|
this.class = options?.class;
|
|
14
|
+
this.hide = options?.hide;
|
|
13
15
|
if (options?.icon && options.icon.caption === undefined) {
|
|
14
16
|
options.icon.caption = options?.caption;
|
|
15
17
|
}
|
package/esm/FF_Fields.js
CHANGED
package/esm/ROUTES.d.ts
CHANGED
package/esm/ROUTES.js
CHANGED
|
@@ -32,9 +32,9 @@ const LINKS = {
|
|
|
32
32
|
"remult_admin": `/api/admin`,
|
|
33
33
|
"github": (params) => {
|
|
34
34
|
params = params ?? {};
|
|
35
|
-
params
|
|
36
|
-
params
|
|
37
|
-
return `https://github.com/${params
|
|
35
|
+
params['owner'] = params['owner'] ?? "jycouet";
|
|
36
|
+
params['repo'] = params['repo'] ?? "firstly";
|
|
37
|
+
return `https://github.com/${params['owner']}/${params['repo']}`;
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
/**
|
|
@@ -49,7 +49,12 @@ export const appendSp = (sp, prefix = '?') => {
|
|
|
49
49
|
params.append(n, String(v));
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
+
let anchor = '';
|
|
52
53
|
for (const [name, val] of Object.entries(sp)) {
|
|
54
|
+
if (name === '__KIT_ROUTES_ANCHOR__' && val !== undefined) {
|
|
55
|
+
anchor = `#${val}`;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
53
58
|
if (Array.isArray(val)) {
|
|
54
59
|
for (const v of val) {
|
|
55
60
|
append(name, v);
|
|
@@ -60,8 +65,8 @@ export const appendSp = (sp, prefix = '?') => {
|
|
|
60
65
|
}
|
|
61
66
|
}
|
|
62
67
|
const formatted = params.toString();
|
|
63
|
-
if (formatted) {
|
|
64
|
-
return `${prefix}${formatted}
|
|
68
|
+
if (formatted || anchor) {
|
|
69
|
+
return `${prefix}${formatted}${anchor}`.replace('?#', '#');
|
|
65
70
|
}
|
|
66
71
|
return '';
|
|
67
72
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const FF_LogToConsole: (duration: number, query: string, args: Record<string, any>, options?: {
|
|
2
2
|
withDetails?: boolean;
|
|
3
3
|
tablesToHide?: string[][];
|
|
4
|
+
ending?: (duration: number, query: string, args: Record<string, any>, tables: string[]) => void;
|
|
4
5
|
}) => string | undefined;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SqlDatabase } from 'remult';
|
|
1
2
|
import { bgCyan, cyan, green, Log, magenta, yellow } from '@kitql/helpers';
|
|
2
3
|
const typeQuery = new Map([
|
|
3
4
|
// CRUD
|
|
@@ -16,7 +17,10 @@ const typeQuery = new Map([
|
|
|
16
17
|
]);
|
|
17
18
|
const keys = ['FROM', 'WHERE', 'LIMIT', 'OFFSET'];
|
|
18
19
|
const typeQueryKey = Array.from(typeQuery.keys());
|
|
20
|
+
const log = new Log('');
|
|
19
21
|
export const FF_LogToConsole = (duration, query, args, options) => {
|
|
22
|
+
if (duration < SqlDatabase.durationThreshold)
|
|
23
|
+
return;
|
|
20
24
|
const rawSql = query
|
|
21
25
|
.replace(/(\r\n|\n|\r|\t)/gm, ' ')
|
|
22
26
|
.replace(/ +/g, ' ')
|
|
@@ -67,6 +71,18 @@ export const FF_LogToConsole = (duration, query, args, options) => {
|
|
|
67
71
|
listArgs.push(s[i - 2].replaceAll('"', '') + ': ' + s[i]);
|
|
68
72
|
}
|
|
69
73
|
}
|
|
74
|
+
const toFilterOut = options?.tablesToHide ?? [
|
|
75
|
+
['information_Schema.tables'],
|
|
76
|
+
['information_schema.columns'],
|
|
77
|
+
// ['__remult_migrations_version'],
|
|
78
|
+
['ff_auth.accounts'],
|
|
79
|
+
['ff_auth.users'],
|
|
80
|
+
['ff_auth.users_sessions'],
|
|
81
|
+
['_ff_change_logs'],
|
|
82
|
+
];
|
|
83
|
+
const toHide = toFilterOut.some((item) => item.every((i) => tables.map((c) => c.replaceAll('"', '')).includes(i)));
|
|
84
|
+
if (toHide)
|
|
85
|
+
return;
|
|
70
86
|
const final_s = s.join(' ').replace(/ +/g, ' ');
|
|
71
87
|
// args replace
|
|
72
88
|
// const listArgs = []
|
|
@@ -79,7 +95,8 @@ export const FF_LogToConsole = (duration, query, args, options) => {
|
|
|
79
95
|
const subTables = uniqueTables.slice(0, -1);
|
|
80
96
|
const time = ` ${bgCyan((duration * 1000).toFixed(0).padStart(3) + ' ms ')}`;
|
|
81
97
|
let toLog = '';
|
|
82
|
-
|
|
98
|
+
const withDetails = options?.withDetails === undefined ? true : options?.withDetails;
|
|
99
|
+
if (withDetails) {
|
|
83
100
|
toLog = `${typeQuery.get(first) || '💢'}` + time + ` ${final_s}`;
|
|
84
101
|
}
|
|
85
102
|
else {
|
|
@@ -90,20 +107,9 @@ export const FF_LogToConsole = (duration, query, args, options) => {
|
|
|
90
107
|
`${listArgs.length > 0 ? ` { ${listArgs.join(', ')} }` : ``}` +
|
|
91
108
|
`${subTables.length > 0 ? magenta(` (sub: ${subTables.join(', ')})`) : ``}`;
|
|
92
109
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
['information_schema.columns'],
|
|
97
|
-
['ff_auth.accounts'],
|
|
98
|
-
['ff_auth.users'],
|
|
99
|
-
['ff_auth.users_sessions'],
|
|
100
|
-
['_ff_change_logs'],
|
|
101
|
-
];
|
|
102
|
-
const OnoOfFiltered = toFilterOut.some((item) => item.every((i) => tables.map((c) => c.replaceAll('"', '')).includes(i)));
|
|
103
|
-
if (!OnoOfFiltered) {
|
|
104
|
-
// console.log(`toLogLong`, toLogLong)
|
|
105
|
-
log.info(toLog);
|
|
106
|
-
return toLog;
|
|
110
|
+
log.info(toLog);
|
|
111
|
+
if (options?.ending) {
|
|
112
|
+
options.ending(duration, query, args, tables);
|
|
107
113
|
}
|
|
114
|
+
return toLog;
|
|
108
115
|
};
|
|
109
|
-
const log = new Log('');
|
package/esm/api/index.d.ts
CHANGED
|
@@ -1,40 +1,39 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RequestEvent } from '@sveltejs/kit';
|
|
2
2
|
import { type ClassType } from 'remult';
|
|
3
3
|
import type { RemultServerOptions } from 'remult/server';
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import { Log } from '@kitql/helpers';
|
|
5
|
+
type ModuleInput = {
|
|
6
6
|
/**
|
|
7
7
|
* The name of the module (usefull for logging and debugging purposes)
|
|
8
8
|
*/
|
|
9
9
|
name: string;
|
|
10
|
-
|
|
10
|
+
priority?: number;
|
|
11
11
|
entities?: ClassType<any>[];
|
|
12
12
|
controllers?: ClassType<any>[];
|
|
13
13
|
initApi?: RemultServerOptions<RequestEvent>['initApi'];
|
|
14
14
|
initRequest?: RemultServerOptions<RequestEvent>['initRequest'];
|
|
15
|
-
handlePreRemult?: Handle;
|
|
16
|
-
handlePosRemult?: Handle;
|
|
17
|
-
earlyReturn?: (input: Parameters<Handle>[0]) => Promise<{
|
|
18
|
-
early: false;
|
|
19
|
-
resolve?: undefined;
|
|
20
|
-
} | {
|
|
21
|
-
early: true;
|
|
22
|
-
resolve: ReturnType<Handle>;
|
|
23
|
-
}>;
|
|
24
15
|
modules?: Module[];
|
|
25
16
|
};
|
|
26
|
-
|
|
17
|
+
export declare class Module {
|
|
18
|
+
name: string;
|
|
19
|
+
log: Log;
|
|
20
|
+
priority?: number;
|
|
21
|
+
entities?: ClassType<any>[];
|
|
22
|
+
controllers?: ClassType<any>[];
|
|
23
|
+
initApi?: RemultServerOptions<RequestEvent>['initApi'];
|
|
24
|
+
initRequest?: RemultServerOptions<RequestEvent>['initRequest'];
|
|
25
|
+
modules?: Module[];
|
|
26
|
+
constructor(input: ModuleInput);
|
|
27
|
+
}
|
|
28
|
+
type Options = RemultServerOptions<RequestEvent<Partial<Record<string, string>>, string | null>> & {
|
|
27
29
|
modules?: Module[] | undefined;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
};
|
|
31
|
+
export declare let entities: ClassType<any>[];
|
|
30
32
|
/**
|
|
31
33
|
* it's basically `remultSveltekit` with the `modules` option
|
|
34
|
+
* @deprecated will be done directly in remult when modules will be in 😉
|
|
32
35
|
*/
|
|
33
|
-
export declare const firstly: (o: Options) =>
|
|
34
|
-
modulesSorted: Module[];
|
|
35
|
-
entities: ClassType<any>[];
|
|
36
|
-
server: import("remult/remult-sveltekit").RemultSveltekitServer;
|
|
37
|
-
};
|
|
36
|
+
export declare const firstly: (o: Options) => import("remult/remult-sveltekit").RemultSveltekitServer;
|
|
38
37
|
/**
|
|
39
38
|
* Full flat and ordered list by index and concatenaining the modules name
|
|
40
39
|
*/
|
package/esm/api/index.js
CHANGED
|
@@ -1,81 +1,93 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { remult } from 'remult';
|
|
1
|
+
import {} from 'remult';
|
|
3
2
|
import { remultSveltekit } from 'remult/remult-sveltekit';
|
|
4
3
|
import { Log } from '@kitql/helpers';
|
|
5
4
|
import { building } from '$app/environment';
|
|
6
|
-
import {
|
|
5
|
+
import { sveltekit } from '../sveltekit/server';
|
|
6
|
+
export class Module {
|
|
7
|
+
name;
|
|
8
|
+
log;
|
|
9
|
+
priority;
|
|
10
|
+
entities;
|
|
11
|
+
controllers;
|
|
12
|
+
initApi;
|
|
13
|
+
initRequest;
|
|
14
|
+
modules;
|
|
15
|
+
constructor(input) {
|
|
16
|
+
this.name = input.name;
|
|
17
|
+
this.log = new Log(`firstly | ${this.name}`);
|
|
18
|
+
this.priority = input.priority;
|
|
19
|
+
this.entities = input.entities;
|
|
20
|
+
this.controllers = input.controllers;
|
|
21
|
+
this.initApi = input.initApi;
|
|
22
|
+
this.initRequest = input.initRequest;
|
|
23
|
+
this.modules = input.modules;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export let entities = [];
|
|
7
27
|
/**
|
|
8
28
|
* it's basically `remultSveltekit` with the `modules` option
|
|
29
|
+
* @deprecated will be done directly in remult when modules will be in 😉
|
|
9
30
|
*/
|
|
10
31
|
export const firstly = (o) => {
|
|
11
|
-
const modulesSorted = modulesFlatAndOrdered(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
32
|
+
const modulesSorted = modulesFlatAndOrdered([
|
|
33
|
+
...[...(o.modules ?? []), sveltekit()],
|
|
34
|
+
new Module({
|
|
35
|
+
name: 'default',
|
|
36
|
+
entities: o.entities ?? [],
|
|
37
|
+
controllers: o.controllers ?? [],
|
|
38
|
+
initRequest: o.initRequest,
|
|
39
|
+
initApi: o.initApi,
|
|
40
|
+
}),
|
|
41
|
+
]);
|
|
42
|
+
entities = modulesSorted.flatMap((m) => m.entities ?? []);
|
|
43
|
+
return remultSveltekit({
|
|
44
|
+
// Changing the default default of remult
|
|
45
|
+
logApiEndPoints: false,
|
|
46
|
+
admin: true,
|
|
47
|
+
defaultGetLimit: 25,
|
|
48
|
+
error: o.error
|
|
49
|
+
? o.error
|
|
50
|
+
: async (e) => {
|
|
51
|
+
// REMULT P2: validation error should probably be 409
|
|
52
|
+
// if 400 we move to 409
|
|
53
|
+
if (e.httpStatusCode == 400) {
|
|
54
|
+
e.sendError(409, e.responseBody);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
// Add user configuration
|
|
58
|
+
...o,
|
|
59
|
+
// Module part
|
|
16
60
|
entities,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
: async (e) => {
|
|
25
|
-
// REMULT P2: validation error should probably be 409
|
|
26
|
-
// if 400 we move to 409
|
|
27
|
-
if (e.httpStatusCode == 400) {
|
|
28
|
-
e.sendError(409, e.responseBody);
|
|
61
|
+
controllers: modulesSorted.flatMap((m) => m.controllers ?? []),
|
|
62
|
+
initRequest: async (kitEvent, op) => {
|
|
63
|
+
for (let i = 0; i < modulesSorted.length; i++) {
|
|
64
|
+
const f = modulesSorted[i].initRequest;
|
|
65
|
+
if (f) {
|
|
66
|
+
try {
|
|
67
|
+
await f(kitEvent, op);
|
|
29
68
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
remult.context.url = kitEvent.url;
|
|
39
|
-
remult.context.setHeaders = (headers) => {
|
|
40
|
-
kitEvent.setHeaders(headers);
|
|
41
|
-
};
|
|
42
|
-
remult.context.setCookie = (name, value, opts) => {
|
|
43
|
-
kitEvent.cookies.set(name, value, opts);
|
|
44
|
-
};
|
|
45
|
-
remult.context.deleteCookie = (name, opts) => {
|
|
46
|
-
kitEvent.cookies.delete(name, opts);
|
|
47
|
-
};
|
|
69
|
+
catch (error) {
|
|
70
|
+
modulesSorted[i].log.error(error);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
initApi: async (r) => {
|
|
76
|
+
if (!building) {
|
|
48
77
|
for (let i = 0; i < modulesSorted.length; i++) {
|
|
49
|
-
const f = modulesSorted[i].
|
|
78
|
+
const f = modulesSorted[i].initApi;
|
|
50
79
|
if (f) {
|
|
51
80
|
try {
|
|
52
|
-
await f(
|
|
81
|
+
await f(r);
|
|
53
82
|
}
|
|
54
83
|
catch (error) {
|
|
55
|
-
|
|
56
|
-
log.error(error);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
initApi: async (r) => {
|
|
62
|
-
if (!building) {
|
|
63
|
-
for (let i = 0; i < modulesSorted.length; i++) {
|
|
64
|
-
const f = modulesSorted[i].initApi;
|
|
65
|
-
if (f) {
|
|
66
|
-
try {
|
|
67
|
-
await f(r);
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
const log = new Log(`firstly | ${modulesSorted[i].name}`);
|
|
71
|
-
log.error(error);
|
|
72
|
-
}
|
|
84
|
+
modulesSorted[i].log.error(error);
|
|
73
85
|
}
|
|
74
86
|
}
|
|
75
87
|
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
};
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
});
|
|
79
91
|
};
|
|
80
92
|
/**
|
|
81
93
|
* Full flat and ordered list by index and concatenaining the modules name
|
|
@@ -92,6 +104,6 @@ export const modulesFlatAndOrdered = (modules) => {
|
|
|
92
104
|
}, []);
|
|
93
105
|
};
|
|
94
106
|
const flatModules = flattenModules(modules);
|
|
95
|
-
flatModules.sort((a, b) => (a.
|
|
107
|
+
flatModules.sort((a, b) => (a.priority || 0) - (b.priority || 0));
|
|
96
108
|
return flatModules;
|
|
97
109
|
};
|
|
@@ -1,25 +1,18 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare class
|
|
3
|
-
|
|
4
|
-
static
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
static resetPasswordFn: any;
|
|
17
|
-
/** DO NOT USE */
|
|
18
|
-
static signInOTPFn: any;
|
|
19
|
-
/** DO NOT USE */
|
|
20
|
-
static verifyOtpFn: any;
|
|
21
|
-
/** DO NOT USE */
|
|
22
|
-
static signInOAuthGetUrlFn: any;
|
|
1
|
+
import type { ProviderConfigured } from './server/module';
|
|
2
|
+
export declare class AuthController {
|
|
3
|
+
#private;
|
|
4
|
+
static _setAbstraction(impl: {
|
|
5
|
+
signOut: any;
|
|
6
|
+
signInDemo: any;
|
|
7
|
+
invite: any;
|
|
8
|
+
signUpPassword: any;
|
|
9
|
+
signInPassword: any;
|
|
10
|
+
forgotPassword: any;
|
|
11
|
+
resetPassword: any;
|
|
12
|
+
signInOTP: any;
|
|
13
|
+
verifyOtp: any;
|
|
14
|
+
signInOAuthGetUrl: any;
|
|
15
|
+
}): void;
|
|
23
16
|
/**
|
|
24
17
|
* Sign out the current user
|
|
25
18
|
*/
|
|
@@ -54,7 +47,7 @@ export declare class Auth {
|
|
|
54
47
|
/**
|
|
55
48
|
* Verify the OTP code
|
|
56
49
|
*/
|
|
57
|
-
static verifyOtp(email: string, otp: string
|
|
50
|
+
static verifyOtp(email: string, otp: string): Promise<any>;
|
|
58
51
|
/** OAUTH */
|
|
59
52
|
/**
|
|
60
53
|
* The the url to redirect to for the OAuth provider
|
|
@@ -68,9 +61,9 @@ export declare class Auth {
|
|
|
68
61
|
*
|
|
69
62
|
* _(popup example should work too, and a nice example/componant would be appreciated)_
|
|
70
63
|
*/
|
|
71
|
-
static signInOAuthGetUrl<T extends keyof
|
|
64
|
+
static signInOAuthGetUrl<T extends keyof ProviderConfigured>(o: {
|
|
72
65
|
provider: T;
|
|
73
|
-
options?:
|
|
66
|
+
options?: ProviderConfigured[T];
|
|
74
67
|
redirect?: string;
|
|
75
68
|
}): Promise<any>;
|
|
76
69
|
}
|
|
@@ -4,81 +4,85 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
static signOutFn;
|
|
12
|
-
|
|
13
|
-
static
|
|
14
|
-
|
|
15
|
-
static
|
|
16
|
-
|
|
17
|
-
static
|
|
18
|
-
|
|
19
|
-
static
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
7
|
+
import { BackendMethod } from 'remult';
|
|
8
|
+
import { FF_Role_Auth } from './Entities';
|
|
9
|
+
export class AuthController {
|
|
10
|
+
// Private static fields
|
|
11
|
+
static #signOutFn;
|
|
12
|
+
static #signInDemoFn;
|
|
13
|
+
static #inviteFn;
|
|
14
|
+
static #signUpPasswordFn;
|
|
15
|
+
static #signInPasswordFn;
|
|
16
|
+
static #forgotPasswordFn;
|
|
17
|
+
static #resetPasswordFn;
|
|
18
|
+
static #signInOTPFn;
|
|
19
|
+
static #verifyOtpFn;
|
|
20
|
+
static #signInOAuthGetUrlFn;
|
|
21
|
+
// Internal setter method that can be used by the module
|
|
22
|
+
static _setAbstraction(impl) {
|
|
23
|
+
this.#signOutFn = impl.signOut;
|
|
24
|
+
this.#signInDemoFn = impl.signInDemo;
|
|
25
|
+
this.#inviteFn = impl.invite;
|
|
26
|
+
this.#signUpPasswordFn = impl.signUpPassword;
|
|
27
|
+
this.#signInPasswordFn = impl.signInPassword;
|
|
28
|
+
this.#forgotPasswordFn = impl.forgotPassword;
|
|
29
|
+
this.#resetPasswordFn = impl.resetPassword;
|
|
30
|
+
this.#signInOTPFn = impl.signInOTP;
|
|
31
|
+
this.#verifyOtpFn = impl.verifyOtp;
|
|
32
|
+
this.#signInOAuthGetUrlFn = impl.signInOAuthGetUrl;
|
|
33
|
+
}
|
|
30
34
|
/**
|
|
31
35
|
* Sign out the current user
|
|
32
36
|
*/
|
|
33
37
|
static async signOut() {
|
|
34
|
-
return await
|
|
38
|
+
return await AuthController.#signOutFn();
|
|
35
39
|
}
|
|
36
40
|
/**
|
|
37
41
|
* Sign in with a demo account
|
|
38
42
|
* _(The easiest way to demo & test your application)_
|
|
39
43
|
*/
|
|
40
44
|
static async signInDemo(name) {
|
|
41
|
-
return await
|
|
45
|
+
return await AuthController.#signInDemoFn(name);
|
|
42
46
|
}
|
|
43
47
|
/**
|
|
44
48
|
* This is for login / password authentication Invite someone
|
|
45
49
|
*/
|
|
46
50
|
static async invite(email) {
|
|
47
|
-
return await
|
|
51
|
+
return await AuthController.#inviteFn(email);
|
|
48
52
|
}
|
|
49
53
|
/**
|
|
50
54
|
* This is for login / password authentication SignUp
|
|
51
55
|
*/
|
|
52
56
|
static async signUpPassword(email, password) {
|
|
53
|
-
return await
|
|
57
|
+
return await AuthController.#signUpPasswordFn(email, password);
|
|
54
58
|
}
|
|
55
59
|
/**
|
|
56
60
|
* This is for login / password authentication SignIn
|
|
57
61
|
*/
|
|
58
62
|
static async signInPassword(email, password) {
|
|
59
|
-
return await
|
|
63
|
+
return await AuthController.#signInPasswordFn(email, password);
|
|
60
64
|
}
|
|
61
65
|
/**
|
|
62
66
|
* Forgot your password ? Send a mail to reset it.
|
|
63
67
|
*/
|
|
64
68
|
static async forgotPassword(email) {
|
|
65
|
-
return await
|
|
69
|
+
return await AuthController.#forgotPasswordFn(email);
|
|
66
70
|
}
|
|
67
71
|
/**
|
|
68
72
|
* Reset your password with a token
|
|
69
73
|
*/
|
|
70
74
|
static async resetPassword(token, password) {
|
|
71
|
-
return await
|
|
75
|
+
return await AuthController.#resetPasswordFn(token, password);
|
|
72
76
|
}
|
|
73
77
|
/** OTP */
|
|
74
78
|
static async signInOTP(email) {
|
|
75
|
-
return await
|
|
79
|
+
return await AuthController.#signInOTPFn(email);
|
|
76
80
|
}
|
|
77
81
|
/**
|
|
78
82
|
* Verify the OTP code
|
|
79
83
|
*/
|
|
80
84
|
static async verifyOtp(email, otp) {
|
|
81
|
-
return await
|
|
85
|
+
return await AuthController.#verifyOtpFn(email, otp);
|
|
82
86
|
}
|
|
83
87
|
/** OAUTH */
|
|
84
88
|
/**
|
|
@@ -94,36 +98,36 @@ export class Auth {
|
|
|
94
98
|
* _(popup example should work too, and a nice example/componant would be appreciated)_
|
|
95
99
|
*/
|
|
96
100
|
static async signInOAuthGetUrl(o) {
|
|
97
|
-
return await
|
|
101
|
+
return await AuthController.#signInOAuthGetUrlFn(o);
|
|
98
102
|
}
|
|
99
103
|
}
|
|
100
104
|
__decorate([
|
|
101
105
|
BackendMethod({ allowed: true })
|
|
102
|
-
],
|
|
106
|
+
], AuthController, "signOut", null);
|
|
103
107
|
__decorate([
|
|
104
108
|
BackendMethod({ allowed: true })
|
|
105
|
-
],
|
|
109
|
+
], AuthController, "signInDemo", null);
|
|
106
110
|
__decorate([
|
|
107
|
-
BackendMethod({ allowed:
|
|
108
|
-
],
|
|
111
|
+
BackendMethod({ allowed: FF_Role_Auth.FF_Role_Auth_Invite })
|
|
112
|
+
], AuthController, "invite", null);
|
|
109
113
|
__decorate([
|
|
110
114
|
BackendMethod({ allowed: true })
|
|
111
|
-
],
|
|
115
|
+
], AuthController, "signUpPassword", null);
|
|
112
116
|
__decorate([
|
|
113
117
|
BackendMethod({ allowed: true })
|
|
114
|
-
],
|
|
118
|
+
], AuthController, "signInPassword", null);
|
|
115
119
|
__decorate([
|
|
116
120
|
BackendMethod({ allowed: true })
|
|
117
|
-
],
|
|
121
|
+
], AuthController, "forgotPassword", null);
|
|
118
122
|
__decorate([
|
|
119
123
|
BackendMethod({ allowed: true })
|
|
120
|
-
],
|
|
124
|
+
], AuthController, "resetPassword", null);
|
|
121
125
|
__decorate([
|
|
122
126
|
BackendMethod({ allowed: true })
|
|
123
|
-
],
|
|
127
|
+
], AuthController, "signInOTP", null);
|
|
124
128
|
__decorate([
|
|
125
129
|
BackendMethod({ allowed: true })
|
|
126
|
-
],
|
|
130
|
+
], AuthController, "verifyOtp", null);
|
|
127
131
|
__decorate([
|
|
128
132
|
BackendMethod({ allowed: true })
|
|
129
|
-
],
|
|
133
|
+
], AuthController, "signInOAuthGetUrl", null);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { BaseEnum } from '
|
|
2
|
-
import type { BaseEnumOptions } from '
|
|
1
|
+
import { BaseEnum } from '..';
|
|
2
|
+
import type { BaseEnumOptions } from '..';
|
|
3
3
|
export declare const FF_Role_Auth: {
|
|
4
|
-
readonly
|
|
4
|
+
readonly FF_Role_Auth_Admin: "FF_Role_Auth.Admin";
|
|
5
|
+
readonly FF_Role_Auth_Invite: "FF_Role_Auth.Invite";
|
|
5
6
|
};
|
|
6
7
|
export declare class FFAuthUser {
|
|
7
8
|
id: string;
|