firstly 0.0.5 → 0.0.6
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/ROUTES.d.ts +3 -1
- package/esm/ROUTES.js +1 -0
- package/esm/api/index.d.ts +1 -1
- package/esm/auth/AuthController.server.js +50 -9
- package/esm/auth/index.d.ts +4 -7
- package/esm/auth/index.js +39 -34
- package/esm/auth/static/assets/Page-BGTO8LC5.css +1 -0
- package/esm/auth/static/assets/Page-DBWJjlEQ.d.ts +4 -0
- package/esm/auth/static/assets/Page-DBWJjlEQ.js +1 -0
- package/esm/auth/static/assets/Page-RIbXHuZG.d.ts +4 -0
- package/esm/auth/static/assets/Page-RIbXHuZG.js +1 -0
- package/esm/auth/static/assets/Page-apb_xgZT.d.ts +6 -0
- package/esm/auth/static/assets/Page-apb_xgZT.js +18 -0
- package/esm/auth/static/assets/{index-R27C_TlP.css → index-CR_3yNaJ.css} +1 -1
- package/esm/auth/static/assets/index-qfq98Nyd.d.ts +63 -0
- package/esm/auth/static/assets/index-qfq98Nyd.js +2 -0
- package/esm/auth/static/index.html +2 -2
- package/esm/auth/types.d.ts +16 -22
- package/esm/cellsBuildor.js +2 -2
- package/esm/index.d.ts +3 -2
- package/esm/index.js +2 -1
- package/esm/mail/index.d.ts +23 -4
- package/esm/mail/index.js +38 -15
- package/esm/mail/templates/DefaultMail.svelte +66 -0
- package/esm/mail/templates/DefaultMail.svelte.d.ts +28 -0
- package/esm/utils/types.d.ts +3 -0
- package/package.json +2 -1
- package/esm/auth/static/assets/Page-BYzkK4q3.d.ts +0 -5
- package/esm/auth/static/assets/Page-BYzkK4q3.js +0 -1
- package/esm/auth/static/assets/Page-ByIhtXVt.d.ts +0 -5
- package/esm/auth/static/assets/Page-ByIhtXVt.js +0 -8190
- package/esm/auth/static/assets/Page-Do7F0Mzd.d.ts +0 -5
- package/esm/auth/static/assets/Page-Do7F0Mzd.js +0 -1
- package/esm/auth/static/assets/Page-gV58jf2r.css +0 -1
- package/esm/auth/static/assets/index-czJ1PA1n.d.ts +0 -53
- package/esm/auth/static/assets/index-czJ1PA1n.js +0 -2
package/esm/mail/index.d.ts
CHANGED
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
import type * as typeNodemailer from 'nodemailer';
|
|
2
|
+
import type JSONTransport from 'nodemailer/lib/json-transport';
|
|
2
3
|
import type Mail from 'nodemailer/lib/mailer';
|
|
3
|
-
|
|
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> = {
|
|
4
14
|
from?: Mail.Options['from'];
|
|
5
|
-
|
|
15
|
+
template?: {
|
|
16
|
+
component?: ComponentType<ComponentTemplateDefault>;
|
|
17
|
+
brandColor?: string;
|
|
18
|
+
};
|
|
19
|
+
transport?: TransportTypes;
|
|
20
|
+
defaults?: DefaultOptions;
|
|
6
21
|
apiUrl?: Parameters<typeof typeNodemailer.createTestAccount>[0];
|
|
7
22
|
};
|
|
8
23
|
declare let transporter: ReturnType<typeof typeNodemailer.createTransport>;
|
|
9
|
-
export declare const mailInit: (nodemailer: typeof typeNodemailer, o?: MailOptions) => void;
|
|
10
|
-
export declare const sendMail:
|
|
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>;
|
|
11
30
|
export {};
|
package/esm/mail/index.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { render } from 'svelte-email';
|
|
2
|
+
import { cyan, green, Log, magenta, red, sleep, white } from '@kitql/helpers';
|
|
3
|
+
import { DefaultMail } from '../';
|
|
4
|
+
const log = new Log('firstly | mail');
|
|
5
|
+
let nodemailerHolder;
|
|
2
6
|
let transporter;
|
|
3
|
-
let
|
|
4
|
-
export const mailInit = (nodemailer, o) => {
|
|
5
|
-
|
|
7
|
+
let globalOptions;
|
|
8
|
+
export const mailInit = async (nodemailer, o) => {
|
|
9
|
+
nodemailerHolder = nodemailer;
|
|
10
|
+
globalOptions = o;
|
|
6
11
|
if (o?.transport) {
|
|
7
|
-
transporter =
|
|
12
|
+
transporter = nodemailerHolder.createTransport(o?.transport, o?.defaults);
|
|
8
13
|
}
|
|
9
14
|
else {
|
|
10
|
-
nodemailerHolder = nodemailer;
|
|
11
15
|
try {
|
|
12
|
-
nodemailer.createTestAccount(
|
|
13
|
-
|
|
16
|
+
nodemailer.createTestAccount(globalOptions?.apiUrl ?? '', (err, account) => {
|
|
17
|
+
globalOptions = { ...globalOptions, from: account.user };
|
|
14
18
|
transporter = nodemailer.createTransport({
|
|
15
19
|
host: account.smtp.host,
|
|
16
20
|
port: account.smtp.port,
|
|
@@ -27,21 +31,40 @@ export const mailInit = (nodemailer, o) => {
|
|
|
27
31
|
}
|
|
28
32
|
}
|
|
29
33
|
};
|
|
30
|
-
const log = new Log('firstly | mail');
|
|
31
|
-
let nodemailerHolder;
|
|
32
34
|
export const sendMail = async (topic, mailOptions) => {
|
|
35
|
+
// if the transporter is not ready, wait for it! (it can happen only if nothing is set...)
|
|
36
|
+
for (let i = 0; i < 30; i++) {
|
|
37
|
+
if (transporter !== undefined) {
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
await sleep(100);
|
|
41
|
+
}
|
|
33
42
|
try {
|
|
43
|
+
if (!mailOptions.html) {
|
|
44
|
+
const template = globalOptions?.template?.component ?? DefaultMail;
|
|
45
|
+
const props = {
|
|
46
|
+
brandColor: globalOptions?.template?.brandColor ?? '#5B68DF',
|
|
47
|
+
...mailOptions.templateProps,
|
|
48
|
+
};
|
|
49
|
+
mailOptions.text = render({ template, props, options: { plainText: true, pretty: true } });
|
|
50
|
+
mailOptions.html = render({ template, props, options: { plainText: false, pretty: true } });
|
|
51
|
+
}
|
|
34
52
|
const info = await transporter.sendMail({
|
|
35
53
|
...mailOptions,
|
|
36
|
-
...{ from: mailOptions.from ??
|
|
54
|
+
...{ from: mailOptions.from ?? globalOptions?.from },
|
|
37
55
|
});
|
|
38
|
-
if (!
|
|
39
|
-
log.
|
|
56
|
+
if (!globalOptions?.transport) {
|
|
57
|
+
log.error(`${magenta(`[${topic}]`)} - ⚠️ ${red(`mail not configured`)} ⚠️
|
|
58
|
+
We are still nice and generated you an email preview link:
|
|
59
|
+
👉 ${cyan(String(nodemailerHolder.getTestMessageUrl(
|
|
40
60
|
// @ts-ignore
|
|
41
|
-
|
|
61
|
+
info)))}
|
|
62
|
+
|
|
63
|
+
To really send mails, check out the doc ${white(`https://firstly.fun/modules/mail`)}.
|
|
64
|
+
`);
|
|
42
65
|
}
|
|
43
66
|
else {
|
|
44
|
-
log.success(`${magenta(`[${topic}]`)} - Sent to ${mailOptions.to}`);
|
|
67
|
+
log.success(`${magenta(`[${topic}]`)} - Sent to ${typeof mailOptions.to === 'string' ? green(mailOptions.to) : mailOptions.to}`);
|
|
45
68
|
}
|
|
46
69
|
return info;
|
|
47
70
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<script>import { Button, Container, Head, Heading, Html, Preview, Section, Text } from "svelte-email";
|
|
2
|
+
export let previewText;
|
|
3
|
+
export let title;
|
|
4
|
+
export let sections = [];
|
|
5
|
+
export let brandColor = "#5B68DF";
|
|
6
|
+
const fontFamily = '-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif';
|
|
7
|
+
const main = {
|
|
8
|
+
backgroundColor: "#ffffff"
|
|
9
|
+
};
|
|
10
|
+
const container = {
|
|
11
|
+
margin: "0 auto",
|
|
12
|
+
padding: "20px 0 48px",
|
|
13
|
+
width: "580px"
|
|
14
|
+
};
|
|
15
|
+
const heading = {
|
|
16
|
+
fontFamily,
|
|
17
|
+
fontSize: "32px",
|
|
18
|
+
lineHeight: "1.3",
|
|
19
|
+
fontWeight: "700",
|
|
20
|
+
color: "#484848"
|
|
21
|
+
};
|
|
22
|
+
const paragraph = {
|
|
23
|
+
fontFamily,
|
|
24
|
+
fontSize: "18px",
|
|
25
|
+
lineHeight: "1.4",
|
|
26
|
+
color: "#484848"
|
|
27
|
+
};
|
|
28
|
+
const highlighted = {
|
|
29
|
+
...paragraph,
|
|
30
|
+
padding: "24px",
|
|
31
|
+
backgroundColor: "#f2f3f3",
|
|
32
|
+
borderRadius: "4px"
|
|
33
|
+
};
|
|
34
|
+
const button = {
|
|
35
|
+
fontFamily,
|
|
36
|
+
backgroundColor: brandColor,
|
|
37
|
+
borderRadius: "5px",
|
|
38
|
+
color: "#fff",
|
|
39
|
+
fontSize: "18px",
|
|
40
|
+
textDecoration: "none",
|
|
41
|
+
textAlign: "center",
|
|
42
|
+
display: "block",
|
|
43
|
+
width: "100%"
|
|
44
|
+
};
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<Html>
|
|
48
|
+
<Head />
|
|
49
|
+
<Preview preview={previewText ?? title + '...'} />
|
|
50
|
+
<Section style={main}>
|
|
51
|
+
<Container style={container}>
|
|
52
|
+
{#if title}
|
|
53
|
+
<Heading style={heading}>{title}</Heading>
|
|
54
|
+
{/if}
|
|
55
|
+
|
|
56
|
+
{#each sections as s}
|
|
57
|
+
<Text style={s.highlighted ? highlighted : paragraph}>
|
|
58
|
+
{s.text}
|
|
59
|
+
</Text>
|
|
60
|
+
{#if s.cta}
|
|
61
|
+
<Button pY={19} style={button} href={s.cta.link}>{s.cta.text}</Button>
|
|
62
|
+
{/if}
|
|
63
|
+
{/each}
|
|
64
|
+
</Container>
|
|
65
|
+
</Section>
|
|
66
|
+
</Html>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
previewText: string | undefined;
|
|
5
|
+
title: string | undefined;
|
|
6
|
+
sections?: {
|
|
7
|
+
text: string;
|
|
8
|
+
highlighted?: boolean | undefined;
|
|
9
|
+
cta?: {
|
|
10
|
+
text: string;
|
|
11
|
+
link: string;
|
|
12
|
+
} | undefined;
|
|
13
|
+
}[] | undefined;
|
|
14
|
+
brandColor?: string | undefined;
|
|
15
|
+
};
|
|
16
|
+
events: {
|
|
17
|
+
[evt: string]: CustomEvent<any>;
|
|
18
|
+
};
|
|
19
|
+
slots: {};
|
|
20
|
+
exports?: {} | undefined;
|
|
21
|
+
bindings?: string | undefined;
|
|
22
|
+
};
|
|
23
|
+
export type DefaultMailProps = typeof __propDef.props;
|
|
24
|
+
export type DefaultMailEvents = typeof __propDef.events;
|
|
25
|
+
export type DefaultMailSlots = typeof __propDef.slots;
|
|
26
|
+
export default class DefaultMail extends SvelteComponent<DefaultMailProps, DefaultMailEvents, DefaultMailSlots> {
|
|
27
|
+
}
|
|
28
|
+
export {};
|
package/esm/utils/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "firstly",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Firstly, an opinionated Remult setup!",
|
|
6
6
|
"repository": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"lucia": "^3.2.0",
|
|
32
32
|
"nodemailer": "^6.9.13",
|
|
33
33
|
"oslo": "^1.2.0",
|
|
34
|
+
"svelte-email": "^0.0.4",
|
|
34
35
|
"tailwind-merge": "^2.3.0",
|
|
35
36
|
"tailwindcss": "^3.4.3",
|
|
36
37
|
"vite": "^5.4.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{S as o,b as r,a as i,H as l,d as c,n as a,k as f}from"./index-czJ1PA1n.js";function m(s){let t;return{c(){t=l("Hello from admin")},m(e,n){c(e,t,n)},p:a,i:a,o:a,d(e){e&&f(t)}}}class d extends o{constructor(t){super(),r(this,t,null,m,i,{})}}export{d as default};
|