fragment-ts 1.2.3 → 1.2.5
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/API.md +76 -243
- package/DOCS.md +88 -294
- package/README.md +56 -97
- package/SETUP.md +71 -74
- package/USAGE.md +56 -138
- package/dist/core/index.d.ts +19 -20
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +10 -11
- package/dist/core/index.js.map +1 -1
- package/dist/core/metadata/metadata-keys.d.ts +0 -7
- package/dist/core/metadata/metadata-keys.d.ts.map +1 -1
- package/dist/core/metadata/metadata-keys.js +0 -8
- package/dist/core/metadata/metadata-keys.js.map +1 -1
- package/dist/index.d.ts +22 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +48 -63
- package/dist/index.js.map +1 -1
- package/dist/platform/cli/commands/make/command.d.ts.map +1 -1
- package/dist/platform/cli/commands/make/command.js +1 -5
- package/dist/platform/cli/commands/make/command.js.map +1 -1
- package/dist/platform/cli/scaffold/generate/component-generator.d.ts +0 -4
- package/dist/platform/cli/scaffold/generate/component-generator.d.ts.map +1 -1
- package/dist/platform/cli/scaffold/generate/component-generator.js +3 -97
- package/dist/platform/cli/scaffold/generate/component-generator.js.map +1 -1
- package/dist/platform/cli/scaffold/init/init.scaffold.d.ts.map +1 -1
- package/dist/platform/cli/scaffold/init/init.scaffold.js +3 -145
- package/dist/platform/cli/scaffold/init/init.scaffold.js.map +1 -1
- package/dist/platform/cli/scaffold/init/prompts.d.ts.map +1 -1
- package/dist/platform/cli/scaffold/init/prompts.js +0 -26
- package/dist/platform/cli/scaffold/init/prompts.js.map +1 -1
- package/dist/platform/cli/scaffold/init/types.d.ts +0 -5
- package/dist/platform/cli/scaffold/init/types.d.ts.map +1 -1
- package/dist/platform/web/bootstrap/ApplicationBootstrapper.d.ts +2 -2
- package/dist/platform/web/bootstrap/ApplicationBootstrapper.d.ts.map +1 -1
- package/dist/platform/web/bootstrap/ApplicationBootstrapper.js +8 -8
- package/dist/platform/web/bootstrap/ApplicationBootstrapper.js.map +1 -1
- package/dist/platform/web/bootstrap/ComponentRegistrar.d.ts.map +1 -1
- package/dist/platform/web/bootstrap/ComponentRegistrar.js +0 -4
- package/dist/platform/web/bootstrap/ComponentRegistrar.js.map +1 -1
- package/dist/shared/config.utils.d.ts +0 -24
- package/dist/shared/config.utils.d.ts.map +1 -1
- package/dist/shared/config.utils.js +0 -3
- package/dist/shared/config.utils.js.map +1 -1
- package/dist/shared/errors.d.ts +0 -9
- package/dist/shared/errors.d.ts.map +1 -1
- package/dist/shared/errors.js +1 -19
- package/dist/shared/errors.js.map +1 -1
- package/package.json +1 -1
- package/examples/blog-api/.env.example +0 -14
- package/examples/blog-api/.eslintignore +0 -3
- package/examples/blog-api/.eslintrc.json +0 -25
- package/examples/blog-api/.prettierrc +0 -6
- package/examples/blog-api/fragment.json +0 -56
- package/examples/blog-api/package-lock.json +0 -7062
- package/examples/blog-api/package.json +0 -33
- package/examples/blog-api/postcss.config.js +0 -6
- package/examples/blog-api/src/entities/user.entity.ts +0 -19
- package/examples/blog-api/src/frontend/styles/tailwind.css +0 -3
- package/examples/blog-api/src/main.ts +0 -15
- package/examples/blog-api/src/modules/app/components/header.component.ts +0 -4
- package/examples/blog-api/src/modules/app/controllers/app.controller.ts +0 -18
- package/examples/blog-api/src/modules/app/services/app.service.ts +0 -8
- package/examples/blog-api/src/modules/app/stores/home.store.ts +0 -12
- package/examples/blog-api/src/modules/app/templates/app.template.ts +0 -8
- package/examples/blog-api/src/modules/app/views/home.view.ts +0 -9
- package/examples/blog-api/src/modules/jobs/example.job.ts +0 -9
- package/examples/blog-api/src/modules/mail/primary.mail.ts +0 -13
- package/examples/blog-api/src/test/app.spec.ts +0 -20
- package/examples/blog-api/tailwind.config.js +0 -8
- package/examples/blog-api/tsconfig.json +0 -24
package/API.md
CHANGED
|
@@ -4,6 +4,7 @@ This document lists public exports and their intended usage.
|
|
|
4
4
|
Each item is documented on its own line for easy search and indexing.
|
|
5
5
|
|
|
6
6
|
## Core Application
|
|
7
|
+
|
|
7
8
|
- `FragmentApplication(options)` class decorator
|
|
8
9
|
- `FragmentWebApplication` bootstrap class
|
|
9
10
|
- `DIContainer` dependency injection container
|
|
@@ -11,6 +12,7 @@ Each item is documented on its own line for easy search and indexing.
|
|
|
11
12
|
- `ComponentScanner` manual component scanning
|
|
12
13
|
|
|
13
14
|
## Core Decorators
|
|
15
|
+
|
|
14
16
|
- `@FragmentApplication(options)`
|
|
15
17
|
- `@Controller(path?)`
|
|
16
18
|
- `@Service()`
|
|
@@ -19,6 +21,7 @@ Each item is documented on its own line for easy search and indexing.
|
|
|
19
21
|
- `@AutoConfiguration()`
|
|
20
22
|
|
|
21
23
|
## Injection Decorators
|
|
24
|
+
|
|
22
25
|
- `@Autowired()`
|
|
23
26
|
- `@Inject(token)`
|
|
24
27
|
- `@InjectRepository(entity)`
|
|
@@ -28,6 +31,7 @@ Each item is documented on its own line for easy search and indexing.
|
|
|
28
31
|
- `@Lazy()`
|
|
29
32
|
|
|
30
33
|
## HTTP Decorators
|
|
34
|
+
|
|
31
35
|
- `@Get(path?)`
|
|
32
36
|
- `@Post(path?)`
|
|
33
37
|
- `@Put(path?)`
|
|
@@ -41,63 +45,50 @@ Each item is documented on its own line for easy search and indexing.
|
|
|
41
45
|
- `@Res()`
|
|
42
46
|
|
|
43
47
|
## Lifecycle Decorators
|
|
48
|
+
|
|
44
49
|
- `@PostConstruct()`
|
|
45
50
|
- `@PreDestroy()`
|
|
46
51
|
- `@OnStartup(order?)`
|
|
47
52
|
- `@OnShutdown(order?)`
|
|
48
53
|
|
|
49
54
|
## Pipeline Decorators
|
|
55
|
+
|
|
50
56
|
- `@FragmentMiddleware(MiddlewareClass)`
|
|
51
57
|
- `@FragmentGuard(GuardClass)`
|
|
52
58
|
- `@FragmentInterceptor(InterceptorClass)`
|
|
53
59
|
- `@FragmentExceptionFilter(ExceptionFilterClass)`
|
|
54
60
|
|
|
55
61
|
## Plugin Decorators
|
|
62
|
+
|
|
56
63
|
- `@Plugin(options)`
|
|
57
64
|
- `@Plugin(token, qualifier?) (property)`
|
|
58
65
|
- `@OnPluginInit(order?)`
|
|
59
66
|
- `@OnPluginShutdown(order?)`
|
|
60
67
|
|
|
61
68
|
## Mail Decorators
|
|
69
|
+
|
|
62
70
|
- `@Mailer(options)`
|
|
63
71
|
- `@Mail(qualifier?) (property)`
|
|
64
72
|
- `@MailTemplate(options)`
|
|
65
73
|
|
|
66
74
|
## Notification Decorators
|
|
75
|
+
|
|
67
76
|
- `@NotificationChannel(options)`
|
|
68
77
|
|
|
69
78
|
## Jobs Decorators
|
|
79
|
+
|
|
70
80
|
- `@Job(options)`
|
|
71
81
|
- `@Cron(expression, options?)`
|
|
72
82
|
|
|
73
|
-
## Frontend Decorators
|
|
74
|
-
- `@View(options)`
|
|
75
|
-
- `@Views(options)`
|
|
76
|
-
- `@Store(options)`
|
|
77
|
-
- `@UIComponent(options)`
|
|
78
|
-
- `@Template(options)`
|
|
79
|
-
- `@Templates(options)`
|
|
80
|
-
- `@Action(options)`
|
|
81
|
-
- `@Actions(options)`
|
|
82
|
-
- `@Effect(options)`
|
|
83
|
-
- `@Effects(options)`
|
|
84
|
-
- `@State(options?)`
|
|
85
|
-
- `@States(options?)`
|
|
86
|
-
|
|
87
83
|
## Docs Decorators
|
|
84
|
+
|
|
88
85
|
- `@ApiTag(tag)`
|
|
89
86
|
- `@ApiOperation({ summary, description })`
|
|
90
87
|
- `@ApiResponse({ status, description, type, isArray, example })`
|
|
91
88
|
- `@ApiProperty({ description, required, example, type })`
|
|
92
|
-
## Frontend Classes
|
|
93
|
-
- `FrontendModule`
|
|
94
|
-
- `FrontendRegistry`
|
|
95
|
-
- `FrontendRouter`
|
|
96
|
-
- `StoreManager`
|
|
97
|
-
- `ThemeManager`
|
|
98
|
-
- `MobXStoreAdapter`
|
|
99
89
|
|
|
100
90
|
## Mail Classes
|
|
91
|
+
|
|
101
92
|
- `MailManager`
|
|
102
93
|
- `MailTemplateRegistry`
|
|
103
94
|
- `MailTransportRegistry`
|
|
@@ -109,6 +100,7 @@ Each item is documented on its own line for easy search and indexing.
|
|
|
109
100
|
- `MailQueueAdapter`
|
|
110
101
|
|
|
111
102
|
## Notification Classes
|
|
103
|
+
|
|
112
104
|
- `NotificationManager`
|
|
113
105
|
- `NotificationRegistry`
|
|
114
106
|
- `NotificationChannel`
|
|
@@ -118,6 +110,7 @@ Each item is documented on its own line for easy search and indexing.
|
|
|
118
110
|
- `NotificationChannelSelection`
|
|
119
111
|
|
|
120
112
|
## Jobs Classes
|
|
113
|
+
|
|
121
114
|
- `Job`
|
|
122
115
|
- `ScheduledJob`
|
|
123
116
|
- `JobManager`
|
|
@@ -128,20 +121,24 @@ Each item is documented on its own line for easy search and indexing.
|
|
|
128
121
|
- `ScheduleOptions`
|
|
129
122
|
|
|
130
123
|
## Docs Classes
|
|
124
|
+
|
|
131
125
|
- `DocGenerator`
|
|
132
126
|
|
|
133
127
|
## Auth Module
|
|
128
|
+
|
|
134
129
|
- `AuthModule`
|
|
135
130
|
- `authMiddleware()`
|
|
136
131
|
- `roleGuard()`
|
|
137
132
|
|
|
138
133
|
## AI Module
|
|
134
|
+
|
|
139
135
|
- `AIModule`
|
|
140
136
|
- `AIProvider`
|
|
141
137
|
- `OpenAIProvider`
|
|
142
138
|
- `OllamaProvider`
|
|
143
139
|
|
|
144
140
|
## Errors
|
|
141
|
+
|
|
145
142
|
- `FragmentError`
|
|
146
143
|
- `BadRequestError`
|
|
147
144
|
- `UnauthorizedError`
|
|
@@ -152,11 +149,13 @@ Each item is documented on its own line for easy search and indexing.
|
|
|
152
149
|
- `InternalServerError`
|
|
153
150
|
|
|
154
151
|
## Logging
|
|
152
|
+
|
|
155
153
|
- `FragmentLogger`
|
|
156
154
|
- `LoggerSettings`
|
|
157
155
|
- `LogLevel`
|
|
158
156
|
|
|
159
157
|
## Testing
|
|
158
|
+
|
|
160
159
|
- `initTestRunner()`
|
|
161
160
|
- `describe()`
|
|
162
161
|
- `it()`
|
|
@@ -165,20 +164,24 @@ Each item is documented on its own line for easy search and indexing.
|
|
|
165
164
|
- `afterEach()`
|
|
166
165
|
|
|
167
166
|
## CLI Programmatic API
|
|
167
|
+
|
|
168
168
|
- `FragmentCommand`
|
|
169
169
|
- `CommandRegistry`
|
|
170
170
|
- `CommandRunner`
|
|
171
171
|
|
|
172
172
|
## Request Context
|
|
173
|
+
|
|
173
174
|
- `RequestContextStorage`
|
|
174
175
|
- `@RequestContext()`
|
|
175
176
|
|
|
176
177
|
## Third-Party Re-exports
|
|
178
|
+
|
|
177
179
|
- `express` (from Express)
|
|
178
180
|
- `typeorm`
|
|
179
181
|
- `dotenv`
|
|
180
182
|
|
|
181
183
|
## CLI Commands
|
|
184
|
+
|
|
182
185
|
- `fragment init [dir]`
|
|
183
186
|
- `fragment init --type=plugin`
|
|
184
187
|
- `fragment serve`
|
|
@@ -212,7 +215,9 @@ Each item is documented on its own line for easy search and indexing.
|
|
|
212
215
|
- `fragment make:store <name>`
|
|
213
216
|
- `fragment make:component <name>`
|
|
214
217
|
- `fragment make:template <name>`
|
|
218
|
+
|
|
215
219
|
## Configuration Keys
|
|
220
|
+
|
|
216
221
|
- `structure.type`
|
|
217
222
|
- `verbose`
|
|
218
223
|
- `logging.level`
|
|
@@ -235,15 +240,9 @@ Each item is documented on its own line for easy search and indexing.
|
|
|
235
240
|
- `docs.perModuleRoutes`
|
|
236
241
|
- `plugins`
|
|
237
242
|
- `pluginAutoQualify`
|
|
238
|
-
- `frontend.enabled`
|
|
239
|
-
- `frontend.templates.default`
|
|
240
|
-
- `frontend.templates.system`
|
|
241
|
-
- `frontend.templates.custom`
|
|
242
|
-
- `frontend.styles.framework`
|
|
243
|
-
- `frontend.styles.tailwind`
|
|
244
|
-
- `frontend.routes.base`
|
|
245
243
|
|
|
246
244
|
## API Notes
|
|
245
|
+
|
|
247
246
|
- `@FragmentApplication(options)` is part of the public API surface.
|
|
248
247
|
- `@Controller(path?)` is part of the public API surface.
|
|
249
248
|
- `@Service()` is part of the public API surface.
|
|
@@ -272,23 +271,13 @@ Each item is documented on its own line for easy search and indexing.
|
|
|
272
271
|
- `@PreDestroy()` is part of the lifecycle API surface.
|
|
273
272
|
- `@OnStartup(order?)` is part of the lifecycle API surface.
|
|
274
273
|
- `@OnShutdown(order?)` is part of the lifecycle API surface.
|
|
275
|
-
- `@View(options)` is part of the frontend API surface.
|
|
276
|
-
- `@Views(options)` is part of the frontend API surface.
|
|
277
|
-
- `@Store(options)` is part of the frontend API surface.
|
|
278
|
-
- `@UIComponent(options)` is part of the frontend API surface.
|
|
279
|
-
- `@Template(options)` is part of the frontend API surface.
|
|
280
|
-
- `@Templates(options)` is part of the frontend API surface.
|
|
281
|
-
- `@Action(options)` is part of the frontend API surface.
|
|
282
|
-
- `@Actions(options)` is part of the frontend API surface.
|
|
283
|
-
- `@Effect(options)` is part of the frontend API surface.
|
|
284
|
-
- `@Effects(options)` is part of the frontend API surface.
|
|
285
|
-
- `@State(options?)` is part of the frontend API surface.
|
|
286
|
-
- `@States(options?)` is part of the frontend API surface.
|
|
287
274
|
- `@ApiTag(tag)` is part of the docs API surface.
|
|
288
275
|
- `@ApiOperation({ summary, description })` is part of the docs API surface.
|
|
289
276
|
- `@ApiResponse({ status, description, type, isArray, example })` is part of the docs API surface.
|
|
290
277
|
- `@ApiProperty({ description, required, example, type })` is part of the docs API surface.
|
|
278
|
+
|
|
291
279
|
## Extended API Index
|
|
280
|
+
|
|
292
281
|
- CLI: `fragment init [dir]` is supported by the framework binary.
|
|
293
282
|
- CLI: `fragment init --type=plugin` is supported by the framework binary.
|
|
294
283
|
- CLI: `fragment serve` is supported by the framework binary.
|
|
@@ -344,188 +333,40 @@ Each item is documented on its own line for easy search and indexing.
|
|
|
344
333
|
- Config: `docs.perModuleRoutes` appears in the configuration schema.
|
|
345
334
|
- Config: `plugins` appears in the configuration schema.
|
|
346
335
|
- Config: `pluginAutoQualify` appears in the configuration schema.
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
-
|
|
351
|
-
-
|
|
352
|
-
-
|
|
353
|
-
-
|
|
354
|
-
-
|
|
355
|
-
-
|
|
356
|
-
-
|
|
357
|
-
-
|
|
358
|
-
-
|
|
359
|
-
- Export note 8: Keep names aligned with file suffixes.
|
|
360
|
-
- Export note 9: Keep names aligned with file suffixes.
|
|
361
|
-
- Export note 10: Keep names aligned with file suffixes.
|
|
362
|
-
- Export note 11: Keep names aligned with file suffixes.
|
|
363
|
-
- Export note 12: Keep names aligned with file suffixes.
|
|
364
|
-
- Export note 13: Keep names aligned with file suffixes.
|
|
365
|
-
- Export note 14: Keep names aligned with file suffixes.
|
|
366
|
-
- Export note 15: Keep names aligned with file suffixes.
|
|
367
|
-
- Export note 16: Keep names aligned with file suffixes.
|
|
368
|
-
- Export note 17: Keep names aligned with file suffixes.
|
|
369
|
-
- Export note 18: Keep names aligned with file suffixes.
|
|
370
|
-
- Export note 19: Keep names aligned with file suffixes.
|
|
371
|
-
- Export note 20: Keep names aligned with file suffixes.
|
|
372
|
-
- Export note 21: Keep names aligned with file suffixes.
|
|
373
|
-
- Export note 22: Keep names aligned with file suffixes.
|
|
374
|
-
- Export note 23: Keep names aligned with file suffixes.
|
|
375
|
-
- Export note 24: Keep names aligned with file suffixes.
|
|
376
|
-
- Export note 25: Keep names aligned with file suffixes.
|
|
377
|
-
- Export note 26: Keep names aligned with file suffixes.
|
|
378
|
-
- Export note 27: Keep names aligned with file suffixes.
|
|
379
|
-
- Export note 28: Keep names aligned with file suffixes.
|
|
380
|
-
- Export note 29: Keep names aligned with file suffixes.
|
|
381
|
-
- Export note 30: Keep names aligned with file suffixes.
|
|
382
|
-
- Export note 31: Keep names aligned with file suffixes.
|
|
383
|
-
- Export note 32: Keep names aligned with file suffixes.
|
|
384
|
-
- Export note 33: Keep names aligned with file suffixes.
|
|
385
|
-
- Export note 34: Keep names aligned with file suffixes.
|
|
386
|
-
- Export note 35: Keep names aligned with file suffixes.
|
|
387
|
-
- Export note 36: Keep names aligned with file suffixes.
|
|
388
|
-
- Export note 37: Keep names aligned with file suffixes.
|
|
389
|
-
- Export note 38: Keep names aligned with file suffixes.
|
|
390
|
-
- Export note 39: Keep names aligned with file suffixes.
|
|
391
|
-
- Export note 40: Keep names aligned with file suffixes.
|
|
392
|
-
- Export note 41: Keep names aligned with file suffixes.
|
|
393
|
-
- Export note 42: Keep names aligned with file suffixes.
|
|
394
|
-
- Export note 43: Keep names aligned with file suffixes.
|
|
395
|
-
- Export note 44: Keep names aligned with file suffixes.
|
|
396
|
-
- Export note 45: Keep names aligned with file suffixes.
|
|
397
|
-
- Export note 46: Keep names aligned with file suffixes.
|
|
398
|
-
- Export note 47: Keep names aligned with file suffixes.
|
|
399
|
-
- Export note 48: Keep names aligned with file suffixes.
|
|
400
|
-
- Export note 49: Keep names aligned with file suffixes.
|
|
401
|
-
- Export note 50: Keep names aligned with file suffixes.
|
|
402
|
-
- Export note 51: Keep names aligned with file suffixes.
|
|
403
|
-
- Export note 52: Keep names aligned with file suffixes.
|
|
404
|
-
- Export note 53: Keep names aligned with file suffixes.
|
|
405
|
-
- Export note 54: Keep names aligned with file suffixes.
|
|
406
|
-
- Export note 55: Keep names aligned with file suffixes.
|
|
407
|
-
- Export note 56: Keep names aligned with file suffixes.
|
|
408
|
-
- Export note 57: Keep names aligned with file suffixes.
|
|
409
|
-
- Export note 58: Keep names aligned with file suffixes.
|
|
410
|
-
- Export note 59: Keep names aligned with file suffixes.
|
|
411
|
-
- Export note 60: Keep names aligned with file suffixes.
|
|
412
|
-
- Export note 61: Keep names aligned with file suffixes.
|
|
413
|
-
- Export note 62: Keep names aligned with file suffixes.
|
|
414
|
-
- Export note 63: Keep names aligned with file suffixes.
|
|
415
|
-
- Export note 64: Keep names aligned with file suffixes.
|
|
416
|
-
- Export note 65: Keep names aligned with file suffixes.
|
|
417
|
-
- Export note 66: Keep names aligned with file suffixes.
|
|
418
|
-
- Export note 67: Keep names aligned with file suffixes.
|
|
419
|
-
- Export note 68: Keep names aligned with file suffixes.
|
|
420
|
-
- Export note 69: Keep names aligned with file suffixes.
|
|
421
|
-
- Export note 70: Keep names aligned with file suffixes.
|
|
422
|
-
- Export note 71: Keep names aligned with file suffixes.
|
|
423
|
-
- Export note 72: Keep names aligned with file suffixes.
|
|
424
|
-
- Export note 73: Keep names aligned with file suffixes.
|
|
425
|
-
- Export note 74: Keep names aligned with file suffixes.
|
|
426
|
-
- Export note 75: Keep names aligned with file suffixes.
|
|
427
|
-
- Export note 76: Keep names aligned with file suffixes.
|
|
428
|
-
- Export note 77: Keep names aligned with file suffixes.
|
|
429
|
-
- Export note 78: Keep names aligned with file suffixes.
|
|
430
|
-
- Export note 79: Keep names aligned with file suffixes.
|
|
431
|
-
- Export note 80: Keep names aligned with file suffixes.
|
|
432
|
-
- Export note 81: Keep names aligned with file suffixes.
|
|
433
|
-
- Export note 82: Keep names aligned with file suffixes.
|
|
434
|
-
- Export note 83: Keep names aligned with file suffixes.
|
|
435
|
-
- Export note 84: Keep names aligned with file suffixes.
|
|
436
|
-
- Export note 85: Keep names aligned with file suffixes.
|
|
437
|
-
- Export note 86: Keep names aligned with file suffixes.
|
|
438
|
-
- Export note 87: Keep names aligned with file suffixes.
|
|
439
|
-
- Export note 88: Keep names aligned with file suffixes.
|
|
440
|
-
- Export note 89: Keep names aligned with file suffixes.
|
|
441
|
-
- Export note 90: Keep names aligned with file suffixes.
|
|
442
|
-
- Export note 91: Keep names aligned with file suffixes.
|
|
443
|
-
- Export note 92: Keep names aligned with file suffixes.
|
|
444
|
-
- Export note 93: Keep names aligned with file suffixes.
|
|
445
|
-
- Export note 94: Keep names aligned with file suffixes.
|
|
446
|
-
- Export note 95: Keep names aligned with file suffixes.
|
|
447
|
-
- Export note 96: Keep names aligned with file suffixes.
|
|
448
|
-
- Export note 97: Keep names aligned with file suffixes.
|
|
449
|
-
- Export note 98: Keep names aligned with file suffixes.
|
|
450
|
-
- Export note 99: Keep names aligned with file suffixes.
|
|
451
|
-
- Export note 100: Keep names aligned with file suffixes.
|
|
452
|
-
- Export note 101: Keep names aligned with file suffixes.
|
|
453
|
-
- Export note 102: Keep names aligned with file suffixes.
|
|
454
|
-
- Export note 103: Keep names aligned with file suffixes.
|
|
455
|
-
- Export note 104: Keep names aligned with file suffixes.
|
|
456
|
-
- Export note 105: Keep names aligned with file suffixes.
|
|
457
|
-
- Export note 106: Keep names aligned with file suffixes.
|
|
458
|
-
- Export note 107: Keep names aligned with file suffixes.
|
|
459
|
-
- Export note 108: Keep names aligned with file suffixes.
|
|
460
|
-
- Export note 109: Keep names aligned with file suffixes.
|
|
461
|
-
- Export note 110: Keep names aligned with file suffixes.
|
|
462
|
-
- Export note 111: Keep names aligned with file suffixes.
|
|
463
|
-
- Export note 112: Keep names aligned with file suffixes.
|
|
464
|
-
- Export note 113: Keep names aligned with file suffixes.
|
|
465
|
-
- Export note 114: Keep names aligned with file suffixes.
|
|
466
|
-
- Export note 115: Keep names aligned with file suffixes.
|
|
467
|
-
- Export note 116: Keep names aligned with file suffixes.
|
|
468
|
-
- Export note 117: Keep names aligned with file suffixes.
|
|
469
|
-
- Export note 118: Keep names aligned with file suffixes.
|
|
470
|
-
- Export note 119: Keep names aligned with file suffixes.
|
|
471
|
-
- Export note 120: Keep names aligned with file suffixes.
|
|
336
|
+
|
|
337
|
+
## Export Notes
|
|
338
|
+
|
|
339
|
+
- Import from the root package (`fragment-ts`) instead of deep paths to avoid breakage across releases.
|
|
340
|
+
- Ensure `reflect-metadata` is imported once at app startup before any decorators are evaluated.
|
|
341
|
+
- File suffixes drive component discovery; keep names aligned with suffixes for consistent scanning.
|
|
342
|
+
- Use `FragmentError` (or subclasses) for consistent HTTP mapping and structured logging.
|
|
343
|
+
- Prefer `FragmentLogger` over `console.log` to honor `verbose` and log level settings.
|
|
344
|
+
- Use `CommandRunner.run()` for programmatic CLI usage in jobs or scripts.
|
|
345
|
+
- Docs decorators (`@ApiTag`, `@ApiOperation`, etc.) only affect documentation output, not runtime behavior.
|
|
346
|
+
- Config values support `${ENV:default}` interpolation through `ConfigUtils`.
|
|
347
|
+
- TypeORM exports are available under `eloquent` for convenience.
|
|
472
348
|
|
|
473
349
|
## API Conventions
|
|
474
|
-
|
|
475
|
-
-
|
|
476
|
-
-
|
|
477
|
-
-
|
|
478
|
-
-
|
|
479
|
-
-
|
|
480
|
-
-
|
|
481
|
-
-
|
|
482
|
-
-
|
|
483
|
-
-
|
|
484
|
-
-
|
|
485
|
-
-
|
|
486
|
-
-
|
|
487
|
-
- API convention 14: Keep decorator usage near the class or method definition.
|
|
488
|
-
- API convention 15: Keep decorator usage near the class or method definition.
|
|
489
|
-
- API convention 16: Keep decorator usage near the class or method definition.
|
|
490
|
-
- API convention 17: Keep decorator usage near the class or method definition.
|
|
491
|
-
- API convention 18: Keep decorator usage near the class or method definition.
|
|
492
|
-
- API convention 19: Keep decorator usage near the class or method definition.
|
|
493
|
-
- API convention 20: Keep decorator usage near the class or method definition.
|
|
494
|
-
- API convention 21: Keep decorator usage near the class or method definition.
|
|
495
|
-
- API convention 22: Keep decorator usage near the class or method definition.
|
|
496
|
-
- API convention 23: Keep decorator usage near the class or method definition.
|
|
497
|
-
- API convention 24: Keep decorator usage near the class or method definition.
|
|
498
|
-
- API convention 25: Keep decorator usage near the class or method definition.
|
|
499
|
-
- API convention 26: Keep decorator usage near the class or method definition.
|
|
500
|
-
- API convention 27: Keep decorator usage near the class or method definition.
|
|
501
|
-
- API convention 28: Keep decorator usage near the class or method definition.
|
|
502
|
-
- API convention 29: Keep decorator usage near the class or method definition.
|
|
503
|
-
- API convention 30: Keep decorator usage near the class or method definition.
|
|
504
|
-
- API convention 31: Keep decorator usage near the class or method definition.
|
|
505
|
-
- API convention 32: Keep decorator usage near the class or method definition.
|
|
506
|
-
- API convention 33: Keep decorator usage near the class or method definition.
|
|
507
|
-
- API convention 34: Keep decorator usage near the class or method definition.
|
|
508
|
-
- API convention 35: Keep decorator usage near the class or method definition.
|
|
509
|
-
- API convention 36: Keep decorator usage near the class or method definition.
|
|
510
|
-
- API convention 37: Keep decorator usage near the class or method definition.
|
|
511
|
-
- API convention 38: Keep decorator usage near the class or method definition.
|
|
512
|
-
- API convention 39: Keep decorator usage near the class or method definition.
|
|
513
|
-
- API convention 40: Keep decorator usage near the class or method definition.
|
|
514
|
-
- API convention 41: Keep decorator usage near the class or method definition.
|
|
515
|
-
- API convention 42: Keep decorator usage near the class or method definition.
|
|
516
|
-
- API convention 43: Keep decorator usage near the class or method definition.
|
|
517
|
-
- API convention 44: Keep decorator usage near the class or method definition.
|
|
518
|
-
- API convention 45: Keep decorator usage near the class or method definition.
|
|
519
|
-
- API convention 46: Keep decorator usage near the class or method definition.
|
|
520
|
-
- API convention 47: Keep decorator usage near the class or method definition.
|
|
521
|
-
- API convention 48: Keep decorator usage near the class or method definition.
|
|
522
|
-
- API convention 49: Keep decorator usage near the class or method definition.
|
|
523
|
-
- API convention 50: Keep decorator usage near the class or method definition.
|
|
350
|
+
|
|
351
|
+
- Keep decorators adjacent to the class or method they configure.
|
|
352
|
+
- Prefer constructor injection for required dependencies and property injection for optional ones.
|
|
353
|
+
- Avoid manual `new` for DI-managed classes; let the container resolve them.
|
|
354
|
+
- Keep controllers thin and delegate to services for business logic.
|
|
355
|
+
- Use DTOs and validators (`class-validator`) for request payload validation.
|
|
356
|
+
- Use qualifiers when two providers share a name or token.
|
|
357
|
+
- Provide explicit `name` values in decorators for stable metadata and docs.
|
|
358
|
+
- Use `@State` for store fields and mutate them inside `@Action` methods.
|
|
359
|
+
- Treat `@Effect` methods as side-effect boundaries (fetching, subscriptions, timers).
|
|
360
|
+
- Use `@OnStartup` and `@OnShutdown` for app lifecycle, not constructors.
|
|
361
|
+
- Prefer `FragmentError` (or subclasses) for errors that reach the web layer.
|
|
362
|
+
- Keep file suffixes aligned with component types to keep scanning reliable.
|
|
524
363
|
|
|
525
364
|
## API Walkthrough Examples
|
|
365
|
+
|
|
526
366
|
This section gives short, implementation-oriented examples for the most-used APIs.
|
|
527
367
|
|
|
528
368
|
### Application Bootstrapping
|
|
369
|
+
|
|
529
370
|
```ts
|
|
530
371
|
import { FragmentApplication, FragmentWebApplication } from "fragment-ts";
|
|
531
372
|
|
|
@@ -541,6 +382,7 @@ bootstrap();
|
|
|
541
382
|
```
|
|
542
383
|
|
|
543
384
|
### DI and Services
|
|
385
|
+
|
|
544
386
|
```ts
|
|
545
387
|
import { Service, Inject } from "fragment-ts";
|
|
546
388
|
|
|
@@ -563,6 +405,7 @@ class SessionService {
|
|
|
563
405
|
```
|
|
564
406
|
|
|
565
407
|
### FragmentError Usage
|
|
408
|
+
|
|
566
409
|
```ts
|
|
567
410
|
import { FragmentError } from "fragment-ts";
|
|
568
411
|
|
|
@@ -574,6 +417,7 @@ class PolicyError extends FragmentError {
|
|
|
574
417
|
```
|
|
575
418
|
|
|
576
419
|
### HTTP Controllers
|
|
420
|
+
|
|
577
421
|
```ts
|
|
578
422
|
import { Controller, Get, Post, Body } from "fragment-ts";
|
|
579
423
|
|
|
@@ -592,6 +436,7 @@ class TaskController {
|
|
|
592
436
|
```
|
|
593
437
|
|
|
594
438
|
### Plugin Lifecycle
|
|
439
|
+
|
|
595
440
|
```ts
|
|
596
441
|
import { Plugin, OnPluginInit, OnPluginShutdown } from "fragment-ts";
|
|
597
442
|
|
|
@@ -606,6 +451,7 @@ class AuditPlugin {
|
|
|
606
451
|
```
|
|
607
452
|
|
|
608
453
|
### Mail and Templates
|
|
454
|
+
|
|
609
455
|
```ts
|
|
610
456
|
import { Mailer, MailTemplate, MailManager } from "fragment-ts";
|
|
611
457
|
import type { MailProvider, MailMessage } from "fragment-ts";
|
|
@@ -621,10 +467,15 @@ class ConsoleMailer implements MailProvider {
|
|
|
621
467
|
class WelcomeTemplate {}
|
|
622
468
|
|
|
623
469
|
const mail = new MailManager();
|
|
624
|
-
await mail.send({
|
|
470
|
+
await mail.send({
|
|
471
|
+
to: "user@example.com",
|
|
472
|
+
template: "welcome",
|
|
473
|
+
data: { name: "Ada" },
|
|
474
|
+
});
|
|
625
475
|
```
|
|
626
476
|
|
|
627
477
|
### Notifications
|
|
478
|
+
|
|
628
479
|
```ts
|
|
629
480
|
import { NotificationManager, NotificationChannel } from "fragment-ts";
|
|
630
481
|
|
|
@@ -635,8 +486,12 @@ class SmsChannel extends NotificationChannel<string> {
|
|
|
635
486
|
}
|
|
636
487
|
|
|
637
488
|
class AlertNotification {
|
|
638
|
-
via() {
|
|
639
|
-
|
|
489
|
+
via() {
|
|
490
|
+
return ["sms"];
|
|
491
|
+
}
|
|
492
|
+
toSms() {
|
|
493
|
+
return "Service degraded";
|
|
494
|
+
}
|
|
640
495
|
}
|
|
641
496
|
|
|
642
497
|
const manager = new NotificationManager();
|
|
@@ -644,6 +499,7 @@ await manager.send(new AlertNotification());
|
|
|
644
499
|
```
|
|
645
500
|
|
|
646
501
|
### Jobs and Scheduling
|
|
502
|
+
|
|
647
503
|
```ts
|
|
648
504
|
import { Job, Cron, ScheduledJob } from "fragment-ts";
|
|
649
505
|
|
|
@@ -658,32 +514,8 @@ class MetricsJob extends ScheduledJob {
|
|
|
658
514
|
new MetricsJob().everyHour(6);
|
|
659
515
|
```
|
|
660
516
|
|
|
661
|
-
### Frontend Metadata
|
|
662
|
-
```ts
|
|
663
|
-
import { View, Store, Template, UIComponent, State, Action } from "fragment-ts";
|
|
664
|
-
|
|
665
|
-
@Template({ name: "app", kind: "system", components: ["TopNav"] })
|
|
666
|
-
class AppTemplate {}
|
|
667
|
-
|
|
668
|
-
@UIComponent({ name: "TopNav" })
|
|
669
|
-
class TopNav {}
|
|
670
|
-
|
|
671
|
-
@Store({ name: "home" })
|
|
672
|
-
class HomeStore {
|
|
673
|
-
@State()
|
|
674
|
-
count = 0;
|
|
675
|
-
|
|
676
|
-
@Action()
|
|
677
|
-
increment() {
|
|
678
|
-
this.count += 1;
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
@View({ path: "/", template: "app", store: "home" })
|
|
683
|
-
class HomeView {}
|
|
684
|
-
```
|
|
685
|
-
|
|
686
517
|
### Docs Generation
|
|
518
|
+
|
|
687
519
|
```ts
|
|
688
520
|
import { DocGenerator } from "fragment-ts";
|
|
689
521
|
|
|
@@ -692,6 +524,7 @@ generator.generate({ outputDir: "docs", perModule: true });
|
|
|
692
524
|
```
|
|
693
525
|
|
|
694
526
|
### Programmatic CLI
|
|
527
|
+
|
|
695
528
|
```ts
|
|
696
529
|
import { CommandRunner } from "fragment-ts";
|
|
697
530
|
|