@cartanova/qgrid-cli 1.3.0 → 1.5.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 (24) hide show
  1. package/bundle/dist/application/qgrid/pool.js +6 -3
  2. package/bundle/dist/sonamu.config.js +4 -2
  3. package/bundle/src/application/qgrid/pool.ts +6 -2
  4. package/bundle/src/sonamu.config.ts +2 -0
  5. package/bundle/web-dist/client/assets/index-CJbMnvkl.css +1 -0
  6. package/bundle/web-dist/client/assets/index-DhqeOdaq.js +116 -0
  7. package/bundle/web-dist/client/assets/logs-BzY81a5V.js +1 -0
  8. package/bundle/web-dist/client/assets/preload-helper-ca-nBW7U.js +1 -0
  9. package/bundle/web-dist/client/assets/routes-C8VZv8Ii.js +5 -0
  10. package/bundle/web-dist/client/assets/{show-CFGLH8f_.js → show-B9Z-snx2.js} +1 -1
  11. package/bundle/web-dist/client/assets/{tokens-Bib8aQbc.js → tokens-Dk4_IBwI.js} +1 -1
  12. package/bundle/web-dist/client/index.html +3 -2
  13. package/bundle/web-dist/server/assets/lazyRouteComponent-Dyl_0WZs.js +1982 -0
  14. package/bundle/web-dist/server/assets/logs-bLRMIO1J.js +244 -0
  15. package/bundle/web-dist/server/assets/{routes-Dx59lTlD.js → routes-qwzTPLE2.js} +14 -388
  16. package/bundle/web-dist/server/assets/{show-BEFi1cKV.js → show-Btv2c6zd.js} +2 -1
  17. package/bundle/web-dist/server/assets/{tokens-Dyi6qMmP.js → tokens-BYhGItkk.js} +1 -1
  18. package/bundle/web-dist/server/entry-server.generated.js +70 -2008
  19. package/dist/cli.js +25 -4
  20. package/package.json +1 -1
  21. package/bundle/web-dist/client/assets/index-BP0XRvKL.css +0 -1
  22. package/bundle/web-dist/client/assets/index-CgXTSTgN.js +0 -116
  23. package/bundle/web-dist/client/assets/routes-DvViUcG1.js +0 -5
  24. /package/bundle/web-dist/client/assets/{services.generated-CAJQk7Wk.js → services.generated-1X7EKUWg.js} +0 -0
