nestlens 0.14.3 → 0.16.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 (96) hide show
  1. package/README.md +10 -0
  2. package/dist/api/api.controller.d.ts +16 -5
  3. package/dist/api/api.controller.js +94 -8
  4. package/dist/api/dto/entries-query.dto.d.ts +20 -4
  5. package/dist/api/dto/entries-query.dto.js +50 -18
  6. package/dist/api/dto/transformers/query-transformers.d.ts +13 -0
  7. package/dist/api/dto/transformers/query-transformers.js +16 -2
  8. package/dist/api/dto/transformers/query-validators.js +2 -0
  9. package/dist/api/interceptors/api-response.interceptor.js +1 -1
  10. package/dist/api/spa-wildcard.d.ts +21 -3
  11. package/dist/api/spa-wildcard.js +38 -4
  12. package/dist/api/tag.controller.js +25 -0
  13. package/dist/api/tools/dto-schema.d.ts +38 -0
  14. package/dist/api/tools/dto-schema.js +128 -0
  15. package/dist/api/tools/index.d.ts +3 -0
  16. package/dist/api/tools/index.js +18 -0
  17. package/dist/api/tools/tool-manifest.d.ts +47 -0
  18. package/dist/api/tools/tool-manifest.js +142 -0
  19. package/dist/api/tools/tool.decorator.d.ts +34 -0
  20. package/dist/api/tools/tool.decorator.js +21 -0
  21. package/dist/dashboard/public/assets/{BatchDetailView-BdQe3DAT.js → BatchDetailView-D30hR4Dr.js} +1 -1
  22. package/dist/dashboard/public/assets/{BatchesPage-B9wO2Ncf.js → BatchesPage-BPIVKXn1.js} +1 -1
  23. package/dist/dashboard/public/assets/{CacheDetailView-CMAxDfBy.js → CacheDetailView-DfjU3yMX.js} +1 -1
  24. package/dist/dashboard/public/assets/{CachePage-DJ8SiKoa.js → CachePage-CbYwp5HQ.js} +1 -1
  25. package/dist/dashboard/public/assets/{CommandDetailView-Dj3SmHuj.js → CommandDetailView-6w6rudlW.js} +1 -1
  26. package/dist/dashboard/public/assets/{CommandsPage-C5EJj66E.js → CommandsPage-CVItOxrh.js} +1 -1
  27. package/dist/dashboard/public/assets/{CopyButton-8NQFvMIW.js → CopyButton-Cp_IPU2R.js} +1 -1
  28. package/dist/dashboard/public/assets/{DashboardPage-C2qvsAiz.js → DashboardPage-Bb84PH1y.js} +1 -1
  29. package/dist/dashboard/public/assets/{DataTable-ChUNEmWG.js → DataTable-B1v1VSqy.js} +1 -1
  30. package/dist/dashboard/public/assets/{DetailRow-BX0zpKTe.js → DetailRow-BsKUo5E1.js} +1 -1
  31. package/dist/dashboard/public/assets/{DumpDetailView-DtxmGLVH.js → DumpDetailView-puF6oBLJ.js} +1 -1
  32. package/dist/dashboard/public/assets/{DumpsPage-CMl3tRmM.js → DumpsPage-CFKPlU24.js} +1 -1
  33. package/dist/dashboard/public/assets/{EntryDetailPage-NLzBL3a7.js → EntryDetailPage-DSpdTWDw.js} +3 -3
  34. package/dist/dashboard/public/assets/{EntrySearchInput-Cl30X6WS.js → EntrySearchInput-BaZslrIV.js} +1 -1
  35. package/dist/dashboard/public/assets/{EventDetailView-mqZ3406I.js → EventDetailView-PyyaqXjz.js} +1 -1
  36. package/dist/dashboard/public/assets/{EventsPage-CRJQVA8A.js → EventsPage-CeUH8Quz.js} +1 -1
  37. package/dist/dashboard/public/assets/{ExceptionDetailView-CgGWCY9S.js → ExceptionDetailView-BLmFiSal.js} +1 -1
  38. package/dist/dashboard/public/assets/{ExceptionsPage-XejTTGZo.js → ExceptionsPage-BUyUE5PT.js} +1 -1
  39. package/dist/dashboard/public/assets/{GateDetailView-RDlBU8AZ.js → GateDetailView-Dg6tUG6S.js} +1 -1
  40. package/dist/dashboard/public/assets/{GatesPage-CugJC28p.js → GatesPage-VzuDj-is.js} +1 -1
  41. package/dist/dashboard/public/assets/{GraphQLDetailView-BFAJoQfl.js → GraphQLDetailView-xq7KpWyY.js} +1 -1
  42. package/dist/dashboard/public/assets/{GraphQLPage-BIhJneVf.js → GraphQLPage-x2-ikcyr.js} +1 -1
  43. package/dist/dashboard/public/assets/{HttpClientDetailView-BQDbioP0.js → HttpClientDetailView-CyDIjshU.js} +1 -1
  44. package/dist/dashboard/public/assets/{HttpClientPage-Ul44nXQ1.js → HttpClientPage-7eUYS6F3.js} +1 -1
  45. package/dist/dashboard/public/assets/{JobDetailView-BOHzBDsg.js → JobDetailView-BnmLsUw6.js} +1 -1
  46. package/dist/dashboard/public/assets/{JobsPage-DUu59mJu.js → JobsPage-BZsSk2Br.js} +1 -1
  47. package/dist/dashboard/public/assets/{LogDetailView-DU_wZ8pq.js → LogDetailView-B5rPgu9-.js} +1 -1
  48. package/dist/dashboard/public/assets/{LogsPage-C98bcWXx.js → LogsPage-B6ECmCD_.js} +1 -1
  49. package/dist/dashboard/public/assets/{MailDetailView-B6KE8HV0.js → MailDetailView-D5MDSTtG.js} +1 -1
  50. package/dist/dashboard/public/assets/{MailPage-Ca_c3Mbx.js → MailPage-Bp0dtJof.js} +1 -1
  51. package/dist/dashboard/public/assets/{ModelDetailView-DSW4FtAE.js → ModelDetailView-CTZe1jWF.js} +1 -1
  52. package/dist/dashboard/public/assets/{ModelsPage-Db-cZ_tz.js → ModelsPage-CzMdlRHH.js} +1 -1
  53. package/dist/dashboard/public/assets/{NotificationDetailView-B4LoEIas.js → NotificationDetailView-BiKR1bL4.js} +1 -1
  54. package/dist/dashboard/public/assets/{NotificationsPage-B4GN3KiM.js → NotificationsPage-BOjxBqJO.js} +1 -1
  55. package/dist/dashboard/public/assets/{PageHeader-CwpXbfba.js → PageHeader-DOCUb2x3.js} +1 -1
  56. package/dist/dashboard/public/assets/{QueriesPage-CQfaBmXe.js → QueriesPage-B4y3NkR5.js} +1 -1
  57. package/dist/dashboard/public/assets/{QueryDetailView-B4wcgIki.js → QueryDetailView-PMgQ5IxF.js} +1 -1
  58. package/dist/dashboard/public/assets/{RedisDetailView-DtJd51k9.js → RedisDetailView-B6zQUBzw.js} +1 -1
  59. package/dist/dashboard/public/assets/{RedisPage-DYRX-6Tf.js → RedisPage-DXybZMsP.js} +1 -1
  60. package/dist/dashboard/public/assets/{RequestDetailView-BKlhzTF2.js → RequestDetailView-D0CEcJXx.js} +1 -1
  61. package/dist/dashboard/public/assets/{RequestsPage-ClUJnaiz.js → RequestsPage-JDR5I6nl.js} +1 -1
  62. package/dist/dashboard/public/assets/{ScheduleDetailView-BA3IBVOs.js → ScheduleDetailView-BEM_W57x.js} +1 -1
  63. package/dist/dashboard/public/assets/{SchedulePage-C9Sf4Nzg.js → SchedulePage-DtAkN83E.js} +1 -1
  64. package/dist/dashboard/public/assets/{UserCard-BiPMOHC2.js → UserCard-W-aR6C32.js} +1 -1
  65. package/dist/dashboard/public/assets/{ViewDetailView-CLcKQAzy.js → ViewDetailView-3m29Eqsg.js} +1 -1
  66. package/dist/dashboard/public/assets/{ViewsPage-Bpg9xsiQ.js → ViewsPage-BxrxkeSF.js} +1 -1
  67. package/dist/dashboard/public/assets/{calendar-9taI7KIF.js → calendar-BvT1GsQt.js} +1 -1
  68. package/dist/dashboard/public/assets/{circle-alert-3qwz1WcZ.js → circle-alert-sfiVJoqG.js} +1 -1
  69. package/dist/dashboard/public/assets/{circle-check-big-DcP6kxnu.js → circle-check-big-rPcvWaGG.js} +1 -1
  70. package/dist/dashboard/public/assets/{circle-x-C5FZ5L0I.js → circle-x-DH6akMMo.js} +1 -1
  71. package/dist/dashboard/public/assets/{eye-7S1ZlGkA.js → eye-BWDCKCKn.js} +1 -1
  72. package/dist/dashboard/public/assets/{index-CC9YqlAO.js → index-B4Yux9BN.js} +2 -2
  73. package/dist/dashboard/public/assets/{search-DlyuMX5Q.js → search-CEpvfCX1.js} +1 -1
  74. package/dist/dashboard/public/assets/{send-C8jkJh8C.js → send-0dzPQ6os.js} +1 -1
  75. package/dist/dashboard/public/assets/{timer-DiBZzrwD.js → timer-BSTWkhfE.js} +1 -1
  76. package/dist/dashboard/public/assets/{types-7eWhJMm7.js → types-kls_XDEv.js} +1 -1
  77. package/dist/dashboard/public/assets/{users-G6Z4vIpX.js → users-CGDrPAyR.js} +1 -1
  78. package/dist/dashboard/public/assets/{zap-DaVFRg-y.js → zap-Buhl44s5.js} +1 -1
  79. package/dist/dashboard/public/index.html +1 -1
  80. package/dist/mcp/bin.d.ts +2 -0
  81. package/dist/mcp/bin.js +29 -0
  82. package/dist/mcp/cli.d.ts +18 -0
  83. package/dist/mcp/cli.js +184 -0
  84. package/dist/mcp/client.d.ts +85 -0
  85. package/dist/mcp/client.js +378 -0
  86. package/dist/mcp/fit.d.ts +10 -0
  87. package/dist/mcp/fit.js +129 -0
  88. package/dist/mcp/http.d.ts +58 -0
  89. package/dist/mcp/http.js +209 -0
  90. package/dist/mcp/index.d.ts +6 -0
  91. package/dist/mcp/index.js +14 -0
  92. package/dist/mcp/server.d.ts +42 -0
  93. package/dist/mcp/server.js +249 -0
  94. package/dist/watchers/exception.watcher.d.ts +6 -6
  95. package/dist/watchers/exception.watcher.js +6 -6
  96. package/package.json +40 -21
