firstly 0.0.11 → 0.0.12
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 +8 -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 +19 -21
- package/esm/api/index.js +72 -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} +126 -164
- package/esm/auth/server/handleAuth.d.ts +2 -0
- package/esm/auth/server/handleAuth.js +140 -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 +5 -0
- package/esm/auth/server/index.js +5 -0
- package/esm/auth/server/module.d.ts +238 -0
- package/esm/auth/server/module.js +184 -0
- package/esm/auth/{providers → server/providers}/github.d.ts +6 -5
- package/esm/auth/{providers → server/providers}/github.js +30 -21
- 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-BEFYPjis.d.ts → Page-Bb8bFlrP.d.ts} +1 -1
- package/esm/auth/static/assets/{Page-DtgkOCJs.js → Page-Bb8bFlrP.js} +1 -1
- package/esm/auth/static/assets/{Page-DtgkOCJs.d.ts → Page-BxomFlZ8.d.ts} +1 -1
- package/esm/auth/static/assets/{Page-BEFYPjis.js → Page-BxomFlZ8.js} +1 -1
- package/esm/auth/static/assets/Page-CaIYu0-y.d.ts +6 -0
- package/esm/auth/static/assets/Page-CaIYu0-y.js +19 -0
- package/esm/auth/static/assets/Page-MkYglNtu.css +1 -0
- package/esm/auth/static/assets/index-Bl0Bk5u0.d.ts +64 -0
- package/esm/auth/static/assets/index-Bl0Bk5u0.js +2 -0
- package/esm/auth/static/assets/{index-CR_3yNaJ.css → index-R27C_TlP.css} +1 -1
- package/esm/auth/static/index.html +2 -2
- package/esm/auth/types.d.ts +5 -0
- package/esm/bin/cmd.js +3 -6
- package/esm/cellsBuildor.js +6 -6
- 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/cron/{index.d.ts → server/index.d.ts} +1 -1
- package/esm/cron/server/index.js +103 -0
- package/esm/feedback/FeedbackController.js +3 -3
- 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/helper.js +3 -3
- package/esm/index.d.ts +2 -16
- package/esm/index.js +2 -3
- 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/storeItem.d.ts +4 -1
- package/esm/storeItem.js +8 -2
- package/esm/storeList.d.ts +5 -2
- package/esm/storeList.js +1 -1
- package/esm/sveltekit/server/index.d.ts +11 -0
- package/esm/sveltekit/server/index.js +21 -0
- package/esm/ui/Clipboardable.svelte +5 -2
- package/esm/ui/Field.svelte +3 -0
- package/esm/ui/Loading.svelte +4 -1
- package/esm/ui/Tooltip.svelte +1 -1
- package/esm/ui/dialog/DialogForm.svelte +1 -1
- package/esm/ui/dialog/DialogPrimitive.svelte +0 -1
- package/esm/ui/dialog/dialog.d.ts +6 -3
- package/esm/ui/dialog/dialog.js +1 -1
- package/esm/ui/internals/FieldContainer.svelte +0 -1
- package/esm/vite/index.js +24 -25
- package/package.json +50 -38
- 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-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/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/esm/changeLog/index.d.ts
CHANGED
|
@@ -1,40 +1,4 @@
|
|
|
1
1
|
import { type FieldRef, type FieldsRef, type LifecycleEvent } from 'remult';
|
|
2
|
-
import type { Module } from '../api';
|
|
3
|
-
/**
|
|
4
|
-
* ## Default way
|
|
5
|
-
* The easiest is to switch from `@Entity` to `@FF_Entity` to the entities where you want to log changes.
|
|
6
|
-
*
|
|
7
|
-
* ```ts
|
|
8
|
-
* \@FF_Entity<User>('users', {
|
|
9
|
-
*
|
|
10
|
-
* // Optional => To disable change logs
|
|
11
|
-
* // changeLog: false,
|
|
12
|
-
*
|
|
13
|
-
* // Optional => To disable some columns from being logged
|
|
14
|
-
* // changeLog: {
|
|
15
|
-
* // excludeColumns: (e) => {
|
|
16
|
-
* // return [e.password]
|
|
17
|
-
* // },
|
|
18
|
-
* // },
|
|
19
|
-
* })
|
|
20
|
-
* export class User {}
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* ## Manual way
|
|
24
|
-
* If you want to go more manual, you can import these functions and call them in your entity's lifecycle events.
|
|
25
|
-
* ```ts
|
|
26
|
-
* \@Entity<User>('users', {
|
|
27
|
-
* saved: async (entity, e) => {
|
|
28
|
-
* await recordSaved(entity, e)
|
|
29
|
-
* },
|
|
30
|
-
* deleted: async (entity, e) => {
|
|
31
|
-
* await recordDeleted(entity, e)
|
|
32
|
-
* },
|
|
33
|
-
* })
|
|
34
|
-
* export class User {}
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export declare const changeLog: () => Module;
|
|
38
2
|
export declare class ChangeLog {
|
|
39
3
|
id: string;
|
|
40
4
|
entity: string;
|
package/esm/changeLog/index.js
CHANGED
|
@@ -4,47 +4,7 @@ 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 { Entity, Fields, getEntityRef, IdEntity, isBackend, remult, } from 'remult';
|
|
8
|
-
/**
|
|
9
|
-
* ## Default way
|
|
10
|
-
* The easiest is to switch from `@Entity` to `@FF_Entity` to the entities where you want to log changes.
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* \@FF_Entity<User>('users', {
|
|
14
|
-
*
|
|
15
|
-
* // Optional => To disable change logs
|
|
16
|
-
* // changeLog: false,
|
|
17
|
-
*
|
|
18
|
-
* // Optional => To disable some columns from being logged
|
|
19
|
-
* // changeLog: {
|
|
20
|
-
* // excludeColumns: (e) => {
|
|
21
|
-
* // return [e.password]
|
|
22
|
-
* // },
|
|
23
|
-
* // },
|
|
24
|
-
* })
|
|
25
|
-
* export class User {}
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* ## Manual way
|
|
29
|
-
* If you want to go more manual, you can import these functions and call them in your entity's lifecycle events.
|
|
30
|
-
* ```ts
|
|
31
|
-
* \@Entity<User>('users', {
|
|
32
|
-
* saved: async (entity, e) => {
|
|
33
|
-
* await recordSaved(entity, e)
|
|
34
|
-
* },
|
|
35
|
-
* deleted: async (entity, e) => {
|
|
36
|
-
* await recordDeleted(entity, e)
|
|
37
|
-
* },
|
|
38
|
-
* })
|
|
39
|
-
* export class User {}
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
export const changeLog = () => {
|
|
43
|
-
return {
|
|
44
|
-
name: 'changeLog',
|
|
45
|
-
entities: [ChangeLog],
|
|
46
|
-
};
|
|
47
|
-
};
|
|
7
|
+
import { Entity, Fields, getEntityRef, IdEntity, isBackend, remult, repo, } from 'remult';
|
|
48
8
|
let ChangeLog = class ChangeLog {
|
|
49
9
|
id = '';
|
|
50
10
|
entity = '';
|
|
@@ -120,7 +80,7 @@ export async function recordSaved(entity, e, options) {
|
|
|
120
80
|
}
|
|
121
81
|
}
|
|
122
82
|
if (changes.length > 0) {
|
|
123
|
-
await
|
|
83
|
+
await repo(ChangeLog).insert({
|
|
124
84
|
changeDate,
|
|
125
85
|
changes,
|
|
126
86
|
entity: e.metadata.key,
|
|
@@ -153,7 +113,7 @@ export async function recordDeleted(entity, e, options) {
|
|
|
153
113
|
throw err;
|
|
154
114
|
}
|
|
155
115
|
}
|
|
156
|
-
await
|
|
116
|
+
await repo(ChangeLog).insert({
|
|
157
117
|
changeDate,
|
|
158
118
|
changes,
|
|
159
119
|
entity: e.metadata.key,
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Module } from '../../api';
|
|
2
|
+
/**
|
|
3
|
+
* ## Default way
|
|
4
|
+
* The easiest is to switch from `@Entity` to `@FF_Entity` to the entities where you want to log changes.
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* \@FF_Entity<User>('users', {
|
|
8
|
+
*
|
|
9
|
+
* // Optional => To disable change logs
|
|
10
|
+
* // changeLog: false,
|
|
11
|
+
*
|
|
12
|
+
* // Optional => To disable some columns from being logged
|
|
13
|
+
* // changeLog: {
|
|
14
|
+
* // excludeColumns: (e) => {
|
|
15
|
+
* // return [e.password]
|
|
16
|
+
* // },
|
|
17
|
+
* // },
|
|
18
|
+
* })
|
|
19
|
+
* export class User {}
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* ## Manual way
|
|
23
|
+
* If you want to go more manual, you can import these functions and call them in your entity's lifecycle events.
|
|
24
|
+
* ```ts
|
|
25
|
+
* \@Entity<User>('users', {
|
|
26
|
+
* saved: async (entity, e) => {
|
|
27
|
+
* await recordSaved(entity, e)
|
|
28
|
+
* },
|
|
29
|
+
* deleted: async (entity, e) => {
|
|
30
|
+
* await recordDeleted(entity, e)
|
|
31
|
+
* },
|
|
32
|
+
* })
|
|
33
|
+
* export class User {}
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare const changeLog: () => Module;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Module } from '../../api';
|
|
2
|
+
import { ChangeLog } from '../index';
|
|
3
|
+
/**
|
|
4
|
+
* ## Default way
|
|
5
|
+
* The easiest is to switch from `@Entity` to `@FF_Entity` to the entities where you want to log changes.
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* \@FF_Entity<User>('users', {
|
|
9
|
+
*
|
|
10
|
+
* // Optional => To disable change logs
|
|
11
|
+
* // changeLog: false,
|
|
12
|
+
*
|
|
13
|
+
* // Optional => To disable some columns from being logged
|
|
14
|
+
* // changeLog: {
|
|
15
|
+
* // excludeColumns: (e) => {
|
|
16
|
+
* // return [e.password]
|
|
17
|
+
* // },
|
|
18
|
+
* // },
|
|
19
|
+
* })
|
|
20
|
+
* export class User {}
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* ## Manual way
|
|
24
|
+
* If you want to go more manual, you can import these functions and call them in your entity's lifecycle events.
|
|
25
|
+
* ```ts
|
|
26
|
+
* \@Entity<User>('users', {
|
|
27
|
+
* saved: async (entity, e) => {
|
|
28
|
+
* await recordSaved(entity, e)
|
|
29
|
+
* },
|
|
30
|
+
* deleted: async (entity, e) => {
|
|
31
|
+
* await recordDeleted(entity, e)
|
|
32
|
+
* },
|
|
33
|
+
* })
|
|
34
|
+
* export class User {}
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export const changeLog = () => {
|
|
38
|
+
return new Module({
|
|
39
|
+
name: 'changeLog',
|
|
40
|
+
entities: [ChangeLog],
|
|
41
|
+
});
|
|
42
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { CronJob } from 'cron';
|
|
2
|
+
import { green, magenta, red, yellow } from '@kitql/helpers';
|
|
3
|
+
import { Module } from '../../api';
|
|
4
|
+
export const jobs = {};
|
|
5
|
+
/**
|
|
6
|
+
* Link to a nice Cheatsheet TODO
|
|
7
|
+
*/
|
|
8
|
+
export const cronTime = {
|
|
9
|
+
/**
|
|
10
|
+
* Every morning is actually at 4 am and 7 minutes. (because I like this number!)
|
|
11
|
+
*/
|
|
12
|
+
every_morning: '0 7 4 * * *',
|
|
13
|
+
/**
|
|
14
|
+
* Every second
|
|
15
|
+
*/
|
|
16
|
+
every_second: '* * * * * *',
|
|
17
|
+
/**
|
|
18
|
+
* Every minute
|
|
19
|
+
*/
|
|
20
|
+
every_minute: '0 * * * * *',
|
|
21
|
+
/**
|
|
22
|
+
* Every 10 minute
|
|
23
|
+
*/
|
|
24
|
+
every_10_minute: '*/10 * * * *',
|
|
25
|
+
/**
|
|
26
|
+
* Every friday at 5:11 am
|
|
27
|
+
*/
|
|
28
|
+
every_friday_morning: '11 5 * * 5',
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* usage:
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { cron, cronTime } from 'firstly/cron'
|
|
35
|
+
*
|
|
36
|
+
* export const api = firstly({
|
|
37
|
+
* modules: [
|
|
38
|
+
* cron([{
|
|
39
|
+
* topic: 'first_cron',
|
|
40
|
+
* cronTime: cronTime.every_second,
|
|
41
|
+
* onTick: () => { console.log('hello') },
|
|
42
|
+
* start: !dev, // Start in production
|
|
43
|
+
* // runOnInit: dev, // nice in dev environement
|
|
44
|
+
* }])
|
|
45
|
+
* ]
|
|
46
|
+
* })
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* using [cron](https://www.npmjs.com/package/cron) library under the hood
|
|
50
|
+
*/
|
|
51
|
+
export const cron = (jobsInfos) => {
|
|
52
|
+
const m = new Module({
|
|
53
|
+
name: 'cron',
|
|
54
|
+
});
|
|
55
|
+
const logJobs = (topic, job, message, with_metadata = true, isSuccess = true) => {
|
|
56
|
+
const l = [];
|
|
57
|
+
l.push(magenta(`[${topic}]`));
|
|
58
|
+
l.push(message);
|
|
59
|
+
if (with_metadata) {
|
|
60
|
+
// If the job is "stopped", there will still be a next date, but it will not fire it. The job has to start.
|
|
61
|
+
l.push(`(${job.running ? green('running') : red('stopped')}, next at ${yellow(job.nextDate().toISO())})`);
|
|
62
|
+
}
|
|
63
|
+
if (isSuccess) {
|
|
64
|
+
m.log.success(l.join(' '));
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
m.log.info(l.join(' '));
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
m.initApi = async () => {
|
|
71
|
+
jobsInfos.forEach((infos) => {
|
|
72
|
+
const { topic, runOnInit, logs, concurrent, ...params } = infos;
|
|
73
|
+
const concurrentToUse = concurrent ?? 1;
|
|
74
|
+
const onTickSaved = params.onTick;
|
|
75
|
+
const fullOnTick = async () => {
|
|
76
|
+
if (jobs[topic].concurrentInProgress < concurrentToUse) {
|
|
77
|
+
jobs[topic].concurrentInProgress = jobs[topic].concurrentInProgress + 1;
|
|
78
|
+
if (logs?.starting === undefined || logs?.starting === true) {
|
|
79
|
+
logJobs(topic, job, 'starting...', false, false);
|
|
80
|
+
}
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
await onTickSaved();
|
|
83
|
+
if (logs?.ended === undefined || logs?.ended === true) {
|
|
84
|
+
logJobs(topic, job, 'done');
|
|
85
|
+
}
|
|
86
|
+
jobs[topic].concurrentInProgress = jobs[topic].concurrentInProgress - 1;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
logJobs(topic, job, `skipped because of concurrent limit (${yellow(concurrentToUse.toString())})`, false, false);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
params.onTick = fullOnTick;
|
|
93
|
+
const job = CronJob.from(params);
|
|
94
|
+
jobs[topic] = { job, concurrentInProgress: 0 };
|
|
95
|
+
logJobs(topic, job, 'setup done');
|
|
96
|
+
// If not it will be done too early
|
|
97
|
+
if (runOnInit) {
|
|
98
|
+
job.fireOnTick();
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
return m;
|
|
103
|
+
};
|
|
@@ -4,13 +4,13 @@ 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 { Allow, BackendMethod, remult } from 'remult';
|
|
7
|
+
import { Allow, BackendMethod, EntityError, remult } from 'remult';
|
|
8
8
|
import { stry } from '@kitql/helpers';
|
|
9
|
-
import { FEEDBACK_OPTIONS } from '
|
|
9
|
+
import { FEEDBACK_OPTIONS } from './server';
|
|
10
10
|
const GITHUB_GRAPHQL_ENDPOINT = 'https://api.github.com/graphql';
|
|
11
11
|
async function getGitHub(query, variables) {
|
|
12
12
|
if (!FEEDBACK_OPTIONS.GITHUB_API_TOKEN) {
|
|
13
|
-
throw new
|
|
13
|
+
throw new EntityError({ message: 'GITHUB_API_TOKEN not found in .env' });
|
|
14
14
|
}
|
|
15
15
|
try {
|
|
16
16
|
const headers = new Headers({
|
package/esm/feedback/index.d.ts
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
import type { Module } from '../api';
|
|
2
1
|
import { FeedbackController } from './FeedbackController';
|
|
3
2
|
import { default as Feedback } from './ui/Feedback.svelte';
|
|
4
3
|
export { FeedbackController, Feedback };
|
|
5
|
-
type FeedbackOptions = {
|
|
6
|
-
GITHUB_API_TOKEN: string;
|
|
7
|
-
repo: {
|
|
8
|
-
owner: string;
|
|
9
|
-
name: string;
|
|
10
|
-
};
|
|
11
|
-
milestones?: {
|
|
12
|
-
title_filter?: string;
|
|
13
|
-
labels_filters?: string[];
|
|
14
|
-
};
|
|
15
|
-
highlight_label?: string;
|
|
16
|
-
create_label?: string;
|
|
17
|
-
};
|
|
18
|
-
export declare let FEEDBACK_OPTIONS: FeedbackOptions;
|
|
19
|
-
export declare const feedback: (o: FeedbackOptions) => Module;
|
package/esm/feedback/index.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
1
|
import { FeedbackController } from './FeedbackController';
|
|
2
2
|
import { default as Feedback } from './ui/Feedback.svelte';
|
|
3
3
|
export { FeedbackController, Feedback };
|
|
4
|
-
export let FEEDBACK_OPTIONS = {
|
|
5
|
-
GITHUB_API_TOKEN: '',
|
|
6
|
-
repo: { owner: '', name: '' },
|
|
7
|
-
};
|
|
8
|
-
export const feedback = (o) => {
|
|
9
|
-
FEEDBACK_OPTIONS = o;
|
|
10
|
-
return {
|
|
11
|
-
name: 'feedback',
|
|
12
|
-
controllers: [FeedbackController],
|
|
13
|
-
};
|
|
14
|
-
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Module } from '../../api';
|
|
2
|
+
type FeedbackOptions = {
|
|
3
|
+
GITHUB_API_TOKEN: string;
|
|
4
|
+
repo: {
|
|
5
|
+
owner: string;
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
milestones?: {
|
|
9
|
+
title_filter?: string;
|
|
10
|
+
labels_filters?: string[];
|
|
11
|
+
};
|
|
12
|
+
highlight_label?: string;
|
|
13
|
+
create_label?: string;
|
|
14
|
+
};
|
|
15
|
+
export declare let FEEDBACK_OPTIONS: FeedbackOptions;
|
|
16
|
+
export declare const feedback: (o: FeedbackOptions) => Module;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Module } from '../../api';
|
|
2
|
+
import { FeedbackController } from '../FeedbackController';
|
|
3
|
+
export let FEEDBACK_OPTIONS = {
|
|
4
|
+
GITHUB_API_TOKEN: '',
|
|
5
|
+
repo: { owner: '', name: '' },
|
|
6
|
+
};
|
|
7
|
+
export const feedback = (o) => {
|
|
8
|
+
FEEDBACK_OPTIONS = o;
|
|
9
|
+
return new Module({
|
|
10
|
+
name: 'feedback',
|
|
11
|
+
controllers: [FeedbackController],
|
|
12
|
+
});
|
|
13
|
+
};
|
package/esm/helper.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getEntityRef, getValueList } from 'remult';
|
|
1
|
+
import { EntityError, getEntityRef, getValueList } from 'remult';
|
|
2
2
|
import { getRelationFieldInfo } from 'remult/internals';
|
|
3
3
|
import { suffixWithS } from './formats/strings.js';
|
|
4
4
|
export function isError(object) {
|
|
@@ -76,7 +76,7 @@ export const getFieldMetaType = (field) => {
|
|
|
76
76
|
kind: 'enum',
|
|
77
77
|
subKind: 'single',
|
|
78
78
|
// @ts-ignore
|
|
79
|
-
values: field.options.valueConverter.values,
|
|
79
|
+
values: field.options.valueConverter.values.filter((v) => !v.hide),
|
|
80
80
|
field,
|
|
81
81
|
};
|
|
82
82
|
}
|
|
@@ -147,7 +147,7 @@ export const onDelete = async (item, e, mode = 'prevent') => {
|
|
|
147
147
|
if (nonEmptyRelations.length > 0) {
|
|
148
148
|
if (mode === 'prevent') {
|
|
149
149
|
const relationNames = nonEmptyRelations.map((r) => r.f.caption).join(', ');
|
|
150
|
-
throw
|
|
150
|
+
throw new EntityError({ message: `Can't with existing: ${relationNames}` });
|
|
151
151
|
}
|
|
152
152
|
else if (mode === 'cascade') {
|
|
153
153
|
nonEmptyRelations.forEach(async (r) => {
|
package/esm/index.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type { RequestEvent } from '@sveltejs/kit';
|
|
2
1
|
import type { FindOptionsBase } from 'remult';
|
|
3
2
|
import { Log } from '@kitql/helpers';
|
|
4
3
|
import type { BaseEnum, BaseItem, FF_Icon } from './BaseEnum.js';
|
|
5
4
|
import type { CellsInput as CellsInput_ForExport } from './cellsBuildor.js';
|
|
6
5
|
import type { ColumnDeciderArgs } from './changeLog/index.js';
|
|
7
|
-
import { default as DefaultMail } from './mail/templates/DefaultMail.svelte';
|
|
8
6
|
import { storeItem } from './storeItem.js';
|
|
9
7
|
import { storeList } from './storeList.js';
|
|
10
8
|
import { default as Button } from './ui/Button.svelte';
|
|
@@ -23,10 +21,10 @@ import { default as Link } from './ui/link/Link.svelte';
|
|
|
23
21
|
import { default as LinkPlus } from './ui/link/LinkPlus.svelte';
|
|
24
22
|
import { default as Loading } from './ui/Loading.svelte';
|
|
25
23
|
import { default as Tooltip } from './ui/Tooltip.svelte';
|
|
26
|
-
export { Field, FormEditAction, Grid, GridPaginate, FieldGroup, Icon, Link, LinkPlus, Loading, Button, Tooltip, DialogManagement, FieldContainer, SelectMelt, Clipboardable,
|
|
24
|
+
export { Field, FormEditAction, Grid, GridPaginate, FieldGroup, Icon, Link, LinkPlus, Loading, Button, Tooltip, DialogManagement, FieldContainer, SelectMelt, Clipboardable, };
|
|
27
25
|
export declare const ff_Log: Log;
|
|
28
26
|
export declare const FF_Role: {
|
|
29
|
-
|
|
27
|
+
readonly FF_Role_Admin: "FF_Role.Admin";
|
|
30
28
|
};
|
|
31
29
|
export type { BaseEnumOptions } from './BaseEnum.js';
|
|
32
30
|
export type { BaseItem };
|
|
@@ -55,12 +53,6 @@ export { UIEntity } from './virtual/UIEntity.js';
|
|
|
55
53
|
export { LibIcon_Empty, LibIcon_Forbidden, LibIcon_ChevronDown, LibIcon_ChevronUp, LibIcon_ChevronLeft, LibIcon_ChevronRight, LibIcon_Search, LibIcon_Check, LibIcon_MultiCheck, LibIcon_Add, LibIcon_MultiAdd, LibIcon_Edit, LibIcon_Delete, LibIcon_Cross, LibIcon_Save, LibIcon_Man, LibIcon_Woman, LibIcon_Send, LibIcon_Load, LibIcon_Settings, LibIcon_Sort, LibIcon_SortAsc, LibIcon_SortDesc, } from './ui/LibIcon.js';
|
|
56
54
|
export type { FF_Icon };
|
|
57
55
|
declare module 'remult' {
|
|
58
|
-
interface RemultContext {
|
|
59
|
-
url: URL;
|
|
60
|
-
setHeaders(headers: Record<string, string>): void;
|
|
61
|
-
setCookie(...args: Parameters<RequestEvent['cookies']['set']>): void;
|
|
62
|
-
deleteCookie(...args: Parameters<RequestEvent['cookies']['delete']>): void;
|
|
63
|
-
}
|
|
64
56
|
interface FieldOptions<entityType, valueType> {
|
|
65
57
|
placeholder?: string;
|
|
66
58
|
suffix?: string;
|
|
@@ -90,10 +82,4 @@ declare module 'remult' {
|
|
|
90
82
|
permissionApiUpdate?: BaseEnum[] | BaseEnum;
|
|
91
83
|
changeLog?: false | ColumnDeciderArgs<entityType>;
|
|
92
84
|
}
|
|
93
|
-
interface UserInfo {
|
|
94
|
-
session: {
|
|
95
|
-
id: string;
|
|
96
|
-
expiresAt: Date;
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
85
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Log } from '@kitql/helpers';
|
|
2
|
-
import { default as DefaultMail } from './mail/templates/DefaultMail.svelte';
|
|
3
2
|
import { storeItem } from './storeItem.js';
|
|
4
3
|
import { storeList } from './storeList.js';
|
|
5
4
|
import { default as Button } from './ui/Button.svelte';
|
|
@@ -20,13 +19,13 @@ import { default as Tooltip } from './ui/Tooltip.svelte';
|
|
|
20
19
|
// ******************************
|
|
21
20
|
// Svelte Components
|
|
22
21
|
// ******************************
|
|
23
|
-
export { Field, FormEditAction, Grid, GridPaginate, FieldGroup, Icon, Link, LinkPlus, Loading, Button, Tooltip, DialogManagement, FieldContainer, SelectMelt, Clipboardable,
|
|
22
|
+
export { Field, FormEditAction, Grid, GridPaginate, FieldGroup, Icon, Link, LinkPlus, Loading, Button, Tooltip, DialogManagement, FieldContainer, SelectMelt, Clipboardable, };
|
|
24
23
|
// ******************************
|
|
25
24
|
// Objects
|
|
26
25
|
// ******************************
|
|
27
26
|
export const ff_Log = new Log('firstly');
|
|
28
27
|
export const FF_Role = {
|
|
29
|
-
|
|
28
|
+
FF_Role_Admin: 'FF_Role.Admin',
|
|
30
29
|
};
|
|
31
30
|
// ******************************
|
|
32
31
|
// Helpers
|
package/esm/mail/index.d.ts
CHANGED
|
@@ -1,30 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import type Mail from 'nodemailer/lib/mailer';
|
|
4
|
-
import type SendmailTransport from 'nodemailer/lib/sendmail-transport';
|
|
5
|
-
import type SESTransport from 'nodemailer/lib/ses-transport';
|
|
6
|
-
import type SMTPPool from 'nodemailer/lib/smtp-pool';
|
|
7
|
-
import type SMTPTransport from 'nodemailer/lib/smtp-transport';
|
|
8
|
-
import type StreamTransport from 'nodemailer/lib/stream-transport';
|
|
9
|
-
import type { ComponentProps, ComponentType, SvelteComponent } from 'svelte';
|
|
10
|
-
import { DefaultMail } from '../';
|
|
11
|
-
export type TransportTypes = SMTPTransport | SMTPTransport.Options | string | SMTPPool | SMTPPool.Options | SendmailTransport | SendmailTransport.Options | StreamTransport | StreamTransport.Options | JSONTransport | JSONTransport.Options | SESTransport | SESTransport.Options | typeNodemailer.Transport<any> | typeNodemailer.TransportOptions;
|
|
12
|
-
export type DefaultOptions = SMTPTransport.Options | SMTPPool.Options | SendmailTransport.Options | StreamTransport.Options | JSONTransport.Options | SESTransport.Options | typeNodemailer.TransportOptions;
|
|
13
|
-
export type MailOptions<ComponentTemplateDefault extends SvelteComponent> = {
|
|
14
|
-
from?: Mail.Options['from'];
|
|
15
|
-
template?: {
|
|
16
|
-
component?: ComponentType<ComponentTemplateDefault>;
|
|
17
|
-
brandColor?: string;
|
|
18
|
-
};
|
|
19
|
-
transport?: TransportTypes;
|
|
20
|
-
defaults?: DefaultOptions;
|
|
21
|
-
apiUrl?: Parameters<typeof typeNodemailer.createTestAccount>[0];
|
|
22
|
-
};
|
|
23
|
-
declare let transporter: ReturnType<typeof typeNodemailer.createTransport>;
|
|
24
|
-
export declare const mailInit: (nodemailer: typeof typeNodemailer, o?: MailOptions<SvelteComponent>) => void;
|
|
25
|
-
export declare const sendMail: <ComponentTemplateDefault extends SvelteComponent = DefaultMail>(
|
|
26
|
-
/** usefull for logs, it has NO impact on the mail itself */
|
|
27
|
-
topic: string, mailOptions: Parameters<typeof transporter.sendMail>[0] & {
|
|
28
|
-
templateProps?: ComponentProps<ComponentTemplateDefault> | undefined;
|
|
29
|
-
}) => ReturnType<typeof transporter.sendMail>;
|
|
30
|
-
export {};
|
|
1
|
+
import { default as DefaultMail } from './templates/DefaultMail.svelte';
|
|
2
|
+
export { DefaultMail };
|
package/esm/mail/index.js
CHANGED
|
@@ -1,79 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { DefaultMail } from '../';
|
|
4
|
-
const log = new Log('firstly | mail');
|
|
5
|
-
let nodemailerHolder;
|
|
6
|
-
let transporter;
|
|
7
|
-
let globalOptions;
|
|
8
|
-
export const mailInit = async (nodemailer, o) => {
|
|
9
|
-
nodemailerHolder = nodemailer;
|
|
10
|
-
globalOptions = o;
|
|
11
|
-
if (o?.transport) {
|
|
12
|
-
transporter = nodemailerHolder.createTransport(o?.transport, o?.defaults);
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
try {
|
|
16
|
-
nodemailer.createTestAccount(globalOptions?.apiUrl ?? '', (err, account) => {
|
|
17
|
-
if (account) {
|
|
18
|
-
globalOptions = { ...globalOptions, from: account.user };
|
|
19
|
-
transporter = nodemailer.createTransport({
|
|
20
|
-
host: account.smtp.host,
|
|
21
|
-
port: account.smtp.port,
|
|
22
|
-
secure: account.smtp.secure,
|
|
23
|
-
auth: {
|
|
24
|
-
user: account.user,
|
|
25
|
-
pass: account.pass,
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
log.error("Error nodemailer.createTestAccount() can't be done.");
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
log.error("Error nodemailer.createTestAccount() can't be done.");
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
export const sendMail = async (topic, mailOptions) => {
|
|
40
|
-
// if the transporter is not ready, wait for it! (it can happen only if nothing is set...)
|
|
41
|
-
for (let i = 0; i < 30; i++) {
|
|
42
|
-
if (transporter !== undefined) {
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
await sleep(100);
|
|
46
|
-
}
|
|
47
|
-
try {
|
|
48
|
-
if (!mailOptions.html) {
|
|
49
|
-
const template = globalOptions?.template?.component ?? DefaultMail;
|
|
50
|
-
const props = {
|
|
51
|
-
brandColor: globalOptions?.template?.brandColor ?? '#5B68DF',
|
|
52
|
-
...mailOptions.templateProps,
|
|
53
|
-
};
|
|
54
|
-
mailOptions.text = render({ template, props, options: { plainText: true, pretty: true } });
|
|
55
|
-
mailOptions.html = render({ template, props, options: { plainText: false, pretty: true } });
|
|
56
|
-
}
|
|
57
|
-
const info = await transporter.sendMail({
|
|
58
|
-
...mailOptions,
|
|
59
|
-
...{ from: mailOptions.from ?? globalOptions?.from },
|
|
60
|
-
});
|
|
61
|
-
if (!globalOptions?.transport) {
|
|
62
|
-
log.error(`${magenta(`[${topic}]`)} - ⚠️ ${red(`mail not configured`)} ⚠️
|
|
63
|
-
We are still nice and generated you an email preview link:
|
|
64
|
-
👉 ${cyan(String(nodemailerHolder.getTestMessageUrl(
|
|
65
|
-
// @ts-ignore
|
|
66
|
-
info)))}
|
|
67
|
-
|
|
68
|
-
To really send mails, check out the doc ${white(`https://firstly.fun/modules/mail`)}.
|
|
69
|
-
`);
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
log.success(`${magenta(`[${topic}]`)} - Sent to ${typeof mailOptions.to === 'string' ? green(mailOptions.to) : mailOptions.to}`);
|
|
73
|
-
}
|
|
74
|
-
return info;
|
|
75
|
-
}
|
|
76
|
-
catch (error) {
|
|
77
|
-
log.error(`${magenta(`[${topic}]`)} - Error`, error);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
1
|
+
import { default as DefaultMail } from './templates/DefaultMail.svelte';
|
|
2
|
+
export { DefaultMail };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type * as typeNodemailer from 'nodemailer';
|
|
2
|
+
import type JSONTransport from 'nodemailer/lib/json-transport';
|
|
3
|
+
import type Mail from 'nodemailer/lib/mailer';
|
|
4
|
+
import type SendmailTransport from 'nodemailer/lib/sendmail-transport';
|
|
5
|
+
import type SESTransport from 'nodemailer/lib/ses-transport';
|
|
6
|
+
import type SMTPPool from 'nodemailer/lib/smtp-pool';
|
|
7
|
+
import type SMTPTransport from 'nodemailer/lib/smtp-transport';
|
|
8
|
+
import type StreamTransport from 'nodemailer/lib/stream-transport';
|
|
9
|
+
import type { ComponentProps, ComponentType, SvelteComponent } from 'svelte';
|
|
10
|
+
import { Module } from '../../api';
|
|
11
|
+
import { default as DefaultMail } from '../templates/DefaultMail.svelte';
|
|
12
|
+
export type TransportTypes = SMTPTransport | SMTPTransport.Options | string | SMTPPool | SMTPPool.Options | SendmailTransport | SendmailTransport.Options | StreamTransport | StreamTransport.Options | JSONTransport | JSONTransport.Options | SESTransport | SESTransport.Options | typeNodemailer.Transport<any> | typeNodemailer.TransportOptions;
|
|
13
|
+
export type DefaultOptions = SMTPTransport.Options | SMTPPool.Options | SendmailTransport.Options | StreamTransport.Options | JSONTransport.Options | SESTransport.Options | typeNodemailer.TransportOptions;
|
|
14
|
+
export type MailOptions<ComponentTemplateDefault extends SvelteComponent> = {
|
|
15
|
+
from?: Mail.Options['from'];
|
|
16
|
+
template?: {
|
|
17
|
+
component?: ComponentType<ComponentTemplateDefault>;
|
|
18
|
+
brandColor?: string;
|
|
19
|
+
};
|
|
20
|
+
transport?: TransportTypes;
|
|
21
|
+
defaults?: DefaultOptions;
|
|
22
|
+
apiUrl?: Parameters<typeof typeNodemailer.createTestAccount>[0];
|
|
23
|
+
};
|
|
24
|
+
declare let transporter: ReturnType<typeof typeNodemailer.createTransport>;
|
|
25
|
+
export declare const sendMail: <ComponentTemplateDefault extends SvelteComponent = DefaultMail>(
|
|
26
|
+
/** usefull for logs, it has NO impact on the mail itself */
|
|
27
|
+
topic: string, mailOptions: Parameters<typeof transporter.sendMail>[0] & {
|
|
28
|
+
templateProps?: ComponentProps<ComponentTemplateDefault> | undefined;
|
|
29
|
+
}) => ReturnType<typeof transporter.sendMail>;
|
|
30
|
+
export declare const mail: (o?: MailOptions<SvelteComponent>) => Module;
|
|
31
|
+
export {};
|