@pikku/inspector 0.12.0 → 0.12.1

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 (109) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/add/add-ai-agent.d.ts +1 -1
  3. package/dist/add/add-ai-agent.js +1 -1
  4. package/dist/add/add-channel.js +12 -0
  5. package/dist/add/add-cli.d.ts +1 -1
  6. package/dist/add/add-cli.js +6 -1
  7. package/dist/add/add-file-extends-core-type.d.ts +1 -1
  8. package/dist/add/add-file-with-config.d.ts +1 -1
  9. package/dist/add/add-file-with-factory.d.ts +1 -1
  10. package/dist/add/add-file-with-factory.js +2 -2
  11. package/dist/add/add-functions.d.ts +1 -1
  12. package/dist/add/add-functions.js +6 -7
  13. package/dist/add/add-http-route.d.ts +3 -2
  14. package/dist/add/add-http-route.js +5 -1
  15. package/dist/add/add-http-routes.d.ts +1 -1
  16. package/dist/add/add-http-routes.js +1 -0
  17. package/dist/add/add-keyed-wiring.d.ts +1 -1
  18. package/dist/add/add-mcp-prompt.d.ts +1 -1
  19. package/dist/add/add-mcp-resource.d.ts +1 -1
  20. package/dist/add/add-queue-worker.d.ts +1 -1
  21. package/dist/add/add-rpc-invocations.d.ts +3 -3
  22. package/dist/add/add-rpc-invocations.js +10 -10
  23. package/dist/add/add-schedule.d.ts +1 -1
  24. package/dist/add/add-secret.d.ts +1 -1
  25. package/dist/add/add-trigger.d.ts +1 -1
  26. package/dist/add/add-trigger.js +2 -2
  27. package/dist/add/add-wire-addon.d.ts +7 -0
  28. package/dist/add/add-wire-addon.js +70 -0
  29. package/dist/add/add-workflow.d.ts +1 -1
  30. package/dist/error-codes.d.ts +1 -0
  31. package/dist/error-codes.js +1 -0
  32. package/dist/index.d.ts +1 -1
  33. package/dist/inspector.d.ts +1 -1
  34. package/dist/inspector.js +7 -4
  35. package/dist/types.d.ts +26 -20
  36. package/dist/utils/compute-required-schemas.js +1 -2
  37. package/dist/utils/contract-hashes.d.ts +20 -3
  38. package/dist/utils/contract-hashes.js +77 -10
  39. package/dist/utils/custom-types-generator.d.ts +1 -1
  40. package/dist/utils/detect-schema-vendor.d.ts +1 -1
  41. package/dist/utils/does-type-extend-core-type.d.ts +1 -1
  42. package/dist/utils/ensure-function-metadata.d.ts +1 -1
  43. package/dist/utils/extract-services.d.ts +1 -1
  44. package/dist/utils/filter-inspector-state.d.ts +1 -1
  45. package/dist/utils/filter-utils.d.ts +2 -2
  46. package/dist/utils/get-files-and-methods.d.ts +1 -1
  47. package/dist/utils/middleware.d.ts +2 -2
  48. package/dist/utils/permissions.d.ts +2 -2
  49. package/dist/utils/post-process.d.ts +4 -3
  50. package/dist/utils/post-process.js +24 -8
  51. package/dist/utils/resolve-addon-package.d.ts +16 -0
  52. package/dist/utils/{resolve-external-package.js → resolve-addon-package.js} +8 -8
  53. package/dist/utils/schema-generator.d.ts +2 -2
  54. package/dist/utils/serialize-inspector-state.d.ts +13 -3
  55. package/dist/utils/serialize-inspector-state.js +6 -2
  56. package/dist/utils/validate-auth-sessionless.d.ts +3 -0
  57. package/dist/utils/validate-auth-sessionless.js +14 -0
  58. package/dist/utils/workflow/dsl/extract-dsl-workflow.d.ts +1 -1
  59. package/dist/visit.d.ts +1 -1
  60. package/dist/visit.js +2 -0
  61. package/package.json +2 -2
  62. package/src/add/add-ai-agent.ts +2 -2
  63. package/src/add/add-channel.ts +21 -0
  64. package/src/add/add-cli.ts +19 -4
  65. package/src/add/add-file-extends-core-type.ts +1 -1
  66. package/src/add/add-file-with-config.ts +1 -1
  67. package/src/add/add-file-with-factory.ts +3 -3
  68. package/src/add/add-functions.ts +21 -19
  69. package/src/add/add-http-route.ts +19 -2
  70. package/src/add/add-http-routes.ts +2 -1
  71. package/src/add/add-keyed-wiring.ts +1 -1
  72. package/src/add/add-mcp-prompt.ts +1 -1
  73. package/src/add/add-mcp-resource.ts +1 -1
  74. package/src/add/add-queue-worker.ts +1 -1
  75. package/src/add/add-rpc-invocations.ts +11 -11
  76. package/src/add/add-schedule.ts +1 -1
  77. package/src/add/add-secret.ts +1 -1
  78. package/src/add/add-trigger.ts +4 -4
  79. package/src/add/add-wire-addon.ts +80 -0
  80. package/src/add/add-workflow.ts +2 -2
  81. package/src/error-codes.ts +1 -0
  82. package/src/index.ts +1 -0
  83. package/src/inspector.ts +13 -5
  84. package/src/types.ts +33 -20
  85. package/src/utils/compute-required-schemas.ts +1 -2
  86. package/src/utils/contract-hashes.test.ts +30 -5
  87. package/src/utils/contract-hashes.ts +110 -14
  88. package/src/utils/custom-types-generator.ts +1 -1
  89. package/src/utils/detect-schema-vendor.ts +1 -1
  90. package/src/utils/does-type-extend-core-type.ts +1 -1
  91. package/src/utils/ensure-function-metadata.ts +1 -1
  92. package/src/utils/extract-services.ts +1 -1
  93. package/src/utils/filter-inspector-state.test.ts +3 -5
  94. package/src/utils/filter-inspector-state.ts +7 -2
  95. package/src/utils/filter-utils.test.ts +1 -1
  96. package/src/utils/filter-utils.ts +2 -2
  97. package/src/utils/get-files-and-methods.ts +1 -1
  98. package/src/utils/middleware.ts +2 -2
  99. package/src/utils/permissions.ts +2 -2
  100. package/src/utils/post-process.ts +34 -12
  101. package/src/utils/{resolve-external-package.ts → resolve-addon-package.ts} +17 -10
  102. package/src/utils/resolve-versions.test.ts +1 -1
  103. package/src/utils/schema-generator.ts +4 -4
  104. package/src/utils/serialize-inspector-state.ts +23 -5
  105. package/src/utils/validate-auth-sessionless.ts +29 -0
  106. package/src/utils/workflow/dsl/extract-dsl-workflow.ts +2 -2
  107. package/src/visit.ts +7 -1
  108. package/tsconfig.tsbuildinfo +1 -1
  109. package/dist/utils/resolve-external-package.d.ts +0 -12
