cabloy 5.1.59 → 5.1.60
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/.claude/skills/cabloy-contract-loop/SKILL.md +16 -0
- package/.claude/skills/cabloy-contract-loop/references/contract-loop-map.md +26 -0
- package/.claude/skills/cabloy-contract-loop/references/resource-custom-state-pattern.md +144 -0
- package/.claude/skills/cabloy-contract-loop/references/verification-checklist.md +18 -0
- package/.claude/skills/cabloy-resource-field-update/SKILL.md +267 -0
- package/.claude/skills/cabloy-resource-field-update/evals/evals.json +53 -0
- package/.claude/skills/cabloy-resource-field-update/references/custom-renderer-demo-checklist.md +102 -0
- package/.claude/skills/cabloy-resource-field-update/references/field-update-decision-tree.md +120 -0
- package/.claude/skills/cabloy-resource-field-update/references/follow-up-checklist.md +80 -0
- package/.claude/skills/cabloy-resource-field-update/references/verification-checklist.md +97 -0
- package/.github/workflows/docs-pages.yml +2 -0
- package/.github/workflows/vona-cov-pg.yml +2 -0
- package/.github/workflows/vona-test-crud.yml +4 -2
- package/.github/workflows/vona-test-mysql.yml +2 -0
- package/.github/workflows/vona-test-pg.yml +2 -0
- package/.github/workflows/vona-test-sqlite3.yml +2 -0
- package/.github/workflows/vona-tsc.yml +2 -0
- package/.github/workflows/zova-ui.yml +2 -0
- package/.gitignore +0 -4
- package/CHANGELOG.md +30 -0
- package/CLAUDE.md +2 -0
- package/README.md +15 -0
- package/cabloy-docs/.vitepress/config.mjs +43 -0
- package/cabloy-docs/ai/class-placement-rule.md +2 -0
- package/cabloy-docs/ai/cli-to-skill-map.md +7 -0
- package/cabloy-docs/ai/future-skill-roadmap.md +17 -2
- package/cabloy-docs/backend/bean-scene-authoring.md +350 -0
- package/cabloy-docs/backend/cli.md +26 -1
- package/cabloy-docs/backend/foundation.md +28 -3
- package/cabloy-docs/backend/introduction.md +8 -0
- package/cabloy-docs/backend/service-guide.md +2 -0
- package/cabloy-docs/backend/websocket-call-flow.md +435 -0
- package/cabloy-docs/backend/websocket-guide.md +455 -0
- package/cabloy-docs/backend/websocket-protocol-guide.md +381 -0
- package/cabloy-docs/backend/websocket-usage-guide.md +356 -0
- package/cabloy-docs/frontend/bean-scene-authoring.md +372 -0
- package/cabloy-docs/frontend/behavior-guide.md +449 -0
- package/cabloy-docs/frontend/cli.md +12 -0
- package/cabloy-docs/frontend/introduction.md +5 -0
- package/cabloy-docs/frontend/ioc-and-beans.md +10 -9
- package/cabloy-docs/frontend/router-tabs-admin-web-comparison.md +206 -0
- package/cabloy-docs/frontend/router-tabs-introduction.md +106 -0
- package/cabloy-docs/frontend/router-tabs-mechanism.md +469 -0
- package/cabloy-docs/frontend/router-tabs-overview.md +227 -0
- package/cabloy-docs/frontend/router-tabs-route-meta-cookbook.md +343 -0
- package/cabloy-docs/frontend/ssr-architecture-overview.md +211 -0
- package/cabloy-docs/frontend/ssr-build-deploy-guide.md +308 -0
- package/cabloy-docs/frontend/ssr-review-checklist.md +184 -0
- package/cabloy-docs/frontend/ssr-troubleshooting-guide.md +301 -0
- package/cabloy-docs/fullstack/framework-performance.md +3 -3
- package/cabloy-docs/fullstack/introduction.md +29 -0
- package/cabloy-docs/fullstack/quickstart.md +7 -1
- package/cabloy-docs/fullstack/tutorial-1-first-module.md +111 -0
- package/cabloy-docs/fullstack/tutorial-2-first-crud.md +122 -0
- package/cabloy-docs/fullstack/tutorial-3-frontend-metadata-sharing.md +131 -0
- package/cabloy-docs/fullstack/tutorial-4-custom-level-renderers.md +119 -0
- package/cabloy-docs/fullstack/tutorial-5-backend-contract-sharing.md +144 -0
- package/cabloy-docs/fullstack/tutorial-6-one-contract-four-uses.md +168 -0
- package/cabloy-docs/fullstack/tutorials-overview.md +179 -0
- package/cabloy-docs/index.md +4 -3
- package/cabloy-docs/reference/bean-scene-boilerplates.md +73 -0
- package/cabloy-docs/reference/cli-reference.md +2 -0
- package/package.json +6 -2
- package/scripts/init.ts +18 -2
- package/vona/packages-cli/cabloy-cli/package.json +2 -2
- package/vona/packages-cli/cli/package.json +1 -1
- package/vona/packages-cli/cli-set-api/package.json +1 -1
- package/vona/packages-cli/cli-set-api/src/lib/bean/cli.create.module.ts +4 -0
- package/vona/packages-vona/vona/package.json +1 -1
- package/vona/pnpm-lock.yaml +133 -1088
- package/vona/pnpm-workspace.yaml +0 -1
- package/vona/src/suite-vendor/a-vona/modules/a-core/assets/static/img/vona.svg +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-core/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-permission/package.json +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-permission/src/bean/bean.permission.ts +1 -1
- package/vona/src/suite-vendor/a-vona/modules/a-upload/package.json +2 -2
- package/vona/src/suite-vendor/a-vona/package.json +1 -1
- package/zova/package.original.json +1 -1
- package/zova/packages-cli/cli/package.json +3 -3
- package/zova/packages-cli/cli-set-front/cli/templates/init/icon/boilerplate/icons/default/zova.svg +1 -1
- package/zova/packages-cli/cli-set-front/package.json +3 -3
- package/zova/packages-cli/cli-set-front/src/lib/bean/cli.create.module.ts +4 -0
- package/zova/packages-cli/cli-set-front/src/lib/command/create.bean.ts +5 -1
- package/zova/packages-utils/zova-vite/package.json +2 -2
- package/zova/packages-zova/zova/package.json +2 -2
- package/zova/pnpm-lock.yaml +284 -1313
- package/zova/pnpm-workspace.yaml +0 -1
- package/zova/src/suite/a-home/modules/home-icon/icons/social/cabloy.svg +1 -1
- package/zova/src/suite/a-home/modules/home-icon/icons/social/vona.svg +1 -1
- package/zova/src/suite/a-home/modules/home-icon/icons/social/zova.svg +1 -1
- package/zova/src/suite/a-home/modules/home-icon/src/.metadata/icons/groups/social.svg +3 -3
- package/zova/src/suite/cabloy-basic/modules/basic-select/src/component/formFieldSelect/controller.tsx +9 -0
- package/zova/src/suite-vendor/a-cabloy/modules/rest-resource/package.json +1 -1
- package/zova/src/suite-vendor/a-cabloy/modules/rest-resource/src/model/resource.ts +66 -16
- package/zova/src/suite-vendor/a-cabloy/package.json +2 -2
- package/zova/src/suite-vendor/a-zova/modules/a-routertabs/package.json +1 -1
- package/zova/src/suite-vendor/a-zova/modules/a-routertabs/src/model/tabs.ts +60 -18
- package/zova/src/suite-vendor/a-zova/modules/a-table/cli/tableActionRow/boilerplate/{{sceneName}}.{{beanName}}.tsx_ +6 -1
- package/zova/src/suite-vendor/a-zova/modules/a-table/cli/tableCell/boilerplate/{{sceneName}}.{{beanName}}.tsx_ +6 -1
- package/zova/src/suite-vendor/a-zova/modules/a-table/package.json +1 -1
- package/zova/src/suite-vendor/a-zova/modules/a-zova/package.json +2 -2
- package/zova/src/suite-vendor/a-zova/package.json +4 -4
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
# Backend Bean Scene Authoring
|
|
2
|
+
|
|
3
|
+
This guide explains the **advanced** Vona workflow for creating a **new backend bean scene**.
|
|
4
|
+
|
|
5
|
+
This is not the same as creating one more bean inside an existing scene such as `service`, `model`, or `dto`.
|
|
6
|
+
|
|
7
|
+
For ordinary bean creation inside an existing scene, use the existing CLI workflow documented in [Backend CLI](/backend/cli) and the scene-specific guides. This page is for framework extension work where you need to define a new scene contract.
|
|
8
|
+
|
|
9
|
+
## When you need this guide
|
|
10
|
+
|
|
11
|
+
Use this guide when you need to extend the backend bean system itself, for example:
|
|
12
|
+
|
|
13
|
+
- define a new decorator such as `@Something()`
|
|
14
|
+
- teach `:create:bean` how to scaffold that scene
|
|
15
|
+
- add new scene-level metadata behavior
|
|
16
|
+
- decide whether the scene should appear in module scope resources
|
|
17
|
+
- decide whether the scene should contribute to the general bean registry
|
|
18
|
+
|
|
19
|
+
If you only need a new service or model bean, you do **not** need this page.
|
|
20
|
+
|
|
21
|
+
## Mental model
|
|
22
|
+
|
|
23
|
+
For most scene-based backend beans, the scene is the middle layer inside the bean identity:
|
|
24
|
+
|
|
25
|
+
- bean identifier: `{module}.{scene}.{bean}`
|
|
26
|
+
- onion name: `{module}:{bean}`
|
|
27
|
+
- scene name: the operational family such as `service`, `model`, `entity`, `dto`, or `startup`
|
|
28
|
+
|
|
29
|
+
A practical exception is the built-in global `bean` scene, whose generated global shorthand entries use the plain bean name rather than the full `module.scene.bean` pattern.
|
|
30
|
+
|
|
31
|
+
The scene is not only a naming convention. It controls several framework behaviors:
|
|
32
|
+
|
|
33
|
+
- which decorator marks the class
|
|
34
|
+
- where the CLI places generated files
|
|
35
|
+
- whether the scene contributes to scope resources
|
|
36
|
+
- whether the scene contributes to general bean typing
|
|
37
|
+
- whether scene-specific metadata generation runs
|
|
38
|
+
|
|
39
|
+
## The smallest built-in pattern
|
|
40
|
+
|
|
41
|
+
The simplest built-in scene is a thin decorator wrapper over `createBeanDecorator(...)`.
|
|
42
|
+
|
|
43
|
+
Representative pattern:
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { createBeanDecorator } from 'vona';
|
|
47
|
+
|
|
48
|
+
export function Service(): ClassDecorator {
|
|
49
|
+
return createBeanDecorator('service');
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
That pattern is the first authoring surface of a new scene: give the scene a stable framework name.
|
|
54
|
+
|
|
55
|
+
Some scenes use richer decorator forms with options or scene-specific post-registration behavior. A good example is `Model()`, which is implemented outside the base bean module and passes scene options through the decorator contract.
|
|
56
|
+
|
|
57
|
+
## The backend authoring surfaces
|
|
58
|
+
|
|
59
|
+
A new backend bean scene usually touches five surfaces.
|
|
60
|
+
|
|
61
|
+
### 1. Decorator surface
|
|
62
|
+
|
|
63
|
+
Define the scene decorator and export it from the owning module.
|
|
64
|
+
|
|
65
|
+
Representative built-in patterns include:
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
export function Bean(): ClassDecorator {
|
|
69
|
+
return createBeanDecorator('bean');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function Scope(): ClassDecorator {
|
|
73
|
+
return createBeanDecorator('scope');
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
A scene-specific decorator can live in the base bean module or in a more specialized module. For example, `Model()` is implemented in the ORM module rather than the base bean module.
|
|
78
|
+
|
|
79
|
+
### 2. Scene typing surface
|
|
80
|
+
|
|
81
|
+
Add the scene to the declaration-merging type registry.
|
|
82
|
+
|
|
83
|
+
Representative pattern:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
declare module 'vona' {
|
|
87
|
+
export interface IBeanSceneRecord {
|
|
88
|
+
service: never;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
This tells the framework and generated typings that the scene exists.
|
|
94
|
+
|
|
95
|
+
Some scenes also extend a scene-specific record in their owning module. For example, the built-in service scene contributes to `IServiceRecord` and then maps that into the broader onion surface.
|
|
96
|
+
|
|
97
|
+
### 3. Onion metadata surface
|
|
98
|
+
|
|
99
|
+
Register the scene in the owning module `package.json` under `vonaModule.onions`.
|
|
100
|
+
|
|
101
|
+
Representative built-in pattern:
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"service": {
|
|
106
|
+
"sceneIsolate": true,
|
|
107
|
+
"scopeResource": true,
|
|
108
|
+
"beanGeneral": true,
|
|
109
|
+
"optionsGlobalInterfaceFrom": "vona-module-a-bean",
|
|
110
|
+
"boilerplate": "service/boilerplate"
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
This metadata is one of the main contracts for `:create:bean` and metadata generation.
|
|
116
|
+
|
|
117
|
+
### 4. CLI boilerplate surface
|
|
118
|
+
|
|
119
|
+
Provide the scaffold template used by `npm run vona :create:bean sceneName beanName -- --module=...`.
|
|
120
|
+
|
|
121
|
+
Representative built-in boilerplate:
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
import { BeanBase } from 'vona';
|
|
125
|
+
import { Bean } from 'vona-module-a-bean';
|
|
126
|
+
|
|
127
|
+
@Bean()
|
|
128
|
+
export class Bean<%=argv.beanNameCapitalize%> extends BeanBase {}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
The important point is not the exact class body. The important point is that the scene owns a template and the CLI resolves it through the onion metadata.
|
|
132
|
+
|
|
133
|
+
### 5. Metadata generation surface
|
|
134
|
+
|
|
135
|
+
Add custom metadata generation only when the scene needs output beyond the default scene scan.
|
|
136
|
+
|
|
137
|
+
Representative built-in pattern:
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
export default async function (options) {
|
|
141
|
+
const { sceneName, globFiles } = options;
|
|
142
|
+
// ...build declaration-merging content...
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
For example, the built-in `bean` scene adds `IBeanRecordGlobal` output through a custom metadata generator.
|
|
147
|
+
|
|
148
|
+
## How `vonaModule.onions` drives scene behavior
|
|
149
|
+
|
|
150
|
+
When adding a scene, the most important design step is deciding the scene flags.
|
|
151
|
+
|
|
152
|
+
### `sceneIsolate`
|
|
153
|
+
|
|
154
|
+
Use this when the scene should live in its own top-level folder rather than being mixed into `src/bean`.
|
|
155
|
+
|
|
156
|
+
Representative example:
|
|
157
|
+
|
|
158
|
+
- `service` uses `sceneIsolate: true`
|
|
159
|
+
- generated files live under `src/service/`
|
|
160
|
+
|
|
161
|
+
A non-isolated scene normally stays in `src/bean` using the `{scene}.{bean}` naming pattern.
|
|
162
|
+
|
|
163
|
+
### `scopeResource`
|
|
164
|
+
|
|
165
|
+
Use this when the scene should appear as a module scope resource such as `this.scope.service.student`.
|
|
166
|
+
|
|
167
|
+
If this flag is enabled, metadata generation will create module-scope typing such as:
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
export interface IModuleService {
|
|
171
|
+
student: ServiceStudent;
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Scenes without scope-resource behavior should not set this flag just for convenience.
|
|
176
|
+
|
|
177
|
+
### `beanGeneral`
|
|
178
|
+
|
|
179
|
+
Use this when the scene should contribute to the general bean registry.
|
|
180
|
+
|
|
181
|
+
Representative generated output:
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
declare module 'vona' {
|
|
185
|
+
export interface IBeanRecordGeneral {
|
|
186
|
+
'demo-student.service.student': ServiceStudent;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
This matters for container-oriented lookup and the broader typed bean surface.
|
|
192
|
+
|
|
193
|
+
### `boilerplate`
|
|
194
|
+
|
|
195
|
+
Use this to tell the CLI which template should be used when a bean of the scene is created.
|
|
196
|
+
|
|
197
|
+
### Multiple boilerplate variants
|
|
198
|
+
|
|
199
|
+
A backend scene can expose more than one named template.
|
|
200
|
+
|
|
201
|
+
A practical rule is:
|
|
202
|
+
|
|
203
|
+
- `boilerplate` provides the default template
|
|
204
|
+
- `--boilerplate=web` maps to `boilerplateWeb`
|
|
205
|
+
- more generally, `--boilerplate=name` maps to `boilerplateName`
|
|
206
|
+
|
|
207
|
+
This is useful when one scene needs multiple scaffold shapes for distinct runtime targets or authoring paths.
|
|
208
|
+
|
|
209
|
+
Representative built-in examples include `ssrMenu` and `ssrMenuGroup`, which expose both the default template and a `web` variant in module metadata.
|
|
210
|
+
|
|
211
|
+
### `metadataCustom`
|
|
212
|
+
|
|
213
|
+
Use this only when the scene needs additional generated output that is not covered by the standard metadata passes.
|
|
214
|
+
|
|
215
|
+
A good rule is:
|
|
216
|
+
|
|
217
|
+
- start without custom metadata if the default scene wiring is enough
|
|
218
|
+
- add `metadataCustom` only when the scene has a real extra output contract
|
|
219
|
+
|
|
220
|
+
## Authoring flow for a new backend scene
|
|
221
|
+
|
|
222
|
+
A practical Vona scene-authoring workflow is:
|
|
223
|
+
|
|
224
|
+
1. choose the owning module for the scene
|
|
225
|
+
2. add the scene decorator
|
|
226
|
+
3. export it from the module `src/lib/index.ts`
|
|
227
|
+
4. add the scene declaration-merging type and export it from `src/types/index.ts`
|
|
228
|
+
5. add the scene under `vonaModule.onions`
|
|
229
|
+
6. create the scene boilerplate for `:create:bean`
|
|
230
|
+
7. add custom metadata generation if the scene needs extra emitted typings
|
|
231
|
+
8. run bean creation in a representative module
|
|
232
|
+
9. inspect the generated `.metadata/index.ts` output
|
|
233
|
+
10. only then write any additional scene-specific docs or business examples
|
|
234
|
+
|
|
235
|
+
## What generated output should prove
|
|
236
|
+
|
|
237
|
+
A new scene is usually correct only if the generated metadata proves the intended contract.
|
|
238
|
+
|
|
239
|
+
Depending on scene flags, inspect for output such as:
|
|
240
|
+
|
|
241
|
+
- declaration merging for the scene itself
|
|
242
|
+
- `IBeanRecordGeneral`
|
|
243
|
+
- module scope-resource interfaces such as `IModuleService`
|
|
244
|
+
- bean instance helpers such as `$beanFullName` and `$onionName`
|
|
245
|
+
- scope-class integration for module resource access
|
|
246
|
+
|
|
247
|
+
Representative generated service output includes:
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
export interface ServiceStudent {
|
|
251
|
+
get $beanFullName(): 'demo-student.service.student';
|
|
252
|
+
get $onionName(): 'demo-student:student';
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
and:
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
export interface IModuleService {
|
|
260
|
+
student: ServiceStudent;
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
If the generated metadata does not match the scene design, fix the scene contract first rather than patching the generated output manually.
|
|
265
|
+
|
|
266
|
+
## A useful split: adding a scene vs adding a bean
|
|
267
|
+
|
|
268
|
+
Keep these two tasks separate.
|
|
269
|
+
|
|
270
|
+
### Add a bean inside an existing scene
|
|
271
|
+
|
|
272
|
+
Example:
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
npm run vona :create:bean service student -- --module=demo-student
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
This uses an already-defined scene.
|
|
279
|
+
|
|
280
|
+
### Add a new scene
|
|
281
|
+
|
|
282
|
+
This requires framework extension work:
|
|
283
|
+
|
|
284
|
+
- new decorator
|
|
285
|
+
- new scene type registration
|
|
286
|
+
- new onion metadata entry
|
|
287
|
+
- new boilerplate
|
|
288
|
+
- optional metadata generation
|
|
289
|
+
|
|
290
|
+
That is why this topic belongs in an advanced guide.
|
|
291
|
+
|
|
292
|
+
## Design rules for new scenes
|
|
293
|
+
|
|
294
|
+
Before adding a scene, ask these questions.
|
|
295
|
+
|
|
296
|
+
### Should the scene be isolated?
|
|
297
|
+
|
|
298
|
+
Choose an isolated scene when the scene deserves its own first-class folder and operational identity, similar to `service`.
|
|
299
|
+
|
|
300
|
+
Choose a non-isolated scene when the scene is better modeled as a bean-family variant under `src/bean`.
|
|
301
|
+
|
|
302
|
+
### Should the scene appear in module scope?
|
|
303
|
+
|
|
304
|
+
Enable scope-resource generation only when the scene should behave like a normal module resource family.
|
|
305
|
+
|
|
306
|
+
If the scene is mainly metadata, infrastructure glue, or a special registry surface, scope exposure may be the wrong contract.
|
|
307
|
+
|
|
308
|
+
### Should the scene be part of the general bean registry?
|
|
309
|
+
|
|
310
|
+
Enable `beanGeneral` only when typed global/general bean lookup is part of the intended developer surface.
|
|
311
|
+
|
|
312
|
+
### Does the scene need custom metadata?
|
|
313
|
+
|
|
314
|
+
Do not add custom generation only because it is available. Add it when the scene needs a real emitted surface beyond the default metadata pipeline.
|
|
315
|
+
|
|
316
|
+
## Relationship to existing guides
|
|
317
|
+
|
|
318
|
+
Read this guide together with:
|
|
319
|
+
|
|
320
|
+
- [Backend Foundation](/backend/foundation)
|
|
321
|
+
- [Backend CLI](/backend/cli)
|
|
322
|
+
- [Service Guide](/backend/service-guide)
|
|
323
|
+
- [Model Guide](/backend/model-guide)
|
|
324
|
+
- [Entity Guide](/backend/entity-guide)
|
|
325
|
+
- [Backend Startup Guide](/backend/startup-guide)
|
|
326
|
+
|
|
327
|
+
Use the basic guides for normal bean creation. Use this page only when extending the scene system itself.
|
|
328
|
+
|
|
329
|
+
## Verification checklist
|
|
330
|
+
|
|
331
|
+
When authoring or documenting a new backend scene, verify in this order:
|
|
332
|
+
|
|
333
|
+
1. confirm the CLI command shape still exists:
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
npm run vona :create:bean --help
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
2. confirm the scene decorator, scene typing, and `vonaModule.onions` entry agree
|
|
340
|
+
3. create a test bean in a representative module
|
|
341
|
+
4. inspect the generated source placement
|
|
342
|
+
5. inspect `src/.metadata/index.ts` in that module
|
|
343
|
+
6. confirm scope resources and general bean output match the design
|
|
344
|
+
7. run the narrowest meaningful type or docs verification for the change
|
|
345
|
+
|
|
346
|
+
For repo-wide docs verification, also run:
|
|
347
|
+
|
|
348
|
+
```bash
|
|
349
|
+
npm run docs:build
|
|
350
|
+
```
|
|
@@ -122,6 +122,24 @@ A practical bean-scene reading is:
|
|
|
122
122
|
- `:create:bean sceneName beanName -- --module=...` uses `sceneName` as the operational family slot inside the bean identifier
|
|
123
123
|
- this is why generated bean names later appear in forms such as `module.scene.bean`
|
|
124
124
|
|
|
125
|
+
## Bean boilerplate variants
|
|
126
|
+
|
|
127
|
+
Some backend bean scenes expose more than one scaffold template.
|
|
128
|
+
|
|
129
|
+
In those cases, use `--boilerplate=...` to select a named variant:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
npm run vona :create:bean ssrMenu menuTest -- --module=demo-student --boilerplate=web
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
A practical rule is:
|
|
136
|
+
|
|
137
|
+
- the default scene template comes from the scene metadata `boilerplate`
|
|
138
|
+
- a named variant such as `--boilerplate=web` maps to a metadata key such as `boilerplateWeb`
|
|
139
|
+
- supported variants are scene-defined, so do not assume every scene exposes them
|
|
140
|
+
|
|
141
|
+
For the current cross-stack lookup table, see [Bean Scene Boilerplate Variants](/reference/bean-scene-boilerplates).
|
|
142
|
+
|
|
125
143
|
## Initializer-family examples
|
|
126
144
|
|
|
127
145
|
Not every backend resource is created through bean scenes.
|
|
@@ -131,13 +149,20 @@ Representative initializer commands include:
|
|
|
131
149
|
```bash
|
|
132
150
|
npm run vona :init:constant demo-student
|
|
133
151
|
npm run vona :init:types demo-student
|
|
152
|
+
npm run vona :init:lib demo-student
|
|
134
153
|
npm run vona :init:asset static -- --module=demo-student
|
|
135
154
|
```
|
|
136
155
|
|
|
137
156
|
A practical distinction is:
|
|
138
157
|
|
|
139
158
|
- `:create:bean` creates scene-based backend beans
|
|
140
|
-
- `:init:*` commands create module-scope resources such as constants, typings, or asset-resource structure
|
|
159
|
+
- `:init:*` commands create module-scope resources such as constants, typings, helper directories, or asset-resource structure
|
|
160
|
+
|
|
161
|
+
A practical helper-placement rule is:
|
|
162
|
+
|
|
163
|
+
- if a backend module needs reusable pure helper functions, initialize `src/lib` with `npm run vona :init:lib demo-student`
|
|
164
|
+
- place those shared helpers under `src/lib` and export shared entrypoints from `src/lib/index.ts`
|
|
165
|
+
- if the logic needs container-managed runtime behavior, do not force it into `src/lib`; re-evaluate `src/service` or another bean scene instead
|
|
141
166
|
|
|
142
167
|
## Relationship to modules, suites, and package metadata
|
|
143
168
|
|
|
@@ -91,7 +91,7 @@ A practical rule is:
|
|
|
91
91
|
| -------------------- | ------------------------------------------------------------------- | -------------------------------------------------------- |
|
|
92
92
|
| Dependency injection | explicit wiring in the current class | `@Use('demo-student.service.student')` |
|
|
93
93
|
| Dependency lookup | ordinary module-oriented business code | `this.scope.service.student` |
|
|
94
|
-
| Direct bean access | container-aware control or request
|
|
94
|
+
| Direct bean access | container-aware control through the app container or request scope | `this.bean._getBean(...)`, `this.ctx.bean._getBean(...)` |
|
|
95
95
|
| Fresh bean creation | workflows that should not reuse the ordinary resolved bean instance | `this.bean._newBean(...)` |
|
|
96
96
|
|
|
97
97
|
## Dependency injection vs dependency lookup vs direct bean access
|
|
@@ -134,6 +134,12 @@ this.ctx.bean._getBean('demo-student.service.student');
|
|
|
134
134
|
this.bean._newBean('demo-student.service.student');
|
|
135
135
|
```
|
|
136
136
|
|
|
137
|
+
A practical distinction is:
|
|
138
|
+
|
|
139
|
+
- `this.bean._getBean(...)` uses app-level container access
|
|
140
|
+
- `this.ctx.bean._getBean(...)` uses request-scoped container access
|
|
141
|
+
- `this.bean._newBean(...)` creates a fresh bean instance instead of reusing the ordinary resolved one
|
|
142
|
+
|
|
137
143
|
The important conceptual split is:
|
|
138
144
|
|
|
139
145
|
- injection wires a dependency into the current class
|
|
@@ -146,7 +152,7 @@ Legacy Vona essentials docs made bean identity more explicit, and that identity
|
|
|
146
152
|
|
|
147
153
|
The most important terms are:
|
|
148
154
|
|
|
149
|
-
- **bean identifier**: a dotted identity such as `{moduleName}.{sceneName}.{beanName}`
|
|
155
|
+
- **bean identifier**: for most scene-based beans, a dotted identity such as `{moduleName}.{sceneName}.{beanName}`
|
|
150
156
|
- **onion name**: a colon-based framework name such as `{moduleName}:{beanName}`
|
|
151
157
|
- **bean scene**: the operational family a bean belongs to, such as service, model, startup, queue, or broadcast
|
|
152
158
|
|
|
@@ -159,12 +165,31 @@ This matters because naming is not cosmetic. It affects:
|
|
|
159
165
|
|
|
160
166
|
A practical naming rule is:
|
|
161
167
|
|
|
162
|
-
-
|
|
168
|
+
- most scene-based beans use the fully qualified `module.scene.bean` form such as `demo-student.service.student`
|
|
163
169
|
- onion name uses the shorter `module:bean` form such as `demo-student:student`
|
|
164
170
|
- bean scene is the middle grouping layer that turns one module into operational families like `service`, `model`, `entity`, `dto`, or `startup`
|
|
171
|
+
- the built-in global `bean` scene is an intentional exception and uses the plain bean name in the global shorthand surface
|
|
172
|
+
|
|
173
|
+
If you need to create a **new backend bean scene** rather than only adding another bean to an existing scene, see [Backend Bean Scene Authoring](/backend/bean-scene-authoring).
|
|
165
174
|
|
|
166
175
|
For deciding whether backend base classes belong in `src/lib`, `src/service`, or the global bean shorthand surface, also see [Class Placement Rule](/ai/class-placement-rule).
|
|
167
176
|
|
|
177
|
+
## Module-local helper functions
|
|
178
|
+
|
|
179
|
+
When you extract reusable helper functions for one backend module, initialize the module `src/lib` directory and place those helpers there.
|
|
180
|
+
|
|
181
|
+
A practical rule is:
|
|
182
|
+
|
|
183
|
+
- keep shared pure helpers in `src/lib`
|
|
184
|
+
- export them from `src/lib/index.ts` when multiple module files should reuse them
|
|
185
|
+
- avoid leaving reusable helper logic duplicated or buried inside `entity`, `dto`, `service`, or `controller` files
|
|
186
|
+
- if the logic needs bean lifecycle, injection, selector lookup, or other container-managed behavior, do not treat it as a plain helper; re-evaluate `src/service` or another bean scene instead
|
|
187
|
+
|
|
188
|
+
This complements the class placement rule:
|
|
189
|
+
|
|
190
|
+
- `src/lib` is the normal home for pure reusable helper logic
|
|
191
|
+
- `src/service` or other bean scenes remain the fit for container-managed runtime behavior
|
|
192
|
+
|
|
168
193
|
## BeanBase built-ins
|
|
169
194
|
|
|
170
195
|
A large part of the backend essentials model is that ordinary backend beans already inherit a useful working surface from `BeanBase`.
|
|
@@ -61,6 +61,10 @@ Use this path when the task is about runtime shape, startup, instances, workers,
|
|
|
61
61
|
- [Election Guide](/backend/election-guide)
|
|
62
62
|
- [Queue Guide](/backend/queue-guide)
|
|
63
63
|
- [Broadcast Guide](/backend/broadcast-guide)
|
|
64
|
+
- [Web Socket Guide](/backend/websocket-guide)
|
|
65
|
+
- [Web Socket Usage Guide](/backend/websocket-usage-guide)
|
|
66
|
+
- [Web Socket Protocol Guide](/backend/websocket-protocol-guide)
|
|
67
|
+
- [Web Socket Call Flow](/backend/websocket-call-flow)
|
|
64
68
|
- [Schedule Guide](/backend/schedule-guide)
|
|
65
69
|
- [Redlock Guide](/backend/redlock-guide)
|
|
66
70
|
|
|
@@ -91,5 +95,9 @@ If your task is already inside the runtime and distributed family, read these gu
|
|
|
91
95
|
- [Election Guide](/backend/election-guide)
|
|
92
96
|
- [Queue Guide](/backend/queue-guide)
|
|
93
97
|
- [Broadcast Guide](/backend/broadcast-guide)
|
|
98
|
+
- [Web Socket Guide](/backend/websocket-guide)
|
|
99
|
+
- [Web Socket Usage Guide](/backend/websocket-usage-guide)
|
|
100
|
+
- [Web Socket Protocol Guide](/backend/websocket-protocol-guide)
|
|
101
|
+
- [Web Socket Call Flow](/backend/websocket-call-flow)
|
|
94
102
|
- [Schedule Guide](/backend/schedule-guide)
|
|
95
103
|
- [Redlock Guide](/backend/redlock-guide)
|
|
@@ -144,6 +144,8 @@ That means service access should be understood together with:
|
|
|
144
144
|
|
|
145
145
|
For deciding whether a backend base class should stay a helper, move into service-scene, or remain part of the global bean shorthand surface, also see [Class Placement Rule](/ai/class-placement-rule).
|
|
146
146
|
|
|
147
|
+
For reusable module-local helper functions, prefer the module `src/lib` directory. If the logic needs container-managed runtime behavior rather than plain helper placement, re-evaluate whether it belongs in service-scene instead. For the fuller rule, also see [Backend Foundation](/backend/foundation).
|
|
148
|
+
|
|
147
149
|
Read this guide together with:
|
|
148
150
|
|
|
149
151
|
- [Backend Foundation](/backend/foundation)
|