webspresso 0.0.108 → 0.0.110
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/LICENSE +21 -0
- package/README.md +3 -3
- package/bin/commands/add-esbuild.js +7 -3
- package/bin/commands/add-tailwind.js +9 -5
- package/bin/commands/build.js +20 -4
- package/bin/commands/dev.js +57 -7
- package/bin/commands/doctor.js +42 -1
- package/bin/commands/favicon-generate.js +10 -3
- package/bin/commands/new.js +8 -3
- package/bin/commands/start.js +3 -1
- package/bin/utils/add-command.js +16 -0
- package/core/app.js +45 -3
- package/core/auth/authenticate.js +3 -3
- package/core/auth/hash.js +167 -43
- package/core/auth/index.js +13 -1
- package/core/auth/jwt.js +21 -2
- package/core/auth/manager.js +63 -14
- package/core/auth/middleware.js +4 -2
- package/core/auth/oauth.js +5 -1
- package/core/auth/tokens.js +7 -2
- package/core/auth/totp.js +42 -6
- package/core/auth/user-agent.js +2 -0
- package/core/client/adapter/datastar.js +1401 -0
- package/core/client/api.js +1337 -0
- package/core/client/controller.js +1706 -0
- package/core/client/debug.js +367 -0
- package/core/client/devtool.js +1134 -0
- package/core/client/forms.js +1164 -0
- package/core/client/fragments.js +894 -0
- package/core/client/index.d.ts +59 -0
- package/core/client/index.js +391 -0
- package/core/client/lite.js +175 -0
- package/core/client/server-fragments.js +868 -0
- package/core/client/storage.js +339 -0
- package/core/client/utils.js +281 -0
- package/core/compression/middleware.js +277 -26
- package/core/context/app-context.js +25 -3
- package/core/context/request.js +32 -4
- package/core/errors/middleware.js +14 -0
- package/core/events/dispatcher.js +33 -0
- package/core/forms/flash.js +136 -102
- package/core/health/middleware.js +36 -6
- package/core/http/pipeline.js +45 -6
- package/core/index.js +25 -7
- package/core/kernel/view.js +41 -10
- package/core/metrics/middleware.js +30 -6
- package/core/metrics/registry.js +13 -5
- package/core/orm/cache/fingerprint.js +32 -11
- package/core/orm/cache/layer.js +19 -2
- package/core/orm/hidden.js +145 -0
- package/core/orm/model.js +48 -2
- package/core/orm/query-builder.js +343 -6
- package/core/orm/query-filters.js +14 -2
- package/core/orm/repository.js +64 -13
- package/core/orm/schema-helpers.js +9 -6
- package/core/orm/transaction.js +50 -6
- package/core/orm/types.js +4 -0
- package/core/queue/adapters/database.js +184 -2
- package/core/queue/adapters/memory.js +153 -5
- package/core/queue/adapters/redis.js +59 -4
- package/core/queue/job.js +14 -1
- package/core/queue/manager.js +115 -0
- package/core/resilience/circuit-breaker.js +27 -8
- package/core/services/builtins/exchange.js +174 -7
- package/core/services/builtins/file-manager.js +36 -0
- package/core/services/builtins/mail.js +27 -0
- package/core/services/builtins/queue.js +144 -0
- package/core/services/builtins/security.js +118 -0
- package/core/services/builtins/webhook.js +110 -0
- package/core/services/executor.js +38 -16
- package/core/services/index.js +4 -1
- package/core/sse/stream.js +28 -5
- package/core/utils/timeout.js +8 -1
- package/core/validation/compiler.js +10 -7
- package/index.d.ts +1320 -74
- package/index.js +128 -8
- package/package.json +75 -27
- package/plugins/admin-panel/client/parts/08-record-list.js +717 -70
- package/plugins/admin-panel/index.js +19 -8
- package/plugins/csrf/index.js +3 -3
- package/plugins/data-exchange/export.js +214 -0
- package/plugins/data-exchange/import.js +48 -5
- package/plugins/data-exchange/index.js +70 -28
- package/plugins/data-exchange/preview.js +266 -0
- package/plugins/data-exchange/template.js +242 -0
- package/plugins/email/admin-component.js +783 -141
- package/plugins/email/api-handlers.js +51 -1
- package/plugins/email/index.js +5 -0
- package/plugins/email/service.js +48 -0
- package/plugins/file-manager/admin-component.js +1546 -70
- package/plugins/file-manager/api-handlers.js +166 -1
- package/plugins/file-manager/core.js +598 -8
- package/plugins/file-manager/index.js +8 -0
- package/plugins/index.js +7 -0
- package/plugins/mcp/auth.js +3 -3
- package/plugins/oauth/index.js +36 -3
- package/plugins/queue/admin-component.js +1092 -0
- package/plugins/queue/api-handlers.js +248 -0
- package/plugins/queue/index.js +69 -0
- package/plugins/rest-resources/index.js +7 -2
- package/plugins/security/admin-component.js +689 -0
- package/plugins/security/api-handlers.js +169 -0
- package/plugins/security/audit.js +153 -0
- package/plugins/security/bruteforce.js +244 -0
- package/plugins/security/firewall.js +459 -0
- package/plugins/security/headers.js +214 -0
- package/plugins/security/honeypot.js +234 -0
- package/plugins/security/incident-recorder.js +137 -0
- package/plugins/security/index.js +211 -0
- package/plugins/seo-checker/analyzer.js +20 -7
- package/plugins/upload/index.js +36 -0
- package/plugins/webhooks/admin-component.js +702 -175
- package/plugins/webhooks/api-handlers.js +75 -1
- package/plugins/webhooks/dispatcher.js +290 -11
- package/plugins/webhooks/index.js +37 -2
- package/plugins/webhooks/sender.js +56 -0
- package/plugins/xlsx/engine.js +19 -4
- package/src/api/api-loader.js +19 -1
- package/src/bundle/index.js +443 -17
- package/src/client-runtime/bootstrap-swup.js +9 -0
- package/src/client-runtime/mount.js +15 -20
- package/src/client-runtime/resolve.js +3 -2
- package/src/dev/api-typegen.js +1300 -0
- package/src/dev/banner.js +10 -1
- package/src/dev/colors.js +1 -1
- package/src/dev/index.js +7 -1
- package/src/dev/typegen.js +173 -17
- package/src/dev-reload/index.js +1 -1
- package/src/discovery/file-route-parser.js +17 -3
- package/src/discovery/scan-routes.js +4 -1
- package/src/file-router.js +253 -69
- package/src/helpers.js +46 -26
- package/src/njk-frontmatter.js +30 -4
- package/src/routing/cascading.js +26 -8
- package/src/routing/mount-discovered-routes.js +76 -0
- package/src/server.js +231 -70
- package/views/partials/webspresso-client-runtime.njk +1 -9
- package/.agents/ADMIN.md +0 -426
- package/.agents/AGENTS.md +0 -96
- package/.agents/ARCHITECTURE.md +0 -163
- package/.agents/AUTH.md +0 -581
- package/.agents/CACHE.md +0 -148
- package/.agents/CLI.md +0 -649
- package/.agents/COMPRESSION.md +0 -59
- package/.agents/CONTEXT.md +0 -152
- package/.agents/CONVENTIONS.md +0 -50
- package/.agents/EARLY_HINTS.md +0 -120
- package/.agents/EMAIL.md +0 -223
- package/.agents/ERRORS.md +0 -260
- package/.agents/EVENTS.md +0 -179
- package/.agents/FLAGS.md +0 -118
- package/.agents/HEALTH.md +0 -118
- package/.agents/LIMITS.md +0 -109
- package/.agents/LOGGING.md +0 -93
- package/.agents/MCP.md +0 -103
- package/.agents/METRICS.md +0 -127
- package/.agents/MIGRATION_JOBS.md +0 -95
- package/.agents/ORM.md +0 -700
- package/.agents/PLUGINS.md +0 -729
- package/.agents/QUEUE.md +0 -290
- package/.agents/RATE_LIMIT.md +0 -147
- package/.agents/REALTIME.md +0 -213
- package/.agents/RESILIENCE.md +0 -235
- package/.agents/ROUTING.md +0 -605
- package/.agents/SCALE_OUT.md +0 -109
- package/.agents/SECRETS.md +0 -117
- package/.agents/SERVICES.md +0 -341
- package/.agents/SHUTDOWN.md +0 -74
- package/.agents/STREAMING.md +0 -108
- package/.agents/WORKFLOW.md +0 -27
- package/.agents/internal/DOCUMENTATION_REVIEW.md +0 -485
- package/.agents/internal/TECHNICAL_REVIEW.md +0 -428
- package/.agents/skills/webspresso-admin-and-plugins/SKILL.md +0 -122
- package/.agents/skills/webspresso-framework/SKILL.md +0 -89
- package/.agents/skills/webspresso-orm-and-database/SKILL.md +0 -127
- package/.agents/skills/webspresso-routing-and-api/SKILL.md +0 -130
- package/.agents/skills/webspresso-services/SKILL.md +0 -134
- package/.cursorrules +0 -14
- package/AGENTS.md +0 -203
- package/CLAUDE.md +0 -54
- package/core/kernel/run-demo.js +0 -58
- package/plugins/admin-panel/styles.js +0 -9
- package/plugins/data-exchange/export-xlsx.js +0 -119
- package/src/client-runtime/bootstrap-alpine-swup.js +0 -34
|
@@ -90,7 +90,11 @@ function createFileManagerApiHandlers(options = {}) {
|
|
|
90
90
|
publicBasePath,
|
|
91
91
|
});
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
const storage = await core.getDetailedStorageStats(baseDir, {
|
|
94
|
+
maxTotalStorageBytes,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return res.json({ success: true, ...result, storage });
|
|
94
98
|
} catch (err) {
|
|
95
99
|
const status = err.statusCode || err.status || 400;
|
|
96
100
|
return res.status(status).json({ success: false, error: err.message });
|
|
@@ -244,6 +248,167 @@ function createFileManagerApiHandlers(options = {}) {
|
|
|
244
248
|
}
|
|
245
249
|
});
|
|
246
250
|
},
|
|
251
|
+
|
|
252
|
+
async saveImage(req, res) {
|
|
253
|
+
if (!isActionAllowed(req, 'upload', permissions)) {
|
|
254
|
+
return res.status(403).json({ success: false, error: 'Permission denied for action: upload' });
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
try {
|
|
258
|
+
const { path: itemPath, dataUrl, overwrite, newName } = req.body || {};
|
|
259
|
+
if (!itemPath || !dataUrl) {
|
|
260
|
+
return res.status(400).json({ success: false, error: 'Path and dataUrl are required' });
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const result = await core.saveEditedImage(baseDir, itemPath, dataUrl, {
|
|
264
|
+
overwrite: overwrite === true || overwrite === 'true',
|
|
265
|
+
newName,
|
|
266
|
+
publicBasePath,
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
return res.status(200).json({ success: true, file: result });
|
|
270
|
+
} catch (err) {
|
|
271
|
+
const status = err.statusCode || err.status || 400;
|
|
272
|
+
return res.status(status).json({ success: false, error: err.message });
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
|
|
276
|
+
async getFileContent(req, res) {
|
|
277
|
+
if (!isActionAllowed(req, 'read', permissions)) {
|
|
278
|
+
return res.status(403).json({ success: false, error: 'Permission denied for action: read' });
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
try {
|
|
282
|
+
const itemPath = req.query.path;
|
|
283
|
+
if (!itemPath) {
|
|
284
|
+
return res.status(400).json({ success: false, error: 'Path query parameter is required' });
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const result = await core.getFileContent(baseDir, itemPath, {
|
|
288
|
+
maxTextBytes: 5 * 1024 * 1024,
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
return res.status(200).json({ success: true, ...result });
|
|
292
|
+
} catch (err) {
|
|
293
|
+
const status = err.statusCode || err.status || (err.name === 'NotFoundError' ? 404 : 400);
|
|
294
|
+
return res.status(status).json({ success: false, error: err.message });
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
|
|
298
|
+
async saveFileContent(req, res) {
|
|
299
|
+
if (!isActionAllowed(req, 'upload', permissions)) {
|
|
300
|
+
return res.status(403).json({ success: false, error: 'Permission denied for action: upload' });
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
try {
|
|
304
|
+
const { path: itemPath, content, overwrite, newName } = req.body || {};
|
|
305
|
+
if (!itemPath || typeof content !== 'string') {
|
|
306
|
+
return res.status(400).json({ success: false, error: 'Path and content string are required' });
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
const result = await core.saveFileContent(baseDir, itemPath, content, {
|
|
310
|
+
overwrite: overwrite === true || overwrite === 'true',
|
|
311
|
+
newName,
|
|
312
|
+
publicBasePath,
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
return res.status(200).json({ success: true, file: result });
|
|
316
|
+
} catch (err) {
|
|
317
|
+
const status = err.statusCode || err.status || 400;
|
|
318
|
+
return res.status(status).json({ success: false, error: err.message });
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
|
|
322
|
+
async batchDelete(req, res) {
|
|
323
|
+
if (!isActionAllowed(req, 'delete', permissions)) {
|
|
324
|
+
return res.status(403).json({ success: false, error: 'Permission denied for action: delete' });
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
try {
|
|
328
|
+
const { paths: itemPaths } = req.body || {};
|
|
329
|
+
if (!Array.isArray(itemPaths) || itemPaths.length === 0) {
|
|
330
|
+
return res.status(400).json({ success: false, error: 'paths array is required' });
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const result = await core.batchDelete(baseDir, itemPaths);
|
|
334
|
+
return res.status(200).json(result);
|
|
335
|
+
} catch (err) {
|
|
336
|
+
const status = err.statusCode || err.status || 400;
|
|
337
|
+
return res.status(status).json({ success: false, error: err.message });
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
|
|
341
|
+
async batchMove(req, res) {
|
|
342
|
+
if (!isActionAllowed(req, 'move', permissions)) {
|
|
343
|
+
return res.status(403).json({ success: false, error: 'Permission denied for action: move' });
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
try {
|
|
347
|
+
const { paths: itemPaths, destination = '' } = req.body || {};
|
|
348
|
+
if (!Array.isArray(itemPaths) || itemPaths.length === 0) {
|
|
349
|
+
return res.status(400).json({ success: false, error: 'paths array is required' });
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const result = await core.batchMove(baseDir, itemPaths, destination);
|
|
353
|
+
return res.status(200).json(result);
|
|
354
|
+
} catch (err) {
|
|
355
|
+
const status = err.statusCode || err.status || 400;
|
|
356
|
+
return res.status(status).json({ success: false, error: err.message });
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
|
|
360
|
+
async downloadZip(req, res) {
|
|
361
|
+
if (!isActionAllowed(req, 'read', permissions)) {
|
|
362
|
+
return res.status(403).json({ success: false, error: 'Permission denied for action: read' });
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
try {
|
|
366
|
+
let itemPaths = [];
|
|
367
|
+
if (req.method === 'POST') {
|
|
368
|
+
itemPaths = (req.body && req.body.paths) || [];
|
|
369
|
+
} else {
|
|
370
|
+
const raw = req.query.paths;
|
|
371
|
+
if (Array.isArray(raw)) {
|
|
372
|
+
itemPaths = raw;
|
|
373
|
+
} else if (typeof raw === 'string') {
|
|
374
|
+
itemPaths = raw.split(',').map(s => s.trim()).filter(Boolean);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
if (!Array.isArray(itemPaths) || itemPaths.length === 0) {
|
|
379
|
+
return res.status(400).json({ success: false, error: 'At least one path is required for zip download' });
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const { buffer, filename, size, fileCount } = await core.createZipFromPaths(baseDir, itemPaths);
|
|
383
|
+
|
|
384
|
+
res.setHeader('Content-Type', 'application/zip');
|
|
385
|
+
res.setHeader('Content-Disposition', `attachment; filename="${filename}"`);
|
|
386
|
+
res.setHeader('Content-Length', String(size));
|
|
387
|
+
res.setHeader('X-Archive-Files-Count', String(fileCount));
|
|
388
|
+
return res.end(buffer);
|
|
389
|
+
} catch (err) {
|
|
390
|
+
const status = err.statusCode || err.status || 400;
|
|
391
|
+
return res.status(status).json({ success: false, error: err.message });
|
|
392
|
+
}
|
|
393
|
+
},
|
|
394
|
+
|
|
395
|
+
async getStorageStats(req, res) {
|
|
396
|
+
if (!isActionAllowed(req, 'list', permissions)) {
|
|
397
|
+
return res.status(403).json({ success: false, error: 'Permission denied for action: list' });
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
try {
|
|
401
|
+
const forceRefresh = req.query.refresh === 'true' || req.query.force === 'true';
|
|
402
|
+
const stats = await core.getDetailedStorageStats(baseDir, {
|
|
403
|
+
forceRefresh,
|
|
404
|
+
maxTotalStorageBytes,
|
|
405
|
+
});
|
|
406
|
+
return res.json({ success: true, stats });
|
|
407
|
+
} catch (err) {
|
|
408
|
+
const status = err.statusCode || err.status || 400;
|
|
409
|
+
return res.status(status).json({ success: false, error: err.message });
|
|
410
|
+
}
|
|
411
|
+
},
|
|
247
412
|
};
|
|
248
413
|
}
|
|
249
414
|
|