@ti-engine/web-framework 1.19.0 → 1.20.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 (52) hide show
  1. package/.env +4 -4
  2. package/CHANGELOG.md +384 -353
  3. package/README.md +73 -73
  4. package/bin/build/post-install.js +18 -18
  5. package/bin/localization/web-server-labels.json +27 -27
  6. package/bin/static/.well-known/appspecific/com.chrome.devtools.json +5 -5
  7. package/bin/static/fragments/components/component-notification-bar.html +21 -21
  8. package/bin/static/fragments/components/component-sidebar.html +33 -33
  9. package/bin/static/fragments/components/component-tooltip.html +10 -10
  10. package/bin/static/fragments/components/component-topbar.html +5 -5
  11. package/bin/static/fragments/frame-administration.html +2 -2
  12. package/bin/static/fragments/frame-application.html +18 -18
  13. package/bin/static/fragments/frame-dashboard.html +2 -2
  14. package/bin/static/fragments/frame-login.html +119 -119
  15. package/bin/static/fragments/frame-not-found.html +2 -2
  16. package/bin/static/fragments/frame-profile.html +2 -2
  17. package/bin/static/index.html +22 -22
  18. package/bin/static/scripts/ti-charts.js +1591 -1591
  19. package/bin/static/scripts/ti-framework.css +3194 -3194
  20. package/bin/static/scripts/ti-framework.js +1427 -1427
  21. package/bin/static/scripts/ti-theme-black-glass.css +216 -216
  22. package/bin/static/scripts/ti-theme-daylight.css +87 -87
  23. package/bin/web-app-manager.js +660 -663
  24. package/bin/web-server.js +936 -937
  25. package/bin/web-server.json +48 -48
  26. package/components/admin-config-handlers.js +95 -92
  27. package/components/auth-manager.js +438 -442
  28. package/components/authorization.js +135 -135
  29. package/components/config-change-notifier.js +98 -98
  30. package/components/config-registry.js +257 -260
  31. package/components/config-service.js +363 -360
  32. package/components/config-store.js +244 -246
  33. package/components/definitions.types.js +28 -26
  34. package/components/session-store.js +113 -110
  35. package/components/user.js +134 -132
  36. package/components/web-config-env.js +85 -85
  37. package/components/web-handlers.js +803 -800
  38. package/package.json +139 -67
  39. package/types/bin/web-app-manager.d.ts +194 -0
  40. package/types/bin/web-server.d.ts +373 -0
  41. package/types/components/admin-config-handlers.d.ts +11 -0
  42. package/types/components/auth-manager.d.ts +125 -0
  43. package/types/components/authorization.d.ts +54 -0
  44. package/types/components/config-change-notifier.d.ts +73 -0
  45. package/types/components/config-registry.d.ts +149 -0
  46. package/types/components/config-service.d.ts +218 -0
  47. package/types/components/config-store.d.ts +128 -0
  48. package/types/components/definitions.types.d.ts +31 -0
  49. package/types/components/session-store.d.ts +56 -0
  50. package/types/components/user.d.ts +83 -0
  51. package/types/components/web-config-env.d.ts +17 -0
  52. package/types/components/web-handlers.d.ts +23 -0
