@soapjs/cli 1.0.0

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 (149) hide show
  1. package/.nvmrc +1 -0
  2. package/LICENSE +21 -0
  3. package/README.md +360 -0
  4. package/build/cli.d.ts +3 -0
  5. package/build/cli.js +50 -0
  6. package/build/commands/add/add.command.d.ts +2 -0
  7. package/build/commands/add/add.command.js +709 -0
  8. package/build/commands/add/command-plan.d.ts +15 -0
  9. package/build/commands/add/command-plan.js +182 -0
  10. package/build/commands/add/entity-plan.d.ts +7 -0
  11. package/build/commands/add/entity-plan.js +106 -0
  12. package/build/commands/add/event-plan.d.ts +8 -0
  13. package/build/commands/add/event-plan.js +59 -0
  14. package/build/commands/add/query-plan.d.ts +10 -0
  15. package/build/commands/add/query-plan.js +156 -0
  16. package/build/commands/add/repository-plan.d.ts +11 -0
  17. package/build/commands/add/repository-plan.js +252 -0
  18. package/build/commands/add/resource-plan.d.ts +52 -0
  19. package/build/commands/add/resource-plan.js +2031 -0
  20. package/build/commands/add/route-plan.d.ts +24 -0
  21. package/build/commands/add/route-plan.js +256 -0
  22. package/build/commands/add/socket-plan.d.ts +9 -0
  23. package/build/commands/add/socket-plan.js +81 -0
  24. package/build/commands/add/use-case-plan.d.ts +7 -0
  25. package/build/commands/add/use-case-plan.js +86 -0
  26. package/build/commands/check/check.command.d.ts +2 -0
  27. package/build/commands/check/check.command.js +113 -0
  28. package/build/commands/create/create.command.d.ts +2 -0
  29. package/build/commands/create/create.command.js +234 -0
  30. package/build/commands/create/project-plan.d.ts +44 -0
  31. package/build/commands/create/project-plan.js +1430 -0
  32. package/build/commands/doctor/doctor.command.d.ts +2 -0
  33. package/build/commands/doctor/doctor.command.js +38 -0
  34. package/build/commands/generate/bruno-analysis.d.ts +19 -0
  35. package/build/commands/generate/bruno-analysis.js +51 -0
  36. package/build/commands/generate/bruno-plan.d.ts +6 -0
  37. package/build/commands/generate/bruno-plan.js +326 -0
  38. package/build/commands/generate/generate.command.d.ts +2 -0
  39. package/build/commands/generate/generate.command.js +130 -0
  40. package/build/commands/info/info.command.d.ts +2 -0
  41. package/build/commands/info/info.command.js +26 -0
  42. package/build/commands/remove/remove.command.d.ts +2 -0
  43. package/build/commands/remove/remove.command.js +328 -0
  44. package/build/commands/shared/common-options.d.ts +10 -0
  45. package/build/commands/shared/common-options.js +23 -0
  46. package/build/commands/update/update.command.d.ts +2 -0
  47. package/build/commands/update/update.command.js +155 -0
  48. package/build/config/auth-policy.d.ts +4 -0
  49. package/build/config/auth-policy.js +54 -0
  50. package/build/config/find-soap-root.d.ts +1 -0
  51. package/build/config/find-soap-root.js +22 -0
  52. package/build/config/load-soap-config.d.ts +2 -0
  53. package/build/config/load-soap-config.js +30 -0
  54. package/build/config/schemas/types.d.ts +127 -0
  55. package/build/config/schemas/types.js +2 -0
  56. package/build/config/schemas/validation.d.ts +5 -0
  57. package/build/config/schemas/validation.js +130 -0
  58. package/build/config/soap-config.service.d.ts +4 -0
  59. package/build/config/soap-config.service.js +24 -0
  60. package/build/config/write-soap-config.d.ts +8 -0
  61. package/build/config/write-soap-config.js +25 -0
  62. package/build/core/command-context.d.ts +20 -0
  63. package/build/core/command-context.js +30 -0
  64. package/build/core/errors.d.ts +6 -0
  65. package/build/core/errors.js +23 -0
  66. package/build/core/output.d.ts +12 -0
  67. package/build/core/output.js +30 -0
  68. package/build/core/result.d.ts +9 -0
  69. package/build/core/result.js +11 -0
  70. package/build/dependencies/dependency-resolver.d.ts +6 -0
  71. package/build/dependencies/dependency-resolver.js +68 -0
  72. package/build/dependencies/package-manager.d.ts +7 -0
  73. package/build/dependencies/package-manager.js +54 -0
  74. package/build/index.d.ts +2 -0
  75. package/build/index.js +9 -0
  76. package/build/io/conflict-policy.d.ts +10 -0
  77. package/build/io/conflict-policy.js +32 -0
  78. package/build/io/file-writer.d.ts +19 -0
  79. package/build/io/file-writer.js +65 -0
  80. package/build/io/format-file.d.ts +1 -0
  81. package/build/io/format-file.js +13 -0
  82. package/build/presets/create-presets.d.ts +4 -0
  83. package/build/presets/create-presets.js +97 -0
  84. package/build/presets/index.d.ts +2 -0
  85. package/build/presets/index.js +18 -0
  86. package/build/presets/preset.types.d.ts +6 -0
  87. package/build/presets/preset.types.js +2 -0
  88. package/build/prompts/add-resource.prompt.d.ts +13 -0
  89. package/build/prompts/add-resource.prompt.js +80 -0
  90. package/build/prompts/add-route.prompt.d.ts +16 -0
  91. package/build/prompts/add-route.prompt.js +140 -0
  92. package/build/prompts/create-project.prompt.d.ts +11 -0
  93. package/build/prompts/create-project.prompt.js +156 -0
  94. package/build/prompts/generate-bruno.prompt.d.ts +7 -0
  95. package/build/prompts/generate-bruno.prompt.js +21 -0
  96. package/build/prompts/index.d.ts +8 -0
  97. package/build/prompts/index.js +24 -0
  98. package/build/prompts/inquirer-prompt-adapter.d.ts +8 -0
  99. package/build/prompts/inquirer-prompt-adapter.js +52 -0
  100. package/build/prompts/mock-prompt-adapter.d.ts +13 -0
  101. package/build/prompts/mock-prompt-adapter.js +60 -0
  102. package/build/prompts/prompt-adapter.d.ts +7 -0
  103. package/build/prompts/prompt-adapter.js +2 -0
  104. package/build/prompts/prompt.types.d.ts +26 -0
  105. package/build/prompts/prompt.types.js +2 -0
  106. package/build/registry/registry.service.d.ts +19 -0
  107. package/build/registry/registry.service.js +68 -0
  108. package/build/resolvers/add-resource.resolver.d.ts +23 -0
  109. package/build/resolvers/add-resource.resolver.js +73 -0
  110. package/build/resolvers/add-route.resolver.d.ts +34 -0
  111. package/build/resolvers/add-route.resolver.js +83 -0
  112. package/build/resolvers/create-config.resolver.d.ts +32 -0
  113. package/build/resolvers/create-config.resolver.js +57 -0
  114. package/build/resolvers/generate-bruno.resolver.d.ts +17 -0
  115. package/build/resolvers/generate-bruno.resolver.js +23 -0
  116. package/build/resolvers/index.d.ts +5 -0
  117. package/build/resolvers/index.js +21 -0
  118. package/build/resolvers/resolver.types.d.ts +8 -0
  119. package/build/resolvers/resolver.types.js +2 -0
  120. package/build/summary/create-summary.d.ts +2 -0
  121. package/build/summary/create-summary.js +24 -0
  122. package/build/summary/index.d.ts +1 -0
  123. package/build/summary/index.js +17 -0
  124. package/build/templates/naming.d.ts +11 -0
  125. package/build/templates/naming.js +30 -0
  126. package/build/templates/template-context.d.ts +6 -0
  127. package/build/templates/template-context.js +2 -0
  128. package/build/templates/template-engine.d.ts +1 -0
  129. package/build/templates/template-engine.js +10 -0
  130. package/build/templates/template-resolver.d.ts +2 -0
  131. package/build/templates/template-resolver.js +17 -0
  132. package/build/terminal/terminal-capabilities.d.ts +6 -0
  133. package/build/terminal/terminal-capabilities.js +14 -0
  134. package/docs/adr/0001-soap-cli-project-aware-generator.md +108 -0
  135. package/docs/cli/add-resource.md +127 -0
  136. package/docs/cli/add-route.md +79 -0
  137. package/docs/cli/bruno.md +58 -0
  138. package/docs/cli/create.md +73 -0
  139. package/docs/cli/index.md +92 -0
  140. package/docs/cli/interactive-mode.md +61 -0
  141. package/docs/cli/remove.md +45 -0
  142. package/docs/guides/auth.md +90 -0
  143. package/docs/guides/cqrs-events-realtime.md +100 -0
  144. package/docs/guides/index.md +24 -0
  145. package/docs/guides/quality-and-safety.md +88 -0
  146. package/docs/guides/regular-api.md +119 -0
  147. package/docs/guides/storage.md +101 -0
  148. package/docs/plans/interactive-mode-plan.md +601 -0
  149. package/package.json +44 -0