@@ -0,0 +1,244 @@
1
+ import { S as require_react, nt as __toESM, x as require_jsx_runtime } from "./sd.generated-BeEKgSOs.js";
2
+ import { n as RequestLogService, r as TokenService } from "./services.generated-DjxCLdMu.js";
3
+ import { o as useNavigate } from "./lazyRouteComponent-Dyl_0WZs.js";
4
+ import { n as Route } from "../entry-server.generated.js";
5
+ //#region ~icons/lucide/chevron-left.jsx
6
+ var import_react = /* @__PURE__ */ __toESM(require_react());
7
+ var import_jsx_runtime = require_jsx_runtime();
8
+ var lucideChevronLeft = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", {
9
+ viewBox: "0 0 24 24",
10
+ width: "1.2em",
11
+ height: "1.2em",
12
+ ...props,
13
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
14
+ fill: "none",
15
+ stroke: "currentColor",
16
+ strokeLinecap: "round",
17
+ strokeLinejoin: "round",
18
+ strokeWidth: 2,
19
+ d: "m15 18l-6-6l6-6"
20
+ })
21
+ });
22
+ //#endregion
23
+ //#region ~icons/lucide/chevron-right.jsx
24
+ var lucideChevronRight = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", {
25
+ viewBox: "0 0 24 24",
26
+ width: "1.2em",
27
+ height: "1.2em",
28
+ ...props,
29
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
30
+ fill: "none",
31
+ stroke: "currentColor",
32
+ strokeLinecap: "round",
33
+ strokeLinejoin: "round",
34
+ strokeWidth: 2,
35
+ d: "m9 18l6-6l-6-6"
36
+ })
37
+ });
38
+ //#endregion
39
+ //#region src/components/qgrid/RequestLogTable.tsx
40
+ var PAGE_SIZE = 50;
41
+ function formatDateTime(iso) {
42
+ const d = new Date(iso);
43
+ return `${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")} ${String(d.getHours()).padStart(2, "0")}:${String(d.getMinutes()).padStart(2, "0")}`;
44
+ }
45
+ function formatNum(n) {
46
+ return n.toLocaleString();
47
+ }
48
+ function calcCacheHitRate(row) {
49
+ const denom = row.input_tokens + row.cache_read_tokens + row.cache_creation_tokens;
50
+ if (denom === 0) return "—";
51
+ return `${Math.round(row.cache_read_tokens / denom * 100)}%`;
52
+ }
53
+ function trimQuery(q, maxLen = 30) {
54
+ return q.length > maxLen ? `${q.slice(0, maxLen)}...` : q;
55
+ }
56
+ function RequestLogTable({ page: externalPage, onPageChange } = {}) {
57
+ const navigate = useNavigate();
58
+ const [internalPage, setInternalPage] = (0, import_react.useState)(1);
59
+ const page = externalPage ?? internalPage;
60
+ const setPage = onPageChange ?? setInternalPage;
61
+ const [tokenFilter, setTokenFilter] = (0, import_react.useState)("");
62
+ const { data: tokensData } = TokenService.useTokens("A");
63
+ const tokenNames = (tokensData?.rows ?? []).map((t) => t.name).filter(Boolean);
64
+ const { data, isLoading } = RequestLogService.useRequestLogs("A", {
65
+ num: PAGE_SIZE,
66
+ page,
67
+ orderBy: "id-desc",
68
+ ...tokenFilter ? { token_name: tokenFilter } : {}
69
+ });
70
+ const rows = data?.rows ?? [];
71
+ const total = data?.total ?? 0;
72
+ const totalPages = Math.ceil(total / PAGE_SIZE);
73
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
74
+ className: "flex items-center gap-2 mb-3 flex-wrap",
75
+ children: [tokenNames.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", {
76
+ value: tokenFilter,
77
+ onChange: (e) => {
78
+ setTokenFilter(e.target.value);
79
+ setPage(1);
80
+ },
81
+ className: "border border-sand-200 rounded-md px-2 py-1 text-xs text-sand-700 bg-white focus:outline-none focus:border-sienna-300",
82
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
83
+ value: "",
84
+ children: "All Tokens"
85
+ }), tokenNames.map((name) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
86
+ value: name,
87
+ children: name
88
+ }, name))]
89
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
90
+ className: "text-[11px] text-sand-400",
91
+ children: [total, " results"]
92
+ })]
93
+ }), isLoading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
94
+ className: "space-y-2",
95
+ children: Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "h-8 bg-sand-100 rounded animate-pulse" }, `skel-${i}`))
96
+ }) : rows.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
97
+ className: "text-sand-400 text-center py-12 text-sm",
98
+ children: "No requests yet."
99
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
100
+ className: "rounded-lg bg-sand-50 overflow-hidden",
101
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", {
102
+ className: "w-full text-sm",
103
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
104
+ className: "border-b border-sand-200",
105
+ children: [
106
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
107
+ className: "text-left px-3 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium",
108
+ children: "Date"
109
+ }),
110
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
111
+ className: "text-left px-3 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium",
112
+ children: "Token"
113
+ }),
114
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
115
+ className: "text-left px-3 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium",
116
+ children: "Query"
117
+ }),
118
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
119
+ className: "text-right px-3 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium",
120
+ children: "In"
121
+ }),
122
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
123
+ className: "text-right px-3 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium",
124
+ children: "Out"
125
+ }),
126
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
127
+ className: "text-right px-3 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium",
128
+ children: "C.Read"
129
+ }),
130
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
131
+ className: "text-right px-3 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium",
132
+ children: "C.Write"
133
+ }),
134
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", {
135
+ className: "text-right px-3 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium",
136
+ children: "Hit"
137
+ }),
138
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { className: "w-8 px-2 py-2.5" })
139
+ ]
140
+ }) }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", {
141
+ className: "divide-y divide-sand-200/60",
142
+ children: rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", {
143
+ className: "transition-colors duration-150 hover:bg-sand-100/60 cursor-pointer",
144
+ onClick: () => navigate({
145
+ to: "/requests/show",
146
+ search: { id: row.id }
147
+ }),
148
+ children: [
149
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
150
+ className: "px-3 py-2.5",
151
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
152
+ className: "text-[10px] text-sand-400 tabular-nums whitespace-nowrap",
153
+ children: formatDateTime(row.created_at)
154
+ })
155
+ }),
156
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
157
+ className: "px-3 py-2.5",
158
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
159
+ className: "text-xs text-sand-500",
160
+ children: row.token_name
161
+ })
162
+ }),
163
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
164
+ className: "px-3 py-2.5",
165
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
166
+ className: "text-sand-800 truncate max-w-48",
167
+ title: row.query,
168
+ children: trimQuery(row.query)
169
+ })
170
+ }),
171
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
172
+ className: "px-3 py-2.5 text-right tabular-nums text-sand-700",
173
+ children: formatNum(row.input_tokens)
174
+ }),
175
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
176
+ className: "px-3 py-2.5 text-right tabular-nums text-sand-700",
177
+ children: formatNum(row.output_tokens)
178
+ }),
179
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
180
+ className: "px-3 py-2.5 text-right tabular-nums text-sand-700",
181
+ children: formatNum(row.cache_read_tokens)
182
+ }),
183
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
184
+ className: "px-3 py-2.5 text-right tabular-nums text-sand-700",
185
+ children: formatNum(row.cache_creation_tokens)
186
+ }),
187
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
188
+ className: "px-3 py-2.5 text-right tabular-nums text-sand-700",
189
+ children: calcCacheHitRate(row)
190
+ }),
191
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", {
192
+ className: "px-2 py-2.5",
193
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucideChevronRight, { className: "size-4 text-sand-400" })
194
+ })
195
+ ]
196
+ }, row.id))
197
+ })]
198
+ })
199
+ }), totalPages > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
200
+ className: "flex items-center justify-center gap-3 mt-3",
201
+ children: [
202
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
203
+ type: "button",
204
+ className: "p-1 rounded text-sand-400 hover:text-sand-600 disabled:opacity-30 transition-colors",
205
+ disabled: page === 1,
206
+ onClick: () => setPage(page - 1),
207
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucideChevronLeft, { className: "size-4" })
208
+ }),
209
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
210
+ className: "text-[11px] text-sand-400 tabular-nums",
211
+ children: [
212
+ page,
213
+ " / ",
214
+ totalPages
215
+ ]
216
+ }),
217
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
218
+ type: "button",
219
+ className: "p-1 rounded text-sand-400 hover:text-sand-600 disabled:opacity-30 transition-colors",
220
+ disabled: page === totalPages,
221
+ onClick: () => setPage(page + 1),
222
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(lucideChevronRight, { className: "size-4" })
223
+ })
224
+ ]
225
+ })] })] });
226
+ }
227
+ //#endregion
228
+ //#region src/routes/logs.tsx?tsr-split=component
229
+ function LogsPage() {
230
+ const { page } = Route.useSearch();
231
+ const navigate = Route.useNavigate();
232
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
233
+ className: "space-y-5 max-w-300 mx-auto -translate-x-4",
234
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", {
235
+ className: "text-xl font-medium text-sand-900 tracking-tight",
236
+ children: "Request Logs"
237
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RequestLogTable, {
238
+ page,
239
+ onPageChange: (p) => navigate({ search: { page: p } })
240
+ })]
241
+ });
242
+ }
243
+ //#endregion
244
+ export { LogsPage as component };