openloops 0.10.2 → 0.11.0
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 +25 -2
- package/README.md +14 -20
- package/dist/clients/llm/llm-client.d.ts +2 -2
- package/dist/clients/llm/llm-client.js +17 -18
- package/dist/clients/llm/llm-client.mjs +12 -13
- package/dist/clients/llm/llm-types.d.ts +2 -2
- package/dist/clients/llm/model-resolution.js +4 -5
- package/dist/clients/llm/model-resolution.mjs +1 -2
- package/dist/clients/serper/serper-client.js +3 -4
- package/dist/clients/serper/serper-client.mjs +1 -2
- package/dist/clients/slack/slack-client.js +2 -2
- package/dist/clients/slack/slack-client.mjs +1 -1
- package/dist/common/utils/number-setting.js +2 -2
- package/dist/common/utils/number-setting.mjs +1 -1
- package/dist/db/indexes/index.js +1 -5
- package/dist/db/indexes/index.mjs +1 -5
- package/dist/guardrails/guard.d.ts +4 -4
- package/dist/harness/actor-profile.d.ts +2 -0
- package/dist/{common/error/error-reporter.js → harness/actor-profile.js} +10 -13
- package/dist/harness/actor-profile.mjs +9 -0
- package/dist/harness/agent-loop.d.ts +4 -5
- package/dist/harness/agent.d.ts +7 -7
- package/dist/harness/agent.js +46 -46
- package/dist/harness/agent.mjs +44 -44
- package/dist/harness/default-model.d.ts +20 -0
- package/dist/harness/default-model.js +72 -0
- package/dist/harness/default-model.mjs +46 -0
- package/dist/harness/index.d.ts +2 -0
- package/dist/harness/index.js +8 -1
- package/dist/harness/index.mjs +5 -1
- package/dist/harness/tool-pipeline.d.ts +1 -1
- package/dist/harness/tool-pipeline.js +3 -3
- package/dist/harness/tool-pipeline.mjs +1 -1
- package/dist/harness/usage-limit.d.ts +2 -2
- package/dist/harness/usage-limit.js +5 -3
- package/dist/harness/usage-limit.mjs +5 -3
- package/dist/harness/workspace.d.ts +3 -3
- package/dist/harness/workspace.js +8 -8
- package/dist/harness/workspace.mjs +8 -8
- package/dist/loops/agi/loop.js +2 -2
- package/dist/loops/agi/loop.mjs +2 -2
- package/dist/services/automations/entities/automation-run.entity.d.ts +1 -1
- package/dist/services/automations/entities/automation-run.entity.js +4 -4
- package/dist/services/automations/entities/automation-run.entity.mjs +1 -1
- package/dist/services/automations/entities/automation.entity.d.ts +1 -1
- package/dist/services/automations/entities/automation.entity.js +3 -3
- package/dist/services/automations/entities/automation.entity.mjs +1 -1
- package/dist/services/automations/repositories/automation-run.repository.d.ts +1 -1
- package/dist/services/automations/repositories/automation-run.repository.js +5 -6
- package/dist/services/automations/repositories/automation-run.repository.mjs +2 -3
- package/dist/services/automations/repositories/automation.repository.d.ts +1 -1
- package/dist/services/automations/repositories/automation.repository.js +5 -6
- package/dist/services/automations/repositories/automation.repository.mjs +2 -3
- package/dist/services/automations/runner/automation-runner.d.ts +4 -4
- package/dist/services/automations/runner/automation-runner.js +16 -15
- package/dist/services/automations/runner/automation-runner.mjs +11 -10
- package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.js +2 -2
- package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.mjs +1 -1
- package/dist/services/automations/use-cases/claim-due-automations.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/claim-due-automations.use-case.js +3 -4
- package/dist/services/automations/use-cases/claim-due-automations.use-case.mjs +1 -2
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.js +2 -2
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.mjs +1 -1
- package/dist/services/automations/use-cases/create-automation.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/create-automation.use-case.js +8 -8
- package/dist/services/automations/use-cases/create-automation.use-case.mjs +5 -5
- package/dist/services/automations/use-cases/delete-automation.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/delete-automation.use-case.js +8 -8
- package/dist/services/automations/use-cases/delete-automation.use-case.mjs +5 -5
- package/dist/services/automations/use-cases/finish-automation-run.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/finish-automation-run.use-case.js +2 -2
- package/dist/services/automations/use-cases/finish-automation-run.use-case.mjs +1 -1
- package/dist/services/automations/use-cases/get-automation-by-id.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/get-automation-by-id.use-case.js +7 -7
- package/dist/services/automations/use-cases/get-automation-by-id.use-case.mjs +4 -4
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.js +7 -7
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.mjs +4 -4
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.d.ts +2 -2
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.js +7 -7
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.mjs +4 -4
- package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.d.ts +2 -2
- package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.js +9 -9
- package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.mjs +6 -6
- package/dist/services/automations/use-cases/list-automations-by-user.use-case.d.ts +2 -2
- package/dist/services/automations/use-cases/list-automations-by-user.use-case.js +9 -9
- package/dist/services/automations/use-cases/list-automations-by-user.use-case.mjs +6 -6
- package/dist/services/automations/use-cases/preview-automation-runs.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/preview-automation-runs.use-case.js +2 -2
- package/dist/services/automations/use-cases/preview-automation-runs.use-case.mjs +1 -1
- package/dist/services/automations/use-cases/receive-automation-event.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/receive-automation-event.use-case.js +3 -3
- package/dist/services/automations/use-cases/receive-automation-event.use-case.mjs +2 -2
- package/dist/services/automations/use-cases/renew-automation-lease.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/renew-automation-lease.use-case.js +2 -2
- package/dist/services/automations/use-cases/renew-automation-lease.use-case.mjs +1 -1
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.js +10 -11
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.mjs +7 -8
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.js +7 -7
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.mjs +4 -4
- package/dist/services/automations/use-cases/start-automation-run.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/start-automation-run.use-case.js +5 -5
- package/dist/services/automations/use-cases/start-automation-run.use-case.mjs +4 -4
- package/dist/services/automations/use-cases/sync-automation-run.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/sync-automation-run.use-case.js +2 -2
- package/dist/services/automations/use-cases/sync-automation-run.use-case.mjs +1 -1
- package/dist/services/automations/use-cases/sync-automation-runs.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/sync-automation-runs.use-case.js +2 -2
- package/dist/services/automations/use-cases/sync-automation-runs.use-case.mjs +1 -1
- package/dist/services/automations/use-cases/update-automation.use-case.d.ts +1 -1
- package/dist/services/automations/use-cases/update-automation.use-case.js +8 -9
- package/dist/services/automations/use-cases/update-automation.use-case.mjs +4 -5
- package/dist/services/automations/utils/event-token.d.ts +1 -0
- package/dist/services/automations/utils/event-token.js +9 -6
- package/dist/services/automations/utils/event-token.mjs +3 -1
- package/dist/services/automations/utils/open-run.d.ts +1 -1
- package/dist/services/automations/utils/runner-scope.d.ts +1 -1
- package/dist/services/automations/utils/runner-scope.js +3 -3
- package/dist/services/automations/utils/runner-scope.mjs +1 -1
- package/dist/services/chats/entities/chat-message.entity.d.ts +1 -1
- package/dist/services/chats/entities/chat-message.entity.js +3 -3
- package/dist/services/chats/entities/chat-message.entity.mjs +1 -1
- package/dist/services/chats/entities/chat.entity.d.ts +1 -1
- package/dist/services/chats/entities/chat.entity.js +4 -4
- package/dist/services/chats/entities/chat.entity.mjs +1 -1
- package/dist/services/chats/repositories/chat.repository.d.ts +1 -1
- package/dist/services/chats/repositories/chat.repository.js +5 -6
- package/dist/services/chats/repositories/chat.repository.mjs +2 -3
- package/dist/services/chats/use-cases/create-chat.use-case.d.ts +1 -1
- package/dist/services/chats/use-cases/create-chat.use-case.js +7 -7
- package/dist/services/chats/use-cases/create-chat.use-case.mjs +4 -4
- package/dist/services/chats/use-cases/delete-chat.use-case.d.ts +1 -1
- package/dist/services/chats/use-cases/delete-chat.use-case.js +8 -8
- package/dist/services/chats/use-cases/delete-chat.use-case.mjs +5 -5
- package/dist/services/chats/use-cases/get-chat-by-id.use-case.d.ts +2 -2
- package/dist/services/chats/use-cases/get-chat-by-id.use-case.js +7 -7
- package/dist/services/chats/use-cases/get-chat-by-id.use-case.mjs +4 -4
- package/dist/services/chats/use-cases/interrupt-execution.use-case.d.ts +1 -1
- package/dist/services/chats/use-cases/interrupt-execution.use-case.js +7 -7
- package/dist/services/chats/use-cases/interrupt-execution.use-case.mjs +4 -4
- package/dist/services/chats/use-cases/list-chats-by-props.use-case.d.ts +2 -2
- package/dist/services/chats/use-cases/list-chats-by-props.use-case.js +7 -7
- package/dist/services/chats/use-cases/list-chats-by-props.use-case.mjs +4 -4
- package/dist/services/chats/use-cases/list-chats-by-user.use-case.d.ts +2 -2
- package/dist/services/chats/use-cases/list-chats-by-user.use-case.js +8 -8
- package/dist/services/chats/use-cases/list-chats-by-user.use-case.mjs +5 -5
- package/dist/services/chats/use-cases/update-chat.use-case.d.ts +1 -1
- package/dist/services/chats/use-cases/update-chat.use-case.js +7 -7
- package/dist/services/chats/use-cases/update-chat.use-case.mjs +4 -4
- package/dist/services/llmcalls/entities/llmcall.entity.d.ts +1 -1
- package/dist/services/llmcalls/entities/llmcall.entity.js +4 -4
- package/dist/services/llmcalls/entities/llmcall.entity.mjs +1 -1
- package/dist/services/llmcalls/repositories/llmcall.repository.d.ts +1 -1
- package/dist/services/llmcalls/repositories/llmcall.repository.js +5 -6
- package/dist/services/llmcalls/repositories/llmcall.repository.mjs +2 -3
- package/dist/services/llmcalls/use-cases/create-llmcall.use-case.d.ts +1 -1
- package/dist/services/llmcalls/use-cases/create-llmcall.use-case.js +7 -7
- package/dist/services/llmcalls/use-cases/create-llmcall.use-case.mjs +4 -4
- package/dist/services/llmcalls/use-cases/delete-llmcall.use-case.d.ts +1 -1
- package/dist/services/llmcalls/use-cases/delete-llmcall.use-case.js +8 -8
- package/dist/services/llmcalls/use-cases/delete-llmcall.use-case.mjs +5 -5
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.d.ts +1 -1
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.js +9 -9
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.mjs +6 -6
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.d.ts +1 -1
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.js +9 -9
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.mjs +6 -6
- package/dist/services/llmcalls/use-cases/get-llm-usage-stats.use-case.d.ts +2 -2
- package/dist/services/llmcalls/use-cases/get-llm-usage-stats.use-case.js +12 -10
- package/dist/services/llmcalls/use-cases/get-llm-usage-stats.use-case.mjs +9 -7
- package/dist/services/llmcalls/use-cases/get-llmcall-by-id.use-case.d.ts +1 -1
- package/dist/services/llmcalls/use-cases/get-llmcall-by-id.use-case.js +7 -7
- package/dist/services/llmcalls/use-cases/get-llmcall-by-id.use-case.mjs +4 -4
- package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.d.ts +2 -2
- package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.js +5 -5
- package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.mjs +4 -4
- package/dist/services/llmcalls/use-cases/update-llmcall.use-case.d.ts +1 -1
- package/dist/services/llmcalls/use-cases/update-llmcall.use-case.js +7 -7
- package/dist/services/llmcalls/use-cases/update-llmcall.use-case.mjs +4 -4
- package/dist/services/mcp-servers/admin/admin-params.d.ts +5 -0
- package/dist/{common/logger/index.js → services/mcp-servers/admin/admin-params.js} +2 -8
- package/dist/services/mcp-servers/admin/admin-params.mjs +0 -0
- package/dist/services/mcp-servers/admin/use-cases/create-internal-mcp.use-case.d.ts +3 -2
- package/dist/services/mcp-servers/admin/use-cases/create-internal-mcp.use-case.js +7 -7
- package/dist/services/mcp-servers/admin/use-cases/create-internal-mcp.use-case.mjs +4 -4
- package/dist/services/mcp-servers/admin/use-cases/delete-internal-mcp.use-case.d.ts +3 -2
- package/dist/services/mcp-servers/admin/use-cases/delete-internal-mcp.use-case.js +7 -7
- package/dist/services/mcp-servers/admin/use-cases/delete-internal-mcp.use-case.mjs +4 -4
- package/dist/services/mcp-servers/admin/use-cases/get-internal-mcp-by-id.use-case.d.ts +3 -2
- package/dist/services/mcp-servers/admin/use-cases/get-internal-mcp-by-id.use-case.js +7 -7
- package/dist/services/mcp-servers/admin/use-cases/get-internal-mcp-by-id.use-case.mjs +4 -4
- package/dist/services/mcp-servers/admin/use-cases/list-internal-mcps.use-case.d.ts +4 -3
- package/dist/services/mcp-servers/admin/use-cases/list-internal-mcps.use-case.js +7 -7
- package/dist/services/mcp-servers/admin/use-cases/list-internal-mcps.use-case.mjs +4 -4
- package/dist/services/mcp-servers/admin/use-cases/update-internal-mcp.use-case.d.ts +3 -2
- package/dist/services/mcp-servers/admin/use-cases/update-internal-mcp.use-case.js +8 -9
- package/dist/services/mcp-servers/admin/use-cases/update-internal-mcp.use-case.mjs +4 -5
- package/dist/services/mcp-servers/entities/mcpserver.entity.d.ts +1 -1
- package/dist/services/mcp-servers/entities/mcpserver.entity.js +2 -2
- package/dist/services/mcp-servers/entities/mcpserver.entity.mjs +1 -1
- package/dist/services/mcp-servers/repositories/mcpserver.repository.d.ts +1 -1
- package/dist/services/mcp-servers/repositories/mcpserver.repository.js +6 -7
- package/dist/services/mcp-servers/repositories/mcpserver.repository.mjs +2 -3
- package/dist/services/mcp-servers/use-cases/create-mcpserver.use-case.d.ts +1 -1
- package/dist/services/mcp-servers/use-cases/create-mcpserver.use-case.js +8 -8
- package/dist/services/mcp-servers/use-cases/create-mcpserver.use-case.mjs +5 -5
- package/dist/services/mcp-servers/use-cases/decide-mcpserver-trust.use-case.d.ts +1 -1
- package/dist/services/mcp-servers/use-cases/decide-mcpserver-trust.use-case.js +7 -7
- package/dist/services/mcp-servers/use-cases/decide-mcpserver-trust.use-case.mjs +4 -4
- package/dist/services/mcp-servers/use-cases/delete-mcpserver.use-case.d.ts +1 -1
- package/dist/services/mcp-servers/use-cases/delete-mcpserver.use-case.js +8 -8
- package/dist/services/mcp-servers/use-cases/delete-mcpserver.use-case.mjs +5 -5
- package/dist/services/mcp-servers/use-cases/get-mcpserver-by-id.use-case.d.ts +1 -1
- package/dist/services/mcp-servers/use-cases/get-mcpserver-by-id.use-case.js +7 -7
- package/dist/services/mcp-servers/use-cases/get-mcpserver-by-id.use-case.mjs +4 -4
- package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.d.ts +1 -1
- package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.js +8 -8
- package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.mjs +5 -5
- package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.d.ts +2 -2
- package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.js +8 -8
- package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.mjs +5 -5
- package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.d.ts +1 -1
- package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.js +9 -10
- package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.mjs +5 -6
- package/dist/services/mcp-servers/use-cases/verify-mcpserver-connection.use-case.d.ts +1 -1
- package/dist/services/mcp-servers/use-cases/verify-mcpserver-connection.use-case.js +9 -10
- package/dist/services/mcp-servers/use-cases/verify-mcpserver-connection.use-case.mjs +4 -5
- package/dist/services/tasks/entities/agent-action.entity.d.ts +1 -1
- package/dist/services/tasks/entities/agent-action.entity.js +6 -7
- package/dist/services/tasks/entities/agent-action.entity.mjs +1 -2
- package/dist/services/tasks/entities/agent-task.entity.d.ts +1 -1
- package/dist/services/tasks/entities/agent-task.entity.js +4 -4
- package/dist/services/tasks/entities/agent-task.entity.mjs +1 -1
- package/dist/services/tasks/repositories/agent-action.repository.d.ts +1 -1
- package/dist/services/tasks/repositories/agent-action.repository.js +5 -6
- package/dist/services/tasks/repositories/agent-action.repository.mjs +2 -3
- package/dist/services/tasks/repositories/agent-task.repository.d.ts +1 -1
- package/dist/services/tasks/repositories/agent-task.repository.js +5 -6
- package/dist/services/tasks/repositories/agent-task.repository.mjs +2 -3
- package/dist/services/tasks/use-cases/create-agent-action.use-case.d.ts +1 -1
- package/dist/services/tasks/use-cases/create-agent-action.use-case.js +7 -7
- package/dist/services/tasks/use-cases/create-agent-action.use-case.mjs +4 -4
- package/dist/services/tasks/use-cases/create-agent-task.use-case.d.ts +1 -1
- package/dist/services/tasks/use-cases/create-agent-task.use-case.js +7 -7
- package/dist/services/tasks/use-cases/create-agent-task.use-case.mjs +4 -4
- package/dist/services/tasks/use-cases/get-agent-task-by-id.use-case.d.ts +1 -1
- package/dist/services/tasks/use-cases/get-agent-task-by-id.use-case.js +7 -7
- package/dist/services/tasks/use-cases/get-agent-task-by-id.use-case.mjs +4 -4
- package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.d.ts +2 -2
- package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.js +9 -10
- package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.mjs +6 -7
- package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.d.ts +2 -2
- package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.js +9 -10
- package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.mjs +6 -7
- package/dist/services/tasks/use-cases/update-agent-action.use-case.d.ts +1 -1
- package/dist/services/tasks/use-cases/update-agent-action.use-case.js +7 -7
- package/dist/services/tasks/use-cases/update-agent-action.use-case.mjs +4 -4
- package/dist/services/tasks/use-cases/update-agent-task.use-case.d.ts +1 -1
- package/dist/services/tasks/use-cases/update-agent-task.use-case.js +7 -7
- package/dist/services/tasks/use-cases/update-agent-task.use-case.mjs +4 -4
- package/dist/services/traces/entities/agent-trace-entry.entity.d.ts +1 -1
- package/dist/services/traces/entities/agent-trace-entry.entity.js +6 -6
- package/dist/services/traces/entities/agent-trace-entry.entity.mjs +1 -1
- package/dist/services/traces/repositories/agent-trace.repository.d.ts +1 -1
- package/dist/services/traces/repositories/agent-trace.repository.js +4 -4
- package/dist/services/traces/repositories/agent-trace.repository.mjs +2 -2
- package/dist/services/traces/use-cases/create-agent-traces.use-case.d.ts +1 -1
- package/dist/services/traces/use-cases/create-agent-traces.use-case.js +7 -7
- package/dist/services/traces/use-cases/create-agent-traces.use-case.mjs +4 -4
- package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.d.ts +2 -2
- package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.js +12 -13
- package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.mjs +6 -7
- package/dist/services/workspaces/entities/workspace-item.entity.d.ts +1 -1
- package/dist/services/workspaces/entities/workspace-item.entity.js +5 -5
- package/dist/services/workspaces/entities/workspace-item.entity.mjs +1 -1
- package/dist/services/workspaces/repositories/workspace-item.repository.d.ts +1 -1
- package/dist/services/workspaces/repositories/workspace-item.repository.js +5 -6
- package/dist/services/workspaces/repositories/workspace-item.repository.mjs +2 -3
- package/dist/services/workspaces/use-cases/delete-workspace-item.use-case.d.ts +1 -1
- package/dist/services/workspaces/use-cases/delete-workspace-item.use-case.js +11 -12
- package/dist/services/workspaces/use-cases/delete-workspace-item.use-case.mjs +6 -7
- package/dist/services/workspaces/use-cases/get-workspace-item.use-case.d.ts +1 -1
- package/dist/services/workspaces/use-cases/get-workspace-item.use-case.js +11 -12
- package/dist/services/workspaces/use-cases/get-workspace-item.use-case.mjs +6 -7
- package/dist/services/workspaces/use-cases/list-workspace-items.use-case.d.ts +2 -2
- package/dist/services/workspaces/use-cases/list-workspace-items.use-case.js +11 -12
- package/dist/services/workspaces/use-cases/list-workspace-items.use-case.mjs +6 -7
- package/dist/services/workspaces/use-cases/save-workspace-item.use-case.d.ts +1 -1
- package/dist/services/workspaces/use-cases/save-workspace-item.use-case.js +10 -11
- package/dist/services/workspaces/use-cases/save-workspace-item.use-case.mjs +6 -7
- package/dist/services/workspaces/use-cases/search-workspace-items.use-case.d.ts +2 -2
- package/dist/services/workspaces/use-cases/search-workspace-items.use-case.js +11 -12
- package/dist/services/workspaces/use-cases/search-workspace-items.use-case.mjs +6 -7
- package/dist/skills/runtime-context.d.ts +3 -3
- package/dist/skills/runtime-context.js +24 -21
- package/dist/skills/runtime-context.mjs +24 -21
- package/dist/skills/skill.d.ts +3 -3
- package/dist/skills/skill.js +5 -5
- package/dist/skills/skill.mjs +4 -4
- package/dist/tools/core/call-ai/call-ai.tool.js +2 -2
- package/dist/tools/core/call-ai/call-ai.tool.mjs +2 -2
- package/dist/tools/core/web-search/web-search.tool.js +1 -1
- package/dist/tools/core/web-search/web-search.tool.mjs +1 -1
- package/dist/tools/tool.d.ts +2 -2
- package/dist/tools/tool.js +1 -1
- package/dist/tools/tool.mjs +1 -1
- package/docs/README.md +1 -1
- package/docs/agent.md +10 -10
- package/docs/authentication.md +15 -114
- package/docs/authorization.md +18 -18
- package/docs/automations.md +30 -28
- package/docs/chats.md +14 -14
- package/docs/configuration.md +14 -15
- package/docs/error-reporting.md +6 -6
- package/docs/guardrails.md +1 -1
- package/docs/integration-guide.md +12 -12
- package/docs/loops.md +2 -2
- package/docs/mcp-servers.md +15 -15
- package/docs/skills.md +1 -1
- package/docs/tools.md +2 -2
- package/docs/usage.md +5 -5
- package/docs/users.md +18 -91
- package/examples/automations/create-automation.ts +4 -4
- package/examples/automations/create-event-automation.ts +5 -5
- package/examples/automations/list-automation-runs.ts +7 -7
- package/examples/automations/list-automations.ts +4 -4
- package/examples/automations/preview-automation-runs.ts +1 -1
- package/examples/automations/receive-automation-event.ts +1 -1
- package/examples/automations/revoke-automation-event-token.ts +6 -6
- package/examples/automations/run-automation-now.ts +4 -4
- package/examples/automations/run-automation-worker.ts +1 -1
- package/examples/automations/update-automation.ts +6 -6
- package/examples/chats/delete-chat.ts +6 -6
- package/examples/chats/get-chat-by-id.ts +6 -6
- package/examples/chats/list-autonomous-chats.ts +4 -4
- package/examples/chats/list-chats.ts +4 -4
- package/examples/chats/search-chats.ts +5 -5
- package/examples/errors/error-reporting.ts +6 -6
- package/examples/loops/custom-loop.ts +5 -5
- package/examples/mcps/create-mcp.ts +4 -4
- package/examples/mcps/decide-mcp.ts +7 -7
- package/examples/mcps/delete-mcp.ts +6 -6
- package/examples/mcps/get-mcp-by-id.ts +4 -4
- package/examples/mcps/internal-mcp-admin.ts +8 -8
- package/examples/mcps/internal-mcp.ts +5 -5
- package/examples/mcps/list-all-mcps.ts +4 -4
- package/examples/mcps/list-user-mcps.ts +4 -4
- package/examples/mcps/update-mcp.ts +4 -4
- package/examples/mcps/verify-mcp.ts +4 -4
- package/examples/run-agent/interrupt-agent.ts +5 -5
- package/examples/run-agent/run-agent-autonomous.ts +5 -5
- package/examples/run-agent/run-agent-multi-tenant.ts +10 -11
- package/examples/run-agent/run-agent-strict-mode.ts +5 -5
- package/examples/run-agent/run-agent-with-confirmation.ts +6 -6
- package/examples/run-agent/run-agent-with-fallback-model.ts +5 -5
- package/examples/run-agent/run-agent-with-fetch-url.ts +5 -5
- package/examples/run-agent/run-agent-with-guards.ts +5 -5
- package/examples/run-agent/run-agent-with-hooks.ts +5 -5
- package/examples/run-agent/run-agent-with-identity.ts +5 -5
- package/examples/run-agent/run-agent-with-model.ts +5 -5
- package/examples/run-agent/run-agent-with-slack.ts +5 -5
- package/examples/run-agent/run-agent-with-tools.ts +5 -5
- package/examples/run-agent/run-agent-with-usage-limit-stop.ts +5 -5
- package/examples/run-agent/run-agent-with-usage-limit.ts +5 -5
- package/examples/tools/basic-tool.ts +1 -1
- package/examples/tools/web-search-tool.ts +1 -1
- package/examples/usage/get-chat-usage.ts +4 -4
- package/examples/usage/get-message-usage.ts +4 -4
- package/examples/usage/get-usage-stats-by-range.ts +4 -4
- package/examples/usage/get-usage-stats.ts +4 -4
- package/examples/users/set-default-model.ts +12 -21
- package/package.json +7 -22
- package/dist/common/base/base.app.d.ts +0 -12
- package/dist/common/base/base.app.js +0 -57
- package/dist/common/base/base.app.mjs +0 -33
- package/dist/common/base/base.entity.d.ts +0 -38
- package/dist/common/base/base.entity.js +0 -100
- package/dist/common/base/base.entity.mjs +0 -76
- package/dist/common/base/base.use-case.d.ts +0 -11
- package/dist/common/base/base.use-case.js +0 -30
- package/dist/common/base/base.use-case.mjs +0 -6
- package/dist/common/base/current-session.d.ts +0 -129
- package/dist/common/base/current-session.js +0 -123
- package/dist/common/base/current-session.mjs +0 -98
- package/dist/common/base/current-user.d.ts +0 -16
- package/dist/common/base/current-user.js +0 -85
- package/dist/common/base/current-user.mjs +0 -61
- package/dist/common/base/index.d.ts +0 -3
- package/dist/common/base/index.js +0 -26
- package/dist/common/base/index.mjs +0 -3
- package/dist/common/base/share.d.ts +0 -12
- package/dist/common/base/share.js +0 -45
- package/dist/common/base/share.mjs +0 -20
- package/dist/common/base/utils/index.d.ts +0 -2
- package/dist/common/base/utils/index.js +0 -24
- package/dist/common/base/utils/index.mjs +0 -2
- package/dist/common/base/utils/is-plain-object.d.ts +0 -1
- package/dist/common/base/utils/is-plain-object.js +0 -32
- package/dist/common/base/utils/is-plain-object.mjs +0 -8
- package/dist/common/base/utils/to-patch.d.ts +0 -9
- package/dist/common/base/utils/to-patch.js +0 -46
- package/dist/common/base/utils/to-patch.mjs +0 -21
- package/dist/common/error/error-reporter.d.ts +0 -11
- package/dist/common/error/error-reporter.mjs +0 -11
- package/dist/common/error/http-error.d.ts +0 -11
- package/dist/common/error/http-error.js +0 -37
- package/dist/common/error/http-error.mjs +0 -13
- package/dist/common/error/index.d.ts +0 -3
- package/dist/common/error/index.js +0 -26
- package/dist/common/error/index.mjs +0 -3
- package/dist/common/error/reportError.d.ts +0 -2
- package/dist/common/error/reportError.js +0 -61
- package/dist/common/error/reportError.mjs +0 -37
- package/dist/common/error/sentry-client.d.ts +0 -10
- package/dist/common/error/sentry-client.js +0 -82
- package/dist/common/error/sentry-client.mjs +0 -57
- package/dist/common/index.d.ts +0 -6
- package/dist/common/index.js +0 -37
- package/dist/common/index.mjs +0 -9
- package/dist/common/logger/index.d.ts +0 -1
- package/dist/common/logger/index.mjs +0 -1
- package/dist/common/logger/pino.d.ts +0 -12
- package/dist/common/logger/pino.js +0 -79
- package/dist/common/logger/pino.mjs +0 -44
- package/dist/common/repositories/index.d.ts +0 -3
- package/dist/common/repositories/index.js +0 -26
- package/dist/common/repositories/index.mjs +0 -3
- package/dist/common/repositories/mongo-db.client.d.ts +0 -11
- package/dist/common/repositories/mongo-db.client.js +0 -83
- package/dist/common/repositories/mongo-db.client.mjs +0 -60
- package/dist/common/repositories/mongo-db.repository.d.ts +0 -130
- package/dist/common/repositories/mongo-db.repository.js +0 -357
- package/dist/common/repositories/mongo-db.repository.mjs +0 -332
- package/dist/common/repositories/scope.d.ts +0 -19
- package/dist/common/repositories/scope.js +0 -63
- package/dist/common/repositories/scope.mjs +0 -39
- package/dist/common/utils/config-context.d.ts +0 -3
- package/dist/common/utils/config-context.js +0 -33
- package/dist/common/utils/config-context.mjs +0 -8
- package/dist/common/utils/database-name.d.ts +0 -2
- package/dist/common/utils/database-name.js +0 -32
- package/dist/common/utils/database-name.mjs +0 -7
- package/dist/common/utils/secret-manager.d.ts +0 -17
- package/dist/common/utils/secret-manager.js +0 -124
- package/dist/common/utils/secret-manager.mjs +0 -89
- package/dist/db/indexes/refresh-tokens.d.ts +0 -2
- package/dist/db/indexes/refresh-tokens.js +0 -33
- package/dist/db/indexes/refresh-tokens.mjs +0 -9
- package/dist/db/indexes/revoked-tokens.d.ts +0 -2
- package/dist/db/indexes/revoked-tokens.js +0 -31
- package/dist/db/indexes/revoked-tokens.mjs +0 -7
- package/dist/services/authentication/entities/index.d.ts +0 -2
- package/dist/services/authentication/entities/index.js +0 -24
- package/dist/services/authentication/entities/index.mjs +0 -2
- package/dist/services/authentication/entities/refresh-token.entity.d.ts +0 -25
- package/dist/services/authentication/entities/refresh-token.entity.js +0 -75
- package/dist/services/authentication/entities/refresh-token.entity.mjs +0 -51
- package/dist/services/authentication/entities/revoked-token.entity.d.ts +0 -17
- package/dist/services/authentication/entities/revoked-token.entity.js +0 -67
- package/dist/services/authentication/entities/revoked-token.entity.mjs +0 -43
- package/dist/services/authentication/helpers/auth-config.d.ts +0 -9
- package/dist/services/authentication/helpers/auth-config.js +0 -36
- package/dist/services/authentication/helpers/auth-config.mjs +0 -12
- package/dist/services/authentication/helpers/session-tokens.d.ts +0 -16
- package/dist/services/authentication/helpers/session-tokens.js +0 -60
- package/dist/services/authentication/helpers/session-tokens.mjs +0 -35
- package/dist/services/authentication/helpers/tokens.d.ts +0 -43
- package/dist/services/authentication/helpers/tokens.js +0 -113
- package/dist/services/authentication/helpers/tokens.mjs +0 -71
- package/dist/services/authentication/index.d.ts +0 -5
- package/dist/services/authentication/index.js +0 -47
- package/dist/services/authentication/index.mjs +0 -13
- package/dist/services/authentication/module.d.ts +0 -16
- package/dist/services/authentication/module.js +0 -81
- package/dist/services/authentication/module.mjs +0 -50
- package/dist/services/authentication/repositories/index.d.ts +0 -2
- package/dist/services/authentication/repositories/index.js +0 -24
- package/dist/services/authentication/repositories/index.mjs +0 -2
- package/dist/services/authentication/repositories/refresh-token.repository.d.ts +0 -10
- package/dist/services/authentication/repositories/refresh-token.repository.js +0 -60
- package/dist/services/authentication/repositories/refresh-token.repository.mjs +0 -36
- package/dist/services/authentication/repositories/revoked-token.repository.d.ts +0 -7
- package/dist/services/authentication/repositories/revoked-token.repository.js +0 -44
- package/dist/services/authentication/repositories/revoked-token.repository.mjs +0 -20
- package/dist/services/authentication/use-cases/claim-refresh-token.use-case.d.ts +0 -12
- package/dist/services/authentication/use-cases/claim-refresh-token.use-case.js +0 -40
- package/dist/services/authentication/use-cases/claim-refresh-token.use-case.mjs +0 -16
- package/dist/services/authentication/use-cases/create-refresh-token.use-case.d.ts +0 -11
- package/dist/services/authentication/use-cases/create-refresh-token.use-case.js +0 -43
- package/dist/services/authentication/use-cases/create-refresh-token.use-case.mjs +0 -19
- package/dist/services/authentication/use-cases/find-refresh-token-by-hash.use-case.d.ts +0 -11
- package/dist/services/authentication/use-cases/find-refresh-token-by-hash.use-case.js +0 -40
- package/dist/services/authentication/use-cases/find-refresh-token-by-hash.use-case.mjs +0 -16
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.d.ts +0 -13
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.js +0 -42
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.mjs +0 -18
- package/dist/services/authentication/use-cases/issue-password-reset-token.use-case.d.ts +0 -18
- package/dist/services/authentication/use-cases/issue-password-reset-token.use-case.js +0 -49
- package/dist/services/authentication/use-cases/issue-password-reset-token.use-case.mjs +0 -25
- package/dist/services/authentication/use-cases/issue-session.use-case.d.ts +0 -13
- package/dist/services/authentication/use-cases/issue-session.use-case.js +0 -48
- package/dist/services/authentication/use-cases/issue-session.use-case.mjs +0 -24
- package/dist/services/authentication/use-cases/login.use-case.d.ts +0 -20
- package/dist/services/authentication/use-cases/login.use-case.js +0 -54
- package/dist/services/authentication/use-cases/login.use-case.mjs +0 -30
- package/dist/services/authentication/use-cases/logout.use-case.d.ts +0 -14
- package/dist/services/authentication/use-cases/logout.use-case.js +0 -48
- package/dist/services/authentication/use-cases/logout.use-case.mjs +0 -24
- package/dist/services/authentication/use-cases/refresh.use-case.d.ts +0 -23
- package/dist/services/authentication/use-cases/refresh.use-case.js +0 -84
- package/dist/services/authentication/use-cases/refresh.use-case.mjs +0 -60
- package/dist/services/authentication/use-cases/reset-password.use-case.d.ts +0 -15
- package/dist/services/authentication/use-cases/reset-password.use-case.js +0 -61
- package/dist/services/authentication/use-cases/reset-password.use-case.mjs +0 -37
- package/dist/services/authentication/use-cases/revoke-refresh-token-family.use-case.d.ts +0 -11
- package/dist/services/authentication/use-cases/revoke-refresh-token-family.use-case.js +0 -40
- package/dist/services/authentication/use-cases/revoke-refresh-token-family.use-case.mjs +0 -16
- package/dist/services/authentication/use-cases/revoke-token.use-case.d.ts +0 -12
- package/dist/services/authentication/use-cases/revoke-token.use-case.js +0 -52
- package/dist/services/authentication/use-cases/revoke-token.use-case.mjs +0 -28
- package/dist/services/authentication/use-cases/revoke-user-refresh-tokens.use-case.d.ts +0 -13
- package/dist/services/authentication/use-cases/revoke-user-refresh-tokens.use-case.js +0 -40
- package/dist/services/authentication/use-cases/revoke-user-refresh-tokens.use-case.mjs +0 -16
- package/dist/services/users/entities/index.d.ts +0 -1
- package/dist/services/users/entities/index.js +0 -22
- package/dist/services/users/entities/index.mjs +0 -1
- package/dist/services/users/entities/user-acquisition.d.ts +0 -12
- package/dist/services/users/entities/user-acquisition.js +0 -42
- package/dist/services/users/entities/user-acquisition.mjs +0 -18
- package/dist/services/users/entities/user-country.d.ts +0 -11
- package/dist/services/users/entities/user-country.js +0 -44
- package/dist/services/users/entities/user-country.mjs +0 -20
- package/dist/services/users/entities/user-currency.d.ts +0 -13
- package/dist/services/users/entities/user-currency.js +0 -44
- package/dist/services/users/entities/user-currency.mjs +0 -20
- package/dist/services/users/entities/user-default-model.d.ts +0 -11
- package/dist/services/users/entities/user-default-model.js +0 -42
- package/dist/services/users/entities/user-default-model.mjs +0 -18
- package/dist/services/users/entities/user-email.value-object.d.ts +0 -6
- package/dist/services/users/entities/user-email.value-object.js +0 -43
- package/dist/services/users/entities/user-email.value-object.mjs +0 -19
- package/dist/services/users/entities/user-language.d.ts +0 -11
- package/dist/services/users/entities/user-language.js +0 -44
- package/dist/services/users/entities/user-language.mjs +0 -20
- package/dist/services/users/entities/user-marketing.d.ts +0 -9
- package/dist/services/users/entities/user-marketing.js +0 -40
- package/dist/services/users/entities/user-marketing.mjs +0 -16
- package/dist/services/users/entities/user-notification-preferences.d.ts +0 -11
- package/dist/services/users/entities/user-notification-preferences.js +0 -41
- package/dist/services/users/entities/user-notification-preferences.mjs +0 -17
- package/dist/services/users/entities/user-password.value-object.d.ts +0 -8
- package/dist/services/users/entities/user-password.value-object.js +0 -69
- package/dist/services/users/entities/user-password.value-object.mjs +0 -35
- package/dist/services/users/entities/user-permissions.d.ts +0 -21
- package/dist/services/users/entities/user-permissions.js +0 -59
- package/dist/services/users/entities/user-permissions.mjs +0 -35
- package/dist/services/users/entities/user-preferences.d.ts +0 -28
- package/dist/services/users/entities/user-preferences.js +0 -74
- package/dist/services/users/entities/user-preferences.mjs +0 -50
- package/dist/services/users/entities/user-report-preferences.d.ts +0 -16
- package/dist/services/users/entities/user-report-preferences.js +0 -56
- package/dist/services/users/entities/user-report-preferences.mjs +0 -32
- package/dist/services/users/entities/user-report-schedule.d.ts +0 -11
- package/dist/services/users/entities/user-report-schedule.js +0 -41
- package/dist/services/users/entities/user-report-schedule.mjs +0 -17
- package/dist/services/users/entities/user-timezone.d.ts +0 -11
- package/dist/services/users/entities/user-timezone.js +0 -44
- package/dist/services/users/entities/user-timezone.mjs +0 -20
- package/dist/services/users/entities/user.entity.d.ts +0 -42
- package/dist/services/users/entities/user.entity.js +0 -117
- package/dist/services/users/entities/user.entity.mjs +0 -92
- package/dist/services/users/index.d.ts +0 -3
- package/dist/services/users/index.js +0 -26
- package/dist/services/users/index.mjs +0 -3
- package/dist/services/users/module.d.ts +0 -12
- package/dist/services/users/module.js +0 -67
- package/dist/services/users/module.mjs +0 -38
- package/dist/services/users/repositories/index.d.ts +0 -1
- package/dist/services/users/repositories/index.js +0 -22
- package/dist/services/users/repositories/index.mjs +0 -1
- package/dist/services/users/repositories/user.repository.d.ts +0 -18
- package/dist/services/users/repositories/user.repository.js +0 -88
- package/dist/services/users/repositories/user.repository.mjs +0 -64
- package/dist/services/users/use-cases/change-password.use-case.d.ts +0 -15
- package/dist/services/users/use-cases/change-password.use-case.js +0 -52
- package/dist/services/users/use-cases/change-password.use-case.mjs +0 -28
- package/dist/services/users/use-cases/create-user.use-case.d.ts +0 -12
- package/dist/services/users/use-cases/create-user.use-case.js +0 -49
- package/dist/services/users/use-cases/create-user.use-case.mjs +0 -25
- package/dist/services/users/use-cases/delete-user.use-case.d.ts +0 -16
- package/dist/services/users/use-cases/delete-user.use-case.js +0 -48
- package/dist/services/users/use-cases/delete-user.use-case.mjs +0 -24
- package/dist/services/users/use-cases/get-user-by-id.use-case.d.ts +0 -12
- package/dist/services/users/use-cases/get-user-by-id.use-case.js +0 -43
- package/dist/services/users/use-cases/get-user-by-id.use-case.mjs +0 -19
- package/dist/services/users/use-cases/list-users-by-props.use-case.d.ts +0 -17
- package/dist/services/users/use-cases/list-users-by-props.use-case.js +0 -42
- package/dist/services/users/use-cases/list-users-by-props.use-case.mjs +0 -18
- package/dist/services/users/use-cases/update-user.use-case.d.ts +0 -13
- package/dist/services/users/use-cases/update-user.use-case.js +0 -53
- package/dist/services/users/use-cases/update-user.use-case.mjs +0 -29
- package/dist/services/users/utils/default-model.d.ts +0 -6
- package/dist/services/users/utils/default-model.js +0 -38
- package/dist/services/users/utils/default-model.mjs +0 -14
- package/examples/authentication/login.ts +0 -22
- package/examples/users/create-user.ts +0 -25
- package/examples/users/delete-user.ts +0 -42
- package/examples/users/get-user-by-id.ts +0 -21
- package/examples/users/list-users.ts +0 -22
- package/examples/users/update-user.ts +0 -25
|
@@ -22,22 +22,22 @@ __export(list_automation_runs_by_user_use_case_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(list_automation_runs_by_user_use_case_exports);
|
|
24
24
|
var import_mongodb = require("mongodb");
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
class ListAutomationRunsByUserUseCase extends
|
|
29
|
-
constructor(automationRunRepository = new
|
|
25
|
+
var import_db = require("nanosaas/db");
|
|
26
|
+
var import_common = require("nanosaas/common");
|
|
27
|
+
var import_repositories = require("../repositories");
|
|
28
|
+
class ListAutomationRunsByUserUseCase extends import_common.BaseUseCase {
|
|
29
|
+
constructor(automationRunRepository = new import_repositories.AutomationRunRepository()) {
|
|
30
30
|
super();
|
|
31
31
|
this.automationRunRepository = automationRunRepository;
|
|
32
32
|
}
|
|
33
33
|
automationRunRepository;
|
|
34
34
|
async execute(params) {
|
|
35
|
-
const { status, options,
|
|
36
|
-
if (!
|
|
35
|
+
const { status, options, actor } = params;
|
|
36
|
+
if (!actor?.userId) throw new Error("actor is required to list the runs of the automations");
|
|
37
37
|
const { page = 1, limit = 10, sortBy = { createdAt: -1 } } = options || {};
|
|
38
38
|
const result = await this.automationRunRepository._.findManyPaginated({
|
|
39
|
-
scope: params.scope ??
|
|
40
|
-
where: { ownerId: new import_mongodb.ObjectId(
|
|
39
|
+
scope: params.scope ?? import_db.Scope.canView(actor),
|
|
40
|
+
where: { ownerId: new import_mongodb.ObjectId(actor.userId), ...status ? { status } : {} },
|
|
41
41
|
options: { page, limit, sortBy }
|
|
42
42
|
});
|
|
43
43
|
return { items: result?.items ?? [], hasMore: result?.hasMore ?? false };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ObjectId } from "mongodb";
|
|
2
|
-
import { Scope } from "
|
|
3
|
-
import { BaseUseCase } from "
|
|
2
|
+
import { Scope } from "nanosaas/db";
|
|
3
|
+
import { BaseUseCase } from "nanosaas/common";
|
|
4
4
|
import { AutomationRunRepository } from "../repositories";
|
|
5
5
|
class ListAutomationRunsByUserUseCase extends BaseUseCase {
|
|
6
6
|
constructor(automationRunRepository = new AutomationRunRepository()) {
|
|
@@ -9,12 +9,12 @@ class ListAutomationRunsByUserUseCase extends BaseUseCase {
|
|
|
9
9
|
}
|
|
10
10
|
automationRunRepository;
|
|
11
11
|
async execute(params) {
|
|
12
|
-
const { status, options,
|
|
13
|
-
if (!
|
|
12
|
+
const { status, options, actor } = params;
|
|
13
|
+
if (!actor?.userId) throw new Error("actor is required to list the runs of the automations");
|
|
14
14
|
const { page = 1, limit = 10, sortBy = { createdAt: -1 } } = options || {};
|
|
15
15
|
const result = await this.automationRunRepository._.findManyPaginated({
|
|
16
|
-
scope: params.scope ?? Scope.canView(
|
|
17
|
-
where: { ownerId: new ObjectId(
|
|
16
|
+
scope: params.scope ?? Scope.canView(actor),
|
|
17
|
+
where: { ownerId: new ObjectId(actor.userId), ...status ? { status } : {} },
|
|
18
18
|
options: { page, limit, sortBy }
|
|
19
19
|
});
|
|
20
20
|
return { items: result?.items ?? [], hasMore: result?.hasMore ?? false };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { QueryOptions } from '
|
|
2
|
-
import { BaseUseCase, BaseUseCaseParams } from '
|
|
1
|
+
import { QueryOptions } from 'nanosaas/db';
|
|
2
|
+
import { BaseUseCase, BaseUseCaseParams } from 'nanosaas/common';
|
|
3
3
|
import { AutomationProps } from '../entities';
|
|
4
4
|
import { AutomationRepository } from '../repositories';
|
|
5
5
|
export interface Params extends BaseUseCaseParams {
|
|
@@ -22,22 +22,22 @@ __export(list_automations_by_user_use_case_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(list_automations_by_user_use_case_exports);
|
|
24
24
|
var import_mongodb = require("mongodb");
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
class ListAutomationsByUserUseCase extends
|
|
29
|
-
constructor(automationRepository = new
|
|
25
|
+
var import_db = require("nanosaas/db");
|
|
26
|
+
var import_common = require("nanosaas/common");
|
|
27
|
+
var import_repositories = require("../repositories");
|
|
28
|
+
class ListAutomationsByUserUseCase extends import_common.BaseUseCase {
|
|
29
|
+
constructor(automationRepository = new import_repositories.AutomationRepository()) {
|
|
30
30
|
super();
|
|
31
31
|
this.automationRepository = automationRepository;
|
|
32
32
|
}
|
|
33
33
|
automationRepository;
|
|
34
34
|
async execute(params) {
|
|
35
|
-
const { options,
|
|
36
|
-
if (!
|
|
35
|
+
const { options, actor } = params;
|
|
36
|
+
if (!actor?.userId) throw new Error("actor is required to list the automations");
|
|
37
37
|
const { page = 1, limit = 10, sortBy = { createdAt: -1 } } = options || {};
|
|
38
38
|
const result = await this.automationRepository._.findManyPaginated({
|
|
39
|
-
scope: params.scope ??
|
|
40
|
-
where: { ownerId: new import_mongodb.ObjectId(
|
|
39
|
+
scope: params.scope ?? import_db.Scope.canView(actor),
|
|
40
|
+
where: { ownerId: new import_mongodb.ObjectId(actor.userId) },
|
|
41
41
|
options: { page, limit, sortBy }
|
|
42
42
|
});
|
|
43
43
|
return { items: result?.items ?? [], hasMore: result?.hasMore ?? false };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ObjectId } from "mongodb";
|
|
2
|
-
import { Scope } from "
|
|
3
|
-
import { BaseUseCase } from "
|
|
2
|
+
import { Scope } from "nanosaas/db";
|
|
3
|
+
import { BaseUseCase } from "nanosaas/common";
|
|
4
4
|
import { AutomationRepository } from "../repositories";
|
|
5
5
|
class ListAutomationsByUserUseCase extends BaseUseCase {
|
|
6
6
|
constructor(automationRepository = new AutomationRepository()) {
|
|
@@ -9,12 +9,12 @@ class ListAutomationsByUserUseCase extends BaseUseCase {
|
|
|
9
9
|
}
|
|
10
10
|
automationRepository;
|
|
11
11
|
async execute(params) {
|
|
12
|
-
const { options,
|
|
13
|
-
if (!
|
|
12
|
+
const { options, actor } = params;
|
|
13
|
+
if (!actor?.userId) throw new Error("actor is required to list the automations");
|
|
14
14
|
const { page = 1, limit = 10, sortBy = { createdAt: -1 } } = options || {};
|
|
15
15
|
const result = await this.automationRepository._.findManyPaginated({
|
|
16
|
-
scope: params.scope ?? Scope.canView(
|
|
17
|
-
where: { ownerId: new ObjectId(
|
|
16
|
+
scope: params.scope ?? Scope.canView(actor),
|
|
17
|
+
where: { ownerId: new ObjectId(actor.userId) },
|
|
18
18
|
options: { page, limit, sortBy }
|
|
19
19
|
});
|
|
20
20
|
return { items: result?.items ?? [], hasMore: result?.hasMore ?? false };
|
|
@@ -21,11 +21,11 @@ __export(preview_automation_runs_use_case_exports, {
|
|
|
21
21
|
PreviewAutomationRunsUseCase: () => PreviewAutomationRunsUseCase
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(preview_automation_runs_use_case_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_common = require("nanosaas/common");
|
|
25
25
|
var import_entities = require("../entities");
|
|
26
26
|
var import_next_run = require("../utils/next-run");
|
|
27
27
|
const DEFAULT_COUNT = 5;
|
|
28
|
-
class PreviewAutomationRunsUseCase extends
|
|
28
|
+
class PreviewAutomationRunsUseCase extends import_common.BaseUseCase {
|
|
29
29
|
async execute(params) {
|
|
30
30
|
const recurrence = (0, import_entities.validateRecurrence)(params.recurrence);
|
|
31
31
|
const timezone = (0, import_next_run.assertTimezone)(params.timezone);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams } from '
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from 'nanosaas/common';
|
|
2
2
|
import { AutomationRunProps } from '../entities';
|
|
3
3
|
import { AutomationRepository, AutomationRunRepository } from '../repositories';
|
|
4
4
|
export type AutomationEventStatus = 'queued' | 'duplicate' | 'skipped';
|
|
@@ -21,8 +21,8 @@ __export(receive_automation_event_use_case_exports, {
|
|
|
21
21
|
ReceiveAutomationEventUseCase: () => ReceiveAutomationEventUseCase
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(receive_automation_event_use_case_exports);
|
|
24
|
-
var
|
|
25
|
-
var import_authentication = require("
|
|
24
|
+
var import_common = require("nanosaas/common");
|
|
25
|
+
var import_authentication = require("nanosaas/authentication");
|
|
26
26
|
var import_repositories = require("../repositories");
|
|
27
27
|
var import_automation_event_error = require("../utils/automation-event-error");
|
|
28
28
|
var import_event_token = require("../utils/event-token");
|
|
@@ -35,7 +35,7 @@ const serialize = (payload) => {
|
|
|
35
35
|
const text = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
36
36
|
return text || void 0;
|
|
37
37
|
};
|
|
38
|
-
class ReceiveAutomationEventUseCase extends
|
|
38
|
+
class ReceiveAutomationEventUseCase extends import_common.BaseUseCase {
|
|
39
39
|
constructor(automationRepository = new import_repositories.AutomationRepository(), automationRunRepository = new import_repositories.AutomationRunRepository()) {
|
|
40
40
|
super();
|
|
41
41
|
this.automationRepository = automationRepository;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseUseCase } from "
|
|
2
|
-
import { isTokenRevoked } from "
|
|
1
|
+
import { BaseUseCase } from "nanosaas/common";
|
|
2
|
+
import { isTokenRevoked } from "nanosaas/authentication";
|
|
3
3
|
import { AutomationRepository, AutomationRunRepository } from "../repositories";
|
|
4
4
|
import { AutomationEventError } from "../utils/automation-event-error";
|
|
5
5
|
import { readEventToken } from "../utils/event-token";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams } from '
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from 'nanosaas/common';
|
|
2
2
|
import { AutomationRepository } from '../repositories';
|
|
3
3
|
export interface Params extends BaseUseCaseParams {
|
|
4
4
|
automationId: string;
|
|
@@ -21,11 +21,11 @@ __export(renew_automation_lease_use_case_exports, {
|
|
|
21
21
|
RenewAutomationLeaseUseCase: () => RenewAutomationLeaseUseCase
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(renew_automation_lease_use_case_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_common = require("nanosaas/common");
|
|
25
25
|
var import_repositories = require("../repositories");
|
|
26
26
|
var import_settings = require("../utils/settings");
|
|
27
27
|
var import_runner_scope = require("../utils/runner-scope");
|
|
28
|
-
class RenewAutomationLeaseUseCase extends
|
|
28
|
+
class RenewAutomationLeaseUseCase extends import_common.BaseUseCase {
|
|
29
29
|
constructor(automationRepository = new import_repositories.AutomationRepository()) {
|
|
30
30
|
super();
|
|
31
31
|
this.automationRepository = automationRepository;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase } from "
|
|
1
|
+
import { BaseUseCase } from "nanosaas/common";
|
|
2
2
|
import { AutomationRepository } from "../repositories";
|
|
3
3
|
import { leaseMs as defaultLeaseMs } from "../utils/settings";
|
|
4
4
|
import { runnerScope } from "../utils/runner-scope";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams } from '
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from 'nanosaas/common';
|
|
2
2
|
import { AutomationRepository } from '../repositories';
|
|
3
3
|
export interface Params extends BaseUseCaseParams {
|
|
4
4
|
id: string;
|
|
@@ -21,27 +21,26 @@ __export(revoke_automation_event_token_use_case_exports, {
|
|
|
21
21
|
RevokeAutomationEventTokenUseCase: () => RevokeAutomationEventTokenUseCase
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(revoke_automation_event_token_use_case_exports);
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var import_authentication = require("
|
|
27
|
-
var
|
|
28
|
-
var import_tokens = require("../../authentication/helpers/tokens.js");
|
|
24
|
+
var import_common = require("nanosaas/common");
|
|
25
|
+
var import_db = require("nanosaas/db");
|
|
26
|
+
var import_authentication = require("nanosaas/authentication");
|
|
27
|
+
var import_repositories = require("../repositories");
|
|
29
28
|
var import_event_token = require("../utils/event-token");
|
|
30
|
-
class RevokeAutomationEventTokenUseCase extends
|
|
31
|
-
constructor(automationRepository = new
|
|
29
|
+
class RevokeAutomationEventTokenUseCase extends import_common.BaseUseCase {
|
|
30
|
+
constructor(automationRepository = new import_repositories.AutomationRepository()) {
|
|
32
31
|
super();
|
|
33
32
|
this.automationRepository = automationRepository;
|
|
34
33
|
}
|
|
35
34
|
automationRepository;
|
|
36
35
|
async execute(params) {
|
|
37
|
-
const { id, token,
|
|
38
|
-
const automation = await this.automationRepository.findById(id, params.scope ??
|
|
36
|
+
const { id, token, actor } = params;
|
|
37
|
+
const automation = await this.automationRepository.findById(id, params.scope ?? import_db.Scope.canManage(actor));
|
|
39
38
|
if (!automation) this.throwHttpError({ statusCode: 404, errorMessage: "{{resource_not_found}}" });
|
|
40
39
|
const claims = (0, import_event_token.readEventToken)(token, { ignoreExpiration: true });
|
|
41
40
|
if (claims.sub !== id) throw new Error("The token does not belong to this automation");
|
|
42
41
|
await (0, import_authentication.revokeToken)({
|
|
43
|
-
payload: { jti: claims.jti, audience:
|
|
44
|
-
|
|
42
|
+
payload: { jti: claims.jti, audience: import_event_token.AUTOMATION_EVENT_AUDIENCE, subject: id, expiresAt: claims.expiresAt },
|
|
43
|
+
actor
|
|
45
44
|
});
|
|
46
45
|
return { jti: claims.jti };
|
|
47
46
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { BaseUseCase } from "
|
|
2
|
-
import { Scope } from "
|
|
3
|
-
import { revokeToken } from "
|
|
1
|
+
import { BaseUseCase } from "nanosaas/common";
|
|
2
|
+
import { Scope } from "nanosaas/db";
|
|
3
|
+
import { revokeToken } from "nanosaas/authentication";
|
|
4
4
|
import { AutomationRepository } from "../repositories";
|
|
5
|
-
import { AUTOMATION_EVENT_AUDIENCE } from "
|
|
6
|
-
import { readEventToken } from "../utils/event-token";
|
|
5
|
+
import { AUTOMATION_EVENT_AUDIENCE, readEventToken } from "../utils/event-token";
|
|
7
6
|
class RevokeAutomationEventTokenUseCase extends BaseUseCase {
|
|
8
7
|
constructor(automationRepository = new AutomationRepository()) {
|
|
9
8
|
super();
|
|
@@ -11,14 +10,14 @@ class RevokeAutomationEventTokenUseCase extends BaseUseCase {
|
|
|
11
10
|
}
|
|
12
11
|
automationRepository;
|
|
13
12
|
async execute(params) {
|
|
14
|
-
const { id, token,
|
|
15
|
-
const automation = await this.automationRepository.findById(id, params.scope ?? Scope.canManage(
|
|
13
|
+
const { id, token, actor } = params;
|
|
14
|
+
const automation = await this.automationRepository.findById(id, params.scope ?? Scope.canManage(actor));
|
|
16
15
|
if (!automation) this.throwHttpError({ statusCode: 404, errorMessage: "{{resource_not_found}}" });
|
|
17
16
|
const claims = readEventToken(token, { ignoreExpiration: true });
|
|
18
17
|
if (claims.sub !== id) throw new Error("The token does not belong to this automation");
|
|
19
18
|
await revokeToken({
|
|
20
19
|
payload: { jti: claims.jti, audience: AUTOMATION_EVENT_AUDIENCE, subject: id, expiresAt: claims.expiresAt },
|
|
21
|
-
|
|
20
|
+
actor
|
|
22
21
|
});
|
|
23
22
|
return { jti: claims.jti };
|
|
24
23
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams } from '
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from 'nanosaas/common';
|
|
2
2
|
import { AutomationProps } from '../entities';
|
|
3
3
|
import { AutomationRepository } from '../repositories';
|
|
4
4
|
export interface Params extends BaseUseCaseParams {
|
|
@@ -21,19 +21,19 @@ __export(rotate_automation_event_tokens_use_case_exports, {
|
|
|
21
21
|
RotateAutomationEventTokensUseCase: () => RotateAutomationEventTokensUseCase
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(rotate_automation_event_tokens_use_case_exports);
|
|
24
|
-
var
|
|
25
|
-
var
|
|
24
|
+
var import_common = require("nanosaas/common");
|
|
25
|
+
var import_db = require("nanosaas/db");
|
|
26
26
|
var import_entities = require("../entities");
|
|
27
|
-
var
|
|
28
|
-
class RotateAutomationEventTokensUseCase extends
|
|
29
|
-
constructor(automationRepository = new
|
|
27
|
+
var import_repositories = require("../repositories");
|
|
28
|
+
class RotateAutomationEventTokensUseCase extends import_common.BaseUseCase {
|
|
29
|
+
constructor(automationRepository = new import_repositories.AutomationRepository()) {
|
|
30
30
|
super();
|
|
31
31
|
this.automationRepository = automationRepository;
|
|
32
32
|
}
|
|
33
33
|
automationRepository;
|
|
34
34
|
async execute(params) {
|
|
35
|
-
const { id,
|
|
36
|
-
const scope = params.scope ??
|
|
35
|
+
const { id, actor } = params;
|
|
36
|
+
const scope = params.scope ?? import_db.Scope.canManage(actor);
|
|
37
37
|
const existing = await this.automationRepository.findById(id, scope);
|
|
38
38
|
if (!existing) this.throwHttpError({ statusCode: 404, errorMessage: "{{resource_not_found}}" });
|
|
39
39
|
if (!existing.triggers?.event) throw new Error("Only an automation with an event trigger has tokens");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseUseCase } from "
|
|
2
|
-
import { Scope } from "
|
|
1
|
+
import { BaseUseCase } from "nanosaas/common";
|
|
2
|
+
import { Scope } from "nanosaas/db";
|
|
3
3
|
import { Automation } from "../entities";
|
|
4
4
|
import { AutomationRepository } from "../repositories";
|
|
5
5
|
class RotateAutomationEventTokensUseCase extends BaseUseCase {
|
|
@@ -9,8 +9,8 @@ class RotateAutomationEventTokensUseCase extends BaseUseCase {
|
|
|
9
9
|
}
|
|
10
10
|
automationRepository;
|
|
11
11
|
async execute(params) {
|
|
12
|
-
const { id,
|
|
13
|
-
const scope = params.scope ?? Scope.canManage(
|
|
12
|
+
const { id, actor } = params;
|
|
13
|
+
const scope = params.scope ?? Scope.canManage(actor);
|
|
14
14
|
const existing = await this.automationRepository.findById(id, scope);
|
|
15
15
|
if (!existing) this.throwHttpError({ statusCode: 404, errorMessage: "{{resource_not_found}}" });
|
|
16
16
|
if (!existing.triggers?.event) throw new Error("Only an automation with an event trigger has tokens");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams } from '
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from 'nanosaas/common';
|
|
2
2
|
import { AutomationProps, AutomationRunProps } from '../entities';
|
|
3
3
|
import { AutomationRepository, AutomationRunRepository } from '../repositories';
|
|
4
4
|
export interface Params extends BaseUseCaseParams {
|
|
@@ -21,13 +21,13 @@ __export(start_automation_run_use_case_exports, {
|
|
|
21
21
|
StartAutomationRunUseCase: () => StartAutomationRunUseCase
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(start_automation_run_use_case_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_common = require("nanosaas/common");
|
|
25
25
|
var import_repositories = require("../repositories");
|
|
26
26
|
var import_open_run = require("../utils/open-run");
|
|
27
27
|
var import_settings = require("../utils/settings");
|
|
28
28
|
var import_runner_scope = require("../utils/runner-scope");
|
|
29
|
-
var
|
|
30
|
-
class StartAutomationRunUseCase extends
|
|
29
|
+
var import_db = require("nanosaas/db");
|
|
30
|
+
class StartAutomationRunUseCase extends import_common.BaseUseCase {
|
|
31
31
|
constructor(automationRepository = new import_repositories.AutomationRepository(), automationRunRepository = new import_repositories.AutomationRunRepository()) {
|
|
32
32
|
super();
|
|
33
33
|
this.automationRepository = automationRepository;
|
|
@@ -36,10 +36,10 @@ class StartAutomationRunUseCase extends import_base.BaseUseCase {
|
|
|
36
36
|
automationRepository;
|
|
37
37
|
automationRunRepository;
|
|
38
38
|
async execute(params) {
|
|
39
|
-
const { automationId, workerId,
|
|
39
|
+
const { automationId, workerId, actor } = params;
|
|
40
40
|
if (!automationId || !workerId) throw new Error("The automation and the worker are required");
|
|
41
41
|
const now = params.now ?? /* @__PURE__ */ new Date();
|
|
42
|
-
const existing = await this.automationRepository.findById(automationId, params.scope ??
|
|
42
|
+
const existing = await this.automationRepository.findById(automationId, params.scope ?? import_db.Scope.canEdit(actor));
|
|
43
43
|
if (!existing) this.throwHttpError({ statusCode: 404, errorMessage: "{{resource_not_found}}" });
|
|
44
44
|
const automation = await this.automationRepository.claimManual({ id: automationId, workerId, now, leaseMs: params.leaseMs ?? (0, import_settings.leaseMs)() }, import_runner_scope.runnerScope);
|
|
45
45
|
if (!automation) throw new Error("The automation is already running");
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { BaseUseCase } from "
|
|
1
|
+
import { BaseUseCase } from "nanosaas/common";
|
|
2
2
|
import { AutomationRepository, AutomationRunRepository } from "../repositories";
|
|
3
3
|
import { openRun } from "../utils/open-run";
|
|
4
4
|
import { leaseMs as defaultLeaseMs } from "../utils/settings";
|
|
5
5
|
import { runnerScope } from "../utils/runner-scope";
|
|
6
|
-
import { Scope } from "
|
|
6
|
+
import { Scope } from "nanosaas/db";
|
|
7
7
|
class StartAutomationRunUseCase extends BaseUseCase {
|
|
8
8
|
constructor(automationRepository = new AutomationRepository(), automationRunRepository = new AutomationRunRepository()) {
|
|
9
9
|
super();
|
|
@@ -13,10 +13,10 @@ class StartAutomationRunUseCase extends BaseUseCase {
|
|
|
13
13
|
automationRepository;
|
|
14
14
|
automationRunRepository;
|
|
15
15
|
async execute(params) {
|
|
16
|
-
const { automationId, workerId,
|
|
16
|
+
const { automationId, workerId, actor } = params;
|
|
17
17
|
if (!automationId || !workerId) throw new Error("The automation and the worker are required");
|
|
18
18
|
const now = params.now ?? /* @__PURE__ */ new Date();
|
|
19
|
-
const existing = await this.automationRepository.findById(automationId, params.scope ?? Scope.canEdit(
|
|
19
|
+
const existing = await this.automationRepository.findById(automationId, params.scope ?? Scope.canEdit(actor));
|
|
20
20
|
if (!existing) this.throwHttpError({ statusCode: 404, errorMessage: "{{resource_not_found}}" });
|
|
21
21
|
const automation = await this.automationRepository.claimManual({ id: automationId, workerId, now, leaseMs: params.leaseMs ?? defaultLeaseMs() }, runnerScope);
|
|
22
22
|
if (!automation) throw new Error("The automation is already running");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams } from '
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from 'nanosaas/common';
|
|
2
2
|
import { AutomationRunProps } from '../entities';
|
|
3
3
|
import { AutomationRepository, AutomationRunRepository } from '../repositories';
|
|
4
4
|
export interface Params extends BaseUseCaseParams {
|
|
@@ -23,14 +23,14 @@ __export(sync_automation_run_use_case_exports, {
|
|
|
23
23
|
SyncAutomationRunUseCase: () => SyncAutomationRunUseCase
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(sync_automation_run_use_case_exports);
|
|
26
|
-
var
|
|
26
|
+
var import_common = require("nanosaas/common");
|
|
27
27
|
var import_chats = require("../../chats/index.js");
|
|
28
28
|
var import_entities = require("../entities");
|
|
29
29
|
var import_repositories = require("../repositories");
|
|
30
30
|
var import_runner_scope = require("../utils/runner-scope");
|
|
31
31
|
const CHAT_DELETED_MESSAGE = "The chat of this run was deleted while it waited for the user";
|
|
32
32
|
const LOST_WORKER_MESSAGE = "The worker that was running this automation was lost before it finished";
|
|
33
|
-
class SyncAutomationRunUseCase extends
|
|
33
|
+
class SyncAutomationRunUseCase extends import_common.BaseUseCase {
|
|
34
34
|
constructor(automationRepository = new import_repositories.AutomationRepository(), automationRunRepository = new import_repositories.AutomationRunRepository()) {
|
|
35
35
|
super();
|
|
36
36
|
this.automationRepository = automationRepository;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase } from "
|
|
1
|
+
import { BaseUseCase } from "nanosaas/common";
|
|
2
2
|
import { getChatById } from "../../chats/index.js";
|
|
3
3
|
import { AutomationRun } from "../entities";
|
|
4
4
|
import { AutomationRepository, AutomationRunRepository } from "../repositories";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams } from '
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from 'nanosaas/common';
|
|
2
2
|
import { AutomationRunRepository } from '../repositories';
|
|
3
3
|
import { SyncAutomationRunUseCase } from './sync-automation-run.use-case';
|
|
4
4
|
export interface Params extends BaseUseCaseParams {
|
|
@@ -21,12 +21,12 @@ __export(sync_automation_runs_use_case_exports, {
|
|
|
21
21
|
SyncAutomationRunsUseCase: () => SyncAutomationRunsUseCase
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(sync_automation_runs_use_case_exports);
|
|
24
|
-
var
|
|
24
|
+
var import_common = require("nanosaas/common");
|
|
25
25
|
var import_repositories = require("../repositories");
|
|
26
26
|
var import_sync_automation_run = require("./sync-automation-run.use-case");
|
|
27
27
|
var import_runner_scope = require("../utils/runner-scope");
|
|
28
28
|
const DEFAULT_LIMIT = 100;
|
|
29
|
-
class SyncAutomationRunsUseCase extends
|
|
29
|
+
class SyncAutomationRunsUseCase extends import_common.BaseUseCase {
|
|
30
30
|
constructor(automationRunRepository = new import_repositories.AutomationRunRepository(), syncRun = new import_sync_automation_run.SyncAutomationRunUseCase()) {
|
|
31
31
|
super();
|
|
32
32
|
this.automationRunRepository = automationRunRepository;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase } from "
|
|
1
|
+
import { BaseUseCase } from "nanosaas/common";
|
|
2
2
|
import { AutomationRunRepository } from "../repositories";
|
|
3
3
|
import { SyncAutomationRunUseCase } from "./sync-automation-run.use-case";
|
|
4
4
|
import { runnerScope } from "../utils/runner-scope";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams } from '
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from 'nanosaas/common';
|
|
2
2
|
import { AutomationPayload, AutomationProps } from '../entities';
|
|
3
3
|
import { AutomationRepository } from '../repositories';
|
|
4
4
|
export interface Params extends BaseUseCaseParams {
|
|
@@ -21,25 +21,24 @@ __export(update_automation_use_case_exports, {
|
|
|
21
21
|
UpdateAutomationUseCase: () => UpdateAutomationUseCase
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(update_automation_use_case_exports);
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var import_mongo_db = require("../../../common/repositories/mongo-db.repository.js");
|
|
24
|
+
var import_common = require("nanosaas/common");
|
|
25
|
+
var import_db = require("nanosaas/db");
|
|
27
26
|
var import_entities = require("../entities");
|
|
28
|
-
var
|
|
27
|
+
var import_repositories = require("../repositories");
|
|
29
28
|
var import_automation_fields = require("../utils/automation-fields");
|
|
30
|
-
class UpdateAutomationUseCase extends
|
|
31
|
-
constructor(automationRepository = new
|
|
29
|
+
class UpdateAutomationUseCase extends import_common.BaseUseCase {
|
|
30
|
+
constructor(automationRepository = new import_repositories.AutomationRepository()) {
|
|
32
31
|
super();
|
|
33
32
|
this.automationRepository = automationRepository;
|
|
34
33
|
}
|
|
35
34
|
automationRepository;
|
|
36
35
|
async execute(params) {
|
|
37
|
-
const { id, payload,
|
|
36
|
+
const { id, payload, actor } = params;
|
|
38
37
|
if (!payload || Object.keys(payload).length === 0) throw new Error("Payload is required for updating an automation");
|
|
39
|
-
const scope = params.scope ??
|
|
38
|
+
const scope = params.scope ?? import_db.Scope.canEdit(actor);
|
|
40
39
|
const existing = await this.automationRepository.findById(id, scope);
|
|
41
40
|
if (!existing) this.throwHttpError({ statusCode: 404, errorMessage: "{{resource_not_found}}" });
|
|
42
|
-
if (payload.__v !== void 0 && payload.__v !== existing.__v) throw new
|
|
41
|
+
if (payload.__v !== void 0 && payload.__v !== existing.__v) throw new import_db.VersionConflictError();
|
|
43
42
|
const changes = (0, import_automation_fields.readAutomationFields)(payload, { complete: false, triggers: existing.triggers });
|
|
44
43
|
const { modelProvider, modelName, ...rest } = changes;
|
|
45
44
|
const provider = modelProvider === void 0 ? existing.modelProvider : modelProvider;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { BaseUseCase } from "
|
|
2
|
-
import { Scope } from "
|
|
3
|
-
import { VersionConflictError } from "../../../common/repositories/mongo-db.repository.js";
|
|
1
|
+
import { BaseUseCase } from "nanosaas/common";
|
|
2
|
+
import { Scope, VersionConflictError } from "nanosaas/db";
|
|
4
3
|
import { Automation } from "../entities";
|
|
5
4
|
import { AutomationRepository } from "../repositories";
|
|
6
5
|
import { readAutomationFields, assertModel } from "../utils/automation-fields";
|
|
@@ -11,9 +10,9 @@ class UpdateAutomationUseCase extends BaseUseCase {
|
|
|
11
10
|
}
|
|
12
11
|
automationRepository;
|
|
13
12
|
async execute(params) {
|
|
14
|
-
const { id, payload,
|
|
13
|
+
const { id, payload, actor } = params;
|
|
15
14
|
if (!payload || Object.keys(payload).length === 0) throw new Error("Payload is required for updating an automation");
|
|
16
|
-
const scope = params.scope ?? Scope.canEdit(
|
|
15
|
+
const scope = params.scope ?? Scope.canEdit(actor);
|
|
17
16
|
const existing = await this.automationRepository.findById(id, scope);
|
|
18
17
|
if (!existing) this.throwHttpError({ statusCode: 404, errorMessage: "{{resource_not_found}}" });
|
|
19
18
|
if (payload.__v !== void 0 && payload.__v !== existing.__v) throw new VersionConflictError();
|
|
@@ -18,17 +18,19 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var event_token_exports = {};
|
|
20
20
|
__export(event_token_exports, {
|
|
21
|
+
AUTOMATION_EVENT_AUDIENCE: () => AUTOMATION_EVENT_AUDIENCE,
|
|
21
22
|
readEventToken: () => readEventToken,
|
|
22
23
|
signEventToken: () => signEventToken
|
|
23
24
|
});
|
|
24
25
|
module.exports = __toCommonJS(event_token_exports);
|
|
25
26
|
var import_node_crypto = require("node:crypto");
|
|
26
|
-
var
|
|
27
|
+
var import_authentication = require("nanosaas/authentication");
|
|
27
28
|
var import_automation_event_error = require("./automation-event-error");
|
|
29
|
+
const AUTOMATION_EVENT_AUDIENCE = "automation-event";
|
|
28
30
|
function signEventToken(params) {
|
|
29
31
|
const { automationId, tokenVersion, expiresIn } = params;
|
|
30
|
-
return (0,
|
|
31
|
-
audience:
|
|
32
|
+
return (0, import_authentication.signToken)({
|
|
33
|
+
audience: AUTOMATION_EVENT_AUDIENCE,
|
|
32
34
|
subject: automationId,
|
|
33
35
|
jti: (0, import_node_crypto.randomUUID)(),
|
|
34
36
|
claims: { v: tokenVersion },
|
|
@@ -37,16 +39,17 @@ function signEventToken(params) {
|
|
|
37
39
|
}
|
|
38
40
|
function readEventToken(token, options = {}) {
|
|
39
41
|
try {
|
|
40
|
-
const claims = (0,
|
|
41
|
-
if (typeof claims.jti !== "string" || typeof claims.v !== "number") throw new
|
|
42
|
+
const claims = (0, import_authentication.verifyToken)(token, AUTOMATION_EVENT_AUDIENCE, options);
|
|
43
|
+
if (typeof claims.jti !== "string" || typeof claims.v !== "number") throw new import_authentication.TokenError("invalid");
|
|
42
44
|
return { jti: claims.jti, sub: claims.sub, v: claims.v, expiresAt: claims.expiresAt };
|
|
43
45
|
} catch (error) {
|
|
44
|
-
if (error instanceof
|
|
46
|
+
if (error instanceof import_authentication.TokenError) throw new import_automation_event_error.AutomationEventError(error.reason);
|
|
45
47
|
throw error;
|
|
46
48
|
}
|
|
47
49
|
}
|
|
48
50
|
// Annotate the CommonJS export names for ESM import in node:
|
|
49
51
|
0 && (module.exports = {
|
|
52
|
+
AUTOMATION_EVENT_AUDIENCE,
|
|
50
53
|
readEventToken,
|
|
51
54
|
signEventToken
|
|
52
55
|
});
|