firstly 0.0.15 → 0.0.16-next.0

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 (95) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/esm/ROUTES.d.ts +10 -2
  3. package/esm/ROUTES.js +5 -1
  4. package/esm/auth/Entities.js +1 -0
  5. package/esm/auth/server/handleAuth.js +2 -1
  6. package/esm/auth/server/handleGuard.d.ts +10 -4
  7. package/esm/auth/server/handleGuard.js +8 -41
  8. package/esm/auth/server/module.d.ts +28 -0
  9. package/esm/auth/server/module.js +3 -0
  10. package/esm/auth/static/assets/{Page-B1GE_oYi.d.ts → Page-BgIgl-Te.d.ts} +2 -2
  11. package/esm/auth/static/assets/{Page-CDHFtYuN.js → Page-BgIgl-Te.js} +1 -1
  12. package/esm/auth/static/assets/{Page-Dh8pvAo6.d.ts → Page-HDnoBhpE.d.ts} +2 -2
  13. package/esm/auth/static/assets/{Page-Dh8pvAo6.js → Page-HDnoBhpE.js} +2 -2
  14. package/esm/auth/static/assets/{Page-CDHFtYuN.d.ts → Page-f5pC21Yg.d.ts} +2 -2
  15. package/esm/auth/static/assets/{Page-B1GE_oYi.js → Page-f5pC21Yg.js} +1 -1
  16. package/esm/auth/static/assets/{index-7Nh2ct-y.js → index-DAjei0Ie.js} +2 -2
  17. package/esm/auth/static/index.html +4 -4
  18. package/esm/auth/types.d.ts +1 -0
  19. package/esm/helper.d.ts +1 -1
  20. package/esm/helper.js +4 -3
  21. package/esm/index.d.ts +5 -3
  22. package/esm/index.js +5 -3
  23. package/esm/mail/server/index.js +2 -1
  24. package/esm/svelte/FF_Cell.svelte +104 -0
  25. package/esm/svelte/FF_Cell.svelte.d.ts +24 -0
  26. package/esm/svelte/FF_Cell_Caption.svelte +20 -0
  27. package/esm/svelte/FF_Cell_Caption.svelte.d.ts +24 -0
  28. package/esm/svelte/FF_Cell_Display.svelte +61 -0
  29. package/esm/svelte/FF_Cell_Display.svelte.d.ts +22 -0
  30. package/esm/svelte/FF_Cell_Edit.svelte +104 -0
  31. package/esm/svelte/FF_Cell_Edit.svelte.d.ts +25 -0
  32. package/esm/svelte/FF_Cell_Error.svelte +20 -0
  33. package/esm/svelte/FF_Cell_Error.svelte.d.ts +24 -0
  34. package/esm/svelte/FF_Cell_Hint.svelte +20 -0
  35. package/esm/svelte/FF_Cell_Hint.svelte.d.ts +24 -0
  36. package/esm/svelte/FF_Config.svelte +29 -0
  37. package/esm/svelte/FF_Config.svelte.d.ts +9 -0
  38. package/esm/svelte/FF_Display.svelte +51 -0
  39. package/esm/svelte/FF_Display.svelte.d.ts +22 -0
  40. package/esm/svelte/FF_Edit.svelte +104 -0
  41. package/esm/svelte/FF_Edit.svelte.d.ts +25 -0
  42. package/esm/svelte/FF_Error.svelte +23 -0
  43. package/esm/svelte/FF_Error.svelte.d.ts +22 -0
  44. package/esm/svelte/FF_Field.svelte +62 -0
  45. package/esm/svelte/FF_Field.svelte.d.ts +22 -0
  46. package/esm/svelte/FF_Form.svelte +156 -0
  47. package/esm/svelte/FF_Form.svelte.d.ts +30 -0
  48. package/esm/svelte/FF_Grid.svelte +257 -0
  49. package/esm/svelte/FF_Grid.svelte.d.ts +31 -0
  50. package/esm/svelte/FF_Hint.svelte +21 -0
  51. package/esm/svelte/FF_Hint.svelte.d.ts +22 -0
  52. package/esm/svelte/FF_Label.svelte +23 -0
  53. package/esm/svelte/FF_Label.svelte.d.ts +22 -0
  54. package/esm/svelte/FF_Layout.svelte +62 -0
  55. package/esm/svelte/FF_Layout.svelte.d.ts +24 -0
  56. package/esm/svelte/FF_Repo.svelte.d.ts +69 -0
  57. package/esm/svelte/FF_Repo.svelte.js +170 -0
  58. package/esm/svelte/actions/intersection.d.ts +6 -0
  59. package/esm/svelte/actions/intersection.js +17 -0
  60. package/esm/svelte/class/SP.svelte.d.ts +61 -0
  61. package/esm/svelte/class/SP.svelte.js +412 -0
  62. package/esm/svelte/customField.d.ts +69 -0
  63. package/esm/svelte/customField.js +4 -0
  64. package/esm/svelte/dialog/DialogManagement.svelte +101 -0
  65. package/esm/svelte/dialog/DialogManagement.svelte.d.ts +18 -0
  66. package/esm/svelte/dialog/DialogPrimitive.svelte +157 -0
  67. package/esm/svelte/dialog/DialogPrimitive.svelte.d.ts +38 -0
  68. package/esm/svelte/dialog/dialog.d.ts +58 -0
  69. package/esm/svelte/dialog/dialog.js +130 -0
  70. package/esm/svelte/ff_Config.svelte.d.ts +91 -0
  71. package/esm/svelte/ff_Config.svelte.js +111 -0
  72. package/esm/svelte/firstly.css +14 -0
  73. package/esm/svelte/helpers/debounce.d.ts +1 -0
  74. package/esm/svelte/helpers/debounce.js +7 -0
  75. package/esm/svelte/helpers.d.ts +29 -0
  76. package/esm/svelte/helpers.js +38 -0
  77. package/esm/svelte/index.d.ts +32 -0
  78. package/esm/svelte/index.js +29 -0
  79. package/esm/svelte/tryCatch.d.ts +12 -0
  80. package/esm/svelte/tryCatch.js +18 -0
  81. package/esm/ui/Field.svelte +1 -1
  82. package/esm/ui/Grid.svelte +8 -2
  83. package/esm/ui/Grid2.svelte +354 -0
  84. package/esm/ui/Grid2.svelte.d.ts +58 -0
  85. package/esm/ui/GridLoading.svelte +33 -8
  86. package/esm/ui/GridLoading.svelte.d.ts +1 -0
  87. package/esm/ui/GridPaginate.svelte +0 -3
  88. package/esm/ui/GridPaginate.svelte.d.ts +0 -1
  89. package/esm/ui/GridPaginate2.svelte +25 -0
  90. package/esm/ui/GridPaginate2.svelte.d.ts +7 -0
  91. package/esm/ui/dialog/dialog.d.ts +3 -1
  92. package/esm/ui/dialog/dialog.js +2 -0
  93. package/esm/ui/link/LinkPlus.svelte +8 -6
  94. package/package.json +17 -2
  95. /package/esm/auth/static/assets/{index-7Nh2ct-y.d.ts → index-DAjei0Ie.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # firstly
2
2
 
3
+ ## 0.0.16-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - [#102](https://github.com/jycouet/firstly/pull/102)
8
+ [`f0effb9`](https://github.com/jycouet/firstly/commit/f0effb9e2dfa3f1c3070bc27c498d7f1e1ed877d)
9
+ Thanks [@jycouet](https://github.com/jycouet)! - Prepare JYC 016
10
+
3
11
  ## 0.0.15
4
12
 
5
13
  ### Patch Changes
package/esm/ROUTES.d.ts CHANGED
@@ -33,7 +33,11 @@ declare const AllObjs: {
33
33
  }) => string;
34
34
  "/": string;
35
35
  "/auth": string;
36
- "/demo/task": string;
36
+ "/demo/FF_Cell": string;
37
+ "/demo/FF_Form_Grid": string;
38
+ "/demo/FF_Layout": string;
39
+ "/demo/FF_Layout/grid": string;
40
+ "/demo/FF_Simple": string;
37
41
  "/mail": string;
38
42
  "/ui/dialog": string;
39
43
  "/ui/enum": string;
@@ -72,7 +76,11 @@ export type KIT_ROUTES = {
72
76
  PAGES: {
73
77
  '/': never;
74
78
  '/auth': never;
75
- '/demo/task': never;
79
+ '/demo/FF_Cell': never;
80
+ '/demo/FF_Form_Grid': never;
81
+ '/demo/FF_Layout': never;
82
+ '/demo/FF_Layout/grid': never;
83
+ '/demo/FF_Simple': never;
76
84
  '/mail': never;
77
85
  '/ui/dialog': never;
78
86
  '/ui/enum': never;
package/esm/ROUTES.js CHANGED
@@ -10,7 +10,11 @@
10
10
  const PAGES = {
11
11
  "/": `/`,
12
12
  "/auth": `/auth`,
13
- "/demo/task": `/demo/task`,
13
+ "/demo/FF_Cell": `/demo/FF_Cell`,
14
+ "/demo/FF_Form_Grid": `/demo/FF_Form_Grid`,
15
+ "/demo/FF_Layout": `/demo/FF_Layout`,
16
+ "/demo/FF_Layout/grid": `/demo/FF_Layout/grid`,
17
+ "/demo/FF_Simple": `/demo/FF_Simple`,
14
18
  "/mail": `/mail`,
15
19
  "/ui/dialog": `/ui/dialog`,
16
20
  "/ui/enum": `/ui/enum`,
@@ -31,6 +31,7 @@ __decorate([
31
31
  ], FFAuthUser.prototype, "updatedAt", void 0);
32
32
  __decorate([
33
33
  Fields.string({
34
+ allowApiUpdate: false,
34
35
  validate: [
35
36
  Validators.unique(),
36
37
  Validators.required(),
@@ -31,7 +31,8 @@ export const handleAuth = async ({ event, resolve }) => {
31
31
  }
32
32
  if (oSafe.firstlyData.props.ui?.paths?.base &&
33
33
  event.url.pathname.startsWith(oSafe.firstlyData.props.ui.paths.base)) {
34
- const content = read(`${oSafe.uiStaticPath}index.html`);
34
+ let content = read(`${oSafe.uiStaticPath}index.html`) ?? '';
35
+ content = content?.replaceAll('<!--PLACE_HERE_HEAD-->', oSafe.ui?.customHtmlHead ?? '');
35
36
  return new Response(content + `<script>const firstlyData = ${JSON.stringify(oSafe.firstlyData)}</script>`, {
36
37
  headers: { 'content-type': 'text/html' },
37
38
  });
@@ -1,9 +1,15 @@
1
1
  import { type Handle } from '@sveltejs/kit';
2
2
  export type RouteGuardConfig = {
3
- anonymous?: string[];
4
- authenticated: string[];
5
- redirectToLogin: string;
6
- redirectAuthenticated: string;
3
+ /**
4
+ * Routes that require authentication (e.g. `{ path: '/app*' }`)
5
+ */
6
+ guard: {
7
+ path: string;
8
+ }[];
9
+ /**
10
+ * Where to redirect when authentication is required but user is not logged in
11
+ */
12
+ login: string;
7
13
  /**
8
14
  * We need this import
9
15
  *
@@ -1,67 +1,34 @@
1
1
  import {} from '@sveltejs/kit';
2
2
  import { remult } from 'remult';
3
- /**
4
- * Checks if a path matches a pattern that may include wildcards
5
- * @param path The actual path to check
6
- * @param pattern The pattern that may include wildcards (*)
7
- */
8
3
  function pathMatchesPattern(path, pattern) {
9
4
  // Convert the pattern to a regex
10
5
  const regexPattern = pattern.replace(/\//g, '\\/').replace(/\*/g, '.*');
11
6
  const regex = new RegExp(`^${regexPattern}$`);
12
7
  return regex.test(path);
13
8
  }
14
- /**
15
- * Checks if a path matches any of the patterns in the array
16
- */
17
9
  function pathMatchesAnyPattern(path, patterns) {
18
- return patterns.some((pattern) => pathMatchesPattern(path, pattern));
10
+ return patterns.some((pattern) => pathMatchesPattern(path, pattern.path));
19
11
  }
20
12
  /**
21
13
  * Creates a handle function with the provided route guard configuration
22
14
  */
23
15
  export function handleGuard(config) {
24
16
  return async ({ event, resolve }) => {
25
- const path = event.url.pathname;
26
- const fullUrl = event.url.pathname + event.url.search;
17
+ const pathname = event.url.pathname;
27
18
  const isAuthenticated = !!remult.user;
28
- // Check if the path is in the anonymous routes
29
- const isAnonymousRoute = config.anonymous ? pathMatchesAnyPattern(path, config.anonymous) : false;
30
- // Check if the path is in the authenticated routes
31
- const isAuthenticatedRoute = pathMatchesAnyPattern(path, config.authenticated);
32
- // Check if the current path is the login page
33
- const isLoginPage = path === config.redirectToLogin || path === config.redirectToLogin.replace(/\/$/, '');
34
- // Create login URL with redirect parameter
35
- const createLoginUrl = (returnUrl) => {
36
- const encodedReturnUrl = encodeURIComponent(returnUrl);
37
- const separator = config.redirectToLogin.includes('?') ? '&' : '?';
38
- return `${config.redirectToLogin}${separator}redirect=${encodedReturnUrl}`;
39
- };
40
- // Handle root path
41
- if (path === config.redirectToLogin) {
42
- if (isAuthenticated) {
43
- config.redirect(302, config.redirectAuthenticated);
44
- }
45
- else {
46
- // Only redirect if we're not already on the login page
47
- if (!isLoginPage) {
48
- config.redirect(302, config.redirectToLogin);
49
- }
50
- }
51
- }
19
+ const isAuthenticatedRoute = pathMatchesAnyPattern(pathname, config.guard);
52
20
  // If user is not authenticated and tries to access an authenticated route
53
21
  if (!isAuthenticated && isAuthenticatedRoute) {
54
22
  // Redirect to login with the current URL as the redirect target
55
23
  // Only redirect if we're not already on the login page
24
+ const isLoginPage = pathname === config.login || pathname === config.login.replace(/\/$/, '');
56
25
  if (!isLoginPage) {
57
- config.redirect(302, createLoginUrl(fullUrl));
26
+ const encodedReturnUrl = encodeURIComponent(pathname + event.url.search);
27
+ const separator = config.login.includes('?') ? '&' : '?';
28
+ const loginUrl = `${config.login}${separator}redirect=${encodedReturnUrl}`;
29
+ config.redirect(302, loginUrl);
58
30
  }
59
31
  }
60
- // If user is authenticated and tries to access an anonymous-only route
61
- // Only check if anonymous routes are defined
62
- if (config.anonymous && isAuthenticated && isAnonymousRoute) {
63
- config.redirect(302, config.redirectAuthenticated);
64
- }
65
32
  return resolve(event);
66
33
  };
67
34
  }
@@ -236,6 +236,34 @@ export declare const getSafeOptions: <TUserEntity extends FFAuthUser = FFAuthUse
236
236
  anErrorOccurred: string;
237
237
  cannotSignUp: string;
238
238
  };
239
+ ui: {
240
+ readonly paths: {
241
+ readonly base: string;
242
+ readonly sign_up: string | false;
243
+ readonly sign_in: string | false;
244
+ readonly forgot_password: string | false;
245
+ readonly reset_password: string | false;
246
+ readonly verify_email: string | false;
247
+ };
248
+ readonly strings: {
249
+ readonly app_name: string;
250
+ readonly email: string;
251
+ readonly email_placeholder: string;
252
+ readonly password: string;
253
+ readonly password_placeholder: string;
254
+ readonly confirm: string;
255
+ readonly reset: string;
256
+ readonly btn_sign_up: string;
257
+ readonly btn_sign_in: string;
258
+ readonly forgot_password: string;
259
+ readonly send_password_reset_instructions: string;
260
+ readonly back_to_sign_in: string;
261
+ };
262
+ readonly images: {
263
+ readonly main: string;
264
+ };
265
+ readonly customHtmlHead: string;
266
+ } | undefined;
239
267
  };
240
268
  export declare const authModuleRaw: Module;
241
269
  /**
@@ -53,6 +53,8 @@ export const getSafeOptions = () => {
53
53
  images: {
54
54
  main: AUTH_OPTIONS.ui?.images?.main ?? '',
55
55
  },
56
+ customHtmlHead: AUTH_OPTIONS.ui?.customHtmlHead ??
57
+ '<title>Auth</title><link rel="icon" href="https://firstly.fun/favicon.svg" />',
56
58
  };
57
59
  if (AUTH_OPTIONS.debug && !building) {
58
60
  authModuleRaw.log.info('ui', ui);
@@ -139,6 +141,7 @@ export const getSafeOptions = () => {
139
141
  cannotSignUp: AUTH_OPTIONS.strings?.cannotSignUp ??
140
142
  "You can't signup by yourself! Contact the administrator.",
141
143
  },
144
+ ui,
142
145
  };
143
146
  };
144
147
  export const authModuleRaw = new Module({
@@ -1,6 +1,6 @@
1
1
  export { a as default };
2
2
  declare function a(e: any, s: any): any;
3
3
  declare namespace a {
4
- let ______13020: string;
5
- export { ______13020 as __@$@13020 };
4
+ let ______17210: string;
5
+ export { ______17210 as __@$@17210 };
6
6
  }
@@ -1 +1 @@
1
- import{v as r,x as l,aa as o,J as m,K as p,M as u,O as d,P as f,R as g}from"./index-7Nh2ct-y.js";d();a[f]="src/lib/modules/storage/Page.svelte";function a(e,s){r(new.target),l(s,!1,a);var t=o("Hello from files");return m(e,t),p({...u()})}g(a);export{a as default};
1
+ import{v as r,x as l,aa as o,J as m,K as p,M as u,O as d,P as f,R as g}from"./index-DAjei0Ie.js";d();a[f]="src/lib/modules/storage/Page.svelte";function a(e,s){r(new.target),l(s,!1,a);var t=o("Hello from files");return m(e,t),p({...u()})}g(a);export{a as default};
@@ -1,6 +1,6 @@
1
1
  export { Q as default };
2
2
  declare function Q(n: any, e: any): any;
3
3
  declare namespace Q {
4
- let ______13020: string;
5
- export { ______13020 as __@$@13020 };
4
+ let ______17210: string;
5
+ export { ______17210 as __@$@17210 };
6
6
  }