@@ -0,0 +1,79 @@
1
+ # `soap add route`
2
+
3
+ Add a route to an existing resource.
4
+
5
+ ```bash
6
+ soap add route invoice approve --method post --path approve --auth jwt --zone public
7
+ soap add route invoice approve --method post --path approve --auth jwt --policy custom:approver
8
+ soap add route invoice approve -i
9
+ soap add route -i
10
+ ```
11
+
12
+ ## Interactive Flow
13
+
14
+ ```bash
15
+ soap add route -i
16
+ ```
17
+
18
+ When arguments are omitted, interactive mode can select the resource from `.soap/registry.json` and ask for the route name.
19
+
20
+ Prompts cover:
21
+
22
+ - resource
23
+ - route name
24
+ - HTTP method
25
+ - route path
26
+ - API zone from project zones
27
+ - route auth from enabled project auth
28
+ - target: direct controller, use case, CQRS command, or CQRS query
29
+ - Bruno refresh when Bruno is enabled
30
+
31
+ CQRS command and query targets are only offered when the project architecture is `cqrs`.
32
+
33
+ ## Non-Interactive Use
34
+
35
+ Without `-i`, both resource and route name are required:
36
+
37
+ ```bash
38
+ soap add route invoice approve --method post --path approve
39
+ ```
40
+
41
+ Target options are mutually exclusive:
42
+
43
+ ```bash
44
+ --use-case approve-invoice
45
+ --command approve-invoice
46
+ --query find-invoices
47
+ ```
48
+
49
+ Use only one target option.
50
+
51
+ ## Auth Policies
52
+
53
+ Attach a policy to a protected route:
54
+
55
+ ```bash
56
+ soap add route invoice approve --method post --path approve --auth jwt --policy roles:admin,editor
57
+ soap add route invoice approve --method post --path approve --auth api-key --policy admin
58
+ soap add route invoice approve --method post --path approve --auth jwt --policy custom:approver
59
+ ```
60
+
61
+ Supported policies:
62
+
63
+ - `admin` -> `@AdminOnly('<strategy>')`
64
+ - `roles:a,b` -> `@Auth('<strategy>', { roles: ['a', 'b'] })`
65
+ - `custom:name` -> `@Auth('<strategy>', { policy: 'name' })`
66
+
67
+ Policies require route auth. `--auth none --policy ...` fails before writing files.
68
+
69
+ ## Contracts
70
+
71
+ When the project has `contracts: ["zod"]`, generated route contracts parse input through Zod schemas.
72
+
73
+ ## Bruno
74
+
75
+ Refresh Bruno after adding a route:
76
+
77
+ ```bash
78
+ soap add route invoice approve --method post --path approve --bruno
79
+ ```
@@ -0,0 +1,58 @@
1
+ # Bruno
2
+
3
+ Bruno generation is driven by `.soap/registry.json`.
4
+
5
+ Enable Bruno at project creation:
6
+
7
+ ```bash
8
+ soap create users-api --api-client bruno --skip-install
9
+ ```
10
+
11
+ Enable it later:
12
+
13
+ ```bash
14
+ soap update config --add-api-client bruno
15
+ soap generate bruno
16
+ ```
17
+
18
+ ## Interactive Generation
19
+
20
+ ```bash
21
+ soap generate bruno -i
22
+ ```
23
+
24
+ Interactive mode analyzes the current collection before writing:
25
+
26
+ - detected routes
27
+ - existing Bruno files
28
+ - missing Bruno files
29
+ - modified generated Bruno files
30
+
31
+ Then choose:
32
+
33
+ - generate missing only
34
+ - regenerate all unmodified generated files
35
+ - generate E2E flow
36
+ - abort
37
+
38
+ Manual `.bru` edits are detected from the registry hash and are skipped unless you use `--force`.
39
+
40
+ ## E2E Flow
41
+
42
+ ```bash
43
+ soap generate bruno --e2e
44
+ soap generate bruno -i
45
+ ```
46
+
47
+ E2E files are generated for resources with complete CRUD routes.
48
+
49
+ ## Overwrite Behavior
50
+
51
+ ```bash
52
+ soap generate bruno --force
53
+ soap generate bruno --write-new
54
+ soap generate bruno --on-conflict skip
55
+ ```
56
+
57
+ Default behavior skips modified generated files.
58
+
@@ -0,0 +1,73 @@
1
+ # `soap create`
2
+
3
+ Create a new SoapJS project.
4
+
5
+ Generated projects require Node.js `>=24.17.0` (Node 24 LTS or newer).
6
+ The generator writes `.nvmrc` with `24.17.0` so `nvm use` selects the supported runtime.
7
+
8
+ ```bash
9
+ soap create users-api --skip-install
10
+ soap create users-api --install
11
+ soap create users-api --git-init --skip-install
12
+ soap create users-api -i
13
+ soap create users-api --preset express-postgres-api --skip-install
14
+ soap create users-api --db mysql --db sqlite --skip-install
15
+ ```
16
+
17
+ ## Interactive Flow
18
+
19
+ ```bash
20
+ soap create users-api -i
21
+ ```
22
+
23
+ Prompts cover the supported MVP capabilities:
24
+
25
+ - framework
26
+ - architecture
27
+ - databases
28
+ - auth
29
+ - messaging
30
+ - realtime
31
+ - telemetry
32
+ - OpenAPI docs
33
+ - contracts
34
+ - Bruno API client
35
+ - API zones
36
+ - package manager
37
+ - dependency install intent
38
+ - git init intent
39
+
40
+ Before writing files, interactive mode prints a project summary and asks for confirmation.
41
+
42
+ Use `--yes` to skip the final confirmation:
43
+
44
+ ```bash
45
+ soap create users-api -i --yes
46
+ ```
47
+
48
+ ## Presets
49
+
50
+ Available presets:
51
+
52
+ - `express-mongo-api`
53
+ - `express-postgres-api`
54
+ - `express-cqrs-kafka-api`
55
+ - `express-full-demo`
56
+
57
+ Examples:
58
+
59
+ ```bash
60
+ soap create users-api --preset express-mongo-api --skip-install
61
+ soap create users-api -i --preset express-full-demo
62
+ ```
63
+
64
+ In interactive mode, preset values become prompt defaults. Explicit CLI flags still override prompt answers and preset defaults.
65
+
66
+ ## Notes
67
+
68
+ - Only `express` is currently supported.
69
+ - `--contracts zod` enables generated contracts backed by Zod.
70
+ - Database capabilities include `mongo`, `postgres`, `mysql`, `sqlite`, and `redis`. Resource repositories are generated for Mongo and SQL adapters; Redis is infrastructure-only for now.
71
+ - `--install` runs the selected package manager after files are written. `--skip-install` always skips installation.
72
+ - `--git-init` runs `git init` after files are written. It does not commit or push.
73
+ - `--dry-run` prints the planned file count and planned writes.
@@ -0,0 +1,92 @@
1
+ # SoapJS CLI Reference
2
+
3
+ This reference lists the main CLI commands and links to task-focused docs.
4
+
5
+ ## Project Creation
6
+
7
+ - [`soap create`](create.md) creates a new SoapJS service.
8
+ - Use `--install` to install dependencies after generation.
9
+ - Use `--git-init` to initialize a local git repository. The CLI does not commit or push.
10
+ - Use `-i` for guided creation.
11
+
12
+ ```bash
13
+ soap create users-api --db postgres --auth jwt --docs openapi --api-client bruno --install
14
+ soap create users-api -i
15
+ ```
16
+
17
+ ## Add Code
18
+
19
+ - [`soap add resource`](add-resource.md) adds a resource, optional CRUD routes, storage, contracts, tests, and Bruno requests.
20
+ - [`soap add route`](add-route.md) adds a custom route to an existing resource.
21
+
22
+ ```bash
23
+ soap add resource invoice --crud --db postgres --auth jwt --zone private
24
+ soap add route invoice approve --method post --path :id/approve --auth jwt --policy custom:approver
25
+ ```
26
+
27
+ Additional component commands:
28
+
29
+ ```bash
30
+ soap add entity invoice --feature invoice
31
+ soap add use-case approve-invoice --feature invoice
32
+ soap add repository invoice --feature invoice --db postgres
33
+ soap add command approve-invoice --feature invoice
34
+ soap add query find-invoices --feature invoice
35
+ soap add event invoice-approved --feature invoice
36
+ soap add socket invoice-updates --feature invoice --auth jwt
37
+ ```
38
+
39
+ ## Generate API Artifacts
40
+
41
+ - [`soap generate bruno`](bruno.md) refreshes Bruno API requests from the route registry.
42
+ - `soap generate openapi` fetches the running app OpenAPI spec.
43
+
44
+ ```bash
45
+ soap generate bruno
46
+ soap generate bruno --e2e
47
+ soap generate openapi --output openapi.json
48
+ ```
49
+
50
+ ## Update Project Capabilities
51
+
52
+ `soap update config` adds infrastructure after project creation.
53
+
54
+ ```bash
55
+ soap update config --add-db mysql
56
+ soap update config --add-auth api-key
57
+ soap update config --add-docs openapi
58
+ soap update config --add-contracts zod
59
+ soap update config --add-api-client bruno
60
+ soap update config --add-realtime ws
61
+ ```
62
+
63
+ Updates are add-only. They do not remove existing capabilities.
64
+
65
+ ## Validate And Inspect
66
+
67
+ ```bash
68
+ soap info
69
+ soap doctor
70
+ soap check routes
71
+ ```
72
+
73
+ - `info` prints project metadata.
74
+ - `doctor` validates the local `.soap` project structure.
75
+ - `check routes` validates route registry consistency, auth, zones, contracts, and Bruno files.
76
+
77
+ ## Remove Generated Code
78
+
79
+ - [`soap remove`](remove.md) safely removes generated routes or resources tracked in `.soap/registry.json`.
80
+
81
+ ```bash
82
+ soap remove route invoice create
83
+ soap remove resource invoice
84
+ soap remove resource invoice -i
85
+ ```
86
+
87
+ ## Interactive Mode
88
+
89
+ See [`interactive-mode.md`](interactive-mode.md).
90
+
91
+ Interactive mode resolves inputs only. It uses the same deterministic planners and file writer as flag-based commands.
92
+
@@ -0,0 +1,61 @@
1
+ # Interactive Mode
2
+
3
+ Interactive mode is a guided input layer for the same deterministic generators used by the flag-based CLI.
4
+
5
+ Use `-i` or `--interactive` on supported commands:
6
+
7
+ ```bash
8
+ soap create users-api -i
9
+ soap add resource invoice -i
10
+ soap add route invoice approve -i
11
+ soap generate bruno -i
12
+ soap remove route invoice approve -i
13
+ soap remove resource invoice -i
14
+ ```
15
+
16
+ Interactive mode requires a TTY. In CI and scripts, use explicit flags instead.
17
+
18
+ ## Supported Commands
19
+
20
+ - `soap create <name> -i`
21
+ - `soap add resource <name> -i`
22
+ - `soap add route [resource] [name] -i`
23
+ - `soap generate bruno -i`
24
+ - `soap remove route <resource> <route> -i`
25
+ - `soap remove resource <resource> -i`
26
+
27
+ ## When To Use It
28
+
29
+ Use interactive mode when exploring project capabilities or when adding resources manually during local development. Use explicit flags in scripts, CI, project templates, and documentation examples that should be reproducible.
30
+
31
+ The scenario guides can be followed either with flags or with `-i`:
32
+
33
+ - [Regular CRUD API](../guides/regular-api.md)
34
+ - [CQRS, events, Kafka, and WebSockets](../guides/cqrs-events-realtime.md)
35
+ - [Auth and route policies](../guides/auth.md)
36
+ - [Storage capabilities](../guides/storage.md)
37
+ - [Quality, tests, and safe changes](../guides/quality-and-safety.md)
38
+
39
+ ## Safety Rules
40
+
41
+ - Prompts only resolve command options; planners and writers stay deterministic.
42
+ - The CLI reads `.soap` before project-aware prompts.
43
+ - Interactive choices are limited to capabilities enabled in `.soap/project.json`.
44
+ - Modified generated files are not overwritten or deleted unless you use `--force` or `--on-conflict overwrite`.
45
+ - `--yes` skips final confirmation prompts where supported.
46
+ - `--dry-run` prints planned writes/deletes without changing files.
47
+
48
+ ## Conflict Policy
49
+
50
+ Most write commands support:
51
+
52
+ ```bash
53
+ --on-conflict skip
54
+ --on-conflict overwrite
55
+ --on-conflict new
56
+ --on-conflict abort
57
+ ```
58
+
59
+ `ask` is reserved by the shared policy but per-file interactive conflict resolution is not implemented yet.
60
+
61
+ Remove commands do not support `new`, because deletion cannot be written as a `.new` file.
@@ -0,0 +1,45 @@
1
+ # `soap remove`
2
+
3
+ Safely remove generated routes and resources.
4
+
5
+ ```bash
6
+ soap remove route invoice create
7
+ soap remove resource invoice
8
+ ```
9
+
10
+ Remove commands only delete files tracked in `.soap/registry.json`.
11
+
12
+ ## Interactive Flow
13
+
14
+ ```bash
15
+ soap remove route invoice create -i
16
+ soap remove resource invoice -i
17
+ ```
18
+
19
+ Interactive mode shows a preview before deletion:
20
+
21
+ - tracked files to delete
22
+ - modified tracked files
23
+ - registry entries to remove
24
+
25
+ Then it asks for confirmation.
26
+
27
+ Use `--yes` to skip confirmation:
28
+
29
+ ```bash
30
+ soap remove route invoice create -i --yes
31
+ ```
32
+
33
+ ## Modified Files
34
+
35
+ Modified generated files are not deleted by default.
36
+
37
+ Use `--force` or `--on-conflict overwrite` to delete modified generated files:
38
+
39
+ ```bash
40
+ soap remove route invoice create --force
41
+ soap remove resource invoice --on-conflict overwrite
42
+ ```
43
+
44
+ `--dry-run` prints planned deletes and registry updates without changing files.
45
+
@@ -0,0 +1,90 @@
1
+ # Guide: Auth And Route Policies
2
+
3
+ SoapJS CLI supports project-level auth capabilities and route-level policies.
4
+
5
+ ## Enable Auth
6
+
7
+ At project creation:
8
+
9
+ ```bash
10
+ soap create secure-api --auth jwt --auth api-key --skip-install
11
+ ```
12
+
13
+ After project creation:
14
+
15
+ ```bash
16
+ soap update config --add-auth jwt
17
+ soap update config --add-auth api-key
18
+ ```
19
+
20
+ Supported auth capabilities:
21
+
22
+ - `jwt`
23
+ - `api-key`
24
+ - `local`
25
+
26
+ For routes, `local` is normalized to `jwt`.
27
+
28
+ ## Add Protected CRUD Routes
29
+
30
+ ```bash
31
+ soap add resource report --crud --auth jwt --zone private
32
+ ```
33
+
34
+ Admin zone:
35
+
36
+ ```bash
37
+ soap add resource audit-log --crud --auth jwt --zone admin
38
+ ```
39
+
40
+ Public route:
41
+
42
+ ```bash
43
+ soap add route report summary --method get --path summary --auth none --zone public
44
+ ```
45
+
46
+ ## Add Policies
47
+
48
+ Policies require route auth.
49
+
50
+ ```bash
51
+ soap add route report approve --method post --path approve --auth jwt --policy roles:admin,editor
52
+ soap add route report purge --method delete --path purge --auth api-key --policy admin
53
+ soap add route report export --method post --path export --auth jwt --policy custom:report-exporter
54
+ ```
55
+
56
+ Generated decorators:
57
+
58
+ - `admin` -> `@AdminOnly('<strategy>')`
59
+ - `roles:a,b` -> `@Auth('<strategy>', { roles: ['a', 'b'] })`
60
+ - `custom:name` -> `@Auth('<strategy>', { policy: 'name' })`
61
+
62
+ Invalid:
63
+
64
+ ```bash
65
+ soap add route report approve --auth none --policy admin
66
+ ```
67
+
68
+ The CLI fails before writing files because policies require auth.
69
+
70
+ ## CRUD Route Matrix Policies
71
+
72
+ Use matrix policies when each CRUD operation needs different auth.
73
+
74
+ ```bash
75
+ soap add resource report --crud \
76
+ --crud-route list:get:/search:jwt:private:roles=admin,editor:bruno \
77
+ --crud-route create:post:/submit:api-key:private:custom=report-writer:bruno \
78
+ --crud-route delete:delete:/:id:jwt:admin:admin:no-bruno
79
+ ```
80
+
81
+ Matrix policy syntax uses `roles=...` and `custom=...` because `:` separates matrix fields.
82
+
83
+ ## Validate Auth Metadata
84
+
85
+ ```bash
86
+ soap check routes
87
+ ```
88
+
89
+ This checks unknown auth strategies, disabled auth capabilities, invalid zones, policy-without-auth, contracts, and Bruno files.
90
+
@@ -0,0 +1,100 @@
1
+ # Guide: CQRS, Events, Kafka, And WebSockets
2
+
3
+ Use this path when the service should be event-oriented or needs WebSocket handlers.
4
+
5
+ ## Create A CQRS Project
6
+
7
+ ```bash
8
+ soap create operations-api \
9
+ --architecture cqrs \
10
+ --messaging kafka \
11
+ --realtime ws \
12
+ --auth jwt \
13
+ --api-client bruno \
14
+ --install
15
+ ```
16
+
17
+ Interactive equivalent:
18
+
19
+ ```bash
20
+ soap create operations-api -i
21
+ ```
22
+
23
+ In interactive mode, select:
24
+
25
+ - architecture: `cqrs`
26
+ - messaging: `kafka`
27
+ - realtime: `ws`
28
+ - auth as needed
29
+ - API client as needed
30
+
31
+ Kafka support uses Redpanda in generated Docker Compose.
32
+
33
+ ## Add A CQRS CRUD Resource
34
+
35
+ ```bash
36
+ soap add resource shipment \
37
+ --crud \
38
+ --auth jwt \
39
+ --zone private \
40
+ --field trackingNumber:string \
41
+ --field status:string
42
+ ```
43
+
44
+ CQRS CRUD generation creates:
45
+
46
+ - commands for create/update/delete
47
+ - queries for get/list
48
+ - command/query handlers
49
+ - handler specs
50
+ - route controllers that dispatch through command/query buses
51
+ - entity and in-memory repository specs
52
+
53
+ ## Add Commands And Queries Directly
54
+
55
+ ```bash
56
+ soap add command dispatch-shipment --feature shipment
57
+ soap add query find-shipments --feature shipment
58
+ ```
59
+
60
+ These commands require a CQRS project.
61
+
62
+ ## Add Domain Events
63
+
64
+ ```bash
65
+ soap add event shipment-dispatched --feature shipment
66
+ ```
67
+
68
+ In CQRS projects, the CLI also generates an event handler placeholder under the feature API layer.
69
+
70
+ ## Add WebSocket Handlers
71
+
72
+ ```bash
73
+ soap add socket shipment-updates --feature shipment --auth jwt
74
+ ```
75
+
76
+ WebSocket support must be enabled first:
77
+
78
+ ```bash
79
+ soap update config --add-realtime ws
80
+ ```
81
+
82
+ The socket command updates `src/config/sockets.ts` and adds a handler under the feature.
83
+
84
+ ## Run With Docker Services
85
+
86
+ ```bash
87
+ make up
88
+ make logs
89
+ make down
90
+ ```
91
+
92
+ Generated Docker Compose includes the API and Redpanda when Kafka is enabled.
93
+
94
+ ## Validate
95
+
96
+ ```bash
97
+ npm test
98
+ soap check routes
99
+ ```
100
+
@@ -0,0 +1,24 @@
1
+ # SoapJS CLI Developer Guides
2
+
3
+ Use these guides when building a service with SoapJS CLI.
4
+
5
+ SoapJS CLI and generated projects require Node.js `>=24.17.0` (Node 24 LTS or newer).
6
+ Generated projects include `.nvmrc` with `24.17.0`.
7
+
8
+ ## Start Here
9
+
10
+ - [Regular CRUD API](regular-api.md): create a standard Express CRUD API with storage, auth, contracts, tests, Bruno, and OpenAPI.
11
+ - [CQRS, events, Kafka, and WebSockets](cqrs-events-realtime.md): create a CQRS/event-oriented service and add realtime handlers.
12
+
13
+ ## Capability Guides
14
+
15
+ - [Auth and route policies](auth.md): JWT, API key, local auth, admin/roles/custom route policies.
16
+ - [Storage capabilities](storage.md): Mongo, Postgres, MySQL, SQLite, Redis, Docker, and environment variables.
17
+
18
+ ## Operations
19
+
20
+ - [Quality, tests, and safe changes](quality-and-safety.md): generated tests, validation commands, dry-runs, conflict policies, remove safety, install, and git init.
21
+
22
+ ## Command Reference
23
+
24
+ See [CLI reference](../cli/index.md) for command-level docs.
@@ -0,0 +1,88 @@
1
+ # Guide: Quality, Tests, And Safe Changes
2
+
3
+ SoapJS CLI is registry-aware. Generated files are tracked in `.soap/registry.json` with hashes so later commands can avoid overwriting user edits.
4
+
5
+ ## Generated Tests
6
+
7
+ CRUD resource generation creates compiling Node test files.
8
+
9
+ Regular CRUD resources generate:
10
+
11
+ - entity spec
12
+ - in-memory repository CRUD spec
13
+ - use-case specs for list/get/create/update/delete
14
+
15
+ CQRS CRUD resources generate:
16
+
17
+ - command handler specs
18
+ - query handler specs
19
+ - entity spec
20
+ - in-memory repository CRUD spec
21
+
22
+ Run tests:
23
+
24
+ ```bash
25
+ npm test
26
+ ```
27
+
28
+ The generated `test` script builds first, then runs compiled `.spec.js` and `.test.js` files with `node --test`.
29
+
30
+ ## Validation Commands
31
+
32
+ ```bash
33
+ soap info
34
+ soap doctor
35
+ soap check routes
36
+ ```
37
+
38
+ Use these commands after changing capabilities, adding routes, or removing generated code.
39
+
40
+ ## Dry Runs
41
+
42
+ Use `--dry-run` before risky writes or deletes.
43
+
44
+ ```bash
45
+ soap add resource invoice --crud --dry-run
46
+ soap remove resource invoice --dry-run
47
+ soap update config --add-db mysql --dry-run
48
+ ```
49
+
50
+ ## Conflict Policies
51
+
52
+ Generated files are safe by default:
53
+
54
+ - unchanged generated files can be updated
55
+ - modified generated files are skipped
56
+ - `--force` overwrites or deletes modified generated files
57
+ - `--write-new` writes a `.new` file where supported
58
+ - `--on-conflict abort` fails on the first conflict
59
+
60
+ Examples:
61
+
62
+ ```bash
63
+ soap generate bruno --write-new
64
+ soap remove resource invoice --force
65
+ soap add resource invoice --crud --on-conflict abort
66
+ ```
67
+
68
+ ## Remove Generated Code
69
+
70
+ ```bash
71
+ soap remove route invoice create
72
+ soap remove resource invoice
73
+ soap remove resource invoice -i
74
+ ```
75
+
76
+ Remove only touches files tracked in the registry. If a generated file was modified, it is skipped unless you explicitly force deletion.
77
+
78
+ ## Git And Install
79
+
80
+ Dependency installation and Git initialization are explicit.
81
+
82
+ ```bash
83
+ soap create users-api --install
84
+ soap create users-api --git-init --skip-install
85
+ ```
86
+
87
+ `--git-init` only runs `git init`. It does not commit or push.
88
+