@@ -26,13 +26,31 @@ import { HttpAdapterHost } from '@nestjs/core';
26
26
  */
27
27
  export declare const toSpaWildcard: (adapterType: string | undefined, expressMajor: number | undefined) => string;
28
28
  /**
29
- * Express's major version, or `undefined` when it cannot be read.
29
+ * The major version of the Express that `@nestjs/platform-express` runs, or
30
+ * `undefined` when it cannot be read.
31
+ *
32
+ * Resolved from the adapter's own directory, because that is the copy the
33
+ * adapter loads. NestJS 9 and 10 bring Express 4, and when anything else in
34
+ * the application wants Express 5 — `@modelcontextprotocol/sdk`, which
35
+ * NestLens's own MCP server uses, is one — npm hoists 5 to the top of
36
+ * node_modules and nests 4 under the adapter. Read from here, that answered 5
37
+ * to an Express 4 router, which then took `*path` literally and 404'd every
38
+ * deep link into the dashboard.
39
+ *
40
+ * The package, not the running application: an application can hand NestJS
41
+ * its own Express, and every Express 4 release has `app.lazyrouter` where 5
42
+ * does not, but no supported pairing needs it. Measured: the NestJS 11 and 12
43
+ * adapters read `app.router`, which throws on Express 4 before NestLens is
44
+ * reached, and on NestJS 10 an Express 5 application dies registering any
45
+ * `forRoutes('*')` middleware — path-to-regexp 8's "Missing parameter name".
46
+ * In every pairing that boots, the running Express has the adapter's major.
30
47
  *
31
48
  * Required lazily: Express is not a dependency of this package, and an
32
49
  * application on Fastify has no reason to have it installed. Only reached when
33
- * the adapter has already identified itself as Express.
50
+ * the adapter has already identified itself as Express. `paths` is where
51
+ * resolution starts, for tests; by default it is this package's location.
34
52
  */
