@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
package/package.json CHANGED
@@ -1,67 +1,139 @@
1
- {
2
- "name": "@ti-engine/web-framework",
3
- "version": "1.19.0",
4
- "description": "A web-framework based on the ti-engine. It provides a customizable ready-to-use web-server microservice and a set of tools for creating web applications. NOTICE: This is still a work in progress and the full architecture, design, and functionality are not available!",
5
- "author": "Boris Kostadinov <kostadinov.boris@gmail.com>",
6
- "license": "GPL-3.0-or-later",
7
- "exports": {
8
- "./config-management": "./components/config-service.js",
9
- "./web-application": "./bin/web-app-manager.js",
10
- "./web-server": "./bin/web-server.js"
11
- },
12
- "imports": {
13
- "#admin-config-handlers": "./components/admin-config-handlers.js",
14
- "#auth-manager": "./components/auth-manager.js",
15
- "#authorization": "./components/authorization.js",
16
- "#config-change-notifier": "./components/config-change-notifier.js",
17
- "#config-registry": "./components/config-registry.js",
18
- "#config-service": "./components/config-service.js",
19
- "#config-store": "./components/config-store.js",
20
- "#session-store": "./components/session-store.js",
21
- "#user": "./components/user.js",
22
- "#web-app-manager": "./bin/web-app-manager.js",
23
- "#web-config-env": "./components/web-config-env.js",
24
- "#web-handlers": "./components/web-handlers.js",
25
- "#web-server": "./bin/web-server.js",
26
- "#web-server-config": "./bin/web-server.json"
27
- },
28
- "dependencies": {
29
- "@ti-engine/core": "*",
30
- "@alpinejs/csp": "^3.15.12",
31
- "htmx.org": "^2.0.10",
32
- "ajv": "^8.20.0",
33
- "cookie-parser": "^1.4.7",
34
- "express": "^5.2.1",
35
- "express-session": "^1.19.0",
36
- "helmet": "^8.3.0",
37
- "lodash": "^4.18.1",
38
- "openid-client": "^6.8.4"
39
- },
40
- "devDependencies": {
41
- },
42
- "files": [
43
- "bin/",
44
- "!bin/tls/**/*",
45
- "components/",
46
- ".env",
47
- "package.json",
48
- "README.md",
49
- "CHANGELOG.md"
50
- ],
51
- "repository": {
52
- "type": "git",
53
- "url": "git+https://github.com/Belleal/ti-engine.git",
54
- "directory": "packages/web-framework"
55
- },
56
- "bugs": {
57
- "url": "https://github.com/Belleal/ti-engine/issues"
58
- },
59
- "homepage": "https://github.com/Belleal/ti-engine/tree/master/packages/web-framework#readme",
60
- "engines": {
61
- "node": ">=20.0.0"
62
- },
63
- "scripts": {
64
- "postinstall": "node ./bin/build/post-install.js",
65
- "test": "node --test test/*.test.js"
66
- }
67
- }
1
+ {
2
+ "name": "@ti-engine/web-framework",
3
+ "version": "1.20.0",
4
+ "description": "A web-framework based on the ti-engine. It provides a customizable ready-to-use web-server microservice and a set of tools for creating web applications. NOTICE: This is still a work in progress and the full architecture, design, and functionality are not available!",
5
+ "keywords": [
6
+ "ti-engine",
7
+ "web-framework",
8
+ "express",
9
+ "microservices",
10
+ "htmx",
11
+ "alpinejs",
12
+ "openid-connect",
13
+ "csp"
14
+ ],
15
+ "author": "Boris Kostadinov <kostadinov.boris@gmail.com>",
16
+ "license": "GPL-3.0-or-later",
17
+ "exports": {
18
+ "./config-management": {
19
+ "types": "./types/components/config-service.d.ts",
20
+ "default": "./components/config-service.js"
21
+ },
22
+ "./web-application": {
23
+ "types": "./types/bin/web-app-manager.d.ts",
24
+ "default": "./bin/web-app-manager.js"
25
+ },
26
+ "./web-server": {
27
+ "types": "./types/bin/web-server.d.ts",
28
+ "default": "./bin/web-server.js"
29
+ },
30
+ "./definitions": {
31
+ "types": "./types/components/definitions.types.d.ts",
32
+ "default": "./components/definitions.types.js"
33
+ }
34
+ },
35
+ "imports": {
36
+ "#admin-config-handlers": {
37
+ "types": "./types/components/admin-config-handlers.d.ts",
38
+ "default": "./components/admin-config-handlers.js"
39
+ },
40
+ "#auth-manager": {
41
+ "types": "./types/components/auth-manager.d.ts",
42
+ "default": "./components/auth-manager.js"
43
+ },
44
+ "#authorization": {
45
+ "types": "./types/components/authorization.d.ts",
46
+ "default": "./components/authorization.js"
47
+ },
48
+ "#config-change-notifier": {
49
+ "types": "./types/components/config-change-notifier.d.ts",
50
+ "default": "./components/config-change-notifier.js"
51
+ },
52
+ "#config-registry": {
53
+ "types": "./types/components/config-registry.d.ts",
54
+ "default": "./components/config-registry.js"
55
+ },
56
+ "#config-service": {
57
+ "types": "./types/components/config-service.d.ts",
58
+ "default": "./components/config-service.js"
59
+ },
60
+ "#config-store": {
61
+ "types": "./types/components/config-store.d.ts",
62
+ "default": "./components/config-store.js"
63
+ },
64
+ "#definitions": {
65
+ "types": "./types/components/definitions.types.d.ts",
66
+ "default": "./components/definitions.types.js"
67
+ },
68
+ "#session-store": {
69
+ "types": "./types/components/session-store.d.ts",
70
+ "default": "./components/session-store.js"
71
+ },
72
+ "#user": {
73
+ "types": "./types/components/user.d.ts",
74
+ "default": "./components/user.js"
75
+ },
76
+ "#web-app-manager": {
77
+ "types": "./types/bin/web-app-manager.d.ts",
78
+ "default": "./bin/web-app-manager.js"
79
+ },
80
+ "#web-config-env": {
81
+ "types": "./types/components/web-config-env.d.ts",
82
+ "default": "./components/web-config-env.js"
83
+ },
84
+ "#web-handlers": {
85
+ "types": "./types/components/web-handlers.d.ts",
86
+ "default": "./components/web-handlers.js"
87
+ },
88
+ "#web-server": {
89
+ "types": "./types/bin/web-server.d.ts",
90
+ "default": "./bin/web-server.js"
91
+ },
92
+ "#web-server-config": "./bin/web-server.json"
93
+ },
94
+ "dependencies": {
95
+ "@alpinejs/csp": "^3.15.12",
96
+ "@ti-engine/core": "*",
97
+ "@types/express": "^5.0.6",
98
+ "@types/express-session": "^1.18.2",
99
+ "@types/node": "^24.10.1",
100
+ "ajv": "^8.20.0",
101
+ "cookie-parser": "^1.4.7",
102
+ "express": "^5.2.1",
103
+ "express-session": "^1.19.0",
104
+ "helmet": "^8.3.0",
105
+ "htmx.org": "^2.0.10",
106
+ "lodash": "^4.18.1",
107
+ "openid-client": "^6.8.4"
108
+ },
109
+ "devDependencies": {
110
+ "typescript": "^7.0.2"
111
+ },
112
+ "files": [
113
+ "bin/",
114
+ "!bin/tls/**/*",
115
+ "components/",
116
+ "types/",
117
+ ".env",
118
+ "package.json",
119
+ "README.md",
120
+ "CHANGELOG.md"
121
+ ],
122
+ "repository": {
123
+ "type": "git",
124
+ "url": "git+https://github.com/Belleal/ti-engine.git",
125
+ "directory": "packages/web-framework"
126
+ },
127
+ "bugs": {
128
+ "url": "https://github.com/Belleal/ti-engine/issues"
129
+ },
130
+ "homepage": "https://github.com/Belleal/ti-engine/tree/master/packages/web-framework#readme",
131
+ "engines": {
132
+ "node": ">=20.0.0"
133
+ },
134
+ "scripts": {
135
+ "postinstall": "node ./bin/build/post-install.js",
136
+ "test": "node --test test/*.test.js",
137
+ "build:types": "tsc -p tsconfig.types.json"
138
+ }
139
+ }
@@ -0,0 +1,194 @@
1
+ export = TiWebAppManager;
2
+ import type { TiSession } from "#definitions";
3
+ /**
4
+ * Gates the login-page authentication markup to the effective enabled methods. The login fragment delimits blocks
5
+ * with HTML-comment markers: `<!--ti-auth-method:METHOD-->…<!--/ti-auth-method-->` around each method's control
6
+ * (the `local` credentials form and each OpenID provider button), `<!--ti-auth-divider-->…<!--/ti-auth-divider-->`
7
+ * around the "or continue with" separator, `<!--ti-auth-social-->…<!--/ti-auth-social-->` around the SSO button
8
+ * group, and `<!--ti-auth-none-->…<!--/ti-auth-none-->` around a "no method configured" fallback. It removes the
9
+ * block for any method that is not enabled, drops the social group when no SSO provider is enabled, shows the
10
+ * divider only when a local form AND at least one SSO provider are both present, and shows the fallback only when
11
+ * nothing is enabled. Any remaining markers are stripped so clean HTML ships. Fragments without these markers
12
+ * (every non-login fragment) are returned unchanged.
13
+ *
14
+ * @param {string} html
15
+ * @param {string[]} [enabledMethods] The effective enabled authentication methods.
16
+ * @returns {string}
17
+ */
18
+ declare function applyAuthMethodVisibility(html: string, enabledMethods?: string[]): string;
19
+ /**
20
+ * A generic web application manager that handles the rendering and behavior of web application views. It is designed to be extended by specific web application
21
+ * managers for each web application you want to implement with the ti-engine web framework.
22
+ * <br/>
23
+ * NOTE: You should not instantiate this class directly. Instead, extend it and override the abstract methods as needed. Additionally, you should configure your
24
+ * ti-engine web server 'TiWebApplicationConfig' settings by specifying the 'classPath' that corresponds to your web application manager. The path should be
25
+ * relative to the intended process's working directory.
26
+ *
27
+ * @class TiWebAppManager
28
+ * @abstract
29
+ * @public
30
+ */
31
+ declare class TiWebAppManager {
32
+ #private;
33
+ /**
34
+ * @constructor
35
+ * @param {string} identifier The identifier for this web application. Should be unique and recognizable.
36
+ * @throws {TiException.E_GEN_ABSTRACT_CLASS_INIT} If this class is instantiated directly.
37
+ */
38
+ constructor(identifier: string);
39
+ /**
40
+ * Returns the identifier for this web application.
41
+ *
42
+ * @property
43
+ * @returns {string}
44
+ * @public
45
+ */
46
+ get webAppIdentifier(): string;
47
+ /**
48
+ * Adds a new HTML fragment to the web application.
49
+ * <br/>
50
+ * NOTE: This method should only be called during the initialization phase of your web application manager.
51
+ *
52
+ * @method
53
+ * @param {string} identifier
54
+ * @param {Object} fragment The fragment descriptor (`{ title, path, components }`). May also carry an optional
55
+ * `roles` array (`Array<string|number>`): when present, the default {@link TiWebAppManager#verifyAccess} serves
56
+ * the fragment only to sessions holding at least one of those roles; omit it (or leave empty) for a public screen.
57
+ * @throws {TiException.E_GEN_UNALLOWED_OVERRIDE} If a fragment with the same identifier already exists.
58
+ * @public
59
+ */
60
+ addFragment(identifier: string, fragment: Object): void;
61
+ /**
62
+ * Registers an editable configuration document with the framework config registry (JSON Schema + semantic
63
+ * validators + default value + editor metadata). Call during initialization. See {@link ConfigRegistry#register}.
64
+ *
65
+ * @method
66
+ * @param {string} configKey
67
+ * @param {Object} definition
68
+ * @returns {TiWebAppManager} this (chainable)
69
+ * @public
70
+ */
71
+ registerConfigDocument(configKey: string, definition: Object): TiWebAppManager;
72
+ /**
73
+ * Registers a JSON Schema that is referenced (via `$ref`) by config-document schemas but is not itself a document.
74
+ *
75
+ * @method
76
+ * @param {Object} schema
77
+ * @returns {TiWebAppManager} this (chainable)
78
+ * @public
79
+ */
80
+ registerConfigSchema(schema: Object): TiWebAppManager;
81
+ /**
82
+ * Registers a composite (entity) editor with the framework config service — a `compose(docs)`/`decompose(edited,docs)`
83
+ * pair over one or more documents. Call during initialization. See {@link ConfigService#registerEditor}.
84
+ *
85
+ * @method
86
+ * @param {string} editorKey
87
+ * @param {Object} definition
88
+ * @returns {TiWebAppManager} this (chainable)
89
+ * @public
90
+ */
91
+ registerConfigEditor(editorKey: string, definition: Object): TiWebAppManager;
92
+ /**
93
+ * Used to clear the static file cache. This is useful for testing purposes to ensure that the web server is always serving fresh content.
94
+ *
95
+ * @method
96
+ * @public
97
+ */
98
+ clearStaticFileCache(): void;
99
+ /**
100
+ * Sets the effective enabled authentication methods used to gate login-page provider buttons. The web server
101
+ * calls this at startup, after the auth manager has dropped any enabled-but-unconfigured OpenID providers.
102
+ *
103
+ * @method
104
+ * @param {string[]} methods
105
+ * @public
106
+ */
107
+ setEnabledAuthMethods(methods: string[]): void;
108
+ /**
109
+ * Optional HTML transformation hook.
110
+ * <br/>
111
+ * NOTE: Override in subclasses to add nonces or other dynamic data to outgoing HTML.
112
+ *
113
+ * @method
114
+ * @param {string} html
115
+ * @param {Object} [options]
116
+ * @param {string} [options.csrfToken] Optional CSRF token to inject into the HTML.
117
+ * @param {boolean} [options.isHome] Optional flag to indicate whether the requested route is the home page.
118
+ * @param {string} [options.nonce] Optional CSP nonce to inject into inline scripts/styles.
119
+ * @param {string} [options.title] Optional title to replace the placeholder in the HTML.
120
+ * @returns {Promise<string>}
121
+ * @virtual
122
+ * @public
123
+ */
124
+ transformHtml(html: string, options?: {
125
+ csrfToken?: string;
126
+ isHome?: boolean;
127
+ nonce?: string;
128
+ title?: string;
129
+ }): Promise<string>;
130
+ /**
131
+ * Used to assemble the complete HTML view for the requested route, including nested HTML fragments.
132
+ *
133
+ * @method
134
+ * @param {TiSession} session
135
+ * @param {string[]} staticContentPaths
136
+ * @param {string} route
137
+ * @param {Object} [options]
138
+ * @param {string} [options.csrfToken] Optional CSRF token to inject into the HTML.
139
+ * @param {boolean} [options.isPartial] Optional flag to indicate whether the requested route is a partial load of a fragment.
140
+ * @param {string} [options.view] Optional view name to load within this route.
141
+ * @param {string} [options.nonce] Optional CSP nonce to inject into inline scripts/styles.
142
+ * @returns {Promise<string>}
143
+ * @public
144
+ */
145
+ assembleHtmlView(session: TiSession, staticContentPaths: string[], route: string, options?: {
146
+ csrfToken?: string;
147
+ isPartial?: boolean;
148
+ view?: string;
149
+ nonce?: string;
150
+ }): Promise<string>;
151
+ /**
152
+ * Used to process a request for a data resource.
153
+ *
154
+ * @method
155
+ * @param {TiSession} session
156
+ * @param {string} view
157
+ * @param {Object} [options]
158
+ * @returns {Promise<Object>}
159
+ * @virtual
160
+ * @public
161
+ */
162
+ processDataRequest(session: TiSession, view: string, options?: Object): Promise<Object>;
163
+ /**
164
+ * Used to process an application service request.
165
+ *
166
+ * @method
167
+ * @param {TiSession} session
168
+ * @param {string} service
169
+ * @param {Object} params
170
+ * @returns {Promise<Object>}
171
+ * @virtual
172
+ * @public
173
+ */
174
+ processServiceRequest(session: TiSession, service: string, params: Object): Promise<Object>;
175
+ /**
176
+ * Used to verify whether the current user has access to the requested resource. The default implementation gates
177
+ * HTML fragments by their declared `roles`: a fragment registered via {@link TiWebAppManager#addFragment} with a
178
+ * `roles` array is served only to sessions holding at least one of those roles (see {@link addFragment}); a
179
+ * fragment with no `roles` is public to any authenticated user. This makes role-restricted screens unreachable by
180
+ * direct URL, not merely hidden in the UI. Override in subclasses only to implement additional/alternative checks.
181
+ *
182
+ * @method
183
+ * @virtual
184
+ * @param {TiSession} session
185
+ * @param {Object} resource The fragment descriptor; its optional `resource.roles` lists the roles permitted to load it.
186
+ * @returns {Promise}
187
+ * @exception {TiException.E_SEC_UNAUTHORIZED_ACCESS} (403) When the session holds none of the fragment's required roles.
188
+ * @public
189
+ */
190
+ verifyAccess(session: TiSession, resource: Object): Promise<any>;
191
+ }
192
+ declare namespace TiWebAppManager {
193
+ export { applyAuthMethodVisibility };
194
+ }