@akanjs/cli 0.9.48 → 0.9.50

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 (128) hide show
  1. package/cjs/index.js +63 -52
  2. package/cjs/src/guidelines/___library/sharedUiStructureDescription.en.md +1 -1
  3. package/cjs/src/guidelines/databaseModule/databaseModule.instruction.md +9 -21
  4. package/cjs/src/guidelines/fieldDecorator/fieldDecorator.instruction.md +0 -5
  5. package/cjs/src/guidelines/framework/framework.instruction.md +10 -12
  6. package/cjs/src/guidelines/modelConstant/modelConstant.generate.json +0 -7
  7. package/cjs/src/guidelines/modelConstant/modelConstant.instruction.md +14 -19
  8. package/cjs/src/guidelines/modelDocument/modelDocument.instruction.md +0 -24
  9. package/cjs/src/guidelines/modelService/modelService.generate.json +4 -11
  10. package/cjs/src/guidelines/modelService/modelService.instruction.md +12 -75
  11. package/cjs/src/guidelines/modelSignal/modelSignal.generate.json +0 -1
  12. package/cjs/src/guidelines/modelSignal/modelSignal.instruction.md +2 -38
  13. package/cjs/src/guidelines/modelStore/modelStore.instruction.md +1 -3
  14. package/cjs/src/guidelines/modelTemplate/modelTemplate.instruction.md +2 -2
  15. package/cjs/src/guidelines/modelUnit/modelUnit.instruction.md +2 -2
  16. package/cjs/src/guidelines/scalarConstant/scalarConstant.instruction.md +6 -11
  17. package/cjs/src/templates/__scalar/__model__/__model__.constant.js +5 -6
  18. package/cjs/src/templates/__scalar/__model__/__model__.dictionary.js +1 -1
  19. package/cjs/src/templates/app/app/[lang]/layout.js +0 -1
  20. package/cjs/src/templates/app/app/csr.js +3 -1
  21. package/cjs/src/templates/app/lib/___appName__/__appName__.dictionary.js +1 -1
  22. package/cjs/src/templates/app/lib/___appName__/__appName__.service.js +2 -3
  23. package/cjs/src/templates/app/lib/___appName__/__appName__.signal.js +2 -3
  24. package/cjs/src/templates/app/lib/___appName__/__appName__.store.js +2 -3
  25. package/cjs/src/templates/client.js +4 -4
  26. package/cjs/src/templates/crudPages/[__model__Id]/edit/page.js +1 -1
  27. package/cjs/src/templates/crudPages/[__model__Id]/page.js +1 -1
  28. package/cjs/src/templates/crudPages/new/page.js +1 -1
  29. package/cjs/src/templates/crudPages/page.js +1 -1
  30. package/cjs/src/templates/index.js +0 -1
  31. package/cjs/src/templates/lib/__lib/lib.constant.js +0 -1
  32. package/cjs/src/templates/lib/__lib/lib.dictionary.js +7 -4
  33. package/cjs/src/templates/lib/__lib/lib.document.js +4 -3
  34. package/cjs/src/templates/lib/__lib/lib.service.js +1 -1
  35. package/cjs/src/templates/lib/__lib/lib.signal.js +23 -4
  36. package/cjs/src/templates/lib/__lib/lib.store.js +19 -2
  37. package/cjs/src/templates/lib/cnst.js +12 -6
  38. package/cjs/src/templates/lib/db.js +10 -3
  39. package/cjs/src/templates/lib/dict.js +12 -4
  40. package/cjs/src/templates/lib/sig.js +20 -9
  41. package/cjs/src/templates/lib/srv.js +7 -6
  42. package/cjs/src/templates/lib/st.js +10 -8
  43. package/cjs/src/templates/lib/useClient.js +39 -0
  44. package/cjs/src/templates/lib/{usePage.js → useServer.js} +6 -8
  45. package/cjs/src/templates/libRoot/lib/___libName__/__libName__.service.js +2 -3
  46. package/cjs/src/templates/libRoot/lib/___libName__/__libName__.store.js +2 -3
  47. package/cjs/src/templates/module/__model__.constant.js +10 -30
  48. package/cjs/src/templates/module/__model__.dictionary.js +2 -2
  49. package/cjs/src/templates/module/__model__.document.js +2 -8
  50. package/cjs/src/templates/module/__model__.service.js +2 -3
  51. package/cjs/src/templates/module/__model__.signal.js +4 -5
  52. package/cjs/src/templates/module/__model__.store.js +3 -4
  53. package/cjs/src/templates/server.js +5 -4
  54. package/cjs/src/templates/workspaceRoot/.gitignore.template +5 -3
  55. package/esm/index.js +63 -52
  56. package/esm/src/guidelines/___library/sharedUiStructureDescription.en.md +1 -1
  57. package/esm/src/guidelines/databaseModule/databaseModule.instruction.md +9 -21
  58. package/esm/src/guidelines/fieldDecorator/fieldDecorator.instruction.md +0 -5
  59. package/esm/src/guidelines/framework/framework.instruction.md +10 -12
  60. package/esm/src/guidelines/modelConstant/modelConstant.generate.json +0 -7
  61. package/esm/src/guidelines/modelConstant/modelConstant.instruction.md +14 -19
  62. package/esm/src/guidelines/modelDocument/modelDocument.instruction.md +0 -24
  63. package/esm/src/guidelines/modelService/modelService.generate.json +4 -11
  64. package/esm/src/guidelines/modelService/modelService.instruction.md +12 -75
  65. package/esm/src/guidelines/modelSignal/modelSignal.generate.json +0 -1
  66. package/esm/src/guidelines/modelSignal/modelSignal.instruction.md +2 -38
  67. package/esm/src/guidelines/modelStore/modelStore.instruction.md +1 -3
  68. package/esm/src/guidelines/modelTemplate/modelTemplate.instruction.md +2 -2
  69. package/esm/src/guidelines/modelUnit/modelUnit.instruction.md +2 -2
  70. package/esm/src/guidelines/scalarConstant/scalarConstant.instruction.md +6 -11
  71. package/esm/src/templates/__scalar/__model__/__model__.constant.js +5 -6
  72. package/esm/src/templates/__scalar/__model__/__model__.dictionary.js +1 -1
  73. package/esm/src/templates/app/app/[lang]/layout.js +0 -1
  74. package/esm/src/templates/app/app/csr.js +3 -1
  75. package/esm/src/templates/app/lib/___appName__/__appName__.dictionary.js +1 -1
  76. package/esm/src/templates/app/lib/___appName__/__appName__.service.js +2 -3
  77. package/esm/src/templates/app/lib/___appName__/__appName__.signal.js +2 -3
  78. package/esm/src/templates/app/lib/___appName__/__appName__.store.js +2 -3
  79. package/esm/src/templates/client.js +4 -4
  80. package/esm/src/templates/crudPages/[__model__Id]/edit/page.js +1 -1
  81. package/esm/src/templates/crudPages/[__model__Id]/page.js +1 -1
  82. package/esm/src/templates/crudPages/new/page.js +1 -1
  83. package/esm/src/templates/crudPages/page.js +1 -1
  84. package/esm/src/templates/index.js +0 -1
  85. package/esm/src/templates/lib/__lib/lib.constant.js +0 -1
  86. package/esm/src/templates/lib/__lib/lib.dictionary.js +7 -4
  87. package/esm/src/templates/lib/__lib/lib.document.js +4 -3
  88. package/esm/src/templates/lib/__lib/lib.service.js +1 -1
  89. package/esm/src/templates/lib/__lib/lib.signal.js +23 -4
  90. package/esm/src/templates/lib/__lib/lib.store.js +19 -2
  91. package/esm/src/templates/lib/cnst.js +12 -6
  92. package/esm/src/templates/lib/db.js +10 -3
  93. package/esm/src/templates/lib/dict.js +12 -4
  94. package/esm/src/templates/lib/sig.js +20 -9
  95. package/esm/src/templates/lib/srv.js +7 -6
  96. package/esm/src/templates/lib/st.js +10 -8
  97. package/esm/src/templates/lib/useClient.js +19 -0
  98. package/esm/src/templates/lib/useServer.js +11 -0
  99. package/esm/src/templates/libRoot/lib/___libName__/__libName__.service.js +2 -3
  100. package/esm/src/templates/libRoot/lib/___libName__/__libName__.store.js +2 -3
  101. package/esm/src/templates/module/__model__.constant.js +10 -30
  102. package/esm/src/templates/module/__model__.dictionary.js +2 -2
  103. package/esm/src/templates/module/__model__.document.js +2 -8
  104. package/esm/src/templates/module/__model__.service.js +2 -3
  105. package/esm/src/templates/module/__model__.signal.js +4 -5
  106. package/esm/src/templates/module/__model__.store.js +3 -4
  107. package/esm/src/templates/server.js +5 -4
  108. package/esm/src/templates/workspaceRoot/.gitignore.template +5 -3
  109. package/package.json +1 -1
  110. package/src/application/application.command.d.ts +7 -7
  111. package/src/application/application.script.d.ts +3 -1
  112. package/src/guidelines/___library/sharedUiStructureDescription.en.md +1 -1
  113. package/src/guidelines/databaseModule/databaseModule.instruction.md +9 -21
  114. package/src/guidelines/fieldDecorator/fieldDecorator.instruction.md +0 -5
  115. package/src/guidelines/framework/framework.instruction.md +10 -12
  116. package/src/guidelines/modelConstant/modelConstant.instruction.md +14 -19
  117. package/src/guidelines/modelDocument/modelDocument.instruction.md +0 -24
  118. package/src/guidelines/modelService/modelService.instruction.md +12 -75
  119. package/src/guidelines/modelSignal/modelSignal.instruction.md +2 -38
  120. package/src/guidelines/modelStore/modelStore.instruction.md +1 -3
  121. package/src/guidelines/modelTemplate/modelTemplate.instruction.md +2 -2
  122. package/src/guidelines/modelUnit/modelUnit.instruction.md +2 -2
  123. package/src/guidelines/scalarConstant/scalarConstant.instruction.md +6 -11
  124. package/src/templates/lib/useServer.d.ts +4 -0
  125. package/src/workspace/workspace.command.d.ts +1 -0
  126. package/src/workspace/workspace.script.d.ts +1 -0
  127. package/esm/src/templates/lib/usePage.js +0 -13
  128. /package/src/templates/lib/{usePage.d.ts → useClient.d.ts} +0 -0
