firstly 0.0.11 → 0.0.13

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 (139) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/esm/BaseEnum.d.ts +2 -0
  3. package/esm/BaseEnum.js +2 -0
  4. package/esm/FF_Fields.js +0 -1
  5. package/esm/ROUTES.d.ts +2 -2
  6. package/esm/ROUTES.js +10 -5
  7. package/esm/SqlDatabase/FF_LogToConsole.d.ts +1 -0
  8. package/esm/SqlDatabase/FF_LogToConsole.js +22 -16
  9. package/esm/api/index.d.ts +20 -21
  10. package/esm/api/index.js +74 -62
  11. package/esm/auth/{client/Auth.d.ts → AuthController.d.ts} +18 -25
  12. package/esm/auth/{client/Auth.js → AuthController.js} +48 -44
  13. package/esm/auth/{client/Entities.d.ts → Entities.d.ts} +4 -3
  14. package/esm/auth/{client/Entities.js → Entities.js} +7 -7
  15. package/esm/auth/README.md +0 -10
  16. package/esm/auth/index.d.ts +5 -149
  17. package/esm/auth/index.js +5 -316
  18. package/esm/auth/{AuthController.server.d.ts → server/AuthController.server.d.ts} +10 -10
  19. package/esm/auth/{AuthController.server.js → server/AuthController.server.js} +133 -171
  20. package/esm/auth/server/handleAuth.d.ts +2 -0
  21. package/esm/auth/server/handleAuth.js +140 -0
  22. package/esm/auth/server/handleGuard.d.ts +16 -0
  23. package/esm/auth/server/handleGuard.js +67 -0
  24. package/esm/auth/server/helperDb.d.ts +10 -0
  25. package/esm/auth/server/helperDb.js +56 -0
  26. package/esm/auth/server/helperFirstly.d.ts +1 -0
  27. package/esm/auth/server/helperFirstly.js +8 -0
  28. package/esm/auth/server/helperOslo.d.ts +7 -0
  29. package/esm/auth/server/helperOslo.js +24 -0
  30. package/esm/auth/server/helperRemultServer.d.ts +5 -0
  31. package/esm/auth/server/helperRemultServer.js +44 -0
  32. package/esm/auth/{RoleHelpers.d.ts → server/helperRole.d.ts} +1 -1
  33. package/esm/auth/{RoleHelpers.js → server/helperRole.js} +1 -1
  34. package/esm/auth/server/index.d.ts +7 -0
  35. package/esm/auth/server/index.js +7 -0
  36. package/esm/auth/server/module.d.ts +257 -0
  37. package/esm/auth/server/module.js +197 -0
  38. package/esm/auth/{providers → server/providers}/github.d.ts +6 -4
  39. package/esm/auth/{providers → server/providers}/github.js +29 -20
  40. package/esm/auth/{providers/index.d.ts → server/providers/helperProvider.d.ts} +0 -2
  41. package/esm/auth/{providers/index.js → server/providers/helperProvider.js} +5 -6
  42. package/esm/auth/static/assets/Page-BUfjaN-D.d.ts +5 -0
  43. package/esm/auth/static/assets/Page-BUfjaN-D.js +19 -0
  44. package/esm/auth/static/assets/Page-CJ58H1vl.css +1 -0
  45. package/esm/auth/static/assets/Page-CaDAqmBS.d.ts +5 -0
  46. package/esm/auth/static/assets/Page-CaDAqmBS.js +1 -0
  47. package/esm/auth/static/assets/Page-DhdZddzJ.d.ts +5 -0
  48. package/esm/auth/static/assets/Page-DhdZddzJ.js +1 -0
  49. package/esm/auth/static/assets/index-BDy4A_14.css +4 -0
  50. package/esm/auth/static/assets/index-D-Ztdt2o.d.ts +54 -0
  51. package/esm/auth/static/assets/index-D-Ztdt2o.js +2 -0
  52. package/esm/auth/static/index.html +11 -11
  53. package/esm/auth/types.d.ts +5 -0
  54. package/esm/bin/cmd.js +122 -54
  55. package/esm/cellsBuildor.js +7 -7
  56. package/esm/changeLog/index.d.ts +0 -36
  57. package/esm/changeLog/index.js +3 -43
  58. package/esm/changeLog/server/index.d.ts +36 -0
  59. package/esm/changeLog/server/index.js +42 -0
  60. package/esm/common.d.ts +5 -0
  61. package/esm/common.js +8 -0
  62. package/esm/cron/{index.d.ts → server/index.d.ts} +1 -1
  63. package/esm/cron/server/index.js +103 -0
  64. package/esm/feedback/FeedbackController.js +4 -5
  65. package/esm/feedback/index.d.ts +0 -16
  66. package/esm/feedback/index.js +0 -11
  67. package/esm/feedback/server/index.d.ts +17 -0
  68. package/esm/feedback/server/index.js +13 -0
  69. package/esm/feedback/ui/DialogIssue.svelte +52 -56
  70. package/esm/feedback/ui/DialogIssues.svelte +71 -71
  71. package/esm/feedback/ui/DialogMilestones.svelte +22 -22
  72. package/esm/helper.js +3 -3
  73. package/esm/index.d.ts +3 -20
  74. package/esm/index.js +3 -10
  75. package/esm/mail/index.d.ts +2 -30
  76. package/esm/mail/index.js +2 -79
  77. package/esm/mail/server/index.d.ts +31 -0
  78. package/esm/mail/server/index.js +88 -0
  79. package/esm/mail/templates/DefaultMail.svelte +17 -17
  80. package/esm/storeItem.js +8 -2
  81. package/esm/storeList.d.ts +1 -1
  82. package/esm/storeList.js +1 -1
  83. package/esm/sveltekit/server/index.d.ts +14 -0
  84. package/esm/sveltekit/server/index.js +24 -0
  85. package/esm/ui/Button.svelte +33 -33
  86. package/esm/ui/Button.svelte.d.ts +2 -2
  87. package/esm/ui/Clipboardable.svelte +11 -8
  88. package/esm/ui/Clipboardable.svelte.d.ts +4 -4
  89. package/esm/ui/Field.svelte +142 -149
  90. package/esm/ui/Field.svelte.d.ts +2 -2
  91. package/esm/ui/FieldGroup.svelte +38 -38
  92. package/esm/ui/Grid.svelte +212 -222
  93. package/esm/ui/GridLoading.svelte +18 -22
  94. package/esm/ui/GridPaginate.svelte +38 -38
  95. package/esm/ui/Icon.svelte +50 -49
  96. package/esm/ui/Icon.svelte.d.ts +18 -18
  97. package/esm/ui/Loading.svelte +5 -2
  98. package/esm/ui/Tooltip.svelte +16 -16
  99. package/esm/ui/dialog/DialogForm.svelte +23 -23
  100. package/esm/ui/dialog/DialogManagement.svelte +74 -74
  101. package/esm/ui/dialog/DialogPrimitive.svelte +50 -51
  102. package/esm/ui/dialog/FormEditAction.svelte +34 -34
  103. package/esm/ui/dialog/dialog.d.ts +2 -2
  104. package/esm/ui/dialog/dialog.js +1 -1
  105. package/esm/ui/internals/FieldContainer.svelte +11 -12
  106. package/esm/ui/internals/FieldContainer.svelte.d.ts +3 -3
  107. package/esm/ui/internals/Input.svelte +25 -25
  108. package/esm/ui/internals/Input.svelte.d.ts +1 -1
  109. package/esm/ui/internals/Textarea.svelte +21 -21
  110. package/esm/ui/internals/Textarea.svelte.d.ts +2 -2
  111. package/esm/ui/internals/select/MultiSelectMelt.svelte +69 -73
  112. package/esm/ui/internals/select/SelectMelt.svelte +86 -86
  113. package/esm/ui/internals/select/SelectRadio.svelte +22 -22
  114. package/esm/ui/link/Link.svelte +14 -14
  115. package/esm/ui/link/Link.svelte.d.ts +3 -4
  116. package/esm/ui/link/LinkPlus.svelte +33 -35
  117. package/esm/vite/index.js +24 -25
  118. package/package.json +50 -42
  119. package/esm/auth/Adapter.d.ts +0 -10
  120. package/esm/auth/Adapter.js +0 -50
  121. package/esm/auth/client/index.d.ts +0 -7
  122. package/esm/auth/client/index.js +0 -7
  123. package/esm/auth/helper.d.ts +0 -6
  124. package/esm/auth/helper.js +0 -14
  125. package/esm/auth/providers/strava.d.ts +0 -30
  126. package/esm/auth/providers/strava.js +0 -60
  127. package/esm/auth/static/assets/Page-BEFYPjis.d.ts +0 -4
  128. package/esm/auth/static/assets/Page-BEFYPjis.js +0 -1
  129. package/esm/auth/static/assets/Page-BGTO8LC5.css +0 -1
  130. package/esm/auth/static/assets/Page-Cfysx_UV.d.ts +0 -6
  131. package/esm/auth/static/assets/Page-Cfysx_UV.js +0 -18
  132. package/esm/auth/static/assets/Page-DtgkOCJs.d.ts +0 -4
  133. package/esm/auth/static/assets/Page-DtgkOCJs.js +0 -1
  134. package/esm/auth/static/assets/index-CR_3yNaJ.css +0 -4
  135. package/esm/auth/static/assets/index-QypqCYwC.d.ts +0 -63
  136. package/esm/auth/static/assets/index-QypqCYwC.js +0 -2
  137. package/esm/cron/index.js +0 -102
  138. package/esm/handle/index.d.ts +0 -7
  139. package/esm/handle/index.js +0 -40
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # firstly
2
2
 
