@pikku/inspector 0.12.10 → 0.12.12
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/CHANGELOG.md +21 -9
- package/dist/add/add-cli.js +10 -3
- package/dist/add/add-credential.js +2 -1
- package/dist/add/add-functions.js +99 -5
- package/dist/add/add-http-route.js +44 -6
- package/dist/add/add-keyed-wiring.js +3 -1
- package/dist/add/add-middleware.js +33 -4
- package/dist/add/add-permission.js +7 -7
- package/dist/add/add-workflow-graph.js +20 -1
- package/dist/error-codes.d.ts +2 -0
- package/dist/error-codes.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/inspector.js +2 -5
- package/dist/types.d.ts +10 -19
- package/dist/utils/extract-function-name.js +6 -0
- package/dist/utils/filter-inspector-state.js +187 -59
- package/dist/utils/filter-utils.js +13 -5
- package/dist/utils/get-property-value.d.ts +10 -0
- package/dist/utils/get-property-value.js +30 -0
- package/dist/utils/post-process.d.ts +2 -3
- package/dist/utils/post-process.js +3 -23
- package/dist/utils/resolve-addon-package.d.ts +4 -5
- package/dist/utils/resolve-addon-package.js +64 -16
- package/dist/utils/resolve-deploy-target.d.ts +28 -0
- package/dist/utils/resolve-deploy-target.js +56 -0
- package/dist/utils/resolve-versions.js +79 -0
- package/dist/utils/schema-generator.js +31 -12
- package/dist/utils/validate-auth-sessionless.d.ts +1 -1
- package/package.json +2 -2
- package/src/add/add-cli.ts +10 -3
- package/src/add/add-credential.ts +3 -0
- package/src/add/add-functions.test.ts +318 -0
- package/src/add/add-functions.ts +164 -6
- package/src/add/add-gateway.ts +5 -1
- package/src/add/add-http-route.ts +54 -7
- package/src/add/add-keyed-wiring.ts +7 -1
- package/src/add/add-mcp-prompt.ts +5 -1
- package/src/add/add-mcp-resource.ts +5 -1
- package/src/add/add-middleware.ts +42 -4
- package/src/add/add-permission.ts +7 -7
- package/src/add/add-schedule.ts +5 -1
- package/src/add/add-workflow-graph.ts +19 -1
- package/src/add/wire-name-literal.test.ts +114 -0
- package/src/error-codes.ts +2 -0
- package/src/index.ts +1 -0
- package/src/inspector.ts +1 -5
- package/src/types.ts +19 -15
- package/src/utils/extract-function-name.ts +8 -0
- package/src/utils/filter-inspector-state.test.ts +168 -64
- package/src/utils/filter-inspector-state.ts +290 -64
- package/src/utils/filter-utils.test.ts +30 -15
- package/src/utils/filter-utils.ts +14 -5
- package/src/utils/get-property-value.ts +40 -0
- package/src/utils/post-process.ts +3 -38
- package/src/utils/resolve-addon-package.ts +65 -14
- package/src/utils/resolve-deploy-target.test.ts +105 -0
- package/src/utils/resolve-deploy-target.ts +63 -0
- package/src/utils/resolve-versions.test.ts +108 -0
- package/src/utils/resolve-versions.ts +86 -0
- package/src/utils/schema-generator.ts +37 -13
- package/src/utils/validate-auth-sessionless.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -147,6 +147,10 @@ function createMockInspectorState(): Omit<InspectorState, 'typesLookup'> {
|
|
|
147
147
|
],
|
|
148
148
|
]),
|
|
149
149
|
},
|
|
150
|
+
triggers: {
|
|
151
|
+
meta: {},
|
|
152
|
+
files: new Set(),
|
|
153
|
+
},
|
|
150
154
|
channels: {
|
|
151
155
|
meta: {
|
|
152
156
|
'chat-channel': {
|
|
@@ -154,15 +158,20 @@ function createMockInspectorState(): Omit<InspectorState, 'typesLookup'> {
|
|
|
154
158
|
tags: ['realtime', 'public'],
|
|
155
159
|
middleware: [],
|
|
156
160
|
permissions: [],
|
|
157
|
-
|
|
161
|
+
sourceFile: '/test/project/src/channels/chat.ts',
|
|
162
|
+
} as any,
|
|
158
163
|
'admin-channel': {
|
|
159
164
|
pikkuFuncId: 'handleAdminMessage',
|
|
160
165
|
tags: ['realtime', 'admin'],
|
|
161
166
|
middleware: [{ type: 'wire', name: 'authMiddleware' }],
|
|
162
167
|
permissions: [],
|
|
163
|
-
|
|
168
|
+
sourceFile: '/test/project/src/channels/admin.ts',
|
|
169
|
+
} as any,
|
|
164
170
|
},
|
|
165
|
-
files: new Set([
|
|
171
|
+
files: new Set([
|
|
172
|
+
'/test/project/src/channels/chat.ts',
|
|
173
|
+
'/test/project/src/channels/admin.ts',
|
|
174
|
+
]),
|
|
166
175
|
},
|
|
167
176
|
scheduledTasks: {
|
|
168
177
|
meta: {
|
|
@@ -171,15 +180,20 @@ function createMockInspectorState(): Omit<InspectorState, 'typesLookup'> {
|
|
|
171
180
|
schedule: '0 0 * * *',
|
|
172
181
|
tags: ['cron', 'reports'],
|
|
173
182
|
middleware: [],
|
|
174
|
-
|
|
183
|
+
sourceFile: '/test/project/src/tasks/reports.ts',
|
|
184
|
+
} as any,
|
|
175
185
|
'hourly-cleanup': {
|
|
176
186
|
pikkuFuncId: 'hourlyCleanup',
|
|
177
187
|
schedule: '0 * * * *',
|
|
178
188
|
tags: ['cron', 'maintenance'],
|
|
179
189
|
middleware: [],
|
|
180
|
-
|
|
190
|
+
sourceFile: '/test/project/src/tasks/cleanup.ts',
|
|
191
|
+
} as any,
|
|
181
192
|
},
|
|
182
|
-
files: new Set([
|
|
193
|
+
files: new Set([
|
|
194
|
+
'/test/project/src/tasks/reports.ts',
|
|
195
|
+
'/test/project/src/tasks/cleanup.ts',
|
|
196
|
+
]),
|
|
183
197
|
},
|
|
184
198
|
queueWorkers: {
|
|
185
199
|
meta: {
|
|
@@ -188,15 +202,20 @@ function createMockInspectorState(): Omit<InspectorState, 'typesLookup'> {
|
|
|
188
202
|
name: 'email-queue',
|
|
189
203
|
tags: ['queue', 'email'],
|
|
190
204
|
middleware: [],
|
|
191
|
-
|
|
205
|
+
sourceFile: '/test/project/src/workers/email.ts',
|
|
206
|
+
} as any,
|
|
192
207
|
'notification-worker': {
|
|
193
208
|
pikkuFuncId: 'sendNotificationWorker',
|
|
194
209
|
name: 'notification-queue',
|
|
195
210
|
tags: ['queue', 'notifications'],
|
|
196
211
|
middleware: [],
|
|
197
|
-
|
|
212
|
+
sourceFile: '/test/project/src/workers/notification.ts',
|
|
213
|
+
} as any,
|
|
198
214
|
},
|
|
199
|
-
files: new Set([
|
|
215
|
+
files: new Set([
|
|
216
|
+
'/test/project/src/workers/email.ts',
|
|
217
|
+
'/test/project/src/workers/notification.ts',
|
|
218
|
+
]),
|
|
200
219
|
},
|
|
201
220
|
workflows: {
|
|
202
221
|
meta: {},
|
|
@@ -221,6 +240,7 @@ function createMockInspectorState(): Omit<InspectorState, 'typesLookup'> {
|
|
|
221
240
|
tags: ['mcp', 'search'],
|
|
222
241
|
middleware: [],
|
|
223
242
|
permissions: [],
|
|
243
|
+
sourceFile: '/test/project/src/mcp/search.ts',
|
|
224
244
|
} as any,
|
|
225
245
|
'analyze-tool': {
|
|
226
246
|
name: 'analyze-tool',
|
|
@@ -229,6 +249,7 @@ function createMockInspectorState(): Omit<InspectorState, 'typesLookup'> {
|
|
|
229
249
|
tags: ['mcp', 'analytics'],
|
|
230
250
|
middleware: [],
|
|
231
251
|
permissions: [],
|
|
252
|
+
sourceFile: '/test/project/src/mcp/analyze.ts',
|
|
232
253
|
} as any,
|
|
233
254
|
},
|
|
234
255
|
resourcesMeta: {
|
|
@@ -240,6 +261,7 @@ function createMockInspectorState(): Omit<InspectorState, 'typesLookup'> {
|
|
|
240
261
|
tags: ['mcp', 'docs'],
|
|
241
262
|
middleware: [],
|
|
242
263
|
permissions: [],
|
|
264
|
+
sourceFile: '/test/project/src/mcp/docs.ts',
|
|
243
265
|
} as any,
|
|
244
266
|
},
|
|
245
267
|
promptsMeta: {
|
|
@@ -250,14 +272,21 @@ function createMockInspectorState(): Omit<InspectorState, 'typesLookup'> {
|
|
|
250
272
|
tags: ['mcp', 'help'],
|
|
251
273
|
middleware: [],
|
|
252
274
|
permissions: [],
|
|
275
|
+
sourceFile: '/test/project/src/mcp/help.ts',
|
|
253
276
|
} as any,
|
|
254
277
|
},
|
|
255
|
-
files: new Set([
|
|
278
|
+
files: new Set([
|
|
279
|
+
'/test/project/src/mcp/search.ts',
|
|
280
|
+
'/test/project/src/mcp/analyze.ts',
|
|
281
|
+
'/test/project/src/mcp/docs.ts',
|
|
282
|
+
'/test/project/src/mcp/help.ts',
|
|
283
|
+
]),
|
|
256
284
|
},
|
|
257
285
|
cli: {
|
|
258
286
|
meta: {
|
|
259
287
|
programs: {
|
|
260
288
|
'my-cli': {
|
|
289
|
+
sourceFile: '/test/project/src/cli/program.ts',
|
|
261
290
|
commands: {
|
|
262
291
|
build: {
|
|
263
292
|
pikkuFuncId: 'cliCommand',
|
|
@@ -265,6 +294,7 @@ function createMockInspectorState(): Omit<InspectorState, 'typesLookup'> {
|
|
|
265
294
|
middleware: [],
|
|
266
295
|
positionals: [],
|
|
267
296
|
options: {},
|
|
297
|
+
sourceFile: '/test/project/src/cli/build.ts',
|
|
268
298
|
} as any,
|
|
269
299
|
test: {
|
|
270
300
|
pikkuFuncId: 'cliTestCommand',
|
|
@@ -272,12 +302,17 @@ function createMockInspectorState(): Omit<InspectorState, 'typesLookup'> {
|
|
|
272
302
|
middleware: [],
|
|
273
303
|
positionals: [],
|
|
274
304
|
options: {},
|
|
305
|
+
sourceFile: '/test/project/src/cli/test.ts',
|
|
275
306
|
} as any,
|
|
276
307
|
},
|
|
277
|
-
},
|
|
308
|
+
} as any,
|
|
278
309
|
},
|
|
279
310
|
},
|
|
280
|
-
files: new Set([
|
|
311
|
+
files: new Set([
|
|
312
|
+
'/test/project/src/cli/program.ts',
|
|
313
|
+
'/test/project/src/cli/build.ts',
|
|
314
|
+
'/test/project/src/cli/test.ts',
|
|
315
|
+
]),
|
|
281
316
|
},
|
|
282
317
|
middleware: {
|
|
283
318
|
definitions: {},
|
|
@@ -329,7 +364,7 @@ describe('filterInspectorState', () => {
|
|
|
329
364
|
const filters: InspectorFilters = {
|
|
330
365
|
names: [],
|
|
331
366
|
tags: [],
|
|
332
|
-
|
|
367
|
+
wires: [],
|
|
333
368
|
directories: [],
|
|
334
369
|
httpRoutes: [],
|
|
335
370
|
httpMethods: [],
|
|
@@ -345,7 +380,7 @@ describe('filterInspectorState', () => {
|
|
|
345
380
|
test('should filter HTTP routes by type', () => {
|
|
346
381
|
const state = createMockInspectorState()
|
|
347
382
|
const filters: InspectorFilters = {
|
|
348
|
-
|
|
383
|
+
wires: ['channel'], // Only channels, not HTTP
|
|
349
384
|
}
|
|
350
385
|
|
|
351
386
|
const result = filterInspectorState(state, filters, mockLogger)
|
|
@@ -361,7 +396,7 @@ describe('filterInspectorState', () => {
|
|
|
361
396
|
test('should filter HTTP routes by tags', () => {
|
|
362
397
|
const state = createMockInspectorState()
|
|
363
398
|
const filters: InspectorFilters = {
|
|
364
|
-
|
|
399
|
+
wires: ['http'],
|
|
365
400
|
tags: ['admin'],
|
|
366
401
|
}
|
|
367
402
|
|
|
@@ -403,7 +438,7 @@ describe('filterInspectorState', () => {
|
|
|
403
438
|
test('should filter HTTP routes by directory', () => {
|
|
404
439
|
const state = createMockInspectorState()
|
|
405
440
|
const filters: InspectorFilters = {
|
|
406
|
-
|
|
441
|
+
wires: ['http'],
|
|
407
442
|
directories: ['src/admin'],
|
|
408
443
|
}
|
|
409
444
|
|
|
@@ -417,7 +452,7 @@ describe('filterInspectorState', () => {
|
|
|
417
452
|
test('should filter HTTP routes by function name', () => {
|
|
418
453
|
const state = createMockInspectorState()
|
|
419
454
|
const filters: InspectorFilters = {
|
|
420
|
-
|
|
455
|
+
wires: ['http'],
|
|
421
456
|
names: ['getUsers'],
|
|
422
457
|
}
|
|
423
458
|
|
|
@@ -431,7 +466,7 @@ describe('filterInspectorState', () => {
|
|
|
431
466
|
test('should filter HTTP routes by name wildcard', () => {
|
|
432
467
|
const state = createMockInspectorState()
|
|
433
468
|
const filters: InspectorFilters = {
|
|
434
|
-
|
|
469
|
+
wires: ['http'],
|
|
435
470
|
names: ['get*'],
|
|
436
471
|
}
|
|
437
472
|
|
|
@@ -445,7 +480,7 @@ describe('filterInspectorState', () => {
|
|
|
445
480
|
test('should track middleware and permissions for filtered HTTP routes', () => {
|
|
446
481
|
const state = createMockInspectorState()
|
|
447
482
|
const filters: InspectorFilters = {
|
|
448
|
-
|
|
483
|
+
wires: ['http'],
|
|
449
484
|
tags: ['admin'],
|
|
450
485
|
}
|
|
451
486
|
|
|
@@ -464,7 +499,7 @@ describe('filterInspectorState', () => {
|
|
|
464
499
|
test('should filter channels by type', () => {
|
|
465
500
|
const state = createMockInspectorState()
|
|
466
501
|
const filters: InspectorFilters = {
|
|
467
|
-
|
|
502
|
+
wires: ['channel'],
|
|
468
503
|
}
|
|
469
504
|
|
|
470
505
|
const result = filterInspectorState(state, filters, mockLogger)
|
|
@@ -480,7 +515,7 @@ describe('filterInspectorState', () => {
|
|
|
480
515
|
test('should filter channels by tags', () => {
|
|
481
516
|
const state = createMockInspectorState()
|
|
482
517
|
const filters: InspectorFilters = {
|
|
483
|
-
|
|
518
|
+
wires: ['channel'],
|
|
484
519
|
tags: ['admin'],
|
|
485
520
|
}
|
|
486
521
|
|
|
@@ -513,19 +548,18 @@ describe('filterInspectorState', () => {
|
|
|
513
548
|
assert.equal(Object.keys(result.channels.meta).length, 2)
|
|
514
549
|
})
|
|
515
550
|
|
|
516
|
-
test('should
|
|
551
|
+
test('should repopulate channel files from surviving metadata', () => {
|
|
517
552
|
const state = createMockInspectorState()
|
|
518
553
|
const filters: InspectorFilters = {
|
|
519
|
-
|
|
554
|
+
wires: ['channel'],
|
|
520
555
|
tags: ['admin'],
|
|
521
556
|
}
|
|
522
557
|
|
|
523
558
|
const result = filterInspectorState(state, filters, mockLogger)
|
|
524
559
|
|
|
525
|
-
assert.
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
)
|
|
560
|
+
assert.deepEqual(Array.from(result.channels.files).sort(), [
|
|
561
|
+
'/test/project/src/channels/admin.ts',
|
|
562
|
+
])
|
|
529
563
|
})
|
|
530
564
|
})
|
|
531
565
|
|
|
@@ -533,7 +567,7 @@ describe('filterInspectorState', () => {
|
|
|
533
567
|
test('should filter scheduled tasks by type', () => {
|
|
534
568
|
const state = createMockInspectorState()
|
|
535
569
|
const filters: InspectorFilters = {
|
|
536
|
-
|
|
570
|
+
wires: ['scheduler'],
|
|
537
571
|
}
|
|
538
572
|
|
|
539
573
|
const result = filterInspectorState(state, filters, mockLogger)
|
|
@@ -548,7 +582,7 @@ describe('filterInspectorState', () => {
|
|
|
548
582
|
test('should filter scheduled tasks by tags', () => {
|
|
549
583
|
const state = createMockInspectorState()
|
|
550
584
|
const filters: InspectorFilters = {
|
|
551
|
-
|
|
585
|
+
wires: ['scheduler'],
|
|
552
586
|
tags: ['reports'],
|
|
553
587
|
}
|
|
554
588
|
|
|
@@ -582,16 +616,18 @@ describe('filterInspectorState', () => {
|
|
|
582
616
|
assert.ok(result.scheduledTasks.meta['hourly-cleanup'])
|
|
583
617
|
})
|
|
584
618
|
|
|
585
|
-
test('should
|
|
619
|
+
test('should repopulate scheduled task files from surviving metadata', () => {
|
|
586
620
|
const state = createMockInspectorState()
|
|
587
621
|
const filters: InspectorFilters = {
|
|
588
|
-
|
|
622
|
+
wires: ['scheduler'],
|
|
589
623
|
tags: ['reports'],
|
|
590
624
|
}
|
|
591
625
|
|
|
592
626
|
const result = filterInspectorState(state, filters, mockLogger)
|
|
593
627
|
|
|
594
|
-
assert.
|
|
628
|
+
assert.deepEqual(Array.from(result.scheduledTasks.files).sort(), [
|
|
629
|
+
'/test/project/src/tasks/reports.ts',
|
|
630
|
+
])
|
|
595
631
|
})
|
|
596
632
|
})
|
|
597
633
|
|
|
@@ -599,7 +635,7 @@ describe('filterInspectorState', () => {
|
|
|
599
635
|
test('should filter queue workers by type', () => {
|
|
600
636
|
const state = createMockInspectorState()
|
|
601
637
|
const filters: InspectorFilters = {
|
|
602
|
-
|
|
638
|
+
wires: ['queue'],
|
|
603
639
|
}
|
|
604
640
|
|
|
605
641
|
const result = filterInspectorState(state, filters, mockLogger)
|
|
@@ -614,7 +650,7 @@ describe('filterInspectorState', () => {
|
|
|
614
650
|
test('should filter queue workers by tags', () => {
|
|
615
651
|
const state = createMockInspectorState()
|
|
616
652
|
const filters: InspectorFilters = {
|
|
617
|
-
|
|
653
|
+
wires: ['queue'],
|
|
618
654
|
tags: ['email'],
|
|
619
655
|
}
|
|
620
656
|
|
|
@@ -647,16 +683,18 @@ describe('filterInspectorState', () => {
|
|
|
647
683
|
assert.equal(Object.keys(result.queueWorkers.meta).length, 2)
|
|
648
684
|
})
|
|
649
685
|
|
|
650
|
-
test('should
|
|
686
|
+
test('should repopulate queue worker files from surviving metadata', () => {
|
|
651
687
|
const state = createMockInspectorState()
|
|
652
688
|
const filters: InspectorFilters = {
|
|
653
|
-
|
|
689
|
+
wires: ['queue'],
|
|
654
690
|
tags: ['email'],
|
|
655
691
|
}
|
|
656
692
|
|
|
657
693
|
const result = filterInspectorState(state, filters, mockLogger)
|
|
658
694
|
|
|
659
|
-
assert.
|
|
695
|
+
assert.deepEqual(Array.from(result.queueWorkers.files).sort(), [
|
|
696
|
+
'/test/project/src/workers/email.ts',
|
|
697
|
+
])
|
|
660
698
|
})
|
|
661
699
|
})
|
|
662
700
|
|
|
@@ -664,7 +702,7 @@ describe('filterInspectorState', () => {
|
|
|
664
702
|
test('should filter MCP tools by type', () => {
|
|
665
703
|
const state = createMockInspectorState()
|
|
666
704
|
const filters: InspectorFilters = {
|
|
667
|
-
|
|
705
|
+
wires: ['mcp'],
|
|
668
706
|
}
|
|
669
707
|
|
|
670
708
|
const result = filterInspectorState(state, filters, mockLogger)
|
|
@@ -680,7 +718,7 @@ describe('filterInspectorState', () => {
|
|
|
680
718
|
test('should filter MCP endpoints by tags', () => {
|
|
681
719
|
const state = createMockInspectorState()
|
|
682
720
|
const filters: InspectorFilters = {
|
|
683
|
-
|
|
721
|
+
wires: ['mcp'],
|
|
684
722
|
tags: ['search'],
|
|
685
723
|
}
|
|
686
724
|
|
|
@@ -716,16 +754,18 @@ describe('filterInspectorState', () => {
|
|
|
716
754
|
assert.equal(Object.keys(result.mcpEndpoints.promptsMeta).length, 0)
|
|
717
755
|
})
|
|
718
756
|
|
|
719
|
-
test('should
|
|
757
|
+
test('should repopulate MCP files from surviving metadata', () => {
|
|
720
758
|
const state = createMockInspectorState()
|
|
721
759
|
const filters: InspectorFilters = {
|
|
722
|
-
|
|
760
|
+
wires: ['mcp'],
|
|
723
761
|
tags: ['search'],
|
|
724
762
|
}
|
|
725
763
|
|
|
726
764
|
const result = filterInspectorState(state, filters, mockLogger)
|
|
727
765
|
|
|
728
|
-
assert.
|
|
766
|
+
assert.deepEqual(Array.from(result.mcpEndpoints.files).sort(), [
|
|
767
|
+
'/test/project/src/mcp/search.ts',
|
|
768
|
+
])
|
|
729
769
|
})
|
|
730
770
|
})
|
|
731
771
|
|
|
@@ -733,7 +773,7 @@ describe('filterInspectorState', () => {
|
|
|
733
773
|
test('should filter CLI commands by type', () => {
|
|
734
774
|
const state = createMockInspectorState()
|
|
735
775
|
const filters: InspectorFilters = {
|
|
736
|
-
|
|
776
|
+
wires: ['cli'],
|
|
737
777
|
}
|
|
738
778
|
|
|
739
779
|
const result = filterInspectorState(state, filters, mockLogger)
|
|
@@ -750,7 +790,7 @@ describe('filterInspectorState', () => {
|
|
|
750
790
|
test('should filter CLI commands by tags', () => {
|
|
751
791
|
const state = createMockInspectorState()
|
|
752
792
|
const filters: InspectorFilters = {
|
|
753
|
-
|
|
793
|
+
wires: ['cli'],
|
|
754
794
|
tags: ['build'],
|
|
755
795
|
}
|
|
756
796
|
|
|
@@ -781,7 +821,7 @@ describe('filterInspectorState', () => {
|
|
|
781
821
|
test('should remove program if all commands are filtered out', () => {
|
|
782
822
|
const state = createMockInspectorState()
|
|
783
823
|
const filters: InspectorFilters = {
|
|
784
|
-
|
|
824
|
+
wires: ['cli'],
|
|
785
825
|
tags: ['non-existent'],
|
|
786
826
|
}
|
|
787
827
|
|
|
@@ -791,16 +831,34 @@ describe('filterInspectorState', () => {
|
|
|
791
831
|
assert.equal(Object.keys(result.cli.meta.programs).length, 0)
|
|
792
832
|
})
|
|
793
833
|
|
|
794
|
-
test('should
|
|
834
|
+
test('should repopulate CLI files from surviving metadata', () => {
|
|
795
835
|
const state = createMockInspectorState()
|
|
796
836
|
const filters: InspectorFilters = {
|
|
797
|
-
|
|
837
|
+
wires: ['cli'],
|
|
798
838
|
tags: ['build'],
|
|
799
839
|
}
|
|
800
840
|
|
|
801
841
|
const result = filterInspectorState(state, filters, mockLogger)
|
|
802
842
|
|
|
803
|
-
assert.
|
|
843
|
+
assert.deepEqual(Array.from(result.cli.files).sort(), [
|
|
844
|
+
'/test/project/src/cli/build.ts',
|
|
845
|
+
'/test/project/src/cli/program.ts',
|
|
846
|
+
])
|
|
847
|
+
})
|
|
848
|
+
})
|
|
849
|
+
|
|
850
|
+
describe('Wire exclusion', () => {
|
|
851
|
+
test('should exclude queue and scheduler wires while keeping http', () => {
|
|
852
|
+
const state = createMockInspectorState()
|
|
853
|
+
const filters: InspectorFilters = {
|
|
854
|
+
excludeWires: ['queue', 'scheduler'],
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
const result = filterInspectorState(state, filters, mockLogger)
|
|
858
|
+
|
|
859
|
+
assert.equal(Object.keys(result.queueWorkers.meta).length, 0)
|
|
860
|
+
assert.equal(Object.keys(result.scheduledTasks.meta).length, 0)
|
|
861
|
+
assert.ok(Object.keys(result.http.meta.get).length > 0)
|
|
804
862
|
})
|
|
805
863
|
})
|
|
806
864
|
|
|
@@ -808,7 +866,7 @@ describe('filterInspectorState', () => {
|
|
|
808
866
|
test('should filter multiple types at once', () => {
|
|
809
867
|
const state = createMockInspectorState()
|
|
810
868
|
const filters: InspectorFilters = {
|
|
811
|
-
|
|
869
|
+
wires: ['http', 'channel'],
|
|
812
870
|
}
|
|
813
871
|
|
|
814
872
|
const result = filterInspectorState(state, filters, mockLogger)
|
|
@@ -841,7 +899,7 @@ describe('filterInspectorState', () => {
|
|
|
841
899
|
test('should handle complex combined filters', () => {
|
|
842
900
|
const state = createMockInspectorState()
|
|
843
901
|
const filters: InspectorFilters = {
|
|
844
|
-
|
|
902
|
+
wires: ['http'],
|
|
845
903
|
tags: ['api'],
|
|
846
904
|
httpMethods: ['POST'],
|
|
847
905
|
}
|
|
@@ -864,7 +922,7 @@ describe('filterInspectorState', () => {
|
|
|
864
922
|
state.serviceAggregation.usedMiddleware.add('oldMiddleware')
|
|
865
923
|
|
|
866
924
|
const filters: InspectorFilters = {
|
|
867
|
-
|
|
925
|
+
wires: ['http'],
|
|
868
926
|
tags: ['admin'],
|
|
869
927
|
}
|
|
870
928
|
|
|
@@ -900,7 +958,7 @@ describe('filterInspectorState', () => {
|
|
|
900
958
|
const originalChannelCount = Object.keys(state.channels.meta).length
|
|
901
959
|
|
|
902
960
|
const filters: InspectorFilters = {
|
|
903
|
-
|
|
961
|
+
wires: ['http'],
|
|
904
962
|
}
|
|
905
963
|
|
|
906
964
|
filterInspectorState(state, filters, mockLogger)
|
|
@@ -916,7 +974,7 @@ describe('filterInspectorState', () => {
|
|
|
916
974
|
test('should create deep copies of metadata', () => {
|
|
917
975
|
const state = createMockInspectorState()
|
|
918
976
|
const filters: InspectorFilters = {
|
|
919
|
-
|
|
977
|
+
wires: ['http'],
|
|
920
978
|
tags: ['api'],
|
|
921
979
|
}
|
|
922
980
|
|
|
@@ -947,7 +1005,7 @@ describe('filterInspectorState', () => {
|
|
|
947
1005
|
state.queueWorkers.meta = {}
|
|
948
1006
|
|
|
949
1007
|
const filters: InspectorFilters = {
|
|
950
|
-
|
|
1008
|
+
wires: ['http'],
|
|
951
1009
|
}
|
|
952
1010
|
|
|
953
1011
|
const result = filterInspectorState(state, filters, mockLogger)
|
|
@@ -1016,7 +1074,7 @@ describe('filterInspectorState', () => {
|
|
|
1016
1074
|
|
|
1017
1075
|
// FILTER: Apply HTTP type filter
|
|
1018
1076
|
const filters: InspectorFilters = {
|
|
1019
|
-
|
|
1077
|
+
wires: ['http'],
|
|
1020
1078
|
}
|
|
1021
1079
|
const result = filterInspectorState(realState, filters, mockLogger)
|
|
1022
1080
|
|
|
@@ -1043,7 +1101,7 @@ describe('filterInspectorState', () => {
|
|
|
1043
1101
|
|
|
1044
1102
|
test('should filter channels by type in real data', () => {
|
|
1045
1103
|
const filters: InspectorFilters = {
|
|
1046
|
-
|
|
1104
|
+
wires: ['channel'],
|
|
1047
1105
|
}
|
|
1048
1106
|
|
|
1049
1107
|
const result = filterInspectorState(realState, filters, mockLogger)
|
|
@@ -1079,7 +1137,7 @@ describe('filterInspectorState', () => {
|
|
|
1079
1137
|
|
|
1080
1138
|
// FILTER: Apply scheduler type filter
|
|
1081
1139
|
const filters: InspectorFilters = {
|
|
1082
|
-
|
|
1140
|
+
wires: ['scheduler'],
|
|
1083
1141
|
}
|
|
1084
1142
|
const result = filterInspectorState(realState, filters, mockLogger)
|
|
1085
1143
|
|
|
@@ -1120,7 +1178,7 @@ describe('filterInspectorState', () => {
|
|
|
1120
1178
|
|
|
1121
1179
|
// FILTER: Apply queue type filter
|
|
1122
1180
|
const filters: InspectorFilters = {
|
|
1123
|
-
|
|
1181
|
+
wires: ['queue'],
|
|
1124
1182
|
}
|
|
1125
1183
|
const result = filterInspectorState(realState, filters, mockLogger)
|
|
1126
1184
|
|
|
@@ -1175,7 +1233,7 @@ describe('filterInspectorState', () => {
|
|
|
1175
1233
|
|
|
1176
1234
|
// FILTER: Apply MCP type filter
|
|
1177
1235
|
const filters: InspectorFilters = {
|
|
1178
|
-
|
|
1236
|
+
wires: ['mcp'],
|
|
1179
1237
|
}
|
|
1180
1238
|
const result = filterInspectorState(realState, filters, mockLogger)
|
|
1181
1239
|
|
|
@@ -1243,7 +1301,7 @@ describe('filterInspectorState', () => {
|
|
|
1243
1301
|
|
|
1244
1302
|
// FILTER: Apply CLI type filter
|
|
1245
1303
|
const filters: InspectorFilters = {
|
|
1246
|
-
|
|
1304
|
+
wires: ['cli'],
|
|
1247
1305
|
}
|
|
1248
1306
|
const result = filterInspectorState(realState, filters, mockLogger)
|
|
1249
1307
|
|
|
@@ -1287,7 +1345,7 @@ describe('filterInspectorState', () => {
|
|
|
1287
1345
|
|
|
1288
1346
|
// FILTER: Apply GET method filter
|
|
1289
1347
|
const filters: InspectorFilters = {
|
|
1290
|
-
|
|
1348
|
+
wires: ['http'],
|
|
1291
1349
|
httpMethods: ['GET'],
|
|
1292
1350
|
}
|
|
1293
1351
|
const result = filterInspectorState(realState, filters, mockLogger)
|
|
@@ -1357,7 +1415,7 @@ describe('filterInspectorState', () => {
|
|
|
1357
1415
|
const originalChannelCount = Object.keys(realState.channels.meta).length
|
|
1358
1416
|
|
|
1359
1417
|
const filters: InspectorFilters = {
|
|
1360
|
-
|
|
1418
|
+
wires: ['http'],
|
|
1361
1419
|
}
|
|
1362
1420
|
|
|
1363
1421
|
filterInspectorState(realState, filters, mockLogger)
|
|
@@ -1374,7 +1432,7 @@ describe('filterInspectorState', () => {
|
|
|
1374
1432
|
|
|
1375
1433
|
test('should aggregate services correctly with real data', () => {
|
|
1376
1434
|
const filters: InspectorFilters = {
|
|
1377
|
-
|
|
1435
|
+
wires: ['http'],
|
|
1378
1436
|
}
|
|
1379
1437
|
|
|
1380
1438
|
const result = filterInspectorState(realState, filters, mockLogger)
|
|
@@ -1404,7 +1462,7 @@ describe('filterInspectorState', () => {
|
|
|
1404
1462
|
|
|
1405
1463
|
// FILTER: Apply combined filters (HTTP and channels, GET/POST methods only)
|
|
1406
1464
|
const filters: InspectorFilters = {
|
|
1407
|
-
|
|
1465
|
+
wires: ['http', 'channel'],
|
|
1408
1466
|
httpMethods: ['GET', 'POST'],
|
|
1409
1467
|
}
|
|
1410
1468
|
const result = filterInspectorState(realState, filters, mockLogger)
|
|
@@ -1443,3 +1501,49 @@ describe('filterInspectorState', () => {
|
|
|
1443
1501
|
})
|
|
1444
1502
|
})
|
|
1445
1503
|
})
|
|
1504
|
+
|
|
1505
|
+
describe('filterInspectorState exclude filters', () => {
|
|
1506
|
+
test('exclude tags removes matching entries after include', () => {
|
|
1507
|
+
const state = createMockInspectorState()
|
|
1508
|
+
const filters: InspectorFilters = {
|
|
1509
|
+
tags: ['api', 'admin'],
|
|
1510
|
+
excludeTags: ['admin'],
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
const result = filterInspectorState(state, filters, mockLogger)
|
|
1514
|
+
|
|
1515
|
+
assert.ok(result.http.meta.get['/api/users'])
|
|
1516
|
+
assert.ok(result.http.meta.post['/api/users'])
|
|
1517
|
+
assert.ok(!result.http.meta.get['/admin/settings'])
|
|
1518
|
+
})
|
|
1519
|
+
|
|
1520
|
+
test('exclude names wins over broad names include', () => {
|
|
1521
|
+
const state = createMockInspectorState()
|
|
1522
|
+
const filters: InspectorFilters = {
|
|
1523
|
+
names: ['*'],
|
|
1524
|
+
excludeNames: ['getAdminSettings'],
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
const result = filterInspectorState(state, filters, mockLogger)
|
|
1528
|
+
|
|
1529
|
+
assert.ok(result.http.meta.get['/api/users'])
|
|
1530
|
+
assert.ok(result.http.meta.post['/api/users'])
|
|
1531
|
+
assert.ok(!result.http.meta.get['/admin/settings'])
|
|
1532
|
+
})
|
|
1533
|
+
|
|
1534
|
+
test('exclude target prunes server target while keeping serverless', () => {
|
|
1535
|
+
const state = createMockInspectorState()
|
|
1536
|
+
;(state.functions.meta as any).getAdminSettings.deploy = 'server'
|
|
1537
|
+
;(state.functions.meta as any).createUser.deploy = 'serverless'
|
|
1538
|
+
|
|
1539
|
+
const filters: InspectorFilters = {
|
|
1540
|
+
target: ['server', 'serverless'],
|
|
1541
|
+
excludeTarget: ['server'],
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
const result = filterInspectorState(state, filters, mockLogger)
|
|
1545
|
+
|
|
1546
|
+
assert.ok(result.http.meta.post['/api/users'])
|
|
1547
|
+
assert.ok(!result.http.meta.get['/admin/settings'])
|
|
1548
|
+
})
|
|
1549
|
+
})
|