firstly 0.0.4 → 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.
Files changed (88) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/esm/{KitBaseEnum.d.ts → BaseEnum.d.ts} +18 -9
  3. package/esm/{KitBaseEnum.js → BaseEnum.js} +2 -13
  4. package/esm/{KitEntity.d.ts → FF_Entity.d.ts} +1 -1
  5. package/esm/{KitEntity.js → FF_Entity.js} +9 -9
  6. package/esm/{KitFields.d.ts → FF_Fields.d.ts} +2 -3
  7. package/esm/{KitFields.js → FF_Fields.js} +13 -9
  8. package/esm/ROUTES.d.ts +3 -1
  9. package/esm/ROUTES.js +2 -1
  10. package/esm/SqlDatabase/FF_LogToConsole.d.ts +1 -0
  11. package/esm/SqlDatabase/{LogToConsoleCustom.js → FF_LogToConsole.js} +1 -1
  12. package/esm/api/index.d.ts +2 -1
  13. package/esm/auth/AuthController.server.js +59 -18
  14. package/esm/auth/Entities.d.ts +18 -17
  15. package/esm/auth/Entities.js +66 -63
  16. package/esm/auth/RoleHelpers.d.ts +2 -2
  17. package/esm/auth/RoleHelpers.js +1 -1
  18. package/esm/auth/client/Auth.js +1 -1
  19. package/esm/auth/index.d.ts +14 -17
  20. package/esm/auth/index.js +59 -52
  21. package/esm/auth/providers/github.d.ts +22 -17
  22. package/esm/auth/providers/github.js +29 -15
  23. package/esm/auth/providers/strava.d.ts +22 -17
  24. package/esm/auth/providers/strava.js +23 -15
  25. package/esm/auth/static/assets/Page-BGTO8LC5.css +1 -0
  26. package/esm/auth/static/assets/Page-DBWJjlEQ.d.ts +4 -0
  27. package/esm/auth/static/assets/Page-DBWJjlEQ.js +1 -0
  28. package/esm/auth/static/assets/Page-RIbXHuZG.d.ts +4 -0
  29. package/esm/auth/static/assets/Page-RIbXHuZG.js +1 -0
  30. package/esm/auth/static/assets/Page-apb_xgZT.d.ts +6 -0
  31. package/esm/auth/static/assets/Page-apb_xgZT.js +18 -0
  32. package/esm/auth/static/assets/{index-R27C_TlP.css → index-CR_3yNaJ.css} +1 -1
  33. package/esm/auth/static/assets/index-qfq98Nyd.d.ts +63 -0
  34. package/esm/auth/static/assets/index-qfq98Nyd.js +2 -0
  35. package/esm/auth/static/index.html +2 -2
  36. package/esm/auth/types.d.ts +16 -22
  37. package/esm/bin/cmd.js +181 -83
  38. package/esm/{kitCellsBuildor.d.ts → cellsBuildor.d.ts} +9 -9
  39. package/esm/{kitCellsBuildor.js → cellsBuildor.js} +9 -9
  40. package/esm/feedback/ui/DialogIssue.svelte +2 -2
  41. package/esm/formats/dates.js +2 -2
  42. package/esm/handle/index.d.ts +1 -0
  43. package/esm/helper.d.ts +8 -10
  44. package/esm/helper.js +13 -8
  45. package/esm/index.d.ts +38 -49
  46. package/esm/index.js +30 -27
  47. package/esm/mail/index.d.ts +23 -4
  48. package/esm/mail/index.js +38 -15
  49. package/esm/mail/templates/DefaultMail.svelte +66 -0
  50. package/esm/mail/templates/DefaultMail.svelte.d.ts +28 -0
  51. package/esm/{kitStoreItem.d.ts → storeItem.d.ts} +1 -1
  52. package/esm/{kitStoreItem.js → storeItem.js} +1 -1
  53. package/esm/{kitStoreList.d.ts → storeList.d.ts} +4 -4
  54. package/esm/{kitStoreList.js → storeList.js} +1 -1
  55. package/esm/ui/Button.svelte +1 -1
  56. package/esm/ui/Button.svelte.d.ts +2 -2
  57. package/esm/ui/Field.svelte.d.ts +2 -2
  58. package/esm/ui/FieldGroup.svelte +2 -2
  59. package/esm/ui/FieldGroup.svelte.d.ts +4 -4
  60. package/esm/ui/Grid.svelte.d.ts +5 -5
  61. package/esm/ui/dialog/DialogForm.svelte +4 -4
  62. package/esm/ui/dialog/DialogPrimitive.svelte.d.ts +2 -2
  63. package/esm/ui/dialog/FormEditAction.svelte.d.ts +2 -2
  64. package/esm/ui/dialog/dialog.d.ts +5 -5
  65. package/esm/ui/index.d.ts +2 -2
  66. package/esm/ui/internals/select/MultiSelectMelt.svelte.d.ts +3 -3
  67. package/esm/ui/internals/select/SelectMelt.svelte.d.ts +3 -3
  68. package/esm/ui/internals/select/SelectRadio.svelte.d.ts +2 -2
  69. package/esm/ui/link/LinkPlus.svelte.d.ts +2 -2
  70. package/esm/utils/types.d.ts +3 -15
  71. package/esm/utils/types.js +1 -17
  72. package/esm/virtual/Customer.js +2 -2
  73. package/esm/virtual/FilterEntity.js +1 -1
  74. package/esm/virtual/StateDemoEnum.d.ts +4 -4
  75. package/esm/virtual/StateDemoEnum.js +2 -2
  76. package/esm/virtual/UIEntity.js +4 -4
  77. package/esm/vite/index.js +1 -1
  78. package/package.json +5 -3
  79. package/esm/SqlDatabase/LogToConsoleCustom.d.ts +0 -1
  80. package/esm/auth/static/assets/Page-BYzkK4q3.d.ts +0 -5
  81. package/esm/auth/static/assets/Page-BYzkK4q3.js +0 -1
  82. package/esm/auth/static/assets/Page-ByIhtXVt.d.ts +0 -5
  83. package/esm/auth/static/assets/Page-ByIhtXVt.js +0 -18
  84. package/esm/auth/static/assets/Page-Do7F0Mzd.d.ts +0 -5
  85. package/esm/auth/static/assets/Page-Do7F0Mzd.js +0 -1
  86. package/esm/auth/static/assets/Page-gV58jf2r.css +0 -1
  87. package/esm/auth/static/assets/index-czJ1PA1n.d.ts +0 -53
  88. package/esm/auth/static/assets/index-czJ1PA1n.js +0 -2