@@ -23,7 +23,6 @@ Akan.js services typically extend base service classes provided by the framework
23
23
  Most services extend `DbService` to work with MongoDB models:
24
24
 
25
25
  ```typescript
26
- @Service("ProductService")
27
26
  export class ProductService extends DbService(db.productDb) {
28
27
  // Service methods here
29
28
  }
@@ -31,13 +30,12 @@ export class ProductService extends DbService(db.productDb) {
31
30
 
32
31
  The `DbService` function automatically injects the database model and provides numerous convenience methods for CRUD operations.
33
32
 
34
- ### LogService
33
+ ### serve
35
34
 
36
35
  For utility services that don't directly work with a database model:
37
36
 
38
37
  ```typescript
39
- @Service("SecurityService")
40
- export class SecurityService extends LogService("SecurityService") {
38
+ export class SecurityService extends serve("security" as const) {
41
39
  // Utility methods here
42
40
  }
43
41
  ```
@@ -51,7 +49,7 @@ For specific domain services with shared functionality:
51
49
  export const LibService = MixSrvs(SharedService, PlatformService, SocialService);
52
50
 
53
51
  // In another service
54
- @Service("CustomService")
52
+
55
53
  export class CustomService extends LibService {
56
54
  // Custom methods here
57
55
  }
@@ -59,20 +57,6 @@ export class CustomService extends LibService {
59
57
 
60
58
  ## Core Decorators
61
59
 
62
- ### @Service Decorator
63
-
64
- Declares a class as an injectable NestJS service with additional configuration options:
65
-
66
- ```typescript
67
- @Service("UserService", {
68
- enabled: true, // Enable/disable service dynamically
69
- serverMode: "federation", // "federation", "batch", or not specified
70
- })
71
- export class UserService extends DbService(db.userDb) {
72
- // Service implementation
73
- }
74
- ```
75
-
76
60
  Options:
77
61
 
78
62
  - `enabled`: Boolean flag to conditionally disable a service (default: true)
@@ -263,7 +247,6 @@ async _postRemove(doc: Product): Promise<Product> {
263
247
  Services often work together to implement complex operations:
264
248
 
265
249
  ```typescript
266
- @Service("OrderService")
267
250
  export class OrderService extends DbService(db.orderDb) {
268
251
  @Srv() productService: ProductService;
269
252
  @Srv() userService: UserService;
@@ -322,7 +305,6 @@ export class OrderService extends DbService(db.orderDb) {
322
305
  For real-time features:
323
306
 
324
307
  ```typescript
325
- @Service("ChatService")
326
308
  export class ChatService extends DbService(db.chatDb) {
327
309
  @Websocket()
328
310
  websocket: Websocket<ChatSignal>;
@@ -354,8 +336,7 @@ export class ChatService extends DbService(db.chatDb) {
354
336
  For background processing:
355
337
 
356
338
  ```typescript
357
- @Service("EmailService")
358
- export class EmailService extends LogService("EmailService") {
339
+ export class EmailService extends serve("email" as const) {
359
340
  @Queue()
360
341
  emailQueue: Queue<EmailSignal>;
361
342
  @Use()
@@ -441,7 +422,7 @@ Services should not maintain internal state between requests:
441
422
 
442
423
  ```typescript
443
424
  // BAD - maintains state in the service
444
- @Service("CounterService")
425
+
445
426
  class CounterService {
446
427
  private count = 0; // This state is lost on server restart
447
428
 
@@ -454,7 +435,7 @@ class CounterService {
454
435
  }
455
436
 
456
437
  // GOOD - uses database for state
457
- @Service("CounterService")
438
+
458
439
  class CounterService extends DbService(db.counterDb) {
459
440
  async increment(counterId: string) {
460
441
  const counter = await this.getCounter(counterId);
@@ -474,7 +455,7 @@ Each service should focus on a specific domain:
474
455
 
475
456
  ```typescript
476
457
  // BAD - mixing concerns
477
- @Service("UserService")
458
+
478
459
  class UserService extends DbService(db.userDb) {
479
460
  async createUser(data) {
480
461
  // User creation logic
@@ -490,7 +471,7 @@ class UserService extends DbService(db.userDb) {
490
471
  }
491
472
 
492
473
  // GOOD - separate services
493
- @Service("UserService")
474
+
494
475
  class UserService extends DbService(db.userDb) {
495
476
  @Srv() emailService: EmailService;
496
477
  @Srv() paymentService: PaymentService;
@@ -500,14 +481,12 @@ class UserService extends DbService(db.userDb) {
500
481
  }
501
482
  }
502
483
 
503
- @Service("EmailService")
504
- class EmailService extends LogService("EmailService") {
484
+ class EmailService extends serve("email" as const) {
505
485
  async sendEmail(userId, subject, content) {
506
486
  // Email sending logic
507
487
  }
508
488
  }
509
489
 
510
- @Service("PaymentService")
511
490
  class PaymentService extends DbService(db.paymentDb) {
512
491
  async processPayment(userId, amount) {
513
492
  // Payment processing logic
@@ -546,13 +525,12 @@ Inject other services using decorators, not direct imports:
546
525
  // BAD - direct import
547
526
  import { UserService } from "../user/user.service";
548
527
 
549
- @Service("OrderService")
550
528
  class OrderService extends DbService(db.orderDb) {
551
529
  private userService = new UserService(); // Hard-coded dependency
552
530
  }
553
531
 
554
532
  // GOOD - dependency injection
555
- @Service("OrderService")
533
+
556
534
  class OrderService extends DbService(db.orderDb) {
557
535
  @Srv() userService: UserService; // Injected dependency
558
536
  }
@@ -563,7 +541,6 @@ class OrderService extends DbService(db.orderDb) {
563
541
  Use the built-in logger for consistent logging:
564
542
 
565
543
  ```typescript
566
- @Service("PaymentService")
567
544
  class PaymentService extends DbService(db.paymentDb) {
568
545
  async processPayment(orderId: string, amount: number) {
569
546
  this.logger.log(`Processing payment of ${amount} for order ${orderId}`);
@@ -581,20 +558,6 @@ class PaymentService extends DbService(db.paymentDb) {
581
558
  }
582
559
  ```
583
560
 
584
- ## Integration with NestJS
585
-
586
- Akan.js services are built on top of NestJS's dependency injection system. The `@Service` decorator builds on top of NestJS's `@Injectable()`:
587
-
588
- ```typescript
589
- // Behind the scenes, @Service does this:
590
- @Injectable()
591
- export class UserService {
592
- // ...
593
- }
594
- ```
595
-
596
- This allows Akan.js services to be used within NestJS modules, controllers, and resolvers.
597
-
598
561
  ## Complete Example
599
562
 
600
563
  Here's a complete example of a service implementation:
@@ -602,7 +565,7 @@ Here's a complete example of a service implementation:
602
565
  ```typescript
603
566
  import { Dayjs } from "@akanjs/base";
604
567
  import { Cron } from "@akanjs/nest";
605
- import { DbService, Service, Srv, Use } from "@akanjs/service";
568
+ import { DbService, Srv, Use } from "@akanjs/service";
606
569
  import type { EmailApi } from "@util/nest";
607
570
 
608
571
  import * as cnst from "../cnst";
@@ -610,7 +573,6 @@ import * as db from "../db";
610
573
  import { Revert } from "../dict";
611
574
  import type * as srv from "../srv";
612
575
 
613
- @Service("OrderService")
614
576
  export class OrderService extends DbService(db.orderDb) {
615
577
  @Srv() userService: srv.UserService;
616
578
  @Srv() productService: srv.ProductService;
@@ -704,31 +666,6 @@ export class OrderService extends DbService(db.orderDb) {
704
666
 
705
667
  ## Troubleshooting
706
668
 
707
- ### Service Not Being Injected
708
-
709
- If a service isn't being injected correctly:
710
-
711
- 1. Ensure the service name matches:
712
-
713
- ```typescript
714
- @Service("UserService") // This name must match
715
- export class UserService extends DbService(db.userDb) {}
716
-
717
- @Srv("UserService") // Or this must match if using explicit name
718
- userService: UserService;
719
- ```
720
-
721
- 2. Check if the service is enabled in the current environment:
722
-
723
- ```typescript
724
- @Service("UserService", { enabled: process.env.ENABLE_USER_SERVICE === 'true' })
725
- ```
726
-
727
- 3. Verify server mode restrictions:
728
- ```typescript
729
- @Service("CleanupService", { serverMode: "batch" }) // Only runs in batch mode
730
- ```
731
-
732
669
  ### Database Operations Failing
733
670
 
734
671
  1. Check model definition and schema:
@@ -763,7 +700,7 @@ Model services in Akan.js are powerful components that encapsulate business logi
763
700
  Key takeaways:
764
701
 
765
702
  - Services should be stateless, with persistent state managed in the database
766
- - Use the appropriate decorator (@Service, @Srv, @Use, etc.) for dependency injection
703
+ - Use the appropriate decorator (@Srv, @Use, etc.) for dependency injection
767
704
  - Implement lifecycle hooks for proper resource management
768
705
  - Use scheduled tasks for recurring operations
769
706
  - Follow single responsibility principle
@@ -176,7 +176,6 @@
176
176
  "contents": [
177
177
  "Purpose and role of model.signal.ts files",
178
178
  "Signal class structure and core components",
179
- "@Signal decorator and Signal class definition",
180
179
  "DbSignal and other higher-order functions",
181
180
  "Endpoint decorators (@Query, @Mutation, @Message, @Process, @Pubsub)",
182
181
  "Parameter decorators (@Arg.Query, @Arg.Param, @Arg.Body, @Self, etc.)",
@@ -26,7 +26,6 @@ import { Arg, DbSignal, Mutation, Query, resolve, Self, Signal } from "@akanjs/s
26
26
  import * as cnst from "../cnst";
27
27
  import type * as db from "../db";
28
28
 
29
- @Signal(() => cnst.ModelName)
30
29
  export class ModelNameSignal extends DbSignal(cnst.modelNameCnst, cnst.Srvs, {
31
30
  guards: { get: Query.Public, cru: Mutation.User },
32
31
  }) {
@@ -36,36 +35,7 @@ export class ModelNameSignal extends DbSignal(cnst.modelNameCnst, cnst.Srvs, {
36
35
 
37
36
  Key components:
38
37
 
39
- - `@Signal()` decorator defines this class as a signal provider
40
- - `DbSignal()` higher-order function provides standard CRUD operations
41
- - `guards` option configures default access control for CRUD operations
42
- - Service references are injected from `Srvs` imported from cnst.ts
43
-
44
- ## Decorator Reference
45
-
46
- ### 1. @Query Decorator
47
-
48
- Used for read-only operations with access control levels:
49
-
50
- ```typescript
51
- @Query.Public(() => [cnst.Product]) // Public access, returns array of Products
52
- async productListInFeatured(
53
- @Arg.Query("skip", () => Int, { nullable: true }) skip: number | null,
54
- @Arg.Query("limit", () => Int, { nullable: true }) limit: number | null,
55
- @Arg.Query("sort", () => String, { nullable: true }) sort: SortOf<cnst.ProductFilter> | null
56
- ) {
57
- const products = await this.productService.listFeatured({ skip, limit, sort });
58
- return resolve<cnst.Product[]>(products); // Type-safe resolution
59
- }
60
- ```
61
-
62
- Access control levels:
63
-
64
- - `Query.Public` - Available to unauthenticated users
65
- - `Query.User` - Requires user authentication
66
- - `Query.Admin` - Requires admin access
67
- - `Query.SuperAdmin` - Requires super admin access
68
- - `Query.Every` - Available to all authenticated users (any role)
38
+ - `
69
39
 
70
40
  ### 2. @Mutation Decorator
71
41
 
@@ -169,7 +139,7 @@ The slice pattern standardizes data access with consistent naming and pagination
169
139
  async chatRoomListInSelf( // listIn<SliceName> pattern
170
140
  @Arg.Query("skip", () => Int, { nullable: true }) skip: number | null,
171
141
  @Arg.Query("limit", () => Int, { nullable: true }) limit: number | null,
172
- @Arg.Query("sort", () => String, { nullable: true }) sort: SortOf<cnst.ChatRoomFilter> | null,
142
+ @Arg.Query("sort", () => String, { nullable: true }) sort: SortOf<db.ChatRoomFilter> | null,
173
143
  @Self() self: Self
174
144
  ) {
175
145
  const chatRooms = await this.chatRoomService.listInUser(self.id, { skip, limit, sort });
@@ -288,7 +258,6 @@ function ChatRoom({ roomId }) {
288
258
  DbSignal creates standard operations that you don't need to implement:
289
259
 
290
260
  ```typescript
291
- @Signal(() => cnst.Board)
292
261
  export class BoardSignal extends DbSignal(cnst.boardCnst, cnst.Srvs, {
293
262
  guards: { get: Query.Public, cru: Mutation.Admin },
294
263
  }) {
@@ -408,7 +377,6 @@ async getProjectDetails(
408
377
  ### Basic CRUD Signal with DbSignal
409
378
 
410
379
  ```typescript
411
- @Signal(() => cnst.Product)
412
380
  export class ProductSignal extends DbSignal(cnst.productCnst, cnst.Srvs, {
413
381
  guards: { get: Query.Public, cru: Mutation.Admin },
414
382
  }) {
@@ -436,7 +404,6 @@ export class ProductSignal extends DbSignal(cnst.productCnst, cnst.Srvs, {
436
404
  ### Real-Time Chat Signal
437
405
 
438
406
  ```typescript
439
- @Signal(() => cnst.Chat)
440
407
  export class ChatSignal {
441
408
  @Mutation.User(() => cnst.Chat)
442
409
  async sendChat(
@@ -464,7 +431,6 @@ export class ChatSignal {
464
431
  ### Background Processing Signal
465
432
 
466
433
  ```typescript
467
- @Signal(() => cnst.Report)
468
434
  export class ReportSignal {
469
435
  @Mutation.Admin(() => cnst.Report)
470
436
  async generateReport(
@@ -543,7 +509,6 @@ export function SelfSlice<T>(returnType: () => T) {
543
509
  ### Signal Integration with External APIs
544
510
 
545
511
  ```typescript
546
- @Signal(() => cnst.ExternalData)
547
512
  export class ExternalApiSignal {
548
513
  @Query.Public(() => cnst.WeatherData)
549
514
  async getWeatherData(@Arg.Query("location", () => String) location: string) {
@@ -564,7 +529,6 @@ export class ExternalApiSignal {
564
529
  Signals can implement caching for performance:
565
530
 
566
531
  ```typescript
567
- @Signal(() => cnst.Product)
568
532
  export class ProductSignal extends DbSignal(cnst.productCnst, Srvs) {
569
533
  @Query.Public(() => cnst.Product)
570
534
  async getProduct(@Arg.Param("productId", () => ID) productId: string) {
@@ -37,7 +37,6 @@ import { stateOf, Store } from "@akanjs/store";
37
37
  import * as cnst from "../cnst";
38
38
  import { fetch } from "../sig";
39
39
 
40
- @Store(() => cnst.Product)
41
40
  export class ProductStore extends stateOf(fetch.productGql, {
42
41
  // Custom state properties
43
42
  featuredProducts: [] as cnst.LightProduct[],
@@ -359,7 +358,7 @@ For complex applications, compose multiple stores:
359
358
  // In store.ts
360
359
  export class RootStore extends MixStore(ProductStore, CategoryStore, VendorStore, CartStore) {}
361
360
 
362
- export const store = rootStoreOf(RootStore);
361
+ export const storeRoot = rootStoreOf(RootStore);
363
362
  ```
364
363
 
365
364
  ### Cross-Store Operations
@@ -489,7 +488,6 @@ import * as cnst from "../cnst";
489
488
  import { fetch } from "../sig";
490
489
  import { msg } from "../msg";
491
490
 
492
- @Store(() => cnst.Product)
493
491
  export class ProductStore extends stateOf(fetch.productGql, {
494
492
  // UI State
495
493
  productViewMode: "grid" as "grid" | "list",
@@ -40,7 +40,7 @@ Model.Template.tsx files are client-side React components that define the form s
40
40
  "use client";
41
41
  import { Field } from "@shared/ui";
42
42
  import { st } from "@[project]/client";
43
- import { usePage } from "@[project]/lib/usePage";
43
+ import { usePage } from "@[project]/lib/useClient";
44
44
 
45
45
  export const General = ({ id }: { id?: string }) => {
46
46
  const form = st.use.[model]Form();
@@ -466,7 +466,7 @@ const DockerRegistry = ({ value, onChange }) => (
466
466
 
467
467
  ```tsx
468
468
  // Model.constant.ts
469
- @Model.Input("ProjectInput")
469
+
470
470
  export class ProjectInput {
471
471
  @Field.Prop(() => String)
472
472
  name: string;
@@ -148,7 +148,7 @@ Model Units work with LightModel types defined in constant files:
148
148
 
149
149
  ```tsx
150
150
  // In your constant.ts file
151
- @Model.Light("LightProduct")
151
+
152
152
  export class LightProduct extends via(ProductObject, ["name", "price", "sku", "inStock"] as const) {
153
153
  get displayPrice() {
154
154
  return `${this.price.toLocaleString()} KRW`;
@@ -503,7 +503,7 @@ Type error: Property 'description' does not exist on type 'LightProduct'
503
503
 
504
504
  ```tsx
505
505
  // In constant.ts
506
- @Model.Light("LightProduct")
506
+
507
507
  export class LightProduct extends via(ProductObject, ["name", "price", "sku"] as const) {
508
508
  // Only these fields are guaranteed to be available
509
509
  }
@@ -41,7 +41,7 @@ export const Status = enumOf(["active", "inactive"] as const);
41
41
  export type Status = enumOf<typeof Status>;
42
42
 
43
43
  // 3. Scalar model class (SINGLE CLASS PER FILE)
44
- @Model.Scalar("ScalarName") // Must match class name
44
+ // Must match class name
45
45
  export class ScalarName {
46
46
  // Field definitions
47
47
  @Field.Prop(() => FieldType, { ...options })
@@ -74,7 +74,7 @@ import { OtherScalar } from "../other-scalar/other-scalar.constant";
74
74
  ### Basic Structure
75
75
 
76
76
  ```typescript
77
- @Model.Scalar("ScalarName") // String must match class name
77
+ // String must match class name
78
78
  export class ScalarName {
79
79
  // Field definitions go here
80
80
  }
@@ -207,7 +207,6 @@ status: Status;
207
207
  Scalar classes can include static methods for common operations on the scalar type:
208
208
 
209
209
  ```typescript
210
- @Model.Scalar("Coordinate")
211
210
  export class Coordinate {
212
211
  @Field.Prop(() => [Float], { default: [0, 0] })
213
212
  coordinates: number[];
@@ -305,8 +304,8 @@ export type Status = enumOf<typeof Status>;
305
304
 
306
305
  ```typescript
307
306
  // ❌ Wrong (violates single-responsibility)
308
- @Model.Scalar("Address") class Address { ... }
309
- @Model.Scalar("User") class User { ... }
307
+ class Address { ... }
308
+ class User { ... }
310
309
 
311
310
  // ✅ Correct (separate files)
312
311
  // address.constant.ts
@@ -339,7 +338,7 @@ createdAt: Dayjs;
339
338
  export class GeoLocation { ... }
340
339
 
341
340
  // ✅ Correct
342
- @Model.Scalar("GeoLocation")
341
+
343
342
  export class GeoLocation { ... }
344
343
  ```
345
344
 
@@ -352,7 +351,6 @@ export class GeoLocation { ... }
352
351
  import { Float } from "@akanjs/base";
353
352
  import { Field, Model } from "@akanjs/constant";
354
353
 
355
- @Model.Scalar("Amount")
356
354
  export class Amount {
357
355
  @Field.Prop(() => Float, { min: 0, default: 0 })
358
356
  value: number;
@@ -373,7 +371,6 @@ import { Field, Model } from "@akanjs/constant";
373
371
  export const AccuracyLevel = enumOf(["low", "medium", "high"] as const);
374
372
  export type AccuracyLevel = enumOf<typeof AccuracyLevel>;
375
373
 
376
- @Model.Scalar("GeoLocation")
377
374
  export class GeoLocation {
378
375
  @Field.Prop(() => Float, {
379
376
  min: -90,
@@ -418,7 +415,6 @@ import { Int, Float } from "@akanjs/base";
418
415
  import { Field, Model } from "@akanjs/constant";
419
416
  import { Dimension } from "../dimension/dimension.constant";
420
417
 
421
- @Model.Scalar("ProductSpec")
422
418
  export class ProductSpec {
423
419
  @Field.Prop(() => String)
424
420
  sku: string;
@@ -450,7 +446,6 @@ export class ProductSpec {
450
446
  import { Float } from "@akanjs/base";
451
447
  import { Field, Model } from "@akanjs/constant";
452
448
 
453
- @Model.Scalar("Coordinate")
454
449
  export class Coordinate {
455
450
  @Field.Prop(() => [Float], { default: [0, 0], example: [127.114367, 37.497114] })
456
451
  coordinates: number[];
@@ -477,7 +472,7 @@ export class Coordinate {
477
472
  1. **Location**: `__scalar/<camelCase>/<camelCase>.constant.ts`
478
473
  2. **Structure**: Single `@Model.Scalar` class per file
479
474
  3. **Naming**: Class name = PascalCase directory name
480
- 4. **Decorator**: `@Model.Scalar("ClassName")` with exact class name match
475
+ 4. **Decorator**: `` with exact class name match
481
476
  5. **Enum Values**: Always camelCase (`active`, not `ACTIVE`)
482
477
  6. **Fields**: Use `@Field.Prop` with arrow function types
483
478
  7. **Arrays**: Wrap in `[]` (e.g., `[Int]`)
@@ -1,13 +1,12 @@
1
1
  // pkgs/@akanjs/cli/src/templates/__scalar/__model__/__model__.constant.ts
2
2
  function getContent(scanInfo, dict) {
3
3
  return `
4
- import { Field, Model } from "@akanjs/constant";
4
+ import { via } from "@akanjs/constant";
5
5
 
6
- @Model.Scalar("${dict.Model}")
7
- export class ${dict.Model} {
8
- @Field.Prop(() => String)
9
- field: string;
10
- }
6
+
7
+ export class ${dict.Model} extends via((field) => ({
8
+ field: field(String),
9
+ })) {}
11
10
  `;
12
11
  }
13
12
  export {
@@ -5,7 +5,7 @@ import { ModelDictionary } from "@akanjs/dictionary";
5
5
 
6
6
  import type { ${dict.Model} } from "./${dict.model}.constant";
7
7
 
8
- const modelDictionary = {
8
+ export const modelDictionary = {
9
9
  modelName: ["${dict.Model}", "${dict.Model}"],
10
10
  modelDesc: ["${dict.Model}", "${dict.Model}"],
11
11
 
@@ -20,7 +20,6 @@ export default function Layout({ children, params }: RootLayoutProps) {
20
20
  head={<link rel="icon" href="/favicon.ico" />}
21
21
  // className="bg-base-100"
22
22
  env={env}
23
- fetch={fetch}
24
23
  >
25
24
  {children}
26
25
  </System.Provider>
@@ -5,7 +5,9 @@ function getContent(scanInfo, dict) {
5
5
  content: `
6
6
  import { bootCsr } from "@akanjs/next";
7
7
 
8
- void bootCsr(import.meta.glob("./**/*.tsx"));
8
+ import { registerClient } from "../client";
9
+
10
+ void bootCsr(import.meta.glob("./**/*.tsx"), registerClient);
9
11
  `
10
12
  };
11
13
  }
@@ -6,7 +6,7 @@ import type { ${dict.AppName}Signal } from "./${dict.appName}.signal";
6
6
 
7
7
  const dictionary = {} as const;
8
8
 
9
- const signalDictionary = {} satisfies SignalDictionary<${dict.AppName}Signal>;
9
+ export const signalDictionary = {} satisfies SignalDictionary<${dict.AppName}Signal>;
10
10
 
11
11
  export const ${dict.appName}Dictionary = { ...dictionary, ...signalDictionary };
12
12
  `;
@@ -1,10 +1,9 @@
1
1
  // pkgs/@akanjs/cli/src/templates/app/lib/___appName__/__appName__.service.ts
2
2
  function getContent(scanInfo, dict) {
3
3
  return `
4
- import { LogService, Service } from "@akanjs/service";
4
+ import { serve } from "@akanjs/service";
5
5
 
6
- @Service("${dict.appName}Service", { serverMode: "batch" })
7
- export class ${dict.AppName}Service extends LogService("${dict.appName}Service") {}
6
+ export class ${dict.AppName}Service extends serve("${dict.appName}" as const, { serverMode: "batch" }) {}
8
7
  `;
9
8
  }
10
9
  export {
@@ -1,12 +1,11 @@
1
1
  // pkgs/@akanjs/cli/src/templates/app/lib/___appName__/__appName__.signal.ts
2
2
  function getContent(scanInfo, dict) {
3
3
  return `
4
- import { LogSignal, Signal } from "@akanjs/signal";
4
+ import { signal } from "@akanjs/signal";
5
5
 
6
6
  import * as cnst from "../cnst";
7
7
 
8
- @Signal({ name: "${dict.AppName}" })
9
- export class ${dict.AppName}Signal extends LogSignal(cnst.Srvs) {}
8
+ export class ${dict.AppName}Signal extends signal("${dict.AppName}" as const, cnst.Srvs) {}
10
9
  `;
11
10
  }
12
11
  export {
@@ -1,10 +1,9 @@
1
1
  // pkgs/@akanjs/cli/src/templates/app/lib/___appName__/__appName__.store.ts
2
2
  function getContent(scanInfo, dict) {
3
3
  return `
4
- import { scalarStateOf, Store } from "@akanjs/store";
4
+ import { store } from "@akanjs/store";
5
5
 
6
- @Store({ name: "${dict.appName}" })
7
- export class ${dict.AppName}Store extends scalarStateOf("${dict.appName}" as const, {
6
+ export class ${dict.AppName}Store extends store("${dict.appName}" as const, {
8
7
  // state
9
8
  }) {
10
9
  // action
@@ -13,10 +13,10 @@ function getContent(scanInfo, dict = {}) {
13
13
  ([_, fileTypes]) => fileTypes.has("template") || fileTypes.has("unit") || fileTypes.has("util") || fileTypes.has("view") || fileTypes.has("zone")
14
14
  ).map(([key]) => key);
15
15
  return `
16
- export { Revert, msg, usePage } from "./lib/usePage";
17
- export { st, store } from "./lib/st";
18
- export { fetch } from "./lib/sig";
19
- export * as cnst from "./lib/cnst"
16
+ export * as cnst from "./lib/cnst";
17
+ export { msg, Revert, usePage, fetch, sig, registerClient } from "./lib/useClient";
18
+ export { st, RootStore } from "./lib/st";
19
+ export * as store from "./lib/st";
20
20
  ${scalarModules.map((module) => `export { ${capitalize(module)} } from "./lib/__scalar/${module}";`).join("\n")}
21
21
  ${serviceModules.map((module) => `export { ${capitalize(module)} } from "./lib/_${module}";`).join("\n")}
22
22
  ${databaseModules.map((module) => `export { ${capitalize(module)} } from "./lib/${module}";`).join("\n")}
@@ -25,7 +25,7 @@ export default function Page({ params }: PageProps) {
25
25
  <div className="container">
26
26
  <div className="flex justify-between m-4 mt-8">
27
27
  <div className="text-xl text-primary flex gap-2 items-center">
28
- {l("shared.updateModel", { model: l("${dict.model}.modelName") })}
28
+ {l("base.updateModel", { model: l("${dict.model}.modelName") })}
29
29
  </div>
30
30
  </div>
31
31
  <Load.Edit
@@ -40,7 +40,7 @@ export default function Page({ params }: PageProps) {
40
40
  <${dict.Model}.Zone.View view={${dict.model}View} />
41
41
  <Link href={\`/${dict.model}/\${${dict.model}.id}/edit\`}>
42
42
  <button className="btn">
43
- {l("shared.updateModel", { model: l("${dict.model}.modelName") })}
43
+ {l("base.updateModel", { model: l("${dict.model}.modelName") })}
44
44
  </button>
45
45
  </Link>
46
46
  </div>
@@ -20,7 +20,7 @@ export default function Page() {
20
20
  <div className="container">
21
21
  <div className="flex justify-between m-4 mt-8">
22
22
  <div className="text-xl text-primary flex gap-2 items-center">
23
- + {l("shared.createModel", { model: l("${dict.model}.modelName") })}
23
+ + {l("base.createModel", { model: l("${dict.model}.modelName") })}
24
24
  </div>
25
25
  </div>
26
26
  <Load.Edit
@@ -23,7 +23,7 @@ export default function Page() {
23
23
  <div className="animate-fadeIn px-4 pt-4 flex gap-4 items-center">
24
24
  <div className="font-bold text-lg md:text-4xl">${dict.Model}s</div>
25
25
  <Link href={\`/${dict.model}/new\`}>
26
- <button className="btn">+ {l("shared.createModel", { model: l("${dict.model}.modelName") })}</button>
26
+ <button className="btn">+ {l("base.createModel", { model: l("${dict.model}.modelName") })}</button>
27
27
  </Link>
28
28
  </div>
29
29
  <div>{l("${dict.model}.modelDesc")}</div>
@@ -2,7 +2,6 @@
2
2
  function getContent(scanInfo, dict = {}) {
3
3
  return `
4
4
  export * as cnst from "./lib/cnst";
5
- export { fetch } from "./lib/sig";
6
5
  `;
7
6
  }
8
7
  export {
@@ -27,7 +27,6 @@ ${Object.entries(extendedModels).map(([modelName, extendedModels2]) => {
27
27
  lights: [${extendedModels2.map((libName) => `${libName}.Light${ModelName}`).join(", ")}] as const,
28
28
  models: [${extendedModels2.map((libName) => `${libName}.${ModelName}`).join(", ")}] as const,
29
29
  insights: [${extendedModels2.map((libName) => `${libName}.${ModelName}Insight`).join(", ")}] as const,
30
- filters: [${extendedModels2.map((libName) => `${libName}.${ModelName}Filter`).join(", ")}] as const,
31
30
  }`;
32
31
  }).join("\n")}
33
32