@pikku/inspector 0.12.10 → 0.12.11

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.
@@ -18,6 +18,7 @@ import { resolveHTTPMiddlewareFromObject } from '../utils/middleware.js'
18
18
  import { resolveHTTPPermissionsFromObject } from '../utils/permissions.js'
19
19
  import { extractWireNames } from '../utils/post-process.js'
20
20
  import { ensureFunctionMetadata } from '../utils/ensure-function-metadata.js'
21
+ import { resolveFunctionMeta } from '../utils/resolve-function-meta.js'
21
22
  import { ErrorCode } from '../error-codes.js'
22
23
  import { validateAuthSessionless } from '../utils/validate-auth-sessionless.js'
23
24
  import { detectSchemaVendorOrError } from '../utils/detect-schema-vendor.js'
@@ -204,6 +205,22 @@ export function registerHTTPRoute({
204
205
  funcName = makeContextBasedId('http', method, fullRoute)
205
206
  }
206
207
 
208
+ let refAddonTarget: string | null = null
209
+ if (
210
+ ts.isCallExpression(funcInitializer) &&
211
+ ts.isIdentifier(funcInitializer.expression) &&
212
+ funcInitializer.expression.text === 'ref'
213
+ ) {
214
+ const [firstArg] = funcInitializer.arguments
215
+ if (
216
+ firstArg &&
217
+ ts.isStringLiteral(firstArg) &&
218
+ firstArg.text.includes(':')
219
+ ) {
220
+ refAddonTarget = firstArg.text
221
+ }
222
+ }
223
+
207
224
  const packageName = ts.isIdentifier(funcInitializer)
208
225
  ? resolveAddonName(
209
226
  funcInitializer,
@@ -212,6 +229,16 @@ export function registerHTTPRoute({
212
229
  )
213
230
  : null
214
231
 
232
+ if (refAddonTarget) {
233
+ const targetMeta = resolveFunctionMeta(state, refAddonTarget)
234
+ if (!targetMeta) {
235
+ logger.warn(
236
+ `Skipping route '${fullRoute}': addon function metadata for '${refAddonTarget}' is not available yet.`
237
+ )
238
+ return
239
+ }
240
+ }
241
+
215
242
  ensureFunctionMetadata(
216
243
  state,
217
244
  funcName,
@@ -222,7 +249,7 @@ export function registerHTTPRoute({
222
249
  )
223
250
 
224
251
  // Lookup existing function metadata
225
- const fnMeta = state.functions.meta[funcName]
252
+ const fnMeta = resolveFunctionMeta(state, funcName)
226
253
  if (!fnMeta) {
227
254
  logger.critical(
228
255
  ErrorCode.FUNCTION_METADATA_NOT_FOUND,
@@ -53,6 +53,7 @@ export enum ErrorCode {
53
53
 
54
54
  // Versioning errors
55
55
  DUPLICATE_FUNCTION_VERSION = 'PKU850',
56
+ DUPLICATE_FUNCTION_NAME = 'PKU851',
56
57
 
57
58
  // Contract versioning errors
58
59
  MANIFEST_MISSING = 'PKU860',
@@ -375,7 +375,7 @@ async function generateZodSchemas(
375
375
  const uniqueSourceFiles = [
376
376
  ...new Set([...schemaLookup.values()].map((ref) => ref.sourceFile)),
377
377
  ]
378
- console.log(
378
+ logger.info(
379
379
  `[TIMING] Zod schemas: ${schemaLookup.size} schemas from ${uniqueSourceFiles.length} files`
380
380
  )
381
381
 
@@ -384,7 +384,7 @@ async function generateZodSchemas(
384
384
  logger,
385
385
  uniqueSourceFiles
386
386
  )
387
- console.log(
387
+ logger.info(
388
388
  `[TIMING] Batch import: ${(performance.now() - importStart).toFixed(0)}ms`
389
389
  )
390
390
 
@@ -456,7 +456,7 @@ async function generateZodSchemas(
456
456
  }
457
457
  }
458
458
 
459
- console.log(
459
+ logger.info(
460
460
  `[TIMING] Process schemas: ${(performance.now() - processStart).toFixed(0)}ms (${Object.keys(schemas).length} generated)`
461
461
  )
462
462
  return schemas
@@ -1,4 +1,4 @@
1
- import * as ts from 'typescript'
1
+ import type * as ts from 'typescript'
2
2
  import { getPropertyValue } from './get-property-value.js'
3
3
  import { ErrorCode } from '../error-codes.js'
4
4
  import type { InspectorLogger, InspectorState } from '../types.js'