go-duck-cli 1.4.16 → 1.4.18
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/generators/swagger.js +23 -1
- package/package.json +1 -1
- package/parser/gdl.js +5 -1
- package/templates/go/router.go.hbs +24 -9
package/generators/swagger.js
CHANGED
|
@@ -121,11 +121,25 @@ export const generateSwaggerDocs = async (config, entities, outputDir, openEntit
|
|
|
121
121
|
|
|
122
122
|
regPath(`${basePath}/${name}s`, 'get', {
|
|
123
123
|
summary: `Get all ${capitalized}s`,
|
|
124
|
+
description: `Retrieves a paginated list of ${capitalized}s. Supports JPA-style dynamic scalar filtering and relationship eager-loading.`,
|
|
124
125
|
parameters: [
|
|
125
126
|
...commonHeaders,
|
|
126
127
|
{ name: 'page', in: 'query', schema: { type: 'integer' }, description: 'Zero-based page index' },
|
|
127
128
|
{ name: 'size', in: 'query', schema: { type: 'integer' }, description: 'Records per page' },
|
|
128
|
-
{ name: '
|
|
129
|
+
{ name: 'sort', in: 'query', schema: { type: 'string' }, description: 'Sort criteria (e.g., name,desc)' },
|
|
130
|
+
{ name: 'eager', in: 'query', schema: { type: 'boolean' }, description: 'If true, performs SQL Join to fetch relations' },
|
|
131
|
+
...entity.fields.map(f => ({
|
|
132
|
+
name: f.name,
|
|
133
|
+
in: 'query',
|
|
134
|
+
schema: getSwaggerFieldSchema(f.type),
|
|
135
|
+
description: `Filter exactly by ${f.name}`
|
|
136
|
+
})),
|
|
137
|
+
...entity.relationships.filter(r => r.to.entity === capitalized).map(r => ({
|
|
138
|
+
name: r.to.field + 'Id',
|
|
139
|
+
in: 'query',
|
|
140
|
+
schema: { type: 'integer' },
|
|
141
|
+
description: `Filter by foreign key ${r.to.field}Id`
|
|
142
|
+
}))
|
|
129
143
|
],
|
|
130
144
|
responses: { 200: { description: 'OK', content: { 'application/json': { schema: { type: 'array', items: { $ref: `#/components/schemas/${capitalized}` } } } } } }
|
|
131
145
|
}, 'read');
|
|
@@ -143,12 +157,20 @@ export const generateSwaggerDocs = async (config, entities, outputDir, openEntit
|
|
|
143
157
|
regPath(`${basePath}/${name}s/{id}`, 'put', {
|
|
144
158
|
summary: `Update ${capitalized}`,
|
|
145
159
|
parameters: [...commonHeaders, { name: 'id', in: 'path', required: true, schema: { type: 'integer' } }],
|
|
160
|
+
requestBody: {
|
|
161
|
+
required: true,
|
|
162
|
+
content: { 'application/json': { schema: { $ref: `#/components/schemas/${capitalized}` } } }
|
|
163
|
+
},
|
|
146
164
|
responses: { 200: { description: 'Updated', content: { 'application/json': { schema: { $ref: `#/components/schemas/${capitalized}` } } } } }
|
|
147
165
|
}, 'update');
|
|
148
166
|
|
|
149
167
|
regPath(`${basePath}/${name}s/{id}`, 'patch', {
|
|
150
168
|
summary: `Patch ${capitalized}`,
|
|
151
169
|
parameters: [...commonHeaders, { name: 'id', in: 'path', required: true, schema: { type: 'integer' } }],
|
|
170
|
+
requestBody: {
|
|
171
|
+
required: true,
|
|
172
|
+
content: { 'application/json': { schema: { $ref: `#/components/schemas/${capitalized}` } } }
|
|
173
|
+
},
|
|
152
174
|
responses: { 200: { description: 'Patched' } }
|
|
153
175
|
}, 'update');
|
|
154
176
|
|
package/package.json
CHANGED
package/parser/gdl.js
CHANGED
|
@@ -273,6 +273,8 @@ export const toGoType = (type, enums = []) => {
|
|
|
273
273
|
Time: 'time.Time',
|
|
274
274
|
LocalDate: 'time.Time',
|
|
275
275
|
Instant: 'time.Time',
|
|
276
|
+
Datetime: 'time.Time',
|
|
277
|
+
DateTime: 'time.Time',
|
|
276
278
|
JSON: 'datatypes.JSON',
|
|
277
279
|
JSONB: 'datatypes.JSON',
|
|
278
280
|
};
|
|
@@ -300,7 +302,9 @@ export const toLiquibaseType = (field, enums = []) => {
|
|
|
300
302
|
Time: 'TIME',
|
|
301
303
|
LocalDate: 'DATE',
|
|
302
304
|
Instant: 'TIMESTAMP',
|
|
303
|
-
|
|
305
|
+
Datetime: 'TIMESTAMP',
|
|
306
|
+
DateTime: 'TIMESTAMP',
|
|
307
|
+
JSON: 'JSONB',
|
|
304
308
|
JSONB: 'JSONB',
|
|
305
309
|
};
|
|
306
310
|
return map[field.type] || 'VARCHAR(255)';
|
|
@@ -44,11 +44,13 @@ const compactWidgetHTML = `<!DOCTYPE html>
|
|
|
44
44
|
<title>Live Telemetry</title>
|
|
45
45
|
<style>
|
|
46
46
|
html, body { margin: 0; padding: 0; width: 100%; height: 100%; background: #121212; color: #fff; font-family: system-ui, sans-serif; overflow: hidden; }
|
|
47
|
-
.bento-grid { display: grid; grid-template-columns:
|
|
48
|
-
.bento-
|
|
47
|
+
.bento-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; width: 100%; height: 100%; padding: 8px; box-sizing: border-box; }
|
|
48
|
+
.bento-col { display: flex; flex-direction: column; gap: 8px; height: 100%; }
|
|
49
|
+
.bento-card { background: #1e1e1e; border-radius: 12px; display: flex; flex-direction: column; justify-content: center; align-items: center; position: relative; border: 1px solid #333; transition: all 0.2s; flex: 1; }
|
|
49
50
|
.bento-title { position: absolute; top: 10px; left: 10px; font-size: 0.75rem; color: #888; text-transform: uppercase; letter-spacing: 1px; }
|
|
50
51
|
.bento-badge { position: absolute; top: 10px; right: 10px; font-size: 0.6rem; padding: 2px 6px; border-radius: 4px; background: #e74c3c; color: #fff; display: none; }
|
|
51
52
|
.bento-value { font-size: 2.5rem; font-weight: 700; color: #fff; margin-top: 15px; display: flex; align-items: baseline; gap: 4px; }
|
|
53
|
+
.bento-value-small { font-size: 1.5rem; font-weight: 700; color: #fff; margin-top: 15px; display: flex; align-items: baseline; gap: 4px; }
|
|
52
54
|
.bento-unit { font-size: 1rem; color: #888; font-weight: normal; }
|
|
53
55
|
.bento-sub { font-size: 0.75rem; color: #666; margin-top: 5px; }
|
|
54
56
|
|
|
@@ -67,10 +69,20 @@ const compactWidgetHTML = `<!DOCTYPE html>
|
|
|
67
69
|
<div class="bento-badge" id="cpu-badge">QUOTA</div>
|
|
68
70
|
<div class="bento-value"><span id="cpu-val">0</span><span class="bento-unit">%</span></div>
|
|
69
71
|
</div>
|
|
70
|
-
<div class="bento-
|
|
71
|
-
<div class="bento-
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
<div class="bento-col">
|
|
73
|
+
<div class="bento-card" id="card-mem">
|
|
74
|
+
<div class="bento-title">HEAP ALLOC</div>
|
|
75
|
+
<div class="bento-value-small"><span id="mem-val">0</span><span class="bento-unit">%</span></div>
|
|
76
|
+
<div class="bento-sub"><span id="mem-raw">0 / 0 MB</span></div>
|
|
77
|
+
</div>
|
|
78
|
+
<div class="bento-card" id="card-goroutines">
|
|
79
|
+
<div class="bento-title">GOROUTINES</div>
|
|
80
|
+
<div class="bento-value-small"><span id="go-val">0</span></div>
|
|
81
|
+
</div>
|
|
82
|
+
<div class="bento-card" id="card-uptime">
|
|
83
|
+
<div class="bento-title">UPTIME</div>
|
|
84
|
+
<div class="bento-value-small" style="font-size: 1rem;"><span id="up-val">-</span></div>
|
|
85
|
+
</div>
|
|
74
86
|
</div>
|
|
75
87
|
</div>
|
|
76
88
|
<script>
|
|
@@ -115,6 +127,10 @@ const compactWidgetHTML = `<!DOCTYPE html>
|
|
|
115
127
|
|
|
116
128
|
if (memPct > 90) document.getElementById('card-mem').classList.add('alarm-active');
|
|
117
129
|
else document.getElementById('card-mem').classList.remove('alarm-active');
|
|
130
|
+
|
|
131
|
+
// Goroutines & Uptime
|
|
132
|
+
document.getElementById('go-val').innerText = sys.goroutines || 0;
|
|
133
|
+
document.getElementById('up-val').innerText = sys.uptime || '-';
|
|
118
134
|
});
|
|
119
135
|
evtSource.onerror = function() {
|
|
120
136
|
document.getElementById('cpu-val').innerText = "OFF";
|
|
@@ -1472,9 +1488,8 @@ func SetupRouter(appConfig *config.Config) *gin.Engine {
|
|
|
1472
1488
|
if (topic.includes('/')) {
|
|
1473
1489
|
let btnHtml = "";
|
|
1474
1490
|
if (keycloak && keycloak.authenticated) {
|
|
1475
|
-
const
|
|
1476
|
-
const
|
|
1477
|
-
const btnColor = isSend ? "#e74c3c" : "#3498db";
|
|
1491
|
+
const btnLabel = "SUBSCRIBE";
|
|
1492
|
+
const btnColor = "#3498db";
|
|
1478
1493
|
btnHtml = " <button class=\"mqtt-action-btn\" style=\"background:" + btnColor + "\" onclick=\"openMqttAction('" + topic + "', '" + btnLabel + "')\">" + btnLabel + "</button>";
|
|
1479
1494
|
}
|
|
1480
1495
|
return '"' + topic + '"' + punct + btnHtml;
|