fragment-ts 1.2.4 → 1.2.6

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.
Files changed (72) hide show
  1. package/API.md +54 -74
  2. package/DOCS.md +71 -116
  3. package/README.md +56 -97
  4. package/SETUP.md +71 -74
  5. package/USAGE.md +56 -138
  6. package/dist/core/index.d.ts +19 -20
  7. package/dist/core/index.d.ts.map +1 -1
  8. package/dist/core/index.js +10 -11
  9. package/dist/core/index.js.map +1 -1
  10. package/dist/core/metadata/metadata-keys.d.ts +0 -7
  11. package/dist/core/metadata/metadata-keys.d.ts.map +1 -1
  12. package/dist/core/metadata/metadata-keys.js +0 -8
  13. package/dist/core/metadata/metadata-keys.js.map +1 -1
  14. package/dist/index.d.ts +22 -24
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +48 -63
  17. package/dist/index.js.map +1 -1
  18. package/dist/integrations/docs/doc-generator.d.ts.map +1 -1
  19. package/dist/integrations/docs/doc-generator.js +685 -42
  20. package/dist/integrations/docs/doc-generator.js.map +1 -1
  21. package/dist/platform/cli/commands/make/command.d.ts.map +1 -1
  22. package/dist/platform/cli/commands/make/command.js +1 -5
  23. package/dist/platform/cli/commands/make/command.js.map +1 -1
  24. package/dist/platform/cli/scaffold/generate/component-generator.d.ts +0 -4
  25. package/dist/platform/cli/scaffold/generate/component-generator.d.ts.map +1 -1
  26. package/dist/platform/cli/scaffold/generate/component-generator.js +3 -97
  27. package/dist/platform/cli/scaffold/generate/component-generator.js.map +1 -1
  28. package/dist/platform/cli/scaffold/init/init.scaffold.d.ts.map +1 -1
  29. package/dist/platform/cli/scaffold/init/init.scaffold.js +3 -145
  30. package/dist/platform/cli/scaffold/init/init.scaffold.js.map +1 -1
  31. package/dist/platform/cli/scaffold/init/prompts.d.ts.map +1 -1
  32. package/dist/platform/cli/scaffold/init/prompts.js +0 -26
  33. package/dist/platform/cli/scaffold/init/prompts.js.map +1 -1
  34. package/dist/platform/cli/scaffold/init/types.d.ts +0 -5
  35. package/dist/platform/cli/scaffold/init/types.d.ts.map +1 -1
  36. package/dist/platform/web/bootstrap/ApplicationBootstrapper.d.ts.map +1 -1
  37. package/dist/platform/web/bootstrap/ApplicationBootstrapper.js +0 -3
  38. package/dist/platform/web/bootstrap/ApplicationBootstrapper.js.map +1 -1
  39. package/dist/platform/web/bootstrap/ComponentRegistrar.d.ts.map +1 -1
  40. package/dist/platform/web/bootstrap/ComponentRegistrar.js +0 -4
  41. package/dist/platform/web/bootstrap/ComponentRegistrar.js.map +1 -1
  42. package/dist/shared/config.utils.d.ts +0 -24
  43. package/dist/shared/config.utils.d.ts.map +1 -1
  44. package/dist/shared/config.utils.js +0 -3
  45. package/dist/shared/config.utils.js.map +1 -1
  46. package/dist/shared/errors.d.ts +0 -9
  47. package/dist/shared/errors.d.ts.map +1 -1
  48. package/dist/shared/errors.js +1 -19
  49. package/dist/shared/errors.js.map +1 -1
  50. package/examples/blog-api/.env.example +1 -7
  51. package/examples/blog-api/fragment.json +3 -50
  52. package/examples/blog-api/package-lock.json +80 -1900
  53. package/examples/blog-api/package.json +9 -16
  54. package/examples/blog-api/src/entities/user.entity.ts +1 -1
  55. package/examples/blog-api/src/lifecycle.ts +26 -0
  56. package/examples/blog-api/src/modules/app/controllers/app.controller.ts +25 -7
  57. package/examples/blog-api/src/modules/auth/controllers/auth.controller.ts +18 -0
  58. package/examples/blog-api/src/modules/auth/services/auth.service.ts +15 -0
  59. package/examples/blog-api/src/modules/jobs/base.job.ts +12 -0
  60. package/package.json +1 -1
  61. package/examples/blog-api/postcss.config.js +0 -6
  62. package/examples/blog-api/src/frontend/styles/tailwind.css +0 -3
  63. package/examples/blog-api/src/modules/app/components/header.component.ts +0 -4
  64. package/examples/blog-api/src/modules/app/controllers/profile.controller.ts +0 -38
  65. package/examples/blog-api/src/modules/app/stores/home.store.ts +0 -12
  66. package/examples/blog-api/src/modules/app/templates/app.template.ts +0 -8
  67. package/examples/blog-api/src/modules/app/views/home.view.ts +0 -9
  68. package/examples/blog-api/src/modules/app/views/user-profile.view.ts +0 -8
  69. package/examples/blog-api/src/modules/jobs/example.job.ts +0 -9
  70. package/examples/blog-api/src/modules/mail/primary.mail.ts +0 -13
  71. package/examples/blog-api/src/modules/notifications/push.notification.ts +0 -15
  72. package/examples/blog-api/tailwind.config.js +0 -8
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,24 +333,21 @@ 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
- - Config: `frontend.enabled` appears in the configuration schema.
348
- - Config: `frontend.templates.default` appears in the configuration schema.
349
- - Config: `frontend.templates.system` appears in the configuration schema.
350
- - Config: `frontend.templates.custom` appears in the configuration schema.
351
- - Config: `frontend.routes.base` appears in the configuration schema.
336
+
352
337
  ## Export Notes
