@pikku/cli 0.11.2 → 0.11.3
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/.pikku/channel/pikku-channel-types.gen.ts +63 -6
- package/.pikku/channel/pikku-channels-map.gen.d.ts +4 -4
- package/.pikku/channel/pikku-channels-meta.gen.ts +4 -2
- package/.pikku/channel/pikku-channels.gen.ts +1 -1
- package/.pikku/cli/pikku-cli-channel.ts +1 -1
- package/.pikku/cli/pikku-cli-client.gen.ts +1 -1
- package/.pikku/cli/pikku-cli-types.gen.ts +1 -1
- package/.pikku/cli/pikku-cli-wirings-meta.gen.json +2 -1
- package/.pikku/cli/pikku-cli-wirings-meta.gen.ts +2 -2
- package/.pikku/cli/pikku-cli-wirings.gen.ts +1 -1
- package/.pikku/cli/pikku-cli.gen.ts +1 -1
- package/.pikku/forge/pikku-forge-types.gen.ts +83 -0
- package/.pikku/function/pikku-function-types.gen.ts +181 -35
- package/.pikku/function/pikku-functions-meta-verbose.gen.json +1030 -0
- package/.pikku/function/pikku-functions-meta.gen.json +88 -420
- package/.pikku/function/pikku-functions-meta.gen.ts +2 -2
- package/.pikku/http/pikku-http-types.gen.ts +19 -3
- package/.pikku/http/pikku-http-wirings-map.gen.d.ts +4 -4
- package/.pikku/http/pikku-http-wirings-meta.gen.json +9 -0
- package/.pikku/http/pikku-http-wirings-meta.gen.ts +4 -10
- package/.pikku/http/pikku-http-wirings.gen.ts +1 -1
- package/.pikku/mcp/pikku-mcp-types.gen.ts +69 -17
- package/.pikku/mcp/pikku-mcp-wirings-meta.gen.ts +4 -4
- package/.pikku/mcp/pikku-mcp-wirings.gen.ts +1 -1
- package/.pikku/pikku-bootstrap.gen.ts +7 -9
- package/.pikku/pikku-services.gen.ts +3 -2
- package/.pikku/pikku-types.gen.ts +4 -1
- package/.pikku/pikku-websocket.gen.ts +1 -1
- package/.pikku/queue/pikku-queue-types.gen.ts +1 -1
- package/.pikku/queue/pikku-queue-workers-wirings-map.gen.d.ts +4 -4
- package/.pikku/queue/pikku-queue-workers-wirings-meta.gen.ts +2 -2
- package/.pikku/queue/pikku-queue-workers-wirings.gen.ts +1 -1
- package/.pikku/rpc/pikku-remote-rpc-workers.gen.ts +4 -1
- package/.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts +12 -7
- package/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts +15 -9
- package/.pikku/scheduler/pikku-scheduler-types.gen.ts +1 -1
- package/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.ts +2 -2
- package/.pikku/scheduler/pikku-schedulers-wirings.gen.ts +1 -1
- package/.pikku/schemas/register.gen.ts +9 -1
- package/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuCLIOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuChannelsOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuForgeNodesOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuFunctionsOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuHTTPOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuMCPOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuMiddlewareOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuPackageOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuPermissionsOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuPublicRPCOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuQueueOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuRPCOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuRemoteRPCOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuSchedulerOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuSchemasOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuWorkflowOutput.schema.json +1 -1
- package/.pikku/services/config.gen.json +11 -6
- package/.pikku/services/getInspectorState.gen.json +2 -2
- package/.pikku/services/jwt.gen.json +2 -2
- package/.pikku/services/logger.gen.json +2 -2
- package/.pikku/services/queueService.gen.json +2 -2
- package/.pikku/services/schedulerService.gen.json +2 -2
- package/.pikku/services/schema.gen.json +2 -2
- package/.pikku/services/secrets.gen.json +13 -0
- package/.pikku/services/variables.gen.json +2 -2
- package/.pikku/services/workflowService.gen.json +6 -6
- package/.pikku/workflow/pikku-workflow-map.gen.d.ts +2 -36
- package/.pikku/workflow/pikku-workflow-types.gen.ts +297 -45
- package/.pikku/workflow/pikku-workflow-wirings-meta.gen.ts +5 -4
- package/.pikku/workflow/pikku-workflow-wirings.gen.ts +1 -6
- package/CHANGELOG.md +23 -1
- package/cli.schema.json +1 -1
- package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +47 -5
- package/dist/.pikku/channel/pikku-channel-types.gen.js +3 -13
- package/dist/.pikku/channel/pikku-channels-meta.gen.js +3 -2
- package/dist/.pikku/channel/pikku-channels.gen.d.ts +1 -1
- package/dist/.pikku/channel/pikku-channels.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-channel.js +1 -1
- package/dist/.pikku/cli/pikku-cli-client.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-client.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-types.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +2 -2
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.json +2 -1
- package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli.gen.js +1 -1
- package/dist/.pikku/forge/pikku-forge-types.gen.d.ts +72 -0
- package/dist/.pikku/forge/pikku-forge-types.gen.js +55 -0
- package/dist/.pikku/function/pikku-function-types.gen.d.ts +123 -31
- package/dist/.pikku/function/pikku-function-types.gen.js +37 -51
- package/dist/.pikku/function/pikku-functions-meta.gen.js +2 -2
- package/dist/.pikku/function/pikku-functions-meta.gen.json +88 -420
- package/dist/.pikku/http/pikku-http-types.gen.d.ts +18 -3
- package/dist/.pikku/http/pikku-http-types.gen.js +1 -1
- package/dist/.pikku/http/pikku-http-wirings-meta.gen.js +3 -10
- package/dist/.pikku/http/pikku-http-wirings-meta.gen.json +9 -0
- package/dist/.pikku/http/pikku-http-wirings.gen.d.ts +1 -1
- package/dist/.pikku/http/pikku-http-wirings.gen.js +1 -1
- package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +54 -14
- package/dist/.pikku/mcp/pikku-mcp-types.gen.js +7 -31
- package/dist/.pikku/mcp/pikku-mcp-wirings-meta.gen.js +4 -4
- package/dist/.pikku/mcp/pikku-mcp-wirings.gen.d.ts +1 -1
- package/dist/.pikku/mcp/pikku-mcp-wirings.gen.js +1 -1
- package/dist/.pikku/pikku-bootstrap.gen.d.ts +7 -9
- package/dist/.pikku/pikku-bootstrap.gen.js +7 -9
- package/dist/.pikku/pikku-services.gen.d.ts +3 -2
- package/dist/.pikku/pikku-services.gen.js +1 -0
- package/dist/.pikku/pikku-types.gen.d.ts +2 -1
- package/dist/.pikku/pikku-types.gen.js +3 -1
- package/dist/.pikku/pikku-websocket.gen.d.ts +1 -1
- package/dist/.pikku/pikku-websocket.gen.js +1 -1
- package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +1 -1
- package/dist/.pikku/queue/pikku-queue-types.gen.js +1 -1
- package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +2 -2
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +1 -1
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +1 -1
- package/dist/.pikku/rpc/pikku-remote-rpc-workers.gen.d.ts +4 -1
- package/dist/.pikku/rpc/pikku-remote-rpc-workers.gen.js +4 -1
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +1 -1
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +1 -1
- package/dist/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.js +2 -2
- package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.d.ts +1 -1
- package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.js +1 -1
- package/dist/.pikku/schemas/register.gen.js +5 -1
- package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuCLIOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuChannelsOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuForgeNodesOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuFunctionsOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuHTTPOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuMCPOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuMiddlewareOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuPackageOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuPermissionsOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuPublicRPCOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuQueueOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuRPCOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuRemoteRPCOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuSchedulerOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuSchemasOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuWorkflowOutput.schema.json +1 -1
- package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +207 -37
- package/dist/.pikku/workflow/pikku-workflow-types.gen.js +104 -28
- package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +3 -3
- package/dist/.pikku/workflow/pikku-workflow-wirings.gen.d.ts +2 -6
- package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +2 -6
- package/dist/src/functions/commands/all.js +117 -79
- package/dist/src/functions/commands/bootstrap.js +2 -9
- package/dist/src/functions/runtimes/nextjs/pikku-command-nextjs.js +0 -1
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.js +49 -35
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-http-wrapper.js +49 -35
- package/dist/src/functions/wirings/channels/pikku-channels.js +1 -1
- package/dist/src/functions/wirings/channels/pikku-command-channels.js +18 -2
- package/dist/src/functions/wirings/channels/serialize-channel-types.js +62 -5
- package/dist/src/functions/wirings/channels/serialize-typed-channel-map.js +1 -2
- package/dist/src/functions/wirings/cli/pikku-command-cli.js +10 -2
- package/dist/src/functions/wirings/forge/pikku-command-forge-nodes.d.ts +1 -0
- package/dist/src/functions/wirings/forge/pikku-command-forge-nodes.js +90 -0
- package/dist/src/functions/wirings/forge/pikku-command-forge-types.d.ts +1 -0
- package/dist/src/functions/wirings/forge/pikku-command-forge-types.js +26 -0
- package/dist/src/functions/wirings/forge/serialize-forge-types.d.ts +4 -0
- package/dist/src/functions/wirings/forge/serialize-forge-types.js +90 -0
- package/dist/src/functions/wirings/functions/pikku-command-function-types-split.js +1 -1
- package/dist/src/functions/wirings/functions/pikku-command-function-types.js +7 -2
- package/dist/src/functions/wirings/functions/pikku-command-functions.js +33 -18
- package/dist/src/functions/wirings/functions/pikku-command-services.js +1 -1
- package/dist/src/functions/wirings/functions/pikku-function-types.js +2 -2
- package/dist/src/functions/wirings/functions/schemas.d.ts +1 -1
- package/dist/src/functions/wirings/functions/schemas.js +5 -4
- package/dist/src/functions/wirings/functions/serialize-function-imports.d.ts +3 -1
- package/dist/src/functions/wirings/functions/serialize-function-imports.js +7 -3
- package/dist/src/functions/wirings/functions/serialize-function-types.d.ts +1 -1
- package/dist/src/functions/wirings/functions/serialize-function-types.js +181 -34
- package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.d.ts +1 -1
- package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.js +19 -21
- package/dist/src/functions/wirings/http/openapi-spec-generator.js +1 -1
- package/dist/src/functions/wirings/http/pikku-command-http-routes.js +18 -2
- package/dist/src/functions/wirings/http/pikku-command-openapi.js +2 -2
- package/dist/src/functions/wirings/http/pikku-http-routes.js +1 -1
- package/dist/src/functions/wirings/http/serialize-http-types.js +18 -2
- package/dist/src/functions/wirings/http/serialize-typed-http-map.js +33 -8
- package/dist/src/functions/wirings/mcp/pikku-command-mcp.js +15 -6
- package/dist/src/functions/wirings/mcp/serialize-mcp-json.js +3 -2
- package/dist/src/functions/wirings/mcp/serialize-mcp-types.js +68 -16
- package/dist/src/functions/wirings/middleware/pikku-command-middleware.js +5 -2
- package/dist/src/functions/wirings/package/pikku-command-package.d.ts +1 -0
- package/dist/src/functions/wirings/package/pikku-command-package.js +58 -0
- package/dist/src/functions/wirings/package/serialize-package.d.ts +5 -0
- package/dist/src/functions/wirings/package/serialize-package.js +32 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue.js +10 -2
- package/dist/src/functions/wirings/queue/pikku-queue.js +1 -9
- package/dist/src/functions/wirings/queue/serialize-queue-map.js +20 -3
- package/dist/src/functions/wirings/queue/serialize-queue-meta.js +1 -1
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-map.js +4 -4
- package/dist/src/functions/wirings/rpc/pikku-command-rpc.js +1 -1
- package/dist/src/functions/wirings/rpc/serialize-remote-rpc.js +3 -0
- package/dist/src/functions/wirings/rpc/serialize-rpc-wrapper.js +1 -1
- package/dist/src/functions/wirings/rpc/serialize-typed-rpc-map.d.ts +1 -1
- package/dist/src/functions/wirings/rpc/serialize-typed-rpc-map.js +54 -8
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler.js +10 -1
- package/dist/src/functions/wirings/scheduler/serialize-scheduler-meta.js +1 -1
- package/dist/src/functions/wirings/workflow/pikku-command-workflow.js +56 -18
- package/dist/src/functions/wirings/workflow/serialize-workflow-map.d.ts +3 -0
- package/dist/src/functions/wirings/workflow/serialize-workflow-map.js +30 -32
- package/dist/src/functions/wirings/workflow/serialize-workflow-meta.d.ts +1 -3
- package/dist/src/functions/wirings/workflow/serialize-workflow-meta.js +43 -18
- package/dist/src/functions/wirings/workflow/serialize-workflow-registration.d.ts +7 -0
- package/dist/src/functions/wirings/workflow/serialize-workflow-registration.js +53 -0
- package/dist/src/functions/wirings/workflow/serialize-workflow-types.d.ts +3 -1
- package/dist/src/functions/wirings/workflow/serialize-workflow-types.js +299 -45
- package/dist/src/functions/wirings/workflow/serialize-workflow-workers.d.ts +1 -1
- package/dist/src/functions/wirings/workflow/serialize-workflow-workers.js +14 -27
- package/dist/src/services.js +4 -1
- package/dist/src/utils/command-summary.d.ts +2 -0
- package/dist/src/utils/command-summary.js +2 -0
- package/dist/src/utils/custom-types-generator.js +13 -15
- package/dist/src/utils/generate-bootstrap-file.js +1 -1
- package/dist/src/utils/pikku-cli-config.js +37 -9
- package/dist/src/utils/schema-generator.d.ts +4 -3
- package/dist/src/utils/schema-generator.js +135 -15
- package/dist/src/utils/strip-verbose-meta.d.ts +43 -0
- package/dist/src/utils/strip-verbose-meta.js +210 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -4
- package/src/functions/commands/all.ts +144 -97
- package/src/functions/commands/bootstrap.ts +2 -10
- package/src/functions/runtimes/nextjs/pikku-command-nextjs.ts +0 -1
- package/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.ts +49 -35
- package/src/functions/runtimes/nextjs/serialize-nextjs-http-wrapper.ts +49 -35
- package/src/functions/wirings/channels/pikku-channels.ts +1 -1
- package/src/functions/wirings/channels/pikku-command-channels.ts +46 -3
- package/src/functions/wirings/channels/serialize-channel-types.ts +62 -5
- package/src/functions/wirings/channels/serialize-typed-channel-map.ts +3 -2
- package/src/functions/wirings/cli/pikku-command-cli.ts +21 -2
- package/src/functions/wirings/forge/pikku-command-forge-nodes.ts +135 -0
- package/src/functions/wirings/forge/pikku-command-forge-types.ts +38 -0
- package/src/functions/wirings/forge/serialize-forge-types.ts +94 -0
- package/src/functions/wirings/functions/pikku-command-function-types-split.ts +3 -2
- package/src/functions/wirings/functions/pikku-command-function-types.ts +17 -10
- package/src/functions/wirings/functions/pikku-command-functions.ts +47 -37
- package/src/functions/wirings/functions/pikku-command-services.ts +1 -1
- package/src/functions/wirings/functions/pikku-function-types.ts +3 -1
- package/src/functions/wirings/functions/schemas.ts +14 -4
- package/src/functions/wirings/functions/serialize-function-imports.ts +12 -3
- package/src/functions/wirings/functions/serialize-function-types.ts +182 -34
- package/src/functions/wirings/functions/serialize-pikku-types-hub.ts +27 -26
- package/src/functions/wirings/http/openapi-spec-generator.ts +1 -1
- package/src/functions/wirings/http/pikku-command-http-routes.ts +46 -2
- package/src/functions/wirings/http/pikku-command-openapi.ts +3 -2
- package/src/functions/wirings/http/pikku-http-routes.ts +1 -1
- package/src/functions/wirings/http/serialize-http-types.ts +18 -2
- package/src/functions/wirings/http/serialize-typed-http-map.ts +32 -8
- package/src/functions/wirings/mcp/pikku-command-mcp.ts +32 -10
- package/src/functions/wirings/mcp/serialize-mcp-json.ts +8 -6
- package/src/functions/wirings/mcp/serialize-mcp-types.ts +68 -16
- package/src/functions/wirings/middleware/pikku-command-middleware.ts +6 -2
- package/src/functions/wirings/package/pikku-command-package.ts +81 -0
- package/src/functions/wirings/package/serialize-package.ts +69 -0
- package/src/functions/wirings/queue/pikku-command-queue.ts +22 -2
- package/src/functions/wirings/queue/pikku-queue.ts +1 -10
- package/src/functions/wirings/queue/serialize-queue-map.ts +18 -3
- package/src/functions/wirings/queue/serialize-queue-meta.ts +1 -1
- package/src/functions/wirings/rpc/pikku-command-rpc-map.ts +7 -4
- package/src/functions/wirings/rpc/pikku-command-rpc.ts +1 -1
- package/src/functions/wirings/rpc/serialize-remote-rpc.ts +3 -0
- package/src/functions/wirings/rpc/serialize-rpc-wrapper.ts +1 -1
- package/src/functions/wirings/rpc/serialize-typed-rpc-map.ts +74 -8
- package/src/functions/wirings/scheduler/pikku-command-scheduler.ts +22 -1
- package/src/functions/wirings/scheduler/serialize-scheduler-meta.ts +1 -1
- package/src/functions/wirings/workflow/pikku-command-workflow.ts +104 -37
- package/src/functions/wirings/workflow/serialize-workflow-map.ts +38 -40
- package/src/functions/wirings/workflow/serialize-workflow-meta.ts +66 -26
- package/src/functions/wirings/workflow/serialize-workflow-registration.ts +83 -0
- package/src/functions/wirings/workflow/serialize-workflow-types.ts +299 -45
- package/src/functions/wirings/workflow/serialize-workflow-workers.ts +14 -27
- package/src/services.ts +8 -1
- package/src/utils/command-summary.ts +4 -0
- package/src/utils/custom-types-generator.ts +15 -15
- package/src/utils/generate-bootstrap-file.ts +1 -1
- package/src/utils/pikku-cli-config.ts +51 -18
- package/src/utils/schema-generator.ts +185 -22
- package/src/utils/strip-verbose-meta.ts +254 -0
- package/types/config.d.ts +37 -3
- package/.pikku/function/pikku-functions-meta.min.gen.json +0 -212
- package/.pikku/function/pikku-functions-meta.min.gen.ts +0 -6
- package/dist/.pikku/function/pikku-functions-meta.min.gen.d.ts +0 -1
- package/dist/.pikku/function/pikku-functions-meta.min.gen.js +0 -6
- package/dist/.pikku/function/pikku-functions-meta.min.gen.json +0 -212
- package/dist/src/functions/wirings/workflow/pikku-command-workflow-map.d.ts +0 -1
- package/dist/src/functions/wirings/workflow/pikku-command-workflow-map.js +0 -12
- package/dist/src/functions/wirings/workflow/pikku-command-workflow-types.d.ts +0 -1
- package/dist/src/functions/wirings/workflow/pikku-command-workflow-types.js +0 -13
- package/dist/src/functions/wirings/workflow/serialize-workflow-wirings.d.ts +0 -8
- package/dist/src/functions/wirings/workflow/serialize-workflow-wirings.js +0 -30
- package/src/functions/wirings/workflow/pikku-command-workflow-map.ts +0 -24
- package/src/functions/wirings/workflow/pikku-command-workflow-types.ts +0 -29
- package/src/functions/wirings/workflow/serialize-workflow-wirings.ts +0 -47
- /package/.pikku/{workflow/pikku-workflow-wirings-meta.gen.json → channel/pikku-channels-meta.gen.json} +0 -0
- /package/dist/.pikku/{workflow/pikku-workflow-wirings-meta.gen.json → channel/pikku-channels-meta.gen.json} +0 -0
|
@@ -8,7 +8,7 @@ export const serializeHTTPTypes = (functionTypesImportPath) => {
|
|
|
8
8
|
|
|
9
9
|
import { AssertHTTPWiringParams, wireHTTP as wireHTTPCore, addHTTPMiddleware as addHTTPMiddlewareCore, addHTTPPermission as addHTTPPermissionCore } from '@pikku/core/http'
|
|
10
10
|
import type { PikkuFunction, PikkuFunctionSessionless, PikkuPermission, PikkuMiddleware } from '${functionTypesImportPath}'
|
|
11
|
-
import type { CoreHTTPFunctionWiring } from '@pikku/core/http'
|
|
11
|
+
import type { CoreHTTPFunctionWiring, HTTPMethod } from '@pikku/core/http'
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Type definition for HTTP API wirings with type-safe path parameters.
|
|
@@ -20,6 +20,22 @@ import type { CoreHTTPFunctionWiring } from '@pikku/core/http'
|
|
|
20
20
|
*/
|
|
21
21
|
type HTTPWiring<In, Out, Route extends string> = CoreHTTPFunctionWiring<In, Out, Route, PikkuFunction<In, Out, 'rpc' | 'session'>, PikkuFunctionSessionless<In, Out, 'rpc' | 'session'>, PikkuPermission<In>, PikkuMiddleware>
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* HTTP wiring for workflow triggers (no function needed)
|
|
25
|
+
*/
|
|
26
|
+
type HTTPWorkflowWiring<Route extends string> = {
|
|
27
|
+
route: Route
|
|
28
|
+
method: HTTPMethod
|
|
29
|
+
workflow: true
|
|
30
|
+
func?: undefined
|
|
31
|
+
permissions?: undefined
|
|
32
|
+
auth?: undefined
|
|
33
|
+
tags?: undefined
|
|
34
|
+
middleware?: undefined
|
|
35
|
+
returnsJSON?: undefined
|
|
36
|
+
sse?: boolean
|
|
37
|
+
}
|
|
38
|
+
|
|
23
39
|
/**
|
|
24
40
|
* Registers an HTTP wiring with the Pikku framework.
|
|
25
41
|
*
|
|
@@ -29,7 +45,7 @@ type HTTPWiring<In, Out, Route extends string> = CoreHTTPFunctionWiring<In, Out,
|
|
|
29
45
|
* @param httpWiring - HTTP wiring definition with handler, method, and optional middleware
|
|
30
46
|
*/
|
|
31
47
|
export const wireHTTP = <In, Out, Route extends string>(
|
|
32
|
-
httpWiring: HTTPWiring<In, Out, Route> & AssertHTTPWiringParams<In, Route>
|
|
48
|
+
httpWiring: (HTTPWiring<In, Out, Route> & AssertHTTPWiringParams<In, Route>) | HTTPWorkflowWiring<Route>
|
|
33
49
|
) => {
|
|
34
50
|
wireHTTPCore(httpWiring as any)
|
|
35
51
|
}
|
|
@@ -9,7 +9,7 @@ export const serializeTypedHTTPWiringsMap = (relativeToPath, packageMappings, ty
|
|
|
9
9
|
return `/**
|
|
10
10
|
* This provides the structure needed for typescript to be aware of routes and their return types
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
${serializedImportMap}
|
|
14
14
|
${serializedCustomTypes}
|
|
15
15
|
${serializedMetaTypes}
|
|
@@ -37,21 +37,39 @@ function generateHTTPWirings(routesMeta, functionsMeta, typesMap, requiredTypes)
|
|
|
37
37
|
for (const methods of Object.values(routesMeta)) {
|
|
38
38
|
for (const meta of Object.values(methods)) {
|
|
39
39
|
const { route, method, pikkuFuncName } = meta;
|
|
40
|
+
// Skip workflow-triggered routes (they don't have a function)
|
|
41
|
+
if (meta.workflow) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
40
44
|
const functionMeta = functionsMeta[pikkuFuncName];
|
|
41
45
|
if (!functionMeta) {
|
|
42
46
|
throw new Error(`Function ${pikkuFuncName} not found in functionsMeta. Please check your configuration.`);
|
|
43
47
|
}
|
|
44
48
|
const input = functionMeta.inputs ? functionMeta.inputs[0] : undefined;
|
|
45
49
|
const output = functionMeta.outputs ? functionMeta.outputs[0] : undefined;
|
|
46
|
-
// Initialize the route entry if it doesn't exist
|
|
47
50
|
if (!routesObj[route]) {
|
|
48
51
|
routesObj[route] = {};
|
|
49
52
|
}
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
// For zod-derived schemas, the type might not be in typesMap, so use the schema name directly
|
|
54
|
+
let inputType = 'null';
|
|
55
|
+
if (input) {
|
|
56
|
+
try {
|
|
57
|
+
inputType = typesMap.getTypeMeta(input).uniqueName;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
inputType = input;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
let outputType = 'null';
|
|
64
|
+
if (output) {
|
|
65
|
+
try {
|
|
66
|
+
outputType = typesMap.getTypeMeta(output).uniqueName;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// Zod-derived schema - use the schema name directly
|
|
70
|
+
outputType = output;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
55
73
|
requiredTypes.add(inputType);
|
|
56
74
|
requiredTypes.add(outputType);
|
|
57
75
|
// Add method entry
|
|
@@ -75,7 +93,14 @@ function generateHTTPWirings(routesMeta, functionsMeta, typesMap, requiredTypes)
|
|
|
75
93
|
}
|
|
76
94
|
const generateMetaTypes = (metaTypes, typesMap) => {
|
|
77
95
|
const nameToTypeMap = Array.from(metaTypes.entries()).reduce((result, [_name, { query, body, params }]) => {
|
|
78
|
-
|
|
96
|
+
let uniqueName;
|
|
97
|
+
try {
|
|
98
|
+
uniqueName = typesMap.getTypeMeta(_name).uniqueName;
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
// Zod-derived schema - use the name directly
|
|
102
|
+
uniqueName = _name;
|
|
103
|
+
}
|
|
79
104
|
const queryType = query && query.length > 0
|
|
80
105
|
? `Pick<${uniqueName}, '${query?.join("' | '")}'>`
|
|
81
106
|
: undefined;
|
|
@@ -5,6 +5,7 @@ import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-
|
|
|
5
5
|
import { readFile } from 'fs/promises';
|
|
6
6
|
import { join } from 'path';
|
|
7
7
|
import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
|
|
8
|
+
import { stripVerboseFields, hasVerboseFields, } from '../../../utils/strip-verbose-meta.js';
|
|
8
9
|
// Helper function to generate arguments from schema
|
|
9
10
|
const generateArgumentsFromSchema = async (inputSchema, schemaDirectory, typesMap, logger) => {
|
|
10
11
|
if (!inputSchema)
|
|
@@ -15,8 +16,8 @@ const generateArgumentsFromSchema = async (inputSchema, schemaDirectory, typesMa
|
|
|
15
16
|
const uniqueName = typesMap.getUniqueName(inputSchema);
|
|
16
17
|
if (!uniqueName)
|
|
17
18
|
return [];
|
|
19
|
+
const schemaPath = join(schemaDirectory, 'schemas', `${uniqueName}.schema.json`);
|
|
18
20
|
try {
|
|
19
|
-
const schemaPath = join(schemaDirectory, 'schemas', `${uniqueName}.schema.json`);
|
|
20
21
|
const schemaContent = await readFile(schemaPath, 'utf-8');
|
|
21
22
|
const schema = JSON.parse(schemaContent);
|
|
22
23
|
const argumentsArray = [];
|
|
@@ -34,7 +35,8 @@ const generateArgumentsFromSchema = async (inputSchema, schemaDirectory, typesMa
|
|
|
34
35
|
return argumentsArray;
|
|
35
36
|
}
|
|
36
37
|
catch (e) {
|
|
37
|
-
logger.warn(`Could not load schema for type: ${uniqueName}`);
|
|
38
|
+
logger.warn(`Command MCP: Could not load schema for type: ${uniqueName} from ${schemaPath}`);
|
|
39
|
+
console.error(e);
|
|
38
40
|
return [];
|
|
39
41
|
}
|
|
40
42
|
};
|
|
@@ -57,7 +59,14 @@ export const pikkuMCP = pikkuSessionlessFunc({
|
|
|
57
59
|
toolsMeta: mcpEndpoints.toolsMeta,
|
|
58
60
|
promptsMeta: promptsMetaWithArguments,
|
|
59
61
|
};
|
|
60
|
-
|
|
62
|
+
// Write minimal JSON (runtime-only fields)
|
|
63
|
+
const minimalMeta = stripVerboseFields(metaData);
|
|
64
|
+
await writeFileInDir(logger, config.mcpWiringsMetaJsonFile, JSON.stringify(minimalMeta, null, 2));
|
|
65
|
+
// Write verbose JSON only if it has additional fields
|
|
66
|
+
if (hasVerboseFields(metaData)) {
|
|
67
|
+
const verbosePath = config.mcpWiringsMetaJsonFile.replace(/\.gen\.json$/, '-verbose.gen.json');
|
|
68
|
+
await writeFileInDir(logger, verbosePath, JSON.stringify(metaData, null, 2));
|
|
69
|
+
}
|
|
61
70
|
const jsonImportPath = getFileImportRelativePath(mcpWiringsMetaFile, config.mcpWiringsMetaJsonFile, packageMappings);
|
|
62
71
|
const supportsImportAttributes = schema?.supportsImportAttributes ?? false;
|
|
63
72
|
const importStatement = supportsImportAttributes
|
|
@@ -66,9 +75,9 @@ export const pikkuMCP = pikkuSessionlessFunc({
|
|
|
66
75
|
await writeFileInDir(logger, mcpWiringsMetaFile, `import { pikkuState } from '@pikku/core'
|
|
67
76
|
import type { MCPResourceMeta, MCPToolMeta, MCPPromptMeta } from '@pikku/core/mcp'
|
|
68
77
|
${importStatement}
|
|
69
|
-
pikkuState('mcp', 'resourcesMeta', metaData.resourcesMeta as MCPResourceMeta)
|
|
70
|
-
pikkuState('mcp', 'toolsMeta', metaData.toolsMeta as MCPToolMeta)
|
|
71
|
-
pikkuState('mcp', 'promptsMeta', metaData.promptsMeta as MCPPromptMeta)`);
|
|
78
|
+
pikkuState(null, 'mcp', 'resourcesMeta', metaData.resourcesMeta as MCPResourceMeta)
|
|
79
|
+
pikkuState(null, 'mcp', 'toolsMeta', metaData.toolsMeta as MCPToolMeta)
|
|
80
|
+
pikkuState(null, 'mcp', 'promptsMeta', metaData.promptsMeta as MCPPromptMeta)`);
|
|
72
81
|
return true;
|
|
73
82
|
},
|
|
74
83
|
middleware: [
|
|
@@ -14,13 +14,14 @@ export const serializeMCPJson = async (logger, schemaDirectory, functionsMeta, t
|
|
|
14
14
|
if (!uniqueName) {
|
|
15
15
|
return undefined;
|
|
16
16
|
}
|
|
17
|
+
const schemaPath = join(schemaDirectory, 'schemas', `${uniqueName}.schema.json`);
|
|
17
18
|
try {
|
|
18
|
-
const schemaPath = join(schemaDirectory, 'schemas', `${uniqueName}.schema.json`);
|
|
19
19
|
const schemaContent = await readFile(schemaPath, 'utf-8');
|
|
20
20
|
return JSON.parse(schemaContent);
|
|
21
21
|
}
|
|
22
22
|
catch (e) {
|
|
23
|
-
logger.warn(`Could not load schema for type: ${uniqueName}`);
|
|
23
|
+
logger.warn(`Serialize MCP: Could not load schema for type: ${uniqueName} from ${schemaPath}`);
|
|
24
|
+
console.error(e);
|
|
24
25
|
return undefined;
|
|
25
26
|
}
|
|
26
27
|
};
|
|
@@ -19,7 +19,8 @@ import {
|
|
|
19
19
|
AssertMCPResourceURIParams
|
|
20
20
|
} from '@pikku/core/mcp'
|
|
21
21
|
|
|
22
|
-
import type { PikkuFunctionConfig, PikkuFunctionSessionless } from '${functionTypesImportPath}'
|
|
22
|
+
import type { PikkuFunctionConfig, PikkuFunctionSessionless, InferZodOutput } from '${functionTypesImportPath}'
|
|
23
|
+
import type { ZodLike } from '@pikku/core'
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Type definition for MCP resources that provide data to AI models.
|
|
@@ -83,60 +84,111 @@ export const wireMCPPrompt = <In>(
|
|
|
83
84
|
wireMCPPromptCore(mcpPrompt as any)
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Configuration for MCP prompt with Zod schema input validation.
|
|
89
|
+
*/
|
|
90
|
+
type MCPPromptFuncConfigWithSchema<InputSchema extends ZodLike> = {
|
|
91
|
+
func: PikkuFunctionSessionless<InferZodOutput<InputSchema>, MCPPromptResponse, 'mcp' | 'rpc'>
|
|
92
|
+
name?: string
|
|
93
|
+
input: InputSchema
|
|
94
|
+
}
|
|
95
|
+
|
|
86
96
|
/**
|
|
87
97
|
* Creates a function for handling MCP prompt requests.
|
|
88
98
|
* These functions generate prompt templates for AI models.
|
|
89
99
|
*
|
|
90
|
-
*
|
|
100
|
+
* Supports two patterns:
|
|
101
|
+
* 1. Generic types: \`pikkuMCPPromptFunc<Input>({ func: ... })\`
|
|
102
|
+
* 2. Zod schemas: \`pikkuMCPPromptFunc({ input: z.object(...), func: ... })\`
|
|
103
|
+
*
|
|
104
|
+
* @template In - Input type for the prompt parameters (inferred from schema if provided)
|
|
91
105
|
* @param func - Function definition, either direct function or configuration object
|
|
92
106
|
* @returns The unwrapped function for internal use
|
|
93
107
|
*/
|
|
94
|
-
export
|
|
108
|
+
export function pikkuMCPPromptFunc<InputSchema extends ZodLike>(
|
|
109
|
+
config: MCPPromptFuncConfigWithSchema<InputSchema>
|
|
110
|
+
): PikkuFunctionConfig<InferZodOutput<InputSchema>, MCPPromptResponse, 'mcp' | 'rpc'>
|
|
111
|
+
export function pikkuMCPPromptFunc<In>(
|
|
95
112
|
func:
|
|
96
|
-
| PikkuFunctionSessionless<In, MCPPromptResponse, 'mcp'>
|
|
113
|
+
| PikkuFunctionSessionless<In, MCPPromptResponse, 'mcp' | 'rpc'>
|
|
97
114
|
| {
|
|
98
|
-
func: PikkuFunctionSessionless<In, MCPPromptResponse, 'mcp'>
|
|
115
|
+
func: PikkuFunctionSessionless<In, MCPPromptResponse, 'mcp' | 'rpc'>
|
|
99
116
|
name?: string
|
|
100
117
|
}
|
|
101
|
-
): PikkuFunctionConfig<In, MCPPromptResponse, 'mcp'
|
|
118
|
+
): PikkuFunctionConfig<In, MCPPromptResponse, 'mcp' | 'rpc'>
|
|
119
|
+
export function pikkuMCPPromptFunc(func: any): any {
|
|
102
120
|
return typeof func === 'function' ? { func } : func
|
|
103
121
|
}
|
|
104
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Configuration for MCP tool with Zod schema input validation.
|
|
125
|
+
*/
|
|
126
|
+
type MCPToolFuncConfigWithSchema<InputSchema extends ZodLike> = {
|
|
127
|
+
func: PikkuFunctionSessionless<InferZodOutput<InputSchema>, MCPToolResponse, 'mcp' | 'rpc'>
|
|
128
|
+
name?: string
|
|
129
|
+
input: InputSchema
|
|
130
|
+
}
|
|
131
|
+
|
|
105
132
|
/**
|
|
106
133
|
* Creates a function for handling MCP tool invocations.
|
|
107
134
|
* These functions perform actions that AI models can request.
|
|
108
135
|
*
|
|
109
|
-
*
|
|
136
|
+
* Supports two patterns:
|
|
137
|
+
* 1. Generic types: \`pikkuMCPToolFunc<Input>({ func: ... })\`
|
|
138
|
+
* 2. Zod schemas: \`pikkuMCPToolFunc({ input: z.object(...), func: ... })\`
|
|
139
|
+
*
|
|
140
|
+
* @template In - Input type for the tool invocation (inferred from schema if provided)
|
|
110
141
|
* @param func - Function definition, either direct function or configuration object
|
|
111
142
|
* @returns The unwrapped function for internal use
|
|
112
143
|
*/
|
|
113
|
-
export
|
|
144
|
+
export function pikkuMCPToolFunc<InputSchema extends ZodLike>(
|
|
145
|
+
config: MCPToolFuncConfigWithSchema<InputSchema>
|
|
146
|
+
): PikkuFunctionConfig<InferZodOutput<InputSchema>, MCPToolResponse, 'mcp' | 'rpc'>
|
|
147
|
+
export function pikkuMCPToolFunc<In>(
|
|
114
148
|
func:
|
|
115
|
-
| PikkuFunctionSessionless<In, MCPToolResponse, 'mcp'>
|
|
149
|
+
| PikkuFunctionSessionless<In, MCPToolResponse, 'mcp' | 'rpc'>
|
|
116
150
|
| {
|
|
117
|
-
func: PikkuFunctionSessionless<In, MCPToolResponse, 'mcp'>
|
|
151
|
+
func: PikkuFunctionSessionless<In, MCPToolResponse, 'mcp' | 'rpc'>
|
|
118
152
|
name?: string
|
|
119
153
|
}
|
|
120
|
-
): PikkuFunctionConfig<In, MCPToolResponse, 'mcp'
|
|
154
|
+
): PikkuFunctionConfig<In, MCPToolResponse, 'mcp' | 'rpc'>
|
|
155
|
+
export function pikkuMCPToolFunc(func: any): any {
|
|
121
156
|
return typeof func === 'function' ? { func } : func
|
|
122
157
|
}
|
|
123
158
|
|
|
159
|
+
/**
|
|
160
|
+
* Configuration for MCP resource with Zod schema input validation.
|
|
161
|
+
*/
|
|
162
|
+
type MCPResourceFuncConfigWithSchema<InputSchema extends ZodLike> = {
|
|
163
|
+
func: PikkuFunctionSessionless<InferZodOutput<InputSchema>, MCPResourceResponse, 'mcp' | 'rpc'>
|
|
164
|
+
name?: string
|
|
165
|
+
input: InputSchema
|
|
166
|
+
}
|
|
167
|
+
|
|
124
168
|
/**
|
|
125
169
|
* Creates a function for handling MCP resource requests.
|
|
126
170
|
* These functions provide data that AI models can access.
|
|
127
171
|
*
|
|
128
|
-
*
|
|
172
|
+
* Supports two patterns:
|
|
173
|
+
* 1. Generic types: \`pikkuMCPResourceFunc<Input>({ func: ... })\`
|
|
174
|
+
* 2. Zod schemas: \`pikkuMCPResourceFunc({ input: z.object(...), func: ... })\`
|
|
175
|
+
*
|
|
176
|
+
* @template In - Input type for the resource request (inferred from schema if provided)
|
|
129
177
|
* @param func - Function definition, either direct function or configuration object
|
|
130
178
|
* @returns The unwrapped function for internal use
|
|
131
179
|
*/
|
|
132
|
-
export
|
|
180
|
+
export function pikkuMCPResourceFunc<InputSchema extends ZodLike>(
|
|
181
|
+
config: MCPResourceFuncConfigWithSchema<InputSchema>
|
|
182
|
+
): PikkuFunctionConfig<InferZodOutput<InputSchema>, MCPResourceResponse, 'mcp' | 'rpc'>
|
|
183
|
+
export function pikkuMCPResourceFunc<In>(
|
|
133
184
|
func:
|
|
134
|
-
| PikkuFunctionSessionless<In, MCPResourceResponse, 'mcp'>
|
|
185
|
+
| PikkuFunctionSessionless<In, MCPResourceResponse, 'mcp' | 'rpc'>
|
|
135
186
|
| {
|
|
136
|
-
func: PikkuFunctionSessionless<In, MCPResourceResponse, 'mcp'>
|
|
187
|
+
func: PikkuFunctionSessionless<In, MCPResourceResponse, 'mcp' | 'rpc'>
|
|
137
188
|
name?: string
|
|
138
189
|
}
|
|
139
|
-
): PikkuFunctionConfig<In, MCPResourceResponse, 'mcp'
|
|
190
|
+
): PikkuFunctionConfig<In, MCPResourceResponse, 'mcp' | 'rpc'>
|
|
191
|
+
export function pikkuMCPResourceFunc(func: any): any {
|
|
140
192
|
return typeof func === 'function' ? { func } : func
|
|
141
193
|
}
|
|
142
194
|
`;
|
|
@@ -24,17 +24,20 @@ export const pikkuMiddleware = pikkuSessionlessFunc({
|
|
|
24
24
|
const importStatement = supportsImportAttributes
|
|
25
25
|
? `import metaData from '${jsonImportPath}' with { type: 'json' }`
|
|
26
26
|
: `import metaData from '${jsonImportPath}'`;
|
|
27
|
+
const packageNameValue = config.externalPackageName
|
|
28
|
+
? `'${config.externalPackageName}'`
|
|
29
|
+
: 'null';
|
|
27
30
|
const tsContent = `import { pikkuState } from '@pikku/core'
|
|
28
31
|
${importStatement}
|
|
29
32
|
|
|
30
33
|
// HTTP middleware groups metadata
|
|
31
34
|
if (metaData.httpGroups && Object.keys(metaData.httpGroups).length > 0) {
|
|
32
|
-
pikkuState('middleware', 'httpGroupMeta', metaData.httpGroups)
|
|
35
|
+
pikkuState(${packageNameValue}, 'middleware', 'httpGroupMeta', metaData.httpGroups)
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
// Tag middleware groups metadata
|
|
36
39
|
if (metaData.tagGroups && Object.keys(metaData.tagGroups).length > 0) {
|
|
37
|
-
pikkuState('middleware', 'tagGroupMeta', metaData.tagGroups)
|
|
40
|
+
pikkuState(${packageNameValue}, 'middleware', 'tagGroupMeta', metaData.tagGroups)
|
|
38
41
|
}
|
|
39
42
|
`;
|
|
40
43
|
await writeFileInDir(logger, config.middlewareGroupsMetaFile, tsContent);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const pikkuPackage: any;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js';
|
|
2
|
+
import { writeFileInDir } from '../../../utils/file-writer.js';
|
|
3
|
+
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js';
|
|
4
|
+
import { serializePackageFactories } from './serialize-package.js';
|
|
5
|
+
export const pikkuPackage = pikkuSessionlessFunc({
|
|
6
|
+
func: async ({ logger, config, getInspectorState }) => {
|
|
7
|
+
const { externalPackageName, packageMappings, packageFile } = config;
|
|
8
|
+
// Only generate for external packages
|
|
9
|
+
if (!externalPackageName) {
|
|
10
|
+
logger.info({
|
|
11
|
+
message: 'Skipping package factories - not an external package (externalPackageName not set)',
|
|
12
|
+
type: 'skip',
|
|
13
|
+
});
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (!packageFile) {
|
|
17
|
+
logger.info({
|
|
18
|
+
message: 'Skipping package factories - packageFile not configured',
|
|
19
|
+
type: 'skip',
|
|
20
|
+
});
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
const state = await getInspectorState();
|
|
24
|
+
const { filesAndMethods } = state;
|
|
25
|
+
const { pikkuConfigFactory, singletonServicesFactory, wireServicesFactory, } = filesAndMethods;
|
|
26
|
+
const content = serializePackageFactories(packageFile, externalPackageName, pikkuConfigFactory
|
|
27
|
+
? {
|
|
28
|
+
file: pikkuConfigFactory.file,
|
|
29
|
+
variable: pikkuConfigFactory.variable,
|
|
30
|
+
}
|
|
31
|
+
: undefined, singletonServicesFactory
|
|
32
|
+
? {
|
|
33
|
+
file: singletonServicesFactory.file,
|
|
34
|
+
variable: singletonServicesFactory.variable,
|
|
35
|
+
}
|
|
36
|
+
: undefined, wireServicesFactory
|
|
37
|
+
? {
|
|
38
|
+
file: wireServicesFactory.file,
|
|
39
|
+
variable: wireServicesFactory.variable,
|
|
40
|
+
}
|
|
41
|
+
: undefined, packageMappings);
|
|
42
|
+
if (!content) {
|
|
43
|
+
logger.info({
|
|
44
|
+
message: 'Skipping package factories - no service factories found',
|
|
45
|
+
type: 'skip',
|
|
46
|
+
});
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
await writeFileInDir(logger, packageFile, content);
|
|
50
|
+
return true;
|
|
51
|
+
},
|
|
52
|
+
middleware: [
|
|
53
|
+
logCommandInfoAndTime({
|
|
54
|
+
commandStart: 'Generating package service factories',
|
|
55
|
+
commandEnd: 'Generated package service factories',
|
|
56
|
+
}),
|
|
57
|
+
],
|
|
58
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export interface PackageFactoryInfo {
|
|
2
|
+
file: string;
|
|
3
|
+
variable: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const serializePackageFactories: (outputPath: string, packageName: string, configFactory: PackageFactoryInfo | undefined, singletonServicesFactory: PackageFactoryInfo | undefined, wireServicesFactory: PackageFactoryInfo | undefined, packageMappings?: Record<string, string>) => string | null;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
|
|
2
|
+
export const serializePackageFactories = (outputPath, packageName, configFactory, singletonServicesFactory, wireServicesFactory, packageMappings = {}) => {
|
|
3
|
+
const imports = [
|
|
4
|
+
`import { addPackageServiceFactories } from '@pikku/core'`,
|
|
5
|
+
];
|
|
6
|
+
const factoryEntries = [];
|
|
7
|
+
if (configFactory) {
|
|
8
|
+
const filePath = getFileImportRelativePath(outputPath, configFactory.file, packageMappings);
|
|
9
|
+
imports.push(`import { ${configFactory.variable} as createConfig } from '${filePath}'`);
|
|
10
|
+
factoryEntries.push(` createConfig,`);
|
|
11
|
+
}
|
|
12
|
+
if (singletonServicesFactory) {
|
|
13
|
+
const filePath = getFileImportRelativePath(outputPath, singletonServicesFactory.file, packageMappings);
|
|
14
|
+
imports.push(`import { ${singletonServicesFactory.variable} as createSingletonServices } from '${filePath}'`);
|
|
15
|
+
factoryEntries.push(` createSingletonServices,`);
|
|
16
|
+
}
|
|
17
|
+
if (wireServicesFactory) {
|
|
18
|
+
const filePath = getFileImportRelativePath(outputPath, wireServicesFactory.file, packageMappings);
|
|
19
|
+
imports.push(`import { ${wireServicesFactory.variable} as createWireServices } from '${filePath}'`);
|
|
20
|
+
factoryEntries.push(` createWireServices,`);
|
|
21
|
+
}
|
|
22
|
+
// Only generate if at least one factory is defined
|
|
23
|
+
if (factoryEntries.length === 0) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
return `${imports.join('\n')}
|
|
27
|
+
|
|
28
|
+
addPackageServiceFactories('${packageName}', {
|
|
29
|
+
${factoryEntries.join('\n')}
|
|
30
|
+
})
|
|
31
|
+
`;
|
|
32
|
+
};
|
|
@@ -4,13 +4,21 @@ import { writeFileInDir } from '../../../utils/file-writer.js';
|
|
|
4
4
|
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js';
|
|
5
5
|
import { serializeQueueMeta, serializeQueueMetaTS, } from './serialize-queue-meta.js';
|
|
6
6
|
import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
|
|
7
|
+
import { stripVerboseFields, hasVerboseFields, } from '../../../utils/strip-verbose-meta.js';
|
|
7
8
|
export const pikkuQueue = pikkuSessionlessFunc({
|
|
8
9
|
func: async ({ logger, config, getInspectorState }) => {
|
|
9
10
|
const visitState = await getInspectorState();
|
|
10
11
|
const { queueWorkersWiringFile, queueWorkersWiringMetaFile, queueWorkersWiringMetaJsonFile, packageMappings, schema, } = config;
|
|
11
12
|
const { queueWorkers } = visitState;
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
const fullMeta = serializeQueueMeta(queueWorkers.meta);
|
|
14
|
+
// Write minimal JSON file (runtime-only fields)
|
|
15
|
+
const minimalMeta = stripVerboseFields(fullMeta);
|
|
16
|
+
await writeFileInDir(logger, queueWorkersWiringMetaJsonFile, JSON.stringify(minimalMeta, null, 2));
|
|
17
|
+
// Write verbose JSON only if it has additional fields
|
|
18
|
+
if (hasVerboseFields(fullMeta)) {
|
|
19
|
+
const verbosePath = queueWorkersWiringMetaJsonFile.replace(/\.gen\.json$/, '-verbose.gen.json');
|
|
20
|
+
await writeFileInDir(logger, verbosePath, JSON.stringify(fullMeta, null, 2));
|
|
21
|
+
}
|
|
14
22
|
// Calculate relative path from TS file to JSON file
|
|
15
23
|
const jsonImportPath = getFileImportRelativePath(queueWorkersWiringMetaFile, queueWorkersWiringMetaJsonFile, packageMappings);
|
|
16
24
|
// Write TypeScript file that imports JSON
|
|
@@ -9,16 +9,8 @@ export const pikkuQueue = pikkuSessionlessFunc({
|
|
|
9
9
|
const visitState = await getInspectorState();
|
|
10
10
|
const { queueWorkersWiringFile, queueWorkersWiringMetaFile, queueWorkersWiringMetaJsonFile, packageMappings, schema, } = config;
|
|
11
11
|
const { queueWorkers } = visitState;
|
|
12
|
-
// Add remote RPC worker to queue metadata if it exists
|
|
13
|
-
const queueMeta = { ...queueWorkers.meta };
|
|
14
|
-
if (config.rpc?.remoteRpcWorkersPath) {
|
|
15
|
-
queueMeta['pikku-remote-internal-rpc'] = {
|
|
16
|
-
pikkuFuncName: 'pikkuRemoteInternalRPC',
|
|
17
|
-
queueName: 'pikku-remote-internal-rpc',
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
12
|
// Write JSON file
|
|
21
|
-
await writeFileInDir(logger, queueWorkersWiringMetaJsonFile, JSON.stringify(serializeQueueMeta(
|
|
13
|
+
await writeFileInDir(logger, queueWorkersWiringMetaJsonFile, JSON.stringify(serializeQueueMeta(queueWorkers.meta), null, 2));
|
|
22
14
|
// Calculate relative path from TS file to JSON file
|
|
23
15
|
const jsonImportPath = getFileImportRelativePath(queueWorkersWiringMetaFile, queueWorkersWiringMetaJsonFile, packageMappings);
|
|
24
16
|
// Write TypeScript file that imports JSON
|
|
@@ -8,7 +8,7 @@ export const serializeQueueMap = (relativeToPath, packageMappings, typesMap, fun
|
|
|
8
8
|
return `/**
|
|
9
9
|
* This provides the structure needed for typescript to be aware of Queue workers and their input/output types
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
${serializedImportMap}
|
|
13
13
|
${serializedCustomTypes}
|
|
14
14
|
|
|
@@ -57,8 +57,25 @@ function generateQueues(queueWorkersMeta, functionsMeta, typesMap, requiredTypes
|
|
|
57
57
|
const input = functionMeta.inputs ? functionMeta.inputs[0] : undefined;
|
|
58
58
|
const output = functionMeta.outputs ? functionMeta.outputs[0] : undefined;
|
|
59
59
|
// Store the input and output types for QueueHandler
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
// For zod-derived schemas, the type might not be in typesMap, so use the schema name directly
|
|
61
|
+
let inputType = 'null';
|
|
62
|
+
if (input) {
|
|
63
|
+
try {
|
|
64
|
+
inputType = typesMap.getTypeMeta(input).uniqueName;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
inputType = input;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
let outputType = 'null';
|
|
71
|
+
if (output) {
|
|
72
|
+
try {
|
|
73
|
+
outputType = typesMap.getTypeMeta(output).uniqueName;
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
outputType = output;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
62
79
|
requiredTypes.add(inputType);
|
|
63
80
|
requiredTypes.add(outputType);
|
|
64
81
|
// Add Queue entry
|
|
@@ -10,6 +10,6 @@ export const serializeQueueMetaTS = (jsonImportPath, supportsImportAttributes) =
|
|
|
10
10
|
serializedOutput.push("import { QueueWorkersMeta } from '@pikku/core/queue'");
|
|
11
11
|
serializedOutput.push(importStatement);
|
|
12
12
|
serializedOutput.push('');
|
|
13
|
-
serializedOutput.push("pikkuState('queue', 'meta', metaData as QueueWorkersMeta)");
|
|
13
|
+
serializedOutput.push("pikkuState(null, 'queue', 'meta', metaData as QueueWorkersMeta)");
|
|
14
14
|
return serializedOutput.join('\n');
|
|
15
15
|
};
|
|
@@ -5,8 +5,8 @@ import { serializeTypedRPCMap } from './serialize-typed-rpc-map.js';
|
|
|
5
5
|
export const pikkuRPCInternalMap = pikkuSessionlessFunc({
|
|
6
6
|
func: async ({ logger, config, getInspectorState }) => {
|
|
7
7
|
const { functions, rpc } = await getInspectorState();
|
|
8
|
-
const { rpcInternalMapDeclarationFile, packageMappings } = config;
|
|
9
|
-
const content = serializeTypedRPCMap(rpcInternalMapDeclarationFile, packageMappings, functions.typesMap, functions.meta, rpc.internalMeta);
|
|
8
|
+
const { rpcInternalMapDeclarationFile, packageMappings, externalPackages } = config;
|
|
9
|
+
const content = serializeTypedRPCMap(rpcInternalMapDeclarationFile, packageMappings, functions.typesMap, functions.meta, rpc.internalMeta, externalPackages);
|
|
10
10
|
await writeFileInDir(logger, rpcInternalMapDeclarationFile, content);
|
|
11
11
|
},
|
|
12
12
|
middleware: [
|
|
@@ -19,8 +19,8 @@ export const pikkuRPCInternalMap = pikkuSessionlessFunc({
|
|
|
19
19
|
export const pikkuRPCExposedMap = pikkuSessionlessFunc({
|
|
20
20
|
func: async ({ logger, config, getInspectorState }) => {
|
|
21
21
|
const { functions, rpc } = await getInspectorState();
|
|
22
|
-
const { rpcMapDeclarationFile, packageMappings } = config;
|
|
23
|
-
const content = serializeTypedRPCMap(rpcMapDeclarationFile, packageMappings, functions.typesMap, functions.meta, rpc.exposedMeta);
|
|
22
|
+
const { rpcMapDeclarationFile, packageMappings, externalPackages } = config;
|
|
23
|
+
const content = serializeTypedRPCMap(rpcMapDeclarationFile, packageMappings, functions.typesMap, functions.meta, rpc.exposedMeta, externalPackages);
|
|
24
24
|
await writeFileInDir(logger, rpcMapDeclarationFile, content);
|
|
25
25
|
},
|
|
26
26
|
middleware: [
|
|
@@ -13,7 +13,7 @@ export const pikkuRPC = pikkuSessionlessFunc({
|
|
|
13
13
|
const importStatement = supportsImportAttributes
|
|
14
14
|
? `import metaData from '${jsonImportPath}' with { type: 'json' }`
|
|
15
15
|
: `import metaData from '${jsonImportPath}'`;
|
|
16
|
-
await writeFileInDir(logger, rpcInternalWiringMetaFile, `import { pikkuState } from '@pikku/core'\n${importStatement}\npikkuState('rpc', 'meta', metaData as Record<string, string>)`);
|
|
16
|
+
await writeFileInDir(logger, rpcInternalWiringMetaFile, `import { pikkuState } from '@pikku/core'\n${importStatement}\npikkuState(null, 'rpc', 'meta', metaData as Record<string, string>)`);
|
|
17
17
|
return true;
|
|
18
18
|
}
|
|
19
19
|
return false;
|
|
@@ -11,6 +11,9 @@ import { pikkuSessionlessFunc, wireQueueWorker } from '${pathToPikkuTypes}'
|
|
|
11
11
|
/**
|
|
12
12
|
* Generic remote RPC worker that invokes any internal RPC by name
|
|
13
13
|
* This is used for executing internal RPCs via a queue or HTTP (e.g., scheduled tasks, background jobs, internal services)
|
|
14
|
+
*
|
|
15
|
+
* TODO: Security risk - this allows any RPC to be invoked by name. Should validate
|
|
16
|
+
* that rpcName is in an allowlist of permitted internal RPCs to prevent unauthorized access.
|
|
14
17
|
*/
|
|
15
18
|
export const pikkuRemoteInternalRPC = pikkuSessionlessFunc<
|
|
16
19
|
{ rpcName: string, data?: any },
|
|
@@ -59,7 +59,7 @@ export class PikkuRPC {
|
|
|
59
59
|
* @returns A promise that resolves with the function's return value
|
|
60
60
|
*/
|
|
61
61
|
invoke: RPCInvoke = async (rpcName, data) => {
|
|
62
|
-
return await this.pikkuFetch.post(\`/rpc/\${rpcName}\` as any, { rpcName, data }) as any
|
|
62
|
+
return await this.pikkuFetch.post(\`/rpc/\${rpcName}\` as any, { rpcName: String(rpcName), data }) as any
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TypesMap } from '@pikku/inspector';
|
|
2
2
|
import { FunctionsMeta } from '@pikku/core';
|
|
3
|
-
export declare const serializeTypedRPCMap: (relativeToPath: string, packageMappings: Record<string, string>, typesMap: TypesMap, functionsMeta: FunctionsMeta, rpcMeta: Record<string, string>) => string;
|
|
3
|
+
export declare const serializeTypedRPCMap: (relativeToPath: string, packageMappings: Record<string, string>, typesMap: TypesMap, functionsMeta: FunctionsMeta, rpcMeta: Record<string, string>, externalPackages?: Record<string, string>) => string;
|