@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,5 +1,11 @@
|
|
|
1
1
|
import type { CoreServices, CoreSingletonServices, CoreUserSession, CorePikkuMiddleware, PikkuWire, PickRequired } from '../types/core.types.js';
|
|
2
|
-
import {
|
|
2
|
+
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
3
|
+
import type { CoreNodeConfig } from '../wirings/node/node.types.js';
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated Use StandardSchemaV1 from @standard-schema/spec instead.
|
|
6
|
+
* This alias exists only for backward compatibility with generated code.
|
|
7
|
+
*/
|
|
8
|
+
export type ZodLike<T = any> = StandardSchemaV1<T, T>;
|
|
3
9
|
/**
|
|
4
10
|
* Represents a core API function that performs an operation using core services and a user session.
|
|
5
11
|
*
|
|
@@ -8,7 +14,7 @@ import { Session } from 'inspector';
|
|
|
8
14
|
* @template Services - The services type, defaults to `CoreServices`.
|
|
9
15
|
* @template Wire - The wire type, defaults to `PikkuWire<In, Out>`.
|
|
10
16
|
*/
|
|
11
|
-
export type CorePikkuFunction<In, Out, Services extends CoreSingletonServices = CoreServices, Wire extends PikkuWire<In, Out> = PikkuWire<In, Out, true, Session>> = (services: Services, data: In, wire: Wire) => Wire['channel'] extends null ? Promise<Out> : Promise<Out> | Promise<void>;
|
|
17
|
+
export type CorePikkuFunction<In, Out, Services extends CoreSingletonServices = CoreServices, Session extends CoreUserSession = CoreUserSession, Wire extends PikkuWire<In, Out> = PikkuWire<In, Out, true, Session>> = (services: Services, data: In, wire: Wire) => Wire['channel'] extends null ? Promise<Out> : Promise<Out> | Promise<void>;
|
|
12
18
|
/**
|
|
13
19
|
* Represents a core API function that can be used without a session.
|
|
14
20
|
*
|
|
@@ -17,7 +23,7 @@ export type CorePikkuFunction<In, Out, Services extends CoreSingletonServices =
|
|
|
17
23
|
* @template Services - The services type, defaults to `CoreServices`.
|
|
18
24
|
* @template Wire - The wire type, defaults to `PikkuWire<In, Out>`.
|
|
19
25
|
*/
|
|
20
|
-
export type CorePikkuFunctionSessionless<In, Out, Services extends CoreSingletonServices = CoreServices, Wire extends PikkuWire<In, Out, false,
|
|
26
|
+
export type CorePikkuFunctionSessionless<In, Out, Services extends CoreSingletonServices = CoreServices, Session extends CoreUserSession = CoreUserSession, Wire extends PikkuWire<In, Out, false, Session, any, any, any> = PikkuWire<In, Out, false, Session, any, any, any>> = (services: Services, data: In, wire: Wire) => Wire['channel'] extends null ? Promise<Out> : Promise<Out> | Promise<void>;
|
|
21
27
|
/**
|
|
22
28
|
* Represents a function that checks permissions for a given operation.
|
|
23
29
|
*
|
|
@@ -36,8 +42,8 @@ export type CorePikkuPermission<In = any, Services extends CoreSingletonServices
|
|
|
36
42
|
export type CorePikkuPermissionConfig<In = any, Services extends CoreSingletonServices = CoreServices, Wire extends PikkuWire<In, never, false, CoreUserSession> = PikkuWire<In, never, false, CoreUserSession>> = {
|
|
37
43
|
/** The permission function */
|
|
38
44
|
func: CorePikkuPermission<In, Services, Wire>;
|
|
39
|
-
/** Optional human-readable
|
|
40
|
-
|
|
45
|
+
/** Optional human-readable name for the permission */
|
|
46
|
+
name?: string;
|
|
41
47
|
/** Optional description of what the permission checks */
|
|
42
48
|
description?: string;
|
|
43
49
|
};
|
|
@@ -49,18 +55,18 @@ export type CorePikkuPermissionConfig<In = any, Services extends CoreSingletonSe
|
|
|
49
55
|
* ```typescript
|
|
50
56
|
* // Direct function syntax
|
|
51
57
|
* export const adminPermission = pikkuPermission(
|
|
52
|
-
* async ({ logger }, _data, {
|
|
53
|
-
* const currentSession = await
|
|
58
|
+
* async ({ logger }, _data, { getSession }) => {
|
|
59
|
+
* const currentSession = await getSession()
|
|
54
60
|
* return currentSession?.role === 'admin'
|
|
55
61
|
* }
|
|
56
62
|
* )
|
|
57
63
|
*
|
|
58
64
|
* // Configuration object syntax with metadata
|
|
59
65
|
* export const adminPermission = pikkuPermission({
|
|
60
|
-
*
|
|
66
|
+
* name: 'Admin Permission',
|
|
61
67
|
* description: 'Checks if user has admin role',
|
|
62
|
-
* func: async ({ logger }, _data, {
|
|
63
|
-
* const currentSession = await
|
|
68
|
+
* func: async ({ logger }, _data, { getSession }) => {
|
|
69
|
+
* const currentSession = await getSession()
|
|
64
70
|
* return currentSession?.role === 'admin'
|
|
65
71
|
* }
|
|
66
72
|
* })
|
|
@@ -85,8 +91,8 @@ export type CorePikkuPermissionFactory<In = any, Services extends CoreSingletonS
|
|
|
85
91
|
* export const requireRole = pikkuPermissionFactory<{ role: string }>(({
|
|
86
92
|
* role
|
|
87
93
|
* }) => {
|
|
88
|
-
* return pikkuPermission(async ({ logger }, data, {
|
|
89
|
-
* const currentSession = await
|
|
94
|
+
* return pikkuPermission(async ({ logger }, data, { getSession }) => {
|
|
95
|
+
* const currentSession = await getSession()
|
|
90
96
|
* if (!currentSession || currentSession.role !== role) {
|
|
91
97
|
* logger.warn(`Permission denied: required role '${role}'`)
|
|
92
98
|
* return false
|
|
@@ -97,93 +103,32 @@ export type CorePikkuPermissionFactory<In = any, Services extends CoreSingletonS
|
|
|
97
103
|
* ```
|
|
98
104
|
*/
|
|
99
105
|
export declare const pikkuPermissionFactory: <In = any>(factory: CorePikkuPermissionFactory<In>) => CorePikkuPermissionFactory<In>;
|
|
100
|
-
export type
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
export type ZodLike<T = any> = {
|
|
106
|
-
_input: T;
|
|
107
|
-
_output: T;
|
|
106
|
+
export type CorePikkuAuth<Services extends CoreSingletonServices = CoreServices, Session extends CoreUserSession = CoreUserSession> = (services: Services, session: Session) => Promise<boolean> | boolean;
|
|
107
|
+
export type CorePikkuAuthConfig<Services extends CoreSingletonServices = CoreServices, Session extends CoreUserSession = CoreUserSession> = {
|
|
108
|
+
func: CorePikkuAuth<Services, Session>;
|
|
109
|
+
name?: string;
|
|
110
|
+
description?: string;
|
|
108
111
|
};
|
|
109
|
-
export
|
|
112
|
+
export declare const pikkuAuth: <Services extends CoreSingletonServices = CoreServices, Session extends CoreUserSession = CoreUserSession>(auth: CorePikkuAuth<Services, Session> | CorePikkuAuthConfig<Services, Session>) => CorePikkuPermission<any, Services, any>;
|
|
113
|
+
export type CorePermissionGroup<PikkuPermission = CorePikkuPermission<any>> = Record<string, PikkuPermission | PikkuPermission[]> | undefined;
|
|
114
|
+
export type CorePikkuFunctionConfig<PikkuFunction extends CorePikkuFunction<any, any, any, any, any> | CorePikkuFunctionSessionless<any, any, any, any, any>, PikkuPermission extends CorePikkuPermission<any, any, any> = CorePikkuPermission<any>, PikkuMiddleware extends CorePikkuMiddleware<any, any> = CorePikkuMiddleware<any, any>, InputSchema extends StandardSchemaV1 | undefined = undefined, OutputSchema extends StandardSchemaV1 | undefined = undefined> = {
|
|
110
115
|
/** Optional human-readable title for the function */
|
|
111
116
|
title?: string;
|
|
112
117
|
/** Optional description of what the function does */
|
|
113
118
|
description?: string;
|
|
114
119
|
override?: string;
|
|
120
|
+
version?: number;
|
|
115
121
|
tags?: string[];
|
|
116
122
|
expose?: boolean;
|
|
117
|
-
|
|
123
|
+
remote?: boolean;
|
|
124
|
+
mcp?: boolean;
|
|
125
|
+
readonly?: boolean;
|
|
126
|
+
requiresApproval?: boolean;
|
|
118
127
|
func: PikkuFunction;
|
|
119
128
|
auth?: boolean;
|
|
120
129
|
permissions?: CorePermissionGroup<PikkuPermission>;
|
|
121
130
|
middleware?: PikkuMiddleware[];
|
|
122
131
|
input?: InputSchema;
|
|
123
132
|
output?: OutputSchema;
|
|
133
|
+
node?: CoreNodeConfig;
|
|
124
134
|
};
|
|
125
|
-
/**
|
|
126
|
-
* A trigger function that sets up a subscription and returns a teardown function.
|
|
127
|
-
* The trigger is fired via wire.trigger.trigger(data).
|
|
128
|
-
*
|
|
129
|
-
* @template TConfig - Configuration type (hardcoded when wired)
|
|
130
|
-
* @template TOutput - Output type produced when trigger fires
|
|
131
|
-
* @template Services - Services available to the trigger
|
|
132
|
-
*/
|
|
133
|
-
export type CorePikkuTriggerFunction<TConfig = unknown, TOutput = unknown, Services extends CoreSingletonServices = CoreSingletonServices> = (services: Services, config: TConfig, wire: {
|
|
134
|
-
trigger: {
|
|
135
|
-
trigger: (data: TOutput) => void;
|
|
136
|
-
};
|
|
137
|
-
}) => Promise<() => void | Promise<void>>;
|
|
138
|
-
/**
|
|
139
|
-
* Configuration object for creating a trigger function with metadata
|
|
140
|
-
*/
|
|
141
|
-
export type CorePikkuTriggerFunctionConfig<TConfig = unknown, TOutput = unknown, Services extends CoreSingletonServices = CoreSingletonServices, ConfigSchema extends ZodLike | undefined = undefined, OutputSchema extends ZodLike | undefined = undefined> = {
|
|
142
|
-
/** Optional human-readable title for the trigger */
|
|
143
|
-
title?: string;
|
|
144
|
-
/** Optional description of what the trigger does */
|
|
145
|
-
description?: string;
|
|
146
|
-
/** Optional tags for categorization */
|
|
147
|
-
tags?: string[];
|
|
148
|
-
/** The trigger function */
|
|
149
|
-
func: CorePikkuTriggerFunction<TConfig, TOutput, Services>;
|
|
150
|
-
/** Optional Zod schema for config validation */
|
|
151
|
-
config?: ConfigSchema;
|
|
152
|
-
/** Optional Zod schema for output validation */
|
|
153
|
-
output?: OutputSchema;
|
|
154
|
-
};
|
|
155
|
-
/**
|
|
156
|
-
* Factory function for creating trigger functions
|
|
157
|
-
* Supports both direct function and configuration object syntax
|
|
158
|
-
*
|
|
159
|
-
* @example
|
|
160
|
-
* ```typescript
|
|
161
|
-
* // Direct function syntax
|
|
162
|
-
* export const redisSubscribeTrigger = pikkuTriggerFunc<
|
|
163
|
-
* { channel: string },
|
|
164
|
-
* { message: string }
|
|
165
|
-
* >(async ({ redis }, { channel }, { trigger }) => {
|
|
166
|
-
* const subscriber = redis.duplicate()
|
|
167
|
-
* await subscriber.subscribe(channel, (msg) => {
|
|
168
|
-
* trigger.trigger({ message: msg })
|
|
169
|
-
* })
|
|
170
|
-
* return () => subscriber.unsubscribe()
|
|
171
|
-
* })
|
|
172
|
-
*
|
|
173
|
-
* // Configuration object syntax with metadata
|
|
174
|
-
* export const redisSubscribeTrigger = pikkuTriggerFunc({
|
|
175
|
-
* title: 'Redis Subscribe Trigger',
|
|
176
|
-
* description: 'Listens to Redis pub/sub channel',
|
|
177
|
-
* config: z.object({ channel: z.string() }),
|
|
178
|
-
* output: z.object({ message: z.string() }),
|
|
179
|
-
* func: async ({ redis }, { channel }, { trigger }) => {
|
|
180
|
-
* const subscriber = redis.duplicate()
|
|
181
|
-
* await subscriber.subscribe(channel, (msg) => {
|
|
182
|
-
* trigger.trigger({ message: msg })
|
|
183
|
-
* })
|
|
184
|
-
* return () => subscriber.unsubscribe()
|
|
185
|
-
* }
|
|
186
|
-
* })
|
|
187
|
-
* ```
|
|
188
|
-
*/
|
|
189
|
-
export declare const pikkuTriggerFunc: <TConfig = unknown, TOutput = unknown, Services extends CoreSingletonServices = CoreSingletonServices, ConfigSchema extends ZodLike | undefined = undefined, OutputSchema extends ZodLike | undefined = undefined>(triggerOrConfig: CorePikkuTriggerFunction<TConfig, TOutput, Services> | CorePikkuTriggerFunctionConfig<TConfig, TOutput, Services, ConfigSchema, OutputSchema>) => CorePikkuTriggerFunctionConfig<TConfig, TOutput, Services, ConfigSchema, OutputSchema>;
|
|
@@ -6,18 +6,18 @@
|
|
|
6
6
|
* ```typescript
|
|
7
7
|
* // Direct function syntax
|
|
8
8
|
* export const adminPermission = pikkuPermission(
|
|
9
|
-
* async ({ logger }, _data, {
|
|
10
|
-
* const currentSession = await
|
|
9
|
+
* async ({ logger }, _data, { getSession }) => {
|
|
10
|
+
* const currentSession = await getSession()
|
|
11
11
|
* return currentSession?.role === 'admin'
|
|
12
12
|
* }
|
|
13
13
|
* )
|
|
14
14
|
*
|
|
15
15
|
* // Configuration object syntax with metadata
|
|
16
16
|
* export const adminPermission = pikkuPermission({
|
|
17
|
-
*
|
|
17
|
+
* name: 'Admin Permission',
|
|
18
18
|
* description: 'Checks if user has admin role',
|
|
19
|
-
* func: async ({ logger }, _data, {
|
|
20
|
-
* const currentSession = await
|
|
19
|
+
* func: async ({ logger }, _data, { getSession }) => {
|
|
20
|
+
* const currentSession = await getSession()
|
|
21
21
|
* return currentSession?.role === 'admin'
|
|
22
22
|
* }
|
|
23
23
|
* })
|
|
@@ -35,8 +35,8 @@ export const pikkuPermission = (permission) => {
|
|
|
35
35
|
* export const requireRole = pikkuPermissionFactory<{ role: string }>(({
|
|
36
36
|
* role
|
|
37
37
|
* }) => {
|
|
38
|
-
* return pikkuPermission(async ({ logger }, data, {
|
|
39
|
-
* const currentSession = await
|
|
38
|
+
* return pikkuPermission(async ({ logger }, data, { getSession }) => {
|
|
39
|
+
* const currentSession = await getSession()
|
|
40
40
|
* if (!currentSession || currentSession.role !== role) {
|
|
41
41
|
* logger.warn(`Permission denied: required role '${role}'`)
|
|
42
42
|
* return false
|
|
@@ -49,43 +49,13 @@ export const pikkuPermission = (permission) => {
|
|
|
49
49
|
export const pikkuPermissionFactory = (factory) => {
|
|
50
50
|
return factory;
|
|
51
51
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
* { message: string }
|
|
62
|
-
* >(async ({ redis }, { channel }, { trigger }) => {
|
|
63
|
-
* const subscriber = redis.duplicate()
|
|
64
|
-
* await subscriber.subscribe(channel, (msg) => {
|
|
65
|
-
* trigger.trigger({ message: msg })
|
|
66
|
-
* })
|
|
67
|
-
* return () => subscriber.unsubscribe()
|
|
68
|
-
* })
|
|
69
|
-
*
|
|
70
|
-
* // Configuration object syntax with metadata
|
|
71
|
-
* export const redisSubscribeTrigger = pikkuTriggerFunc({
|
|
72
|
-
* title: 'Redis Subscribe Trigger',
|
|
73
|
-
* description: 'Listens to Redis pub/sub channel',
|
|
74
|
-
* config: z.object({ channel: z.string() }),
|
|
75
|
-
* output: z.object({ message: z.string() }),
|
|
76
|
-
* func: async ({ redis }, { channel }, { trigger }) => {
|
|
77
|
-
* const subscriber = redis.duplicate()
|
|
78
|
-
* await subscriber.subscribe(channel, (msg) => {
|
|
79
|
-
* trigger.trigger({ message: msg })
|
|
80
|
-
* })
|
|
81
|
-
* return () => subscriber.unsubscribe()
|
|
82
|
-
* }
|
|
83
|
-
* })
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
|
-
export const pikkuTriggerFunc = (triggerOrConfig) => {
|
|
87
|
-
if (typeof triggerOrConfig === 'function') {
|
|
88
|
-
return { func: triggerOrConfig };
|
|
89
|
-
}
|
|
90
|
-
return triggerOrConfig;
|
|
52
|
+
export const pikkuAuth = (auth) => {
|
|
53
|
+
const fn = typeof auth === 'function' ? auth : auth.func;
|
|
54
|
+
const wrapper = async (services, _data, wire) => {
|
|
55
|
+
const session = wire.session;
|
|
56
|
+
if (!session)
|
|
57
|
+
return false;
|
|
58
|
+
return fn(services, session);
|
|
59
|
+
};
|
|
60
|
+
return wrapper;
|
|
91
61
|
};
|
package/dist/function/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { addFunction, getAllFunctionNames } from './function-runner.js';
|
|
2
|
+
export type { CorePikkuFunction, CorePikkuFunctionSessionless, } from './functions.types.js';
|
package/dist/function/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from './functions.types.js';
|
|
1
|
+
export { addFunction, getAllFunctionNames } from './function-runner.js';
|
package/dist/handle-error.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Logger } from './services/logger.js';
|
|
2
|
-
import { PikkuHTTP } from './wirings/http/http.types.js';
|
|
1
|
+
import type { Logger } from './services/logger.js';
|
|
2
|
+
import type { PikkuHTTP } from './wirings/http/http.types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Handle errors that occur during route processing
|
|
5
5
|
*
|
package/dist/handle-error.js
CHANGED
|
@@ -31,29 +31,20 @@ export const handleHTTPError = (e, http, trackerId, logger, logWarningsForStatus
|
|
|
31
31
|
if (trackerId) {
|
|
32
32
|
logger.warn(`Warning id: ${trackerId}`);
|
|
33
33
|
}
|
|
34
|
-
logger.warn(e);
|
|
34
|
+
logger.warn(e instanceof Error ? e.message : e);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
else {
|
|
38
38
|
// Handle unexpected errors
|
|
39
|
-
logger.error(e);
|
|
39
|
+
logger.error(e instanceof Error ? e.message : e);
|
|
40
40
|
http?.response?.status(500);
|
|
41
41
|
if (trackerId) {
|
|
42
42
|
logger.warn(`Error id: ${trackerId}`);
|
|
43
43
|
http?.response?.json({ errorId: trackerId });
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
// Handle 404 errors specifically
|
|
47
|
-
if (e instanceof NotFoundError) {
|
|
48
|
-
// TODO
|
|
49
|
-
// http?.response?.end()
|
|
50
|
-
}
|
|
51
|
-
// Either bubble up or end the response
|
|
52
46
|
if (bubbleError) {
|
|
53
47
|
throw e;
|
|
54
48
|
}
|
|
55
|
-
|
|
56
|
-
// TODO
|
|
57
|
-
// http?.response?.end()
|
|
58
|
-
}
|
|
49
|
+
http?.response?.close?.();
|
|
59
50
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,32 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module @pikku/core
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
export
|
|
25
|
-
export
|
|
26
|
-
export
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
export {
|
|
4
|
+
export type { CommonWireMeta, CoreConfig, CorePikkuMiddleware, CorePikkuMiddlewareConfig, CorePikkuMiddlewareFactory, CorePikkuMiddlewareGroup, CoreServices, CoreSingletonServices, CoreUserSession, CreateConfig, FunctionMeta, FunctionRuntimeMeta, FunctionServicesMeta, FunctionWiresMeta, FunctionsMeta, FunctionsRuntimeMeta, JSONPrimitive, JSONValue, MakeRequired, MiddlewareMetadata, PermissionMetadata, PickOptional, PickRequired, PikkuAIMiddlewareHooks, PikkuWire, PikkuWiringTypes, RequireAtLeastOne, SerializedError, WireServices, } from './types/core.types.js';
|
|
5
|
+
export { pikkuAIMiddleware, pikkuChannelMiddleware, pikkuChannelMiddlewareFactory, pikkuMiddleware, pikkuMiddlewareFactory, } from './types/core.types.js';
|
|
6
|
+
export type { CorePikkuAuth, CorePikkuAuthConfig, CorePikkuFunction, CorePikkuFunctionConfig, CorePikkuPermission, CorePikkuPermissionConfig, CorePikkuPermissionFactory, CorePermissionGroup, ZodLike, } from './function/functions.types.js';
|
|
7
|
+
export { pikkuAuth, pikkuPermission, pikkuPermissionFactory, } from './function/functions.types.js';
|
|
8
|
+
export { addFunction, getAllFunctionNames } from './function/index.js';
|
|
9
|
+
export { PikkuRequest } from './pikku-request.js';
|
|
10
|
+
export { getRelativeTimeOffsetFromNow, parseDurationString, } from './time-utils.js';
|
|
11
|
+
export type { RelativeTimeInput } from './time-utils.js';
|
|
12
|
+
export { formatVersionedId, isVersionedId, parseVersionedId, } from './version.js';
|
|
13
|
+
export { runPikkuFunc } from './function/function-runner.js';
|
|
14
|
+
export { runCLICommand, pikkuCLIRender } from './wirings/cli/cli-runner.js';
|
|
15
|
+
export { fetch } from './wirings/http/http-runner.js';
|
|
16
|
+
export { runMCPTool, runMCPResource, runMCPPrompt, } from './wirings/mcp/mcp-runner.js';
|
|
17
|
+
export type { MCPToolResponse, MCPResourceResponse, MCPPromptResponse, } from './wirings/mcp/mcp.types.js';
|
|
18
|
+
export { runQueueJob } from './wirings/queue/queue-runner.js';
|
|
19
|
+
export { runScheduledTask } from './wirings/scheduler/scheduler-runner.js';
|
|
20
|
+
export { NotFoundError } from './errors/errors.js';
|
|
21
|
+
export type { EventHubService } from './wirings/channel/eventhub-service.js';
|
|
22
|
+
export type { QueueService } from './wirings/queue/queue.types.js';
|
|
23
|
+
export type { JWTService } from './services/jwt-service.js';
|
|
24
|
+
export type { HTTPMethod } from './wirings/http/http.types.js';
|
|
25
|
+
export type { GraphNodeConfig } from './wirings/workflow/graph/workflow-graph.types.js';
|
|
26
|
+
export { createGraph } from './wirings/workflow/graph/graph-node.js';
|
|
27
|
+
export { workflow as wireWorkflow } from './wirings/workflow/workflow-helpers.js';
|
|
28
|
+
export { wireAddon } from './wirings/rpc/wire-addon.js';
|
|
29
|
+
export type { WireAddonConfig } from './wirings/rpc/wire-addon.js';
|
|
30
30
|
export type { PikkuPackageState } from './types/state.types.js';
|
|
31
31
|
export { runMiddleware, addMiddleware } from './middleware-runner.js';
|
|
32
32
|
export { addPermission } from './permissions.js';
|
|
33
|
+
export { isSerializable, stopSingletonServices } from './utils.js';
|
|
34
|
+
export { getSingletonServices, getCreateWireServices } from './pikku-state.js';
|
|
35
|
+
export { type ScheduledTaskInfo, type ScheduledTaskSummary, } from './services/scheduler-service.js';
|
|
36
|
+
export { SchedulerService } from './services/scheduler-service.js';
|
package/dist/index.js
CHANGED
|
@@ -1,31 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export * from './wirings/rpc/index.js';
|
|
18
|
-
export * from './wirings/queue/index.js';
|
|
19
|
-
export * from './wirings/workflow/index.js';
|
|
20
|
-
export * from './wirings/workflow/graph/index.js';
|
|
21
|
-
export * from './wirings/mcp/index.js';
|
|
22
|
-
export * from './wirings/cli/index.js';
|
|
23
|
-
export * from './wirings/forge-node/index.js';
|
|
24
|
-
export * from './wirings/trigger/index.js';
|
|
25
|
-
export * from './errors/index.js';
|
|
26
|
-
export * from './middleware/index.js';
|
|
27
|
-
export * from './utils.js';
|
|
28
|
-
export * from './time-utils.js';
|
|
29
|
-
export { pikkuState, initializePikkuState, resetPikkuState, addPackageServiceFactories, } from './pikku-state.js';
|
|
1
|
+
export { pikkuAIMiddleware, pikkuChannelMiddleware, pikkuChannelMiddlewareFactory, pikkuMiddleware, pikkuMiddlewareFactory, } from './types/core.types.js';
|
|
2
|
+
export { pikkuAuth, pikkuPermission, pikkuPermissionFactory, } from './function/functions.types.js';
|
|
3
|
+
export { addFunction, getAllFunctionNames } from './function/index.js';
|
|
4
|
+
export { PikkuRequest } from './pikku-request.js';
|
|
5
|
+
export { getRelativeTimeOffsetFromNow, parseDurationString, } from './time-utils.js';
|
|
6
|
+
export { formatVersionedId, isVersionedId, parseVersionedId, } from './version.js';
|
|
7
|
+
export { runPikkuFunc } from './function/function-runner.js';
|
|
8
|
+
export { runCLICommand, pikkuCLIRender } from './wirings/cli/cli-runner.js';
|
|
9
|
+
export { fetch } from './wirings/http/http-runner.js';
|
|
10
|
+
export { runMCPTool, runMCPResource, runMCPPrompt, } from './wirings/mcp/mcp-runner.js';
|
|
11
|
+
export { runQueueJob } from './wirings/queue/queue-runner.js';
|
|
12
|
+
export { runScheduledTask } from './wirings/scheduler/scheduler-runner.js';
|
|
13
|
+
export { NotFoundError } from './errors/errors.js';
|
|
14
|
+
export { createGraph } from './wirings/workflow/graph/graph-node.js';
|
|
15
|
+
export { workflow as wireWorkflow } from './wirings/workflow/workflow-helpers.js';
|
|
16
|
+
export { wireAddon } from './wirings/rpc/wire-addon.js';
|
|
30
17
|
export { runMiddleware, addMiddleware } from './middleware-runner.js';
|
|
31
18
|
export { addPermission } from './permissions.js';
|
|
19
|
+
export { isSerializable, stopSingletonServices } from './utils.js';
|
|
20
|
+
export { getSingletonServices, getCreateWireServices } from './pikku-state.js';
|
|
21
|
+
export { SchedulerService } from './services/scheduler-service.js';
|
package/dist/internal.js
ADDED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
export declare const authAPIKey: import("../types/core.types.js").CorePikkuMiddlewareFactory<{
|
|
19
19
|
source: "header" | "query" | "all";
|
|
20
20
|
}, import("../types/core.types.js").CoreSingletonServices<{
|
|
21
|
-
logLevel?: import("../
|
|
21
|
+
logLevel?: import("../services/logger.js").LogLevel;
|
|
22
22
|
secrets?: {};
|
|
23
|
-
workflow?: import("../
|
|
23
|
+
workflow?: import("../wirings/workflow/workflow.types.js").WorkflowServiceConfig;
|
|
24
24
|
}>, import("../types/core.types.js").CoreUserSession>;
|
|
@@ -16,8 +16,8 @@ import { pikkuMiddleware, pikkuMiddlewareFactory } from '../types/core.types.js'
|
|
|
16
16
|
* ])
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
export const authAPIKey = pikkuMiddlewareFactory(({ source }) => pikkuMiddleware(async ({ jwt: jwtService }, { http, session
|
|
20
|
-
if (!http?.request || !
|
|
19
|
+
export const authAPIKey = pikkuMiddlewareFactory(({ source }) => pikkuMiddleware(async ({ jwt: jwtService }, { http, setSession, session }, next) => {
|
|
20
|
+
if (!http?.request || !setSession || session) {
|
|
21
21
|
return next();
|
|
22
22
|
}
|
|
23
23
|
let apiKey = null;
|
|
@@ -30,7 +30,7 @@ export const authAPIKey = pikkuMiddlewareFactory(({ source }) => pikkuMiddleware
|
|
|
30
30
|
if (apiKey && jwtService) {
|
|
31
31
|
const userSession = await jwtService.decode(apiKey);
|
|
32
32
|
if (userSession) {
|
|
33
|
-
|
|
33
|
+
setSession?.(userSession);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
return next();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CoreUserSession } from '../types/core.types.js';
|
|
1
|
+
import type { CoreUserSession } from '../types/core.types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Bearer token middleware that extracts and validates tokens from the Authorization header.
|
|
4
4
|
*
|
|
@@ -34,7 +34,7 @@ export declare const authBearer: import("../types/core.types.js").CorePikkuMiddl
|
|
|
34
34
|
userSession: CoreUserSession;
|
|
35
35
|
};
|
|
36
36
|
}, import("../types/core.types.js").CoreSingletonServices<{
|
|
37
|
-
logLevel?: import("../
|
|
37
|
+
logLevel?: import("../services/logger.js").LogLevel;
|
|
38
38
|
secrets?: {};
|
|
39
|
-
workflow?: import("../
|
|
39
|
+
workflow?: import("../wirings/workflow/workflow.types.js").WorkflowServiceConfig;
|
|
40
40
|
}>, CoreUserSession>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InvalidSessionError } from '../errors/errors.js';
|
|
2
|
-
import { pikkuMiddleware, pikkuMiddlewareFactory
|
|
2
|
+
import { pikkuMiddleware, pikkuMiddlewareFactory } from '../types/core.types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Bearer token middleware that extracts and validates tokens from the Authorization header.
|
|
5
5
|
*
|
|
@@ -29,9 +29,8 @@ import { pikkuMiddleware, pikkuMiddlewareFactory, } from '../types/core.types.js
|
|
|
29
29
|
* ])
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
|
-
export const authBearer = pikkuMiddlewareFactory(({ token } = {}) => pikkuMiddleware(async ({ jwt: jwtService }, { http, session }, next) => {
|
|
33
|
-
|
|
34
|
-
if (!http?.request || !session || session.get()) {
|
|
32
|
+
export const authBearer = pikkuMiddlewareFactory(({ token } = {}) => pikkuMiddleware(async ({ jwt: jwtService }, { http, setSession, session }, next) => {
|
|
33
|
+
if (!http?.request || !setSession || session) {
|
|
35
34
|
return next();
|
|
36
35
|
}
|
|
37
36
|
const authHeader = http.request.header('authorization') ||
|
|
@@ -42,16 +41,14 @@ export const authBearer = pikkuMiddlewareFactory(({ token } = {}) => pikkuMiddle
|
|
|
42
41
|
throw new InvalidSessionError();
|
|
43
42
|
}
|
|
44
43
|
let userSession = null;
|
|
45
|
-
// If static token provided, validate against it
|
|
46
44
|
if (token && bearerToken === token.value) {
|
|
47
45
|
userSession = token.userSession;
|
|
48
46
|
}
|
|
49
|
-
// Otherwise, default to JWT decoding
|
|
50
47
|
else if (jwtService && !token) {
|
|
51
48
|
userSession = await jwtService.decode(bearerToken);
|
|
52
49
|
}
|
|
53
50
|
if (userSession) {
|
|
54
|
-
|
|
51
|
+
setSession?.(userSession);
|
|
55
52
|
}
|
|
56
53
|
}
|
|
57
54
|
return next();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SerializeOptions } from 'cookie';
|
|
2
|
-
import { RelativeTimeInput } from '../time-utils.js';
|
|
1
|
+
import type { SerializeOptions } from 'cookie';
|
|
2
|
+
import type { RelativeTimeInput } from '../time-utils.js';
|
|
3
3
|
/**
|
|
4
4
|
* Cookie-based session middleware that uses JWT for encoding/decoding session data.
|
|
5
5
|
*
|
|
@@ -33,7 +33,7 @@ export declare const authCookie: import("../types/core.types.js").CorePikkuMiddl
|
|
|
33
33
|
options: SerializeOptions;
|
|
34
34
|
expiresIn: RelativeTimeInput;
|
|
35
35
|
}, import("../types/core.types.js").CoreSingletonServices<{
|
|
36
|
-
logLevel?: import("../
|
|
36
|
+
logLevel?: import("../services/logger.js").LogLevel;
|
|
37
37
|
secrets?: {};
|
|
38
|
-
workflow?: import("../
|
|
38
|
+
workflow?: import("../wirings/workflow/workflow.types.js").WorkflowServiceConfig;
|
|
39
39
|
}>, import("../types/core.types.js").CoreUserSession>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { pikkuMiddleware, pikkuMiddlewareFactory } from '../types/core.types.js';
|
|
2
|
-
import { getRelativeTimeOffsetFromNow
|
|
2
|
+
import { getRelativeTimeOffsetFromNow } from '../time-utils.js';
|
|
3
3
|
/**
|
|
4
4
|
* Cookie-based session middleware that uses JWT for encoding/decoding session data.
|
|
5
5
|
*
|
|
@@ -28,27 +28,25 @@ import { getRelativeTimeOffsetFromNow, } from '../time-utils.js';
|
|
|
28
28
|
* ])
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
|
-
export const authCookie = pikkuMiddlewareFactory(({ name, options, expiresIn }) => pikkuMiddleware(async ({ jwt: jwtService, logger }, { http, session
|
|
32
|
-
if (!http?.request || !
|
|
31
|
+
export const authCookie = pikkuMiddlewareFactory(({ name, options, expiresIn }) => pikkuMiddleware(async ({ jwt: jwtService, logger }, { http, setSession, getSession, session, hasSessionChanged }, next) => {
|
|
32
|
+
if (!http?.request || !setSession || session) {
|
|
33
33
|
return next();
|
|
34
34
|
}
|
|
35
|
-
// Try to decode session from cookie
|
|
36
35
|
const cookieValue = http.request.cookie(name);
|
|
37
36
|
if (cookieValue && jwtService) {
|
|
38
37
|
const userSession = await jwtService.decode(cookieValue);
|
|
39
38
|
if (userSession) {
|
|
40
|
-
|
|
39
|
+
setSession?.(userSession);
|
|
41
40
|
}
|
|
42
41
|
}
|
|
43
42
|
await next();
|
|
44
|
-
// Set the cookie in the response if the session has changed
|
|
45
43
|
if (!http?.response) {
|
|
46
44
|
return;
|
|
47
45
|
}
|
|
48
|
-
if (
|
|
49
|
-
const
|
|
46
|
+
if (hasSessionChanged?.()) {
|
|
47
|
+
const currentSession = await getSession?.();
|
|
50
48
|
if (jwtService) {
|
|
51
|
-
http.response.cookie(name, await jwtService.encode(expiresIn,
|
|
49
|
+
http.response.cookie(name, await jwtService.encode(expiresIn, currentSession), {
|
|
52
50
|
...options,
|
|
53
51
|
expires: getRelativeTimeOffsetFromNow(expiresIn),
|
|
54
52
|
});
|