go-duck-cli 1.2.11 → 1.3.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/README.md +79 -0
- package/generators/ai_docs.js +22 -8
- package/generators/config.js +16 -8
- package/generators/devops.js +591 -1
- package/generators/postman.js +156 -6
- package/generators/security.js +2 -2
- package/go-duck-planner/css/bootstrap.min.css +6 -0
- package/go-duck-planner/css/main.css +1 -0
- package/go-duck-planner/favicon.ico +0 -0
- package/go-duck-planner/fonts/icomoonf33b-2.html +0 -0
- package/go-duck-planner/fonts/icomoonf33b-3.html +0 -0
- package/go-duck-planner/fonts/icomoonf33b-4.html +0 -0
- package/go-duck-planner/fonts/icomoonf33b.html +0 -0
- package/go-duck-planner/fonts/open-sans/OpenSans-Bold.html +0 -0
- package/go-duck-planner/fonts/open-sans/OpenSans-ExtraBold.html +0 -0
- package/go-duck-planner/fonts/open-sans/OpenSans-Light.html +0 -0
- package/go-duck-planner/fonts/open-sans/OpenSans-Regular.html +0 -0
- package/go-duck-planner/fonts/open-sans/OpenSans-SemiBold.html +0 -0
- package/go-duck-planner/fonts/rubik-mono/RubikMonoOne-Regular.html +0 -0
- package/go-duck-planner/fonts/style.css +2735 -0
- package/go-duck-planner/img/cancel.html +0 -0
- package/go-duck-planner/img/consulting.html +0 -0
- package/go-duck-planner/img/consulting2.html +0 -0
- package/go-duck-planner/img/dashed-circles-dark.html +0 -0
- package/go-duck-planner/img/docs/doc.html +0 -0
- package/go-duck-planner/img/docs/pdf.html +0 -0
- package/go-duck-planner/img/docs/ppt.html +0 -0
- package/go-duck-planner/img/docs/xls.html +0 -0
- package/go-duck-planner/img/docs/zip.html +0 -0
- package/go-duck-planner/img/empty-chat-display.html +0 -0
- package/go-duck-planner/img/error-screen/stars.html +0 -0
- package/go-duck-planner/img/fav.png +0 -0
- package/go-duck-planner/img/flags/1x1/au.html +0 -0
- package/go-duck-planner/img/flags/1x1/br.html +0 -0
- package/go-duck-planner/img/flags/1x1/bv.html +131 -0
- package/go-duck-planner/img/flags/1x1/ca.html +0 -0
- package/go-duck-planner/img/flags/1x1/cw.html +131 -0
- package/go-duck-planner/img/flags/1x1/eu.html +131 -0
- package/go-duck-planner/img/flags/1x1/hn.html +131 -0
- package/go-duck-planner/img/flags/1x1/in.html +0 -0
- package/go-duck-planner/img/flags/1x1/ni.html +131 -0
- package/go-duck-planner/img/flags/1x1/se.html +131 -0
- package/go-duck-planner/img/flags/1x1/za.html +131 -0
- package/go-duck-planner/img/folder.html +0 -0
- package/go-duck-planner/img/followers.html +0 -0
- package/go-duck-planner/img/food/biscuit.html +0 -0
- package/go-duck-planner/img/food/cupcake.html +0 -0
- package/go-duck-planner/img/food/donut.html +0 -0
- package/go-duck-planner/img/food/ice-cream.html +0 -0
- package/go-duck-planner/img/food/pizza.html +0 -0
- package/go-duck-planner/img/food/tea-cup.html +0 -0
- package/go-duck-planner/img/hover-on-tabs.html +0 -0
- package/go-duck-planner/img/icon-search.html +0 -0
- package/go-duck-planner/img/lines-bg.html +0 -0
- package/go-duck-planner/img/lines-bg2.html +0 -0
- package/go-duck-planner/img/login-bg.html +0 -0
- package/go-duck-planner/img/logo-compact.html +0 -0
- package/go-duck-planner/img/logo-large.html +0 -0
- package/go-duck-planner/img/logo.png +0 -0
- package/go-duck-planner/img/logo.svg +19 -0
- package/go-duck-planner/img/pattern.html +0 -0
- package/go-duck-planner/img/products/bag.html +0 -0
- package/go-duck-planner/img/products/camera.html +0 -0
- package/go-duck-planner/img/products/clock.html +0 -0
- package/go-duck-planner/img/products/drone.html +0 -0
- package/go-duck-planner/img/products/pencils.html +0 -0
- package/go-duck-planner/img/products/ring.html +0 -0
- package/go-duck-planner/img/products/shirt.html +0 -0
- package/go-duck-planner/img/products/shoes.html +0 -0
- package/go-duck-planner/img/products/toy.html +0 -0
- package/go-duck-planner/img/realestate/img1.html +0 -0
- package/go-duck-planner/img/realestate/img10.html +0 -0
- package/go-duck-planner/img/realestate/img11.html +0 -0
- package/go-duck-planner/img/realestate/img12.html +0 -0
- package/go-duck-planner/img/realestate/img2.html +0 -0
- package/go-duck-planner/img/realestate/img3.html +0 -0
- package/go-duck-planner/img/realestate/img4.html +0 -0
- package/go-duck-planner/img/realestate/img5.html +0 -0
- package/go-duck-planner/img/realestate/img6.html +0 -0
- package/go-duck-planner/img/realestate/img7.html +0 -0
- package/go-duck-planner/img/realestate/img8.html +0 -0
- package/go-duck-planner/img/realestate/img9.html +0 -0
- package/go-duck-planner/img/shade.html +0 -0
- package/go-duck-planner/img/stock/img1.html +0 -0
- package/go-duck-planner/img/stock/img10.html +0 -0
- package/go-duck-planner/img/stock/img11.html +0 -0
- package/go-duck-planner/img/stock/img12.html +0 -0
- package/go-duck-planner/img/stock/img13.html +0 -0
- package/go-duck-planner/img/stock/img14.html +0 -0
- package/go-duck-planner/img/stock/img2.html +0 -0
- package/go-duck-planner/img/stock/img3.html +0 -0
- package/go-duck-planner/img/stock/img4.html +0 -0
- package/go-duck-planner/img/stock/img5.html +0 -0
- package/go-duck-planner/img/stock/img6.html +0 -0
- package/go-duck-planner/img/stock/img7.html +0 -0
- package/go-duck-planner/img/stock/img8.html +0 -0
- package/go-duck-planner/img/stock/img9.html +0 -0
- package/go-duck-planner/img/svg/box.html +0 -0
- package/go-duck-planner/img/svg/commisions.html +0 -0
- package/go-duck-planner/img/svg/customer.html +0 -0
- package/go-duck-planner/img/svg/income.html +0 -0
- package/go-duck-planner/img/trophy.html +0 -0
- package/go-duck-planner/img/user-2.html +0 -0
- package/go-duck-planner/img/user.html +0 -0
- package/go-duck-planner/img/user1.html +0 -0
- package/go-duck-planner/img/user10.html +0 -0
- package/go-duck-planner/img/user12.html +0 -0
- package/go-duck-planner/img/user13.html +0 -0
- package/go-duck-planner/img/user14.html +0 -0
- package/go-duck-planner/img/user15.html +0 -0
- package/go-duck-planner/img/user16.html +0 -0
- package/go-duck-planner/img/user17.html +0 -0
- package/go-duck-planner/img/user18.html +0 -0
- package/go-duck-planner/img/user19.html +0 -0
- package/go-duck-planner/img/user2.html +0 -0
- package/go-duck-planner/img/user20.html +0 -0
- package/go-duck-planner/img/user21.html +0 -0
- package/go-duck-planner/img/user22.html +0 -0
- package/go-duck-planner/img/user23.html +0 -0
- package/go-duck-planner/img/user24.html +0 -0
- package/go-duck-planner/img/user3.html +0 -0
- package/go-duck-planner/img/user4.html +0 -0
- package/go-duck-planner/img/user5.html +0 -0
- package/go-duck-planner/img/user6.html +0 -0
- package/go-duck-planner/img/user7.html +0 -0
- package/go-duck-planner/img/user8.html +0 -0
- package/go-duck-planner/img/user9.html +0 -0
- package/go-duck-planner/index.html +30 -0
- package/go-duck-planner/js/bootstrap.bundle.min.html +0 -0
- package/go-duck-planner/js/jquery.min.html +0 -0
- package/go-duck-planner/js/main.html +0 -0
- package/go-duck-planner/js/modernizr.html +0 -0
- package/go-duck-planner/js/moment.html +0 -0
- package/go-duck-planner/main-HHOZYGRI.js +47 -0
- package/go-duck-planner/styles-3LK4NBNX.css +1 -0
- package/go-duck-planner/vendor/apex/apexcharts.min.html +0 -0
- package/go-duck-planner/vendor/apex/custom/analytics/byChannelGraph.html +0 -0
- package/go-duck-planner/vendor/apex/custom/analytics/byCountryGraph.html +0 -0
- package/go-duck-planner/vendor/apex/custom/analytics/byDeviceGraph.html +0 -0
- package/go-duck-planner/vendor/apex/custom/analytics/ordersGraph.html +0 -0
- package/go-duck-planner/vendor/apex/custom/analytics/targets.html +0 -0
- package/go-duck-planner/vendor/apex/custom/crm/sales.html +0 -0
- package/go-duck-planner/vendor/apex/custom/crm/sparkline-graphs.html +0 -0
- package/go-duck-planner/vendor/apex/custom/home/customersGraph.html +0 -0
- package/go-duck-planner/vendor/apex/custom/home/earningsGraph.html +0 -0
- package/go-duck-planner/vendor/apex/custom/home/ordersGraph.html +0 -0
- package/go-duck-planner/vendor/apex/custom/home/salesGraph.html +0 -0
- package/go-duck-planner/vendor/apex/custom/home/sparkline.html +0 -0
- package/go-duck-planner/vendor/apex/custom/home/visitorsGraph.html +0 -0
- package/go-duck-planner/vendor/apex/custom/profile/revenue.html +0 -0
- package/go-duck-planner/vendor/apex/custom/reports/orders.html +0 -0
- package/go-duck-planner/vendor/apex/custom/reports/revenue.html +0 -0
- package/go-duck-planner/vendor/apex/custom/reports/sales.html +0 -0
- package/go-duck-planner/vendor/apex/custom/reports/sales2.html +0 -0
- package/go-duck-planner/vendor/apex/custom/reports/sparkline.html +0 -0
- package/go-duck-planner/vendor/apex/custom/saas/revenue.html +0 -0
- package/go-duck-planner/vendor/apex/custom/saas/sales.html +0 -0
- package/go-duck-planner/vendor/apex/custom/sales/revenue.html +0 -0
- package/go-duck-planner/vendor/apex/custom/sales/tickets.html +0 -0
- package/go-duck-planner/vendor/bs-select/bs-select-custom.html +0 -0
- package/go-duck-planner/vendor/bs-select/bs-select.html +0 -0
- package/go-duck-planner/vendor/bs-select/bs-select.min.html +0 -0
- package/go-duck-planner/vendor/calendar/css/custom.html +0 -0
- package/go-duck-planner/vendor/calendar/css/main.min.html +0 -0
- package/go-duck-planner/vendor/calendar/custom/custom-schedule-calendar.html +0 -0
- package/go-duck-planner/vendor/calendar/custom/daygrid-calendar.html +0 -0
- package/go-duck-planner/vendor/calendar/custom/draggable-calendar.html +0 -0
- package/go-duck-planner/vendor/calendar/custom/google-view-calendar.html +0 -0
- package/go-duck-planner/vendor/calendar/custom/list-view-calendar.html +0 -0
- package/go-duck-planner/vendor/calendar/custom/selectable-calendar.html +0 -0
- package/go-duck-planner/vendor/calendar/js/main.min.html +0 -0
- package/go-duck-planner/vendor/circliful/circliful.custom.html +0 -0
- package/go-duck-planner/vendor/circliful/circliful.min.html +0 -0
- package/go-duck-planner/vendor/datatables/buttons.bs.html +0 -0
- package/go-duck-planner/vendor/datatables/buttons.min.html +0 -0
- package/go-duck-planner/vendor/datatables/buttons.print.min.html +0 -0
- package/go-duck-planner/vendor/datatables/custom/custom-datatables.html +0 -0
- package/go-duck-planner/vendor/datatables/dataTables.bootstrap.min.html +0 -0
- package/go-duck-planner/vendor/datatables/dataTables.bs4-custom.html +0 -0
- package/go-duck-planner/vendor/datatables/dataTables.bs4.html +0 -0
- package/go-duck-planner/vendor/datatables/dataTables.min.html +0 -0
- package/go-duck-planner/vendor/datatables/html5.min.html +0 -0
- package/go-duck-planner/vendor/datatables/jszip.min.html +0 -0
- package/go-duck-planner/vendor/datatables/pdfmake.min.html +0 -0
- package/go-duck-planner/vendor/datatables/vfs_fonts.html +0 -0
- package/go-duck-planner/vendor/daterange/custom-daterange.html +0 -0
- package/go-duck-planner/vendor/daterange/daterange-2.html +0 -0
- package/go-duck-planner/vendor/daterange/daterange.html +0 -0
- package/go-duck-planner/vendor/dropzone/dropzone.min-2.html +0 -0
- package/go-duck-planner/vendor/dropzone/dropzone.min.html +0 -0
- package/go-duck-planner/vendor/gallery/baguetteBox.html +0 -0
- package/go-duck-planner/vendor/gallery/custom-gallery.html +0 -0
- package/go-duck-planner/vendor/gallery/gallery.html +0 -0
- package/go-duck-planner/vendor/gallery/plugins.html +0 -0
- package/go-duck-planner/vendor/input-tags/tagsinput-custom.html +0 -0
- package/go-duck-planner/vendor/input-tags/tagsinput.html +0 -0
- package/go-duck-planner/vendor/input-tags/tagsinput.min.html +0 -0
- package/go-duck-planner/vendor/input-tags/typeahead.html +0 -0
- package/go-duck-planner/vendor/megamenu/css/megamenu.css +591 -0
- package/go-duck-planner/vendor/megamenu/js/custom.html +0 -0
- package/go-duck-planner/vendor/megamenu/js/megamenu.html +0 -0
- package/go-duck-planner/vendor/rating/raty-custom.html +0 -0
- package/go-duck-planner/vendor/rating/raty.html +0 -0
- package/go-duck-planner/vendor/search-filter/custom-search-filter.css +122 -0
- package/go-duck-planner/vendor/search-filter/custom-search-filter.html +0 -0
- package/go-duck-planner/vendor/search-filter/search-filter.css +497 -0
- package/go-duck-planner/vendor/search-filter/search-filter.html +0 -0
- package/go-duck-planner/vendor/slimscroll/custom-scrollbar.html +0 -0
- package/go-duck-planner/vendor/slimscroll/slimscroll.min.html +0 -0
- package/go-duck-planner/vendor/summernote/summernote-bs4-2.html +0 -0
- package/go-duck-planner/vendor/summernote/summernote-bs4.html +0 -0
- package/go-duck-planner/vendor/wizard/jquery.steps.custom.html +0 -0
- package/go-duck-planner/vendor/wizard/jquery.steps.html +0 -0
- package/go-duck-planner/vendor/wizard/jquery.steps.min.html +0 -0
- package/index.js +98 -9
- package/package.json +1 -1
- package/parser/gdl.js +2 -0
- package/templates/docs/index.html.hbs +13 -1
- package/templates/docs/pages/cli.hbs +20 -4
- package/templates/docs/pages/gdl-annotations.hbs +17 -0
- package/templates/docs/pages/rest.hbs +21 -0
- package/templates/go/controller.go.hbs +107 -20
- package/templates/go/main.go.hbs +16 -2
- package/templates/go/router.go.hbs +8 -3
- package/templates/kratos/service.go.hbs +25 -2
- package/templates/proto/entity.proto.hbs +1 -0
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
<p align="center">
|
|
14
14
|
<a href="https://badge.fury.io/js/go-duck-cli"><img src="https://badge.fury.io/js/go-duck-cli.svg" alt="npm version"></a>
|
|
15
15
|
<a href="https://opensource.org/licenses/ISC"><img src="https://img.shields.io/badge/License-ISC-blue.svg" alt="License: ISC"></a>
|
|
16
|
+