@@ -1,111 +1,114 @@
1
- /*
2
- * The ti-engine is an open source, free to use—both for personal and commercial projects—framework for the creation of microservice-based solutions using node.js.
3
- * Copyright © 2021-2025 Boris Kostadinov <kostadinov.boris@gmail.com>
4
- * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
5
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
6
- * You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
7
- */
8
-
9
- const cache = require( "@ti-engine/core/cache" );
10
- const logger = require( "@ti-engine/core/logger" );
11
- const exceptions = require( "@ti-engine/core/exceptions" );
12
- const _ = require( "lodash" );
13
- const session = require( "express-session" );
14
-
15
- // The name of the session store in the cache:
16
- const sessionStoreName = "ti:web:sessions";
17
-
18
- /**
19
- * A session store for the web server using the standard 'cache' module of the ti-engine.
20
- * <br/>
21
- * NOTE: This implementation is compatible with the 'express-session' module.
22
- *
23
- * @class SessionStore
24
- * @public
25
- */
26
- class SessionStore extends session.Store {
27
-
28
- /**
29
- * @constructor
30
- */
31
- constructor() {
32
- super();
33
- }
34
-
35
- /**
36
- * Used to store a user session in the cache.
37
- *
38
- * @method
39
- * @param {string} sessionID
40
- * @param {TiSession} session
41
- * @param {function( (Error|TiException|null)= )} callback
42
- * @public
43
- */
44
- set( sessionID, session, callback ) {
45
- cache.instance.hashSetField( sessionStoreName, sessionID, session ).then( () => {
46
- let expire = ( session.cookie && _.isNumber( session.cookie.maxAge ) ) ? session.cookie.maxAge / 1000 : null;
47
- return ( expire ) ? cache.instance.expireValue( sessionID, expire, sessionStoreName ) : null;
48
- } ).then( () => {
49
- callback();
50
- } ).catch( ( error ) => {
51
- logger.log( `Error while trying to store user session in cache!`, logger.logSeverity.ERROR, error );
52
- callback( exceptions.raise( error ) );
53
- } );
54
- }
55
-
56
- /**
57
- * Used to retrieve a user session from the cache.
58
- *
59
- * @method
60
- * @param {string} sessionID
61
- * @param {function( (Error|TiException|null)=, (TiSession)= )} callback
62
- * @public
63
- */
64
- get( sessionID, callback ) {
65
- cache.instance.hashGetField( sessionStoreName, sessionID ).then( ( session ) => {
66
- callback( null, session );
67
- } ).catch( ( error ) => {
68
- logger.log( `Error while trying to fetch user session from cache!`, logger.logSeverity.ERROR, error );
69
- callback( exceptions.raise( error ) );
70
- } );
71
- }
72
-
73
- /**
74
- * Used to remove a user session from the cache.
75
- *
76
- * @method
77
- * @param {string} sessionID
78
- * @param {function( (Error|TiException|null)= )} callback
79
- * @public
80
- */
81
- destroy( sessionID, callback ) {
82
- cache.instance.hashDeleteField( sessionStoreName, sessionID ).then( () => {
83
- callback();
84
- } ).catch( ( error ) => {
85
- logger.log( `Error while trying to remove user session from cache!`, logger.logSeverity.ERROR, error );
86
- callback( exceptions.raise( error ) );
87
- } );
88
- }
89
-
90
- /**
91
- * Used to update the expiration time of a user session in the cache.
92
- *
93
- * @method
94
- * @param {string} sessionID
95
- * @param {TiSession} session
96
- * @param {function( (Error|TiException|null)= )} callback
97
- * @public
98
- */
99
- touch( sessionID, session, callback ) {
100
- let expire = ( session.cookie && _.isNumber( session.cookie.maxAge ) ) ? session.cookie.maxAge / 1000 : null;
101
- cache.instance.expireValue( sessionID, expire, sessionStoreName ).then( () => {
102
- callback();
103
- } ).catch( ( error ) => {
104
- logger.log( `Error while trying to refresh user session expiration in cache!`, logger.logSeverity.ERROR, error );
105
- callback( exceptions.raise( error ) );
106
- } );
107
- }
108
-
109
- }
110
-
1
+ /*
2
+ * The ti-engine is an open source, free to use—both for personal and commercial projects—framework for the creation of microservice-based solutions using node.js.
3
+ * Copyright © 2021-2025 Boris Kostadinov <kostadinov.boris@gmail.com>
4
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
5
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
6
+ * You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
7
+ */
8
+
9
+ const cache = require( "@ti-engine/core/cache" );
10
+ const logger = require( "@ti-engine/core/logger" );
11
+ const exceptions = require( "@ti-engine/core/exceptions" );
12
+ const _ = require( "lodash" );
13
+ const session = require( "express-session" );
14
+
15
+ /** @import { SessionData } from "express-session" */
16
+ /** @import { TiException } from "@ti-engine/core/exceptions" */
17
+
18
+ // The name of the session store in the cache:
19
+ const sessionStoreName = "ti:web:sessions";
20
+
21
+ /**
22
+ * A session store for the web server using the standard 'cache' module of the ti-engine.
23
+ * <br/>
24
+ * NOTE: This implementation is compatible with the 'express-session' module.
25
+ *
26
+ * @class SessionStore
27
+ * @public
28
+ */
29
+ class SessionStore extends session.Store {
30
+
31
+ /**
32
+ * @constructor
33
+ */
34
+ constructor() {
35
+ super();
36
+ }
37
+
38
+ /**
39
+ * Used to store a user session in the cache.
40
+ *
41
+ * @method
42
+ * @param {string} sessionID
43
+ * @param {SessionData} session
44
+ * @param {(error?: Error|TiException|null) => void} callback
45
+ * @public
46
+ */
47
+ set( sessionID, session, callback ) {
48
+ cache.instance.hashSetField( sessionStoreName, sessionID, session ).then( () => {
49
+ let expire = ( session.cookie && _.isNumber( session.cookie.maxAge ) ) ? session.cookie.maxAge / 1000 : null;
50
+ return ( expire ) ? cache.instance.expireValue( sessionID, expire, sessionStoreName ) : null;
51
+ } ).then( () => {
52
+ callback();
53
+ } ).catch( ( error ) => {
54
+ logger.log( `Error while trying to store user session in cache!`, logger.logSeverity.ERROR, error );
55
+ callback( exceptions.raise( error ) );
56
+ } );
57
+ }
58
+
59
+ /**
60
+ * Used to retrieve a user session from the cache.
61
+ *
62
+ * @method
63
+ * @param {string} sessionID
64
+ * @param {(error?: Error|TiException|null, session?: SessionData|null) => void} callback
65
+ * @public
66
+ */
67
+ get( sessionID, callback ) {
68
+ cache.instance.hashGetField( sessionStoreName, sessionID ).then( ( session ) => {
69
+ callback( null, session );
70
+ } ).catch( ( error ) => {
71
+ logger.log( `Error while trying to fetch user session from cache!`, logger.logSeverity.ERROR, error );
72
+ callback( exceptions.raise( error ) );
73
+ } );
74
+ }
75
+
76
+ /**
77
+ * Used to remove a user session from the cache.
78
+ *
79
+ * @method
80
+ * @param {string} sessionID
81
+ * @param {(error?: Error|TiException|null) => void} callback
82
+ * @public
83
+ */
84
+ destroy( sessionID, callback ) {
85
+ cache.instance.hashDeleteField( sessionStoreName, sessionID ).then( () => {
86
+ callback();
87
+ } ).catch( ( error ) => {
88
+ logger.log( `Error while trying to remove user session from cache!`, logger.logSeverity.ERROR, error );
89
+ callback( exceptions.raise( error ) );
90
+ } );
91
+ }
92
+
93
+ /**
94
+ * Used to update the expiration time of a user session in the cache.
95
+ *
96
+ * @method
97
+ * @param {string} sessionID
98
+ * @param {SessionData} session
99
+ * @param {(error?: Error|TiException|null) => void} callback
100
+ * @public
101
+ */
102
+ touch( sessionID, session, callback ) {
103
+ let expire = ( session.cookie && _.isNumber( session.cookie.maxAge ) ) ? session.cookie.maxAge / 1000 : null;
104
+ cache.instance.expireValue( sessionID, expire, sessionStoreName ).then( () => {
105
+ callback();
106
+ } ).catch( ( error ) => {
107
+ logger.log( `Error while trying to refresh user session expiration in cache!`, logger.logSeverity.ERROR, error );
108
+ callback( exceptions.raise( error ) );
109
+ } );
110
+ }
111
+
112
+ }
113
+
111
114
  module.exports = SessionStore;