package/esm/index.d.ts CHANGED
@@ -1,10 +1,12 @@
1
+ /// <reference types=".pnpm/@sveltejs+kit@2.5.24_@sveltejs+vite-plugin-svelte@3.1.1_svelte@4.2.18_vite@5.4.1_@types+node@_vtylvkjv5lewhfcl4vq2py4rce/node_modules/@sveltejs/kit" />
1
2
  import type { RequestEvent } from '@sveltejs/kit';
2
- import type { FieldMetadata, FindOptionsBase, Repository } from 'remult';
3
+ import type { FindOptionsBase } from 'remult';
3
4
  import { Log } from '@kitql/helpers';
4
- import type { KitBaseEnum, KitBaseEnumOptions, KitIcon } from './KitBaseEnum.js';
5
- import type { KitCellsInput as KitCellsInputForExport } from './kitCellsBuildor.js';
6
- import { kitStoreItem } from './kitStoreItem.js';
7
- import { kitStoreList } from './kitStoreList.js';
5
+ import type { BaseEnum, BaseItem, FF_Icon } from './BaseEnum.js';
6
+ import type { CellsInput as CellsInput_ForExport } from './cellsBuildor.js';
7
+ import { default as DefaultMail } from './mail/templates/DefaultMail.svelte';
8
+ import { storeItem } from './storeItem.js';
9
+ import { storeList } from './storeList.js';
8
10
  import { default as Button } from './ui/Button.svelte';
9
11
  import { default as Clipboardable } from './ui/Clipboardable.svelte';
