@pikku/inspector 0.12.11 → 0.12.13
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 -0
- package/dist/add/add-cli.js +10 -3
- package/dist/add/add-credential.js +2 -1
- package/dist/add/add-functions.js +48 -1
- package/dist/add/add-http-route.js +24 -5
- 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 +3 -1
- package/dist/error-codes.js +3 -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/check-pii-output.d.ts +14 -0
- package/dist/utils/check-pii-output.js +63 -0
- 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/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 +149 -0
- package/src/add/add-functions.ts +61 -1
- package/src/add/add-gateway.ts +5 -1
- package/src/add/add-http-route.ts +26 -6
- 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/pii-check.test.ts +197 -0
- package/src/add/wire-name-literal.test.ts +114 -0
- package/src/error-codes.ts +4 -0
- package/src/index.ts +1 -0
- package/src/inspector.ts +1 -5
- package/src/types.ts +19 -15
- package/src/utils/check-pii-output.ts +76 -0
- 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/tsconfig.tsbuildinfo +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as ts from 'typescript'
|
|
2
2
|
import { dirname, join, resolve } from 'path'
|
|
3
3
|
import { createGenerator, RootlessError } from 'ts-json-schema-generator'
|
|
4
|
-
import { register
|
|
4
|
+
import { register } from 'tsx/esm/api'
|
|
5
5
|
import * as z from 'zod'
|
|
6
6
|
import { zodToTs, createAuxiliaryTypeStore } from 'zod-to-ts'
|
|
7
7
|
import type { FunctionsMeta, JSONValue } from '@pikku/core'
|
|
@@ -273,7 +273,7 @@ async function batchImportWithRegister(
|
|
|
273
273
|
): Promise<Map<string, Record<string, any>> | null> {
|
|
274
274
|
if (sourceFiles.length === 0) return new Map()
|
|
275
275
|
|
|
276
|
-
let unregister: (() => void) | undefined
|
|
276
|
+
let unregister: (() => void | Promise<void>) | undefined
|
|
277
277
|
try {
|
|
278
278
|
unregister = register()
|
|
279
279
|
|
|
@@ -297,7 +297,18 @@ async function batchImportWithRegister(
|
|
|
297
297
|
logger.debug(`tsx register() batch import failed: ${(e as Error).message}`)
|
|
298
298
|
return null
|
|
299
299
|
} finally {
|
|
300
|
-
unregister?.()
|
|
300
|
+
await unregister?.()
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
async function importWithRegister(
|
|
305
|
+
sourceFile: string
|
|
306
|
+
): Promise<Record<string, any>> {
|
|
307
|
+
const unregister = register()
|
|
308
|
+
try {
|
|
309
|
+
return await import(sourceFile)
|
|
310
|
+
} finally {
|
|
311
|
+
await unregister()
|
|
301
312
|
}
|
|
302
313
|
}
|
|
303
314
|
|
|
@@ -350,6 +361,7 @@ async function generateZodSchemas(
|
|
|
350
361
|
typesMap: TypesMap
|
|
351
362
|
): Promise<Record<string, JSONValue>> {
|
|
352
363
|
const schemas: Record<string, JSONValue> = {}
|
|
364
|
+
const errors: string[] = []
|
|
353
365
|
const auxiliaryTypeStore = createAuxiliaryTypeStore()
|
|
354
366
|
const printer = ts.createPrinter()
|
|
355
367
|
const fakeSourceFile = ts.createSourceFile(
|
|
@@ -375,7 +387,7 @@ async function generateZodSchemas(
|
|
|
375
387
|
const uniqueSourceFiles = [
|
|
376
388
|
...new Set([...schemaLookup.values()].map((ref) => ref.sourceFile)),
|
|
377
389
|
]
|
|
378
|
-
logger.
|
|
390
|
+
logger.debug(
|
|
379
391
|
`[TIMING] Zod schemas: ${schemaLookup.size} schemas from ${uniqueSourceFiles.length} files`
|
|
380
392
|
)
|
|
381
393
|
|
|
@@ -384,7 +396,7 @@ async function generateZodSchemas(
|
|
|
384
396
|
logger,
|
|
385
397
|
uniqueSourceFiles
|
|
386
398
|
)
|
|
387
|
-
logger.
|
|
399
|
+
logger.debug(
|
|
388
400
|
`[TIMING] Batch import: ${(performance.now() - importStart).toFixed(0)}ms`
|
|
389
401
|
)
|
|
390
402
|
|
|
@@ -397,7 +409,7 @@ async function generateZodSchemas(
|
|
|
397
409
|
if (mod) {
|
|
398
410
|
const zodSchema = mod[ref.variableName]
|
|
399
411
|
if (!zodSchema) {
|
|
400
|
-
|
|
412
|
+
errors.push(
|
|
401
413
|
`Could not find exported schema '${ref.variableName}' in ${ref.sourceFile} for ${schemaName}. Available exports: ${Object.keys(mod).join(', ')}`
|
|
402
414
|
)
|
|
403
415
|
continue
|
|
@@ -414,7 +426,7 @@ async function generateZodSchemas(
|
|
|
414
426
|
logger
|
|
415
427
|
)
|
|
416
428
|
} catch (e) {
|
|
417
|
-
|
|
429
|
+
errors.push(
|
|
418
430
|
`Could not convert Zod schema '${schemaName}': ${e instanceof Error ? e.message : e}`
|
|
419
431
|
)
|
|
420
432
|
}
|
|
@@ -423,17 +435,20 @@ async function generateZodSchemas(
|
|
|
423
435
|
}
|
|
424
436
|
}
|
|
425
437
|
|
|
426
|
-
// Fallback: use
|
|
438
|
+
// Fallback: use a scoped tsx register/import cycle for any schemas that
|
|
439
|
+
// batch import couldn't handle. Avoid tsImport() here because its ESM path
|
|
440
|
+
// can leave loader plumbing alive after failed imports, which prevents the
|
|
441
|
+
// CLI process from exiting on schema errors.
|
|
427
442
|
if (fallbackSchemas.length > 0) {
|
|
428
443
|
logger.debug(
|
|
429
|
-
`Falling back to
|
|
444
|
+
`Falling back to register() import for ${fallbackSchemas.length} schema(s)`
|
|
430
445
|
)
|
|
431
446
|
for (const [schemaName, ref] of fallbackSchemas) {
|
|
432
447
|
try {
|
|
433
|
-
const module = await
|
|
448
|
+
const module = await importWithRegister(ref.sourceFile)
|
|
434
449
|
const zodSchema = module[ref.variableName]
|
|
435
450
|
if (!zodSchema) {
|
|
436
|
-
|
|
451
|
+
errors.push(
|
|
437
452
|
`Could not find exported schema '${ref.variableName}' in ${ref.sourceFile} for ${schemaName}. Available exports: ${Object.keys(module).join(', ')}`
|
|
438
453
|
)
|
|
439
454
|
continue
|
|
@@ -449,14 +464,23 @@ async function generateZodSchemas(
|
|
|
449
464
|
logger
|
|
450
465
|
)
|
|
451
466
|
} catch (e) {
|
|
452
|
-
|
|
467
|
+
errors.push(
|
|
453
468
|
`Could not convert Zod schema '${schemaName}': ${e instanceof Error ? e.message : e}`
|
|
454
469
|
)
|
|
455
470
|
}
|
|
456
471
|
}
|
|
457
472
|
}
|
|
458
473
|
|
|
459
|
-
|
|
474
|
+
if (errors.length > 0) {
|
|
475
|
+
for (const message of errors) {
|
|
476
|
+
logger.error(message)
|
|
477
|
+
}
|
|
478
|
+
throw new Error(
|
|
479
|
+
`Schema generation failed for ${errors.length} schema${errors.length === 1 ? '' : 's'}`
|
|
480
|
+
)
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
logger.debug(
|
|
460
484
|
`[TIMING] Process schemas: ${(performance.now() - processStart).toFixed(0)}ms (${Object.keys(schemas).length} generated)`
|
|
461
485
|
)
|
|
462
486
|
return schemas
|