@@ -1,133 +1,135 @@
1
- /*
2
- * The ti-engine is an open source, free to use—both for personal and commercial projects—framework for the creation of microservice-based solutions using node.js.
3
- * Copyright © 2021-2025 Boris Kostadinov <kostadinov.boris@gmail.com>
4
- * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
5
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
6
- * You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
7
- */
8
-
9
- /**
10
- * Represents a user in the system.
11
- *
12
- * @class User
13
- * @public
14
- */
15
- class User {
16
-
17
- #userID;
18
- #username;
19
- #email;
20
- #name;
21
- #language;
22
- #roles;
23
- #permissions;
24
- #details;
25
-
26
- /**
27
- * @constructor
28
- * @param {Object} userData
29
- * @param {string} userData.userID
30
- * @param {string} [userData.username]
31
- * @param {string} [userData.email]
32
- * @param {string} [userData.name]
33
- * @param {TiLocalizationLanguage} [userData.language]
34
- * @param {string[]} [userData.roles]
35
- * @param {string[]} [userData.permissions]
36
- * @param {Object} [userData.details]
37
- */
38
- constructor( userData = {} ) {
39
- this.#userID = userData.userID;
40
- this.#username = userData.username;
41
- this.#email = userData.email;
42
- this.#name = userData.name;
43
- this.#language = userData.language;
44
- this.#roles = Array.isArray( userData.roles ) ? userData.roles : [];
45
- this.#permissions = Array.isArray( userData.permissions ) ? userData.permissions : [];
46
- this.#details = userData.details || {};
47
- }
48
-
49
- /**
50
- * @property
51
- * @returns {string}
52
- * @public
53
- */
54
- get userID() {
55
- return this.#userID;
56
- }
57
-
58
- /**
59
- * @property
60
- * @returns {string}
61
- * @public
62
- */
63
- get username() {
64
- return this.#username;
65
- }
66
-
67
- /**
68
- * @property
69
- * @returns {string}
70
- * @public
71
- */
72
- get email() {
73
- return this.#email;
74
- }
75
-
76
- /**
77
- * @property
78
- * @returns {string}
79
- * @public
80
- */
81
- get name() {
82
- return this.#name;
83
- }
84
-
85
- /**
86
- * @property
87
- * @returns {TiLocalizationLanguage}
88
- * @public
89
- */
90
- get language() {
91
- return this.#language;
92
- }
93
-
94
- /**
95
- * @method
96
- * @returns {*}
97
- * @public
98
- */
99
- getDetail( key ) {
100
- return this.#details[ key ];
101
- }
102
-
103
- /**
104
- * @method
105
- * @param {string} key
106
- * @param {*} value
107
- * @public
108
- */
109
- setDetail( key, value ) {
110
- this.#details[ key ] = value;
111
- }
112
-
113
- /**
114
- * @method
115
- * @returns {Object}
116
- * @public
117
- */
118
- asJSON() {
119
- return {
120
- userID: this.#userID,
121
- username: this.#username,
122
- email: this.#email,
123
- name: this.#name,
124
- language: this.#language,
125
- roles: this.#roles,
126
- permissions: this.#permissions,
127
- details: this.#details
128
- };
129
- }
130
-
131
- }
132
-
1
+ /*
2
+ * The ti-engine is an open source, free to use—both for personal and commercial projects—framework for the creation of microservice-based solutions using node.js.
3
+ * Copyright © 2021-2025 Boris Kostadinov <kostadinov.boris@gmail.com>
4
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
5
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
6
+ * You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
7
+ */
8
+
9
+ /** @import { TiLocalizationLanguage } from "@ti-engine/core/localization" */
10
+
11
+ /**
12
+ * Represents a user in the system.
13
+ *
14
+ * @class User
15
+ * @public
16
+ */
17
+ class User {
18
+
19
+ #userID;
20
+ #username;
21
+ #email;
22
+ #name;
23
+ #language;
24
+ #roles;
25
+ #permissions;
26
+ #details;
27
+
28
+ /**
29
+ * @constructor
30
+ * @param {Object} userData
31
+ * @param {string} userData.userID
32
+ * @param {string} [userData.username]
33
+ * @param {string} [userData.email]
34
+ * @param {string} [userData.name]
35
+ * @param {TiLocalizationLanguage} [userData.language]
36
+ * @param {string[]} [userData.roles]
37
+ * @param {string[]} [userData.permissions]
38
+ * @param {Object} [userData.details]
39
+ */
40
+ constructor( userData = {} ) {
41
+ this.#userID = userData.userID;
42
+ this.#username = userData.username;
43
+ this.#email = userData.email;
44
+ this.#name = userData.name;
45
+ this.#language = userData.language;
46
+ this.#roles = Array.isArray( userData.roles ) ? userData.roles : [];
47
+ this.#permissions = Array.isArray( userData.permissions ) ? userData.permissions : [];
48
+ this.#details = userData.details || {};
49
+ }
50
+
51
+ /**
52
+ * @property
53
+ * @returns {string}
54
+ * @public
55
+ */
56
+ get userID() {
57
+ return this.#userID;
58
+ }
59
+
60
+ /**
61
+ * @property
62
+ * @returns {string}
63
+ * @public
64
+ */
65
+ get username() {
66
+ return this.#username;
67
+ }
68
+
69
+ /**
70
+ * @property
71
+ * @returns {string}
72
+ * @public
73
+ */
74
+ get email() {
75
+ return this.#email;
76
+ }
77
+
78
+ /**
79
+ * @property
80
+ * @returns {string}
81
+ * @public
82
+ */
83
+ get name() {
84
+ return this.#name;
85
+ }
86
+
87
+ /**
88
+ * @property
89
+ * @returns {TiLocalizationLanguage}
90
+ * @public
91
+ */
92
+ get language() {
93
+ return this.#language;
94
+ }
95
+
96
+ /**
97
+ * @method
98
+ * @returns {*}
99
+ * @public
100
+ */
101
+ getDetail( key ) {
102
+ return this.#details[ key ];
103
+ }
104
+
105
+ /**
106
+ * @method
107
+ * @param {string} key
108
+ * @param {*} value
109
+ * @public
110
+ */
111
+ setDetail( key, value ) {
112
+ this.#details[ key ] = value;
113
+ }
114
+
115
+ /**
116
+ * @method
117
+ * @returns {Object}
118
+ * @public
119
+ */
120
+ asJSON() {
121
+ return {
122
+ userID: this.#userID,
123
+ username: this.#username,
124
+ email: this.#email,
125
+ name: this.#name,
126
+ language: this.#language,
127
+ roles: this.#roles,
128
+ permissions: this.#permissions,
129
+ details: this.#details
130
+ };
131
+ }
132
+
133
+ }
134
+
133
135
  module.exports = User;