@@ -0,0 +1,29 @@
1
+ import * as ts from 'typescript'
2
+ import { getPropertyValue } from './get-property-value.js'
3
+ import { ErrorCode } from '../error-codes.js'
4
+ import type { InspectorLogger, InspectorState } from '../types.js'
5
+
6
+ export function validateAuthSessionless(
7
+ logger: InspectorLogger,
8
+ obj: ts.ObjectLiteralExpression,
9
+ state: InspectorState,
10
+ funcName: string,
11
+ wireDescription: string,
12
+ inheritedAuth?: boolean
13
+ ): boolean {
14
+ const fnMeta = state.functions.meta[funcName]
15
+ if (!fnMeta) return true
16
+
17
+ const routeAuth = getPropertyValue(obj, 'auth')
18
+ const resolvedAuth =
19
+ routeAuth === true || routeAuth === false ? routeAuth : inheritedAuth
20
+ if (resolvedAuth === false && fnMeta.sessionless === false) {
21
+ logger.critical(
22
+ ErrorCode.AUTH_DISABLED_REQUIRES_SESSIONLESS,
23
+ `${wireDescription} has auth disabled but function '${funcName}' uses pikkuFunc (requires session). Use pikkuSessionlessFunc instead.`
24
+ )
25
+ return false
26
+ }
27
+
28
+ return true
29
+ }
@@ -1,5 +1,5 @@
1
1
  import * as ts from 'typescript'
2
- import {
2
+ import type {
3
3
  WorkflowStepMeta,
4
4
  RpcStepMeta,
5
5
  BranchStepMeta,
@@ -33,11 +33,11 @@ import {
33
33
  isArrayType,
34
34
  getSourceText,
35
35
  } from './patterns.js'
36
+ import type { ValidationError } from './validation.js'
36
37
  import {
37
38
  validateNoDisallowedPatterns,
38
39
  validateAwaitedCalls,
39
40
  formatValidationErrors,
40
- ValidationError,
41
41
  } from './validation.js'
42
42
  import {
43
43
  extractStringLiteral,
package/src/visit.ts CHANGED
@@ -9,10 +9,15 @@ import { addQueueWorker } from './add/add-queue-worker.js'
9
9
  import { addWorkflow } from './add/add-workflow.js'
10
10
  import { addMCPResource } from './add/add-mcp-resource.js'
11
11
  import { addMCPPrompt } from './add/add-mcp-prompt.js'
12
- import { InspectorState, InspectorLogger, InspectorOptions } from './types.js'
12
+ import type {
13
+ InspectorState,
14
+ InspectorLogger,
15
+ InspectorOptions,
16
+ } from './types.js'
13
17
  import { addFunctions } from './add/add-functions.js'
14
18
  import { addChannel } from './add/add-channel.js'
15
19
  import { addRPCInvocations } from './add/add-rpc-invocations.js'
20
+ import { addWireAddon } from './add/add-wire-addon.js'
16
21
  import { addMiddleware } from './add/add-middleware.js'
17
22
  import { addPermission } from './add/add-permission.js'
18
23
  import { addCLI, addCLIRenderers } from './add/add-cli.js'
@@ -78,6 +83,7 @@ export const visitSetup = (
78
83
  addFileWithFactory(node, checker, state.configFactories, 'CreateConfig')
79
84
 
80
85
  addRPCInvocations(node, state, logger)
86
+ addWireAddon(node, state, logger)
81
87
  addMiddleware(logger, node, checker, state, options)
82
88
  addPermission(logger, node, checker, state, options)
83
89
  addWorkflow(logger, node, checker, state, options)