10
12
  import { default as DialogManagement } from './ui/dialog/DialogManagement.svelte';
@@ -20,48 +22,37 @@ import { default as Link } from './ui/link/Link.svelte';
20
22
  import { default as LinkPlus } from './ui/link/LinkPlus.svelte';
21
23
  import { default as Loading } from './ui/Loading.svelte';
22
24
  import { default as Tooltip } from './ui/Tooltip.svelte';
23
- export declare const logFirstly: Log;
24
- export declare const KitRole: {
25
+ export { Field, FormEditAction, Grid, GridPaginate, FieldGroup, Icon, Link, LinkPlus, Loading, Button, Tooltip, DialogManagement, FieldContainer, SelectMelt, Clipboardable, DefaultMail, };
26
+ export declare const ff_Log: Log;
27
+ export declare const FF_Role: {
25
28
  Admin: string;
26
29
  };
27
- export { Field, FormEditAction, Grid, GridPaginate, FieldGroup, Icon, Link, LinkPlus, Loading, Button, Tooltip, DialogManagement, FieldContainer, SelectMelt, Clipboardable, };
28
- export { dialog } from './ui/dialog/dialog.js';
30
+ export type { BaseEnumOptions } from './BaseEnum.js';
31
+ export type { BaseItem };
32
+ export type BaseItemLight = Partial<BaseItem>;
29
33
  export type { DialogMetaDataInternal } from './ui/dialog/dialog.js';
30
- export { KitBaseEnum, getEnum, getEnums } from './KitBaseEnum.js';
31
- export type { KitBaseEnumOptions } from './KitBaseEnum.js';
32
- export { KitFields } from './KitFields.js';
33
- export { KitEntity } from './KitEntity.js';
34
- export { LogToConsoleCustom } from './SqlDatabase/LogToConsoleCustom.js';
35
- export { getEntityDisplayValue, isError, kitDbNamesOf, getFieldLinkDisplayValue } from './helper.js';
36
- export { buildWhere, getPlaceholder, buildSearchWhere, kitCellsBuildor, kitCellBuildor, fieldsOf, } from './kitCellsBuildor.js';
37
- export { kitStoreItem };
38
- export { kitStoreList };
39
- export type KitCellsInput<entityType> = KitCellsInputForExport<entityType>;
40
- export type { KitCell, VisibilityMode } from './kitCellsBuildor.js';
41
- export type { FindOptionsPlus } from './kitStoreList.js';
42
- export type KitBaseItem = KitBaseEnumOptions & {
43
- id: string;
44
- captionSub?: string | (string | undefined)[];
45
- href?: string;
46
- repo?: Repository<any>;
47
- sub?: {
48
- captionPre?: string;
49
- repo?: Repository<any>;
50
- item?: any;
51
- };
52
- };
53
- export type KitStoreItem<T> = ReturnType<typeof kitStoreItem<T>>;
54
- export type KitStoreList<T> = ReturnType<typeof kitStoreList<T>>;
55
- export type KitBaseItemLight = Partial<KitBaseItem>;
56
- export { FilterEntity } from './virtual/FilterEntity.js';
57
- export { UIEntity } from './virtual/UIEntity.js';
58
- 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';
59
- export type { KitIcon };
34
+ export type CellsInput<entityType> = CellsInput_ForExport<entityType>;
35
+ export type { Cell, VisibilityMode } from './cellsBuildor.js';
36
+ export type { FF_FindOptions } from './storeList.js';
37
+ export type StoreItem<T> = ReturnType<typeof storeItem<T>>;
38
+ export type StoreList<T> = ReturnType<typeof storeList<T>>;
39
+ export type { ResolvedType, UnArray, RecursivePartial } from './utils/types.js';
40
+ export { FF_Fields } from './FF_Fields.js';
41
+ export { FF_Entity } from './FF_Entity.js';
42
+ export { FF_LogToConsole } from './SqlDatabase/FF_LogToConsole.js';
43
+ export { BaseEnum } from './BaseEnum.js';
44
+ export { dialog } from './ui/dialog/dialog.js';
45
+ export { getEntityDisplayValue, isError, getFieldLinkDisplayValue, getEnum, getEnums, } from './helper.js';
46
+ export { buildWhere, getPlaceholder, buildSearchWhere, cellsBuildor, cellBuildor, fieldsOf, } from './cellsBuildor.js';
47
+ export { storeItem };
48
+ export { storeList };
60
49
  export { displayPhone, arrToStr } from './formats/strings.js';
61
50
  export { displayCurrency } from './formats/numbers.js';
62
51
  export { tw } from './utils/tailwind.js';
63
- export { litOrStr } from './utils/types.js';
64
- export type { ResolvedType, UnArray } from './utils/types.js';
52
+ export { FilterEntity } from './virtual/FilterEntity.js';
53
+ export { UIEntity } from './virtual/UIEntity.js';
54
+ 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';
55
+ export type { FF_Icon };
65
56
  declare module 'remult' {
66
57
  interface RemultContext {
67
58
  url: URL;
@@ -83,16 +74,15 @@ declare module 'remult' {
83
74
  createOptionWhenNoResult?: boolean;
84
75
  multiSelect?: boolean;
85
76
  skipForDefaultField?: boolean;
86
- isHidden?: (item: entityType) => boolean;
87
77
  }
88
78
  interface EntityOptions<entityType> {
89
79
  searchableFind?: (str: string) => FindOptionsBase<entityType>;
90
- displayValue?: (item: entityType) => KitBaseItem;
91
- permissionApiCrud?: KitBaseEnum[] | KitBaseEnum;
92
- permissionApiDelete?: KitBaseEnum[] | KitBaseEnum;
93
- permissionApiInsert?: KitBaseEnum[] | KitBaseEnum;
94
- permissionApiRead?: KitBaseEnum[] | KitBaseEnum;
95
- permissionApiUpdate?: KitBaseEnum[] | KitBaseEnum;
80
+ displayValue?: (item: entityType) => BaseItem;
81
+ permissionApiCrud?: BaseEnum[] | BaseEnum;
82
+ permissionApiDelete?: BaseEnum[] | BaseEnum;
83
+ permissionApiInsert?: BaseEnum[] | BaseEnum;
84
+ permissionApiRead?: BaseEnum[] | BaseEnum;
85
+ permissionApiUpdate?: BaseEnum[] | BaseEnum;
96
86
  }
97
87
  interface UserInfo {
98
88
  session: {
@@ -101,4 +91,3 @@ declare module 'remult' {
101
91
  };
102
92
  }
103
93
  }
104
- export declare const isHidden: (fm: FieldMetadata, row: any) => boolean;
package/esm/index.js CHANGED
@@ -1,8 +1,7 @@
1
- // I'm not sure I can remove this or not ?
2
- // import 'remult'
3
1
  import { Log } from '@kitql/helpers';
4
- import { kitStoreItem } from './kitStoreItem.js';
5
- import { kitStoreList } from './kitStoreList.js';
2
+ import { default as DefaultMail } from './mail/templates/DefaultMail.svelte';
3
+ import { storeItem } from './storeItem.js';
4
+ import { storeList } from './storeList.js';
6
5
  import { default as Button } from './ui/Button.svelte';
7
6
  import { default as Clipboardable } from './ui/Clipboardable.svelte';
8
7
  import { default as DialogManagement } from './ui/dialog/DialogManagement.svelte';
@@ -18,32 +17,36 @@ import { default as Link } from './ui/link/Link.svelte';
18
17
  import { default as LinkPlus } from './ui/link/LinkPlus.svelte';
19
18
  import { default as Loading } from './ui/Loading.svelte';
20
19
  import { default as Tooltip } from './ui/Tooltip.svelte';
21
- export const logFirstly = new Log('firstly');
22
- export const KitRole = {
23
- Admin: 'KitAdmin',
20
+ // ******************************
21
+ // Svelte Components
22
+ // ******************************
23
+ export { Field, FormEditAction, Grid, GridPaginate, FieldGroup, Icon, Link, LinkPlus, Loading, Button, Tooltip, DialogManagement, FieldContainer, SelectMelt, Clipboardable, DefaultMail, };
24
+ // ******************************
25
+ // Objects
26
+ // ******************************
27
+ export const ff_Log = new Log('firstly');
28
+ export const FF_Role = {
29
+ Admin: 'FF_Role.Admin',
24
30
  };
25
- export { Field, FormEditAction, Grid, GridPaginate, FieldGroup, Icon, Link, LinkPlus, Loading, Button, Tooltip, DialogManagement, FieldContainer, SelectMelt, Clipboardable, };
31
+ // ******************************
32
+ // Helpers
33
+ // ******************************
34
+ export { FF_Fields } from './FF_Fields.js';
35
+ export { FF_Entity } from './FF_Entity.js';
36
+ export { FF_LogToConsole } from './SqlDatabase/FF_LogToConsole.js';
37
+ export { BaseEnum } from './BaseEnum.js';
26
38
  export { dialog } from './ui/dialog/dialog.js';
27
- export { KitBaseEnum, getEnum, getEnums } from './KitBaseEnum.js';
28
- export { KitFields } from './KitFields.js';
29
- export { KitEntity } from './KitEntity.js';
30
- export { LogToConsoleCustom } from './SqlDatabase/LogToConsoleCustom.js';
31
- export { getEntityDisplayValue, isError, kitDbNamesOf, getFieldLinkDisplayValue } from './helper.js';
32
- export { buildWhere, getPlaceholder, buildSearchWhere, kitCellsBuildor, kitCellBuildor, fieldsOf, } from './kitCellsBuildor.js';
33
- export { kitStoreItem };
34
- export { kitStoreList };
39
+ export { getEntityDisplayValue, isError, getFieldLinkDisplayValue, getEnum, getEnums, } from './helper.js';
40
+ export { buildWhere, getPlaceholder, buildSearchWhere, cellsBuildor, cellBuildor, fieldsOf, } from './cellsBuildor.js';
41
+ export { storeItem };
42
+ export { storeList };
43
+ export { displayPhone, arrToStr } from './formats/strings.js';
44
+ export { displayCurrency } from './formats/numbers.js';
45
+ export { tw } from './utils/tailwind.js';
46
+ // Hummm... I don't know if we should keep it...
35
47
  export { FilterEntity } from './virtual/FilterEntity.js';
36
48
  export { UIEntity } from './virtual/UIEntity.js';
49
+ // ******************************
37
50
  // Icons
51
+ // ******************************
38
52
  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';
39
- // Formats & Utils
40
- export { displayPhone, arrToStr } from './formats/strings.js';
41
- export { displayCurrency } from './formats/numbers.js';
42
- export { tw } from './utils/tailwind.js';
43
- export { litOrStr } from './utils/types.js';
44
- export const isHidden = (fm, row) => {
45
- if (fm.options.isHidden) {
46
- return fm.options.isHidden(row);
47
- }
48
- return false;
49
- };
@@ -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
- export type MailOptions = {
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
- transport?: Parameters<typeof typeNodemailer.createTransport>[0];
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: (topic: string, mailOptions: Parameters<typeof transporter.sendMail>[0]) => ReturnType<typeof transporter.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 { Log, magenta } from '@kitql/helpers';
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 options;
4
- export const mailInit = (nodemailer, o) => {
5
- options = o;
7
+ let globalOptions;
8
+ export const mailInit = async (nodemailer, o) => {
9
+ nodemailerHolder = nodemailer;
10
+ globalOptions = o;
6
11
  if (o?.transport) {
7
- transporter = nodemailer.createTransport(o?.transport);
12
+ transporter = nodemailerHolder.createTransport(o?.transport, o?.defaults);
8
13
  }
9
14
  else {
10
- nodemailerHolder = nodemailer;
11
15
  try {
12
- nodemailer.createTestAccount(options?.apiUrl ?? '', (err, account) => {
13
- options = { ...options, from: account.user };
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 ?? options?.from },
54
+ ...{ from: mailOptions.from ?? globalOptions?.from },
37
55
  });
38
- if (!options?.transport) {
39
- log.info(
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
- `${magenta(`[${topic}]`)} - Preview URL: ${nodemailerHolder.getTestMessageUrl(info)}`);
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 {};
@@ -6,7 +6,7 @@ type TheStoreItem<T> = {
6
6
  errors: ErrorInfo<T> | undefined;
7
7
  globalError?: string | undefined;
8
8
  };
9
- export declare const kitStoreItem: <T>(repo: Repository<T>, initValues?: TheStoreItem<T>) => {
9
+ export declare const storeItem: <T>(repo: Repository<T>, initValues?: TheStoreItem<T>) => {
10
10
  subscribe: (this: void, run: import("svelte/store").Subscriber<TheStoreItem<T>>, invalidate?: import("svelte/store").Invalidator<TheStoreItem<T>> | undefined) => import("svelte/store").Unsubscriber;
11
11
  create: (item: Partial<T>) => void;
12
12
  set: (newItem: TheStoreItem<T>) => void;
@@ -2,7 +2,7 @@ import { BROWSER } from 'esm-env';
2
2
  import { derived, get, writable } from 'svelte/store';
3
3
  import { Log } from '@kitql/helpers';
4
4
  import { isError } from './helper';
5
- export const kitStoreItem = (repo, initValues = {
5
+ export const storeItem = (repo, initValues = {
6
6
  item: undefined,
7
7
  loading: true,
8
8
  errors: undefined,
@@ -5,7 +5,7 @@ type TheStoreList<T> = {
5
5
  loading: boolean;
6
6
  totalCount: number | undefined;
7
7
  };
8
- export type FindOptionsPlus<T> = FindOptions<T> & {
8
+ export type FF_FindOptions<T> = FindOptions<T> & {
9
9
  withCount?: boolean;
10
10
  withItems?: boolean;
11
11
  };
@@ -23,11 +23,11 @@ export type FindOptionsPlus<T> = FindOptions<T> & {
23
23
  * $: browser && tasks.listen(data.options)
24
24
  * ```
25
25
  */
26
- export declare const kitStoreList: <T>(repo: Repository<T>, initValues?: TheStoreList<T>) => {
26
+ export declare const storeList: <T>(repo: Repository<T>, initValues?: TheStoreList<T>) => {
27
27
  subscribe: (this: void, run: import("svelte/store").Subscriber<TheStoreList<T>>, invalidate?: import("svelte/store").Invalidator<TheStoreList<T>> | undefined) => import("svelte/store").Unsubscriber;
28
28
  manualSet: (info: TheStoreList<T>) => void;
29
- fetch: (options?: FindOptionsPlus<T>, onNewData?: ((items?: T[], totalCount?: number) => void) | undefined) => Promise<void>;
30
- listen: (options?: FindOptionsPlus<T>) => Promise<void>;
29
+ fetch: (options?: FF_FindOptions<T>, onNewData?: ((items?: T[], totalCount?: number) => void) | undefined) => Promise<void>;
30
+ listen: (options?: FF_FindOptions<T>) => Promise<void>;
31
31
  getRepo: () => Repository<T>;
32
32
  };
33
33
  export {};
@@ -15,7 +15,7 @@ import { writable } from 'svelte/store';
15
15
  * $: browser && tasks.listen(data.options)
16
16
  * ```
17
17
  */
18
- export const kitStoreList = (repo, initValues = { items: [], loading: true, totalCount: undefined }) => {
18
+ export const storeList = (repo, initValues = { items: [], loading: true, totalCount: undefined }) => {
19
19
  const { subscribe, set, update } = writable(initValues);
20
20
  let unSub = null;
21
21
  onDestroy(async () => {
@@ -1,7 +1,7 @@
1
1
  <script>import { createTooltip } from "@melt-ui/svelte";
2
2
  import { fade, fly } from "svelte/transition";
3
3
  import { remult } from "remult";
4
- import { KitBaseEnum, tw } from "../";
4
+ import { BaseEnum, tw } from "../";
5
5
  export let isLoading = false;
6
6
  let className = void 0;
7
7
  export { className as class };
@@ -1,11 +1,11 @@
1
1
  import { SvelteComponent } from "svelte";
2
- import { KitBaseEnum } from '../';
2
+ import { BaseEnum } from '../';
3
3
  declare const __propDef: {
4
4
  props: {
5
5
  [x: string]: any;
6
6
  isLoading?: boolean | undefined;
7
7
  class?: string | undefined | null;
8
- permission?: KitBaseEnum[] | KitBaseEnum | undefined;
8
+ permission?: BaseEnum[] | BaseEnum | undefined;
9
9
  };
10
10
  events: {
11
11
  click: MouseEvent;
@@ -1,9 +1,9 @@
1
1
  import { SvelteComponent } from "svelte";
2
- import { type KitCell } from '../';
2
+ import { type Cell } from '../';
3
3
  declare class __sveltets_Render<T extends Record<any, any>> {
4
4
  props(): {
5
5
  [x: string]: any;
6
- cell: KitCell<T>;
6
+ cell: Cell<T>;
7
7
  value?: any;
8
8
  cellsValues?: any;
9
9
  withDedounce?: boolean | undefined;
@@ -1,6 +1,6 @@
1
1
  <script generics="T extends Record<any, any>">import { createEventDispatcher } from "svelte";
2
2
  import { getRelationFieldInfo } from "remult/internals";
3
- import { isHidden, tw } from "..";
3
+ import { tw } from "../";
4
4
  import Field from "./Field.svelte";
5
5
  import FieldContainer from "./internals/FieldContainer.svelte";
6
6
  import Loading from "./Loading.svelte";
@@ -55,7 +55,7 @@ function isToFocus(currentKey, focusKey2, i) {
55
55
  {@const focus = isToFocus(cell.field?.key, focusKey, i)}
56
56
  {#if shouldHide(cell, mode)}
57
57
  <!-- Do nothing -->
58
- {:else if cell.field && isHidden(cell.field, $store.item)}
58
+ {:else if cell.field && !cell.field.includedInApi($store.item)}
59
59
  <!-- Do nothing, but keep the class... -->
60
60
  <div class={cell.class}></div>
61
61
  {:else}
@@ -1,12 +1,12 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  import type { FieldMetadata } from 'remult';
3
- import { type KitStoreItem } from '..';
4
- import type { KitCell } from '../kitCellsBuildor';
3
+ import { type StoreItem } from '../';
4
+ import type { Cell } from '../cellsBuildor';
5
5
  declare class __sveltets_Render<T extends Record<any, any>> {
6
6
  props(): {
7
7
  mode?: ("view" | "edit" | "filtre") | undefined;
8
- cells: KitCell<T>[];
9
- store: KitStoreItem<T>;
8
+ cells: Cell<T>[];
9
+ store: StoreItem<T>;
10
10
  focusKey?: string | null | undefined;
11
11
  };
12
12
  events(): {
@@ -1,11 +1,11 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  import type { EntityOrderBy } from 'remult';
3
- import { type KitStoreList } from '../index.js';
4
- import type { KitCell } from '../kitCellsBuildor.js';
3
+ import type { Cell } from '../cellsBuildor.js';
4
+ import { type StoreList } from '../index.js';
5
5
  declare class __sveltets_Render<T extends Record<any, any>> {
6
6
  props(): {
7
- cells: KitCell<T>[];
8
- store: KitStoreList<T>;
7
+ cells: Cell<T>[];
8
+ store: StoreList<T>;
9
9
  withAdd?: boolean | undefined;
10
10
  withEdit?: boolean | undefined;
11
11
  withDelete?: boolean | undefined;
@@ -33,7 +33,7 @@ declare class __sveltets_Render<T extends Record<any, any>> {
33
33
  cell: {
34
34
  row: T;
35
35
  field: import("remult").FieldMetadata<any, T> | undefined;
36
- cell: KitCell<T>;
36
+ cell: Cell<T>;
37
37
  };
38
38
  extra: {};
39
39
  };
@@ -1,11 +1,11 @@
1
- <script>import { FieldGroup, kitStoreItem } from "../..";
2
- import { kitCellsBuildor } from "../../kitCellsBuildor";
1
+ <script>import { FieldGroup, storeItem } from "../..";
2
+ import { cellsBuildor } from "../../cellsBuildor";
3
3
  import { dialog } from "./dialog";
4
4
  import DialogPrimitive from "./DialogPrimitive.svelte";
5
5
  import FormEditAction from "./FormEditAction.svelte";
6
6
  export let toShow;
7
- $: cells = kitCellsBuildor(toShow.repo, toShow.cells);
8
- $: store = toShow.store ?? kitStoreItem(toShow.repo);
7
+ $: cells = cellsBuildor(toShow.repo, toShow.cells);
8
+ $: store = toShow.store ?? storeItem(toShow.repo);
9
9
  $: {
10
10
  if (toShow.type === "update" || toShow.type === "view") {
11
11
  store.set({ item: toShow.defaults, errors: {}, loading: false, globalError: void 0 });
@@ -1,8 +1,8 @@
1
1
  import { SvelteComponent } from "svelte";
2
- import { type KitBaseItemLight } from '../../';
2
+ import { type BaseItemLight } from '../../';
3
3
  declare const __propDef: {
4
4
  props: {
5
- detail?: KitBaseItemLight | undefined;
5
+ detail?: BaseItemLight | undefined;
6
6
  open?: boolean | undefined;
7
7
  classes?: {
8
8
  root?: string | undefined;
@@ -1,10 +1,10 @@
1
1
  import { SvelteComponent } from "svelte";
2
- import type { KitStoreItem } from '../..';
2
+ import type { StoreItem } from '../..';
3
3
  import type { DialogType } from './dialog';
4
4
  declare class __sveltets_Render<T extends any> {
5
5
  props(): {
6
6
  [x: string]: any;
7
- store: KitStoreItem<T>;
7
+ store: StoreItem<T>;
8
8
  type: DialogType;
9
9
  wDelete?: boolean | undefined;
10
10
  textCreate?: string | undefined;
@@ -1,6 +1,6 @@
1
1
  import type { SvelteComponent } from 'svelte';
2
2
  import type { Repository } from 'remult';
3
- import { type KitBaseItemLight, type KitCellsInput, type KitStoreItem } from '../../';
3
+ import { type BaseItemLight, type CellsInput, type StoreItem } from '../../';
4
4
  export type DialogClasses = {
5
5
  /**
6
6
  * for example `overflow-auto` to have a scrollbar in the dialog
@@ -10,10 +10,10 @@ export type DialogClasses = {
10
10
  };
11
11
  export type FormGrid = 'grid-cols-1' | 'grid-cols-2' | 'grid-cols-3' | 'grid-cols-4' | 'grid-cols-1 lg:grid-cols-4';
12
12
  export type DialogMetaData<entityType = any> = {
13
- detail?: KitBaseItemLight;
13
+ detail?: BaseItemLight;
14
14
  repo?: Repository<entityType>;
15
- store?: KitStoreItem<entityType>;
16
- cells?: KitCellsInput<entityType>;
15
+ store?: StoreItem<entityType>;
16
+ cells?: CellsInput<entityType>;
17
17
  defaults?: Partial<entityType>;
18
18
  classes?: DialogClasses;
19
19
  component?: new (...args: any[]) => SvelteComponent;
@@ -37,7 +37,7 @@ export type DialogMetaDataInternal<entityType = any> = DialogMetaData<entityType
37
37
  export declare const dialog: {
38
38
  confirm: (topic: string, text: string, icon?: string) => Promise<ResultClose<any>>;
39
39
  confirmDelete: (topic: string) => Promise<ResultClose<any>>;
40
- form: <entityType>(type: 'insert' | 'update' | 'view', topic: string, repo: Repository<entityType>, cells: KitCellsInput<entityType>, options?: {
40
+ form: <entityType>(type: 'insert' | 'update' | 'view', topic: string, repo: Repository<entityType>, cells: CellsInput<entityType>, options?: {
41
41
  defaults?: Partial<entityType>;
42
42
  classes?: DialogClasses;
43
43
  noThrow?: boolean;