firstly 0.0.16-next.1 → 0.1.0-next.3

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 (108) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/esm/FF_Entity.d.ts +1 -1
  3. package/esm/FF_Entity.js +9 -9
  4. package/esm/ROUTES.d.ts +1 -1
  5. package/esm/ROUTES.js +2 -2
  6. package/esm/SqlDatabase/FF_LogToConsole.d.ts +14 -0
  7. package/esm/SqlDatabase/FF_LogToConsole.js +24 -5
  8. package/esm/auth/Entities.d.ts +7 -1
  9. package/esm/auth/Entities.js +22 -14
  10. package/esm/auth/server/AuthController.server.js +111 -111
  11. package/esm/auth/server/handleAuth.d.ts +4 -2
  12. package/esm/auth/server/handleAuth.js +13 -12
  13. package/esm/auth/server/helperRole.d.ts +11 -4
  14. package/esm/auth/server/helperRole.js +29 -20
  15. package/esm/auth/server/index.d.ts +1 -0
  16. package/esm/auth/server/index.js +1 -0
  17. package/esm/auth/server/module.d.ts +31 -13
  18. package/esm/auth/server/module.js +40 -10
  19. package/esm/auth/server/providers/github.d.ts +2 -2
  20. package/esm/auth/server/providers/github.js +14 -2
  21. package/esm/auth/static/assets/Page-BHW08QWz.css +1 -0
  22. package/esm/auth/static/assets/{Page-BgIgl-Te.d.ts → Page-CTZPxniP.d.ts} +2 -2
  23. package/esm/auth/static/assets/{Page-f5pC21Yg.js → Page-CTZPxniP.js} +1 -1
  24. package/esm/auth/static/assets/{Page-f5pC21Yg.d.ts → Page-D0d9iZO-.d.ts} +2 -2
  25. package/esm/auth/static/assets/{Page-BgIgl-Te.js → Page-D0d9iZO-.js} +1 -1
  26. package/esm/auth/static/assets/Page-DXshwJi7.d.ts +6 -0
  27. package/esm/auth/static/assets/Page-DXshwJi7.js +20 -0
  28. package/esm/auth/static/assets/index-LRDptjak.d.ts +217 -0
  29. package/esm/auth/static/assets/index-LRDptjak.js +44 -0
  30. package/esm/auth/static/index.html +1 -2
  31. package/esm/auth/types.d.ts +16 -1
  32. package/esm/bin/cmd.js +16 -16
  33. package/esm/changeLog/changeLogEntities.d.ts +21 -0
  34. package/esm/changeLog/changeLogEntities.js +57 -0
  35. package/esm/changeLog/index.d.ts +3 -15
  36. package/esm/changeLog/index.js +3 -51
  37. package/esm/changeLog/server/index.d.ts +39 -28
  38. package/esm/changeLog/server/index.js +40 -29
  39. package/esm/cron/Cron.d.ts +11 -0
  40. package/esm/cron/Cron.js +43 -0
  41. package/esm/cron/Role_Cron.d.ts +3 -0
  42. package/esm/cron/Role_Cron.js +3 -0
  43. package/esm/cron/index.d.ts +3 -0
  44. package/esm/cron/index.js +3 -0
  45. package/esm/cron/server/index.d.ts +29 -11
  46. package/esm/cron/server/index.js +29 -13
  47. package/esm/feedback/FeedbackController.d.ts +3 -1
  48. package/esm/feedback/FeedbackController.js +23 -1
  49. package/esm/feedback/server/index.d.ts +2 -2
  50. package/esm/feedback/server/index.js +2 -2
  51. package/esm/feedback/types.d.ts +6 -0
  52. package/esm/feedback/ui/DialogIssue.svelte +8 -1
  53. package/esm/feedback/ui/DialogIssues.svelte +1 -1
  54. package/esm/formats/index.d.ts +1 -1
  55. package/esm/formats/index.js +1 -1
  56. package/esm/formats/strings.d.ts +2 -0
  57. package/esm/formats/strings.js +22 -0
  58. package/esm/index.d.ts +1 -2
  59. package/esm/index.js +0 -2
  60. package/esm/mail/Mail.d.ts +13 -0
  61. package/esm/mail/Mail.js +51 -0
  62. package/esm/mail/Role_Mail.d.ts +3 -0
  63. package/esm/mail/Role_Mail.js +3 -0
  64. package/esm/mail/index.d.ts +7 -2
  65. package/esm/mail/index.js +7 -2
  66. package/esm/mail/server/formatMailHelper.d.ts +16 -0
  67. package/esm/mail/server/formatMailHelper.js +113 -0
  68. package/esm/mail/server/index.d.ts +32 -19
  69. package/esm/mail/server/index.js +113 -38
  70. package/esm/server/index.d.ts +9 -6
  71. package/esm/server/index.js +28 -50
  72. package/esm/svelte/FF_Layout.svelte +2 -2
  73. package/esm/svelte/dialog/DialogManagement.svelte +2 -2
  74. package/esm/svelte/helpers.d.ts +1 -0
  75. package/esm/svelte/index.d.ts +1 -0
  76. package/esm/svelte/index.js +1 -0
  77. package/esm/svelte/initRemultSvelteReactivity.d.ts +1 -0
  78. package/esm/svelte/initRemultSvelteReactivity.js +29 -0
  79. package/esm/sveltekit/server/index.d.ts +2 -2
  80. package/esm/sveltekit/server/index.js +2 -2
  81. package/esm/ui/Button.svelte +1 -1
  82. package/esm/ui/Field.svelte +5 -3
  83. package/esm/ui/Field.svelte.d.ts +4 -1
  84. package/esm/ui/FieldGroup.svelte +2 -1
  85. package/esm/ui/FieldGroup.svelte.d.ts +4 -1
  86. package/esm/ui/GridPaginate.svelte +2 -2
  87. package/esm/ui/GridPaginate2.svelte +1 -1
  88. package/esm/ui/Loading.svelte +1 -1
  89. package/esm/ui/Tooltip.svelte +1 -1
  90. package/esm/ui/dialog/DialogForm.svelte +3 -3
  91. package/esm/ui/dialog/DialogManagement.svelte +2 -2
  92. package/esm/ui/dialog/DialogPrimitive.svelte +2 -2
  93. package/esm/ui/dialog/FormEditAction.svelte +2 -2
  94. package/esm/ui/internals/FieldContainer.svelte +2 -2
  95. package/esm/ui/internals/Textarea.svelte +2 -2
  96. package/esm/ui/internals/select/MultiSelectMelt.svelte +6 -6
  97. package/esm/ui/internals/select/SelectMelt.svelte +28 -14
  98. package/esm/ui/internals/select/SelectMelt.svelte.d.ts +4 -1
  99. package/esm/ui/link/LinkPlus.svelte +2 -2
  100. package/esm/vite/index.js +50 -52
  101. package/package.json +15 -12
  102. package/esm/auth/static/assets/Page-HDnoBhpE.d.ts +0 -6
  103. package/esm/auth/static/assets/Page-HDnoBhpE.js +0 -20
  104. package/esm/auth/static/assets/Page-mK42zGEw.css +0 -1
  105. package/esm/auth/static/assets/index-DAjei0Ie.d.ts +0 -151
  106. package/esm/auth/static/assets/index-DAjei0Ie.js +0 -42
  107. package/esm/mail/templates/DefaultMail.svelte +0 -86
  108. package/esm/mail/templates/DefaultMail.svelte.d.ts +0 -30