35
- export declare const readExpressMajor: () => number | undefined;
53
+ export declare const readExpressMajor: (paths?: string[]) => number | undefined;
36
54
  /**
37
55
  * Points the dashboard's catch-all at the syntax the running router accepts.
38
56
  *
@@ -16,6 +16,7 @@ exports.SpaRouteRegistrar = exports.readExpressMajor = exports.toSpaWildcard = v
16
16
  const common_1 = require("@nestjs/common");
17
17
  const constants_1 = require("@nestjs/common/constants");
18
18
  const core_1 = require("@nestjs/core");
19
+ const path_1 = require("path");
19
20
  const dashboard_controller_1 = require("./dashboard.controller");
20
21
  /**
21
22
  * The SPA fallback has to match any depth — `/nestlens/requests/42` is a route
@@ -49,16 +50,49 @@ const toSpaWildcard = (adapterType, expressMajor) => {
49
50
  return (expressMajor ?? 0) >= 5 ? '*path' : '*';
50
51
  };
51
52
  exports.toSpaWildcard = toSpaWildcard;
53
+ /** Where `request` resolves from `paths`, or `undefined` when it does not. */
54
+ const resolveFrom = (request, paths) => {
55
+ try {
56
+ return paths ? require.resolve(request, { paths }) : require.resolve(request);
57
+ }
58
+ catch {
59
+ return undefined;
60
+ }
61
+ };
52
62
  /**
53
- * Express's major version, or `undefined` when it cannot be read.
63
+ * The major version of the Express that `@nestjs/platform-express` runs, or
64
+ * `undefined` when it cannot be read.
65
+ *
66
+ * Resolved from the adapter's own directory, because that is the copy the
67
+ * adapter loads. NestJS 9 and 10 bring Express 4, and when anything else in
68
+ * the application wants Express 5 — `@modelcontextprotocol/sdk`, which
69
+ * NestLens's own MCP server uses, is one — npm hoists 5 to the top of
70
+ * node_modules and nests 4 under the adapter. Read from here, that answered 5
71
+ * to an Express 4 router, which then took `*path` literally and 404'd every
72
+ * deep link into the dashboard.
73
+ *
74
+ * The package, not the running application: an application can hand NestJS
75
+ * its own Express, and every Express 4 release has `app.lazyrouter` where 5
76
+ * does not, but no supported pairing needs it. Measured: the NestJS 11 and 12
77
+ * adapters read `app.router`, which throws on Express 4 before NestLens is
78
+ * reached, and on NestJS 10 an Express 5 application dies registering any
79
+ * `forRoutes('*')` middleware — path-to-regexp 8's "Missing parameter name".
80
+ * In every pairing that boots, the running Express has the adapter's major.
54
81
  *
55
82
  * Required lazily: Express is not a dependency of this package, and an
56
83
  * application on Fastify has no reason to have it installed. Only reached when
57
- * the adapter has already identified itself as Express.
84
+ * the adapter has already identified itself as Express. `paths` is where
85
+ * resolution starts, for tests; by default it is this package's location.
58
86
  */
