webspresso 0.0.95 → 0.0.96
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 +225 -0
- package/.agents/AGENTS.md +72 -0
- package/.agents/ARCHITECTURE.md +119 -0
- package/.agents/AUTH.md +103 -0
- package/.agents/CLI.md +115 -0
- package/.agents/COMPRESSION.md +59 -0
- package/.agents/CONVENTIONS.md +46 -0
- package/.agents/EMAIL.md +141 -0
- package/.agents/ERRORS.md +201 -0
- package/.agents/MCP.md +103 -0
- package/.agents/ORM.md +230 -0
- package/.agents/PLUGINS.md +419 -0
- package/.agents/QUEUE.md +113 -0
- package/.agents/REALTIME.md +213 -0
- package/.agents/ROUTING.md +292 -0
- package/.agents/SERVICES.md +341 -0
- package/.agents/SHUTDOWN.md +67 -0
- package/.agents/STREAMING.md +73 -0
- package/.agents/WORKFLOW.md +27 -0
- package/.agents/internal/DOCUMENTATION_REVIEW.md +485 -0
- package/.agents/internal/TECHNICAL_REVIEW.md +428 -0
- package/.cursorrules +14 -0
- package/AGENTS.md +175 -0
- package/CLAUDE.md +54 -0
- package/README.md +18 -14
- package/bin/commands/agents-init.js +169 -0
- package/bin/commands/api.js +114 -48
- package/bin/commands/doctor.js +35 -0
- package/bin/commands/new.js +13 -2
- package/bin/commands/page.js +75 -89
- package/bin/commands/service.js +77 -0
- package/bin/webspresso.js +2 -2
- package/core/compileSchema.js +1 -1
- package/core/errors/middleware.js +22 -2
- package/core/errors/normalize.js +29 -2
- package/{utils/schemaCache.js → core/schema-cache.js} +2 -3
- package/index.d.ts +306 -0
- package/index.js +35 -1
- package/package.json +5 -3
- package/plugins/admin-panel/client/parts/05-rich-text-file-helpers.js +22 -1
- package/plugins/csrf/index.js +3 -2
- package/plugins/csv/engine.js +447 -0
- package/plugins/csv/index.js +94 -0
- package/plugins/csv/middleware.js +80 -0
- package/plugins/csv/services.js +138 -0
- package/plugins/file-manager/admin-component.js +613 -0
- package/plugins/file-manager/api-handlers.js +261 -0
- package/plugins/file-manager/core.js +601 -0
- package/plugins/file-manager/index.js +139 -0
- package/plugins/file-manager/security.js +207 -0
- package/plugins/index.js +8 -0
- package/plugins/xlsx/engine.js +397 -0
- package/plugins/xlsx/index.js +91 -0
- package/plugins/xlsx/middleware.js +87 -0
- package/plugins/xlsx/services.js +118 -0
- package/src/api/api-loader.js +233 -0
- package/src/api/define-api.js +35 -0
- package/src/discovery/file-route-parser.js +201 -0
- package/src/discovery/scan-routes.js +265 -0
- package/src/file-router.js +6 -0
- package/src/modules/define-module.js +99 -0
- package/src/modules/module-discovery.js +117 -0
- package/src/pages/define-page.js +36 -0
- package/src/pages/page-loader.js +214 -0
- package/src/routing/mount-discovered-routes.js +78 -0
- package/src/routing/route-table.js +191 -0
- package/src/server.js +112 -15
- package/src/services/builtins/file-manager.js +178 -0
- package/src/services/index.js +2 -0
- package/bin/commands/skill.js +0 -187
- package/templates/skills/webspresso-usage/REFERENCE-framework.md +0 -289
- package/templates/skills/webspresso-usage/REFERENCE-kernel.md +0 -93
- package/templates/skills/webspresso-usage/SKILL.md +0 -48
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
# Webspresso — application kernel (event bus, flows, views)
|
|
2
|
-
|
|
3
|
-
This layer must **not** be confused with Express SSR. The package root **`createApp`** sets up file-based SSR; **`kernel.createApp`** is a lightweight in-process API with an event bus, optional view resolver, and flow registry.
|
|
4
|
-
|
|
5
|
-
## Name clash
|
|
6
|
-
|
|
7
|
-
| API | Purpose |
|
|
8
|
-
|-----|---------|
|
|
9
|
-
| `require('webspresso').createApp(...)` | SSR — `pages/`, Nunjucks, Express |
|
|
10
|
-
| `require('webspresso').kernel.createApp(...)` | Kernel — `events`, `registerPlugin`, `registerFlow`, `view` |
|
|
11
|
-
|
|
12
|
-
## Usage
|
|
13
|
-
|
|
14
|
-
```javascript
|
|
15
|
-
const { kernel } = require('webspresso');
|
|
16
|
-
const app = kernel.createApp({
|
|
17
|
-
paths: {
|
|
18
|
-
appViews: './views', // optional app override root
|
|
19
|
-
themeViews: './themes/default',
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Module layout (source repo): [`core/kernel/`](../../../core/kernel/).
|
|
25
|
-
|
|
26
|
-
## Event bus
|
|
27
|
-
|
|
28
|
-
- **`events.dispatch(name, ctx)`** — Handlers for the same name run **sequentially** with `await`; `ctx` is mutable; errors stop the caller.
|
|
29
|
-
- **`events.publish(name, ctx)`** — Handlers run concurrently via **`Promise.all`** (side effects / “after” events).
|
|
30
|
-
- **`events.on(name, handler)`** / **`off`** — Subscribe / unsubscribe.
|
|
31
|
-
- **`events.buildContext(payload, { source, requestId?, userId? })`** → `{ payload, meta: { source, createdAt, … } }`; `source`: `'orm' | 'auth' | 'route' | 'plugin' | 'system'`.
|
|
32
|
-
|
|
33
|
-
Standalone bus: `kernel.createEventBus()`.
|
|
34
|
-
|
|
35
|
-
## Simulated repository (ORM lifecycle)
|
|
36
|
-
|
|
37
|
-
`kernel.BaseRepository` — in-memory store; events named by `resource`: `orm.<resource>.beforeCreate`, `afterCreate`, `beforeUpdate`, …
|
|
38
|
-
|
|
39
|
-
Implementation: [`core/kernel/base-repository.js`](../../../core/kernel/base-repository.js).
|
|
40
|
-
|
|
41
|
-
## Plugin shell
|
|
42
|
-
|
|
43
|
-
```javascript
|
|
44
|
-
const { kernel } = require('webspresso');
|
|
45
|
-
const myPlugin = kernel.definePlugin({
|
|
46
|
-
name: 'my-plugin',
|
|
47
|
-
events(app) {
|
|
48
|
-
app.events.on('orm.post.afterCreate', async (ctx) => { /* ... */ });
|
|
49
|
-
},
|
|
50
|
-
views() {
|
|
51
|
-
return {
|
|
52
|
-
namespace: 'blog',
|
|
53
|
-
layouts: {},
|
|
54
|
-
pages: { home: '<h1>{{ title }}</h1>' },
|
|
55
|
-
partials: {},
|
|
56
|
-
};
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
app.registerPlugin(myPlugin);
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## View resolver
|
|
63
|
-
|
|
64
|
-
- Name shape: **`namespace::page`** (e.g. `blog::home`).
|
|
65
|
-
- Resolution order: app file overrides → theme file overrides → inline plugin templates.
|
|
66
|
-
- **`app.view.renderView('ns::id', data, { layout: 'ns::layoutName' })`**
|
|
67
|
-
- **`app.view.renderPartial(...)`**
|
|
68
|
-
- Minimal templates: `{{ field }}` interpolation.
|
|
69
|
-
|
|
70
|
-
## Flow
|
|
71
|
-
|
|
72
|
-
```javascript
|
|
73
|
-
app.registerFlow(
|
|
74
|
-
kernel.defineFlow({
|
|
75
|
-
trigger: 'orm.post.afterCreate',
|
|
76
|
-
when: (ctx) => ctx.payload.record?.status === 'published',
|
|
77
|
-
actions: [async (ctx, kernApp) => { /* run in order */ }],
|
|
78
|
-
}),
|
|
79
|
-
);
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
## Demo
|
|
83
|
-
|
|
84
|
-
From the repo: `node core/kernel/run-demo.js` — plugin, flow, and view example.
|
|
85
|
-
|
|
86
|
-
## When to read this file
|
|
87
|
-
|
|
88
|
-
- Event-driven domain logic, “on afterCreate do X” automation.
|
|
89
|
-
- When you want this minimal kernel instead of SSR routes or Knex ORM `ModelEvents` alone.
|
|
90
|
-
|
|
91
|
-
Types: npm package **`index.d.ts`** (`kernel`, `KernelAppShell`, …).
|
|
92
|
-
|
|
93
|
-
HTML section: **[`doc/index.html#application-kernel`](../../../doc/index.html#application-kernel)**.
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: webspresso-usage
|
|
3
|
-
description: >-
|
|
4
|
-
Webspresso: SSR file routes (createApp), ORM, auth, plugins, CLI; plus optional in-process
|
|
5
|
-
kernel (kernel.createApp: event bus, flows, view resolver). Read REFERENCE-framework.md for
|
|
6
|
-
pages/api/ORM/auth; REFERENCE-kernel.md for kernel. Use in this repo or Webspresso apps.
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# Webspresso — agent skill (overview)
|
|
10
|
-
|
|
11
|
-
There are **three** files in this folder; open the reference that matches the task.
|
|
12
|
-
|
|
13
|
-
## Which file should I read?
|
|
14
|
-
|
|
15
|
-
| Need | File | Notes |
|
|
16
|
-
|------|------|-------|
|
|
17
|
-
| `pages/`, `views/`, API, `load()`, hooks, i18n, `fsy` | [`REFERENCE-framework.md`](./REFERENCE-framework.md) | SSR **`createApp`** — the main framework. |
|
|
18
|
-
| `createApp({ db })`, `ctx.db`, `defineModel`, migrations | [`REFERENCE-framework.md`](./REFERENCE-framework.md) § ORM | Knex ORM in `core/orm`. |
|
|
19
|
-
| `createAuth`, `quickAuth`, `middleware: ['auth']` | [`REFERENCE-framework.md`](./REFERENCE-framework.md) § Auth | **`webspresso/core/auth`**. |
|
|
20
|
-
| Admin, sitemap, upload, redirect, data-exchange plugins | [`REFERENCE-framework.md`](./REFERENCE-framework.md) § Plugins | Framework plugin API (`createApp({ plugins })`). |
|
|
21
|
-
| Greenfield project, `webspresso new`, `dev`, `db:migrate`, `doctor` | [`REFERENCE-framework.md`](./REFERENCE-framework.md) § CLI | Full command table there. |
|
|
22
|
-
| Event bus, `kernel.createApp`, `defineFlow`, `definePlugin`, simulated `BaseRepository`, namespaced minimal views | [`REFERENCE-kernel.md`](./REFERENCE-kernel.md) | **Not** SSR **`createApp`** — [`doc/index.html#application-kernel`](../../../doc/index.html#application-kernel). |
|
|
23
|
-
| Long-form narrative, all options | [`README.md`](../../../README.md), [`doc/index.html`](../../../doc/index.html) | Single-page HTML docs. |
|
|
24
|
-
| System structure, feature sets, C4 map | [`docs/ARCHITECTURE.md`](../../../docs/ARCHITECTURE.md) | **Update when adding plugins, CLI commands, or extension points.** |
|
|
25
|
-
|
|
26
|
-
## CLI cheat sheet
|
|
27
|
-
|
|
28
|
-
| Command | Purpose |
|
|
29
|
-
|---------|---------|
|
|
30
|
-
| `webspresso new [name]` or `webspresso new .` | Scaffold a new app (Tailwind, i18n, optional DB). |
|
|
31
|
-
| `webspresso new . --yes` | Non-interactive scaffold (CI / agents). |
|
|
32
|
-
| `webspresso new . --yes -i` | Scaffold + install deps / CSS build. |
|
|
33
|
-
| `webspresso dev` | Dev server (watch). |
|
|
34
|
-
| `webspresso db:migrate` / `db:rollback` / `db:status` | ORM migrations. |
|
|
35
|
-
| `webspresso doctor` | Environment / project sanity checks. |
|
|
36
|
-
| `webspresso skill --preset webspresso` | Copies this skill bundle under `.agents/skills/webspresso-usage/` (`SKILL.md` + `REFERENCE-*.md`). |
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
## When to use this skill
|
|
40
|
-
|
|
41
|
-
- **`REFERENCE-framework.md`:** Routes, APIs, ORM, auth, plugins, i18n, hooks, client runtime (Alpine/swup), `setupRoutes`, 404 ordering.
|
|
42
|
-
- **`REFERENCE-kernel.md`:** `kernel`, domain events, `dispatch` / `publish`, `registerFlow`, `definePlugin` inside the kernel.
|
|
43
|
-
|
|
44
|
-
They are independent: most apps only need SSR **`createApp`**; the kernel is optional.
|
|
45
|
-
|
|
46
|
-
## Architecture maintenance
|
|
47
|
-
|
|
48
|
-
When you add or materially change a **plugin**, **CLI command**, **extension point**, or **request-pipeline rule**, update [`docs/ARCHITECTURE.md`](../../../docs/ARCHITECTURE.md) (feature-set section + changelog).
|