go-duck-cli 1.1.12 β†’ 1.1.14

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 CHANGED
@@ -74,6 +74,14 @@ GO-DUCK has officially reached the **375% Achievement Status**, evolving from a
74
74
  * **SaaS Quota Engine**: Redis-backed API bandwidth tracking with dynamic, hierarchical limits (User vs. Role mapping).
75
75
  * **Resilience Layer**: Sony/Gobreaker Integration + Zero-Trust Distributed Redis Rate Limiter.
76
76
 
77
+ ### πŸ—ΊοΈ System Topology & Identity Registry
78
+
79
+ To prevent ID enumeration attacks and completely hide internal database names and structure, GO-DUCK implements a zero-trust **Triple-Identity Registry** (Role ↔ DB ↔ Opaque UUID):
80
+
81
+ <p align="center">
82
+ <img src="https://goduck.theheavenscode.com/triple_identity_registry.png" alt="Triple-Identity Registry Topology" width="800"/>
83
+ </p>
84
+
77
85
  ## πŸ’Ύ Global Installation
78
86
 
79
87
  To get started with GO-DUCK CLI, install it globally via npm:
@@ -99,9 +107,42 @@ Follow these steps to create and run a new microservice with GO-DUCK:
99
107
  # 1. Create a new microservice
100
108
  go-duck create -o ./my-app -c config.yaml
101
109
 
102
- # 2. Enter the application directory and run
110
+ # 2. Enter the application directory
103
111
  cd my-app
112
+ ```
113
+
114
+ ### πŸ—οΈ Compiling Protobuf & gRPC Contracts
115
+
116
+ Before running the microservice, compile the protobuf contract files using the scaffolded scripts:
117
+
118
+ #### Prerequisites
119
+ 1. Ensure the `protoc` compiler is installed and added to your system's `PATH`.
120
+ 2. Install the necessary Go compiler plugins:
121
+ ```cmd
122
+ go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
123
+ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
124
+ ```
125
+
126
+ #### Compilation
127
+ Execute the script corresponding to your operating system in the root of the generated microservice directory:
128
+
129
+ * **Windows CMD / PowerShell**:
130
+ ```cmd
131
+ .\generate.bat
132
+ ```
133
+ * **Linux / macOS / Git Bash / WSL**:
134
+ ```bash
135
+ chmod +x generate.sh
136
+ ./generate.sh
137
+ ```
138
+
139
+ Once compiled, launch the dependencies and start the application:
140
+
141
+ ```bash
142
+ # 3. Spin up dependent services
104
143
  docker-compose up -d
144
+
145
+ # 4. Run the Go application
105
146
  go run main.go
106
147
  ```
107
148
 
@@ -149,44 +190,118 @@ go-duck import-gdl new-entities.gdl -o my-existing-app
149
190
 
150
191
  ## GoDuck Definition Language (GDL)
151
192
 
152
- GDL is a simple language for defining your application's entities, fields, and relationships.
193
+ GDL is a clean DSL for defining your application's entities, enums, fields, nested document structures, relationships, and public/auth boundaries.
153
194
 
154
195
  **Example (`app.gdl`):**
155
196
 
156
197
  ```gdl
