webspresso 0.0.90 → 0.0.93
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.
- package/README.md +98 -2509
- package/bin/commands/admin-password.js +8 -2
- package/bin/commands/api.js +7 -1
- package/bin/commands/favicon-generate.js +6 -4
- package/bin/commands/mcp.js +162 -0
- package/bin/commands/new.js +7 -1
- package/bin/commands/page.js +7 -1
- package/bin/commands/seed.js +7 -1
- package/bin/commands/service.js +199 -0
- package/bin/commands/skill.js +7 -1
- package/bin/webspresso.js +4 -0
- package/core/auth/middleware.js +9 -0
- package/core/compileSchema.js +1 -5
- package/core/compression/compressible.js +63 -0
- package/core/compression/compression-stream.js +59 -0
- package/core/compression/index.js +25 -0
- package/core/compression/middleware.js +310 -0
- package/core/compression/negotiate.js +165 -0
- package/core/errors/base.js +31 -0
- package/core/errors/domain.js +193 -0
- package/core/errors/http.js +133 -0
- package/core/errors/index.js +77 -0
- package/core/errors/middleware.js +162 -0
- package/core/errors/normalize.js +171 -0
- package/core/kernel/app.js +2 -1
- package/core/kernel/index.js +5 -1
- package/core/orm/cache/fingerprint.js +23 -5
- package/core/orm/complexity.js +120 -0
- package/core/orm/eager-loader.js +54 -9
- package/core/orm/events.js +64 -14
- package/core/orm/index.js +83 -12
- package/core/orm/model.js +13 -2
- package/core/orm/query-builder.js +30 -4
- package/core/orm/repository.js +57 -25
- package/core/orm/transaction.js +39 -5
- package/core/orm/utils.js +6 -3
- package/core/queue/adapters/database.js +317 -0
- package/core/queue/adapters/memory.js +176 -0
- package/core/queue/adapters/redis.js +357 -0
- package/core/queue/index.js +21 -0
- package/core/queue/job.js +103 -0
- package/core/queue/manager.js +413 -0
- package/core/realtime/adapters/redis.js +431 -0
- package/core/realtime/adapters/socket-io.js +203 -0
- package/core/realtime/adapters/sse.js +210 -0
- package/core/realtime/adapters/websocket.js +337 -0
- package/core/realtime/auth-manager.js +140 -0
- package/core/realtime/core.js +359 -0
- package/core/realtime/emitter.js +98 -0
- package/core/realtime/errors.js +71 -0
- package/core/realtime/index.js +79 -0
- package/core/realtime/reconnect-manager.js +118 -0
- package/core/realtime/registry.js +243 -0
- package/core/shutdown/http-adapter.js +134 -0
- package/core/shutdown/index.js +12 -0
- package/core/shutdown/shutdown-manager.js +312 -0
- package/core/ssr/index.js +13 -0
- package/core/ssr/stream.js +174 -0
- package/core/validation/index.js +70 -0
- package/index.d.ts +924 -53
- package/index.js +110 -1
- package/package.json +30 -2
- package/plugins/admin-panel/api.js +37 -4
- package/plugins/admin-panel/app.js +57 -17
- package/plugins/admin-panel/client/parts/01-state-api-breadcrumb.js +10 -2
- package/plugins/admin-panel/client/parts/04-field-renderers.js +102 -58
- package/plugins/admin-panel/client/parts/05-rich-text-file-helpers.js +51 -27
- package/plugins/admin-panel/client/parts/07-model-list.js +9 -4
- package/plugins/admin-panel/client/parts/08-record-list.js +37 -26
- package/plugins/admin-panel/client/parts/09-record-form.js +168 -19
- package/plugins/admin-panel/core/admin-module.js +2 -2
- package/plugins/admin-panel/core/api-extensions.js +149 -0
- package/plugins/admin-panel/field-renderers/rich-text.js +3 -2
- package/plugins/admin-panel/index.js +155 -23
- package/plugins/admin-panel/modules/bulk-actions.js +9 -2
- package/plugins/admin-panel/modules/custom-pages.js +144 -45
- package/plugins/admin-panel/modules/dashboard.js +8 -1
- package/plugins/admin-panel/modules/menu.js +85 -0
- package/plugins/admin-panel/modules/user-management.js +5 -2
- package/plugins/admin-panel/vendor/mithril.min.js +1 -0
- package/plugins/admin-panel/vendor/quill.min.js +7 -0
- package/plugins/admin-panel/vendor/quill.snow.min.css +945 -0
- package/plugins/admin-panel/vendor/tailwind.min.js +65 -0
- package/plugins/basic-auth/index.js +293 -0
- package/plugins/data-exchange/export-xlsx.js +28 -2
- package/plugins/data-exchange/import.js +55 -16
- package/plugins/data-exchange/index.js +19 -0
- package/plugins/data-exchange/parse-table.js +14 -5
- package/plugins/data-exchange/record-selection.js +2 -0
- package/plugins/email/index.js +14 -1
- package/plugins/index.js +33 -0
- package/plugins/mcp/auth.js +104 -0
- package/plugins/mcp/discovery.js +88 -0
- package/plugins/mcp/index.js +208 -0
- package/plugins/mcp/prompts.js +149 -0
- package/plugins/mcp/providers/orm.js +325 -0
- package/plugins/mcp/providers/services.js +190 -0
- package/plugins/mcp/providers/system.js +87 -0
- package/plugins/mcp/server.js +472 -0
- package/plugins/mcp/transports/sse.js +139 -0
- package/plugins/mcp/transports/stdio.js +108 -0
- package/plugins/queue/index.js +108 -0
- package/plugins/realtime/index.js +150 -0
- package/plugins/recaptcha/index.js +11 -0
- package/plugins/redirect/index.js +9 -1
- package/plugins/rest-resources/index.js +280 -11
- package/plugins/upload/index.js +16 -0
- package/src/app-context.js +46 -6
- package/src/file-router.js +366 -130
- package/src/helpers.js +20 -2
- package/src/njk-frontmatter.js +24 -14
- package/src/plugin-manager.js +124 -4
- package/src/server.js +332 -54
- package/src/services/builtins/auth.js +273 -0
- package/src/services/builtins/exchange.js +229 -0
- package/src/services/builtins/mail.js +134 -0
- package/src/services/builtins/media.js +196 -0
- package/src/services/builtins/system.js +221 -0
- package/src/services/discovery.js +141 -0
- package/src/services/executor.js +292 -0
- package/src/services/index.js +70 -0
- package/src/services/memoize.js +256 -0
- package/src/services/registry.js +290 -0
- package/src/services/validator.js +230 -0
- package/templates/skills/webspresso-usage/REFERENCE-framework.md +6 -4
package/src/app-context.js
CHANGED
|
@@ -3,21 +3,23 @@
|
|
|
3
3
|
* @module src/app-context
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
/** @type {{ db: object|null }} */
|
|
6
|
+
/** @type {{ db: object|null, shutdownManager: object|null, serviceRegistry: object|null }} */
|
|
7
7
|
let context = {
|
|
8
8
|
db: null,
|
|
9
|
+
shutdownManager: null,
|
|
10
|
+
serviceRegistry: null,
|
|
9
11
|
};
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Merge into the current context (typically called once from createApp).
|
|
13
|
-
* @param {{ db?: object|null }} partial
|
|
15
|
+
* @param {{ db?: object|null, shutdownManager?: object|null, serviceRegistry?: object|null }} partial
|
|
14
16
|
*/
|
|
15
17
|
function setAppContext(partial) {
|
|
16
18
|
context = { ...context, ...partial };
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
|
-
* @returns {{ db: object|null }}
|
|
22
|
+
* @returns {{ db: object|null, shutdownManager: object|null, serviceRegistry: object|null }}
|
|
21
23
|
*/
|
|
22
24
|
function getAppContext() {
|
|
23
25
|
return context;
|
|
@@ -45,23 +47,57 @@ function hasDb() {
|
|
|
45
47
|
return context.db != null;
|
|
46
48
|
}
|
|
47
49
|
|
|
50
|
+
/**
|
|
51
|
+
* @returns {object|null}
|
|
52
|
+
*/
|
|
53
|
+
function getShutdownManager() {
|
|
54
|
+
return context.shutdownManager;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @returns {boolean}
|
|
59
|
+
*/
|
|
60
|
+
function hasShutdownManager() {
|
|
61
|
+
return context.shutdownManager != null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Get the registered ServiceRegistry instance
|
|
66
|
+
* @returns {object|null}
|
|
67
|
+
*/
|
|
68
|
+
function getServiceRegistry() {
|
|
69
|
+
return context.serviceRegistry;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Check if a ServiceRegistry is registered
|
|
74
|
+
* @returns {boolean}
|
|
75
|
+
*/
|
|
76
|
+
function hasServiceRegistry() {
|
|
77
|
+
return context.serviceRegistry != null;
|
|
78
|
+
}
|
|
79
|
+
|
|
48
80
|
/**
|
|
49
81
|
* Clear context (e.g. between tests).
|
|
50
82
|
*/
|
|
51
83
|
function resetAppContext() {
|
|
52
|
-
context = { db: null };
|
|
84
|
+
context = { db: null, shutdownManager: null, serviceRegistry: null };
|
|
53
85
|
}
|
|
54
86
|
|
|
55
87
|
/**
|
|
56
|
-
* Express middleware: sets `req.db` from registered app context.
|
|
88
|
+
* Express middleware: sets `req.db` and `req.service` from registered app context.
|
|
57
89
|
* File-based `pages/api/*` routes attach this automatically; use in `setupRoutes`
|
|
58
|
-
* for manually registered handlers that need `req.db`.
|
|
90
|
+
* for manually registered handlers that need `req.db` and `req.service`.
|
|
59
91
|
* @type {import('express').RequestHandler}
|
|
60
92
|
*/
|
|
61
93
|
function attachDbMiddleware(req, res, next) {
|
|
62
94
|
if (context.db != null) {
|
|
63
95
|
req.db = context.db;
|
|
64
96
|
}
|
|
97
|
+
if (context.serviceRegistry != null) {
|
|
98
|
+
req.service = (name, input, opts) =>
|
|
99
|
+
context.serviceRegistry.call(name, input, req.context || { req, res, db: context.db }, opts);
|
|
100
|
+
}
|
|
65
101
|
next();
|
|
66
102
|
}
|
|
67
103
|
|
|
@@ -70,6 +106,10 @@ module.exports = {
|
|
|
70
106
|
getAppContext,
|
|
71
107
|
getDb,
|
|
72
108
|
hasDb,
|
|
109
|
+
getShutdownManager,
|
|
110
|
+
hasShutdownManager,
|
|
111
|
+
getServiceRegistry,
|
|
112
|
+
hasServiceRegistry,
|
|
73
113
|
resetAppContext,
|
|
74
114
|
attachDbMiddleware,
|
|
75
115
|
};
|