338
+
353
339
  - Import from the root package (`fragment-ts`) instead of deep paths to avoid breakage across releases.
354
340
  - Ensure `reflect-metadata` is imported once at app startup before any decorators are evaluated.
355
341
  - File suffixes drive component discovery; keep names aligned with suffixes for consistent scanning.
356
342
  - Use `FragmentError` (or subclasses) for consistent HTTP mapping and structured logging.
357
343
  - Prefer `FragmentLogger` over `console.log` to honor `verbose` and log level settings.
358
- - Frontend metadata relies on MobX. Ensure `mobx` is installed when frontend is enabled.
359
344
  - Use `CommandRunner.run()` for programmatic CLI usage in jobs or scripts.
360
345
  - Docs decorators (`@ApiTag`, `@ApiOperation`, etc.) only affect documentation output, not runtime behavior.
361
346
  - Config values support `${ENV:default}` interpolation through `ConfigUtils`.
362
347
  - TypeORM exports are available under `eloquent` for convenience.
363
348
 
364
349
  ## API Conventions
350
+
365
351
  - Keep decorators adjacent to the class or method they configure.
366
352
  - Prefer constructor injection for required dependencies and property injection for optional ones.
367
353
  - Avoid manual `new` for DI-managed classes; let the container resolve them.
@@ -376,9 +362,11 @@ Each item is documented on its own line for easy search and indexing.
376
362
  - Keep file suffixes aligned with component types to keep scanning reliable.
377
363
 
378
364
  ## API Walkthrough Examples
365
+
379
366
  This section gives short, implementation-oriented examples for the most-used APIs.
380
367
 
381
368
  ### Application Bootstrapping
369
+
382
370
  ```ts
383
371
  import { FragmentApplication, FragmentWebApplication } from "fragment-ts";
384
372
 
@@ -394,6 +382,7 @@ bootstrap();
394
382
  ```
395
383
 
396
384
  ### DI and Services
