@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
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Generate all workflow type helpers for authoring workflows
|
|
3
|
+
* Combines DSL helpers (pikkuWorkflowFunc, pikkuWorkflowComplexFunc) and
|
|
4
|
+
* graph helpers (pikkuWorkflowGraph) with unified wireWorkflow
|
|
3
5
|
*/
|
|
4
6
|
export const serializeWorkflowTypes = (functionTypesImportPath, rpcMapImportPath) => {
|
|
5
7
|
return `/**
|
|
6
|
-
* Workflow
|
|
8
|
+
* Workflow type definitions and helpers
|
|
9
|
+
* Used for authoring both DSL and graph-based workflows
|
|
7
10
|
*/
|
|
8
11
|
|
|
9
|
-
import { PikkuWorkflowWire, WorkflowStepOptions } from '@pikku/core/workflow'
|
|
12
|
+
import { PikkuWorkflowWire, WorkflowStepOptions, WorkflowCancelledException } from '@pikku/core/workflow'
|
|
13
|
+
|
|
14
|
+
// Re-export WorkflowCancelledException for use in workflow functions
|
|
15
|
+
export { WorkflowCancelledException }
|
|
10
16
|
import type { PikkuFunctionSessionless, PikkuFunctionConfig } from '${functionTypesImportPath}'
|
|
11
|
-
import type { RPCMap } from '${rpcMapImportPath}'
|
|
17
|
+
import type { RPCMap, FlattenedRPCMap } from '${rpcMapImportPath}'
|
|
18
|
+
import type { GraphNodeConfig, HTTPMethod } from '@pikku/core'
|
|
19
|
+
import { createGraph, wireWorkflow as coreWireWorkflow } from '@pikku/core'
|
|
20
|
+
|
|
21
|
+
// ============================================================================
|
|
22
|
+
// DSL Workflow Types (pikkuWorkflowFunc, pikkuWorkflowComplexFunc)
|
|
23
|
+
// ============================================================================
|
|
12
24
|
|
|
13
25
|
/**
|
|
14
26
|
* Typed workflow wire with RPC awareness
|
|
15
27
|
* Provides type-safe workflow.do() for RPC steps
|
|
16
28
|
*/
|
|
17
29
|
export interface TypedWorkflow extends PikkuWorkflowWire {
|
|
18
|
-
/**
|
|
19
|
-
* Execute a workflow step with RPC invocation (typed based on available RPCs)
|
|
20
|
-
* @template K - RPC name from the RPC map
|
|
21
|
-
*/
|
|
22
30
|
do<K extends keyof RPCMap>(
|
|
23
31
|
stepName: string,
|
|
24
32
|
rpcName: K,
|
|
@@ -26,10 +34,6 @@ export interface TypedWorkflow extends PikkuWorkflowWire {
|
|
|
26
34
|
options?: WorkflowStepOptions
|
|
27
35
|
): Promise<RPCMap[K]['output']>
|
|
28
36
|
|
|
29
|
-
/**
|
|
30
|
-
* Execute a workflow step with inline function
|
|
31
|
-
* @template T - Return type of the inline function
|
|
32
|
-
*/
|
|
33
37
|
do<T>(
|
|
34
38
|
stepName: string,
|
|
35
39
|
fn: () => T | Promise<T>,
|
|
@@ -39,28 +43,14 @@ export interface TypedWorkflow extends PikkuWorkflowWire {
|
|
|
39
43
|
|
|
40
44
|
/**
|
|
41
45
|
* Workflow function type with typed workflow service
|
|
42
|
-
* Includes the workflow wire object with typed RPC methods
|
|
43
46
|
*/
|
|
44
47
|
export type PikkuFunctionWorkflow<
|
|
45
48
|
In = unknown,
|
|
46
49
|
Out = never
|
|
47
|
-
> = PikkuFunctionSessionless<
|
|
48
|
-
In,
|
|
49
|
-
Out,
|
|
50
|
-
'workflow'
|
|
51
|
-
>
|
|
50
|
+
> = PikkuFunctionSessionless<In, Out, 'workflow'>
|
|
52
51
|
|
|
53
52
|
/**
|
|
54
|
-
* Creates a workflow function
|
|
55
|
-
* Workflow functions have access to the workflow wire object for step execution.
|
|
56
|
-
*
|
|
57
|
-
* This is the permissive mode - workflows that don't conform to simple DSL will fall back
|
|
58
|
-
* to basic extraction with a warning.
|
|
59
|
-
*
|
|
60
|
-
* @template In - Input type for the workflow
|
|
61
|
-
* @template Out - Output type for the workflow
|
|
62
|
-
* @param func - Function definition, either direct function or configuration object
|
|
63
|
-
* @returns The normalized configuration object
|
|
53
|
+
* Creates a DSL-compatible workflow function (serializable, shows in Forge UI)
|
|
64
54
|
*/
|
|
65
55
|
export const pikkuWorkflowFunc = <In, Out = unknown>(
|
|
66
56
|
func:
|
|
@@ -71,24 +61,9 @@ export const pikkuWorkflowFunc = <In, Out = unknown>(
|
|
|
71
61
|
}
|
|
72
62
|
|
|
73
63
|
/**
|
|
74
|
-
* Creates a
|
|
75
|
-
* Simple workflows must conform to the restricted DSL for static analysis.
|
|
76
|
-
*
|
|
77
|
-
* This is the strict mode - workflows that don't conform to simple DSL will cause
|
|
78
|
-
* a critical error during inspection.
|
|
79
|
-
*
|
|
80
|
-
* Constraints:
|
|
81
|
-
* - Must use only workflow.do() with RPC form (no inline functions)
|
|
82
|
-
* - Only if/else, for..of, and Promise.all(array.map()) control flow allowed
|
|
83
|
-
* - Step names must be unique (except across mutually exclusive branches)
|
|
84
|
-
* - All workflow calls must be awaited
|
|
85
|
-
*
|
|
86
|
-
* @template In - Input type for the workflow
|
|
87
|
-
* @template Out - Output type for the workflow
|
|
88
|
-
* @param func - Function definition, either direct function or configuration object
|
|
89
|
-
* @returns The normalized configuration object
|
|
64
|
+
* Creates a complex workflow function (arbitrary code, hidden from Forge UI)
|
|
90
65
|
*/
|
|
91
|
-
export const
|
|
66
|
+
export const pikkuWorkflowComplexFunc = <In, Out = unknown>(
|
|
92
67
|
func:
|
|
93
68
|
| PikkuFunctionWorkflow<In, Out>
|
|
94
69
|
| PikkuFunctionConfig<In, Out, 'workflow', PikkuFunctionWorkflow<In, Out>>
|
|
@@ -96,5 +71,284 @@ export const pikkuSimpleWorkflowFunc = <In, Out = unknown>(
|
|
|
96
71
|
return typeof func === 'function' ? { func } : func
|
|
97
72
|
}
|
|
98
73
|
|
|
74
|
+
// ============================================================================
|
|
75
|
+
// Graph Workflow Types (pikkuWorkflowGraph)
|
|
76
|
+
// ============================================================================
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Type-safe graph builder with full RPC autocomplete
|
|
80
|
+
*/
|
|
81
|
+
const graphBuilder = createGraph<FlattenedRPCMap>()
|
|
82
|
+
|
|
83
|
+
/** HTTP wire configuration for graph workflows */
|
|
84
|
+
interface GraphHttpWire<NodeIds extends string> {
|
|
85
|
+
route: string
|
|
86
|
+
method: HTTPMethod
|
|
87
|
+
startNode: NodeIds
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Channel wire configuration for graph workflows */
|
|
91
|
+
interface GraphChannelWire<NodeIds extends string> {
|
|
92
|
+
name: string
|
|
93
|
+
onConnect?: NodeIds
|
|
94
|
+
onDisconnect?: NodeIds
|
|
95
|
+
onMessage?: NodeIds
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Queue wire configuration for graph workflows */
|
|
99
|
+
interface GraphQueueWire<NodeIds extends string> {
|
|
100
|
+
name: string
|
|
101
|
+
startNode: NodeIds
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** CLI wire configuration for graph workflows */
|
|
105
|
+
interface GraphCliWire<NodeIds extends string> {
|
|
106
|
+
command: string
|
|
107
|
+
startNode: NodeIds
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** MCP wire configurations for graph workflows */
|
|
111
|
+
interface GraphMcpWires<NodeIds extends string> {
|
|
112
|
+
tool?: Array<{ name: string; startNode: NodeIds }>
|
|
113
|
+
prompt?: Array<{ name: string; startNode: NodeIds }>
|
|
114
|
+
resource?: Array<{ uri: string; startNode: NodeIds }>
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Schedule wire configuration for graph workflows */
|
|
118
|
+
interface GraphScheduleWire<NodeIds extends string> {
|
|
119
|
+
cron?: string
|
|
120
|
+
interval?: string
|
|
121
|
+
startNode: NodeIds
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Trigger wire configuration for graph workflows */
|
|
125
|
+
interface GraphTriggerWire<NodeIds extends string> {
|
|
126
|
+
name: string // RPC name of the trigger function
|
|
127
|
+
startNode: NodeIds
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** All wire configurations for graph workflows */
|
|
131
|
+
interface GraphWiresConfig<NodeIds extends string> {
|
|
132
|
+
http?: Array<GraphHttpWire<NodeIds>>
|
|
133
|
+
channel?: Array<GraphChannelWire<NodeIds>>
|
|
134
|
+
queue?: Array<GraphQueueWire<NodeIds>>
|
|
135
|
+
cli?: Array<GraphCliWire<NodeIds>>
|
|
136
|
+
mcp?: GraphMcpWires<NodeIds>
|
|
137
|
+
schedule?: Array<GraphScheduleWire<NodeIds>>
|
|
138
|
+
trigger?: Array<GraphTriggerWire<NodeIds>>
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Configuration for graph-based workflow */
|
|
142
|
+
export interface PikkuWorkflowGraphConfig<
|
|
143
|
+
FuncMap extends Record<string, keyof FlattenedRPCMap & string>,
|
|
144
|
+
T
|
|
145
|
+
> {
|
|
146
|
+
/** Workflow name (optional - defaults to exported variable name) */
|
|
147
|
+
name?: string
|
|
148
|
+
/** Optional description */
|
|
149
|
+
description?: string
|
|
150
|
+
/** Optional tags for organization */
|
|
151
|
+
tags?: string[]
|
|
152
|
+
/** Node to RPC function mapping */
|
|
153
|
+
nodes: FuncMap
|
|
154
|
+
/** Wire configurations - how this workflow can be triggered */
|
|
155
|
+
wires?: GraphWiresConfig<Extract<keyof FuncMap, string>>
|
|
156
|
+
/** Node configurations (next, input, onError) */
|
|
157
|
+
config?: T
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** Result of pikkuWorkflowGraph - includes metadata for wiring */
|
|
161
|
+
export interface PikkuWorkflowGraphResult<T, NodeIds extends string = string> {
|
|
162
|
+
__type: 'pikkuWorkflowGraph'
|
|
163
|
+
name?: string
|
|
164
|
+
description?: string
|
|
165
|
+
tags?: string[]
|
|
166
|
+
wires?: GraphWiresConfig<NodeIds>
|
|
167
|
+
graph: T
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Creates a graph-based workflow definition with metadata
|
|
172
|
+
* Name defaults to the exported variable name if not provided.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* // Name inferred from exported variable name
|
|
176
|
+
* export const myWorkflow = pikkuWorkflowGraph({
|
|
177
|
+
* description: 'Handles user onboarding',
|
|
178
|
+
* tags: ['onboarding'],
|
|
179
|
+
* nodes: {
|
|
180
|
+
* entry: 'createUser',
|
|
181
|
+
* sendEmail: 'sendWelcomeEmail',
|
|
182
|
+
* },
|
|
183
|
+
* config: {
|
|
184
|
+
* entry: { next: 'sendEmail' },
|
|
185
|
+
* sendEmail: { input: (ref) => ({ to: ref('entry', 'email') }) },
|
|
186
|
+
* },
|
|
187
|
+
* })
|
|
188
|
+
*/
|
|
189
|
+
export function pikkuWorkflowGraph<
|
|
190
|
+
const FuncMap extends Record<string, keyof FlattenedRPCMap & string>
|
|
191
|
+
>(
|
|
192
|
+
config: PikkuWorkflowGraphConfig<FuncMap, GraphNodeConfigMap<FuncMap>>
|
|
193
|
+
): PikkuWorkflowGraphResult<Record<Extract<keyof FuncMap, string>, GraphNodeConfig<Extract<keyof FuncMap, string>>>, Extract<keyof FuncMap, string>> {
|
|
194
|
+
return {
|
|
195
|
+
__type: 'pikkuWorkflowGraph',
|
|
196
|
+
name: config.name,
|
|
197
|
+
description: config.description,
|
|
198
|
+
tags: config.tags,
|
|
199
|
+
wires: config.wires,
|
|
200
|
+
graph: graphBuilder(config.nodes, config.config as any),
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** Typed ref value */
|
|
205
|
+
type TypedRef<T> = { $ref: string; path?: string } & { __phantomType?: T }
|
|
206
|
+
|
|
207
|
+
/** Template string type - assignable to string fields */
|
|
208
|
+
type TemplateString = {
|
|
209
|
+
$template: {
|
|
210
|
+
parts: string[]
|
|
211
|
+
expressions: Array<{ $ref: string; path?: string }>
|
|
212
|
+
}
|
|
213
|
+
} & { __brand: 'TemplateString' }
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Creates a template string with variable interpolation
|
|
217
|
+
* Uses indexed placeholders $0, $1, etc. with refs array
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* template('Hello $0, your order $1 is ready', [ref('trigger', 'name'), ref('step_0', 'orderId')])
|
|
221
|
+
*/
|
|
222
|
+
export function template(templateStr: string, refs: TypedRef<unknown>[]): TemplateString {
|
|
223
|
+
const parts: string[] = []
|
|
224
|
+
const expressions: Array<{ $ref: string; path?: string }> = []
|
|
225
|
+
|
|
226
|
+
// Parse template string: "Hello $0" -> parts: ["Hello ", ""], use refs[0] for expression
|
|
227
|
+
const regex = /\$(\d+)/g
|
|
228
|
+
let lastIndex = 0
|
|
229
|
+
let match
|
|
230
|
+
|
|
231
|
+
while ((match = regex.exec(templateStr)) !== null) {
|
|
232
|
+
// Add the part before this match
|
|
233
|
+
parts.push(templateStr.slice(lastIndex, match.index))
|
|
234
|
+
|
|
235
|
+
// Get the ref by index
|
|
236
|
+
const refIndex = parseInt(match[1]!, 10)
|
|
237
|
+
const refValue = refs[refIndex]
|
|
238
|
+
if (refValue) {
|
|
239
|
+
const expr: { $ref: string; path?: string } = { $ref: refValue.$ref }
|
|
240
|
+
if (refValue.path) {
|
|
241
|
+
expr.path = refValue.path
|
|
242
|
+
}
|
|
243
|
+
expressions.push(expr)
|
|
244
|
+
} else {
|
|
245
|
+
expressions.push({ $ref: 'unknown' })
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
lastIndex = regex.lastIndex
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Add the remaining part
|
|
252
|
+
parts.push(templateStr.slice(lastIndex))
|
|
253
|
+
|
|
254
|
+
return {
|
|
255
|
+
$template: { parts, expressions }
|
|
256
|
+
} as TemplateString
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** Map input type fields to allow TypedRef or TemplateString for any field */
|
|
260
|
+
type InputWithRefs<T> = {
|
|
261
|
+
[K in keyof T]?: T[K] | TypedRef<T[K]> | TypedRef<unknown> | TemplateString
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** Get the input type for a node based on its RPC mapping */
|
|
265
|
+
type NodeInputType<FuncMap extends Record<string, string>, K extends keyof FuncMap> =
|
|
266
|
+
FuncMap[K] extends keyof FlattenedRPCMap
|
|
267
|
+
? InputWithRefs<FlattenedRPCMap[FuncMap[K]]['input']>
|
|
268
|
+
: Record<string, unknown>
|
|
269
|
+
|
|
270
|
+
/** Get the output type keys for a node based on its RPC mapping */
|
|
271
|
+
type NodeOutputKeys<FuncMap extends Record<string, string>, N extends string> =
|
|
272
|
+
N extends keyof FuncMap
|
|
273
|
+
? FuncMap[N] extends keyof FlattenedRPCMap
|
|
274
|
+
? keyof FlattenedRPCMap[FuncMap[N]]['output'] & string
|
|
275
|
+
: string
|
|
276
|
+
: string
|
|
277
|
+
|
|
278
|
+
/** Ref function type with path validation */
|
|
279
|
+
type RefFunction<FuncMap extends Record<string, string>> = {
|
|
280
|
+
<N extends Extract<keyof FuncMap, string>>(
|
|
281
|
+
nodeId: N,
|
|
282
|
+
path: NodeOutputKeys<FuncMap, N>
|
|
283
|
+
): TypedRef<unknown>
|
|
284
|
+
(nodeId: 'trigger' | '$item', path?: string): TypedRef<unknown>
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** Template function type */
|
|
288
|
+
type TemplateFunction = (templateStr: string, refs: TypedRef<unknown>[]) => TemplateString
|
|
289
|
+
|
|
290
|
+
/** Type helper for node configuration */
|
|
291
|
+
type GraphNodeConfigMap<FuncMap extends Record<string, string>> = {
|
|
292
|
+
[K in Extract<keyof FuncMap, string>]?: {
|
|
293
|
+
next?: NextConfig<Extract<keyof FuncMap, string>>
|
|
294
|
+
input?:
|
|
295
|
+
| NodeInputType<FuncMap, K>
|
|
296
|
+
| (() => NodeInputType<FuncMap, K>)
|
|
297
|
+
| ((ref: RefFunction<FuncMap>, template: TemplateFunction) => NodeInputType<FuncMap, K>)
|
|
298
|
+
onError?: Extract<keyof FuncMap, string> | Extract<keyof FuncMap, string>[]
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
type NextConfig<NodeIds extends string> = NodeIds | NodeIds[] | { if: string; then: NodeIds; else?: NodeIds }
|
|
303
|
+
|
|
304
|
+
// ============================================================================
|
|
305
|
+
// Unified wireWorkflow
|
|
306
|
+
// ============================================================================
|
|
307
|
+
|
|
308
|
+
/** Workflow definition with DSL function */
|
|
309
|
+
interface WorkflowDefinitionFunc {
|
|
310
|
+
/** Whether this workflow wiring is enabled (default: true) */
|
|
311
|
+
enabled?: boolean
|
|
312
|
+
/** Wire configurations for the workflow */
|
|
313
|
+
wires: {
|
|
314
|
+
http?: { route: string; method: HTTPMethod }
|
|
315
|
+
channel?: string
|
|
316
|
+
queue?: string
|
|
317
|
+
}
|
|
318
|
+
/** DSL workflow function */
|
|
319
|
+
func: PikkuFunctionConfig<any, any, 'workflow', PikkuFunctionWorkflow<any, any>>
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/** Workflow definition with graph */
|
|
323
|
+
interface WorkflowDefinitionGraph<T, NodeIds extends string = string> {
|
|
324
|
+
/** Whether this workflow wiring is enabled (default: true) */
|
|
325
|
+
enabled?: boolean
|
|
326
|
+
/** Graph workflow definition - wires are defined in the graph itself */
|
|
327
|
+
graph: PikkuWorkflowGraphResult<T, NodeIds>
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Wire a workflow with wires
|
|
332
|
+
* Accepts either a DSL function (func) or a graph definition (graph)
|
|
333
|
+
*
|
|
334
|
+
* @example
|
|
335
|
+
* // DSL workflow
|
|
336
|
+
* wireWorkflow({
|
|
337
|
+
* wires: { http: { route: '/start', method: 'post' } },
|
|
338
|
+
* func: myWorkflowFunc,
|
|
339
|
+
* })
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* // Graph workflow - wires are defined in the graph itself
|
|
343
|
+
* wireWorkflow({
|
|
344
|
+
* enabled: true, // default: true
|
|
345
|
+
* graph: myGraphWorkflow,
|
|
346
|
+
* })
|
|
347
|
+
*/
|
|
348
|
+
export function wireWorkflow<T extends Record<string, GraphNodeConfig<Extract<keyof T, string>>>, NodeIds extends string = string>(
|
|
349
|
+
definition: WorkflowDefinitionFunc | WorkflowDefinitionGraph<T, NodeIds>
|
|
350
|
+
): void {
|
|
351
|
+
coreWireWorkflow(definition as any)
|
|
352
|
+
}
|
|
99
353
|
`;
|
|
100
354
|
};
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Generate queue workers
|
|
2
|
+
* Generate queue workers for workflow orchestration
|
|
3
3
|
*/
|
|
4
4
|
export const serializeWorkflowWorkers = (pathToPikkuTypes) => {
|
|
5
5
|
return `/**
|
|
6
|
-
*
|
|
7
|
-
* Do not edit manually - regenerate with 'npx pikku'
|
|
6
|
+
* Workflow queue workers for orchestration
|
|
8
7
|
*/
|
|
9
8
|
import { pikkuSessionlessFunc, wireQueueWorker } from '${pathToPikkuTypes}'
|
|
10
9
|
|
|
11
|
-
/**
|
|
12
|
-
* Worker input types for generated queue workers
|
|
13
|
-
*/
|
|
14
10
|
export type WorkflowStepInput = {
|
|
15
11
|
runId: string
|
|
16
12
|
stepName: string
|
|
@@ -18,43 +14,34 @@ export type WorkflowStepInput = {
|
|
|
18
14
|
data: any
|
|
19
15
|
}
|
|
20
16
|
|
|
21
|
-
export const pikkuWorkflowWorker = pikkuSessionlessFunc<
|
|
22
|
-
WorkflowStepInput,
|
|
23
|
-
void
|
|
24
|
-
>({
|
|
17
|
+
export const pikkuWorkflowWorker = pikkuSessionlessFunc<WorkflowStepInput, void>({
|
|
25
18
|
func: async ({ workflowService }, { runId, stepName, rpcName, data }, { rpc }) => {
|
|
26
19
|
await workflowService!.executeWorkflowStep(runId, stepName, rpcName, data, rpc)
|
|
27
20
|
}
|
|
28
21
|
})
|
|
29
22
|
|
|
30
|
-
export const pikkuWorkflowOrchestrator = pikkuSessionlessFunc<
|
|
31
|
-
{ runId: string },
|
|
32
|
-
void
|
|
33
|
-
>({
|
|
23
|
+
export const pikkuWorkflowOrchestrator = pikkuSessionlessFunc<{ runId: string }, void>({
|
|
34
24
|
func: async ({ workflowService }, { runId }, { rpc }) => {
|
|
35
25
|
await workflowService!.orchestrateWorkflow(runId, rpc)
|
|
36
26
|
}
|
|
37
27
|
})
|
|
38
28
|
|
|
39
|
-
export const pikkuWorkflowSleeper = pikkuSessionlessFunc<
|
|
40
|
-
{ runId: string, stepId: string },
|
|
41
|
-
void
|
|
42
|
-
>({
|
|
29
|
+
export const pikkuWorkflowSleeper = pikkuSessionlessFunc<{ runId: string, stepId: string }, void>({
|
|
43
30
|
func: async ({ workflowService }, { runId, stepId }) => {
|
|
44
|
-
await workflowService!.
|
|
31
|
+
await workflowService!.executeWorkflowSleepCompleted(runId, stepId)
|
|
45
32
|
},
|
|
46
|
-
name: 'pikkuWorkflowStepSleeper',
|
|
47
33
|
internal: true,
|
|
48
34
|
})
|
|
49
35
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
36
|
+
export const pikkuRemoteInternalRPC = pikkuSessionlessFunc<{ rpcName: string, data?: any }, any>({
|
|
37
|
+
func: async (_services, { rpcName, data }, { rpc }) => {
|
|
38
|
+
return await (rpc.invoke as any)(rpcName, data)
|
|
39
|
+
},
|
|
40
|
+
internal: true,
|
|
53
41
|
})
|
|
54
42
|
|
|
55
|
-
wireQueueWorker({
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
})
|
|
43
|
+
wireQueueWorker({ queueName: 'pikku-workflow-step-worker', func: pikkuWorkflowWorker })
|
|
44
|
+
wireQueueWorker({ queueName: 'pikku-workflow-orchestrator', func: pikkuWorkflowOrchestrator })
|
|
45
|
+
wireQueueWorker({ queueName: 'pikku-remote-internal-rpc', func: pikkuRemoteInternalRPC })
|
|
59
46
|
`;
|
|
60
47
|
};
|
package/dist/src/services.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { pikkuCLIRender } from '@pikku/core/cli';
|
|
2
|
-
import { LocalVariablesService, LogLevel } from '@pikku/core/services';
|
|
2
|
+
import { LocalVariablesService, LocalSecretService, LogLevel, } from '@pikku/core/services';
|
|
3
3
|
import { CLILogger } from './services/cli-logger.service.js';
|
|
4
4
|
import { getPikkuCLIConfig } from './utils/pikku-cli-config.js';
|
|
5
5
|
import { inspect, serializeInspectorState, deserializeInspectorState, filterInspectorState, getInitialInspectorState, } from '@pikku/inspector';
|
|
@@ -183,9 +183,11 @@ export const createSingletonServices = async (config) => {
|
|
|
183
183
|
// Run inspector WITHOUT filters to get full state
|
|
184
184
|
const wiringFiles = (await Promise.all(srcDirectories.map((dir) => glob(`${path.join(rootDir, dir)}/**/*.ts`, {
|
|
185
185
|
ignore: config.ignoreFiles || [],
|
|
186
|
+
absolute: true,
|
|
186
187
|
})))).flat();
|
|
187
188
|
unfilteredState = inspect(logger, wiringFiles, {
|
|
188
189
|
setupOnly,
|
|
190
|
+
rootDir,
|
|
189
191
|
types: {
|
|
190
192
|
configFileType: config.configFile,
|
|
191
193
|
userSessionType: config.userSessionType,
|
|
@@ -215,6 +217,7 @@ export const createSingletonServices = async (config) => {
|
|
|
215
217
|
config,
|
|
216
218
|
logger,
|
|
217
219
|
variables,
|
|
220
|
+
secrets: new LocalSecretService(variables),
|
|
218
221
|
getInspectorState,
|
|
219
222
|
};
|
|
220
223
|
};
|
|
@@ -52,6 +52,8 @@ export class CommandSummary {
|
|
|
52
52
|
mcpEndpoints: 'MCP endpoint',
|
|
53
53
|
cliCommands: 'CLI command',
|
|
54
54
|
workflows: 'Workflow',
|
|
55
|
+
forgeNodes: 'Forge node',
|
|
56
|
+
workflowGraphs: 'Workflow graph',
|
|
55
57
|
};
|
|
56
58
|
for (const [key, label] of Object.entries(statLabels)) {
|
|
57
59
|
const value = this.stats[key];
|
|
@@ -1,40 +1,38 @@
|
|
|
1
|
+
// Sanitize a type name to be a valid TypeScript identifier
|
|
2
|
+
function sanitizeTypeName(name) {
|
|
3
|
+
// Replace hyphens with underscores
|
|
4
|
+
return name.replace(/-/g, '_');
|
|
5
|
+
}
|
|
1
6
|
export function generateCustomTypes(typesMap, requiredTypes) {
|
|
2
7
|
return `
|
|
3
|
-
// Custom types are those that are defined directly within generics
|
|
4
|
-
// or are broken into simpler types
|
|
5
8
|
${Array.from(typesMap.customTypes.entries())
|
|
6
|
-
.
|
|
9
|
+
.filter(([_name, { type }]) => {
|
|
10
|
+
const hasUndefinedGeneric = /\b(Name|In|Out|Key)\b/.test(type) && /\[.*\]/.test(type);
|
|
11
|
+
return !hasUndefinedGeneric;
|
|
12
|
+
})
|
|
13
|
+
.map(([originalName, { type, references }]) => {
|
|
14
|
+
const name = sanitizeTypeName(originalName);
|
|
7
15
|
references.forEach((refName) => {
|
|
8
|
-
// Skip __object types (including those with suffixes like __object_abc123)
|
|
9
|
-
// These are placeholder types created by the inspector for invalid/broken functions
|
|
10
|
-
// (e.g., functions with type errors or missing return statements). Attempting to
|
|
11
|
-
// import these would fail since the source files don't actually export __object.
|
|
12
16
|
if (refName !== '__object' && !refName.startsWith('__object_')) {
|
|
13
17
|
requiredTypes.add(refName);
|
|
14
18
|
}
|
|
15
19
|
});
|
|
16
|
-
// Extract type names from the type string that might not be in references
|
|
17
20
|
const typeString = type;
|
|
18
|
-
// Use regex to extract potential type names (PascalCase identifiers)
|
|
19
21
|
const typeNameRegex = /\b[A-Z][a-zA-Z0-9]*\b/g;
|
|
20
22
|
const potentialTypes = typeString.match(typeNameRegex) || [];
|
|
21
23
|
potentialTypes.forEach((typeName) => {
|
|
22
|
-
// Skip string literals and common keywords
|
|
23
24
|
if (typeString.includes(`"${typeName}"`) ||
|
|
24
25
|
['Pick', 'Omit', 'Partial', 'Required', 'Record', 'Readonly'].includes(typeName)) {
|
|
25
26
|
return;
|
|
26
27
|
}
|
|
27
|
-
// Try to find this type in the typesMap and add it if found
|
|
28
28
|
try {
|
|
29
29
|
const typeMeta = typesMap.getTypeMeta(typeName);
|
|
30
30
|
if (typeMeta.path) {
|
|
31
|
-
// Add originalName to preserve canonical import name
|
|
32
31
|
requiredTypes.add(typeMeta.originalName);
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
|
-
catch
|
|
36
|
-
// Type not found in map (ambient/builtin type)
|
|
37
|
-
// Do NOT add to requiredTypes to avoid crashes in serializeImportMap
|
|
34
|
+
catch {
|
|
35
|
+
// Type not found in map (ambient/builtin type)
|
|
38
36
|
}
|
|
39
37
|
});
|
|
40
38
|
return `export type ${name} = ${type}`;
|
|
@@ -7,7 +7,7 @@ export const generateBootstrapFile = async (logger, config, bootstrapFile, speci
|
|
|
7
7
|
if (hasMiddleware) {
|
|
8
8
|
commonImports.push(config.middlewareFile);
|
|
9
9
|
}
|
|
10
|
-
commonImports.push(config.
|
|
10
|
+
commonImports.push(config.functionsMetaFile, config.functionsFile);
|
|
11
11
|
// Add schema if it exists
|
|
12
12
|
if (schemas) {
|
|
13
13
|
commonImports.push(`${config.schemaDirectory}/register.gen.ts`);
|
|
@@ -38,6 +38,10 @@ const _getPikkuCLIConfig = async (logger, configFile = undefined, requiredFields
|
|
|
38
38
|
...extendedConfig.packageMappings,
|
|
39
39
|
...config.packageMappings,
|
|
40
40
|
},
|
|
41
|
+
externalPackages: {
|
|
42
|
+
...extendedConfig.externalPackages,
|
|
43
|
+
...config.externalPackages,
|
|
44
|
+
},
|
|
41
45
|
ignoreFiles: config.ignoreFiles ??
|
|
42
46
|
extendedConfig.ignoreFiles ?? [
|
|
43
47
|
'**/*.test.ts',
|
|
@@ -58,6 +62,7 @@ const _getPikkuCLIConfig = async (logger, configFile = undefined, requiredFields
|
|
|
58
62
|
...config,
|
|
59
63
|
configDir,
|
|
60
64
|
packageMappings: config.packageMappings || {},
|
|
65
|
+
externalPackages: config.externalPackages || {},
|
|
61
66
|
rootDir: config.rootDir
|
|
62
67
|
? resolve(configDir, config.rootDir)
|
|
63
68
|
: configDir,
|
|
@@ -99,12 +104,6 @@ const _getPikkuCLIConfig = async (logger, configFile = undefined, requiredFields
|
|
|
99
104
|
if (!result.functionsMetaJsonFile) {
|
|
100
105
|
result.functionsMetaJsonFile = join(functionDir, 'pikku-functions-meta.gen.json');
|
|
101
106
|
}
|
|
102
|
-
if (!result.functionsMetaMinFile) {
|
|
103
|
-
result.functionsMetaMinFile = join(functionDir, 'pikku-functions-meta.min.gen.ts');
|
|
104
|
-
}
|
|
105
|
-
if (!result.functionsMetaMinJsonFile) {
|
|
106
|
-
result.functionsMetaMinJsonFile = join(functionDir, 'pikku-functions-meta.min.gen.json');
|
|
107
|
-
}
|
|
108
107
|
if (!result.functionTypesFile) {
|
|
109
108
|
result.functionTypesFile = join(functionDir, 'pikku-function-types.gen.ts');
|
|
110
109
|
}
|
|
@@ -199,9 +198,6 @@ const _getPikkuCLIConfig = async (logger, configFile = undefined, requiredFields
|
|
|
199
198
|
if (!result.workflowsWiringMetaFile) {
|
|
200
199
|
result.workflowsWiringMetaFile = join(workflowDir, 'pikku-workflow-wirings-meta.gen.ts');
|
|
201
200
|
}
|
|
202
|
-
if (!result.workflowsWiringMetaJsonFile) {
|
|
203
|
-
result.workflowsWiringMetaJsonFile = join(workflowDir, 'pikku-workflow-wirings-meta.gen.json');
|
|
204
|
-
}
|
|
205
201
|
if (!result.workflowsWorkersFile) {
|
|
206
202
|
result.workflowsWorkersFile = join(workflowDir, 'pikku-workflow-workers.gen.ts');
|
|
207
203
|
}
|
|
@@ -211,6 +207,10 @@ const _getPikkuCLIConfig = async (logger, configFile = undefined, requiredFields
|
|
|
211
207
|
if (!result.workflowTypesFile) {
|
|
212
208
|
result.workflowTypesFile = join(workflowDir, 'pikku-workflow-types.gen.ts');
|
|
213
209
|
}
|
|
210
|
+
// Workflow meta directory (individual JSON files for each workflow)
|
|
211
|
+
if (!result.workflowMetaDir) {
|
|
212
|
+
result.workflowMetaDir = join(workflowDir, 'meta');
|
|
213
|
+
}
|
|
214
214
|
// Services
|
|
215
215
|
if (!result.servicesFile) {
|
|
216
216
|
result.servicesFile = join(result.outDir, 'pikku-services.gen.ts');
|
|
@@ -234,6 +234,10 @@ const _getPikkuCLIConfig = async (logger, configFile = undefined, requiredFields
|
|
|
234
234
|
if (!result.bootstrapFile) {
|
|
235
235
|
result.bootstrapFile = join(result.outDir, 'pikku-bootstrap.gen.ts');
|
|
236
236
|
}
|
|
237
|
+
// Package service factories (for external packages)
|
|
238
|
+
if (!result.packageFile) {
|
|
239
|
+
result.packageFile = join(result.outDir, 'pikku-package.gen.ts');
|
|
240
|
+
}
|
|
237
241
|
// MCP
|
|
238
242
|
if (!result.mcpWiringsMetaFile) {
|
|
239
243
|
result.mcpWiringsMetaFile = join(mcpDir, 'pikku-mcp-wirings-meta.gen.ts');
|
|
@@ -266,6 +270,14 @@ const _getPikkuCLIConfig = async (logger, configFile = undefined, requiredFields
|
|
|
266
270
|
if (!result.cliTypesFile) {
|
|
267
271
|
result.cliTypesFile = join(cliDir, 'pikku-cli-types.gen.ts');
|
|
268
272
|
}
|
|
273
|
+
// Forge
|
|
274
|
+
const forgeDir = join(result.outDir, 'forge');
|
|
275
|
+
if (!result.forgeNodesMetaJsonFile) {
|
|
276
|
+
result.forgeNodesMetaJsonFile = join(forgeDir, 'pikku-forge-nodes-meta.gen.json');
|
|
277
|
+
}
|
|
278
|
+
if (!result.forgeTypesFile) {
|
|
279
|
+
result.forgeTypesFile = join(forgeDir, 'pikku-forge-types.gen.ts');
|
|
280
|
+
}
|
|
269
281
|
if (requiredFields.length > 0) {
|
|
270
282
|
validateCLIConfig(result, requiredFields);
|
|
271
283
|
}
|
|
@@ -285,6 +297,22 @@ const _getPikkuCLIConfig = async (logger, configFile = undefined, requiredFields
|
|
|
285
297
|
if (!isAbsolute(result.tsconfig)) {
|
|
286
298
|
result.tsconfig = join(result.rootDir, result.tsconfig);
|
|
287
299
|
}
|
|
300
|
+
if (result.externalPackage) {
|
|
301
|
+
const packageJsonPath = join(result.rootDir, 'package.json');
|
|
302
|
+
try {
|
|
303
|
+
const packageJsonContent = await readFile(packageJsonPath, 'utf-8');
|
|
304
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
305
|
+
if (!packageJson.name ||
|
|
306
|
+
typeof packageJson.name !== 'string' ||
|
|
307
|
+
packageJson.name.trim() === '') {
|
|
308
|
+
throw new Error(`package.json at ${packageJsonPath} is missing a valid "name" field`);
|
|
309
|
+
}
|
|
310
|
+
result.externalPackageName = packageJson.name;
|
|
311
|
+
}
|
|
312
|
+
catch (e) {
|
|
313
|
+
throw new Error(`externalPackage is true but could not read or parse package.json at ${packageJsonPath}: ${e.message}`);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
288
316
|
return result;
|
|
289
317
|
}
|
|
290
318
|
catch (e) {
|