@pikku/core 0.11.2 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -2
- package/dist/crypto-utils.d.ts +2 -0
- package/dist/crypto-utils.js +78 -0
- package/dist/errors/errors.d.ts +14 -0
- package/dist/errors/errors.js +26 -0
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/function/function-runner.d.ts +10 -4
- package/dist/function/function-runner.js +126 -45
- package/dist/function/functions.types.d.ts +32 -87
- package/dist/function/functions.types.js +16 -46
- package/dist/function/index.d.ts +2 -2
- package/dist/function/index.js +1 -2
- package/dist/handle-error.d.ts +2 -2
- package/dist/handle-error.js +3 -12
- package/dist/index.d.ts +30 -26
- package/dist/index.js +19 -29
- package/dist/internal.d.ts +3 -0
- package/dist/internal.js +2 -0
- package/dist/middleware/auth-apikey.d.ts +2 -2
- package/dist/middleware/auth-apikey.js +3 -3
- package/dist/middleware/auth-bearer.d.ts +3 -3
- package/dist/middleware/auth-bearer.js +4 -7
- package/dist/middleware/auth-cookie.d.ts +4 -4
- package/dist/middleware/auth-cookie.js +7 -9
- package/dist/middleware/cors.d.ts +46 -0
- package/dist/middleware/cors.js +81 -0
- package/dist/middleware/index.d.ts +5 -3
- package/dist/middleware/index.js +5 -3
- package/dist/middleware/remote-auth.d.ts +5 -0
- package/dist/middleware/remote-auth.js +55 -0
- package/dist/middleware/timeout.d.ts +2 -2
- package/dist/middleware-runner.d.ts +1 -1
- package/dist/middleware-runner.js +8 -10
- package/dist/permissions.d.ts +2 -2
- package/dist/permissions.js +11 -15
- package/dist/pikku-state.d.ts +10 -8
- package/dist/pikku-state.js +48 -25
- package/dist/schema.d.ts +4 -4
- package/dist/schema.js +20 -15
- package/dist/services/ai-agent-runner-service.d.ts +43 -0
- package/dist/services/ai-agent-runner-service.js +1 -0
- package/dist/services/ai-run-state-service.d.ts +13 -0
- package/dist/services/ai-run-state-service.js +1 -0
- package/dist/services/ai-storage-service.d.ts +18 -0
- package/dist/services/ai-storage-service.js +1 -0
- package/dist/services/content-service.d.ts +6 -0
- package/dist/services/deployment-service.d.ts +19 -0
- package/dist/services/deployment-service.js +1 -0
- package/dist/services/gopass-secrets.d.ts +47 -0
- package/dist/services/gopass-secrets.js +97 -0
- package/dist/services/in-memory-ai-run-state-service.d.ts +15 -0
- package/dist/services/in-memory-ai-run-state-service.js +44 -0
- package/dist/services/in-memory-trigger-service.d.ts +22 -0
- package/dist/services/in-memory-trigger-service.js +48 -0
- package/dist/services/in-memory-workflow-service.d.ts +59 -0
- package/dist/services/in-memory-workflow-service.js +287 -0
- package/dist/services/index.d.ts +26 -11
- package/dist/services/index.js +11 -13
- package/dist/services/local-content.d.ts +2 -1
- package/dist/services/local-content.js +6 -1
- package/dist/services/local-secrets.d.ts +25 -2
- package/dist/services/local-secrets.js +45 -0
- package/dist/services/local-variables.d.ts +6 -1
- package/dist/services/local-variables.js +18 -0
- package/dist/services/logger-console.d.ts +2 -1
- package/dist/services/scheduler-service.d.ts +9 -1
- package/dist/services/scheduler-service.js +8 -0
- package/dist/services/schema-service.d.ts +6 -0
- package/dist/services/scoped-secret-service.d.ts +16 -0
- package/dist/services/scoped-secret-service.js +35 -0
- package/dist/services/secret-service.d.ts +25 -4
- package/dist/services/trigger-service.d.ts +16 -0
- package/dist/services/trigger-service.js +1 -0
- package/dist/services/typed-secret-service.d.ts +30 -0
- package/dist/services/typed-secret-service.js +40 -0
- package/dist/services/typed-variables-service.d.ts +27 -0
- package/dist/services/typed-variables-service.js +46 -0
- package/dist/services/user-session-service.d.ts +15 -2
- package/dist/services/user-session-service.js +17 -0
- package/dist/services/variables-service.d.ts +5 -0
- package/dist/services/workflow-service.d.ts +9 -5
- package/dist/types/core.types.d.ts +67 -25
- package/dist/types/core.types.js +8 -1
- package/dist/types/state.types.d.ts +53 -59
- package/dist/utils.d.ts +7 -6
- package/dist/utils.js +27 -12
- package/dist/version.d.ts +6 -0
- package/dist/version.js +19 -0
- package/dist/wirings/ai-agent/ai-agent-assistant-ui.d.ts +5 -0
- package/dist/wirings/ai-agent/ai-agent-assistant-ui.js +146 -0
- package/dist/wirings/ai-agent/ai-agent-helpers.d.ts +28 -0
- package/dist/wirings/ai-agent/ai-agent-helpers.js +40 -0
- package/dist/wirings/ai-agent/ai-agent-memory.d.ts +29 -0
- package/dist/wirings/ai-agent/ai-agent-memory.js +199 -0
- package/dist/wirings/ai-agent/ai-agent-model-config.d.ts +9 -0
- package/dist/wirings/ai-agent/ai-agent-model-config.js +36 -0
- package/dist/wirings/ai-agent/ai-agent-prepare.d.ts +59 -0
- package/dist/wirings/ai-agent/ai-agent-prepare.js +348 -0
- package/dist/wirings/ai-agent/ai-agent-registry.d.ts +15 -0
- package/dist/wirings/ai-agent/ai-agent-registry.js +47 -0
- package/dist/wirings/ai-agent/ai-agent-runner.d.ts +3 -0
- package/dist/wirings/ai-agent/ai-agent-runner.js +195 -0
- package/dist/wirings/ai-agent/ai-agent-stream.d.ts +12 -0
- package/dist/wirings/ai-agent/ai-agent-stream.js +662 -0
- package/dist/wirings/ai-agent/ai-agent.types.d.ts +313 -0
- package/dist/wirings/ai-agent/ai-agent.types.js +1 -0
- package/dist/wirings/ai-agent/index.d.ts +7 -0
- package/dist/wirings/ai-agent/index.js +6 -0
- package/dist/wirings/channel/channel-common.d.ts +8 -5
- package/dist/wirings/channel/channel-common.js +15 -8
- package/dist/wirings/channel/channel-handler.d.ts +3 -3
- package/dist/wirings/channel/channel-handler.js +15 -6
- package/dist/wirings/channel/channel-middleware-runner.d.ts +9 -0
- package/dist/wirings/channel/channel-middleware-runner.js +73 -0
- package/dist/wirings/channel/channel-runner.d.ts +5 -5
- package/dist/wirings/channel/channel-runner.js +10 -9
- package/dist/wirings/channel/channel-store.d.ts +1 -1
- package/dist/wirings/channel/channel.types.d.ts +9 -7
- package/dist/wirings/channel/define-channel-routes.d.ts +21 -0
- package/dist/wirings/channel/define-channel-routes.js +23 -0
- package/dist/wirings/channel/index.d.ts +10 -8
- package/dist/wirings/channel/index.js +7 -8
- package/dist/wirings/channel/local/index.d.ts +3 -3
- package/dist/wirings/channel/local/index.js +3 -3
- package/dist/wirings/channel/local/local-channel-runner.d.ts +7 -2
- package/dist/wirings/channel/local/local-channel-runner.js +22 -9
- package/dist/wirings/channel/local/local-eventhub-service.d.ts +2 -2
- package/dist/wirings/channel/log-channels.d.ts +1 -1
- package/dist/wirings/channel/pikku-abstract-channel-handler.d.ts +1 -1
- package/dist/wirings/channel/serverless/index.d.ts +1 -1
- package/dist/wirings/channel/serverless/index.js +1 -1
- package/dist/wirings/channel/serverless/serverless-channel-runner.d.ts +4 -4
- package/dist/wirings/channel/serverless/serverless-channel-runner.js +40 -23
- package/dist/wirings/cli/channel/cli-channel-runner.d.ts +1 -1
- package/dist/wirings/cli/channel/index.d.ts +1 -1
- package/dist/wirings/cli/channel/index.js +1 -1
- package/dist/wirings/cli/cli-runner.d.ts +3 -3
- package/dist/wirings/cli/cli-runner.js +12 -8
- package/dist/wirings/cli/cli.types.d.ts +9 -9
- package/dist/wirings/cli/command-parser.d.ts +1 -1
- package/dist/wirings/cli/define-cli-commands.d.ts +19 -0
- package/dist/wirings/cli/define-cli-commands.js +20 -0
- package/dist/wirings/cli/index.d.ts +2 -3
- package/dist/wirings/cli/index.js +1 -3
- package/dist/wirings/http/http-routes.d.ts +69 -0
- package/dist/wirings/http/http-routes.js +139 -0
- package/dist/wirings/http/http-runner.d.ts +9 -9
- package/dist/wirings/http/http-runner.js +79 -34
- package/dist/wirings/http/http.types.d.ts +77 -41
- package/dist/wirings/http/index.d.ts +5 -4
- package/dist/wirings/http/index.js +4 -3
- package/dist/wirings/http/log-http-routes.d.ts +1 -1
- package/dist/wirings/http/pikku-fetch-http-request.d.ts +1 -1
- package/dist/wirings/http/pikku-fetch-http-response.d.ts +2 -2
- package/dist/wirings/http/pikku-fetch-http-response.js +6 -1
- package/dist/wirings/http/routers/http-router.d.ts +1 -1
- package/dist/wirings/http/routers/path-to-regex.d.ts +2 -2
- package/dist/wirings/mcp/index.d.ts +4 -3
- package/dist/wirings/mcp/index.js +3 -3
- package/dist/wirings/mcp/mcp-endpoint-registry.d.ts +1 -1
- package/dist/wirings/mcp/mcp-runner.d.ts +1 -6
- package/dist/wirings/mcp/mcp-runner.js +28 -40
- package/dist/wirings/mcp/mcp.types.d.ts +5 -5
- package/dist/wirings/node/index.d.ts +2 -0
- package/dist/wirings/node/index.js +1 -0
- package/dist/wirings/node/node.types.d.ts +20 -0
- package/dist/wirings/node/node.types.js +1 -0
- package/dist/wirings/oauth2/index.d.ts +3 -0
- package/dist/wirings/oauth2/index.js +2 -0
- package/dist/wirings/oauth2/oauth2-client.d.ts +47 -0
- package/dist/wirings/oauth2/oauth2-client.js +267 -0
- package/dist/wirings/oauth2/oauth2.types.d.ts +65 -0
- package/dist/wirings/oauth2/oauth2.types.js +4 -0
- package/dist/wirings/oauth2/wire-oauth2-credential.d.ts +20 -0
- package/dist/wirings/oauth2/wire-oauth2-credential.js +21 -0
- package/dist/wirings/queue/index.d.ts +1 -1
- package/dist/wirings/queue/queue-runner.d.ts +1 -5
- package/dist/wirings/queue/queue-runner.js +11 -8
- package/dist/wirings/queue/queue.types.d.ts +5 -5
- package/dist/wirings/queue/register-queue-helper.d.ts +2 -2
- package/dist/wirings/queue/register-queue-helper.js +1 -1
- package/dist/wirings/queue/validate-worker-config.d.ts +1 -1
- package/dist/wirings/rpc/index.d.ts +3 -1
- package/dist/wirings/rpc/index.js +2 -1
- package/dist/wirings/rpc/rpc-runner.d.ts +58 -8
- package/dist/wirings/rpc/rpc-runner.js +177 -31
- package/dist/wirings/rpc/rpc-types.d.ts +20 -4
- package/dist/wirings/rpc/wire-addon.d.ts +10 -0
- package/dist/wirings/rpc/wire-addon.js +9 -0
- package/dist/wirings/scheduler/index.d.ts +2 -2
- package/dist/wirings/scheduler/index.js +1 -2
- package/dist/wirings/scheduler/log-schedulers.d.ts +1 -1
- package/dist/wirings/scheduler/scheduler-runner.d.ts +3 -5
- package/dist/wirings/scheduler/scheduler-runner.js +11 -14
- package/dist/wirings/scheduler/scheduler.types.d.ts +2 -2
- package/dist/wirings/secret/index.d.ts +3 -0
- package/dist/wirings/secret/index.js +2 -0
- package/dist/wirings/secret/secret.types.d.ts +27 -0
- package/dist/wirings/secret/secret.types.js +1 -0
- package/dist/wirings/secret/validate-secret-definitions.d.ts +6 -0
- package/dist/wirings/secret/validate-secret-definitions.js +55 -0
- package/dist/wirings/trigger/index.d.ts +3 -2
- package/dist/wirings/trigger/index.js +2 -2
- package/dist/wirings/trigger/pikku-trigger-service.d.ts +22 -0
- package/dist/wirings/trigger/pikku-trigger-service.js +70 -0
- package/dist/wirings/trigger/trigger-runner.d.ts +18 -9
- package/dist/wirings/trigger/trigger-runner.js +48 -19
- package/dist/wirings/trigger/trigger.types.d.ts +99 -11
- package/dist/wirings/trigger/trigger.types.js +40 -1
- package/dist/wirings/variable/index.d.ts +3 -0
- package/dist/wirings/variable/index.js +2 -0
- package/dist/wirings/variable/validate-variable-definitions.d.ts +6 -0
- package/dist/wirings/variable/validate-variable-definitions.js +45 -0
- package/dist/wirings/variable/variable.types.d.ts +18 -0
- package/dist/wirings/variable/variable.types.js +1 -0
- package/dist/wirings/workflow/dsl/index.d.ts +1 -1
- package/dist/wirings/workflow/dsl/workflow-dsl.types.d.ts +7 -1
- package/dist/wirings/workflow/dsl/workflow-runner.js +3 -2
- package/dist/wirings/workflow/graph/graph-node.d.ts +1 -6
- package/dist/wirings/workflow/graph/graph-runner.d.ts +5 -31
- package/dist/wirings/workflow/graph/graph-runner.js +384 -296
- package/dist/wirings/workflow/graph/index.d.ts +4 -3
- package/dist/wirings/workflow/graph/index.js +3 -3
- package/dist/wirings/workflow/graph/template.d.ts +15 -0
- package/dist/wirings/workflow/graph/template.js +27 -0
- package/dist/wirings/workflow/graph/wire-workflow-graph.d.ts +15 -0
- package/dist/wirings/workflow/graph/wire-workflow-graph.js +8 -0
- package/dist/wirings/workflow/graph/workflow-graph.types.d.ts +0 -13
- package/dist/wirings/workflow/index.d.ts +6 -6
- package/dist/wirings/workflow/index.js +6 -4
- package/dist/wirings/workflow/pikku-workflow-service.d.ts +29 -19
- package/dist/wirings/workflow/pikku-workflow-service.js +217 -82
- package/dist/wirings/workflow/workflow-helpers.d.ts +36 -0
- package/dist/wirings/workflow/workflow-helpers.js +38 -0
- package/dist/wirings/workflow/workflow.types.d.ts +42 -95
- package/package.json +14 -15
- package/run-tests.sh +4 -1
- package/src/crypto-utils.test.ts +116 -0
- package/src/crypto-utils.ts +99 -0
- package/src/errors/error.test.ts +143 -2
- package/src/errors/errors.ts +27 -0
- package/src/errors/index.ts +1 -1
- package/src/factory-functions.test.ts +42 -2
- package/src/function/function-runner.test.ts +6 -13
- package/src/function/function-runner.ts +161 -53
- package/src/function/functions.types.ts +63 -132
- package/src/function/index.ts +5 -2
- package/src/handle-error.test.ts +361 -0
- package/src/handle-error.ts +6 -14
- package/src/index.ts +97 -30
- package/src/internal.ts +6 -0
- package/src/middleware/auth-apikey.test.ts +16 -13
- package/src/middleware/auth-apikey.ts +3 -3
- package/src/middleware/auth-bearer.test.ts +18 -15
- package/src/middleware/auth-bearer.ts +27 -32
- package/src/middleware/auth-cookie.test.ts +17 -14
- package/src/middleware/auth-cookie.ts +9 -13
- package/src/middleware/cors.test.ts +424 -0
- package/src/middleware/cors.ts +104 -0
- package/src/middleware/index.ts +5 -3
- package/src/middleware/remote-auth.test.ts +488 -0
- package/src/middleware/remote-auth.ts +68 -0
- package/src/middleware-runner.test.ts +123 -1
- package/src/middleware-runner.ts +13 -13
- package/src/permissions.test.ts +83 -9
- package/src/permissions.ts +17 -19
- package/src/pikku-state.test.ts +224 -0
- package/src/pikku-state.ts +59 -35
- package/src/run-tests-script.test.ts +49 -0
- package/src/schema.test.ts +198 -6
- package/src/schema.ts +28 -21
- package/src/services/ai-agent-runner-service.ts +41 -0
- package/src/services/ai-run-state-service.ts +20 -0
- package/src/services/ai-storage-service.ts +39 -0
- package/src/services/content-service.ts +7 -0
- package/src/services/deployment-service.ts +22 -0
- package/src/services/gopass-secrets.ts +98 -0
- package/src/services/in-memory-ai-run-state-service.ts +73 -0
- package/src/services/in-memory-trigger-service.ts +64 -0
- package/src/services/in-memory-workflow-service.test.ts +351 -0
- package/src/services/in-memory-workflow-service.ts +395 -0
- package/src/services/index.ts +50 -14
- package/src/services/local-content.ts +9 -3
- package/src/services/local-secrets.test.ts +80 -0
- package/src/services/local-secrets.ts +53 -2
- package/src/services/local-variables.test.ts +61 -0
- package/src/services/local-variables.ts +23 -1
- package/src/services/logger-console.test.ts +118 -0
- package/src/services/logger-console.ts +2 -1
- package/src/services/scheduler-service.ts +11 -1
- package/src/services/schema-service.ts +7 -0
- package/src/services/scoped-secret-service.test.ts +74 -0
- package/src/services/scoped-secret-service.ts +41 -0
- package/src/services/secret-service.ts +25 -4
- package/src/services/trigger-service.ts +17 -0
- package/src/services/typed-secret-service.test.ts +93 -0
- package/src/services/typed-secret-service.ts +70 -0
- package/src/services/typed-variables-service.test.ts +73 -0
- package/src/services/typed-variables-service.ts +81 -0
- package/src/services/user-session-service.test.ts +113 -0
- package/src/services/user-session-service.ts +25 -2
- package/src/services/variables-service.ts +5 -0
- package/src/services/workflow-service.ts +23 -13
- package/src/time-utils.test.ts +1 -1
- package/src/types/core.types.ts +95 -24
- package/src/types/state.types.ts +56 -73
- package/src/utils.test.ts +350 -0
- package/src/utils.ts +33 -18
- package/src/version.test.ts +80 -0
- package/src/version.ts +25 -0
- package/src/wirings/ai-agent/ai-agent-assistant-ui.test.ts +363 -0
- package/src/wirings/ai-agent/ai-agent-assistant-ui.ts +214 -0
- package/src/wirings/ai-agent/ai-agent-helpers.test.ts +152 -0
- package/src/wirings/ai-agent/ai-agent-helpers.ts +76 -0
- package/src/wirings/ai-agent/ai-agent-memory.ts +300 -0
- package/src/wirings/ai-agent/ai-agent-model-config.test.ts +115 -0
- package/src/wirings/ai-agent/ai-agent-model-config.ts +43 -0
- package/src/wirings/ai-agent/ai-agent-prepare.ts +504 -0
- package/src/wirings/ai-agent/ai-agent-registry.test.ts +37 -0
- package/src/wirings/ai-agent/ai-agent-registry.ts +82 -0
- package/src/wirings/ai-agent/ai-agent-runner.test.ts +317 -0
- package/src/wirings/ai-agent/ai-agent-runner.ts +251 -0
- package/src/wirings/ai-agent/ai-agent-stream.test.ts +652 -0
- package/src/wirings/ai-agent/ai-agent-stream.ts +1049 -0
- package/src/wirings/ai-agent/ai-agent.types.ts +328 -0
- package/src/wirings/ai-agent/index.ts +39 -0
- package/src/wirings/channel/channel-common.ts +33 -20
- package/src/wirings/channel/channel-handler.ts +26 -9
- package/src/wirings/channel/channel-middleware-runner.ts +119 -0
- package/src/wirings/channel/channel-runner.ts +15 -16
- package/src/wirings/channel/channel-store.ts +1 -1
- package/src/wirings/channel/channel.types.ts +21 -9
- package/src/wirings/channel/define-channel-routes.ts +25 -0
- package/src/wirings/channel/index.ts +23 -8
- package/src/wirings/channel/local/index.ts +3 -3
- package/src/wirings/channel/local/local-channel-runner.test.ts +57 -7
- package/src/wirings/channel/local/local-channel-runner.ts +40 -19
- package/src/wirings/channel/local/local-eventhub-service.test.ts +2 -2
- package/src/wirings/channel/local/local-eventhub-service.ts +2 -2
- package/src/wirings/channel/log-channels.ts +1 -1
- package/src/wirings/channel/pikku-abstract-channel-handler.ts +1 -1
- package/src/wirings/channel/serverless/index.ts +5 -1
- package/src/wirings/channel/serverless/serverless-channel-runner.ts +57 -36
- package/src/wirings/cli/channel/cli-channel-runner.ts +1 -1
- package/src/wirings/cli/channel/index.ts +1 -1
- package/src/wirings/cli/cli-runner.test.ts +10 -10
- package/src/wirings/cli/cli-runner.ts +28 -14
- package/src/wirings/cli/cli.types.ts +14 -14
- package/src/wirings/cli/command-parser.test.ts +9 -9
- package/src/wirings/cli/command-parser.ts +1 -1
- package/src/wirings/cli/define-cli-commands.ts +24 -0
- package/src/wirings/cli/index.ts +10 -4
- package/src/wirings/http/http-routes.test.ts +322 -0
- package/src/wirings/http/http-routes.ts +198 -0
- package/src/wirings/http/http-runner.test.ts +12 -20
- package/src/wirings/http/http-runner.ts +101 -51
- package/src/wirings/http/http.types.ts +119 -48
- package/src/wirings/http/index.ts +16 -4
- package/src/wirings/http/log-http-routes.ts +1 -1
- package/src/wirings/http/pikku-fetch-http-request.ts +1 -1
- package/src/wirings/http/pikku-fetch-http-response.ts +12 -5
- package/src/wirings/http/routers/http-router.ts +1 -1
- package/src/wirings/http/routers/path-to-regex.test.ts +1 -1
- package/src/wirings/http/routers/path-to-regex.ts +4 -3
- package/src/wirings/mcp/index.ts +27 -3
- package/src/wirings/mcp/mcp-endpoint-registry.test.ts +3 -3
- package/src/wirings/mcp/mcp-endpoint-registry.ts +5 -1
- package/src/wirings/mcp/mcp-runner.ts +48 -65
- package/src/wirings/mcp/mcp.types.ts +5 -5
- package/src/wirings/node/index.ts +2 -0
- package/src/wirings/node/node.types.ts +23 -0
- package/src/wirings/oauth2/index.ts +3 -0
- package/src/wirings/oauth2/oauth2-client.test.ts +929 -0
- package/src/wirings/oauth2/oauth2-client.ts +335 -0
- package/src/wirings/oauth2/oauth2.types.ts +69 -0
- package/src/wirings/oauth2/wire-oauth2-credential.ts +23 -0
- package/src/wirings/queue/index.ts +13 -2
- package/src/wirings/queue/queue-runner.test.ts +142 -73
- package/src/wirings/queue/queue-runner.ts +18 -14
- package/src/wirings/queue/queue.types.ts +5 -5
- package/src/wirings/queue/register-queue-helper.ts +3 -5
- package/src/wirings/queue/validate-worker-config.test.ts +108 -0
- package/src/wirings/queue/validate-worker-config.ts +4 -1
- package/src/wirings/rpc/index.ts +3 -1
- package/src/wirings/rpc/rpc-runner.ts +254 -41
- package/src/wirings/rpc/rpc-types.ts +28 -4
- package/src/wirings/rpc/wire-addon.ts +20 -0
- package/src/wirings/scheduler/index.ts +6 -4
- package/src/wirings/scheduler/log-schedulers.ts +1 -1
- package/src/wirings/scheduler/scheduler-runner.test.ts +78 -45
- package/src/wirings/scheduler/scheduler-runner.ts +20 -27
- package/src/wirings/scheduler/scheduler.types.ts +2 -2
- package/src/wirings/secret/index.ts +9 -0
- package/src/wirings/secret/secret.types.ts +32 -0
- package/src/wirings/secret/validate-secret-definitions.test.ts +140 -0
- package/src/wirings/secret/validate-secret-definitions.ts +82 -0
- package/src/wirings/trigger/index.ts +10 -2
- package/src/wirings/trigger/pikku-trigger-service.ts +112 -0
- package/src/wirings/trigger/trigger-runner.test.ts +79 -0
- package/src/wirings/trigger/trigger-runner.ts +80 -41
- package/src/wirings/trigger/trigger.types.ts +144 -22
- package/src/wirings/variable/index.ts +8 -0
- package/src/wirings/variable/validate-variable-definitions.test.ts +91 -0
- package/src/wirings/variable/validate-variable-definitions.ts +69 -0
- package/src/wirings/variable/variable.types.ts +22 -0
- package/src/wirings/workflow/dsl/index.ts +1 -0
- package/src/wirings/workflow/dsl/workflow-dsl.types.ts +9 -1
- package/src/wirings/workflow/dsl/workflow-runner.ts +4 -3
- package/src/wirings/workflow/graph/graph-node.ts +1 -6
- package/src/wirings/workflow/graph/graph-runner.test.ts +487 -0
- package/src/wirings/workflow/graph/graph-runner.ts +496 -374
- package/src/wirings/workflow/graph/index.ts +14 -3
- package/src/wirings/workflow/graph/template.test.ts +49 -0
- package/src/wirings/workflow/graph/template.ts +42 -0
- package/src/wirings/workflow/graph/wire-workflow-graph.ts +29 -0
- package/src/wirings/workflow/graph/workflow-graph.types.ts +0 -22
- package/src/wirings/workflow/index.ts +21 -10
- package/src/wirings/workflow/pikku-workflow-service.test.ts +200 -0
- package/src/wirings/workflow/pikku-workflow-service.ts +308 -105
- package/src/wirings/workflow/workflow-helpers.test.ts +129 -0
- package/src/wirings/workflow/workflow-helpers.ts +79 -0
- package/src/wirings/workflow/workflow.types.ts +47 -92
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/wirings/forge-node/forge-node.types.d.ts +0 -120
- package/dist/wirings/forge-node/forge-node.types.js +0 -38
- package/dist/wirings/forge-node/index.d.ts +0 -1
- package/dist/wirings/forge-node/index.js +0 -1
- package/dist/wirings/workflow/wire-workflow.d.ts +0 -42
- package/dist/wirings/workflow/wire-workflow.js +0 -53
- package/dist/wirings/workflow/workflow-utils.d.ts +0 -23
- package/dist/wirings/workflow/workflow-utils.js +0 -66
- package/src/wirings/forge-node/forge-node.types.ts +0 -135
- package/src/wirings/forge-node/index.ts +0 -1
- package/src/wirings/workflow/wire-workflow.ts +0 -94
- package/src/wirings/workflow/workflow-utils.ts +0 -120
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PikkuWire, WireServices } from '../../../types/core.types.js'
|
|
1
|
+
import type { PikkuWire, WireServices } from '../../../types/core.types.js'
|
|
2
2
|
import { closeWireServices } from '../../../utils.js'
|
|
3
3
|
import { processMessageHandlers } from '../channel-handler.js'
|
|
4
4
|
import { openChannel } from '../channel-runner.js'
|
|
@@ -9,12 +9,19 @@ import type {
|
|
|
9
9
|
PikkuChannelHandlerFactory,
|
|
10
10
|
} from '../channel.types.js'
|
|
11
11
|
import { createHTTPWire } from '../../http/http-runner.js'
|
|
12
|
-
import { ChannelStore } from '../channel-store.js'
|
|
12
|
+
import type { ChannelStore } from '../channel-store.js'
|
|
13
13
|
import { handleHTTPError } from '../../../handle-error.js'
|
|
14
|
-
import {
|
|
15
|
-
|
|
14
|
+
import {
|
|
15
|
+
PikkuSessionService,
|
|
16
|
+
createMiddlewareSessionWireProps,
|
|
17
|
+
} from '../../../services/user-session-service.js'
|
|
18
|
+
import {
|
|
19
|
+
getSingletonServices,
|
|
20
|
+
getCreateWireServices,
|
|
21
|
+
pikkuState,
|
|
22
|
+
} from '../../../pikku-state.js'
|
|
16
23
|
import { PikkuFetchHTTPRequest } from '../../http/pikku-fetch-http-request.js'
|
|
17
|
-
import { PikkuHTTP } from '../../http/http.types.js'
|
|
24
|
+
import type { PikkuHTTP } from '../../http/http.types.js'
|
|
18
25
|
import { runChannelLifecycleWithMiddleware } from '../channel-common.js'
|
|
19
26
|
|
|
20
27
|
export interface RunServerlessChannelParams<ChannelData>
|
|
@@ -59,13 +66,11 @@ const getVariablesForChannel = ({
|
|
|
59
66
|
}
|
|
60
67
|
|
|
61
68
|
export const runChannelConnect = async ({
|
|
62
|
-
singletonServices,
|
|
63
69
|
channelId,
|
|
64
70
|
channelObject,
|
|
65
71
|
request,
|
|
66
72
|
response,
|
|
67
73
|
route,
|
|
68
|
-
createWireServices,
|
|
69
74
|
channelStore,
|
|
70
75
|
channelHandlerFactory,
|
|
71
76
|
coerceDataFromSchema = true,
|
|
@@ -75,6 +80,8 @@ export const runChannelConnect = async ({
|
|
|
75
80
|
}: Pick<CoreChannel<unknown, any>, 'route'> &
|
|
76
81
|
RunChannelOptions &
|
|
77
82
|
RunServerlessChannelParams<unknown>) => {
|
|
83
|
+
const singletonServices = getSingletonServices()
|
|
84
|
+
const createWireServices = getCreateWireServices()
|
|
78
85
|
let wireServices: WireServices | undefined
|
|
79
86
|
|
|
80
87
|
let http: PikkuHTTP | undefined
|
|
@@ -86,10 +93,8 @@ export const runChannelConnect = async ({
|
|
|
86
93
|
|
|
87
94
|
const { channelConfig, openingData, meta } = await openChannel({
|
|
88
95
|
channelId,
|
|
89
|
-
createWireServices,
|
|
90
96
|
request,
|
|
91
97
|
route,
|
|
92
|
-
singletonServices,
|
|
93
98
|
coerceDataFromSchema,
|
|
94
99
|
userSession,
|
|
95
100
|
})
|
|
@@ -107,7 +112,10 @@ export const runChannelConnect = async ({
|
|
|
107
112
|
channelName: channelConfig.name,
|
|
108
113
|
})
|
|
109
114
|
|
|
110
|
-
const wire: PikkuWire = {
|
|
115
|
+
const wire: PikkuWire = {
|
|
116
|
+
channel,
|
|
117
|
+
...createMiddlewareSessionWireProps(userSession),
|
|
118
|
+
}
|
|
111
119
|
|
|
112
120
|
if (createWireServices) {
|
|
113
121
|
wireServices = await createWireServices(singletonServices, wire)
|
|
@@ -127,6 +135,7 @@ export const runChannelConnect = async ({
|
|
|
127
135
|
services,
|
|
128
136
|
channel,
|
|
129
137
|
data: openingData,
|
|
138
|
+
channelMiddlewareMeta: meta.channelMiddleware,
|
|
130
139
|
})
|
|
131
140
|
}
|
|
132
141
|
http?.response?.status(101)
|
|
@@ -148,9 +157,12 @@ export const runChannelConnect = async ({
|
|
|
148
157
|
}
|
|
149
158
|
|
|
150
159
|
export const runChannelDisconnect = async ({
|
|
151
|
-
|
|
152
|
-
|
|
160
|
+
channelId,
|
|
161
|
+
channelStore,
|
|
162
|
+
channelHandlerFactory,
|
|
153
163
|
}: RunServerlessChannelParams<unknown>): Promise<void> => {
|
|
164
|
+
const singletonServices = getSingletonServices()
|
|
165
|
+
const createWireServices = getCreateWireServices()
|
|
154
166
|
let wireServices: WireServices | undefined
|
|
155
167
|
|
|
156
168
|
// Try to get channel from store. In serverless environments (especially with
|
|
@@ -159,31 +171,31 @@ export const runChannelDisconnect = async ({
|
|
|
159
171
|
// there's nothing to disconnect, so we can return early.
|
|
160
172
|
let channelData
|
|
161
173
|
try {
|
|
162
|
-
channelData = await
|
|
163
|
-
|
|
164
|
-
)
|
|
165
|
-
} catch (error) {
|
|
174
|
+
channelData = await channelStore.getChannelAndSession(channelId)
|
|
175
|
+
} catch {
|
|
166
176
|
singletonServices.logger.info(
|
|
167
|
-
`Channel ${
|
|
177
|
+
`Channel ${channelId} not found during disconnect - already cleaned up`
|
|
168
178
|
)
|
|
169
179
|
return
|
|
170
180
|
}
|
|
171
181
|
|
|
172
182
|
const { openingData, channelName, session } = channelData
|
|
173
183
|
const { channel, channelConfig, meta } = getVariablesForChannel({
|
|
174
|
-
|
|
184
|
+
channelId,
|
|
185
|
+
channelHandlerFactory,
|
|
175
186
|
openingData,
|
|
176
187
|
channelName,
|
|
177
188
|
})
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
params.channelId
|
|
181
|
-
)
|
|
189
|
+
|
|
190
|
+
const userSession = new PikkuSessionService(channelStore, channelId)
|
|
182
191
|
userSession.setInitial(session)
|
|
183
|
-
const wire: PikkuWire = {
|
|
192
|
+
const wire: PikkuWire = {
|
|
193
|
+
channel,
|
|
194
|
+
...createMiddlewareSessionWireProps(userSession),
|
|
195
|
+
}
|
|
184
196
|
|
|
185
|
-
if (
|
|
186
|
-
wireServices = await
|
|
197
|
+
if (createWireServices) {
|
|
198
|
+
wireServices = await createWireServices(singletonServices, wire)
|
|
187
199
|
}
|
|
188
200
|
|
|
189
201
|
const services = {
|
|
@@ -200,6 +212,7 @@ export const runChannelDisconnect = async ({
|
|
|
200
212
|
lifecycleType: 'disconnect',
|
|
201
213
|
services,
|
|
202
214
|
channel,
|
|
215
|
+
channelMiddlewareMeta: meta.channelMiddleware,
|
|
203
216
|
})
|
|
204
217
|
} catch (e: any) {
|
|
205
218
|
singletonServices.logger.error(
|
|
@@ -207,34 +220,42 @@ export const runChannelDisconnect = async ({
|
|
|
207
220
|
)
|
|
208
221
|
}
|
|
209
222
|
}
|
|
210
|
-
await
|
|
223
|
+
await channelStore.removeChannels([channel.channelId])
|
|
211
224
|
if (wireServices) {
|
|
212
225
|
await closeWireServices(singletonServices.logger, wireServices)
|
|
213
226
|
}
|
|
214
227
|
}
|
|
215
228
|
|
|
216
229
|
export const runChannelMessage = async (
|
|
217
|
-
{
|
|
230
|
+
{
|
|
231
|
+
channelId,
|
|
232
|
+
channelStore,
|
|
233
|
+
channelHandlerFactory,
|
|
234
|
+
}: RunServerlessChannelParams<unknown>,
|
|
218
235
|
data: unknown
|
|
219
236
|
): Promise<unknown> => {
|
|
237
|
+
const singletonServices = getSingletonServices()
|
|
238
|
+
const createWireServices = getCreateWireServices()
|
|
220
239
|
let wireServices: WireServices | undefined
|
|
221
240
|
const { openingData, channelName, session } =
|
|
222
|
-
await
|
|
241
|
+
await channelStore.getChannelAndSession(channelId)
|
|
223
242
|
|
|
224
243
|
const { channel, channelHandler, channelConfig } = getVariablesForChannel({
|
|
225
|
-
|
|
244
|
+
channelId,
|
|
245
|
+
channelHandlerFactory,
|
|
226
246
|
openingData,
|
|
227
247
|
channelName,
|
|
228
248
|
})
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
params.channelId
|
|
232
|
-
)
|
|
249
|
+
|
|
250
|
+
const userSession = new PikkuSessionService(channelStore, channelId)
|
|
233
251
|
userSession.setInitial(session)
|
|
234
|
-
const wire: PikkuWire = {
|
|
252
|
+
const wire: PikkuWire = {
|
|
253
|
+
channel,
|
|
254
|
+
...createMiddlewareSessionWireProps(userSession),
|
|
255
|
+
}
|
|
235
256
|
|
|
236
|
-
if (
|
|
237
|
-
wireServices = await
|
|
257
|
+
if (createWireServices) {
|
|
258
|
+
wireServices = await createWireServices(singletonServices, wire)
|
|
238
259
|
}
|
|
239
260
|
|
|
240
261
|
const services = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { pikkuState } from '../../../pikku-state.js'
|
|
2
|
-
import { CorePikkuCLIRender,
|
|
2
|
+
import type { CorePikkuCLIRender, CLIMeta } from '../cli.types.js'
|
|
3
3
|
import { generateCommandHelp, parseCLIArguments } from '../command-parser.js'
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { executeCLIViaChannel } from './cli-channel-runner.js'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { test, describe, beforeEach, afterEach } from 'node:test'
|
|
2
2
|
import * as assert from 'assert'
|
|
3
3
|
import { NotFoundError } from '../../errors/errors.js'
|
|
4
|
-
import { CorePikkuMiddleware } from '../../types/core.types.js'
|
|
4
|
+
import type { CorePikkuMiddleware } from '../../types/core.types.js'
|
|
5
5
|
import { wireCLI, runCLICommand, pikkuCLIRender } from './cli-runner.js'
|
|
6
6
|
import { pikkuState, resetPikkuState } from '../../pikku-state.js'
|
|
7
7
|
import { addFunction } from '../../function/function-runner.js'
|
|
@@ -91,7 +91,7 @@ describe('CLI Runner', () => {
|
|
|
91
91
|
commands: {
|
|
92
92
|
greet: {
|
|
93
93
|
command: 'greet <name>',
|
|
94
|
-
|
|
94
|
+
pikkuFuncId: 'greetFunc',
|
|
95
95
|
positionals: [{ name: 'name', required: true }],
|
|
96
96
|
options: {},
|
|
97
97
|
},
|
|
@@ -112,7 +112,7 @@ describe('CLI Runner', () => {
|
|
|
112
112
|
|
|
113
113
|
pikkuState(null, 'function', 'meta', {
|
|
114
114
|
greetFunc: {
|
|
115
|
-
|
|
115
|
+
pikkuFuncId: 'greetFunc',
|
|
116
116
|
inputSchemaName: null,
|
|
117
117
|
outputSchemaName: null,
|
|
118
118
|
},
|
|
@@ -155,7 +155,7 @@ describe('CLI Runner', () => {
|
|
|
155
155
|
commands: {
|
|
156
156
|
test: {
|
|
157
157
|
command: 'test',
|
|
158
|
-
|
|
158
|
+
pikkuFuncId: 'testFunc',
|
|
159
159
|
positionals: [],
|
|
160
160
|
options: {},
|
|
161
161
|
},
|
|
@@ -176,7 +176,7 @@ describe('CLI Runner', () => {
|
|
|
176
176
|
|
|
177
177
|
pikkuState(null, 'function', 'meta', {
|
|
178
178
|
testFunc: {
|
|
179
|
-
|
|
179
|
+
pikkuFuncId: 'testFunc',
|
|
180
180
|
inputSchemaName: null,
|
|
181
181
|
outputSchemaName: null,
|
|
182
182
|
},
|
|
@@ -215,7 +215,7 @@ describe('CLI Runner', () => {
|
|
|
215
215
|
commands: {
|
|
216
216
|
greet: {
|
|
217
217
|
command: 'greet <name>',
|
|
218
|
-
|
|
218
|
+
pikkuFuncId: 'greetFunc',
|
|
219
219
|
positionals: [{ name: 'name', required: true }],
|
|
220
220
|
options: {},
|
|
221
221
|
},
|
|
@@ -236,7 +236,7 @@ describe('CLI Runner', () => {
|
|
|
236
236
|
|
|
237
237
|
pikkuState(null, 'function', 'meta', {
|
|
238
238
|
greetFunc: {
|
|
239
|
-
|
|
239
|
+
pikkuFuncId: 'greetFunc',
|
|
240
240
|
inputSchemaName: null,
|
|
241
241
|
outputSchemaName: null,
|
|
242
242
|
},
|
|
@@ -267,7 +267,7 @@ describe('CLI Runner', () => {
|
|
|
267
267
|
commands: {
|
|
268
268
|
secure: {
|
|
269
269
|
command: 'secure',
|
|
270
|
-
|
|
270
|
+
pikkuFuncId: 'secureFunc',
|
|
271
271
|
positionals: [],
|
|
272
272
|
options: {},
|
|
273
273
|
},
|
|
@@ -280,7 +280,7 @@ describe('CLI Runner', () => {
|
|
|
280
280
|
|
|
281
281
|
pikkuState(null, 'function', 'meta', {
|
|
282
282
|
secureFunc: {
|
|
283
|
-
|
|
283
|
+
pikkuFuncId: 'secureFunc',
|
|
284
284
|
inputSchemaName: null,
|
|
285
285
|
outputSchemaName: null,
|
|
286
286
|
},
|
|
@@ -313,7 +313,7 @@ describe('CLI Runner', () => {
|
|
|
313
313
|
commands: {
|
|
314
314
|
greet: {
|
|
315
315
|
command: 'greet <name>',
|
|
316
|
-
|
|
316
|
+
pikkuFuncId: 'greetFunc',
|
|
317
317
|
positionals: [{ name: 'name', required: true }],
|
|
318
318
|
options: {
|
|
319
319
|
loud: {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { NotFoundError } from '../../errors/errors.js'
|
|
1
|
+
import { NotFoundError, PikkuMissingMetaError } from '../../errors/errors.js'
|
|
2
2
|
import { addFunction, runPikkuFunc } from '../../function/function-runner.js'
|
|
3
3
|
import { pikkuState } from '../../pikku-state.js'
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import type {
|
|
5
|
+
CorePikkuMiddleware,
|
|
6
|
+
CoreUserSession,
|
|
7
|
+
} from '../../types/core.types.js'
|
|
8
|
+
import type {
|
|
6
9
|
CoreCLI,
|
|
7
10
|
CLICommandMeta,
|
|
8
11
|
CLIOption,
|
|
@@ -19,8 +22,11 @@ import type {
|
|
|
19
22
|
CreateConfig,
|
|
20
23
|
CreateSingletonServices,
|
|
21
24
|
} from '../../types/core.types.js'
|
|
22
|
-
import { PikkuChannel } from '../channel/channel.types.js'
|
|
23
|
-
import {
|
|
25
|
+
import type { PikkuChannel } from '../channel/channel.types.js'
|
|
26
|
+
import {
|
|
27
|
+
PikkuSessionService,
|
|
28
|
+
createMiddlewareSessionWireProps,
|
|
29
|
+
} from '../../services/user-session-service.js'
|
|
24
30
|
import { LocalVariablesService } from '../../services/local-variables.js'
|
|
25
31
|
import { generateCommandHelp, parseCLIArguments } from './command-parser.js'
|
|
26
32
|
|
|
@@ -60,8 +66,8 @@ export const wireCLI = <
|
|
|
60
66
|
const cliMeta = pikkuState(null, 'cli', 'meta') || {}
|
|
61
67
|
|
|
62
68
|
if (!cliMeta.programs?.[cli.program]) {
|
|
63
|
-
throw new
|
|
64
|
-
`CLI metadata not found for program '${cli.program}'
|
|
69
|
+
throw new PikkuMissingMetaError(
|
|
70
|
+
`CLI metadata not found for program '${cli.program}'`
|
|
65
71
|
)
|
|
66
72
|
}
|
|
67
73
|
|
|
@@ -141,7 +147,7 @@ function registerCLICommands(
|
|
|
141
147
|
for (let i = 1; i < fullPath.length; i++) {
|
|
142
148
|
currentMeta = currentMeta?.subcommands?.[fullPath[i]]
|
|
143
149
|
}
|
|
144
|
-
const funcName = currentMeta?.
|
|
150
|
+
const funcName = currentMeta?.pikkuFuncId
|
|
145
151
|
|
|
146
152
|
// Skip if no function name (could be a command group)
|
|
147
153
|
if (!funcName) {
|
|
@@ -272,7 +278,7 @@ export async function runCLICommand({
|
|
|
272
278
|
currentCommand = currentCommand.subcommands[commandPath[i]]
|
|
273
279
|
}
|
|
274
280
|
|
|
275
|
-
const funcName = currentCommand.
|
|
281
|
+
const funcName = currentCommand.pikkuFuncId
|
|
276
282
|
|
|
277
283
|
// Get program-specific data
|
|
278
284
|
const programs: Record<string, CLIProgramState> =
|
|
@@ -332,7 +338,7 @@ export async function runCLICommand({
|
|
|
332
338
|
data: pluckedData,
|
|
333
339
|
channel,
|
|
334
340
|
},
|
|
335
|
-
|
|
341
|
+
...createMiddlewareSessionWireProps(userSession),
|
|
336
342
|
}
|
|
337
343
|
|
|
338
344
|
try {
|
|
@@ -347,12 +353,18 @@ export async function runCLICommand({
|
|
|
347
353
|
wirePermissions: undefined,
|
|
348
354
|
tags: programData?.tags,
|
|
349
355
|
wire,
|
|
356
|
+
sessionService: userSession,
|
|
350
357
|
})
|
|
351
358
|
|
|
352
359
|
// Apply renderer one final time with the final output (if renderer exists)
|
|
353
|
-
if (
|
|
360
|
+
// Skip if result is undefined (void functions handle their own output)
|
|
361
|
+
if (renderer && result !== undefined) {
|
|
354
362
|
await Promise.resolve(
|
|
355
|
-
renderer(
|
|
363
|
+
renderer(
|
|
364
|
+
singletonServices,
|
|
365
|
+
result,
|
|
366
|
+
userSession.get() as CoreUserSession | undefined
|
|
367
|
+
)
|
|
356
368
|
)
|
|
357
369
|
}
|
|
358
370
|
|
|
@@ -395,7 +407,7 @@ export async function executeCLI({
|
|
|
395
407
|
}: {
|
|
396
408
|
programName: string
|
|
397
409
|
args?: string[]
|
|
398
|
-
createConfig
|
|
410
|
+
createConfig?: CreateConfig<any, any>
|
|
399
411
|
createSingletonServices: CreateSingletonServices<any, any>
|
|
400
412
|
createWireServices?: CreateWireServices<any, any, any>
|
|
401
413
|
}): Promise<void> {
|
|
@@ -470,7 +482,9 @@ export async function executeCLI({
|
|
|
470
482
|
const data = { ...parsed.positionals, ...parsed.options }
|
|
471
483
|
|
|
472
484
|
// Create config (pass data in case it needs to use any parsed options)
|
|
473
|
-
const config =
|
|
485
|
+
const config = createConfig
|
|
486
|
+
? await createConfig(new LocalVariablesService(), data)
|
|
487
|
+
: ({} as any)
|
|
474
488
|
|
|
475
489
|
// Create services with config
|
|
476
490
|
const singletonServices = await createSingletonServices(config)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
CorePikkuMiddleware,
|
|
3
3
|
CoreSingletonServices,
|
|
4
4
|
CoreUserSession,
|
|
@@ -6,13 +6,13 @@ import {
|
|
|
6
6
|
MiddlewareMetadata,
|
|
7
7
|
PermissionMetadata,
|
|
8
8
|
} from '../../types/core.types.js'
|
|
9
|
-
import {
|
|
9
|
+
import type {
|
|
10
10
|
CorePikkuFunctionConfig,
|
|
11
11
|
CorePikkuPermission,
|
|
12
12
|
CorePikkuFunction,
|
|
13
13
|
CorePikkuFunctionSessionless,
|
|
14
14
|
} from '../../function/functions.types.js'
|
|
15
|
-
import { PikkuChannel } from '../channel/channel.types.js'
|
|
15
|
+
import type { PikkuChannel } from '../channel/channel.types.js'
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* CLI option definition
|
|
@@ -69,7 +69,7 @@ export interface CLIProgramState {
|
|
|
69
69
|
*/
|
|
70
70
|
export interface CLICommandMeta {
|
|
71
71
|
parameters?: string
|
|
72
|
-
|
|
72
|
+
pikkuFuncId: string
|
|
73
73
|
positionals: CLIPositional[]
|
|
74
74
|
options: Record<string, CLIOption>
|
|
75
75
|
renderName?: string
|
|
@@ -131,8 +131,8 @@ export type CorePikkuCLIRender<
|
|
|
131
131
|
export type ExtractFunctionInput<Func> =
|
|
132
132
|
Func extends CorePikkuFunctionConfig<infer FuncType, any, any>
|
|
133
133
|
? FuncType extends
|
|
134
|
-
| CorePikkuFunction<infer Input, any, any, any>
|
|
135
|
-
| CorePikkuFunctionSessionless<infer Input, any, any, any>
|
|
134
|
+
| CorePikkuFunction<infer Input, any, any, any, any>
|
|
135
|
+
| CorePikkuFunctionSessionless<infer Input, any, any, any, any>
|
|
136
136
|
? Input
|
|
137
137
|
: never
|
|
138
138
|
: never
|
|
@@ -198,8 +198,8 @@ export type ValidateParameters<Params extends string, Input> =
|
|
|
198
198
|
export type ExtractFunctionOutput<Func> =
|
|
199
199
|
Func extends CorePikkuFunctionConfig<infer FuncType, any, any>
|
|
200
200
|
? FuncType extends
|
|
201
|
-
| CorePikkuFunction<any, infer Output, any, any>
|
|
202
|
-
| CorePikkuFunctionSessionless<any, infer Output, any, any>
|
|
201
|
+
| CorePikkuFunction<any, infer Output, any, any, any>
|
|
202
|
+
| CorePikkuFunctionSessionless<any, infer Output, any, any, any>
|
|
203
203
|
? Output
|
|
204
204
|
: never
|
|
205
205
|
: never
|
|
@@ -249,8 +249,8 @@ export interface CoreCLICommand<
|
|
|
249
249
|
In,
|
|
250
250
|
Out,
|
|
251
251
|
PikkuFunctionConfig extends CorePikkuFunctionConfig<
|
|
252
|
-
| CorePikkuFunction<In, Out, any, any>
|
|
253
|
-
| CorePikkuFunctionSessionless<In, Out, any, any>
|
|
252
|
+
| CorePikkuFunction<In, Out, any, any, any>
|
|
253
|
+
| CorePikkuFunctionSessionless<In, Out, any, any, any>
|
|
254
254
|
>,
|
|
255
255
|
PikkuPermission extends CorePikkuPermission<any, any, any>,
|
|
256
256
|
PikkuMiddleware extends CorePikkuMiddleware,
|
|
@@ -282,8 +282,8 @@ export type CLICommandShorthand<
|
|
|
282
282
|
In,
|
|
283
283
|
Out,
|
|
284
284
|
PikkuFunctionConfig extends CorePikkuFunctionConfig<
|
|
285
|
-
| CorePikkuFunction<In, Out, any, any>
|
|
286
|
-
| CorePikkuFunctionSessionless<In, Out, any, any>
|
|
285
|
+
| CorePikkuFunction<In, Out, any, any, any>
|
|
286
|
+
| CorePikkuFunctionSessionless<In, Out, any, any, any>
|
|
287
287
|
>,
|
|
288
288
|
> = PikkuFunctionConfig
|
|
289
289
|
|
|
@@ -294,8 +294,8 @@ export type CLICommandDefinition<
|
|
|
294
294
|
In,
|
|
295
295
|
Out,
|
|
296
296
|
PikkuFunctionConfig extends CorePikkuFunctionConfig<
|
|
297
|
-
| CorePikkuFunction<In, Out, any, any>
|
|
298
|
-
| CorePikkuFunctionSessionless<In, Out, any, any>
|
|
297
|
+
| CorePikkuFunction<In, Out, any, any, any>
|
|
298
|
+
| CorePikkuFunctionSessionless<In, Out, any, any, any>
|
|
299
299
|
>,
|
|
300
300
|
PikkuPermission extends CorePikkuPermission<any, any, any>,
|
|
301
301
|
PikkuMiddleware extends CorePikkuMiddleware,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { test, describe } from 'node:test'
|
|
2
2
|
import * as assert from 'assert'
|
|
3
3
|
import { parseCLIArguments, generateCommandHelp } from './command-parser.js'
|
|
4
|
-
import { CLIMeta } from './cli.types.js'
|
|
4
|
+
import type { CLIMeta } from './cli.types.js'
|
|
5
5
|
|
|
6
6
|
const testMeta: CLIMeta = {
|
|
7
7
|
programs: {
|
|
@@ -17,7 +17,7 @@ const testMeta: CLIMeta = {
|
|
|
17
17
|
commands: {
|
|
18
18
|
greet: {
|
|
19
19
|
parameters: '<name>',
|
|
20
|
-
|
|
20
|
+
pikkuFuncId: 'greetFunc',
|
|
21
21
|
positionals: [{ name: 'name', required: true }],
|
|
22
22
|
options: {
|
|
23
23
|
loud: {
|
|
@@ -28,13 +28,13 @@ const testMeta: CLIMeta = {
|
|
|
28
28
|
},
|
|
29
29
|
},
|
|
30
30
|
user: {
|
|
31
|
-
|
|
31
|
+
pikkuFuncId: '',
|
|
32
32
|
positionals: [],
|
|
33
33
|
options: {},
|
|
34
34
|
subcommands: {
|
|
35
35
|
create: {
|
|
36
36
|
parameters: '<name> <email>',
|
|
37
|
-
|
|
37
|
+
pikkuFuncId: 'createUserFunc',
|
|
38
38
|
positionals: [
|
|
39
39
|
{ name: 'name', required: true },
|
|
40
40
|
{ name: 'email', required: true },
|
|
@@ -50,7 +50,7 @@ const testMeta: CLIMeta = {
|
|
|
50
50
|
},
|
|
51
51
|
delete: {
|
|
52
52
|
parameters: '<id>',
|
|
53
|
-
|
|
53
|
+
pikkuFuncId: 'deleteUserFunc',
|
|
54
54
|
positionals: [{ name: 'id', required: true }],
|
|
55
55
|
options: {
|
|
56
56
|
force: {
|
|
@@ -64,13 +64,13 @@ const testMeta: CLIMeta = {
|
|
|
64
64
|
},
|
|
65
65
|
files: {
|
|
66
66
|
parameters: '<paths...>',
|
|
67
|
-
|
|
67
|
+
pikkuFuncId: 'filesFunc',
|
|
68
68
|
positionals: [{ name: 'paths', required: true, variadic: true }],
|
|
69
69
|
options: {},
|
|
70
70
|
},
|
|
71
71
|
optional: {
|
|
72
72
|
parameters: '[name]',
|
|
73
|
-
|
|
73
|
+
pikkuFuncId: 'optionalFunc',
|
|
74
74
|
positionals: [{ name: 'name', required: false }],
|
|
75
75
|
options: {},
|
|
76
76
|
},
|
|
@@ -299,7 +299,7 @@ describe('Command Parser', () => {
|
|
|
299
299
|
options: {},
|
|
300
300
|
commands: {
|
|
301
301
|
test: {
|
|
302
|
-
|
|
302
|
+
pikkuFuncId: 'testFunc',
|
|
303
303
|
positionals: [],
|
|
304
304
|
options: {
|
|
305
305
|
port: {
|
|
@@ -380,7 +380,7 @@ describe('Command Parser', () => {
|
|
|
380
380
|
commands: {
|
|
381
381
|
greet: {
|
|
382
382
|
parameters: '<name>',
|
|
383
|
-
|
|
383
|
+
pikkuFuncId: 'greetFunc',
|
|
384
384
|
description: 'Greet a user',
|
|
385
385
|
positionals: [{ name: 'name', required: true }],
|
|
386
386
|
options: {},
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { CoreCLICommandConfig } from './cli.types.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Type-safe helper for defining CLI commands that can be composed.
|
|
5
|
+
* Returns the commands record as-is (identity function) for use with `wireCLI`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* export const chatCommands = defineCLICommands({
|
|
10
|
+
* chat: pikkuCLICommand({ func: chatFunc }),
|
|
11
|
+
* 'chat:history': pikkuCLICommand({ func: historyFunc }),
|
|
12
|
+
* })
|
|
13
|
+
*
|
|
14
|
+
* wireCLI({
|
|
15
|
+
* program: 'my-app',
|
|
16
|
+
* commands: { ...chatCommands, other: pikkuCLICommand({ func: otherFunc }) }
|
|
17
|
+
* })
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export function defineCLICommands<
|
|
21
|
+
T extends Record<string, CoreCLICommandConfig<any, any, any, any>>,
|
|
22
|
+
>(commands: T): T {
|
|
23
|
+
return commands
|
|
24
|
+
}
|
package/src/wirings/cli/index.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
export * from './cli.types.js'
|
|
2
|
-
export * from './cli-runner.js'
|
|
3
|
-
export * from './command-parser.js'
|
|
4
|
-
|
|
5
1
|
export {
|
|
6
2
|
wireCLI,
|
|
7
3
|
runCLICommand,
|
|
@@ -11,3 +7,13 @@ export {
|
|
|
11
7
|
} from './cli-runner.js'
|
|
12
8
|
|
|
13
9
|
export { parseCLIArguments, generateCommandHelp } from './command-parser.js'
|
|
10
|
+
|
|
11
|
+
export { defineCLICommands } from './define-cli-commands.js'
|
|
12
|
+
export type {
|
|
13
|
+
CLIMeta,
|
|
14
|
+
CLICommandMeta,
|
|
15
|
+
CLIProgramMeta,
|
|
16
|
+
CoreCLI,
|
|
17
|
+
CoreCLICommandConfig,
|
|
18
|
+
CorePikkuCLIRender,
|
|
19
|
+
} from './cli.types.js'
|