@pikku/inspector 0.11.0 → 0.11.2
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 +32 -2
- package/dist/add/add-channel.js +11 -10
- package/dist/add/add-file-with-factory.js +10 -10
- package/dist/add/add-forge-credential.d.ts +8 -0
- package/dist/add/add-forge-credential.js +77 -0
- package/dist/add/add-forge-node.d.ts +7 -0
- package/dist/add/add-forge-node.js +77 -0
- package/dist/add/add-functions.js +158 -51
- package/dist/add/add-http-route.js +28 -4
- package/dist/add/add-mcp-prompt.js +6 -5
- package/dist/add/add-mcp-resource.js +6 -5
- package/dist/add/add-mcp-tool.js +6 -5
- package/dist/add/add-middleware.js +1 -1
- package/dist/add/add-permission.js +1 -1
- package/dist/add/add-queue-worker.js +6 -5
- package/dist/add/add-rpc-invocations.d.ts +3 -0
- package/dist/add/add-rpc-invocations.js +51 -25
- package/dist/add/add-schedule.js +5 -4
- package/dist/add/add-workflow-graph.d.ts +6 -0
- package/dist/add/add-workflow-graph.js +659 -0
- package/dist/add/add-workflow.d.ts +1 -1
- package/dist/add/add-workflow.js +191 -69
- package/dist/error-codes.d.ts +3 -0
- package/dist/error-codes.js +3 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +3 -0
- package/dist/inspector.js +29 -9
- package/dist/types.d.ts +47 -8
- package/dist/utils/extract-function-name.js +7 -7
- package/dist/utils/extract-function-node.d.ts +10 -0
- package/dist/utils/extract-function-node.js +38 -0
- package/dist/utils/extract-node-value.d.ts +8 -0
- package/dist/utils/extract-node-value.js +24 -0
- package/dist/utils/extract-service-metadata.d.ts +19 -0
- package/dist/utils/extract-service-metadata.js +244 -0
- package/dist/utils/get-files-and-methods.d.ts +3 -3
- package/dist/utils/get-files-and-methods.js +3 -3
- package/dist/utils/get-property-value.d.ts +14 -6
- package/dist/utils/get-property-value.js +55 -43
- package/dist/utils/post-process.d.ts +9 -0
- package/dist/utils/post-process.js +30 -3
- package/dist/utils/serialize-inspector-state.d.ts +42 -6
- package/dist/utils/serialize-inspector-state.js +36 -10
- package/dist/utils/workflow/dsl/deserialize-dsl-workflow.d.ts +24 -0
- package/dist/utils/workflow/dsl/deserialize-dsl-workflow.js +898 -0
- package/dist/utils/workflow/dsl/extract-dsl-workflow.d.ts +17 -0
- package/dist/utils/workflow/dsl/extract-dsl-workflow.js +1284 -0
- package/dist/utils/workflow/dsl/index.d.ts +7 -0
- package/dist/utils/workflow/dsl/index.js +7 -0
- package/dist/utils/workflow/dsl/patterns.d.ts +60 -0
- package/dist/utils/workflow/dsl/patterns.js +218 -0
- package/dist/utils/workflow/dsl/validation.d.ts +30 -0
- package/dist/utils/workflow/dsl/validation.js +142 -0
- package/dist/utils/workflow/graph/convert-dsl-to-graph.d.ts +13 -0
- package/dist/utils/workflow/graph/convert-dsl-to-graph.js +316 -0
- package/dist/utils/workflow/graph/index.d.ts +6 -0
- package/dist/utils/workflow/graph/index.js +6 -0
- package/dist/utils/workflow/graph/serialize-workflow-graph.d.ts +43 -0
- package/dist/utils/workflow/graph/serialize-workflow-graph.js +152 -0
- package/dist/utils/workflow/graph/workflow-graph.types.d.ts +229 -0
- package/dist/utils/workflow/graph/workflow-graph.types.js +38 -0
- package/dist/utils/write-service-metadata.d.ts +13 -0
- package/dist/utils/write-service-metadata.js +37 -0
- package/dist/visit.js +8 -2
- package/package.json +16 -4
- package/src/add/add-channel.ts +37 -17
- package/src/add/add-file-with-factory.ts +10 -10
- package/src/add/add-forge-credential.ts +119 -0
- package/src/add/add-forge-node.ts +132 -0
- package/src/add/add-functions.ts +199 -69
- package/src/add/add-http-route.ts +34 -5
- package/src/add/add-mcp-prompt.ts +11 -7
- package/src/add/add-mcp-resource.ts +11 -7
- package/src/add/add-mcp-tool.ts +11 -7
- package/src/add/add-middleware.ts +1 -1
- package/src/add/add-permission.ts +1 -1
- package/src/add/add-queue-worker.ts +11 -12
- package/src/add/add-rpc-invocations.ts +61 -31
- package/src/add/add-schedule.ts +10 -5
- package/src/add/add-workflow-graph.ts +864 -0
- package/src/add/add-workflow.ts +212 -116
- package/src/error-codes.ts +3 -0
- package/src/index.ts +12 -0
- package/src/inspector.ts +36 -10
- package/src/types.ts +43 -9
- package/src/utils/extract-function-name.ts +7 -7
- package/src/utils/extract-function-node.ts +58 -0
- package/src/utils/extract-node-value.ts +31 -0
- package/src/utils/extract-service-metadata.ts +353 -0
- package/src/utils/filter-inspector-state.test.ts +3 -3
- package/src/utils/filter-utils.test.ts +45 -51
- package/src/utils/get-files-and-methods.ts +11 -11
- package/src/utils/get-property-value.ts +67 -53
- package/src/utils/permissions.test.ts +3 -3
- package/src/utils/post-process.ts +56 -3
- package/src/utils/serialize-inspector-state.ts +67 -19
- package/src/utils/test-data/inspector-state.json +9 -9
- package/src/utils/workflow/dsl/deserialize-dsl-workflow.ts +1180 -0
- package/src/utils/workflow/dsl/extract-dsl-workflow.ts +1608 -0
- package/src/utils/workflow/dsl/index.ts +11 -0
- package/src/utils/workflow/dsl/patterns.ts +279 -0
- package/src/utils/workflow/dsl/validation.ts +180 -0
- package/src/utils/workflow/graph/convert-dsl-to-graph.ts +415 -0
- package/src/utils/workflow/graph/index.ts +6 -0
- package/src/utils/workflow/graph/serialize-workflow-graph.ts +223 -0
- package/src/utils/workflow/graph/workflow-graph.types.ts +280 -0
- package/src/utils/write-service-metadata.ts +51 -0
- package/src/visit.ts +9 -3
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { test, describe } from 'node:test'
|
|
2
2
|
import { strict as assert } from 'node:assert'
|
|
3
|
-
import { PikkuWiringTypes } from '@pikku/core'
|
|
4
3
|
import { InspectorFilters } from '../types'
|
|
5
4
|
import { matchesFilters, matchesWildcard } from './filter-utils'
|
|
6
5
|
|
|
@@ -11,6 +10,8 @@ describe('matchesFilters', () => {
|
|
|
11
10
|
error: () => {},
|
|
12
11
|
warn: () => {},
|
|
13
12
|
debug: () => {},
|
|
13
|
+
critical: () => {},
|
|
14
|
+
hasCriticalErrors: () => false,
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
describe('Empty filters', () => {
|
|
@@ -20,7 +21,7 @@ describe('matchesFilters', () => {
|
|
|
20
21
|
const result = matchesFilters(
|
|
21
22
|
filters,
|
|
22
23
|
{ tags: ['test'] },
|
|
23
|
-
{ type:
|
|
24
|
+
{ type: 'http', name: 'test-route' },
|
|
24
25
|
mockLogger
|
|
25
26
|
)
|
|
26
27
|
|
|
@@ -37,7 +38,7 @@ describe('matchesFilters', () => {
|
|
|
37
38
|
const result = matchesFilters(
|
|
38
39
|
filters,
|
|
39
40
|
{ tags: ['test'] },
|
|
40
|
-
{ type:
|
|
41
|
+
{ type: 'http', name: 'test-route' },
|
|
41
42
|
mockLogger
|
|
42
43
|
)
|
|
43
44
|
|
|
@@ -54,7 +55,7 @@ describe('matchesFilters', () => {
|
|
|
54
55
|
const result = matchesFilters(
|
|
55
56
|
filters,
|
|
56
57
|
{ tags: ['api', 'internal'] },
|
|
57
|
-
{ type:
|
|
58
|
+
{ type: 'http', name: 'test-route' },
|
|
58
59
|
mockLogger
|
|
59
60
|
)
|
|
60
61
|
|
|
@@ -69,7 +70,7 @@ describe('matchesFilters', () => {
|
|
|
69
70
|
const result = matchesFilters(
|
|
70
71
|
filters,
|
|
71
72
|
{ tags: ['internal', 'private'] },
|
|
72
|
-
{ type:
|
|
73
|
+
{ type: 'http', name: 'test-route' },
|
|
73
74
|
mockLogger
|
|
74
75
|
)
|
|
75
76
|
|
|
@@ -84,7 +85,7 @@ describe('matchesFilters', () => {
|
|
|
84
85
|
const result = matchesFilters(
|
|
85
86
|
filters,
|
|
86
87
|
{ tags: undefined },
|
|
87
|
-
{ type:
|
|
88
|
+
{ type: 'http', name: 'test-route' },
|
|
88
89
|
mockLogger
|
|
89
90
|
)
|
|
90
91
|
|
|
@@ -99,7 +100,7 @@ describe('matchesFilters', () => {
|
|
|
99
100
|
const result = matchesFilters(
|
|
100
101
|
filters,
|
|
101
102
|
{ tags: [] },
|
|
102
|
-
{ type:
|
|
103
|
+
{ type: 'http', name: 'test-route' },
|
|
103
104
|
mockLogger
|
|
104
105
|
)
|
|
105
106
|
|
|
@@ -116,7 +117,7 @@ describe('matchesFilters', () => {
|
|
|
116
117
|
const result = matchesFilters(
|
|
117
118
|
filters,
|
|
118
119
|
{ tags: ['test'] },
|
|
119
|
-
{ type:
|
|
120
|
+
{ type: 'http', name: 'test-route' },
|
|
120
121
|
mockLogger
|
|
121
122
|
)
|
|
122
123
|
|
|
@@ -131,7 +132,7 @@ describe('matchesFilters', () => {
|
|
|
131
132
|
const result = matchesFilters(
|
|
132
133
|
filters,
|
|
133
134
|
{ tags: ['test'] },
|
|
134
|
-
{ type:
|
|
135
|
+
{ type: 'http', name: 'test-route' },
|
|
135
136
|
mockLogger
|
|
136
137
|
)
|
|
137
138
|
|
|
@@ -139,14 +140,7 @@ describe('matchesFilters', () => {
|
|
|
139
140
|
})
|
|
140
141
|
|
|
141
142
|
test('should handle all PikkuWiringTypes correctly', () => {
|
|
142
|
-
const eventTypes = [
|
|
143
|
-
PikkuWiringTypes.http,
|
|
144
|
-
PikkuWiringTypes.channel,
|
|
145
|
-
PikkuWiringTypes.queue,
|
|
146
|
-
PikkuWiringTypes.scheduler,
|
|
147
|
-
PikkuWiringTypes.rpc,
|
|
148
|
-
PikkuWiringTypes.mcp,
|
|
149
|
-
]
|
|
143
|
+
const eventTypes = ['http', 'channel', 'queue', 'scheduler', 'rpc', 'mcp']
|
|
150
144
|
|
|
151
145
|
eventTypes.forEach((eventType) => {
|
|
152
146
|
const filters: InspectorFilters = {
|
|
@@ -175,7 +169,7 @@ describe('matchesFilters', () => {
|
|
|
175
169
|
filters,
|
|
176
170
|
{ tags: ['test'] },
|
|
177
171
|
{
|
|
178
|
-
type:
|
|
172
|
+
type: 'http',
|
|
179
173
|
name: 'test-route',
|
|
180
174
|
filePath: '/project/src/api/routes.ts',
|
|
181
175
|
},
|
|
@@ -194,7 +188,7 @@ describe('matchesFilters', () => {
|
|
|
194
188
|
filters,
|
|
195
189
|
{ tags: ['test'] },
|
|
196
190
|
{
|
|
197
|
-
type:
|
|
191
|
+
type: 'http',
|
|
198
192
|
name: 'test-route',
|
|
199
193
|
filePath: '/project/src/public/routes.ts',
|
|
200
194
|
},
|
|
@@ -213,7 +207,7 @@ describe('matchesFilters', () => {
|
|
|
213
207
|
filters,
|
|
214
208
|
{ tags: ['test'] },
|
|
215
209
|
{
|
|
216
|
-
type:
|
|
210
|
+
type: 'http',
|
|
217
211
|
name: 'test-route',
|
|
218
212
|
filePath: 'C:\\project\\src\\api\\routes.ts',
|
|
219
213
|
},
|
|
@@ -232,7 +226,7 @@ describe('matchesFilters', () => {
|
|
|
232
226
|
filters,
|
|
233
227
|
{ tags: ['test'] },
|
|
234
228
|
{
|
|
235
|
-
type:
|
|
229
|
+
type: 'http',
|
|
236
230
|
name: 'test-route',
|
|
237
231
|
filePath: 'C:\\project\\src\\api\\routes.ts',
|
|
238
232
|
},
|
|
@@ -250,7 +244,7 @@ describe('matchesFilters', () => {
|
|
|
250
244
|
const result = matchesFilters(
|
|
251
245
|
filters,
|
|
252
246
|
{ tags: ['test'] },
|
|
253
|
-
{ type:
|
|
247
|
+
{ type: 'http', name: 'test-route' }, // no filePath
|
|
254
248
|
mockLogger
|
|
255
249
|
)
|
|
256
250
|
|
|
@@ -266,7 +260,7 @@ describe('matchesFilters', () => {
|
|
|
266
260
|
filters,
|
|
267
261
|
{ tags: ['test'] },
|
|
268
262
|
{
|
|
269
|
-
type:
|
|
263
|
+
type: 'http',
|
|
270
264
|
name: 'test-route',
|
|
271
265
|
filePath: '/project/src/api/v1/routes.ts',
|
|
272
266
|
},
|
|
@@ -289,7 +283,7 @@ describe('matchesFilters', () => {
|
|
|
289
283
|
filters,
|
|
290
284
|
{ tags: ['api', 'public'] },
|
|
291
285
|
{
|
|
292
|
-
type:
|
|
286
|
+
type: 'http',
|
|
293
287
|
name: 'test-route',
|
|
294
288
|
filePath: '/project/src/api/routes.ts',
|
|
295
289
|
},
|
|
@@ -310,7 +304,7 @@ describe('matchesFilters', () => {
|
|
|
310
304
|
filters,
|
|
311
305
|
{ tags: ['api', 'public'] },
|
|
312
306
|
{
|
|
313
|
-
type:
|
|
307
|
+
type: 'http',
|
|
314
308
|
name: 'test-route',
|
|
315
309
|
filePath: '/project/src/api/routes.ts',
|
|
316
310
|
},
|
|
@@ -331,7 +325,7 @@ describe('matchesFilters', () => {
|
|
|
331
325
|
filters,
|
|
332
326
|
{ tags: ['api', 'public'] },
|
|
333
327
|
{
|
|
334
|
-
type:
|
|
328
|
+
type: 'http',
|
|
335
329
|
name: 'test-route',
|
|
336
330
|
filePath: '/project/src/api/routes.ts',
|
|
337
331
|
},
|
|
@@ -352,7 +346,7 @@ describe('matchesFilters', () => {
|
|
|
352
346
|
filters,
|
|
353
347
|
{ tags: ['api', 'public'] },
|
|
354
348
|
{
|
|
355
|
-
type:
|
|
349
|
+
type: 'http',
|
|
356
350
|
name: 'test-route',
|
|
357
351
|
filePath: '/project/src/api/routes.ts',
|
|
358
352
|
},
|
|
@@ -372,7 +366,7 @@ describe('matchesFilters', () => {
|
|
|
372
366
|
const result = matchesFilters(
|
|
373
367
|
filters,
|
|
374
368
|
{ tags: undefined },
|
|
375
|
-
{ type:
|
|
369
|
+
{ type: 'http', name: 'test-route' },
|
|
376
370
|
mockLogger
|
|
377
371
|
)
|
|
378
372
|
|
|
@@ -387,7 +381,7 @@ describe('matchesFilters', () => {
|
|
|
387
381
|
const result = matchesFilters(
|
|
388
382
|
filters,
|
|
389
383
|
{ tags: ['test'] },
|
|
390
|
-
{ type:
|
|
384
|
+
{ type: 'http', name: '' },
|
|
391
385
|
mockLogger
|
|
392
386
|
)
|
|
393
387
|
|
|
@@ -403,7 +397,7 @@ describe('matchesFilters', () => {
|
|
|
403
397
|
filters,
|
|
404
398
|
{ tags: ['test'] },
|
|
405
399
|
{
|
|
406
|
-
type:
|
|
400
|
+
type: 'http',
|
|
407
401
|
name: 'test-route',
|
|
408
402
|
filePath: '/project/src/api-v2/routes.ts',
|
|
409
403
|
},
|
|
@@ -422,7 +416,7 @@ describe('matchesFilters', () => {
|
|
|
422
416
|
filters,
|
|
423
417
|
{ tags: ['test'] },
|
|
424
418
|
{
|
|
425
|
-
type:
|
|
419
|
+
type: 'http',
|
|
426
420
|
name: 'test-route',
|
|
427
421
|
filePath: '/project/src/api/routes.ts',
|
|
428
422
|
},
|
|
@@ -440,7 +434,7 @@ describe('matchesFilters', () => {
|
|
|
440
434
|
const result = matchesFilters(
|
|
441
435
|
filters,
|
|
442
436
|
{ tags: ['api', 'public', 'v1'] },
|
|
443
|
-
{ type:
|
|
437
|
+
{ type: 'http', name: 'test-route' },
|
|
444
438
|
mockLogger
|
|
445
439
|
)
|
|
446
440
|
|
|
@@ -455,7 +449,7 @@ describe('matchesFilters', () => {
|
|
|
455
449
|
const result = matchesFilters(
|
|
456
450
|
filters,
|
|
457
451
|
{ tags: ['test'] },
|
|
458
|
-
{ type:
|
|
452
|
+
{ type: 'channel', name: 'test-channel' },
|
|
459
453
|
mockLogger
|
|
460
454
|
)
|
|
461
455
|
|
|
@@ -471,7 +465,7 @@ describe('matchesFilters', () => {
|
|
|
471
465
|
filters,
|
|
472
466
|
{ tags: ['test'] },
|
|
473
467
|
{
|
|
474
|
-
type:
|
|
468
|
+
type: 'http',
|
|
475
469
|
name: 'test-route',
|
|
476
470
|
filePath: '/project/src/internal/routes.ts',
|
|
477
471
|
},
|
|
@@ -491,7 +485,7 @@ describe('matchesFilters', () => {
|
|
|
491
485
|
const result = matchesFilters(
|
|
492
486
|
filters,
|
|
493
487
|
{ name: 'email-worker' },
|
|
494
|
-
{ type:
|
|
488
|
+
{ type: 'queue', name: 'email-queue' },
|
|
495
489
|
mockLogger
|
|
496
490
|
)
|
|
497
491
|
|
|
@@ -506,7 +500,7 @@ describe('matchesFilters', () => {
|
|
|
506
500
|
const result = matchesFilters(
|
|
507
501
|
filters,
|
|
508
502
|
{ name: 'email-worker' },
|
|
509
|
-
{ type:
|
|
503
|
+
{ type: 'queue', name: 'email-queue' },
|
|
510
504
|
mockLogger
|
|
511
505
|
)
|
|
512
506
|
|
|
@@ -521,7 +515,7 @@ describe('matchesFilters', () => {
|
|
|
521
515
|
const result = matchesFilters(
|
|
522
516
|
filters,
|
|
523
517
|
{ name: 'notification-worker' },
|
|
524
|
-
{ type:
|
|
518
|
+
{ type: 'queue', name: 'notification-queue' },
|
|
525
519
|
mockLogger
|
|
526
520
|
)
|
|
527
521
|
|
|
@@ -536,7 +530,7 @@ describe('matchesFilters', () => {
|
|
|
536
530
|
const result = matchesFilters(
|
|
537
531
|
filters,
|
|
538
532
|
{},
|
|
539
|
-
{ type:
|
|
533
|
+
{ type: 'http', name: 'test-route' },
|
|
540
534
|
mockLogger
|
|
541
535
|
)
|
|
542
536
|
|
|
@@ -551,7 +545,7 @@ describe('matchesFilters', () => {
|
|
|
551
545
|
const result = matchesFilters(
|
|
552
546
|
filters,
|
|
553
547
|
{ name: 'email-worker' },
|
|
554
|
-
{ type:
|
|
548
|
+
{ type: 'queue', name: 'other-name' },
|
|
555
549
|
mockLogger
|
|
556
550
|
)
|
|
557
551
|
|
|
@@ -569,7 +563,7 @@ describe('matchesFilters', () => {
|
|
|
569
563
|
filters,
|
|
570
564
|
{},
|
|
571
565
|
{
|
|
572
|
-
type:
|
|
566
|
+
type: 'http',
|
|
573
567
|
name: 'users-route',
|
|
574
568
|
httpRoute: '/api/users',
|
|
575
569
|
},
|
|
@@ -588,7 +582,7 @@ describe('matchesFilters', () => {
|
|
|
588
582
|
filters,
|
|
589
583
|
{},
|
|
590
584
|
{
|
|
591
|
-
type:
|
|
585
|
+
type: 'http',
|
|
592
586
|
name: 'users-route',
|
|
593
587
|
httpRoute: '/api/users',
|
|
594
588
|
},
|
|
@@ -607,7 +601,7 @@ describe('matchesFilters', () => {
|
|
|
607
601
|
filters,
|
|
608
602
|
{},
|
|
609
603
|
{
|
|
610
|
-
type:
|
|
604
|
+
type: 'http',
|
|
611
605
|
name: 'webhook-route',
|
|
612
606
|
httpRoute: '/webhooks/stripe',
|
|
613
607
|
},
|
|
@@ -625,7 +619,7 @@ describe('matchesFilters', () => {
|
|
|
625
619
|
const result = matchesFilters(
|
|
626
620
|
filters,
|
|
627
621
|
{},
|
|
628
|
-
{ type:
|
|
622
|
+
{ type: 'queue', name: 'worker' },
|
|
629
623
|
mockLogger
|
|
630
624
|
)
|
|
631
625
|
|
|
@@ -641,7 +635,7 @@ describe('matchesFilters', () => {
|
|
|
641
635
|
filters,
|
|
642
636
|
{},
|
|
643
637
|
{
|
|
644
|
-
type:
|
|
638
|
+
type: 'http',
|
|
645
639
|
name: 'webhook-route',
|
|
646
640
|
httpRoute: '/webhooks/stripe',
|
|
647
641
|
},
|
|
@@ -662,7 +656,7 @@ describe('matchesFilters', () => {
|
|
|
662
656
|
filters,
|
|
663
657
|
{},
|
|
664
658
|
{
|
|
665
|
-
type:
|
|
659
|
+
type: 'http',
|
|
666
660
|
name: 'users-route',
|
|
667
661
|
httpMethod: 'GET',
|
|
668
662
|
},
|
|
@@ -681,7 +675,7 @@ describe('matchesFilters', () => {
|
|
|
681
675
|
filters,
|
|
682
676
|
{},
|
|
683
677
|
{
|
|
684
|
-
type:
|
|
678
|
+
type: 'http',
|
|
685
679
|
name: 'users-route',
|
|
686
680
|
httpMethod: 'DELETE',
|
|
687
681
|
},
|
|
@@ -700,7 +694,7 @@ describe('matchesFilters', () => {
|
|
|
700
694
|
filters,
|
|
701
695
|
{},
|
|
702
696
|
{
|
|
703
|
-
type:
|
|
697
|
+
type: 'http',
|
|
704
698
|
name: 'users-route',
|
|
705
699
|
httpMethod: 'get',
|
|
706
700
|
},
|
|
@@ -718,7 +712,7 @@ describe('matchesFilters', () => {
|
|
|
718
712
|
const result = matchesFilters(
|
|
719
713
|
filters,
|
|
720
714
|
{},
|
|
721
|
-
{ type:
|
|
715
|
+
{ type: 'queue', name: 'worker' },
|
|
722
716
|
mockLogger
|
|
723
717
|
)
|
|
724
718
|
|
|
@@ -739,7 +733,7 @@ describe('matchesFilters', () => {
|
|
|
739
733
|
filters,
|
|
740
734
|
{ tags: ['api'] },
|
|
741
735
|
{
|
|
742
|
-
type:
|
|
736
|
+
type: 'http',
|
|
743
737
|
name: 'users-route',
|
|
744
738
|
httpRoute: '/api/users',
|
|
745
739
|
httpMethod: 'GET',
|
|
@@ -760,7 +754,7 @@ describe('matchesFilters', () => {
|
|
|
760
754
|
filters,
|
|
761
755
|
{ tags: ['api'] },
|
|
762
756
|
{
|
|
763
|
-
type:
|
|
757
|
+
type: 'http',
|
|
764
758
|
name: 'users-route',
|
|
765
759
|
httpRoute: '/api/users',
|
|
766
760
|
},
|
|
@@ -780,7 +774,7 @@ describe('matchesFilters', () => {
|
|
|
780
774
|
filters,
|
|
781
775
|
{},
|
|
782
776
|
{
|
|
783
|
-
type:
|
|
777
|
+
type: 'http',
|
|
784
778
|
name: 'users-route',
|
|
785
779
|
httpRoute: '/api/users',
|
|
786
780
|
httpMethod: 'GET',
|
|
@@ -13,12 +13,12 @@ interface Meta {
|
|
|
13
13
|
|
|
14
14
|
export type FilesAndMethods = {
|
|
15
15
|
userSessionType: Meta
|
|
16
|
-
|
|
16
|
+
wireServicesType: Meta
|
|
17
17
|
singletonServicesType: Meta
|
|
18
18
|
pikkuConfigType: Meta
|
|
19
19
|
pikkuConfigFactory: Meta
|
|
20
20
|
singletonServicesFactory: Meta
|
|
21
|
-
|
|
21
|
+
wireServicesFactory: Meta
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export type FilesAndMethodsErrors = Map<string, PathToNameAndType>
|
|
@@ -86,10 +86,10 @@ const getMetaTypes = (
|
|
|
86
86
|
export const getFilesAndMethods = (
|
|
87
87
|
{
|
|
88
88
|
singletonServicesTypeImportMap,
|
|
89
|
-
|
|
89
|
+
wireServicesTypeImportMap,
|
|
90
90
|
userSessionTypeImportMap,
|
|
91
91
|
configTypeImportMap,
|
|
92
|
-
|
|
92
|
+
wireServicesFactories,
|
|
93
93
|
singletonServicesFactories,
|
|
94
94
|
configFactories,
|
|
95
95
|
}: InspectorState,
|
|
@@ -97,7 +97,7 @@ export const getFilesAndMethods = (
|
|
|
97
97
|
configFileType,
|
|
98
98
|
userSessionType,
|
|
99
99
|
singletonServicesFactoryType,
|
|
100
|
-
|
|
100
|
+
wireServicesFactoryType,
|
|
101
101
|
}: InspectorOptions['types'] = {}
|
|
102
102
|
): { result: Partial<FilesAndMethods>; errors: FilesAndMethodsErrors } => {
|
|
103
103
|
const errors: FilesAndMethodsErrors = new Map()
|
|
@@ -115,9 +115,9 @@ export const getFilesAndMethods = (
|
|
|
115
115
|
undefined,
|
|
116
116
|
errors
|
|
117
117
|
),
|
|
118
|
-
|
|
118
|
+
wireServicesType: getMetaTypes(
|
|
119
119
|
'CoreServices',
|
|
120
|
-
|
|
120
|
+
wireServicesTypeImportMap,
|
|
121
121
|
undefined,
|
|
122
122
|
errors
|
|
123
123
|
),
|
|
@@ -139,10 +139,10 @@ export const getFilesAndMethods = (
|
|
|
139
139
|
singletonServicesFactoryType,
|
|
140
140
|
errors
|
|
141
141
|
),
|
|
142
|
-
|
|
143
|
-
'
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
wireServicesFactory: getMetaTypes(
|
|
143
|
+
'CreateWireServices',
|
|
144
|
+
wireServicesFactories,
|
|
145
|
+
wireServicesFactoryType,
|
|
146
146
|
errors
|
|
147
147
|
),
|
|
148
148
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { PikkuDocs } from '@pikku/core'
|
|
2
1
|
import * as ts from 'typescript'
|
|
3
2
|
import { ErrorCode } from '../error-codes.js'
|
|
4
3
|
|
|
5
4
|
export const getPropertyValue = (
|
|
6
5
|
obj: ts.ObjectLiteralExpression,
|
|
7
6
|
propertyName: string
|
|
8
|
-
): string | string[] | null |
|
|
7
|
+
): string | string[] | null | boolean => {
|
|
9
8
|
const property = obj.properties.find(
|
|
10
9
|
(p) =>
|
|
11
10
|
ts.isPropertyAssignment(p) &&
|
|
@@ -33,42 +32,6 @@ export const getPropertyValue = (
|
|
|
33
32
|
return stringArray.length > 0 ? stringArray : null
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
// Special handling for 'docs' -> expect RouteDocs
|
|
37
|
-
if (propertyName === 'docs' && ts.isObjectLiteralExpression(initializer)) {
|
|
38
|
-
const docs: PikkuDocs = {}
|
|
39
|
-
|
|
40
|
-
initializer.properties.forEach((prop) => {
|
|
41
|
-
if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name)) {
|
|
42
|
-
const propName = prop.name.text
|
|
43
|
-
|
|
44
|
-
if (propName === 'summary' && ts.isStringLiteral(prop.initializer)) {
|
|
45
|
-
docs.summary = prop.initializer.text
|
|
46
|
-
} else if (
|
|
47
|
-
propName === 'description' &&
|
|
48
|
-
ts.isStringLiteral(prop.initializer)
|
|
49
|
-
) {
|
|
50
|
-
docs.description = prop.initializer.text
|
|
51
|
-
} else if (
|
|
52
|
-
propName === 'tags' &&
|
|
53
|
-
ts.isArrayLiteralExpression(prop.initializer)
|
|
54
|
-
) {
|
|
55
|
-
docs.tags = prop.initializer.elements
|
|
56
|
-
.filter(ts.isStringLiteral)
|
|
57
|
-
.map((element) => element.text)
|
|
58
|
-
} else if (
|
|
59
|
-
propName === 'errors' &&
|
|
60
|
-
ts.isArrayLiteralExpression(prop.initializer)
|
|
61
|
-
) {
|
|
62
|
-
docs.errors = prop.initializer.elements
|
|
63
|
-
.filter(ts.isIdentifier)
|
|
64
|
-
.map((element) => element.text as unknown as string)
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
return docs
|
|
70
|
-
}
|
|
71
|
-
|
|
72
35
|
// booleans -> true/false
|
|
73
36
|
if (initializer.kind === ts.SyntaxKind.TrueKeyword) {
|
|
74
37
|
return true
|
|
@@ -94,27 +57,78 @@ export const getPropertyValue = (
|
|
|
94
57
|
}
|
|
95
58
|
|
|
96
59
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
60
|
+
* Extracts common wire metadata (title, tags, summary, description, errors) directly from an object
|
|
61
|
+
* @param obj - The TypeScript object literal expression to extract metadata from
|
|
62
|
+
* @param wiringType - The type of wiring (e.g., 'HTTP route', 'Channel', 'Queue worker')
|
|
63
|
+
* @param wiringName - The name/identifier of the wiring (e.g., route path, channel name)
|
|
99
64
|
* @param logger - Optional logger instance; if not provided, uses console.error
|
|
65
|
+
* @returns Object containing the common wire metadata fields
|
|
100
66
|
*/
|
|
101
|
-
export const
|
|
67
|
+
export const getCommonWireMetaData = (
|
|
102
68
|
obj: ts.ObjectLiteralExpression,
|
|
103
69
|
wiringType: string,
|
|
104
70
|
wiringName: string | null,
|
|
105
71
|
logger?: { critical: (code: ErrorCode, message: string) => void }
|
|
106
|
-
):
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
72
|
+
): {
|
|
73
|
+
title?: string
|
|
74
|
+
tags?: string[]
|
|
75
|
+
summary?: string
|
|
76
|
+
description?: string
|
|
77
|
+
errors?: string[]
|
|
78
|
+
} => {
|
|
79
|
+
const metadata: {
|
|
80
|
+
title?: string
|
|
81
|
+
tags?: string[]
|
|
82
|
+
summary?: string
|
|
83
|
+
description?: string
|
|
84
|
+
errors?: string[]
|
|
85
|
+
} = {}
|
|
86
|
+
|
|
87
|
+
obj.properties.forEach((prop) => {
|
|
88
|
+
if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name)) {
|
|
89
|
+
const propName = prop.name.text
|
|
90
|
+
|
|
91
|
+
if (propName === 'title' && ts.isStringLiteral(prop.initializer)) {
|
|
92
|
+
metadata.title = prop.initializer.text
|
|
93
|
+
} else if (
|
|
94
|
+
propName === 'summary' &&
|
|
95
|
+
ts.isStringLiteral(prop.initializer)
|
|
96
|
+
) {
|
|
97
|
+
metadata.summary = prop.initializer.text
|
|
98
|
+
} else if (
|
|
99
|
+
propName === 'description' &&
|
|
100
|
+
ts.isStringLiteral(prop.initializer)
|
|
101
|
+
) {
|
|
102
|
+
metadata.description = prop.initializer.text
|
|
103
|
+
} else if (propName === 'tags') {
|
|
104
|
+
if (ts.isArrayLiteralExpression(prop.initializer)) {
|
|
105
|
+
metadata.tags = prop.initializer.elements
|
|
106
|
+
.filter(ts.isStringLiteral)
|
|
107
|
+
.map((element) => element.text)
|
|
108
|
+
} else {
|
|
109
|
+
const errorMsg = `${wiringType} '${wiringName}' has invalid 'tags' property - must be an array of strings.`
|
|
110
|
+
if (logger) {
|
|
111
|
+
logger.critical(ErrorCode.INVALID_TAGS_TYPE, errorMsg)
|
|
112
|
+
} else {
|
|
113
|
+
console.error(errorMsg)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
} else if (propName === 'errors') {
|
|
117
|
+
if (ts.isArrayLiteralExpression(prop.initializer)) {
|
|
118
|
+
metadata.errors = prop.initializer.elements
|
|
119
|
+
.filter(ts.isIdentifier)
|
|
120
|
+
.map((element) => element.text as unknown as string)
|
|
121
|
+
} else {
|
|
122
|
+
const errorMsg = `${wiringType} '${wiringName}' has invalid 'errors' property - must be an array of error identifiers.`
|
|
123
|
+
if (logger) {
|
|
124
|
+
logger.critical(ErrorCode.INVALID_TAGS_TYPE, errorMsg)
|
|
125
|
+
} else {
|
|
126
|
+
console.error(errorMsg)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
115
130
|
}
|
|
116
|
-
|
|
117
|
-
}
|
|
131
|
+
})
|
|
118
132
|
|
|
119
|
-
return
|
|
133
|
+
return metadata
|
|
120
134
|
}
|
|
@@ -256,12 +256,12 @@ function createMockObjectLiteral(): any {
|
|
|
256
256
|
function createMockState(): InspectorState {
|
|
257
257
|
return {
|
|
258
258
|
singletonServicesTypeImportMap: new Map(),
|
|
259
|
-
|
|
259
|
+
wireServicesTypeImportMap: new Map(),
|
|
260
260
|
userSessionTypeImportMap: new Map(),
|
|
261
261
|
configTypeImportMap: new Map(),
|
|
262
262
|
singletonServicesFactories: new Map(),
|
|
263
|
-
|
|
264
|
-
|
|
263
|
+
wireServicesFactories: new Map(),
|
|
264
|
+
wireServicesMeta: new Map(),
|
|
265
265
|
configFactories: new Map(),
|
|
266
266
|
filesAndMethods: {},
|
|
267
267
|
filesAndMethodsErrors: new Map(),
|