385
+
397
386
  ```ts
398
387
  import { Service, Inject } from "fragment-ts";
399
388
 
@@ -416,6 +405,7 @@ class SessionService {
416
405
  ```
417
406
 
418
407
  ### FragmentError Usage
408
+
419
409
  ```ts
420
410
  import { FragmentError } from "fragment-ts";
421
411
 
@@ -427,6 +417,7 @@ class PolicyError extends FragmentError {
427
417
  ```
428
418
 
429
419
  ### HTTP Controllers
420
+
430
421
  ```ts
431
422
  import { Controller, Get, Post, Body } from "fragment-ts";
432
423
 
@@ -445,6 +436,7 @@ class TaskController {
445
436
  ```
446
437
 
447
438
  ### Plugin Lifecycle
439
+
448
440
  ```ts
449
441
  import { Plugin, OnPluginInit, OnPluginShutdown } from "fragment-ts";
450
442
 
@@ -459,6 +451,7 @@ class AuditPlugin {
459
451
  ```
460
452
 
461
453
  ### Mail and Templates
454
+
462
455
  ```ts
463
456
  import { Mailer, MailTemplate, MailManager } from "fragment-ts";
464
457
  import type { MailProvider, MailMessage } from "fragment-ts";
@@ -474,10 +467,15 @@ class ConsoleMailer implements MailProvider {
474
467
  class WelcomeTemplate {}
475
468
 
476
469
  const mail = new MailManager();
477
- await mail.send({ to: "user@example.com", template: "welcome", data: { name: "Ada" } });
470
+ await mail.send({
471
+ to: "user@example.com",
472
+ template: "welcome",
473
+ data: { name: "Ada" },
474
+ });
478
475
  ```
479
476
 
480
477
  ### Notifications
478
+
481
479
  ```ts
482
480
  import { NotificationManager, NotificationChannel } from "fragment-ts";
483
481
 
@@ -488,8 +486,12 @@ class SmsChannel extends NotificationChannel<string> {
488
486
  }
489
487
 
490
488
  class AlertNotification {
491
- via() { return ["sms"]; }
492
- toSms() { return "Service degraded"; }
489
+ via() {
490
+ return ["sms"];
491
+ }
492
+ toSms() {
493
+ return "Service degraded";
494
+ }
493
495
  }
494
496
 
495
497
  const manager = new NotificationManager();
@@ -497,6 +499,7 @@ await manager.send(new AlertNotification());
497
499
  ```
498
500
 
499
501
  ### Jobs and Scheduling
502
+
500
503
  ```ts
501
504
  import { Job, Cron, ScheduledJob } from "fragment-ts";
502
505
 
@@ -511,32 +514,8 @@ class MetricsJob extends ScheduledJob {
511
514
  new MetricsJob().everyHour(6);
512
515
  ```
513
516
 
514
- ### Frontend Metadata
515
- ```ts
516
- import { View, Store, Template, UIComponent, State, Action } from "fragment-ts";
517
-
518
- @Template({ name: "app", kind: "system", components: ["TopNav"] })
519
- class AppTemplate {}
520
-
521
- @UIComponent({ name: "TopNav" })
522
- class TopNav {}
523
-
524
- @Store({ name: "home" })
525
- class HomeStore {
526
- @State()
527
- count = 0;
528
-
529
- @Action()
530
- increment() {
531
- this.count += 1;
532
- }
533
- }
534
-
535
- @View({ path: "/", template: "app", store: "home" })
536
- class HomeView {}
537
- ```
538
-
539
517
  ### Docs Generation
518
+
540
519
  ```ts
541
520
  import { DocGenerator } from "fragment-ts";
542
521
 
@@ -545,6 +524,7 @@ generator.generate({ outputDir: "docs", perModule: true });
545
524
  ```
546
525
 
547
526
  ### Programmatic CLI
527
+
548
528
  ```ts
549
529
  import { CommandRunner } from "fragment-ts";
550
530