157
- entity Author {
158
- name String required
159
- email String unique
198
+ // ==============================================================================
199
+ // πŸ¦† GO-DUCK ELITE DEALERSHIP BLUEPRINT
200
+ // ==============================================================================
201
+
202
+ /**
203
+ * Car: Relational Entity stored in PostgreSQL.
204
+ * @Searchable: Enable Spring-style fuzzy search on make/model.
205
+ * @Federated: Synchronize history across all dealership siloes.
206
+ * @Audited: Track every modification with Zero-Trust Keycloak IDs.
207
+ */
208
+ @Searchable @Federated @Audited
209
+ entity Car {
210
+ string(100) make required
211
+ string(100) model required
212
+ int(32) year required
213
+ bigdecimal price
214
+ string(50) vin unique
215
+ jsonb metadata
160
216
  }
161
217
 
162
- entity Book {
163
- title String required
164
- publishedDate LocalDate
218
+ /**
219
+ * Patient: MongoDB Document Entity.
220
+ * @Document: Stored in MongoDB instead of PostgreSQL.
221
+ */
222
+ @Document
223
+ entity Patient {
224
+ string name required
225
+ clinicalData {
226
+ vitals {
227
+ int bpm
228
+ float temp
229
+ }
230
+ history [String]
231
+ }
165
232
  }
166
233
 
234
+ /**
235
+ * ArticleStatus: Native Enum Support.
236
+ * GO-DUCK generates Go Enums, GraphQL Enums, and Proto definitions.
237
+ */
238
+ enum ArticleStatus {
239
+ DRAFT, PUBLISHED, ARCHIVED
240
+ }
241
+
242
+ // πŸ¦† RELATIONSHIPS: Build the Graph
167
243
  relationship OneToMany {
168
- Author{books} to Book{author}
244
+ Customer{car} to Car{owner}
169
245
  }
246
+
247
+ // πŸ¦† SECURITY: Define Public/Auth Access
248
+ open Car(read)
170
249
  ```
171
250
 
172
251
  ## Configuration (`config.yaml`)
173
252
 
174
- The `config.yaml` file contains the configuration for your generated application.
253
+ The `config.yaml` file configures the scaffolding engine and generated Go bootstrap files. It must start with the top-level `go-duck` block.
175
254
 
176
255
  ```yaml
177
- app:
178
- name: my-app
256
+ go-duck:
257
+ name: "my-app"
258
+ version: "1.0.0"
259
+ description: "GO-DUCK Scaffolded Microservice"
260
+
261
+ # --- Network & Server Layer ---
262
+ server:
263
+ port: 8080
264
+ grpc:
265
+ addr: ":9000"
266
+ network: "tcp"
267
+ timeout: "1s"
268
+ cors:
269
+ allow-origins: ["*"]
270
+ allow-methods: ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"]
271
+ allow-headers: ["Origin", "Content-Type", "Accept", "Authorization", "X-Tenant-ID"]
272
+
273
+ # --- Persistence Layer (Hybrid Store) ---
179
274
  datasource:
180
- host: localhost
275
+ # PostgreSQL (Relational Registry & Entity Store)
276
+ host: "localhost"
181
277
  port: 5432
182
- username: user
183
- password: password
184
- database: my_app_db
278
+ username: "postgres"
279
+ password: "password"
280
+ database: "my_app_db"
281
+ ssl-mode: "disable"
282
+ # MongoDB (Document Entity Store)
283
+ mongodb:
284
+ enabled: true
285
+ uri: "mongodb://localhost:27017"
286
+ database: "my_app_mongo"
287
+
288
+ # --- Security & Identity (Keycloak/OIDC) ---
289
+ security:
290
+ keycloak-host: "http://localhost:8080"
291
+ keycloak-realm: "my-realm"
292
+ keycloak-app-client-id: "my-app"
293
+ keycloak-service-client-id: "my-service"
294
+ keycloak-service-secret: "service-secret-123"
295
+ super-admin-role: "admin"
296
+ confidential-mode: true
297
+ rate-limit:
298
+ rps: 100
299
+ burst: 200
300
+
301
+ # --- Federated Multi-Tenancy ---
185
302
  multitenancy:
186
303
  enabled: true
187
- security:
188
- jwt:
189
- secret: "your-jwt-secret"
304
+ hide-silo-names: false
190
305
  ```
191
306
 
192
307
  ## License
@@ -213,9 +213,29 @@ find api -name "*.proto" -exec protoc --proto_path=. \\
213
213
  {} +
214
214
 
215
215
  echo "βœ… Protos compiled successfully!"
216
+ `;
217
+ const generateBat = `@echo off
218
+ echo πŸ¦† Syncing Protobuf Dependencies...
219
+ if not exist "third_party\\google\\api" mkdir "third_party\\google\\api"
220
+ curl -sSL https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/annotations.proto > third_party\\google\\api\\annotations.proto
221
+ curl -sSL https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/http.proto > third_party\\google\\api\\http.proto
222
+
223
+ echo πŸ—οΈ Compiling API Layer...
224
+ where protoc >nul 2>nul
225
+ if %errorlevel% neq 0 (
226
+ echo ❌ Error: 'protoc' not found. Please install protobuf and add it to your PATH.
227
+ exit /b 1
228
+ )
229
+
230
+ for /f "tokens=*" %%f in ('dir /b /s api\\*.proto') do (
231
+ protoc --proto_path=. --proto_path=./api --proto_path=./third_party --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. "%%f"
232
+ )
233
+
234
+ echo βœ… Protos compiled successfully!
216
235
  `;
217
236
  await fs.writeFile(path.join(projectRootDir, 'generate.sh'), generateSh);
218
237
  await fs.chmod(path.join(projectRootDir, 'generate.sh'), 0o755);
238
+ await fs.writeFile(path.join(projectRootDir, 'generate.bat'), generateBat);
219
239
 
220
240
  console.log(chalk.green('βœ… Kratos gRPC code generated successfully!'));
221
241
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "go-duck-cli",
3
- "version": "1.1.12",
3
+ "version": "1.1.14",
4
4
  "description": "The Ultimate Evolutionary Go Microservice Scaffolder.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -45,6 +45,51 @@ service {{capitalize (defaultStr (lookup entities "0.name") "Entity")}}Service {
45
45
  </div>
46
46
  </section>
47
47
 
48
+ <!-- Compiling Protobuf Contracts -->
49
+ <section class="mb-20">
50
+ <h2 class="text-3xl font-black text-slate-900 mb-6 tracking-tight italic underline decoration-blue-200 underline-offset-8">Compiling Protobuf & gRPC Contracts</h2>
51
+ <p class="text-lg text-slate-600 mb-8 leading-relaxed">
52
+ GO-DUCK scaffolds script files in the root of the generated project to manage the compilation of <code>.proto</code> contracts natively on all operating systems.
53
+ </p>
54
+
55
+ <div class="bg-white border border-slate-200 rounded-3xl p-8 shadow-sm mb-8">
56
+ <h3 class="text-xl font-bold text-slate-800 mb-4 flex items-center">
57
+ πŸ› οΈ Scaffolded Compiler Scripts
58
+ </h3>
59
+ <p class="text-slate-600 mb-4">The generator scaffolds both <code>generate.sh</code> and <code>generate.bat</code> files in the project root. At compilation time, they perform the following tasks:</p>
60
+ <ul class="list-disc pl-6 space-y-2 text-slate-600 mb-6">
61
+ <li>Create the <code>third_party/google/api</code> dependencies directory.</li>
62
+ <li>Synchronize necessary Google API annotation contracts (<code>annotations.proto</code> and <code>http.proto</code>) using native command line transfers.</li>
63
+ <li>Recursively find and compile all <code>.proto</code> files inside <code>api/</code> into Go source files using the <code>protoc</code> compiler.</li>
64
+ </ul>
65
+
66
+ <h3 class="text-xl font-bold text-slate-800 mb-4 flex items-center">
67
+ πŸš€ How to Compile
68
+ </h3>
69
+ <p class="text-slate-600 mb-4">To compile the contract schemas into Go source structures, execute the following commands in the root of your generated application:</p>
70
+
71
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
72
+ <div class="p-6 bg-slate-50 rounded-2xl border border-slate-200">
73
+ <span class="text-xs font-black text-blue-600 uppercase tracking-widest block mb-2">Windows (CMD / PowerShell)</span>
74
+ <pre class="bg-slate-900 text-slate-100 p-4 rounded-xl text-xs font-mono">.\generate.bat</pre>
75
+ </div>
76
+ <div class="p-6 bg-slate-50 rounded-2xl border border-slate-200">
77
+ <span class="text-xs font-black text-emerald-600 uppercase tracking-widest block mb-2">Unix / Linux / macOS</span>
78
+ <pre class="bg-slate-900 text-slate-100 p-4 rounded-xl text-xs font-mono">chmod +x generate.sh<br>./generate.sh</pre>
79
+ </div>
80
+ </div>
81
+
82
+ <div class="mt-8 p-6 bg-blue-50 rounded-2xl border border-blue-100">
83
+ <h4 class="font-bold text-blue-900 mb-2">πŸ“Œ Compilation Prerequisites</h4>
84
+ <p class="text-blue-800 text-sm leading-relaxed mb-4">
85
+ Ensure you have the <code>protoc</code> binary installed and added to your system's <code>PATH</code>.
86
+ </p>
87
+ <p class="text-blue-800 text-sm leading-relaxed mb-2">Also ensure the necessary Go compiler plugins are installed on your environment:</p>
88
+ <pre class="bg-slate-900 text-slate-100 p-4 rounded-xl text-xs font-mono">go install google.golang.org/protobuf/cmd/protoc-gen-go@latest<br>go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest</pre>
89
+ </div>
90
+ </div>
91
+ </section>
92
+
48
93
  <!-- Silo-Aware Repository Wrapper -->
49
94
  <section class="mb-20">
50
95
  <div class="bg-gradient-to-r from-blue-950 to-blue-900 border border-blue-800/50 rounded-[2.5rem] p-16 text-white text-center shadow-2xl relative overflow-hidden group">