59
- const readExpressMajor = () => {
87
+ const readExpressMajor = (paths) => {
88
+ const adapter = resolveFrom('@nestjs/platform-express/package.json', paths);
89
+ const manifest = (adapter ? resolveFrom('express/package.json', [(0, path_1.dirname)(adapter)]) : undefined) ??
90
+ resolveFrom('express/package.json', paths);
91
+ if (!manifest) {
92
+ return undefined;
93
+ }
60
94
  try {
61
- const { version } = require('express/package.json');
95
+ const { version } = require(manifest);
62
96
  const major = Number.parseInt(version ?? '', 10);
63
97
  return Number.isNaN(major) ? undefined : major;
64
98
  }
@@ -20,6 +20,7 @@ const dto_1 = require("./dto");
20
20
  const api_guard_1 = require("./api.guard");
21
21
  const api_exception_filter_1 = require("./filters/api-exception.filter");
22
22
  const api_response_interceptor_1 = require("./interceptors/api-response.interceptor");
23
+ const tools_1 = require("./tools");
23
24
  const pipes_1 = require("./pipes");
24
25
  /**
25
26
  * Every handler here takes an unused `@Res() _res` parameter — see
@@ -93,6 +94,9 @@ let TagController = class TagController {
93
94
  };
94
95
  exports.TagController = TagController;
95
96
  __decorate([
97
+ (0, tools_1.NestLensTool)({
98
+ description: 'Every tag in use with how many entries carry it. NestLens tags entries automatically from their content, and tags can be added by hand.',
99
+ }),
96
100
  (0, common_1.Get)(),
97
101
  __param(0, (0, common_1.Res)()),
98
102
  __metadata("design:type", Function),
@@ -100,6 +104,9 @@ __decorate([
100
104
  __metadata("design:returntype", Promise)
101
105
  ], TagController.prototype, "getAllTags", null);
102
106
  __decorate([
107
+ (0, tools_1.NestLensTool)({
108
+ description: 'Entries carrying one or more tags. `logic` is OR (any of the tags, the default) or AND (all of them).',
109
+ }),
103
110
  (0, common_1.Get)('entries'),
104
111
  __param(0, (0, common_1.Query)()),
105
112
  __param(1, (0, common_1.Res)()),
@@ -108,6 +115,9 @@ __decorate([
108
115
  __metadata("design:returntype", Promise)
109
116
  ], TagController.prototype, "getEntriesByTags", null);
110
117
  __decorate([
118
+ (0, tools_1.NestLensTool)({
119
+ description: 'The tags on one entry.',
120
+ }),
111
121
  (0, common_1.Get)('entry/:id'),
112
122
  __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
113
123
  __param(1, (0, common_1.Res)()),
@@ -116,6 +126,9 @@ __decorate([
116
126
  __metadata("design:returntype", Promise)
117
127
  ], TagController.prototype, "getEntryTags", null);
118
128
  __decorate([
129
+ (0, tools_1.NestLensTool)({
130
+ description: 'Add tags to an entry.',
131
+ }),
119
132
  (0, common_1.Post)('entry/:id'),
120
133
  __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
121
134
  __param(1, (0, common_1.Body)()),
@@ -125,6 +138,9 @@ __decorate([
125
138
  __metadata("design:returntype", Promise)
126
139
  ], TagController.prototype, "addTagsToEntry", null);
127
140
  __decorate([
141
+ (0, tools_1.NestLensTool)({
142
+ description: 'Remove tags from an entry.',
143
+ }),
128
144
  (0, common_1.Delete)('entry/:id'),
129
145
  __param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
130
146
  __param(1, (0, common_1.Body)()),
@@ -134,6 +150,9 @@ __decorate([
134
150
  __metadata("design:returntype", Promise)
135
151
  ], TagController.prototype, "removeTagsFromEntry", null);
136
152
  __decorate([
153
+ (0, tools_1.NestLensTool)({
154
+ description: 'Tags that are monitored, with their entry counts. Pruning never deletes an entry that carries one.',
155
+ }),
137
156
  (0, common_1.Get)('monitored'),
138
157
  __param(0, (0, common_1.Res)()),
139
158
  __metadata("design:type", Function),
@@ -141,6 +160,9 @@ __decorate([
141
160
  __metadata("design:returntype", Promise)
142
161
  ], TagController.prototype, "getMonitoredTags", null);
143
162
  __decorate([
163
+ (0, tools_1.NestLensTool)({
164
+ description: 'Monitor a tag, so pruning keeps every entry that carries it.',
165
+ }),
144
166
  (0, common_1.Post)('monitored'),
145
167
  __param(0, (0, common_1.Body)()),
146
168
  __param(1, (0, common_1.Res)()),
@@ -149,6 +171,9 @@ __decorate([
149
171
  __metadata("design:returntype", Promise)
150
172
  ], TagController.prototype, "addMonitoredTag", null);
151
173
  __decorate([
174
+ (0, tools_1.NestLensTool)({
175
+ description: 'Stop monitoring a tag. Entries it protected become eligible for pruning again.',
176
+ }),
152
177
  (0, common_1.Delete)('monitored/:tag'),
153
178
  __param(0, (0, common_1.Param)('tag')),
154
179
  __param(1, (0, common_1.Res)()),
@@ -0,0 +1,38 @@
1
+ /** The JSON types a parameter can take. */
2
+ export type ToolParameterType = 'string' | 'integer' | 'number' | 'boolean' | 'array';
3
+ /** Where a parameter travels on the wire. */
4
+ export type ToolParameterLocation = 'path' | 'query' | 'body';
5
+ export interface ToolParameter {
6
+ name: string;
7
+ in: ToolParameterLocation;
8
+ type: ToolParameterType;
9
+ required: boolean;
10
+ /** Said once here for the shapes that are not obvious from a name and a type. */
11
+ description?: string;
12
+ /** For `array`, the type of each item. */
13
+ items?: 'string' | 'integer';
14
+ enum?: readonly string[];
15
+ format?: 'date-time';
16
+ minimum?: number;
17
+ maximum?: number;
18
+ maxLength?: number;
19
+ minItems?: number;
20
+ /** For `array`, the longest each item may be. */
21
+ itemMaxLength?: number;
22
+ maxItems?: number;
23
+ }
24
+ /**
25
+ * Read off a class by what its validators declare, which is the one place a
26
+ * parameter's shape is already written down. A second description would be a
27
+ * second thing to keep in step with the first, and the manifest exists so that
28
+ * nothing has to be.
29
+ */
30
+ type Constructor = new (...args: never[]) => object;
31
+ /**
32
+ * A `ToolParameter` for every property a validated class declares.
33
+ *
34
+ * Only properties with at least one validator are seen — which is every
35
+ * property these classes accept, because the validation pipe rejects the rest.
36
+ */
37
+ export declare const describeDto: (dto: Constructor, location: Exclude<ToolParameterLocation, "path">) => ToolParameter[];
38
+ export {};
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.describeDto = void 0;
4
+ const class_validator_1 = require("class-validator");
5
+ const transformers_1 = require("../dto/transformers");
6
+ const asNumber = (value) => typeof value === 'number' && Number.isFinite(value) ? value : undefined;
7
+ /** What a TypeScript type, as the compiler emitted it, says about the JSON type. */
8
+ const typeOfDesign = (design) => {
9
+ if (design === Number)
10
+ return 'number';
11
+ if (design === Boolean)
12
+ return 'boolean';
13
+ if (design === Array)
14
+ return 'array';
15
+ return 'string';
16
+ };
17
+ /**
18
+ * A `ToolParameter` for every property a validated class declares.
19
+ *
20
+ * Only properties with at least one validator are seen — which is every
21
+ * property these classes accept, because the validation pipe rejects the rest.
22
+ */
23
+ const describeDto = (dto, location) => {
24
+ const metadata = (0, class_validator_1.getMetadataStorage)().getTargetValidationMetadatas(dto, '', false, false);
25
+ const byProperty = new Map();
26
+ for (const entry of metadata) {
27
+ const list = byProperty.get(entry.propertyName) ?? [];
28
+ list.push(entry);
29
+ byProperty.set(entry.propertyName, list);
30
+ }
31
+ const parameters = [];
32
+ // `isAbsentWith` sits on one side of a pair; both sides are told.
33
+ const exclusions = [];
34
+ for (const [name, validators] of byProperty) {
35
+ const design = Reflect.getMetadata('design:type', dto.prototype, name);
36
+ const names = new Set(validators.map((validator) => validator.name));
37
+ const find = (validatorName) => validators.find((validator) => validator.name === validatorName);
38
+ const parameter = {
39
+ name,
40
+ in: location,
41
+ type: typeOfDesign(design),
42
+ required: !validators.some((validator) => validator.type === 'conditionalValidation'),
43
+ };
44
+ if (names.has('isInt'))
45
+ parameter.type = 'integer';
46
+ // A whole number from zero, at most its first constraint when it has one.
47
+ const wholeNumber = find('isWholeNumberLike');
48
+ if (wholeNumber)
49
+ parameter.type = 'integer';
50
+ // A parameter parsed into a bounded integer by the transformer rather than
51
+ // checked by a validator: the API clamps it into this range.
52
+ const bounds = Reflect.getMetadata(transformers_1.INTEGER_BOUNDS_METADATA, dto.prototype, name);
53
+ if (bounds)
54
+ parameter.type = 'integer';
55
+ if (names.has('isBooleanLike') || names.has('isBoolean'))
56
+ parameter.type = 'boolean';
57
+ if (names.has('isArray') || names.has('isCommaSeparatedStrings')) {
58
+ parameter.type = 'array';
59
+ parameter.items = 'string';
60
+ }
61
+ if (names.has('isCommaSeparatedList')) {
62
+ parameter.type = 'array';
63
+ parameter.items = 'string';
64
+ parameter.description =
65
+ 'Comma-separated; numbers, or ERR for a request that failed before it was answered';
66
+ }
67
+ else if (names.has('isCommaSeparatedStrings')) {
68
+ parameter.description = 'Comma-separated list of values';
69
+ }
70
+ if (names.has('isIso8601') ||
71
+ names.has('isDate') ||
72
+ names.has('isDateLike') ||
73
+ design === Date) {
74
+ parameter.type = 'string';
75
+ parameter.format = 'date-time';
76
+ parameter.description = 'ISO 8601 instant, such as 2026-08-22T14:03:00Z';
77
+ }
78
+ const allowed = find('isIn')?.constraints?.[0];
79
+ if (Array.isArray(allowed))
80
+ parameter.enum = allowed.map(String);
81
+ const minimum = asNumber(find('min')?.constraints?.[0]) ?? bounds?.min ?? (wholeNumber ? 0 : undefined);
82
+ if (minimum !== undefined)
83
+ parameter.minimum = minimum;
84
+ const maximum = asNumber(find('max')?.constraints?.[0]) ??
85
+ asNumber(wholeNumber?.constraints?.[0]) ??
86
+ bounds?.max;
87
+ if (maximum !== undefined)
88
+ parameter.maximum = maximum;
89
+ const lengthRule = find('maxLength');
90
+ const maxLength = asNumber(lengthRule?.constraints?.[0]);
91
+ if (maxLength !== undefined && lengthRule?.each === true && parameter.type === 'array') {
92
+ parameter.itemMaxLength = maxLength;
93
+ }
94
+ else if (maxLength !== undefined) {
95
+ parameter.maxLength = maxLength;
96
+ }
97
+ const itemMaxLength = asNumber(find('hasItemsOfMaxLength')?.constraints?.[0]);
98
+ if (itemMaxLength !== undefined)
99
+ parameter.itemMaxLength = itemMaxLength;
100
+ const minItems = asNumber(find('arrayMinSize')?.constraints?.[0]) ??
101
+ (names.has('arrayNotEmpty') || names.has('isNonEmptyListLike') ? 1 : undefined);
102
+ if (minItems !== undefined)
103
+ parameter.minItems = minItems;
104
+ const exclusive = find('isAbsentWith')?.constraints?.[0];
105
+ if (typeof exclusive === 'string')
106
+ exclusions.push([name, exclusive]);
107
+ const maxItems = asNumber((find('arrayMaxSize') ?? find('isCommaSeparatedStrings') ?? find('isCommaSeparatedList'))
108
+ ?.constraints?.[0]);
109
+ if (maxItems !== undefined)
110
+ parameter.maxItems = maxItems;
111
+ parameters.push(parameter);
112
+ }
113
+ const note = (name, other) => {
114
+ const parameter = parameters.find((candidate) => candidate.name === name);
115
+ if (!parameter)
116
+ return;
117
+ const sentence = `Not together with ${other}.`;
118
+ parameter.description = parameter.description
119
+ ? `${parameter.description}. ${sentence}`
120
+ : sentence;
121
+ };
122
+ for (const [name, other] of exclusions) {
123
+ note(name, other);
124
+ note(other, name);
125
+ }
126
+ return parameters.sort((a, b) => a.name.localeCompare(b.name));
127
+ };
128
+ exports.describeDto = describeDto;
@@ -0,0 +1,3 @@
1
+ export * from './tool.decorator';
2
+ export * from './tool-manifest';
3
+ export type { ToolParameter, ToolParameterType, ToolParameterLocation } from './dto-schema';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./tool.decorator"), exports);
18
+ __exportStar(require("./tool-manifest"), exports);
@@ -0,0 +1,47 @@
1
+ import { ToolParameter } from './dto-schema';
2
+ /**
3
+ * The keys Nest writes its route metadata under.
4
+ *
5
+ * Inlined rather than imported from `@nestjs/common/constants`, which is not
6
+ * part of the public API (the same reasoning as `HTTP_CODE_METADATA` in the
7
+ * response interceptor). `tool-manifest.spec.ts` asserts each still matches the
8
+ * framework's constant, so a rename fails a test and not every tool at once.
9
+ */
10
+ export declare const PATH_KEY = "path";
11
+ export declare const METHOD_KEY = "method";
12
+ export declare const ROUTE_ARGS_KEY = "__routeArguments__";
13
+ /** `RouteParamtypes` from `@nestjs/common/enums`, for the three kinds read here. */
14
+ export declare const PARAMTYPE_BODY = 3;
15
+ export declare const PARAMTYPE_QUERY = 4;
16
+ export declare const PARAMTYPE_PARAM = 5;
17
+ export type ToolHttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
18
+ export interface NestLensToolDescriptor {
19
+ /** The handler's method name in snake_case: stable, and one per handler. */
20
+ name: string;
21
+ description: string;
22
+ method: ToolHttpMethod;
23
+ /** Relative to the API root, with `:name` placeholders: `/entries/:id`. */
24
+ path: string;
25
+ /** Anything but a GET. Reading is always safe; this is not. */
26
+ mutates: boolean;
27
+ /** Cannot be undone. Only ever set on something that `mutates`. */
28
+ destructive: boolean;
29
+ parameters: ToolParameter[];
30
+ }
31
+ export interface NestLensToolManifest {
32
+ /** Bumped when the shape of a descriptor changes, so a client can refuse one it does not know. */
33
+ version: 1;
34
+ tools: NestLensToolDescriptor[];
35
+ }
36
+ type Controller = new (...args: never[]) => object;
37
+ export declare const toSnakeCase: (name: string) => string;
38
+ /**
39
+ * Everything the API offers as a tool, read from the controllers themselves.
40
+ *
41
+ * Built on request, from the live metadata, rather than kept as a list: a list
42
+ * is the thing that goes stale. Reading the controllers means the manifest is
43
+ * the API, so the MCP server that consumes it never has to be updated when an
44
+ * endpoint is added.
45
+ */
46
+ export declare const buildToolManifest: (controllers: readonly Controller[]) => NestLensToolManifest;
47
+ export {};
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildToolManifest = exports.toSnakeCase = exports.PARAMTYPE_PARAM = exports.PARAMTYPE_QUERY = exports.PARAMTYPE_BODY = exports.ROUTE_ARGS_KEY = exports.METHOD_KEY = exports.PATH_KEY = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const nestlens_config_1 = require("../../nestlens.config");
6
+ const dto_schema_1 = require("./dto-schema");
7
+ const tool_decorator_1 = require("./tool.decorator");
8
+ /**
9
+ * The keys Nest writes its route metadata under.
10
+ *
11
+ * Inlined rather than imported from `@nestjs/common/constants`, which is not
12
+ * part of the public API (the same reasoning as `HTTP_CODE_METADATA` in the
13
+ * response interceptor). `tool-manifest.spec.ts` asserts each still matches the
14
+ * framework's constant, so a rename fails a test and not every tool at once.
15
+ */
16
+ exports.PATH_KEY = 'path';
17
+ exports.METHOD_KEY = 'method';
18
+ exports.ROUTE_ARGS_KEY = '__routeArguments__';
19
+ /** `RouteParamtypes` from `@nestjs/common/enums`, for the three kinds read here. */
20
+ exports.PARAMTYPE_BODY = 3;
21
+ exports.PARAMTYPE_QUERY = 4;
22
+ exports.PARAMTYPE_PARAM = 5;
23
+ const METHODS = {
24
+ [common_1.RequestMethod.GET]: 'GET',
25
+ [common_1.RequestMethod.POST]: 'POST',
26
+ [common_1.RequestMethod.PUT]: 'PUT',
27
+ [common_1.RequestMethod.PATCH]: 'PATCH',
28
+ [common_1.RequestMethod.DELETE]: 'DELETE',
29
+ };
30
+ const toSnakeCase = (name) => name.replace(/([a-z0-9])([A-Z])/g, '$1_$2').toLowerCase();
31
+ exports.toSnakeCase = toSnakeCase;
32
+ const firstPath = (value) => {
33
+ const raw = Array.isArray(value) ? value[0] : value;
34
+ return typeof raw === 'string' ? raw : '';
35
+ };
36
+ const joinPath = (...parts) => {
37
+ const joined = parts
38
+ .map((part) => part.replace(/^\/+|\/+$/g, ''))
39
+ .filter((part) => part.length > 0)
40
+ .join('/');
41
+ return `/${joined}`;
42
+ };
43
+ /**
44
+ * Where the controller sits relative to the API root.
45
+ *
46
+ * The prefix is rewritten at runtime to follow `NestLensConfig.path` (see
47
+ * `NestLensModule.mountControllersAt`), so it is read here rather than assumed,
48
+ * and everything up to and including `__nestlens__/api` is dropped. What is
49
+ * left — nothing, or `tags` — is the same wherever NestLens is mounted, which
50
+ * is what lets a client know only the one URL.
51
+ */
52
+ const relativeControllerPath = (controller) => {
53
+ const full = firstPath(Reflect.getMetadata(exports.PATH_KEY, controller));
54
+ const marker = `${nestlens_config_1.NESTLENS_API_PREFIX}/api`;
55
+ // The last one: `path` may itself contain the marker, and the controller's own
56
+ // prefix is always appended after the mount.
57
+ const at = full.lastIndexOf(marker);
58
+ return at === -1 ? full : full.slice(at + marker.length);
59
+ };
60
+ const pathParameters = (target, handler, args) => {
61
+ const types = (Reflect.getMetadata('design:paramtypes', target, handler) ?? []);
62
+ const found = [];
63
+ for (const [key, argument] of Object.entries(args)) {
64
+ if (key.split(':')[0] !== String(exports.PARAMTYPE_PARAM) || !argument.data)
65
+ continue;
66
+ found.push({
67
+ name: argument.data,
68
+ in: 'path',
69
+ required: true,
70
+ type: types[argument.index] === Number ? 'integer' : 'string',
71
+ });
72
+ }
73
+ return found;
74
+ };
75
+ const dtoParameters = (target, handler, args, paramtype, location) => {
76
+ const types = (Reflect.getMetadata('design:paramtypes', target, handler) ?? []);
77
+ const found = [];
78
+ for (const [key, argument] of Object.entries(args)) {
79
+ if (key.split(':')[0] !== String(paramtype))
80
+ continue;
81
+ const dto = types[argument.index];
82
+ // `@Query() query: SomeDto` — every property of the class is a parameter.
83
+ if (!argument.data && typeof dto === 'function' && dto !== Object) {
84
+ found.push(...(0, dto_schema_1.describeDto)(dto, location));
85
+ }
86
+ }
87
+ return found;
88
+ };
89
+ const describeHandler = (controller, handler) => {
90
+ const target = controller.prototype;
91
+ const fn = target[handler];
92
+ if (typeof fn !== 'function')
93
+ return null;
94
+ const options = Reflect.getMetadata(tool_decorator_1.NESTLENS_TOOL_METADATA, fn);
95
+ if (!options)
96
+ return null;
97
+ const method = METHODS[Reflect.getMetadata(exports.METHOD_KEY, fn)];
98
+ if (!method) {
99
+ throw new Error(`${controller.name}.${handler} is a tool but not an HTTP route`);
100
+ }
101
+ const args = (Reflect.getMetadata(exports.ROUTE_ARGS_KEY, controller, handler) ?? {});
102
+ const mutates = method !== 'GET';
103
+ return {
104
+ name: (0, exports.toSnakeCase)(handler),
105
+ description: options.description,
106
+ method,
107
+ path: joinPath(relativeControllerPath(controller), firstPath(Reflect.getMetadata(exports.PATH_KEY, fn))),
108
+ mutates,
109
+ destructive: mutates && options.destructive === true,
110
+ parameters: [
111
+ ...pathParameters(target, handler, args),
112
+ ...dtoParameters(target, handler, args, exports.PARAMTYPE_QUERY, 'query'),
113
+ ...dtoParameters(target, handler, args, exports.PARAMTYPE_BODY, 'body'),
114
+ ],
115
+ };
116
+ };
117
+ /**
118
+ * Everything the API offers as a tool, read from the controllers themselves.
119
+ *
120
+ * Built on request, from the live metadata, rather than kept as a list: a list
121
+ * is the thing that goes stale. Reading the controllers means the manifest is
122
+ * the API, so the MCP server that consumes it never has to be updated when an
123
+ * endpoint is added.
124
+ */
125
+ const buildToolManifest = (controllers) => {
126
+ const tools = [];
127
+ const seen = new Set();
128
+ for (const controller of controllers) {
129
+ for (const handler of Object.getOwnPropertyNames(controller.prototype)) {
130
+ const descriptor = describeHandler(controller, handler);
131
+ if (!descriptor)
132
+ continue;
133
+ if (seen.has(descriptor.name)) {
134
+ throw new Error(`Two NestLens tools are named "${descriptor.name}"; rename one handler`);
135
+ }
136
+ seen.add(descriptor.name);
137
+ tools.push(descriptor);
138
+ }
139
+ }
140
+ return { version: 1, tools };
141
+ };
142
+ exports.buildToolManifest = buildToolManifest;
@@ -0,0 +1,34 @@
1
+ /** Where {@link NestLensTool} writes its options. */
2
+ export declare const NESTLENS_TOOL_METADATA = "nestlens:tool";
3
+ export interface NestLensToolOptions {
4
+ /**
5
+ * What the endpoint does, written for a reader that has never seen the
6
+ * dashboard — an AI agent choosing between tools by this sentence alone.
7
+ *
8
+ * Say what it returns or changes and when to reach for it. Parameter names,
9
+ * types, enums and bounds are read from the DTOs the handler already
10
+ * validates with, so do not repeat them here.
11
+ */
12
+ description: string;
13
+ /**
14
+ * The call cannot be undone — it deletes recorded entries or turns recording
15
+ * off. Every non-GET endpoint already counts as a change and stays behind the
16
+ * MCP server's `--allow-write`; this is the extra word that tells the reader
17
+ * it is not the reversible kind.
18
+ */
19
+ destructive?: boolean;
20
+ }
21
+ /**
22
+ * Publishes an API endpoint as a tool.
23
+ *
24
+ * `GET __nestlens__/api/tools` lists every handler that carries this decorator,
25
+ * with its route, its parameters and its description, and the `nestlens-mcp`
26
+ * server offers whatever that list holds. A new endpoint becomes a tool by being
27
+ * decorated — nothing in the MCP server changes — and
28
+ * `tools/tool-coverage.spec.ts` fails for a route that is neither decorated nor
29
+ * excluded on purpose, so it cannot be forgotten.
30
+ *
31
+ * The tool's name is the handler's method name in snake_case (`getEntries` →
32
+ * `get_entries`), which keeps one name for one handler.
33
+ */
34
+ export declare const NestLensTool: (options: NestLensToolOptions) => MethodDecorator;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NestLensTool = exports.NESTLENS_TOOL_METADATA = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ /** Where {@link NestLensTool} writes its options. */
6
+ exports.NESTLENS_TOOL_METADATA = 'nestlens:tool';
7
+ /**
8
+ * Publishes an API endpoint as a tool.
9
+ *
10
+ * `GET __nestlens__/api/tools` lists every handler that carries this decorator,
11
+ * with its route, its parameters and its description, and the `nestlens-mcp`
12
+ * server offers whatever that list holds. A new endpoint becomes a tool by being
13
+ * decorated — nothing in the MCP server changes — and
14
+ * `tools/tool-coverage.spec.ts` fails for a route that is neither decorated nor
15
+ * excluded on purpose, so it cannot be forgotten.
16
+ *
17
+ * The tool's name is the handler's method name in snake_case (`getEntries` →
18
+ * `get_entries`), which keeps one name for one handler.
19
+ */
20
+ const NestLensTool = (options) => (0, common_1.SetMetadata)(exports.NESTLENS_TOOL_METADATA, options);
21
+ exports.NestLensTool = NestLensTool;
@@ -1 +1 @@
1
- import{j as e,L as o,A as y,C as u}from"./index-CC9YqlAO.js";import{p as n,f as v}from"./date-Dwgqy666.js";import{D as r,f as k}from"./DetailRow-BX0zpKTe.js";import{C as m}from"./types-7eWhJMm7.js";import{C as w}from"./CopyButton-8NQFvMIW.js";import{C as g}from"./circle-x-C5FZ5L0I.js";import{C as j}from"./circle-alert-3qwz1WcZ.js";import{C}from"./circle-check-big-DcP6kxnu.js";import"./vendor-DBTT3jXp.js";import"./EntryDetailPage-NLzBL3a7.js";import"./search-DlyuMX5Q.js";const p={completed:{icon:C,color:"text-green-500",bg:"bg-green-100 dark:bg-green-900/30"},partial:{icon:j,color:"text-yellow-500",bg:"bg-yellow-100 dark:bg-yellow-900/30"},failed:{icon:g,color:"text-red-500",bg:"bg-red-100 dark:bg-red-900/30"}};function h(a){return a?a<1024?`${a}B`:a<1024*1024?`${(a/1024).toFixed(1)}KB`:a<1024*1024*1024?`${(a/(1024*1024)).toFixed(1)}MB`:`${(a/(1024*1024*1024)).toFixed(1)}GB`:"-"}function E({entry:a}){const{payload:s,createdAt:c}=a,t=p[s.status]||p.completed,f=t.icon,{processedItems:x,totalItems:d,failedItems:l}=s,i=d>0?Math.round(x/d*100):0;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:`p-2 ${t.bg} rounded-lg`,children:e.jsx(o,{className:`h-5 w-5 ${t.color}`})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white font-mono",children:s.name}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Batch Operation"})]})]}),e.jsx(w,{text:s.name,label:"Copy batch name"})]})}),e.jsxs("div",{className:`grid ${s.memory!==void 0?"grid-cols-2 md:grid-cols-5":"grid-cols-2 md:grid-cols-4"} divide-x divide-gray-200 dark:divide-gray-700`,children:[e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx(f,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Status"})]}),e.jsx("p",{className:`text-lg font-bold ${t.color}`,children:s.status.toUpperCase()})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx(y,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Progress"})]}),e.jsxs("p",{className:"text-lg font-bold text-gray-900 dark:text-white",children:[i,e.jsx("span",{className:"text-sm font-normal text-gray-500 dark:text-gray-400",children:"%"})]})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx(u,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Duration"})]}),e.jsxs("p",{className:"text-lg font-bold text-gray-900 dark:text-white",children:[s.duration,e.jsx("span",{className:"text-sm font-normal text-gray-500 dark:text-gray-400",children:"ms"})]})]}),l>0&&e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx(g,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Failed"})]}),e.jsx("p",{className:"text-lg font-bold text-red-600 dark:text-red-400",children:l})]}),s.memory!==void 0&&e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx(o,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Memory"})]}),e.jsx("p",{className:"text-lg font-bold text-gray-900 dark:text-white",children:h(s.memory)})]})]})]}),e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700",children:e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Details"})}),e.jsx("div",{className:"p-4",children:e.jsxs("dl",{className:"divide-y-0",children:[e.jsx(r,{label:"Time",value:e.jsxs("span",{children:[k(n(c),"MMMM do yyyy, h:mm:ss a")," ",e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["(",v(n(c),{addSuffix:!0}),")"]})]})}),e.jsx(r,{label:"Name",value:e.jsx("code",{className:"text-sm font-mono text-gray-900 dark:text-white",children:s.name})}),s.operation&&e.jsx(r,{label:"Operation",value:e.jsx(m,{listType:"batches",filterType:"operations",filterValue:s.operation,children:s.operation})}),e.jsx(r,{label:"Status",value:e.jsx(m,{listType:"batches",filterType:"statuses",filterValue:s.status,children:s.status.toUpperCase()})}),e.jsx(r,{label:"Progress",value:e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm font-mono",children:[x," / ",d," (",i,"%)"]}),e.jsx("div",{className:"mt-2 w-full bg-gray-200 dark:bg-gray-700 rounded-full h-2",children:e.jsx("div",{className:"bg-blue-600 dark:bg-blue-500 h-2 rounded-full transition-all",style:{width:`${i}%`}})})]})}),l>0&&e.jsx(r,{label:"Failed Items",value:e.jsx("span",{className:"text-red-600 dark:text-red-400 font-mono",children:l})}),e.jsx(r,{label:"Duration",value:`${s.duration}ms`}),s.batchSize&&e.jsx(r,{label:"Batch Size",value:s.batchSize}),s.memory!==void 0&&e.jsx(r,{label:"Memory",value:h(s.memory)})]})})]}),s.errors&&s.errors.length>0&&e.jsxs("div",{className:"card border-red-200 dark:border-red-800",children:[e.jsx("div",{className:"px-4 py-3 border-b border-red-200 dark:border-red-800 bg-red-50 dark:bg-red-900/20",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(j,{className:"h-5 w-5 text-red-500"}),e.jsxs("h2",{className:"text-lg font-semibold text-red-700 dark:text-red-400",children:["Errors (",s.errors.length,")"]})]})}),e.jsx("div",{className:"divide-y divide-red-200 dark:divide-red-800",children:s.errors.map((N,b)=>e.jsx("div",{className:"p-4 bg-red-50/50 dark:bg-red-900/10",children:e.jsx("pre",{className:"text-sm text-red-600 dark:text-red-400 font-mono whitespace-pre-wrap overflow-x-auto",children:N})},b))})]})]})}export{E as default};
1
+ import{j as e,L as o,A as y,C as u}from"./index-B4Yux9BN.js";import{p as n,f as v}from"./date-Dwgqy666.js";import{D as r,f as k}from"./DetailRow-BsKUo5E1.js";import{C as m}from"./types-kls_XDEv.js";import{C as w}from"./CopyButton-Cp_IPU2R.js";import{C as g}from"./circle-x-DH6akMMo.js";import{C as j}from"./circle-alert-sfiVJoqG.js";import{C}from"./circle-check-big-rPcvWaGG.js";import"./vendor-DBTT3jXp.js";import"./EntryDetailPage-DSpdTWDw.js";import"./search-CEpvfCX1.js";const p={completed:{icon:C,color:"text-green-500",bg:"bg-green-100 dark:bg-green-900/30"},partial:{icon:j,color:"text-yellow-500",bg:"bg-yellow-100 dark:bg-yellow-900/30"},failed:{icon:g,color:"text-red-500",bg:"bg-red-100 dark:bg-red-900/30"}};function h(a){return a?a<1024?`${a}B`:a<1024*1024?`${(a/1024).toFixed(1)}KB`:a<1024*1024*1024?`${(a/(1024*1024)).toFixed(1)}MB`:`${(a/(1024*1024*1024)).toFixed(1)}GB`:"-"}function E({entry:a}){const{payload:s,createdAt:c}=a,t=p[s.status]||p.completed,f=t.icon,{processedItems:x,totalItems:d,failedItems:l}=s,i=d>0?Math.round(x/d*100):0;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:`p-2 ${t.bg} rounded-lg`,children:e.jsx(o,{className:`h-5 w-5 ${t.color}`})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white font-mono",children:s.name}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Batch Operation"})]})]}),e.jsx(w,{text:s.name,label:"Copy batch name"})]})}),e.jsxs("div",{className:`grid ${s.memory!==void 0?"grid-cols-2 md:grid-cols-5":"grid-cols-2 md:grid-cols-4"} divide-x divide-gray-200 dark:divide-gray-700`,children:[e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx(f,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Status"})]}),e.jsx("p",{className:`text-lg font-bold ${t.color}`,children:s.status.toUpperCase()})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx(y,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Progress"})]}),e.jsxs("p",{className:"text-lg font-bold text-gray-900 dark:text-white",children:[i,e.jsx("span",{className:"text-sm font-normal text-gray-500 dark:text-gray-400",children:"%"})]})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx(u,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Duration"})]}),e.jsxs("p",{className:"text-lg font-bold text-gray-900 dark:text-white",children:[s.duration,e.jsx("span",{className:"text-sm font-normal text-gray-500 dark:text-gray-400",children:"ms"})]})]}),l>0&&e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx(g,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Failed"})]}),e.jsx("p",{className:"text-lg font-bold text-red-600 dark:text-red-400",children:l})]}),s.memory!==void 0&&e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"flex items-center space-x-2 text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx(o,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs uppercase tracking-wider",children:"Memory"})]}),e.jsx("p",{className:"text-lg font-bold text-gray-900 dark:text-white",children:h(s.memory)})]})]})]}),e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700",children:e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Details"})}),e.jsx("div",{className:"p-4",children:e.jsxs("dl",{className:"divide-y-0",children:[e.jsx(r,{label:"Time",value:e.jsxs("span",{children:[k(n(c),"MMMM do yyyy, h:mm:ss a")," ",e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["(",v(n(c),{addSuffix:!0}),")"]})]})}),e.jsx(r,{label:"Name",value:e.jsx("code",{className:"text-sm font-mono text-gray-900 dark:text-white",children:s.name})}),s.operation&&e.jsx(r,{label:"Operation",value:e.jsx(m,{listType:"batches",filterType:"operations",filterValue:s.operation,children:s.operation})}),e.jsx(r,{label:"Status",value:e.jsx(m,{listType:"batches",filterType:"statuses",filterValue:s.status,children:s.status.toUpperCase()})}),e.jsx(r,{label:"Progress",value:e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm font-mono",children:[x," / ",d," (",i,"%)"]}),e.jsx("div",{className:"mt-2 w-full bg-gray-200 dark:bg-gray-700 rounded-full h-2",children:e.jsx("div",{className:"bg-blue-600 dark:bg-blue-500 h-2 rounded-full transition-all",style:{width:`${i}%`}})})]})}),l>0&&e.jsx(r,{label:"Failed Items",value:e.jsx("span",{className:"text-red-600 dark:text-red-400 font-mono",children:l})}),e.jsx(r,{label:"Duration",value:`${s.duration}ms`}),s.batchSize&&e.jsx(r,{label:"Batch Size",value:s.batchSize}),s.memory!==void 0&&e.jsx(r,{label:"Memory",value:h(s.memory)})]})})]}),s.errors&&s.errors.length>0&&e.jsxs("div",{className:"card border-red-200 dark:border-red-800",children:[e.jsx("div",{className:"px-4 py-3 border-b border-red-200 dark:border-red-800 bg-red-50 dark:bg-red-900/20",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(j,{className:"h-5 w-5 text-red-500"}),e.jsxs("h2",{className:"text-lg font-semibold text-red-700 dark:text-red-400",children:["Errors (",s.errors.length,")"]})]})}),e.jsx("div",{className:"divide-y divide-red-200 dark:divide-red-800",children:s.errors.map((N,b)=>e.jsx("div",{className:"p-4 bg-red-50/50 dark:bg-red-900/10",children:e.jsx("pre",{className:"text-sm text-red-600 dark:text-red-400 font-mono whitespace-pre-wrap overflow-x-auto",children:N})},b))})]})]})}export{E as default};