3
+ ## 0.0.13
4
+
5
+ ### Patch Changes
6
+
7
+ - [#66](https://github.com/jycouet/firstly/pull/66)
8
+ [`7d8b323`](https://github.com/jycouet/firstly/commit/7d8b323b49d7d76b6d59ec887ed2e37a2238f201)
9
+ Thanks [@jycouet](https://github.com/jycouet)! - prepare JYC 013
10
+
11
+ ## 0.0.12
12
+
13
+ ### Patch Changes
14
+
15
+ - [#64](https://github.com/jycouet/firstly/pull/64)
16
+ [`782ef9c`](https://github.com/jycouet/firstly/commit/782ef9c8a1d967950e4c17de59b3225bc28df5c2)
17
+ Thanks [@jycouet](https://github.com/jycouet)! - prepare JYC 012
18
+
3
19
  ## 0.0.11
4
20
 
5
21
  ### Patch Changes
package/esm/BaseEnum.d.ts CHANGED
@@ -22,6 +22,7 @@ export type BaseEnumOptions<Entity = any> = {
22
22
  icon?: FF_Icon;
23
23
  where?: FindOptionsBase<Entity>['where'];
24
24
  class?: string;
25
+ hide?: boolean;
25
26
  };
26
27
  export declare class BaseEnum<Entity = any> {
27
28
  id: string;
@@ -29,5 +30,6 @@ export declare class BaseEnum<Entity = any> {
29
30
  icon?: FF_Icon;
30
31
  where?: FindOptionsBase<Entity>['where'];
31
32
  class?: string;
33
+ hide?: boolean;
32
34
  constructor(_id: string | number, options?: BaseEnumOptions<Entity>);
33
35
  }
package/esm/BaseEnum.js CHANGED
@@ -4,12 +4,14 @@ export class BaseEnum {
4
4
  icon;
5
5
  where;
6
6
  class;
7
+ hide;
7
8
  constructor(_id, options) {
8
9
  this.id = _id.toString();
9
10
  this.caption = options?.caption ?? this.id;
10
11
  this.icon = options?.icon;
11
12
  this.where = options?.where;
12
13
  this.class = options?.class;
14
+ this.hide = options?.hide;
13
15
  if (options?.icon && options.icon.caption === undefined) {
14
16
  options.icon.caption = options?.caption;
15
17
  }
package/esm/FF_Fields.js CHANGED
@@ -61,7 +61,6 @@ export class FF_Fields {
61
61
  suffixEdit: '€',
62
62
  inputType: 'number',
63
63
  displayValue: displayCurrency,
64
- // REMULT P2: all default valueConverter are removed if I set one?
65
64
  valueConverter: {
66
65
  toInput(val, inputType) {
67
66
  const valStr = String(val);
package/esm/ROUTES.d.ts CHANGED
@@ -85,8 +85,8 @@ export type KIT_ROUTES = {
85
85
  'github': 'owner' | 'repo';
86
86
  };
87
87
  Params: {
88
- owner: never;
89
- repo: never;
88
+ 'owner': never;
89
+ 'repo': never;
90
90
  };
91
91
  };
92
92
  export {};
package/esm/ROUTES.js CHANGED
@@ -32,9 +32,9 @@ const LINKS = {
32
32
  "remult_admin": `/api/admin`,
33
33
  "github": (params) => {
34
34
  params = params ?? {};
35
- params.owner = params.owner ?? "jycouet";
36
- params.repo = params.repo ?? "firstly";
37
- return `https://github.com/${params.owner}/${params.repo}`;
35
+ params['owner'] = params['owner'] ?? "jycouet";
36
+ params['repo'] = params['repo'] ?? "firstly";
37
+ return `https://github.com/${params['owner']}/${params['repo']}`;
38
38
  }
39
39
  };
40
40
  /**
@@ -49,7 +49,12 @@ export const appendSp = (sp, prefix = '?') => {
49
49
  params.append(n, String(v));
50
50
  }
51
51
  };
52
+ let anchor = '';
52
53
  for (const [name, val] of Object.entries(sp)) {
54
+ if (name === '__KIT_ROUTES_ANCHOR__' && val !== undefined) {
55
+ anchor = `#${val}`;
56
+ continue;
57
+ }
53
58
  if (Array.isArray(val)) {
54
59
  for (const v of val) {
55
60
  append(name, v);
@@ -60,8 +65,8 @@ export const appendSp = (sp, prefix = '?') => {
60
65
  }
61
66
  }
62
67
  const formatted = params.toString();
63
- if (formatted) {
64
- return `${prefix}${formatted}`;
68
+ if (formatted || anchor) {
69
+ return `${prefix}${formatted}${anchor}`.replace('?#', '#');
65
70
  }
66
71
  return '';
67
72
  };
@@ -1,4 +1,5 @@
1
1
  export declare const FF_LogToConsole: (duration: number, query: string, args: Record<string, any>, options?: {
2
2
  withDetails?: boolean;
3
3
  tablesToHide?: string[][];
4
+ ending?: (duration: number, query: string, args: Record<string, any>, tables: string[]) => void;
4
5
  }) => string | undefined;
@@ -1,3 +1,4 @@
1
+ import { SqlDatabase } from 'remult';
1
2
  import { bgCyan, cyan, green, Log, magenta, yellow } from '@kitql/helpers';
2
3
  const typeQuery = new Map([
3
4
  // CRUD
@@ -16,7 +17,10 @@ const typeQuery = new Map([
16
17
  ]);
17
18
  const keys = ['FROM', 'WHERE', 'LIMIT', 'OFFSET'];
18
19
  const typeQueryKey = Array.from(typeQuery.keys());
20
+ const log = new Log('');
19
21
  export const FF_LogToConsole = (duration, query, args, options) => {
22
+ if (duration < SqlDatabase.durationThreshold)
23
+ return;
20
24
  const rawSql = query
21
25
  .replace(/(\r\n|\n|\r|\t)/gm, ' ')
22
26
  .replace(/ +/g, ' ')
@@ -67,6 +71,18 @@ export const FF_LogToConsole = (duration, query, args, options) => {
67
71
  listArgs.push(s[i - 2].replaceAll('"', '') + ': ' + s[i]);
68
72
  }
69
73
  }
74
+ const toFilterOut = options?.tablesToHide ?? [
75
+ ['information_Schema.tables'],
76
+ ['information_schema.columns'],
77
+ // ['__remult_migrations_version'],
78
+ ['ff_auth.accounts'],
79
+ ['ff_auth.users'],
80
+ ['ff_auth.users_sessions'],
81
+ ['_ff_change_logs'],
82
+ ];
83
+ const toHide = toFilterOut.some((item) => item.every((i) => tables.map((c) => c.replaceAll('"', '')).includes(i)));
84
+ if (toHide)
85
+ return;
70
86
  const final_s = s.join(' ').replace(/ +/g, ' ');
71
87
  // args replace
72
88
  // const listArgs = []
@@ -79,7 +95,8 @@ export const FF_LogToConsole = (duration, query, args, options) => {
79
95
  const subTables = uniqueTables.slice(0, -1);
80
96
  const time = ` ${bgCyan((duration * 1000).toFixed(0).padStart(3) + ' ms ')}`;
81
97
  let toLog = '';
82
- if (options?.withDetails) {
98
+ const withDetails = options?.withDetails === undefined ? true : options?.withDetails;
99
+ if (withDetails) {
83
100
  toLog = `${typeQuery.get(first) || '💢'}` + time + ` ${final_s}`;
84
101
  }
85
102
  else {
@@ -90,20 +107,9 @@ export const FF_LogToConsole = (duration, query, args, options) => {
90
107
  `${listArgs.length > 0 ? ` { ${listArgs.join(', ')} }` : ``}` +
91
108
  `${subTables.length > 0 ? magenta(` (sub: ${subTables.join(', ')})`) : ``}`;
92
109
  }
93
- const toFilterOut = options?.tablesToHide ?? [
94
- ['__remult_migrations_version'],
95
- ['information_Schema.tables'],
96
- ['information_schema.columns'],
97
- ['ff_auth.accounts'],
98
- ['ff_auth.users'],
99
- ['ff_auth.users_sessions'],
100
- ['_ff_change_logs'],
101
- ];
102
- const OnoOfFiltered = toFilterOut.some((item) => item.every((i) => tables.map((c) => c.replaceAll('"', '')).includes(i)));
103
- if (!OnoOfFiltered) {
104
- // console.log(`toLogLong`, toLogLong)
105
- log.info(toLog);
106
- return toLog;
110
+ log.info(toLog);
111
+ if (options?.ending) {
112
+ options.ending(duration, query, args, tables);
107
113
  }
114
+ return toLog;
108
115
  };
109
- const log = new Log('');
@@ -1,40 +1,39 @@
1
- import type { Handle, RequestEvent } from '@sveltejs/kit';
1
+ import type { RequestEvent } from '@sveltejs/kit';
2
2
  import { type ClassType } from 'remult';
3
3
  import type { RemultServerOptions } from 'remult/server';
4
- import { type MailOptions } from '../mail';
5
- export type Module = {
4
+ import { Log } from '@kitql/helpers';
5
+ type ModuleInput = {
6
6
  /**
7
7
  * The name of the module (usefull for logging and debugging purposes)
8
8
  */
9
9
  name: string;
10
- index?: number;
10
+ priority?: number;
11
11
  entities?: ClassType<any>[];
12
12
  controllers?: ClassType<any>[];
13
13
  initApi?: RemultServerOptions<RequestEvent>['initApi'];
14
14
  initRequest?: RemultServerOptions<RequestEvent>['initRequest'];
15
- handlePreRemult?: Handle;
16
- handlePosRemult?: Handle;
17
- earlyReturn?: (input: Parameters<Handle>[0]) => Promise<{
18
- early: false;
19
- resolve?: undefined;
20
- } | {
21
- early: true;
22
- resolve: ReturnType<Handle>;
23
- }>;
24
15
  modules?: Module[];
25
16
  };
26
- type Options = Omit<RemultServerOptions<RequestEvent<Partial<Record<string, string>>, string | null>> & {
17
+ export declare class Module {
18
+ name: string;
19
+ log: Log;
20
+ priority?: number;
21
+ entities?: ClassType<any>[];
22
+ controllers?: ClassType<any>[];
23
+ initApi?: RemultServerOptions<RequestEvent>['initApi'];
24
+ initRequest?: RemultServerOptions<RequestEvent>['initRequest'];
25
+ modules?: Module[];
26
+ constructor(input: ModuleInput);
27
+ }
28
+ type Options = RemultServerOptions<RequestEvent<Partial<Record<string, string>>, string | null>> & {
27
29
  modules?: Module[] | undefined;
28
- mail?: MailOptions<any>;
29
- }, 'entities' | 'controllers' | 'initRequest' | 'initApi'>;
30
+ };
31
+ export declare let entities: ClassType<any>[];
30
32
  /**
31
33
  * it's basically `remultSveltekit` with the `modules` option
34
+ * @deprecated will be done directly in remult when modules will be in 😉
32
35
  */
33
- export declare const firstly: (o: Options) => {
34
- modulesSorted: Module[];
35
- entities: ClassType<any>[];
36
- server: import("remult/remult-sveltekit").RemultSveltekitServer;
37
- };
36
+ export declare const firstly: (o: Options) => import("remult/remult-sveltekit").RemultSveltekitServer;
38
37
  /**
39
38
  * Full flat and ordered list by index and concatenaining the modules name
40
39
  */
package/esm/api/index.js CHANGED
@@ -1,81 +1,93 @@
1
- import nodemailer from 'nodemailer';
2
- import { remult } from 'remult';
1
+ import {} from 'remult';
3
2
  import { remultSveltekit } from 'remult/remult-sveltekit';
4
3
  import { Log } from '@kitql/helpers';
5
4
  import { building } from '$app/environment';
6
- import { mailInit } from '../mail';
5
+ import { sveltekit } from '../sveltekit/server';
6
+ export class Module {
7
+ name;
8
+ log;
9
+ priority;
10
+ entities;
11
+ controllers;
12
+ initApi;
13
+ initRequest;
14
+ modules;
15
+ constructor(input) {
16
+ this.name = input.name;
17
+ this.log = new Log(`firstly | ${this.name}`);
18
+ this.priority = input.priority;
19
+ this.entities = input.entities;
20
+ this.controllers = input.controllers;
21
+ this.initApi = input.initApi;
22
+ this.initRequest = input.initRequest;
23
+ this.modules = input.modules;
24
+ }
25
+ }
26
+ export let entities = [];
7
27
  /**
8
28
  * it's basically `remultSveltekit` with the `modules` option
29
+ * @deprecated will be done directly in remult when modules will be in 😉
9
30
  */
10
31
  export const firstly = (o) => {
11
- const modulesSorted = modulesFlatAndOrdered(o.modules ?? []);
12
- const entities = modulesSorted.flatMap((m) => m.entities ?? []);
13
- mailInit(nodemailer, o.mail);
14
- return {
15
- modulesSorted: modulesSorted,
32
+ const modulesSorted = modulesFlatAndOrdered([
33
+ ...[...(o.modules ?? []), sveltekit()],
34
+ new Module({
35
+ name: 'default',
36
+ entities: o.entities ?? [],
37
+ controllers: o.controllers ?? [],
38
+ initRequest: o.initRequest,
39
+ initApi: o.initApi,
40
+ }),
41
+ ]);
42
+ entities = modulesSorted.flatMap((m) => m.entities ?? []);
43
+ return remultSveltekit({
44
+ // Changing the default default of remult
45
+ logApiEndPoints: false,
46
+ admin: true,
47
+ defaultGetLimit: 25,
48
+ error: o.error
49
+ ? o.error
50
+ : async (e) => {
51
+ // REMULT P2: validation error should probably be 409
52
+ // if 400 we move to 409
53
+ if (e.httpStatusCode == 400) {
54
+ e.sendError(409, e.responseBody);
55
+ }
56
+ },
57
+ // Add user configuration
58
+ ...o,
59
+ // Module part
16
60
  entities,
17
- server: remultSveltekit({
18
- // Changing the default default of remult
19
- logApiEndPoints: false,
20
- admin: true,
21
- defaultGetLimit: 25,
22
- error: o.error
23
- ? o.error
24
- : async (e) => {
25
- // REMULT P2: validation error should probably be 409
26
- // if 400 we move to 409
27
- if (e.httpStatusCode == 400) {
28
- e.sendError(409, e.responseBody);
61
+ controllers: modulesSorted.flatMap((m) => m.controllers ?? []),
62
+ initRequest: async (kitEvent, op) => {
63
+ for (let i = 0; i < modulesSorted.length; i++) {
64
+ const f = modulesSorted[i].initRequest;
65
+ if (f) {
66
+ try {
67
+ await f(kitEvent, op);
29
68
  }
30
- },
31
- // Add user configuration
32
- ...o,
33
- // Module part
34
- entities,
35
- controllers: modulesSorted.flatMap((m) => m.controllers ?? []),
36
- initRequest: async (kitEvent, op) => {
37
- // usefull for later...
38
- remult.context.url = kitEvent.url;
39
- remult.context.setHeaders = (headers) => {
40
- kitEvent.setHeaders(headers);
41
- };
42
- remult.context.setCookie = (name, value, opts) => {
43
- kitEvent.cookies.set(name, value, opts);
44
- };
45
- remult.context.deleteCookie = (name, opts) => {
46
- kitEvent.cookies.delete(name, opts);
47
- };
69
+ catch (error) {
70
+ modulesSorted[i].log.error(error);
71
+ }
72
+ }
73
+ }
74
+ },
75
+ initApi: async (r) => {
76
+ if (!building) {
48
77
  for (let i = 0; i < modulesSorted.length; i++) {
49
- const f = modulesSorted[i].initRequest;
78
+ const f = modulesSorted[i].initApi;
50
79
  if (f) {
51
80
  try {
52
- await f(kitEvent, op);
81
+ await f(r);
53
82
  }
54
83
  catch (error) {
55
- const log = new Log(`firstly | ${modulesSorted[i].name}`);
56
- log.error(error);
57
- }
58
- }
59
- }
60
- },
61
- initApi: async (r) => {
62
- if (!building) {
63
- for (let i = 0; i < modulesSorted.length; i++) {
64
- const f = modulesSorted[i].initApi;
65
- if (f) {
66
- try {
67
- await f(r);
68
- }
69
- catch (error) {
70
- const log = new Log(`firstly | ${modulesSorted[i].name}`);
71
- log.error(error);
72
- }
84
+ modulesSorted[i].log.error(error);
73
85
  }
74
86
  }
75
87
  }
76
- },
77
- }),
78
- };
88
+ }
89
+ },
90
+ });
79
91
  };
80
92
  /**
81
93
  * Full flat and ordered list by index and concatenaining the modules name
@@ -92,6 +104,6 @@ export const modulesFlatAndOrdered = (modules) => {
92
104
  }, []);
93
105
  };
94
106
  const flatModules = flattenModules(modules);
95
- flatModules.sort((a, b) => (a.index || 0) - (b.index || 0));
107
+ flatModules.sort((a, b) => (a.priority || 0) - (b.priority || 0));
96
108
  return flatModules;
97
109
  };
@@ -1,25 +1,18 @@
1
- import type { AuthorizationURLOptions } from '..';
2
- export declare class Auth {
3
- /** DO NOT USE */
4
- static signOutFn: any;
5
- /** DO NOT USE */
6
- static signInDemoFn: any;
7
- /** DO NOT USE */
8
- static inviteFn: any;
9
- /** DO NOT USE */
10
- static signUpPasswordFn: any;
11
- /** DO NOT USE */
12
- static signInPasswordFn: any;
13
- /** DO NOT USE */
14
- static forgotPasswordFn: any;
15
- /** DO NOT USE */
16
- static resetPasswordFn: any;
17
- /** DO NOT USE */
18
- static signInOTPFn: any;
19
- /** DO NOT USE */
20
- static verifyOtpFn: any;
21
- /** DO NOT USE */
22
- static signInOAuthGetUrlFn: any;
1
+ import type { ProviderConfigured } from './server/module';
2
+ export declare class AuthController {
3
+ #private;
4
+ static _setAbstraction(impl: {
5
+ signOut: any;
6
+ signInDemo: any;
7
+ invite: any;
8
+ signUpPassword: any;
9
+ signInPassword: any;
10
+ forgotPassword: any;
11
+ resetPassword: any;
12
+ signInOTP: any;
13
+ verifyOtp: any;
14
+ signInOAuthGetUrl: any;
15
+ }): void;
23
16
  /**
24
17
  * Sign out the current user
25
18
  */
@@ -54,7 +47,7 @@ export declare class Auth {
54
47
  /**
55
48
  * Verify the OTP code
56
49
  */
57
- static verifyOtp(email: string, otp: string | number): Promise<any>;
50
+ static verifyOtp(email: string, otp: string): Promise<any>;
58
51
  /** OAUTH */
59
52
  /**
60
53
  * The the url to redirect to for the OAuth provider
@@ -68,9 +61,9 @@ export declare class Auth {
68
61
  *
69
62
  * _(popup example should work too, and a nice example/componant would be appreciated)_
70
63
  */
71
- static signInOAuthGetUrl<T extends keyof AuthorizationURLOptions>(o: {
64
+ static signInOAuthGetUrl<T extends keyof ProviderConfigured>(o: {
72
65
  provider: T;
73
- options?: AuthorizationURLOptions[T];
66
+ options?: ProviderConfigured[T];
74
67
  redirect?: string;
75
68
  }): Promise<any>;
76
69
  }
@@ -4,81 +4,85 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { Allow, BackendMethod } from 'remult';
8
- export class Auth {
9
- // Do not show for firstly users ?
10
- /** DO NOT USE */
11
- static signOutFn;
12
- /** DO NOT USE */
13
- static signInDemoFn;
14
- /** DO NOT USE */
15
- static inviteFn;
16
- /** DO NOT USE */
17
- static signUpPasswordFn;
18
- /** DO NOT USE */
19
- static signInPasswordFn;
20
- /** DO NOT USE */
21
- static forgotPasswordFn;
22
- /** DO NOT USE */
23
- static resetPasswordFn;
24
- /** DO NOT USE */
25
- static signInOTPFn;
26
- /** DO NOT USE */
27
- static verifyOtpFn;
28
- /** DO NOT USE */
29
- static signInOAuthGetUrlFn;
7
+ import { BackendMethod } from 'remult';
8
+ import { FF_Role_Auth } from './Entities';
9
+ export class AuthController {
10
+ // Private static fields
11
+ static #signOutFn;
12
+ static #signInDemoFn;
13
+ static #inviteFn;
14
+ static #signUpPasswordFn;
15
+ static #signInPasswordFn;
16
+ static #forgotPasswordFn;
17
+ static #resetPasswordFn;
18
+ static #signInOTPFn;
19
+ static #verifyOtpFn;
20
+ static #signInOAuthGetUrlFn;
21
+ // Internal setter method that can be used by the module
22
+ static _setAbstraction(impl) {
23
+ this.#signOutFn = impl.signOut;
24
+ this.#signInDemoFn = impl.signInDemo;
25
+ this.#inviteFn = impl.invite;
26
+ this.#signUpPasswordFn = impl.signUpPassword;
27
+ this.#signInPasswordFn = impl.signInPassword;
28
+ this.#forgotPasswordFn = impl.forgotPassword;
29
+ this.#resetPasswordFn = impl.resetPassword;
30
+ this.#signInOTPFn = impl.signInOTP;
31
+ this.#verifyOtpFn = impl.verifyOtp;
32
+ this.#signInOAuthGetUrlFn = impl.signInOAuthGetUrl;
33
+ }
30
34
  /**
31
35
  * Sign out the current user
32
36
  */
33
37
  static async signOut() {
34
- return await Auth.signOutFn();
38
+ return await AuthController.#signOutFn();
35
39
  }
36
40
  /**
37
41
  * Sign in with a demo account
38
42
  * _(The easiest way to demo & test your application)_
39
43
  */
40
44
  static async signInDemo(name) {
41
- return await Auth.signInDemoFn(name);
45
+ return await AuthController.#signInDemoFn(name);
42
46
  }
43
47
  /**
44
48
  * This is for login / password authentication Invite someone
45
49
  */
46
50
  static async invite(email) {
47
- return await Auth.inviteFn(email);
51
+ return await AuthController.#inviteFn(email);
48
52
  }
49
53
  /**
50
54
  * This is for login / password authentication SignUp
51
55
  */
52
56
  static async signUpPassword(email, password) {
53
- return await Auth.signUpPasswordFn(email, password);
57
+ return await AuthController.#signUpPasswordFn(email, password);
54
58
  }
55
59
  /**
56
60
  * This is for login / password authentication SignIn
57
61
  */
58
62
  static async signInPassword(email, password) {
59
- return await Auth.signInPasswordFn(email, password);
63
+ return await AuthController.#signInPasswordFn(email, password);
60
64
  }
61
65
  /**
62
66
  * Forgot your password ? Send a mail to reset it.
63
67
  */
64
68
  static async forgotPassword(email) {
65
- return await Auth.forgotPasswordFn(email);
69
+ return await AuthController.#forgotPasswordFn(email);
66
70
  }
67
71
  /**
68
72
  * Reset your password with a token
69
73
  */
70
74
  static async resetPassword(token, password) {
71
- return await Auth.resetPasswordFn(token, password);
75
+ return await AuthController.#resetPasswordFn(token, password);
72
76
  }
73
77
  /** OTP */
74
78
  static async signInOTP(email) {
75
- return await Auth.signInOTPFn(email);
79
+ return await AuthController.#signInOTPFn(email);
76
80
  }
77
81
  /**
78
82
  * Verify the OTP code
79
83
  */
80
84
  static async verifyOtp(email, otp) {
81
- return await Auth.verifyOtpFn(email, otp);
85
+ return await AuthController.#verifyOtpFn(email, otp);
82
86
  }
83
87
  /** OAUTH */
84
88
  /**
@@ -94,36 +98,36 @@ export class Auth {
94
98
  * _(popup example should work too, and a nice example/componant would be appreciated)_
95
99
  */
96
100
  static async signInOAuthGetUrl(o) {
97
- return await Auth.signInOAuthGetUrlFn(o);
101
+ return await AuthController.#signInOAuthGetUrlFn(o);
98
102
  }
99
103
  }
100
104
  __decorate([
101
105
  BackendMethod({ allowed: true })
102
- ], Auth, "signOut", null);
106
+ ], AuthController, "signOut", null);
103
107
  __decorate([
104
108
  BackendMethod({ allowed: true })
105
- ], Auth, "signInDemo", null);
109
+ ], AuthController, "signInDemo", null);
106
110
  __decorate([
107
- BackendMethod({ allowed: Allow.authenticated })
108
- ], Auth, "invite", null);
111
+ BackendMethod({ allowed: FF_Role_Auth.FF_Role_Auth_Invite })
112
+ ], AuthController, "invite", null);
109
113
  __decorate([
110
114
  BackendMethod({ allowed: true })
111
- ], Auth, "signUpPassword", null);
115
+ ], AuthController, "signUpPassword", null);
112
116
  __decorate([
113
117
  BackendMethod({ allowed: true })
114
- ], Auth, "signInPassword", null);
118
+ ], AuthController, "signInPassword", null);
115
119
  __decorate([
116
120
  BackendMethod({ allowed: true })
117
- ], Auth, "forgotPassword", null);
121
+ ], AuthController, "forgotPassword", null);
118
122
  __decorate([
119
123
  BackendMethod({ allowed: true })
120
- ], Auth, "resetPassword", null);
124
+ ], AuthController, "resetPassword", null);
121
125
  __decorate([
122
126
  BackendMethod({ allowed: true })
123
- ], Auth, "signInOTP", null);
127
+ ], AuthController, "signInOTP", null);
124
128
  __decorate([
125
129
  BackendMethod({ allowed: true })
126
- ], Auth, "verifyOtp", null);
130
+ ], AuthController, "verifyOtp", null);
127
131
  __decorate([
128
132
  BackendMethod({ allowed: true })
129
- ], Auth, "signInOAuthGetUrl", null);
133
+ ], AuthController, "signInOAuthGetUrl", null);
@@ -1,7 +1,8 @@
1
- import { BaseEnum } from '../..';
2
- import type { BaseEnumOptions } from '../..';
1
+ import { BaseEnum } from '..';
2
+ import type { BaseEnumOptions } from '..';
3
3
  export declare const FF_Role_Auth: {
4
- readonly Admin: "FF_Role_Auth.Admin";
4
+ readonly FF_Role_Auth_Admin: "FF_Role_Auth.Admin";
5
+ readonly FF_Role_Auth_Invite: "FF_Role_Auth.Invite";
5
6
  };
6
7
  export declare class FFAuthUser {
7
8
  id: string;