|
|
16
17
|
</p>
|
|
17
18
|
|
|
18
19
|
---
|
|
@@ -64,6 +65,8 @@ GO-DUCK has officially reached the **410% Achievement Status**, evolving from a
|
|
|
64
65
|
### ✨ Primary Features (The 410% Core)
|
|
65
66
|
|
|
66
67
|
* **Federated Multi-Tenancy**: Side-by-side **Database-per-Tenant isolation** with a **Master-Tenant Registry** (Role ↔ DB ↔ Opaque UUID).
|
|
68
|
+
* **Multi-Protocol REST**: Dynamically switchable REST rendering using standard `json` or high-performance `messagepack` based on configuration.
|
|
69
|
+
* **gRPC-Web Native Proxy**: Natively wraps Kratos gRPC to automatically serve a web proxy (e.g. on port `9090`) to allow direct frontend Protobuf interaction.
|
|
67
70
|
* **Industrial-Grade Parallel Harvester**: Asynchronous goroutine-based data aggregation across multiple silos with `?federated=true` opt-in.
|
|
68
71
|
* **Precision Harvesting**: Surgical multi-silo selection via comma-separated `X-Tenant-ID` headers.
|
|
69
72
|
* **Super Admin Security Boundaries**: Strict architectural separation between Business APIs and Infrastructure Control APIs.
|
|
@@ -104,16 +107,61 @@ Ensure your development environment meets the following requirements:
|
|
|
104
107
|
* **Docker:** v20+
|
|
105
108
|
* **Composability:** v2+
|
|
106
109
|
|
|
110
|
+
## Quick‑Start
|
|
111
|
+
|
|
112
|
+
Follow these four steps to get a generated microservice running locally and in Kubernetes:
|
|
113
|
+
|
|
114
|
+
1. **Create**: `go-duck create -o ./my-app -c config.yaml`
|
|
115
|
+
2. **Enter**: `cd my-app`
|
|
116
|
+
3. **Build & Push**: `./push.sh my-registry/my-app:1.0.0`
|
|
117
|
+
4. **Deploy**: `kubectl apply -f devops/k8s/`
|
|
118
|
+
|
|
107
119
|
## 🚀 Scaffold & Run
|
|
108
120
|
|
|
109
121
|
Follow these steps to create and run a new microservice with GO-DUCK:
|
|
110
122
|
|
|
123
|
+
```bash
|
|
124
|
+
# 0. Design your schema visually (Optional)
|
|
125
|
+
go-duck gdl-planner -p 8000
|
|
126
|
+
```
|
|
127
|
+
This launches a browser-based drag-and-drop canvas at `http://localhost:8000` where you can visually design your entities, relationships, nested BSON objects, and Enums, and then export it directly into a `.gdl` file!
|
|
128
|
+
|
|
111
129
|
```bash
|
|
112
130
|
# 1. Create a new microservice
|
|
113
131
|
go-duck create -o ./my-app -c config.yaml
|
|
114
132
|
|
|
115
133
|
# 2. Enter the application directory
|
|
116
134
|
cd my-app
|
|
135
|
+
|
|
136
|
+
# 3. Build, tag, and push Docker image (updates app.yaml)
|
|
137
|
+
./push.sh my-registry/my-app:1.0.0
|
|
138
|
+
|
|
139
|
+
# 4. Deploy to Kubernetes
|
|
140
|
+
kubectl apply -f devops/k8s/
|
|
141
|
+
|
|
142
|
+
### 🚢 Deploy to Kubernetes & Push Images
|
|
143
|
+
|
|
144
|
+
The generated project includes a **devops/k8s** directory with ready‑to‑apply Kubernetes manifests:
|
|
145
|
+
|
|
146
|
+
- `mongo.yaml` – StatefulSet & Service for MongoDB.
|
|
147
|
+
- `minio.yaml` – Deployment & Service for MinIO object storage.
|
|
148
|
+
- `app.yaml` – Deployment for the generated Go microservice, referencing a placeholder image name (`<app‑name>:latest`). Replace the image with the tag you push.
|
|
149
|
+
|
|
150
|
+
A helper script **push.sh** (located at the project root) automates the Docker build, tag, push, and then updates the `app.yaml` image field:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
./push.sh my-registry/my-app:1.0.0
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
After pushing, deploy everything with:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
kubectl apply -f devops/k8s/
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
> [!NOTE]
|
|
163
|
+
> The K8s manifests use placeholder values (e.g., resource limits, storage class). Adjust them to match your cluster requirements before applying.
|
|
164
|
+
|
|
117
165
|
```
|
|
118
166
|
|
|
119
167
|
### 🏗️ Compiling Protobuf & gRPC Contracts
|
|
@@ -156,6 +204,37 @@ docker-compose up -d
|
|
|
156
204
|
go run main.go
|
|
157
205
|
```
|
|
158
206
|
|
|
207
|
+
## 🌐 Calling the Multi-Protocol Endpoints
|
|
208
|
+
|
|
209
|
+
GO-DUCK automatically exposes your microservice across three distinct ports to serve different architectural needs without code duplication:
|
|
210
|
+
|
|
211
|
+
1. **REST API (Port 8080 by default)**
|
|
212
|
+
Standard HTTP endpoints for web browsers and legacy clients.
|
|
213
|
+
- **JSON (Default):** Perfect for general use.
|
|
214
|
+
- **MessagePack (High Performance):** To switch to binary MessagePack, update your `config.yaml` before generation:
|
|
215
|
+
```yaml
|
|
216
|
+
server:
|
|
217
|
+
rest:
|
|
218
|
+
port: 8080
|
|
219
|
+
protocol: "messagepack"
|
|
220
|
+
```
|
|
221
|
+
Clients must send the `Accept: application/msgpack` and `Content-Type: application/msgpack` headers to consume this endpoint correctly.
|
|
222
|
+
- **Pagination & Sorting:** All `GetAll` endpoints support pagination via `?page=1&size=20`, and dynamic sorting via `?sort=field,asc` or `?sort=field,desc` (e.g. `?sort=name,desc`).
|
|
223
|
+
|
|
224
|
+
2. **Native Kratos gRPC (Port 9000 by default)**
|
|
225
|
+
Pure HTTP/2 Protobuf communication. Used strictly for internal **backend-to-backend** communication (e.g., Microservice A calling Microservice B) where maximum throughput is required.
|
|
226
|
+
|
|
227
|
+
3. **gRPC-Web Proxy (Port 9090 by default)**
|
|
228
|
+
Web browsers cannot speak raw HTTP/2 gRPC. This port acts as an HTTP/1.1 proxy bridge, allowing frontend frameworks (React, Angular, Vue) to interact directly with the Protobuf gRPC contracts.
|
|
229
|
+
To disable or change the proxy port, update your `config.yaml`:
|
|
230
|
+
```yaml
|
|
231
|
+
server:
|
|
232
|
+
grpc:
|
|
233
|
+
web_enabled: true
|
|
234
|
+
web_port: 9090
|
|
235
|
+
```
|
|
236
|
+
*Frontend Tip: Use the `grpc-web` npm package to generate a frontend client that communicates with this port!*
|
|
237
|
+
|
|
159
238
|
## Usage
|
|
160
239
|
|
|
161
240
|
The `go-duck-cli` has two main commands: `create` and `import-gdl`.
|
package/generators/ai_docs.js
CHANGED
|
@@ -52,7 +52,7 @@ export const generateAIDocs = async (config, entities, outputDir, enums, openEnt
|
|
|
52
52
|
for (const entity of entities) {
|
|
53
53
|
const routeName = entity.name.toLowerCase() + 's';
|
|
54
54
|
endpointsContent += `\n#### ${entity.name}\n`;
|
|
55
|
-
endpointsContent += `- \`GET /api/${routeName}\` (Pagination, e.g. \`?page=1&size=10&eager=true\`)\n`;
|
|
55
|
+
endpointsContent += `- \`GET /api/${routeName}\` (Pagination & dynamic sorting, e.g. \`?page=1&size=10&eager=true&sort=id,asc\`)\n`;
|
|
56
56
|
endpointsContent += `- \`GET /api/${routeName}/:id\`\n`;
|
|
57
57
|
endpointsContent += `- \`POST /api/${routeName}\`\n`;
|
|
58
58
|
endpointsContent += `- \`PUT /api/${routeName}/:id\`\n`;
|
|
@@ -88,6 +88,7 @@ export const generateAIDocs = async (config, entities, outputDir, enums, openEnt
|
|
|
88
88
|
if (entity.isSearchable) entitiesContent += `- \`@Searchable\`\n`;
|
|
89
89
|
if (entity.isAudited) entitiesContent += `- \`@Audited\`\n`;
|
|
90
90
|
if (entity.isFederated) entitiesContent += `- \`@Federated\`\n`;
|
|
91
|
+
if (entity.isDelete) entitiesContent += `- \`@Delete\`\n`;
|
|
91
92
|
|
|
92
93
|
entitiesContent += `\nFields:\n`;
|
|
93
94
|
for (const field of entity.fields) {
|
|
@@ -101,16 +102,20 @@ export const generateAIDocs = async (config, entities, outputDir, enums, openEnt
|
|
|
101
102
|
// 4. PROTOCOLS.md
|
|
102
103
|
let protoContent = `# Additional Network Protocols\n\n`;
|
|
103
104
|
protoContent += `## GraphQL Surface\n`;
|
|
104
|
-
protoContent += `- **Endpoint**: \`POST /
|
|
105
|
-
protoContent += `- **Playground**:
|
|
105
|
+
protoContent += `- **Endpoint**: \`POST /graphql\` (Secured via JWT and Tenant headers)\n`;
|
|
106
|
+
protoContent += `- **Playground**: GraphQL Playground UI is enabled on the server.\n`;
|
|
107
|
+
protoContent += `- **Queries**: \`list[Entity]s(page: Int, size: Int)\`, \`get[Entity](id: ID!)\`\n`;
|
|
108
|
+
protoContent += `- **Mutations**: \`create[Entity](input: CreateInput)\`, \`update[Entity](id: ID!, input: UpdateInput)\`, \`delete[Entity](id: ID!)\`\n`;
|
|
109
|
+
protoContent += `- **Postman Collection Integration**: The auto-generated Postman collection includes a comprehensive **GraphQL Federation Layer** folder containing test queries and mutations for all entities.\n\n`;
|
|
106
110
|
|
|
107
111
|
protoContent += `## WebSocket Engine\n`;
|
|
108
|
-
protoContent += `- **Endpoint**: \`ws[s]://host/ws\`\n`;
|
|
109
|
-
protoContent += `- **Format**: JSON Envelope Payload \`{ "type": "...", "payload": {...} }\`\n\n`;
|
|
112
|
+
protoContent += `- **Endpoint**: \`ws[s]://host/ws?token={JWT}\`\n`;
|
|
113
|
+
protoContent += `- **Format**: JSON Envelope Payload with HMAC-SHA256 digital signature: \`{ "type": "...", "payload": {...} }\`\n\n`;
|
|
110
114
|
|
|
111
|
-
protoContent += `## gRPC
|
|
112
|
-
protoContent += `- **Port**: \`9000\` (
|
|
113
|
-
protoContent += `- **
|
|
115
|
+
protoContent += `## gRPC & gRPC-Web Engine\n`;
|
|
116
|
+
protoContent += `- **Native Kratos gRPC Port**: \`9000\` (TCP)\n`;
|
|
117
|
+
protoContent += `- **gRPC-Web Proxy Port**: \`9090\` (HTTP/1.1 for web clients)\n`;
|
|
118
|
+
protoContent += `- **Proto Definitions**: Located in \`api/v1/*.proto\`\n`;
|
|
114
119
|
|
|
115
120
|
await fs.writeFile(path.join(aiDocsDir, 'PROTOCOLS.md'), protoContent);
|
|
116
121
|
|
|
@@ -118,6 +123,15 @@ export const generateAIDocs = async (config, entities, outputDir, enums, openEnt
|
|
|
118
123
|
let agentInstructions = `# LLM / AI AGENT INSTRUCTIONS 🤖\n\n`;
|
|
119
124
|
agentInstructions += `Welcome to the generated codebase for **${appName}**.\n\n`;
|
|
120
125
|
agentInstructions += `This application was generated by the GO-DUCK-CLI (An advanced Evolutionary Go Code Generator).\n\n`;
|
|
126
|
+
agentInstructions += `### High-Velocity Commands:\n`;
|
|
127
|
+
agentInstructions += `- **Build Project**: \`go build ./...\`\n`;
|
|
128
|
+
agentInstructions += `- **Protobuf Compilation**: \`./generate.sh\` (or \`.\\generate.bat\` on Windows)\n`;
|
|
129
|
+
agentInstructions += `- **Local Dependencies & Dev Boot**: \`docker-compose up -d && go run main.go\`\n`;
|
|
130
|
+
agentInstructions += `- **Docker Build & Push**: \`./push.sh\` (Builds and pushes the Docker image to registry)\n\n`;
|
|
131
|
+
agentInstructions += `### GDL Evolution & Schema Deletions:\n`;
|
|
132
|
+
agentInstructions += `- **Snapshot Merging (Multi-File GDL)**: The generator implements stateful snapshot merging. Running \`import-gdl\` on a single GDL file will NOT wipe out other entities; previous snapshots are retrieved from the \`.go-duck/\` state folder and merged automatically.\n`;
|
|
133
|
+
agentInstructions += `- **Altering/Dropping Fields**: To add, drop, or edit fields within an entity, update the fields inline in the GDL entity block. Running \`import-gdl\` generates targeted Goose SQL column-level migrations.\n`;
|
|
134
|
+
agentInstructions += `- **Dropping Entities**: To completely delete an entity, its database table, all generated code files, and its snapshot, append the \`@Delete\` annotation above the entity definition block and run \`import-gdl\`.\n\n`;
|
|
121
135
|
agentInstructions += `### How to navigate this system:\n`;
|
|
122
136
|
agentInstructions += `The full system specifications and dynamically generated blueprints have been exported for you in the \`docs/ai/\` folder. Look there before attempting any code modifications.\n\n`;
|
|
123
137
|
agentInstructions += `- **[docs/ai/ARCHITECTURE.md](docs/ai/ARCHITECTURE.md)**: Describes the databases, caching layers, configuration structure, and middleware enabled in this project.\n`;
|
package/generators/config.js
CHANGED
|
@@ -2,7 +2,7 @@ import fs from 'fs-extra';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
|
|
5
|
-
export const generateConfigLoader = async (outputDir) => {
|
|
5
|
+
export const generateConfigLoader = async (outputDir, configObj) => {
|
|
6
6
|
const configDir = path.join(outputDir, 'config');
|
|
7
7
|
await fs.ensureDir(configDir);
|
|
8
8
|
|
|
@@ -25,13 +25,17 @@ type Config struct {
|
|
|
25
25
|
Description string \`mapstructure:"description"\`
|
|
26
26
|
|
|
27
27
|
Server struct {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
REST struct {
|
|
29
|
+
Port int \`mapstructure:"port"\`
|
|
30
|
+
Protocol string \`mapstructure:"protocol"\`
|
|
31
|
+
ApiPathPrefix string \`mapstructure:"api-path-prefix"\`
|
|
32
|
+
} \`mapstructure:"rest"\`
|
|
31
33
|
GRPC struct {
|
|
32
|
-
Addr
|
|
33
|
-
Network
|
|
34
|
-
Timeout
|
|
34
|
+
Addr string \`mapstructure:"addr"\`
|
|
35
|
+
Network string \`mapstructure:"network"\`
|
|
36
|
+
Timeout time.Duration \`mapstructure:"timeout"\`
|
|
37
|
+
WebEnabled bool \`mapstructure:"web_enabled"\`
|
|
38
|
+
WebPort int \`mapstructure:"web_port"\`
|
|
35
39
|
} \`mapstructure:"grpc"\`
|
|
36
40
|
CORS struct {
|
|
37
41
|
AllowOrigins []string \`mapstructure:"allow-origins"\`
|
|
@@ -237,7 +241,9 @@ func LoadConfig() (*Config, error) {
|
|
|
237
241
|
v.AddConfigPath(".")
|
|
238
242
|
|
|
239
243
|
// Default values
|
|
240
|
-
v.SetDefault("go-duck.server.port", 8080)
|
|
244
|
+
v.SetDefault("go-duck.server.rest.port", 8080)
|
|
245
|
+
v.SetDefault("go-duck.server.rest.protocol", "json")
|
|
246
|
+
v.SetDefault("go-duck.server.rest.api-path-prefix", "/${configObj.name || 'api'}/api")
|
|
241
247
|
v.SetDefault("go-duck.security.rate-limit.rps", 100.0)
|
|
242
248
|
v.SetDefault("go-duck.security.rate-limit.burst", 200)
|
|
243
249
|
v.SetDefault("go-duck.logging.datadog.enabled", false)
|
|
@@ -254,6 +260,8 @@ func LoadConfig() (*Config, error) {
|
|
|
254
260
|
v.SetDefault("go-duck.server.grpc.addr", ":9000")
|
|
255
261
|
v.SetDefault("go-duck.server.grpc.network", "tcp")
|
|
256
262
|
v.SetDefault("go-duck.server.grpc.timeout", "1s")
|
|
263
|
+
v.SetDefault("go-duck.server.grpc.web_enabled", false)
|
|
264
|
+
v.SetDefault("go-duck.server.grpc.web_port", 9090)
|
|
257
265
|
v.SetDefault("go-duck.resilience.circuit-breaker.enabled", true)
|
|
258
266
|
v.SetDefault("go-duck.resilience.circuit-breaker.failure-threshold", 5)
|
|
259
267
|
v.SetDefault("go-duck.resilience.circuit-breaker.timeout", "60s")
|