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
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import nodemailer from 'nodemailer';
|
|
2
|
+
import { render } from 'svelty-email';
|
|
3
|
+
import { cyan, green, magenta, red, sleep, white } from '@kitql/helpers';
|
|
4
|
+
import { Module } from '../../api';
|
|
5
|
+
import { default as DefaultMail } from '../templates/DefaultMail.svelte';
|
|
6
|
+
let transporter;
|
|
7
|
+
let globalOptions;
|
|
8
|
+
const initMail = async (o) => {
|
|
9
|
+
globalOptions = o;
|
|
10
|
+
if (o?.transport) {
|
|
11
|
+
transporter = nodemailer.createTransport(o?.transport, o?.defaults);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
try {
|
|
15
|
+
nodemailer.createTestAccount(globalOptions?.apiUrl ?? '', (err, account) => {
|
|
16
|
+
if (account) {
|
|
17
|
+
globalOptions = { ...globalOptions, from: account.user };
|
|
18
|
+
transporter = nodemailer.createTransport({
|
|
19
|
+
host: account.smtp.host,
|
|
20
|
+
port: account.smtp.port,
|
|
21
|
+
secure: account.smtp.secure,
|
|
22
|
+
auth: {
|
|
23
|
+
user: account.user,
|
|
24
|
+
pass: account.pass,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
mailModule.log.error("Error nodemailer.createTestAccount() can't be done.");
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
mailModule.log.error("Error nodemailer.createTestAccount() can't be done.");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
export const sendMail = async (topic, mailOptions) => {
|
|
39
|
+
// if the transporter is not ready, wait for it! (it can happen only if nothing is set...)
|
|
40
|
+
for (let i = 0; i < 30; i++) {
|
|
41
|
+
if (transporter !== undefined) {
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
await sleep(100);
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
if (!mailOptions.html) {
|
|
48
|
+
const template = globalOptions?.template?.component ?? DefaultMail;
|
|
49
|
+
const props = {
|
|
50
|
+
brandColor: globalOptions?.template?.brandColor ?? '#5B68DF',
|
|
51
|
+
...mailOptions.templateProps,
|
|
52
|
+
};
|
|
53
|
+
mailOptions.text = render({ template, props, options: { plainText: true, pretty: true } });
|
|
54
|
+
mailOptions.html = render({ template, props, options: { plainText: false, pretty: true } });
|
|
55
|
+
}
|
|
56
|
+
const info = await transporter.sendMail({
|
|
57
|
+
...mailOptions,
|
|
58
|
+
...{ from: mailOptions.from ?? globalOptions?.from },
|
|
59
|
+
});
|
|
60
|
+
if (!globalOptions?.transport) {
|
|
61
|
+
mailModule.log.error(`${magenta(`[${topic}]`)} - ⚠️ ${red(`mail not configured`)} ⚠️
|
|
62
|
+
We are still nice and generated you an email preview link:
|
|
63
|
+
👉 ${cyan(String(nodemailer.getTestMessageUrl(
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
info)))}
|
|
66
|
+
|
|
67
|
+
To really send mails, check out the doc ${white(`https://firstly.fun/modules/mail`)}.
|
|
68
|
+
`);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
mailModule.log.success(`${magenta(`[${topic}]`)} - Sent to ${typeof mailOptions.to === 'string' ? green(mailOptions.to) : mailOptions.to}`);
|
|
72
|
+
}
|
|
73
|
+
return info;
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
mailModule.log.error(`${magenta(`[${topic}]`)} - Error`, error);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const mailModule = new Module({
|
|
80
|
+
name: 'mail',
|
|
81
|
+
priority: -778,
|
|
82
|
+
});
|
|
83
|
+
export const mail = (o) => {
|
|
84
|
+
mailModule.initApi = () => {
|
|
85
|
+
initMail(o);
|
|
86
|
+
};
|
|
87
|
+
return mailModule;
|
|
88
|
+
};
|
package/esm/storeItem.d.ts
CHANGED
|
@@ -6,7 +6,10 @@ type TheStoreItem<T> = {
|
|
|
6
6
|
globalError?: string | undefined;
|
|
7
7
|
};
|
|
8
8
|
export declare const storeItem: <T>(repo: Repository<T>, initValues?: TheStoreItem<T>) => {
|
|
9
|
-
subscribe:
|
|
9
|
+
subscribe: {
|
|
10
|
+
(this: void, run: import("svelte/store").Subscriber<TheStoreItem<T>>, invalidate?: import("svelte/store").Invalidator<TheStoreItem<T>> | undefined): import("svelte/store").Unsubscriber;
|
|
11
|
+
(this: void, run: import("svelte/store").Subscriber<TheStoreItem<T>>, invalidate?: (() => void) | undefined): import("svelte/store").Unsubscriber;
|
|
12
|
+
};
|
|
10
13
|
create: (item: Partial<T>) => void;
|
|
11
14
|
set: (newItem: TheStoreItem<T>) => void;
|
|
12
15
|
/**
|
package/esm/storeItem.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BROWSER } from 'esm-env';
|
|
2
2
|
import { derived, get, writable } from 'svelte/store';
|
|
3
|
-
import {
|
|
3
|
+
import { ff_Log } from './';
|
|
4
4
|
import { isError } from './helper';
|
|
5
5
|
export const storeItem = (repo, initValues = {
|
|
6
6
|
item: undefined,
|
|
@@ -87,6 +87,7 @@ export const storeItem = (repo, initValues = {
|
|
|
87
87
|
if (!s.item) {
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
|
+
internalStore.update((s) => ({ ...s, loading: true }));
|
|
90
91
|
const item = await repo.save(s.item);
|
|
91
92
|
internalStore.update((s) => ({
|
|
92
93
|
...s,
|
|
@@ -130,11 +131,16 @@ export const storeItem = (repo, initValues = {
|
|
|
130
131
|
delete: async () => {
|
|
131
132
|
const s = get(internalStore);
|
|
132
133
|
if (!s.item) {
|
|
133
|
-
|
|
134
|
+
ff_Log.error(`To delete an item, you need set it first.`);
|
|
134
135
|
return;
|
|
135
136
|
}
|
|
136
137
|
try {
|
|
138
|
+
internalStore.update((s) => ({ ...s, loading: true }));
|
|
137
139
|
await repo.delete(s.item);
|
|
140
|
+
internalStore.update((s) => ({
|
|
141
|
+
...s,
|
|
142
|
+
loading: false,
|
|
143
|
+
}));
|
|
138
144
|
}
|
|
139
145
|
catch (error) {
|
|
140
146
|
if (isError(error)) {
|
package/esm/storeList.d.ts
CHANGED
|
@@ -18,14 +18,17 @@ export type FF_FindOptions<T> = FindOptions<T> & {
|
|
|
18
18
|
* Example
|
|
19
19
|
* ```ts
|
|
20
20
|
* // get the repo
|
|
21
|
-
* const taskRepo =
|
|
21
|
+
* const taskRepo = repo(Task)
|
|
22
22
|
*
|
|
23
23
|
* const tasks = kitStore(taskRepo, data.tasks)
|
|
24
24
|
* $: browser && tasks.listen(data.options)
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
27
|
export declare const storeList: <T>(repo: Repository<T>, initValues?: TheStoreList<T>) => {
|
|
28
|
-
subscribe:
|
|
28
|
+
subscribe: {
|
|
29
|
+
(this: void, run: import("svelte/store").Subscriber<TheStoreList<T>>, invalidate?: import("svelte/store").Invalidator<TheStoreList<T>> | undefined): import("svelte/store").Unsubscriber;
|
|
30
|
+
(this: void, run: import("svelte/store").Subscriber<TheStoreList<T>>, invalidate?: (() => void) | undefined): import("svelte/store").Unsubscriber;
|
|
31
|
+
};
|
|
29
32
|
manualSet: (info: TheStoreList<T>) => void;
|
|
30
33
|
fetch: (options?: FF_FindOptions<T>, onNewData?: (items?: T[], totalCount?: number) => void) => Promise<void>;
|
|
31
34
|
listen: (options?: FF_FindOptions<T>) => Promise<void>;
|
package/esm/storeList.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RequestEvent } from '@sveltejs/kit';
|
|
2
|
+
import { Module } from '../../api';
|
|
3
|
+
declare module 'remult' {
|
|
4
|
+
interface RemultContext {
|
|
5
|
+
request: RequestEvent;
|
|
6
|
+
setHeaders(headers: Record<string, string>): void;
|
|
7
|
+
setCookie(...args: Parameters<RequestEvent['cookies']['set']>): void;
|
|
8
|
+
deleteCookie(...args: Parameters<RequestEvent['cookies']['delete']>): void;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export declare const sveltekit: () => Module;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { remult } from 'remult';
|
|
2
|
+
import { Module } from '../../api';
|
|
3
|
+
export const sveltekit = () => {
|
|
4
|
+
return new Module({
|
|
5
|
+
name: 'sveltekit',
|
|
6
|
+
priority: -779,
|
|
7
|
+
entities: [],
|
|
8
|
+
controllers: [],
|
|
9
|
+
initRequest: async (kitEvent, op) => {
|
|
10
|
+
remult.context.setHeaders = (headers) => {
|
|
11
|
+
kitEvent.setHeaders(headers);
|
|
12
|
+
};
|
|
13
|
+
remult.context.setCookie = (name, value, opts) => {
|
|
14
|
+
kitEvent.cookies.set(name, value, opts);
|
|
15
|
+
};
|
|
16
|
+
remult.context.deleteCookie = (name, opts) => {
|
|
17
|
+
kitEvent.cookies.delete(name, opts);
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
<script>export let value;
|
|
2
2
|
export { extraClass as class };
|
|
3
3
|
let extraClass = "";
|
|
4
|
-
function clip(_value) {
|
|
4
|
+
async function clip(_value) {
|
|
5
5
|
if (_value) {
|
|
6
|
-
|
|
6
|
+
try {
|
|
7
|
+
await navigator.clipboard.writeText(_value);
|
|
8
|
+
} catch (error) {
|
|
9
|
+
}
|
|
7
10
|
}
|
|
8
11
|
}
|
|
9
12
|
</script>
|
package/esm/ui/Field.svelte
CHANGED
|
@@ -61,6 +61,9 @@ const toInput = (_metadata, _value) => {
|
|
|
61
61
|
};
|
|
62
62
|
const fromInput = (_metadata, _value) => {
|
|
63
63
|
try {
|
|
64
|
+
if (_metadata.allowNull && _value === null) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
64
67
|
return _metadata?.valueConverter.fromInput(_value, metaType.subKind);
|
|
65
68
|
} catch (error2) {
|
|
66
69
|
console.error(`error fromInput w field '${_metadata.key}'`, error2);
|
package/esm/ui/Loading.svelte
CHANGED
|
@@ -5,7 +5,10 @@ let extraClass = "";
|
|
|
5
5
|
|
|
6
6
|
<!-- To fix one capa & cadb are on the same css -->
|
|
7
7
|
<div
|
|
8
|
-
class={tw(
|
|
8
|
+
class={tw(
|
|
9
|
+
'skeleton bg-base-content/20 flex h-4 w-full items-center justify-center rounded-lg',
|
|
10
|
+
extraClass,
|
|
11
|
+
)}
|
|
9
12
|
>
|
|
10
13
|
<slot />
|
|
11
14
|
</div>
|
package/esm/ui/Tooltip.svelte
CHANGED
|
@@ -19,7 +19,7 @@ export type DialogMetaData<entityType = any> = {
|
|
|
19
19
|
component?: new (...args: any[]) => SvelteComponent;
|
|
20
20
|
props?: any;
|
|
21
21
|
children?: any;
|
|
22
|
-
|
|
22
|
+
reThrow?: boolean;
|
|
23
23
|
wDelete?: boolean;
|
|
24
24
|
focusKey?: string;
|
|
25
25
|
topicPrefixText?: string;
|
|
@@ -33,7 +33,7 @@ export type DialogFormType<entityType> = {
|
|
|
33
33
|
cells?: CellsInput<entityType>;
|
|
34
34
|
defaults?: Partial<entityType>;
|
|
35
35
|
classes?: DialogClasses;
|
|
36
|
-
|
|
36
|
+
reThrow?: boolean;
|
|
37
37
|
wDelete?: boolean;
|
|
38
38
|
topicPrefixText?: string;
|
|
39
39
|
focusKey?: string;
|
|
@@ -50,6 +50,9 @@ export declare const dialog: {
|
|
|
50
50
|
show: (dialog: DialogMetaData) => Promise<ResultClose<any>>;
|
|
51
51
|
close: (id: number, result: ResultClose) => void;
|
|
52
52
|
closeAll: () => void;
|
|
53
|
-
subscribe:
|
|
53
|
+
subscribe: {
|
|
54
|
+
(this: void, run: import("svelte/store").Subscriber<DialogMetaDataInternal<any>[]>, invalidate?: import("svelte/store").Invalidator<DialogMetaDataInternal<any>[]> | undefined): import("svelte/store").Unsubscriber;
|
|
55
|
+
(this: void, run: import("svelte/store").Subscriber<DialogMetaDataInternal<any>[]>, invalidate?: (() => void) | undefined): import("svelte/store").Unsubscriber;
|
|
56
|
+
};
|
|
54
57
|
};
|
|
55
58
|
export {};
|
package/esm/ui/dialog/dialog.js
CHANGED
|
@@ -62,7 +62,7 @@ const createDialogManagement = () => {
|
|
|
62
62
|
cells: settings.cells ?? [],
|
|
63
63
|
defaults: settings?.defaults,
|
|
64
64
|
classes: settings?.classes,
|
|
65
|
-
|
|
65
|
+
reThrow: settings?.reThrow,
|
|
66
66
|
wDelete: settings?.wDelete,
|
|
67
67
|
focusKey: settings?.focusKey,
|
|
68
68
|
topicPrefixText,
|
package/esm/vite/index.js
CHANGED
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {} from 'vite';
|
|
2
2
|
import { kitRoutes } from 'vite-plugin-kit-routes';
|
|
3
3
|
import { stripper } from 'vite-plugin-stripper';
|
|
4
4
|
// import { Log } from '@kitql/helpers'
|
|
5
|
-
// const toRemove = ['
|
|
5
|
+
// const toRemove = ['@node-rs/argon2', '@node-rs/bcrypt']
|
|
6
6
|
// oslo needs to be in the dependencies (not devDependencies) !!
|
|
7
|
-
const toRemove = ['oslo/password', 'oslo']
|
|
7
|
+
// const toRemove = ['oslo/password', 'oslo']
|
|
8
8
|
export function firstly(options) {
|
|
9
|
-
//
|
|
10
|
-
// console.log(`toRemove`, toRemove)
|
|
9
|
+
// @ts-ignore
|
|
11
10
|
return [
|
|
12
|
-
{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
},
|
|
11
|
+
// {
|
|
12
|
+
// name: 'vite-plugin-firstly',
|
|
13
|
+
// enforce: 'pre',
|
|
14
|
+
// config: async (a) => {
|
|
15
|
+
// return mergeConfig(a, {
|
|
16
|
+
// build: {
|
|
17
|
+
// // THE ERROR:
|
|
18
|
+
// // RollupError: Unexpected character '�' or Unexpected character '\u{7f}'
|
|
19
|
+
// // This code (A) is to fix in `build` mode
|
|
20
|
+
// rollupOptions: {
|
|
21
|
+
// external: toRemove,
|
|
22
|
+
// },
|
|
23
|
+
// },
|
|
24
|
+
// // This code (B) is to fix in `dev` mode
|
|
25
|
+
// optimizeDeps: {
|
|
26
|
+
// exclude: toRemove,
|
|
27
|
+
// },
|
|
28
|
+
// })
|
|
29
|
+
// },
|
|
30
|
+
// },
|
|
32
31
|
// @ts-ignore
|
|
33
32
|
...kitRoutes({
|
|
34
33
|
...(options?.kitRoutes ?? {}),
|
package/package.json
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "firstly",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Firstly, an opinionated Remult setup!",
|
|
6
|
+
"funding": "https://github.com/sponsors/jycouet",
|
|
7
|
+
"homepage": "https://firstly.fun/",
|
|
6
8
|
"repository": {
|
|
7
9
|
"type": "git",
|
|
8
10
|
"url": "https://github.com/jycouet/firstly",
|
|
@@ -14,46 +16,44 @@
|
|
|
14
16
|
},
|
|
15
17
|
"peerDependencies": {
|
|
16
18
|
"@sveltejs/kit": ">=1.0.0 <3.0.0",
|
|
17
|
-
"remult": "2.7.
|
|
19
|
+
"remult": "2.7.29",
|
|
18
20
|
"svelte": ">=4.2.18"
|
|
19
21
|
},
|
|
20
22
|
"dependencies": {
|
|
21
|
-
"@clack/prompts": "
|
|
23
|
+
"@clack/prompts": "0.7.0",
|
|
22
24
|
"@kitql/internals": "0.9.9",
|
|
23
|
-
"@mdi/js": "
|
|
24
|
-
"@melt-ui/svelte": "
|
|
25
|
-
"@
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"vite
|
|
25
|
+
"@mdi/js": "7.4.47",
|
|
26
|
+
"@melt-ui/svelte": "0.86.3",
|
|
27
|
+
"@oslojs/crypto": "1.0.1",
|
|
28
|
+
"@oslojs/encoding": "1.1.0",
|
|
29
|
+
"@oslojs/otp": "1.1.0",
|
|
30
|
+
"@types/nodemailer": "6.4.14",
|
|
31
|
+
"arctic": "3.5.0",
|
|
32
|
+
"bcrypt": "5.1.1",
|
|
33
|
+
"clsx": "2.1.1",
|
|
34
|
+
"cron": "3.1.7",
|
|
35
|
+
"daisyui": "4.12.14",
|
|
36
|
+
"esm-env": "1.0.0",
|
|
37
|
+
"nodemailer": "6.9.14",
|
|
38
|
+
"svelty-email": "0.0.11",
|
|
39
|
+
"tailwind-merge": "2.3.0",
|
|
40
|
+
"tailwindcss": "3.4.4",
|
|
41
|
+
"vite": "5.4.1",
|
|
42
|
+
"vite-plugin-kit-routes": "0.8.3",
|
|
43
|
+
"vite-plugin-stripper": "0.5.4"
|
|
40
44
|
},
|
|
41
45
|
"sideEffects": false,
|
|
42
46
|
"bin": "./esm/bin/cmd.js",
|
|
43
47
|
"exports": {
|
|
44
48
|
".": {
|
|
45
49
|
"types": "./esm/index.d.ts",
|
|
46
|
-
"
|
|
47
|
-
"
|
|
50
|
+
"svelte": "./esm/index.js",
|
|
51
|
+
"default": "./esm/index.js"
|
|
48
52
|
},
|
|
49
53
|
"./api": {
|
|
50
54
|
"types": "./esm/api/index.d.ts",
|
|
51
55
|
"default": "./esm/api/index.js"
|
|
52
56
|
},
|
|
53
|
-
"./handle": {
|
|
54
|
-
"types": "./esm/handle/index.d.ts",
|
|
55
|
-
"default": "./esm/handle/index.js"
|
|
56
|
-
},
|
|
57
57
|
"./vite": {
|
|
58
58
|
"types": "./esm/vite/index.d.ts",
|
|
59
59
|
"default": "./esm/vite/index.js"
|
|
@@ -69,29 +69,41 @@
|
|
|
69
69
|
"types": "./esm/auth/index.d.ts",
|
|
70
70
|
"default": "./esm/auth/index.js"
|
|
71
71
|
},
|
|
72
|
-
"./auth/
|
|
73
|
-
"types": "./esm/auth/
|
|
74
|
-
"default": "./esm/auth/
|
|
72
|
+
"./auth/server": {
|
|
73
|
+
"types": "./esm/auth/server/index.d.ts",
|
|
74
|
+
"default": "./esm/auth/server/index.js"
|
|
75
|
+
},
|
|
76
|
+
"./changeLog": {
|
|
77
|
+
"types": "./esm/changeLog/index.d.ts",
|
|
78
|
+
"default": "./esm/changeLog/index.js"
|
|
79
|
+
},
|
|
80
|
+
"./changeLog/server": {
|
|
81
|
+
"types": "./esm/changeLog/server/index.d.ts",
|
|
82
|
+
"default": "./esm/changeLog/server/index.js"
|
|
75
83
|
},
|
|
76
|
-
"./
|
|
77
|
-
"types": "./esm/
|
|
78
|
-
"default": "./esm/
|
|
84
|
+
"./cron/server": {
|
|
85
|
+
"types": "./esm/cron/server/index.d.ts",
|
|
86
|
+
"default": "./esm/cron/server/index.js"
|
|
79
87
|
},
|
|
80
88
|
"./feedback": {
|
|
81
89
|
"types": "./esm/feedback/index.d.ts",
|
|
82
90
|
"default": "./esm/feedback/index.js"
|
|
83
91
|
},
|
|
84
|
-
"./
|
|
85
|
-
"types": "./esm/
|
|
86
|
-
"default": "./esm/
|
|
92
|
+
"./feedback/server": {
|
|
93
|
+
"types": "./esm/feedback/server/index.d.ts",
|
|
94
|
+
"default": "./esm/feedback/server/index.js"
|
|
87
95
|
},
|
|
88
96
|
"./mail": {
|
|
89
97
|
"types": "./esm/mail/index.d.ts",
|
|
90
98
|
"default": "./esm/mail/index.js"
|
|
91
99
|
},
|
|
92
|
-
"./
|
|
93
|
-
"types": "./esm/
|
|
94
|
-
"default": "./esm/
|
|
100
|
+
"./mail/server": {
|
|
101
|
+
"types": "./esm/mail/server/index.d.ts",
|
|
102
|
+
"default": "./esm/mail/server/index.js"
|
|
103
|
+
},
|
|
104
|
+
"./sveltekit/server": {
|
|
105
|
+
"types": "./esm/sveltekit/server/index.d.ts",
|
|
106
|
+
"default": "./esm/sveltekit/server/index.js"
|
|
95
107
|
}
|
|
96
108
|
},
|
|
97
109
|
"keywords": [
|
package/esm/auth/Adapter.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Adapter, DatabaseSession, DatabaseUser } from 'lucia';
|
|
2
|
-
export declare class RemultLuciaAdapter implements Adapter {
|
|
3
|
-
getSessionAndUser(sessionId: string): Promise<[session: DatabaseSession | null, user: DatabaseUser | null]>;
|
|
4
|
-
getUserSessions(userId: string): Promise<DatabaseSession[]>;
|
|
5
|
-
setSession(session: DatabaseSession): Promise<void>;
|
|
6
|
-
updateSessionExpiration(sessionId: string, expiresAt: Date): Promise<void>;
|
|
7
|
-
deleteSession(sessionId: string): Promise<void>;
|
|
8
|
-
deleteUserSessions(userId: string): Promise<void>;
|
|
9
|
-
deleteExpiredSessions(): Promise<void>;
|
|
10
|
-
}
|
package/esm/auth/Adapter.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { remult } from 'remult';
|
|
2
|
-
import { getSafeOptions } from './index.js';
|
|
3
|
-
export class RemultLuciaAdapter {
|
|
4
|
-
async getSessionAndUser(sessionId) {
|
|
5
|
-
const oSafe = getSafeOptions();
|
|
6
|
-
const session = await remult.repo(oSafe.Session).findId(sessionId);
|
|
7
|
-
if (session) {
|
|
8
|
-
const user = await remult.repo(oSafe.User).findId(session.userId);
|
|
9
|
-
if (user) {
|
|
10
|
-
return [
|
|
11
|
-
{ ...session, attributes: {} },
|
|
12
|
-
{ ...user, attributes: oSafe.transformDbUserToClientUser(session, user) },
|
|
13
|
-
];
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return [null, null];
|
|
17
|
-
}
|
|
18
|
-
async getUserSessions(userId) {
|
|
19
|
-
const oSafe = getSafeOptions();
|
|
20
|
-
return (await remult.repo(oSafe.Session).find({ where: { userId } })).map((s) => {
|
|
21
|
-
return { ...s, attributes: {} };
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
async setSession(session) {
|
|
25
|
-
const oSafe = getSafeOptions();
|
|
26
|
-
await remult.repo(oSafe.Session).insert(session);
|
|
27
|
-
}
|
|
28
|
-
async updateSessionExpiration(sessionId, expiresAt) {
|
|
29
|
-
const oSafe = getSafeOptions();
|
|
30
|
-
await remult.repo(oSafe.Session).update(sessionId, { expiresAt });
|
|
31
|
-
}
|
|
32
|
-
async deleteSession(sessionId) {
|
|
33
|
-
const oSafe = getSafeOptions();
|
|
34
|
-
await remult.repo(oSafe.Session).delete(sessionId);
|
|
35
|
-
}
|
|
36
|
-
async deleteUserSessions(userId) {
|
|
37
|
-
const oSafe = getSafeOptions();
|
|
38
|
-
const all = await remult.repo(oSafe.Session).find({ where: { userId } });
|
|
39
|
-
for (const s of all) {
|
|
40
|
-
await remult.repo(oSafe.Session).delete(s);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
async deleteExpiredSessions() {
|
|
44
|
-
const oSafe = getSafeOptions();
|
|
45
|
-
const all = await remult.repo(oSafe.Session).find({ where: { expiresAt: { $lt: new Date() } } });
|
|
46
|
-
for (const s of all) {
|
|
47
|
-
await remult.repo(oSafe.Session).delete(s);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Log } from '@kitql/helpers';
|
|
2
|
-
import { Auth } from './Auth';
|
|
3
|
-
import { FFAuthAccount, FFAuthProvider, FFAuthUser, FFAuthUserSession } from './Entities';
|
|
4
|
-
export declare const logAuth: Log;
|
|
5
|
-
export { FF_Role_Auth } from './Entities';
|
|
6
|
-
export { Auth };
|
|
7
|
-
export { FFAuthUser, FFAuthAccount, FFAuthProvider, FFAuthUserSession };
|
package/esm/auth/client/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Log } from '@kitql/helpers';
|
|
2
|
-
import { Auth } from './Auth';
|
|
3
|
-
import { FFAuthAccount, FFAuthProvider, FFAuthUser, FFAuthUserSession } from './Entities';
|
|
4
|
-
export const logAuth = new Log('firstly | auth');
|
|
5
|
-
export { FF_Role_Auth } from './Entities';
|
|
6
|
-
export { Auth };
|
|
7
|
-
export { FFAuthUser, FFAuthAccount, FFAuthProvider, FFAuthUserSession };
|
package/esm/auth/helper.d.ts
DELETED
package/esm/auth/helper.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { remult } from 'remult';
|
|
2
|
-
import { lucia } from '.';
|
|
3
|
-
/**
|
|
4
|
-
* Create or extend a session for a user.
|
|
5
|
-
* If you pass a session, it will extend it.
|
|
6
|
-
*/
|
|
7
|
-
export async function createOrExtendSession(userId, session) {
|
|
8
|
-
const sessionToUser = session ? session : await lucia.createSession(userId, {});
|
|
9
|
-
const sessionCookie = lucia.createSessionCookie(sessionToUser.id);
|
|
10
|
-
remult.context.setCookie(sessionCookie.name, sessionCookie.value, {
|
|
11
|
-
path: '/',
|
|
12
|
-
...sessionCookie.attributes,
|
|
13
|
-
});
|
|
14
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Strava } from 'arctic';
|
|
2
|
-
import { type FFOAuth2Provider } from '../';
|
|
3
|
-
/**
|
|
4
|
-
* ## Strava OAuth2 provider
|
|
5
|
-
*
|
|
6
|
-
* 1. Get your **id** & **secret** from [Strava (direct link)](https://www.strava.com/settings/api).
|
|
7
|
-
* 2. In Strava, set your callback url to
|
|
8
|
-
* - [ ] dev: `http://localhost:5173/api/auth_callback`
|
|
9
|
-
* - [ ] prod: `https://MY_SUPER_SITE/api/auth_callback`
|
|
10
|
-
* 3. In your project add a `.env` file with the following:
|
|
11
|
-
* ```bash
|
|
12
|
-
* STRAVA_CLIENT_ID = 'your-client-id'
|
|
13
|
-
* STRAVA_CLIENT_SECRET = 'your-client-secret'
|
|
14
|
-
* # STRAVA_REDIRECT_URI = '' # optional, will default to "${origin}/api/auth_callback"
|
|
15
|
-
* ```
|
|
16
|
-
* 4. In your frontend, under a button click call something like:
|
|
17
|
-
* ```ts
|
|
18
|
-
* async function oauth() {
|
|
19
|
-
* window.location.href = await Auth.signInOAuthGetUrl({ provider: 'strava', redirect: window.location.pathname })
|
|
20
|
-
* }
|
|
21
|
-
* ```
|
|
22
|
-
* 5. Enjoy 🥳
|
|
23
|
-
*/
|
|
24
|
-
export declare function strava(options?: {
|
|
25
|
-
STRAVA_CLIENT_ID?: string;
|
|
26
|
-
STRAVA_CLIENT_SECRET?: string;
|
|
27
|
-
STRAVA_REDIRECT_URI?: string;
|
|
28
|
-
authorizationURLOptions?: ReturnType<FFOAuth2Provider<'strava', Strava>['authorizationURLOptions']>;
|
|
29
|
-
log?: boolean;
|
|
30
|
-
}): FFOAuth2Provider<'strava', Strava>;
|