@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.
- package/.nvmrc +1 -0
- package/LICENSE +21 -0
- package/README.md +360 -0
- package/build/cli.d.ts +3 -0
- package/build/cli.js +50 -0
- package/build/commands/add/add.command.d.ts +2 -0
- package/build/commands/add/add.command.js +709 -0
- package/build/commands/add/command-plan.d.ts +15 -0
- package/build/commands/add/command-plan.js +182 -0
- package/build/commands/add/entity-plan.d.ts +7 -0
- package/build/commands/add/entity-plan.js +106 -0
- package/build/commands/add/event-plan.d.ts +8 -0
- package/build/commands/add/event-plan.js +59 -0
- package/build/commands/add/query-plan.d.ts +10 -0
- package/build/commands/add/query-plan.js +156 -0
- package/build/commands/add/repository-plan.d.ts +11 -0
- package/build/commands/add/repository-plan.js +252 -0
- package/build/commands/add/resource-plan.d.ts +52 -0
- package/build/commands/add/resource-plan.js +2031 -0
- package/build/commands/add/route-plan.d.ts +24 -0
- package/build/commands/add/route-plan.js +256 -0
- package/build/commands/add/socket-plan.d.ts +9 -0
- package/build/commands/add/socket-plan.js +81 -0
- package/build/commands/add/use-case-plan.d.ts +7 -0
- package/build/commands/add/use-case-plan.js +86 -0
- package/build/commands/check/check.command.d.ts +2 -0
- package/build/commands/check/check.command.js +113 -0
- package/build/commands/create/create.command.d.ts +2 -0
- package/build/commands/create/create.command.js +234 -0
- package/build/commands/create/project-plan.d.ts +44 -0
- package/build/commands/create/project-plan.js +1430 -0
- package/build/commands/doctor/doctor.command.d.ts +2 -0
- package/build/commands/doctor/doctor.command.js +38 -0
- package/build/commands/generate/bruno-analysis.d.ts +19 -0
- package/build/commands/generate/bruno-analysis.js +51 -0
- package/build/commands/generate/bruno-plan.d.ts +6 -0
- package/build/commands/generate/bruno-plan.js +326 -0
- package/build/commands/generate/generate.command.d.ts +2 -0
- package/build/commands/generate/generate.command.js +130 -0
- package/build/commands/info/info.command.d.ts +2 -0
- package/build/commands/info/info.command.js +26 -0
- package/build/commands/remove/remove.command.d.ts +2 -0
- package/build/commands/remove/remove.command.js +328 -0
- package/build/commands/shared/common-options.d.ts +10 -0
- package/build/commands/shared/common-options.js +23 -0
- package/build/commands/update/update.command.d.ts +2 -0
- package/build/commands/update/update.command.js +155 -0
- package/build/config/auth-policy.d.ts +4 -0
- package/build/config/auth-policy.js +54 -0
- package/build/config/find-soap-root.d.ts +1 -0
- package/build/config/find-soap-root.js +22 -0
- package/build/config/load-soap-config.d.ts +2 -0
- package/build/config/load-soap-config.js +30 -0
- package/build/config/schemas/types.d.ts +127 -0
- package/build/config/schemas/types.js +2 -0
- package/build/config/schemas/validation.d.ts +5 -0
- package/build/config/schemas/validation.js +130 -0
- package/build/config/soap-config.service.d.ts +4 -0
- package/build/config/soap-config.service.js +24 -0
- package/build/config/write-soap-config.d.ts +8 -0
- package/build/config/write-soap-config.js +25 -0
- package/build/core/command-context.d.ts +20 -0
- package/build/core/command-context.js +30 -0
- package/build/core/errors.d.ts +6 -0
- package/build/core/errors.js +23 -0
- package/build/core/output.d.ts +12 -0
- package/build/core/output.js +30 -0
- package/build/core/result.d.ts +9 -0
- package/build/core/result.js +11 -0
- package/build/dependencies/dependency-resolver.d.ts +6 -0
- package/build/dependencies/dependency-resolver.js +68 -0
- package/build/dependencies/package-manager.d.ts +7 -0
- package/build/dependencies/package-manager.js +54 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +9 -0
- package/build/io/conflict-policy.d.ts +10 -0
- package/build/io/conflict-policy.js +32 -0
- package/build/io/file-writer.d.ts +19 -0
- package/build/io/file-writer.js +65 -0
- package/build/io/format-file.d.ts +1 -0
- package/build/io/format-file.js +13 -0
- package/build/presets/create-presets.d.ts +4 -0
- package/build/presets/create-presets.js +97 -0
- package/build/presets/index.d.ts +2 -0
- package/build/presets/index.js +18 -0
- package/build/presets/preset.types.d.ts +6 -0
- package/build/presets/preset.types.js +2 -0
- package/build/prompts/add-resource.prompt.d.ts +13 -0
- package/build/prompts/add-resource.prompt.js +80 -0
- package/build/prompts/add-route.prompt.d.ts +16 -0
- package/build/prompts/add-route.prompt.js +140 -0
- package/build/prompts/create-project.prompt.d.ts +11 -0
- package/build/prompts/create-project.prompt.js +156 -0
- package/build/prompts/generate-bruno.prompt.d.ts +7 -0
- package/build/prompts/generate-bruno.prompt.js +21 -0
- package/build/prompts/index.d.ts +8 -0
- package/build/prompts/index.js +24 -0
- package/build/prompts/inquirer-prompt-adapter.d.ts +8 -0
- package/build/prompts/inquirer-prompt-adapter.js +52 -0
- package/build/prompts/mock-prompt-adapter.d.ts +13 -0
- package/build/prompts/mock-prompt-adapter.js +60 -0
- package/build/prompts/prompt-adapter.d.ts +7 -0
- package/build/prompts/prompt-adapter.js +2 -0
- package/build/prompts/prompt.types.d.ts +26 -0
- package/build/prompts/prompt.types.js +2 -0
- package/build/registry/registry.service.d.ts +19 -0
- package/build/registry/registry.service.js +68 -0
- package/build/resolvers/add-resource.resolver.d.ts +23 -0
- package/build/resolvers/add-resource.resolver.js +73 -0
- package/build/resolvers/add-route.resolver.d.ts +34 -0
- package/build/resolvers/add-route.resolver.js +83 -0
- package/build/resolvers/create-config.resolver.d.ts +32 -0
- package/build/resolvers/create-config.resolver.js +57 -0
- package/build/resolvers/generate-bruno.resolver.d.ts +17 -0
- package/build/resolvers/generate-bruno.resolver.js +23 -0
- package/build/resolvers/index.d.ts +5 -0
- package/build/resolvers/index.js +21 -0
- package/build/resolvers/resolver.types.d.ts +8 -0
- package/build/resolvers/resolver.types.js +2 -0
- package/build/summary/create-summary.d.ts +2 -0
- package/build/summary/create-summary.js +24 -0
- package/build/summary/index.d.ts +1 -0
- package/build/summary/index.js +17 -0
- package/build/templates/naming.d.ts +11 -0
- package/build/templates/naming.js +30 -0
- package/build/templates/template-context.d.ts +6 -0
- package/build/templates/template-context.js +2 -0
- package/build/templates/template-engine.d.ts +1 -0
- package/build/templates/template-engine.js +10 -0
- package/build/templates/template-resolver.d.ts +2 -0
- package/build/templates/template-resolver.js +17 -0
- package/build/terminal/terminal-capabilities.d.ts +6 -0
- package/build/terminal/terminal-capabilities.js +14 -0
- package/docs/adr/0001-soap-cli-project-aware-generator.md +108 -0
- package/docs/cli/add-resource.md +127 -0
- package/docs/cli/add-route.md +79 -0
- package/docs/cli/bruno.md +58 -0
- package/docs/cli/create.md +73 -0
- package/docs/cli/index.md +92 -0
- package/docs/cli/interactive-mode.md +61 -0
- package/docs/cli/remove.md +45 -0
- package/docs/guides/auth.md +90 -0
- package/docs/guides/cqrs-events-realtime.md +100 -0
- package/docs/guides/index.md +24 -0
- package/docs/guides/quality-and-safety.md +88 -0
- package/docs/guides/regular-api.md +119 -0
- package/docs/guides/storage.md +101 -0
- package/docs/plans/interactive-mode-plan.md +601 -0
- package/package.json +44 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Guide: Regular CRUD API
|
|
2
|
+
|
|
3
|
+
Use this path for a conventional Express service with generated CRUD routes, storage, route contracts, tests, Bruno, and OpenAPI.
|
|
4
|
+
|
|
5
|
+
## Create The Project
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
soap create billing-api \
|
|
9
|
+
--db postgres \
|
|
10
|
+
--auth jwt \
|
|
11
|
+
--docs openapi \
|
|
12
|
+
--contracts zod \
|
|
13
|
+
--api-client bruno \
|
|
14
|
+
--install \
|
|
15
|
+
--git-init
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Interactive equivalent:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
soap create billing-api -i
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
In interactive mode, select:
|
|
25
|
+
|
|
26
|
+
- architecture: `regular`
|
|
27
|
+
- database: `postgres`
|
|
28
|
+
- auth: `jwt`
|
|
29
|
+
- docs: `openapi`
|
|
30
|
+
- contracts: `zod`
|
|
31
|
+
- API client: `bruno`
|
|
32
|
+
- install dependencies: yes when wanted
|
|
33
|
+
- git init: yes only when you want a new local repository
|
|
34
|
+
|
|
35
|
+
## Run The Service
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
cd billing-api
|
|
39
|
+
npm run build
|
|
40
|
+
npm test
|
|
41
|
+
npm start
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Health check:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
curl http://localhost:3000/health
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Add A CRUD Resource
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
soap add resource invoice \
|
|
54
|
+
--crud \
|
|
55
|
+
--db postgres \
|
|
56
|
+
--auth jwt \
|
|
57
|
+
--zone private \
|
|
58
|
+
--field number:string \
|
|
59
|
+
--field total:number \
|
|
60
|
+
--field paid:boolean:optional \
|
|
61
|
+
--bruno
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Generated output includes:
|
|
65
|
+
|
|
66
|
+
- domain entity and entity spec
|
|
67
|
+
- repository port
|
|
68
|
+
- in-memory repository and repository spec
|
|
69
|
+
- Postgres SQL repository
|
|
70
|
+
- CRUD use-cases and use-case specs
|
|
71
|
+
- route contracts
|
|
72
|
+
- route controllers
|
|
73
|
+
- resource setup registration
|
|
74
|
+
- Bruno requests when Bruno is enabled
|
|
75
|
+
|
|
76
|
+
## Add A Custom Route
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
soap add route invoice approve \
|
|
80
|
+
--method post \
|
|
81
|
+
--path :id/approve \
|
|
82
|
+
--auth jwt \
|
|
83
|
+
--zone private \
|
|
84
|
+
--policy custom:invoice-approver \
|
|
85
|
+
--bruno
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Route paths are scoped under the resource path. The example generates `/invoices/:id/approve`.
|
|
89
|
+
|
|
90
|
+
## Validate Generated Metadata
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
soap info
|
|
94
|
+
soap doctor
|
|
95
|
+
soap check routes
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Run these after adding or removing resources/routes.
|
|
99
|
+
|
|
100
|
+
## Refresh API Artifacts
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
soap generate bruno
|
|
104
|
+
soap generate bruno --e2e
|
|
105
|
+
soap generate openapi --output openapi.json
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
`generate openapi` expects the service to be running.
|
|
109
|
+
|
|
110
|
+
## Safe Removal
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
soap remove route invoice approve
|
|
114
|
+
soap remove resource invoice --dry-run
|
|
115
|
+
soap remove resource invoice
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Modified generated files are skipped unless you use `--force` or `--on-conflict overwrite`.
|
|
119
|
+
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Guide: Storage Capabilities
|
|
2
|
+
|
|
3
|
+
Storage capabilities affect generated dependencies, config, Docker services, and resource repository templates.
|
|
4
|
+
|
|
5
|
+
## Supported Storage
|
|
6
|
+
|
|
7
|
+
| Capability | Project infra | Resource repository |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `none` | no external service | in-memory |
|
|
10
|
+
| `mongo` | Mongo client, config, Docker service | Mongo repository |
|
|
11
|
+
| `postgres` | SQL client, config, Docker service | SQL repository |
|
|
12
|
+
| `mysql` | SQL client, config, Docker service | SQL repository |
|
|
13
|
+
| `sqlite` | SQL client, local filename config | SQL repository |
|
|
14
|
+
| `redis` | Redis client/config/Docker service | infrastructure only |
|
|
15
|
+
|
|
16
|
+
Redis is currently infrastructure-only for resources. Do not pass `--db redis` to resource generation expecting a Redis repository template.
|
|
17
|
+
|
|
18
|
+
## Create With Storage
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
soap create data-api --db postgres --install
|
|
22
|
+
soap create data-api --db mysql --db sqlite --skip-install
|
|
23
|
+
soap create data-api --db mongo --db redis --skip-install
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Add Storage Later
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
soap update config --add-db postgres
|
|
30
|
+
soap update config --add-db mysql
|
|
31
|
+
soap update config --add-db sqlite
|
|
32
|
+
soap update config --add-db redis
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`update config` is add-only.
|
|
36
|
+
|
|
37
|
+
## Add Resources With Storage
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
soap add resource invoice --crud --db postgres
|
|
41
|
+
soap add resource invoice --crud --db mysql
|
|
42
|
+
soap add resource note --crud --db sqlite
|
|
43
|
+
soap add resource customer --crud --db mongo
|
|
44
|
+
soap add resource task --crud --db none
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Generated SQL repositories use the same repository template with adapter-specific config:
|
|
48
|
+
|
|
49
|
+
- PostgreSQL uses `$1`, `$2` placeholders.
|
|
50
|
+
- MySQL and SQLite use `?` placeholders.
|
|
51
|
+
|
|
52
|
+
## Environment Variables
|
|
53
|
+
|
|
54
|
+
PostgreSQL:
|
|
55
|
+
|
|
56
|
+
```txt
|
|
57
|
+
POSTGRES_HOST=localhost
|
|
58
|
+
POSTGRES_PORT=5432
|
|
59
|
+
POSTGRES_DB=app
|
|
60
|
+
POSTGRES_USER=app
|
|
61
|
+
POSTGRES_PASSWORD=app
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
MySQL:
|
|
65
|
+
|
|
66
|
+
```txt
|
|
67
|
+
MYSQL_HOST=localhost
|
|
68
|
+
MYSQL_PORT=3306
|
|
69
|
+
MYSQL_DATABASE=app
|
|
70
|
+
MYSQL_USER=app
|
|
71
|
+
MYSQL_PASSWORD=app
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
SQLite:
|
|
75
|
+
|
|
76
|
+
```txt
|
|
77
|
+
SQLITE_FILENAME=./data/app.sqlite
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Mongo:
|
|
81
|
+
|
|
82
|
+
```txt
|
|
83
|
+
MONGO_URI=mongodb://localhost:27017/app
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Redis:
|
|
87
|
+
|
|
88
|
+
```txt
|
|
89
|
+
REDIS_URL=redis://localhost:6379
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Docker
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
make up
|
|
96
|
+
make logs
|
|
97
|
+
make down
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Generated Docker Compose includes services for Mongo, Postgres, MySQL, Redis, and Kafka/Redpanda when those capabilities are enabled.
|
|
101
|
+
|