package/CHANGELOG.md CHANGED
@@ -1,5 +1,46 @@
1
1
  # firstly
2
2
 
3
+ ## 0.1.0-next.3
4
+
5
+ ### Minor Changes
6
+
7
+ - [#140](https://github.com/jycouet/firstly/pull/140)
8
+ [`94b2188`](https://github.com/jycouet/firstly/commit/94b2188c78772f94e7835ab933fcebbe2a37703c)
9
+ Thanks [@jycouet](https://github.com/jycouet)! - [BREAKING] - deprecate firstly module in favor of
10
+ remult module
11
+
12
+ ```diff
13
+ remultApi({
14
+ -- modules: [], // firstly modules
15
+ ++ modulesFF: [], // firstly modules
16
+ })
17
+
18
+ Then, you can use `modules` level of `remult`
19
+ ```
20
+
21
+ ### Patch Changes
22
+
23
+ - [#117](https://github.com/jycouet/firstly/pull/117)
24
+ [`407ed4d`](https://github.com/jycouet/firstly/commit/407ed4db8f4b99f234932965b870d51f6a9c07ca)
25
+ Thanks [@jycouet](https://github.com/jycouet)! - need to pass `redirect` to handleAuth manually
26
+
27
+ - [#117](https://github.com/jycouet/firstly/pull/117)
28
+ [`f30c737`](https://github.com/jycouet/firstly/commit/f30c73781d8f50da08fcdc25f1f7611133ea8b0c)
29
+ Thanks [@jycouet](https://github.com/jycouet)! - switch mail engine to sailkit
30
+
31
+ - [#117](https://github.com/jycouet/firstly/pull/117)
32
+ [`5e1d67e`](https://github.com/jycouet/firstly/commit/5e1d67eb8f75127c3d729945e20b22c40184ee20)
33
+ Thanks [@jycouet](https://github.com/jycouet)! - [BREAKING] - Auth Identifier got removed in favor
34
+ of name in User table.
35
+
36
+ ## 0.0.16-next.2
37
+
38
+ ### Patch Changes
39
+
40
+ - [#110](https://github.com/jycouet/firstly/pull/110)
41
+ [`0c66f11`](https://github.com/jycouet/firstly/commit/0c66f114dd95f65c0407abddbd647a66769142eb)
42
+ Thanks [@jycouet](https://github.com/jycouet)! - add github in default ui (if configured)
43
+
3
44
  ## 0.0.16-next.1
4
45
 
5
46
  ### Patch Changes
@@ -1,2 +1,2 @@
1
1
  import { type EntityOptions } from 'remult';
2
- export declare function FF_Entity<entityType>(key: string, options: EntityOptions<entityType extends new (...args: any) => any ? InstanceType<entityType> : entityType>): (target: any, info?: import("remult/src/remult3/remult3").ClassDecoratorContextStub<entityType extends infer T ? T extends entityType ? T extends new (...args: any) => any ? entityType : never : never : never> | undefined) => any;
2
+ export declare function FF_Entity<entityType>(key: string, options?: EntityOptions<entityType extends new (...args: any) => any ? InstanceType<entityType> : entityType>): (target: any, info?: import("remult/src/remult3/remult3").ClassDecoratorContextStub<entityType extends infer T ? T extends entityType ? T extends new (...args: any) => any ? entityType : never : never : never> | undefined) => any;
package/esm/FF_Entity.js CHANGED
@@ -12,31 +12,31 @@ const toAllow = (permission) => {
12
12
  export function FF_Entity(key, options) {
13
13
  return Entity(key, {
14
14
  ...options,
15
- allowApiCrud: options.allowApiCrud ?? toAllow(options.permissionApiCrud),
16
- allowApiDelete: options.allowApiDelete ?? toAllow(options.permissionApiDelete),
17
- allowApiInsert: options.allowApiInsert ?? toAllow(options.permissionApiInsert),
18
- allowApiRead: options.allowApiRead ?? toAllow(options.permissionApiRead),
19
- allowApiUpdate: options.allowApiUpdate ?? toAllow(options.permissionApiUpdate),
15
+ allowApiCrud: options?.allowApiCrud ?? toAllow(options?.permissionApiCrud),
16
+ allowApiDelete: options?.allowApiDelete ?? toAllow(options?.permissionApiDelete),
17
+ allowApiInsert: options?.allowApiInsert ?? toAllow(options?.permissionApiInsert),
18
+ allowApiRead: options?.allowApiRead ?? toAllow(options?.permissionApiRead),
19
+ allowApiUpdate: options?.allowApiUpdate ?? toAllow(options?.permissionApiUpdate),
20
20
  // changesLogs
21
21
  saved: async (entity, e) => {
22
22
  await options?.saved?.(entity, e);
23
- if (options.changeLog === false) {
23
+ if (options?.changeLog === false) {
24
24
  // Don't log changes
25
25
  }
26
26
  else {
27
27
  if (isBackend()) {
28
- await recordSaved(entity, e, options.changeLog);
28
+ await recordSaved(entity, e, options?.changeLog);
29
29
  }
30
30
  }
31
31
  },
32
32
  deleted: async (entity, e) => {
33
33
  await options?.deleted?.(entity, e);
34
- if (options.changeLog === false) {
34
+ if (options?.changeLog === false) {
35
35
  // Don't log changes
36
36
  }
37
37
  else {
38
38
  if (isBackend()) {
39
- await recordDeleted(entity, e, options.changeLog);
39
+ await recordDeleted(entity, e, options?.changeLog);
40
40
  }
41
41
  }
42
42
  },
package/esm/ROUTES.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * >> DO NOT EDIT THIS FILE MANUALLY <<
5
5
  */
6
- type ParamValue = string | number | undefined;
6
+ type ParamValue = string | number | boolean | null | undefined;
7
7
  /**
8
8
  * Append search params to a string
9
9
  */
package/esm/ROUTES.js CHANGED
@@ -37,8 +37,8 @@ const LINKS = {
37
37
  "remult_admin": `/api/admin`,
38
38
  "github": (params) => {
39
39
  params = params ?? {};
40
- params['owner'] = params['owner'] ?? "jycouet";
41
- params['repo'] = params['repo'] ?? "firstly";
40
+ params['owner'] = params['owner'] ?? "\"jycouet\"";
41
+ params['repo'] = params['repo'] ?? "\"firstly\"";
42
42
  return `https://github.com/${params['owner']}/${params['repo']}`;
43
43
  }
44
44
  };
@@ -1,5 +1,19 @@
1
+ type TypeQuery = 'INSERT' | 'SELECT' | 'SELECT_COUNT' | 'UPDATE' | 'DELETE' | 'CREATE' | 'ALTER' | 'DROP' | 'TRUNCATE' | 'GRANT' | 'REVOKE';
2
+ /**
3
+ * @example
4
+ * SqlDatabase.LogToConsole = (...a) => FF_LogToConsole(...a, {
5
+ * type: {
6
+ * exclude: ['SELECT', 'SELECT_COUNT']
7
+ * }
8
+ * })
9
+ */
1
10
  export declare const FF_LogToConsole: (duration: number, query: string, args: Record<string, any>, options?: {
11
+ type?: {
12
+ include?: TypeQuery[];
13
+ exclude?: TypeQuery[];
14
+ };
2
15
  withDetails?: boolean;
3
16
  tablesToHide?: string[][];
4
17
  ending?: (duration: number, query: string, args: Record<string, any>, tables: string[]) => void;
5
18
  }) => string | undefined;
19
+ export {};
@@ -4,7 +4,7 @@ const typeQuery = new Map([
4
4
  // CRUD
5
5
  ['INSERT', '⚪'], // Used to insert new data into a database.
6
6
  ['SELECT', '🔵'], // Used to select data from a database and retrieve it.
7
- ['COUNT ', '🟦'], // Used to count data from a database and retrieve it.
7
+ ['SELECT_COUNT', '🟦'], // Used to count data from a database and retrieve it.
8
8
  ['UPDATE', '🟣'], // Used to update existing data within a database.
9
9
  ['DELETE', '🟤'], // Used to delete existing data from a database.
10
10
  // Additional
@@ -18,17 +18,36 @@ const typeQuery = new Map([
18
18
  const keys = ['FROM', 'WHERE', 'LIMIT', 'OFFSET'];
19
19
  const typeQueryKey = Array.from(typeQuery.keys());
20
20
  const log = new Log('');
21
+ /**
22
+ * @example
23
+ * SqlDatabase.LogToConsole = (...a) => FF_LogToConsole(...a, {
24
+ * type: {
25
+ * exclude: ['SELECT', 'SELECT_COUNT']
26
+ * }
27
+ * })
28
+ */
21
29
  export const FF_LogToConsole = (duration, query, args, options) => {
22
30
  if (duration < SqlDatabase.durationThreshold)
23
31
  return;
24
32
  const rawSql = query
33
+ .replace(/--.*?(?=\r\n|\n|$)/g, '') // Remove SQL comments
25
34
  .replace(/(\r\n|\n|\r|\t)/gm, ' ')
26
35
  .replace(/ +/g, ' ')
27
36
  .trim();
28
37
  const s = rawSql.split(' ');
29
38
  let first = s[0].toUpperCase();
30
- if (s.includes('count(*)')) {
31
- first = 'COUNT ';
39
+ if (s.length > 1 && s[1].toLowerCase() === 'count(*)') {
40
+ first = 'SELECT_COUNT';
41
+ }
42
+ if (options?.type?.include) {
43
+ if (!options.type.include.includes(first)) {
44
+ return;
45
+ }
46
+ }
47
+ if (options?.type?.exclude) {
48
+ if (options.type.exclude.includes(first)) {
49
+ return;
50
+ }
32
51
  }
33
52
  const tables = [];
34
53
  const listArgs = [];
@@ -75,8 +94,8 @@ export const FF_LogToConsole = (duration, query, args, options) => {
75
94
  ['information_Schema.tables'],
76
95
  ['information_schema.columns'],
77
96
  // ['__remult_migrations_version'],
78
- ['ff_auth.accounts'],
79
- ['ff_auth.users'],
97
+ // ['ff_auth.accounts'],
98
+ // ['ff_auth.users'],
80
99
  ['ff_auth.users_sessions'],
81
100
  ['_ff_change_logs'],
82
101
  ];
@@ -1,5 +1,7 @@
1
+ import type { OAuth2Tokens } from 'arctic';
1
2
  import { BaseEnum } from '..';
2
3
  import type { BaseEnumOptions } from '..';
4
+ import type { OAuth2UserInfo } from './types';
3
5
  export declare const FF_Role_Auth: {
4
6
  readonly FF_Role_Auth_Admin: "FF_Role_Auth.Admin";
5
7
  readonly FF_Role_Auth_Invite: "FF_Role_Auth.Invite";
@@ -8,7 +10,7 @@ export declare class FFAuthUser {
8
10
  id: string;
9
11
  createdAt: Date;
10
12
  updatedAt?: Date;
11
- identifier: string;
13
+ name: string;
12
14
  roles: string[];
13
15
  accounts: FFAuthAccount[];
14
16
  sessions: FFAuthUserSession[];
@@ -21,10 +23,14 @@ export declare class FFAuthAccount {
21
23
  user: FFAuthUser;
22
24
  provider: string;
23
25
  providerUserId: string;
26
+ email?: string | null;
24
27
  hashPassword?: string;
25
28
  token?: string;
26
29
  expiresAt?: Date;
27
30
  lastVerifiedAt?: Date;
31
+ metadata?: OAuth2UserInfo & {
32
+ tokens_data: OAuth2Tokens['data'];
33
+ };
28
34
  }
29
35
  export declare class FFAuthUserSession {
30
36
  id: string;
@@ -15,7 +15,7 @@ let FFAuthUser = class FFAuthUser {
15
15
  id;
16
16
  createdAt;
17
17
  updatedAt;
18
- identifier;
18
+ name;
19
19
  roles = [];
20
20
  accounts;
21
21
  sessions;
@@ -24,29 +24,29 @@ __decorate([
24
24
  Fields.cuid()
25
25
  ], FFAuthUser.prototype, "id", void 0);
26
26
  __decorate([
27
- Fields.createdAt()
27
+ Fields.createdAt({ includeInApi: [FF_Role_Auth.FF_Role_Auth_Admin, FF_Role.FF_Role_Admin] })
28
28
  ], FFAuthUser.prototype, "createdAt", void 0);
29
29
  __decorate([
30
- Fields.updatedAt()
30
+ Fields.updatedAt({ includeInApi: [FF_Role_Auth.FF_Role_Auth_Admin, FF_Role.FF_Role_Admin] })
31
31
  ], FFAuthUser.prototype, "updatedAt", void 0);
32
32
  __decorate([
33
33
  Fields.string({
34
- allowApiUpdate: false,
35
- validate: [
36
- Validators.unique(),
37
- Validators.required(),
38
- (e) => {
39
- if (e.identifier?.length < 2)
40
- throw 'Must be at least 2 characters long';
41
- },
42
- ],
34
+ required: true,
35
+ validate: [Validators.unique(), Validators.required()],
43
36
  })
44
- ], FFAuthUser.prototype, "identifier", void 0);
37
+ ], FFAuthUser.prototype, "name", void 0);
45
38
  __decorate([
46
39
  Fields.json(() => [], {
40
+ includeInApi: [FF_Role_Auth.FF_Role_Auth_Admin, FF_Role.FF_Role_Admin],
47
41
  inputType: 'selectEnum',
48
42
  valueConverter: {
49
- toDb: (x) => (x ? x.join(',') : []),
43
+ toDb: (x) => {
44
+ if (x === null)
45
+ return null;
46
+ if (Array.isArray(x))
47
+ return x.join(',');
48
+ return x;
49
+ },
50
50
  //FIXME: refacto this + remove "permissions" & add a disable user!
51
51
  fromDb: (x) => {
52
52
  return x
@@ -80,10 +80,12 @@ let FFAuthAccount = class FFAuthAccount {
80
80
  user;
81
81
  provider = FFAuthProvider.PASSWORD.id;
82
82
  providerUserId = '';
83
+ email = null;
83
84
  hashPassword;
84
85
  token;
85
86
  expiresAt;
86
87
  lastVerifiedAt;
88
+ metadata;
87
89
  };
88
90
  __decorate([
89
91
  Fields.cuid()
@@ -106,6 +108,9 @@ __decorate([
106
108
  __decorate([
107
109
  Fields.string()
108
110
  ], FFAuthAccount.prototype, "providerUserId", void 0);
111
+ __decorate([
112
+ Fields.string({ allowNull: true })
113
+ ], FFAuthAccount.prototype, "email", void 0);
109
114
  __decorate([
110
115
  Fields.string({ includeInApi: false, allowNull: true })
111
116
  ], FFAuthAccount.prototype, "hashPassword", void 0);
@@ -118,6 +123,9 @@ __decorate([
118
123
  __decorate([
119
124
  Fields.date({ includeInApi: false, allowNull: true })
120
125
  ], FFAuthAccount.prototype, "lastVerifiedAt", void 0);
126
+ __decorate([
127
+ Fields.json({ includeInApi: false, allowNull: true })
128
+ ], FFAuthAccount.prototype, "metadata", void 0);
121
129
  FFAuthAccount = __decorate([
122
130
  FF_Entity('ff_auth.accounts', {
123
131
  allowApiCrud: [FF_Role_Auth.FF_Role_Auth_Admin, FF_Role.FF_Role_Admin],