webspresso 0.0.96 → 0.0.98
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/.agents/ADMIN.md +153 -5
- package/.agents/ARCHITECTURE.md +10 -0
- package/.agents/CLI.md +195 -1
- package/.agents/PLUGINS.md +153 -9
- package/.agents/QUEUE.md +43 -0
- package/.agents/skills/webspresso-admin-and-plugins/SKILL.md +122 -0
- package/.agents/skills/webspresso-framework/SKILL.md +56 -0
- package/.agents/skills/webspresso-orm-and-database/SKILL.md +119 -0
- package/.agents/skills/webspresso-routing-and-api/SKILL.md +114 -0
- package/.agents/skills/webspresso-services/SKILL.md +101 -0
- package/bin/commands/add-esbuild.js +80 -0
- package/bin/commands/add-tailwind.js +76 -31
- package/bin/commands/admin-password.js +2 -1
- package/bin/commands/admin-setup.js +1 -1
- package/bin/commands/agents-init.js +51 -11
- package/bin/commands/analytics-prune.js +57 -0
- package/bin/commands/api.js +207 -15
- package/bin/commands/audit-prune.js +1 -1
- package/bin/commands/build.js +99 -0
- package/bin/commands/dev.js +64 -35
- package/bin/commands/doctor.js +26 -0
- package/bin/commands/email-prune.js +47 -0
- package/bin/commands/favicon-generate.js +1 -1
- package/bin/commands/make-job.js +86 -0
- package/bin/commands/make-model.js +250 -0
- package/bin/commands/new.js +45 -28
- package/bin/commands/openapi.js +102 -0
- package/bin/commands/orm-map.js +5 -4
- package/bin/commands/page.js +6 -3
- package/bin/commands/polar-migrate.js +1 -1
- package/bin/commands/queue-prune.js +59 -0
- package/bin/commands/routes.js +52 -0
- package/bin/commands/seed.js +1 -1
- package/bin/commands/service.js +6 -3
- package/bin/commands/typegen.js +106 -0
- package/bin/commands/upload-prune.js +79 -0
- package/bin/webspresso.js +22 -0
- package/core/applySchema.js +13 -6
- package/core/auth/hash.js +31 -17
- package/core/compression/middleware.js +23 -17
- package/core/openapi/build-from-api-routes.js +160 -29
- package/core/orm/cache/fingerprint.js +15 -1
- package/core/orm/cache/memory-provider.js +27 -2
- package/core/orm/index.js +12 -7
- package/core/orm/model.js +49 -7
- package/core/queue/adapters/database.js +94 -0
- package/core/queue/adapters/memory.js +62 -0
- package/core/queue/adapters/redis.js +80 -0
- package/core/queue/manager.js +123 -0
- package/core/ssr/stream.js +11 -0
- package/index.d.ts +660 -10
- package/index.js +44 -96
- package/package.json +32 -12
- package/plugins/admin-panel/api.js +279 -17
- package/plugins/admin-panel/app.js +124 -31
- package/plugins/admin-panel/client/parts/01-state-api-breadcrumb.js +314 -9
- package/plugins/admin-panel/client/parts/04-field-renderers.js +264 -67
- package/plugins/admin-panel/client/parts/05-rich-text-file-helpers.js +10 -5
- package/plugins/admin-panel/client/parts/06-login-setup-forms.js +119 -28
- package/plugins/admin-panel/client/parts/07-model-list.js +49 -8
- package/plugins/admin-panel/client/parts/08-record-list.js +243 -23
- package/plugins/admin-panel/client/parts/09-record-form.js +59 -12
- package/plugins/admin-panel/client/parts/10-export-registry.js +23 -0
- package/plugins/admin-panel/core/admin-module.js +13 -7
- package/plugins/admin-panel/core/api-extensions.js +34 -2
- package/plugins/admin-panel/core/registry.js +96 -16
- package/plugins/admin-panel/index.js +96 -0
- package/plugins/admin-panel/lib/login-rate-limiter.js +119 -0
- package/plugins/admin-panel/modules/admin-users.js +16 -1
- package/plugins/admin-panel/modules/bulk-actions.js +13 -5
- package/plugins/admin-panel/modules/custom-pages.js +492 -3
- package/plugins/admin-panel/modules/dashboard.js +283 -0
- package/plugins/admin-panel/modules/menu.js +56 -18
- package/plugins/admin-panel/modules/user-management.js +24 -6
- package/plugins/audit-log/admin-component.js +11 -0
- package/plugins/audit-log/api-handlers.js +34 -0
- package/plugins/audit-log/index.js +129 -3
- package/plugins/audit-log/purge.js +60 -10
- package/plugins/basic-auth/index.js +3 -1
- package/plugins/content/client/inline-edit.js +12 -12
- package/plugins/cors.js +6 -7
- package/plugins/dashboard/app.js +152 -27
- package/plugins/dashboard/index.js +143 -39
- package/plugins/dashboard/styles.js +78 -0
- package/plugins/data-exchange/export-xlsx.js +9 -2
- package/plugins/data-exchange/import.js +9 -2
- package/plugins/data-exchange/index.js +6 -3
- package/plugins/email/index.js +132 -2
- package/plugins/email/purge.js +60 -10
- package/plugins/file-manager/core.js +1 -1
- package/plugins/file-manager/security.js +33 -23
- package/plugins/index.js +49 -87
- package/plugins/mcp/transports/sse.js +4 -2
- package/plugins/orm-cache-admin/index.js +4 -2
- package/plugins/queue/index.js +11 -0
- package/plugins/schema-explorer/admin-component.js +714 -0
- package/plugins/schema-explorer/relations-graph.js +205 -0
- package/plugins/schema-explorer.js +248 -69
- package/plugins/site-analytics/admin-component.js +30 -8
- package/plugins/site-analytics/api-handlers.js +42 -0
- package/plugins/site-analytics/index.js +147 -2
- package/plugins/site-analytics/purge.js +168 -0
- package/plugins/swagger.js +261 -13
- package/plugins/upload/index.js +26 -0
- package/plugins/upload/orphan-pruner.js +292 -0
- package/src/api/api-loader.js +3 -1
- package/src/bundle/index.js +517 -0
- package/src/bundle/manifest.js +165 -0
- package/src/dev/banner.js +296 -0
- package/src/dev/colors.js +70 -0
- package/src/dev/index.js +62 -0
- package/src/dev/profiler.js +354 -0
- package/src/dev/typegen.js +497 -0
- package/src/dev-reload/index.js +611 -0
- package/src/file-router.js +213 -63
- package/src/helpers.js +958 -98
- package/src/njk-frontmatter.js +12 -0
- package/src/pages/page-loader.js +61 -11
- package/src/server.js +629 -63
- package/src/services/discovery.js +6 -1
- package/src/services/index.js +6 -13
package/src/njk-frontmatter.js
CHANGED
|
@@ -152,9 +152,20 @@ function loadNjkRouteTemplate(absPath, isDev) {
|
|
|
152
152
|
return fresh;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
+
const clearHooks = new Set();
|
|
156
|
+
|
|
157
|
+
function registerClearHook(fn) {
|
|
158
|
+
if (typeof fn === 'function') clearHooks.add(fn);
|
|
159
|
+
}
|
|
160
|
+
|
|
155
161
|
function clearNjkFrontmatterCaches() {
|
|
156
162
|
prodRouteCache.clear();
|
|
157
163
|
devRouteCache.clear();
|
|
164
|
+
for (const fn of clearHooks) {
|
|
165
|
+
try {
|
|
166
|
+
fn();
|
|
167
|
+
} catch (_) {}
|
|
168
|
+
}
|
|
158
169
|
}
|
|
159
170
|
|
|
160
171
|
module.exports = {
|
|
@@ -162,5 +173,6 @@ module.exports = {
|
|
|
162
173
|
frontmatterToPatches,
|
|
163
174
|
loadNjkRouteTemplate,
|
|
164
175
|
clearNjkFrontmatterCaches,
|
|
176
|
+
registerClearHook,
|
|
165
177
|
extractFrontmatterBlock,
|
|
166
178
|
};
|
package/src/pages/page-loader.js
CHANGED
|
@@ -8,8 +8,16 @@
|
|
|
8
8
|
|
|
9
9
|
const fs = require('fs');
|
|
10
10
|
const path = require('path');
|
|
11
|
-
const { createHelpers } = require('../helpers');
|
|
12
|
-
const {
|
|
11
|
+
const { createHelpers, getAssetManager } = require('../helpers');
|
|
12
|
+
const {
|
|
13
|
+
loadI18n,
|
|
14
|
+
createTranslator,
|
|
15
|
+
detectLocale,
|
|
16
|
+
resolveMiddlewares,
|
|
17
|
+
translatorCache,
|
|
18
|
+
resolvePageAssets,
|
|
19
|
+
applyPageAssetsToTemplateData,
|
|
20
|
+
} = require('../file-router');
|
|
13
21
|
|
|
14
22
|
const EMPTY_ARRAY = Object.freeze([]);
|
|
15
23
|
|
|
@@ -111,13 +119,29 @@ function createPageHandler(descriptor, context) {
|
|
|
111
119
|
|
|
112
120
|
// i18n
|
|
113
121
|
const defaultLocale = process.env.DEFAULT_LOCALE || 'en';
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
122
|
+
let t;
|
|
123
|
+
if (!isDev && translatorCache) {
|
|
124
|
+
const transKey = `${pagesDir}::::${locale}::${defaultLocale}`;
|
|
125
|
+
t = translatorCache.get(transKey);
|
|
126
|
+
if (!t) {
|
|
127
|
+
const translations = loadI18n(pagesDir, '', locale, false);
|
|
128
|
+
const fallbackTranslations = locale !== defaultLocale ? loadI18n(pagesDir, '', defaultLocale, false) : undefined;
|
|
129
|
+
t = createTranslator(translations, {
|
|
130
|
+
locale,
|
|
131
|
+
fallbackTranslations,
|
|
132
|
+
fallbackLocale: defaultLocale,
|
|
133
|
+
});
|
|
134
|
+
translatorCache.set(transKey, t);
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
const translations = loadI18n(pagesDir, '', locale, isDev);
|
|
138
|
+
const fallbackTranslations = locale !== defaultLocale ? loadI18n(pagesDir, '', defaultLocale, isDev) : undefined;
|
|
139
|
+
t = createTranslator(translations, {
|
|
140
|
+
locale,
|
|
141
|
+
fallbackTranslations,
|
|
142
|
+
fallbackLocale: defaultLocale,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
121
145
|
|
|
122
146
|
const pageCtx = {
|
|
123
147
|
req,
|
|
@@ -163,10 +187,36 @@ function createPageHandler(descriptor, context) {
|
|
|
163
187
|
const templateExists = hasNjkTemplate !== null ? hasNjkTemplate : fs.existsSync(njkCandidate);
|
|
164
188
|
|
|
165
189
|
if (templateExists && nunjucks) {
|
|
190
|
+
let pageHead = headData;
|
|
191
|
+
let pageAssetsActive = false;
|
|
192
|
+
const pageAssetsOpt = context.pageAssets || (appOptions && appOptions.pageAssets);
|
|
193
|
+
if (pageAssetsOpt) {
|
|
194
|
+
const pageAssetsResolved = resolvePageAssets(pageAssetsOpt);
|
|
195
|
+
if (pageAssetsResolved.enabled) {
|
|
196
|
+
const pageAssetBundle = applyPageAssetsToTemplateData(
|
|
197
|
+
pageAssetsResolved,
|
|
198
|
+
loadedData,
|
|
199
|
+
{
|
|
200
|
+
file: descriptor.source || descriptor.file,
|
|
201
|
+
routePath: descriptor.path,
|
|
202
|
+
},
|
|
203
|
+
fsy?.assetManager || getAssetManager()
|
|
204
|
+
);
|
|
205
|
+
loadedData = pageAssetBundle.data;
|
|
206
|
+
pageHead = {
|
|
207
|
+
...headData,
|
|
208
|
+
stylesheets: [...(headData.stylesheets || []), ...(pageAssetBundle.pageHead?.stylesheets || [])],
|
|
209
|
+
scripts: [...(headData.scripts || []), ...(pageAssetBundle.pageHead?.scripts || [])],
|
|
210
|
+
};
|
|
211
|
+
pageAssetsActive = true;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
166
215
|
const templateData = {
|
|
167
216
|
...loadedData,
|
|
168
|
-
head:
|
|
169
|
-
pageHead
|
|
217
|
+
head: pageHead,
|
|
218
|
+
pageHead,
|
|
219
|
+
pageAssets: pageAssetsActive || Boolean(loadedData.pageAssets),
|
|
170
220
|
fsy,
|
|
171
221
|
locale,
|
|
172
222
|
t,
|