openloops 0.6.0 → 0.7.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 +33 -0
- package/README.md +1 -1
- package/dist/clients/llm/llm-client.mjs +0 -1
- package/dist/clients/llm/llm-error.mjs +0 -1
- package/dist/clients/llm/llm-types.mjs +0 -1
- package/dist/clients/llm/model-resolution.mjs +0 -1
- package/dist/clients/llm/pi-ai-adapter.mjs +0 -1
- package/dist/clients/llm/sampling-rules.mjs +0 -1
- package/dist/clients/serper/serper-client.mjs +0 -1
- package/dist/clients/slack/slack-client.mjs +0 -1
- package/dist/common/base/base.app.d.ts +3 -3
- package/dist/common/base/base.app.mjs +0 -1
- package/dist/common/base/base.entity.d.ts +4 -16
- package/dist/common/base/base.entity.js +11 -39
- package/dist/common/base/base.entity.mjs +11 -40
- package/dist/common/base/base.use-case.d.ts +1 -7
- package/dist/common/base/base.use-case.mjs +0 -1
- package/dist/common/base/current-session.mjs +0 -1
- package/dist/common/base/current-user.mjs +0 -1
- package/dist/common/base/share.mjs +0 -1
- package/dist/common/base/utils/index.d.ts +1 -2
- package/dist/common/base/utils/index.js +2 -4
- package/dist/common/base/utils/index.mjs +1 -2
- package/dist/common/base/utils/is-plain-object.mjs +0 -1
- package/dist/common/base/utils/to-patch.d.ts +9 -0
- package/dist/common/base/utils/to-patch.js +46 -0
- package/dist/common/base/utils/to-patch.mjs +21 -0
- package/dist/common/constants/harness.mjs +0 -1
- package/dist/common/error/http-error.mjs +0 -1
- package/dist/common/error/reportError.mjs +0 -1
- package/dist/common/error/sentry-client.mjs +0 -1
- package/dist/common/helpers/escape-regex.mjs +0 -1
- package/dist/common/helpers/extract-json-from-text.mjs +0 -1
- package/dist/common/helpers/sanitize-string.mjs +0 -1
- package/dist/common/logger/pino.mjs +0 -1
- package/dist/common/repositories/mongo-db.client.mjs +0 -1
- package/dist/common/repositories/mongo-db.repository.d.ts +15 -4
- package/dist/common/repositories/mongo-db.repository.js +44 -15
- package/dist/common/repositories/mongo-db.repository.mjs +44 -16
- package/dist/common/repositories/scope.mjs +0 -1
- package/dist/common/utils/database-name.mjs +0 -1
- package/dist/common/utils/number-setting.mjs +0 -1
- package/dist/common/utils/secret-manager.mjs +0 -1
- package/dist/db/indexes/agent-actions.mjs +0 -1
- package/dist/db/indexes/agent-tasks.mjs +0 -1
- package/dist/db/indexes/agent-traces.mjs +0 -1
- package/dist/db/indexes/automation-runs.mjs +0 -1
- package/dist/db/indexes/automations.mjs +0 -1
- package/dist/db/indexes/chats.mjs +0 -1
- package/dist/db/indexes/index.js +3 -1
- package/dist/db/indexes/index.mjs +3 -2
- package/dist/db/indexes/llm-calls.mjs +0 -1
- package/dist/db/indexes/mcp-servers.mjs +0 -1
- package/dist/db/indexes/refresh-tokens.d.ts +2 -0
- package/dist/{common/decorators/mask-in-logs/index.js → db/indexes/refresh-tokens.js} +16 -5
- package/dist/db/indexes/refresh-tokens.mjs +9 -0
- package/dist/db/indexes/revoked-tokens.mjs +0 -1
- package/dist/db/indexes/workspace-items.mjs +0 -1
- package/dist/db/migrations/automations.mjs +0 -1
- package/dist/guardrails/guard.mjs +0 -1
- package/dist/guardrails/index.mjs +0 -1
- package/dist/guardrails/input/block-card.mjs +0 -1
- package/dist/guardrails/input/block-code.mjs +0 -1
- package/dist/guardrails/input/block-email.mjs +0 -1
- package/dist/guardrails/input/create-block-input-oversize.mjs +0 -1
- package/dist/guardrails/input/diagnostic-sanity.mjs +0 -1
- package/dist/guardrails/input/input-check.mjs +0 -1
- package/dist/harness/agent-loop.mjs +0 -1
- package/dist/harness/agent-state.mjs +0 -1
- package/dist/harness/agent.d.ts +0 -1
- package/dist/harness/agent.js +14 -14
- package/dist/harness/agent.mjs +14 -15
- package/dist/harness/native-tools.mjs +0 -1
- package/dist/harness/skills/approval-request.mjs +0 -1
- package/dist/harness/skills/autonomous-answer.mjs +0 -1
- package/dist/harness/skills/confirmation-gate.mjs +0 -1
- package/dist/harness/skills/mcp-change-review.mjs +0 -1
- package/dist/harness/tool-catalog.mjs +0 -1
- package/dist/harness/tool-pipeline.mjs +0 -1
- package/dist/harness/utils/activity.mjs +0 -1
- package/dist/harness/utils/describe-shape.mjs +0 -1
- package/dist/harness/utils/grounding.mjs +0 -1
- package/dist/harness/utils/rank-tools-by-keywords.mjs +0 -1
- package/dist/harness/workspace.js +7 -7
- package/dist/harness/workspace.mjs +7 -8
- package/dist/loops/agi/loop.mjs +0 -1
- package/dist/loops/agi/skills/reasoning-engine.mjs +0 -1
- package/dist/loops/shared/skills/fast-responder.mjs +0 -1
- package/dist/services/authentication/entities/index.d.ts +1 -0
- package/dist/services/authentication/entities/index.js +3 -1
- package/dist/services/authentication/entities/index.mjs +1 -0
- package/dist/services/authentication/entities/refresh-token.entity.d.ts +25 -0
- package/dist/services/authentication/entities/refresh-token.entity.js +75 -0
- package/dist/services/authentication/entities/refresh-token.entity.mjs +51 -0
- package/dist/services/authentication/entities/revoked-token.entity.mjs +0 -1
- package/dist/services/authentication/helpers/auth-config.d.ts +9 -0
- package/dist/{common/decorators/index.js → services/authentication/helpers/auth-config.js} +19 -5
- package/dist/services/authentication/helpers/auth-config.mjs +12 -0
- package/dist/services/authentication/helpers/session-tokens.d.ts +16 -0
- package/dist/services/authentication/helpers/session-tokens.js +60 -0
- package/dist/services/authentication/helpers/session-tokens.mjs +35 -0
- package/dist/services/authentication/helpers/tokens.d.ts +43 -0
- package/dist/services/authentication/helpers/tokens.js +113 -0
- package/dist/services/authentication/helpers/tokens.mjs +71 -0
- package/dist/services/authentication/index.d.ts +3 -0
- package/dist/services/authentication/index.js +23 -0
- package/dist/services/authentication/index.mjs +11 -0
- package/dist/services/authentication/module.d.ts +12 -3
- package/dist/services/authentication/module.js +40 -7
- package/dist/services/authentication/module.mjs +34 -7
- package/dist/services/authentication/repositories/index.d.ts +1 -0
- package/dist/services/authentication/repositories/index.js +3 -1
- package/dist/services/authentication/repositories/index.mjs +1 -0
- package/dist/services/authentication/repositories/refresh-token.repository.d.ts +10 -0
- package/dist/services/authentication/repositories/refresh-token.repository.js +60 -0
- package/dist/services/authentication/repositories/refresh-token.repository.mjs +36 -0
- package/dist/services/authentication/repositories/revoked-token.repository.js +3 -15
- package/dist/services/authentication/repositories/revoked-token.repository.mjs +3 -10
- package/dist/services/authentication/use-cases/claim-refresh-token.use-case.d.ts +12 -0
- package/dist/services/authentication/use-cases/claim-refresh-token.use-case.js +40 -0
- package/dist/services/authentication/use-cases/claim-refresh-token.use-case.mjs +16 -0
- package/dist/services/authentication/use-cases/create-refresh-token.use-case.d.ts +11 -0
- package/dist/services/authentication/use-cases/create-refresh-token.use-case.js +43 -0
- package/dist/services/authentication/use-cases/create-refresh-token.use-case.mjs +19 -0
- package/dist/services/authentication/use-cases/find-refresh-token-by-hash.use-case.d.ts +11 -0
- package/dist/services/authentication/use-cases/find-refresh-token-by-hash.use-case.js +40 -0
- package/dist/services/authentication/use-cases/find-refresh-token-by-hash.use-case.mjs +16 -0
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.d.ts +6 -8
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.js +4 -18
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.mjs +4 -13
- package/dist/services/authentication/use-cases/issue-password-reset-token.use-case.d.ts +18 -0
- package/dist/services/authentication/use-cases/issue-password-reset-token.use-case.js +49 -0
- package/dist/services/authentication/use-cases/issue-password-reset-token.use-case.mjs +25 -0
- package/dist/services/authentication/use-cases/issue-session.use-case.d.ts +13 -0
- package/dist/services/authentication/use-cases/issue-session.use-case.js +48 -0
- package/dist/services/authentication/use-cases/issue-session.use-case.mjs +24 -0
- package/dist/services/authentication/use-cases/login.use-case.d.ts +11 -11
- package/dist/services/authentication/use-cases/login.use-case.js +18 -54
- package/dist/services/authentication/use-cases/login.use-case.mjs +17 -38
- package/dist/services/authentication/use-cases/logout.use-case.d.ts +14 -0
- package/dist/services/authentication/use-cases/logout.use-case.js +48 -0
- package/dist/services/authentication/use-cases/logout.use-case.mjs +24 -0
- package/dist/services/authentication/use-cases/refresh.use-case.d.ts +23 -0
- package/dist/services/authentication/use-cases/refresh.use-case.js +84 -0
- package/dist/services/authentication/use-cases/refresh.use-case.mjs +60 -0
- package/dist/services/authentication/use-cases/reset-password.use-case.d.ts +15 -0
- package/dist/services/authentication/use-cases/reset-password.use-case.js +61 -0
- package/dist/services/authentication/use-cases/reset-password.use-case.mjs +37 -0
- package/dist/services/authentication/use-cases/revoke-refresh-token-family.use-case.d.ts +11 -0
- package/dist/services/authentication/use-cases/revoke-refresh-token-family.use-case.js +40 -0
- package/dist/services/authentication/use-cases/revoke-refresh-token-family.use-case.mjs +16 -0
- package/dist/services/authentication/use-cases/revoke-token.use-case.d.ts +4 -6
- package/dist/services/authentication/use-cases/revoke-token.use-case.js +12 -26
- package/dist/services/authentication/use-cases/revoke-token.use-case.mjs +10 -19
- package/dist/services/authentication/use-cases/revoke-user-refresh-tokens.use-case.d.ts +13 -0
- package/dist/services/authentication/use-cases/revoke-user-refresh-tokens.use-case.js +40 -0
- package/dist/services/authentication/use-cases/revoke-user-refresh-tokens.use-case.mjs +16 -0
- package/dist/services/automations/entities/automation-run.entity.mjs +0 -1
- package/dist/services/automations/entities/automation.entity.d.ts +1 -0
- package/dist/services/automations/entities/automation.entity.js +2 -1
- package/dist/services/automations/entities/automation.entity.mjs +2 -2
- package/dist/services/automations/entities/recurrence.mjs +0 -1
- package/dist/services/automations/entities/trigger.mjs +0 -1
- package/dist/services/automations/module.d.ts +0 -1
- package/dist/services/automations/module.js +20 -22
- package/dist/services/automations/module.mjs +20 -23
- package/dist/services/automations/repositories/automation-run.repository.js +7 -22
- package/dist/services/automations/repositories/automation-run.repository.mjs +7 -17
- package/dist/services/automations/repositories/automation.repository.js +25 -39
- package/dist/services/automations/repositories/automation.repository.mjs +25 -34
- package/dist/services/automations/runner/automation-runner.js +8 -9
- package/dist/services/automations/runner/automation-runner.mjs +8 -10
- package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.d.ts +4 -6
- package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.js +5 -19
- package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.mjs +5 -14
- package/dist/services/automations/use-cases/claim-due-automations.use-case.d.ts +9 -11
- package/dist/services/automations/use-cases/claim-due-automations.use-case.js +4 -20
- package/dist/services/automations/use-cases/claim-due-automations.use-case.mjs +4 -15
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.d.ts +9 -11
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.js +4 -20
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.mjs +4 -15
- package/dist/services/automations/use-cases/create-automation.use-case.d.ts +4 -6
- package/dist/services/automations/use-cases/create-automation.use-case.js +5 -19
- package/dist/services/automations/use-cases/create-automation.use-case.mjs +5 -14
- package/dist/services/automations/use-cases/delete-automation.use-case.d.ts +6 -6
- package/dist/services/automations/use-cases/delete-automation.use-case.js +8 -22
- package/dist/services/automations/use-cases/delete-automation.use-case.mjs +8 -17
- package/dist/services/automations/use-cases/finish-automation-run.use-case.d.ts +5 -7
- package/dist/services/automations/use-cases/finish-automation-run.use-case.js +5 -20
- package/dist/services/automations/use-cases/finish-automation-run.use-case.mjs +5 -15
- package/dist/services/automations/use-cases/get-automation-by-id.use-case.d.ts +4 -6
- package/dist/services/automations/use-cases/get-automation-by-id.use-case.js +5 -19
- package/dist/services/automations/use-cases/get-automation-by-id.use-case.mjs +5 -14
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.d.ts +7 -9
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.js +6 -20
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.mjs +6 -15
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.d.ts +6 -6
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.js +5 -19
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.mjs +5 -14
- package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.d.ts +6 -6
- package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.js +5 -19
- package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.mjs +5 -14
- package/dist/services/automations/use-cases/list-automations-by-user.use-case.d.ts +6 -6
- package/dist/services/automations/use-cases/list-automations-by-user.use-case.js +5 -19
- package/dist/services/automations/use-cases/list-automations-by-user.use-case.mjs +5 -14
- package/dist/services/automations/use-cases/preview-automation-runs.use-case.d.ts +4 -6
- package/dist/services/automations/use-cases/preview-automation-runs.use-case.js +3 -15
- package/dist/services/automations/use-cases/preview-automation-runs.use-case.mjs +3 -10
- package/dist/services/automations/use-cases/receive-automation-event.use-case.d.ts +8 -10
- package/dist/services/automations/use-cases/receive-automation-event.use-case.js +8 -23
- package/dist/services/automations/use-cases/receive-automation-event.use-case.mjs +8 -18
- package/dist/services/automations/use-cases/renew-automation-lease.use-case.d.ts +6 -8
- package/dist/services/automations/use-cases/renew-automation-lease.use-case.js +4 -18
- package/dist/services/automations/use-cases/renew-automation-lease.use-case.mjs +4 -13
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.d.ts +6 -8
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.js +8 -21
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.mjs +9 -17
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.d.ts +4 -6
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.js +8 -22
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.mjs +8 -17
- package/dist/services/automations/use-cases/start-automation-run.use-case.d.ts +8 -10
- package/dist/services/automations/use-cases/start-automation-run.use-case.js +5 -20
- package/dist/services/automations/use-cases/start-automation-run.use-case.mjs +5 -15
- package/dist/services/automations/use-cases/sync-automation-run.use-case.d.ts +5 -7
- package/dist/services/automations/use-cases/sync-automation-run.use-case.js +12 -27
- package/dist/services/automations/use-cases/sync-automation-run.use-case.mjs +12 -22
- package/dist/services/automations/use-cases/sync-automation-runs.use-case.d.ts +8 -10
- package/dist/services/automations/use-cases/sync-automation-runs.use-case.js +7 -22
- package/dist/services/automations/use-cases/sync-automation-runs.use-case.mjs +7 -17
- package/dist/services/automations/use-cases/update-automation.use-case.d.ts +4 -6
- package/dist/services/automations/use-cases/update-automation.use-case.js +10 -24
- package/dist/services/automations/use-cases/update-automation.use-case.mjs +10 -19
- package/dist/services/automations/utils/automation-event-error.mjs +0 -1
- package/dist/services/automations/utils/automation-fields.mjs +0 -1
- package/dist/services/automations/utils/event-message.mjs +0 -1
- package/dist/services/automations/utils/event-token.d.ts +1 -2
- package/dist/services/automations/utils/event-token.js +9 -35
- package/dist/services/automations/utils/event-token.mjs +9 -25
- package/dist/services/automations/utils/next-run.mjs +0 -1
- package/dist/services/automations/utils/open-run.mjs +0 -1
- package/dist/services/automations/utils/previous-run.js +1 -1
- package/dist/services/automations/utils/previous-run.mjs +1 -2
- package/dist/services/automations/utils/runner-scope.mjs +0 -1
- package/dist/services/automations/utils/settings.mjs +0 -1
- package/dist/services/chats/entities/chat-message.entity.mjs +0 -1
- package/dist/services/chats/entities/chat-settings.entity.mjs +0 -1
- package/dist/services/chats/entities/chat.entity.d.ts +1 -0
- package/dist/services/chats/entities/chat.entity.js +3 -2
- package/dist/services/chats/entities/chat.entity.mjs +3 -3
- package/dist/services/chats/module.d.ts +0 -1
- package/dist/services/chats/module.js +5 -7
- package/dist/services/chats/module.mjs +5 -8
- package/dist/services/chats/repositories/chat.repository.js +5 -20
- package/dist/services/chats/repositories/chat.repository.mjs +5 -15
- package/dist/services/chats/use-cases/create-chat.use-case.d.ts +4 -6
- package/dist/services/chats/use-cases/create-chat.use-case.js +5 -19
- package/dist/services/chats/use-cases/create-chat.use-case.mjs +5 -14
- package/dist/services/chats/use-cases/delete-chat.use-case.d.ts +6 -6
- package/dist/services/chats/use-cases/delete-chat.use-case.js +8 -22
- package/dist/services/chats/use-cases/delete-chat.use-case.mjs +8 -17
- package/dist/services/chats/use-cases/get-chat-by-id.use-case.d.ts +4 -6
- package/dist/services/chats/use-cases/get-chat-by-id.use-case.js +6 -20
- package/dist/services/chats/use-cases/get-chat-by-id.use-case.mjs +6 -15
- package/dist/services/chats/use-cases/interrupt-execution.use-case.d.ts +4 -6
- package/dist/services/chats/use-cases/interrupt-execution.use-case.js +6 -20
- package/dist/services/chats/use-cases/interrupt-execution.use-case.mjs +6 -15
- package/dist/services/chats/use-cases/list-chats-by-props.use-case.d.ts +6 -6
- package/dist/services/chats/use-cases/list-chats-by-props.use-case.js +5 -19
- package/dist/services/chats/use-cases/list-chats-by-props.use-case.mjs +5 -14
- package/dist/services/chats/use-cases/list-chats-by-user.use-case.d.ts +6 -6
- package/dist/services/chats/use-cases/list-chats-by-user.use-case.js +5 -19
- package/dist/services/chats/use-cases/list-chats-by-user.use-case.mjs +5 -14
- package/dist/services/chats/use-cases/update-chat.use-case.d.ts +5 -6
- package/dist/services/chats/use-cases/update-chat.use-case.js +8 -26
- package/dist/services/chats/use-cases/update-chat.use-case.mjs +8 -21
- package/dist/services/chats/utils/deprecated-activity.mjs +0 -1
- package/dist/services/llmcalls/entities/llmcall.entity.mjs +0 -1
- package/dist/services/llmcalls/module.d.ts +0 -1
- package/dist/services/llmcalls/module.js +4 -6
- package/dist/services/llmcalls/module.mjs +4 -7
- package/dist/services/llmcalls/repositories/llmcall.repository.js +5 -20
- package/dist/services/llmcalls/repositories/llmcall.repository.mjs +5 -15
- package/dist/services/llmcalls/use-cases/create-llmcall.use-case.d.ts +4 -6
- package/dist/services/llmcalls/use-cases/create-llmcall.use-case.js +5 -19
- package/dist/services/llmcalls/use-cases/create-llmcall.use-case.mjs +5 -14
- package/dist/services/llmcalls/use-cases/delete-llmcall.use-case.d.ts +6 -6
- package/dist/services/llmcalls/use-cases/delete-llmcall.use-case.js +8 -22
- package/dist/services/llmcalls/use-cases/delete-llmcall.use-case.mjs +8 -17
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.d.ts +4 -6
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.js +5 -19
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.mjs +5 -14
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.d.ts +4 -6
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.js +5 -19
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.mjs +5 -14
- package/dist/services/llmcalls/use-cases/get-llm-usage-stats.use-case.d.ts +4 -6
- package/dist/services/llmcalls/use-cases/get-llm-usage-stats.use-case.js +5 -19
- package/dist/services/llmcalls/use-cases/get-llm-usage-stats.use-case.mjs +5 -14
- package/dist/services/llmcalls/use-cases/get-llmcall-by-id.use-case.d.ts +4 -6
- package/dist/services/llmcalls/use-cases/get-llmcall-by-id.use-case.js +6 -20
- package/dist/services/llmcalls/use-cases/get-llmcall-by-id.use-case.mjs +6 -15
- package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.d.ts +6 -6
- package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.js +5 -19
- package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.mjs +5 -14
- package/dist/services/llmcalls/use-cases/update-llmcall.use-case.d.ts +4 -6
- package/dist/services/llmcalls/use-cases/update-llmcall.use-case.js +7 -21
- package/dist/services/llmcalls/use-cases/update-llmcall.use-case.mjs +7 -16
- package/dist/services/llmcalls/utils/usage-periods.mjs +0 -1
- package/dist/services/llmcalls/utils/usage-totals.mjs +0 -1
- package/dist/services/mcp-servers/entities/mcp-manifest.mjs +0 -1
- package/dist/services/mcp-servers/entities/mcpserver.entity.mjs +0 -1
- package/dist/services/mcp-servers/module.d.ts +0 -1
- package/dist/services/mcp-servers/module.js +8 -10
- package/dist/services/mcp-servers/module.mjs +8 -11
- package/dist/services/mcp-servers/repositories/mcpserver.repository.js +5 -21
- package/dist/services/mcp-servers/repositories/mcpserver.repository.mjs +5 -16
- package/dist/services/mcp-servers/use-cases/create-mcpserver.use-case.d.ts +5 -7
- package/dist/services/mcp-servers/use-cases/create-mcpserver.use-case.js +5 -21
- package/dist/services/mcp-servers/use-cases/create-mcpserver.use-case.mjs +5 -16
- package/dist/services/mcp-servers/use-cases/decide-mcpserver-trust.use-case.d.ts +4 -6
- package/dist/services/mcp-servers/use-cases/decide-mcpserver-trust.use-case.js +7 -21
- package/dist/services/mcp-servers/use-cases/decide-mcpserver-trust.use-case.mjs +7 -16
- package/dist/services/mcp-servers/use-cases/delete-mcpserver.use-case.d.ts +6 -6
- package/dist/services/mcp-servers/use-cases/delete-mcpserver.use-case.js +8 -22
- package/dist/services/mcp-servers/use-cases/delete-mcpserver.use-case.mjs +8 -17
- package/dist/services/mcp-servers/use-cases/get-mcpserver-by-id.use-case.d.ts +4 -6
- package/dist/services/mcp-servers/use-cases/get-mcpserver-by-id.use-case.js +5 -19
- package/dist/services/mcp-servers/use-cases/get-mcpserver-by-id.use-case.mjs +5 -14
- package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.d.ts +6 -6
- package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.js +5 -19
- package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.mjs +5 -14
- package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.d.ts +6 -6
- package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.js +5 -19
- package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.mjs +5 -14
- package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.d.ts +5 -7
- package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.js +9 -25
- package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.mjs +9 -20
- package/dist/services/mcp-servers/use-cases/verify-mcpserver-connection.use-case.d.ts +4 -6
- package/dist/services/mcp-servers/use-cases/verify-mcpserver-connection.use-case.js +9 -23
- package/dist/services/mcp-servers/use-cases/verify-mcpserver-connection.use-case.mjs +9 -18
- package/dist/services/tasks/entities/agent-action.entity.mjs +0 -1
- package/dist/services/tasks/entities/agent-task.entity.mjs +0 -1
- package/dist/services/tasks/module.d.ts +0 -1
- package/dist/services/tasks/module.js +7 -9
- package/dist/services/tasks/module.mjs +7 -10
- package/dist/services/tasks/repositories/agent-action.repository.js +5 -21
- package/dist/services/tasks/repositories/agent-action.repository.mjs +5 -16
- package/dist/services/tasks/repositories/agent-task.repository.js +5 -21
- package/dist/services/tasks/repositories/agent-task.repository.mjs +5 -16
- package/dist/services/tasks/use-cases/create-agent-action.use-case.d.ts +4 -6
- package/dist/services/tasks/use-cases/create-agent-action.use-case.js +5 -19
- package/dist/services/tasks/use-cases/create-agent-action.use-case.mjs +5 -14
- package/dist/services/tasks/use-cases/create-agent-task.use-case.d.ts +4 -6
- package/dist/services/tasks/use-cases/create-agent-task.use-case.js +5 -19
- package/dist/services/tasks/use-cases/create-agent-task.use-case.mjs +5 -14
- package/dist/services/tasks/use-cases/get-agent-task-by-id.use-case.d.ts +4 -6
- package/dist/services/tasks/use-cases/get-agent-task-by-id.use-case.js +5 -19
- package/dist/services/tasks/use-cases/get-agent-task-by-id.use-case.mjs +5 -14
- package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.d.ts +6 -6
- package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.js +5 -19
- package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.mjs +5 -14
- package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.d.ts +6 -6
- package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.js +5 -19
- package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.mjs +5 -14
- package/dist/services/tasks/use-cases/update-agent-action.use-case.d.ts +4 -6
- package/dist/services/tasks/use-cases/update-agent-action.use-case.js +6 -20
- package/dist/services/tasks/use-cases/update-agent-action.use-case.mjs +6 -15
- package/dist/services/tasks/use-cases/update-agent-task.use-case.d.ts +4 -6
- package/dist/services/tasks/use-cases/update-agent-task.use-case.js +6 -20
- package/dist/services/tasks/use-cases/update-agent-task.use-case.mjs +6 -15
- package/dist/services/traces/entities/agent-trace-entry.entity.mjs +0 -1
- package/dist/services/traces/module.d.ts +0 -1
- package/dist/services/traces/module.js +2 -4
- package/dist/services/traces/module.mjs +2 -5
- package/dist/services/traces/repositories/agent-trace.repository.js +3 -15
- package/dist/services/traces/repositories/agent-trace.repository.mjs +3 -10
- package/dist/services/traces/use-cases/create-agent-traces.use-case.d.ts +6 -8
- package/dist/services/traces/use-cases/create-agent-traces.use-case.js +5 -19
- package/dist/services/traces/use-cases/create-agent-traces.use-case.mjs +5 -14
- package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.d.ts +6 -6
- package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.js +5 -19
- package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.mjs +5 -14
- package/dist/services/users/entities/user-acquisition.js +2 -2
- package/dist/services/users/entities/user-acquisition.mjs +2 -3
- package/dist/services/users/entities/user-country.js +2 -2
- package/dist/services/users/entities/user-country.mjs +2 -3
- package/dist/services/users/entities/user-currency.js +2 -2
- package/dist/services/users/entities/user-currency.mjs +2 -3
- package/dist/services/users/entities/user-default-model.js +2 -2
- package/dist/services/users/entities/user-default-model.mjs +2 -3
- package/dist/services/users/entities/user-email.value-object.mjs +0 -1
- package/dist/services/users/entities/user-language.js +2 -2
- package/dist/services/users/entities/user-language.mjs +2 -3
- package/dist/services/users/entities/user-marketing.js +2 -2
- package/dist/services/users/entities/user-marketing.mjs +2 -3
- package/dist/services/users/entities/user-notification-preferences.mjs +0 -1
- package/dist/services/users/entities/user-password.value-object.mjs +0 -1
- package/dist/services/users/entities/user-permissions.mjs +0 -1
- package/dist/services/users/entities/user-preferences.mjs +0 -1
- package/dist/services/users/entities/user-report-preferences.mjs +0 -1
- package/dist/services/users/entities/user-report-schedule.mjs +0 -1
- package/dist/services/users/entities/user-timezone.js +2 -2
- package/dist/services/users/entities/user-timezone.mjs +2 -3
- package/dist/services/users/entities/user.entity.d.ts +1 -0
- package/dist/services/users/entities/user.entity.js +9 -22
- package/dist/services/users/entities/user.entity.mjs +9 -17
- package/dist/services/users/module.d.ts +2 -1
- package/dist/services/users/module.js +12 -7
- package/dist/services/users/module.mjs +11 -8
- package/dist/services/users/repositories/user.repository.d.ts +2 -0
- package/dist/services/users/repositories/user.repository.js +11 -20
- package/dist/services/users/repositories/user.repository.mjs +11 -15
- package/dist/services/users/use-cases/change-password.use-case.d.ts +15 -0
- package/dist/services/users/use-cases/change-password.use-case.js +52 -0
- package/dist/services/users/use-cases/change-password.use-case.mjs +28 -0
- package/dist/services/users/use-cases/create-user.use-case.d.ts +4 -6
- package/dist/services/users/use-cases/create-user.use-case.js +5 -19
- package/dist/services/users/use-cases/create-user.use-case.mjs +5 -14
- package/dist/services/users/use-cases/delete-user.use-case.d.ts +6 -6
- package/dist/services/users/use-cases/delete-user.use-case.js +8 -22
- package/dist/services/users/use-cases/delete-user.use-case.mjs +8 -17
- package/dist/services/users/use-cases/get-user-by-id.use-case.d.ts +4 -6
- package/dist/services/users/use-cases/get-user-by-id.use-case.js +6 -20
- package/dist/services/users/use-cases/get-user-by-id.use-case.mjs +6 -15
- package/dist/services/users/use-cases/list-users-by-props.use-case.d.ts +6 -6
- package/dist/services/users/use-cases/list-users-by-props.use-case.js +5 -19
- package/dist/services/users/use-cases/list-users-by-props.use-case.mjs +5 -14
- package/dist/services/users/use-cases/update-user.use-case.d.ts +4 -6
- package/dist/services/users/use-cases/update-user.use-case.js +9 -22
- package/dist/services/users/use-cases/update-user.use-case.mjs +9 -17
- package/dist/services/users/utils/default-model.mjs +0 -1
- package/dist/services/workspaces/entities/workspace-item.entity.mjs +0 -1
- package/dist/services/workspaces/module.d.ts +0 -1
- package/dist/services/workspaces/module.js +5 -7
- package/dist/services/workspaces/module.mjs +5 -8
- package/dist/services/workspaces/repositories/workspace-item.repository.js +5 -20
- package/dist/services/workspaces/repositories/workspace-item.repository.mjs +5 -15
- package/dist/services/workspaces/use-cases/delete-workspace-item.use-case.d.ts +6 -8
- package/dist/services/workspaces/use-cases/delete-workspace-item.use-case.js +7 -21
- package/dist/services/workspaces/use-cases/delete-workspace-item.use-case.mjs +7 -16
- package/dist/services/workspaces/use-cases/get-workspace-item.use-case.d.ts +4 -6
- package/dist/services/workspaces/use-cases/get-workspace-item.use-case.js +6 -20
- package/dist/services/workspaces/use-cases/get-workspace-item.use-case.mjs +6 -15
- package/dist/services/workspaces/use-cases/list-workspace-items.use-case.d.ts +6 -6
- package/dist/services/workspaces/use-cases/list-workspace-items.use-case.js +5 -19
- package/dist/services/workspaces/use-cases/list-workspace-items.use-case.mjs +5 -14
- package/dist/services/workspaces/use-cases/save-workspace-item.use-case.d.ts +4 -6
- package/dist/services/workspaces/use-cases/save-workspace-item.use-case.js +10 -24
- package/dist/services/workspaces/use-cases/save-workspace-item.use-case.mjs +10 -19
- package/dist/services/workspaces/use-cases/search-workspace-items.use-case.d.ts +6 -6
- package/dist/services/workspaces/use-cases/search-workspace-items.use-case.js +5 -19
- package/dist/services/workspaces/use-cases/search-workspace-items.use-case.mjs +5 -14
- package/dist/skills/call-modes.mjs +0 -1
- package/dist/skills/runtime-context.mjs +0 -1
- package/dist/skills/shared/shared-rules.mjs +0 -1
- package/dist/skills/skill.js +1 -2
- package/dist/skills/skill.mjs +1 -3
- package/dist/tools/core/call-ai/call-ai.skill.mjs +0 -1
- package/dist/tools/core/call-ai/call-ai.tool.mjs +0 -1
- package/dist/tools/core/slack/send-slack-message.tool.mjs +0 -1
- package/dist/tools/core/web-search/web-search.tool.mjs +0 -1
- package/dist/tools/tool.mjs +0 -1
- package/docs/authentication.md +95 -16
- package/docs/authorization.md +1 -1
- package/docs/automations.md +6 -5
- package/docs/chats.md +1 -1
- package/docs/configuration.md +1 -1
- package/docs/integration-guide.md +2 -2
- package/docs/mcp-servers.md +1 -1
- package/docs/usage.md +5 -5
- package/docs/users.md +1 -1
- package/examples/authentication/login.ts +1 -1
- package/examples/automations/create-automation.ts +1 -1
- package/examples/automations/create-event-automation.ts +2 -2
- package/examples/automations/list-automation-runs.ts +2 -2
- package/examples/automations/list-automations.ts +1 -1
- 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 +2 -2
- package/examples/automations/update-automation.ts +2 -2
- package/examples/chats/get-chat-by-id.ts +2 -2
- package/examples/chats/list-autonomous-chats.ts +1 -1
- package/examples/chats/list-chats.ts +1 -1
- package/examples/mcps/decide-mcp.ts +3 -3
- package/examples/mcps/list-all-mcps.ts +1 -1
- package/examples/mcps/verify-mcp.ts +1 -1
- package/examples/usage/get-chat-usage.ts +2 -2
- package/examples/usage/get-message-usage.ts +2 -2
- package/examples/usage/get-usage-stats-by-range.ts +1 -1
- package/examples/usage/get-usage-stats.ts +3 -3
- package/examples/users/set-default-model.ts +1 -1
- package/package.json +2 -4
- package/dist/chunk-CF3WOMB3.mjs +0 -16
- package/dist/common/base/utils/delete-empty-fields.d.ts +0 -1
- package/dist/common/base/utils/delete-empty-fields.js +0 -66
- package/dist/common/base/utils/delete-empty-fields.mjs +0 -43
- package/dist/common/base/utils/flatten-object.d.ts +0 -1
- package/dist/common/base/utils/flatten-object.js +0 -45
- package/dist/common/base/utils/flatten-object.mjs +0 -22
- package/dist/common/decorators/index.d.ts +0 -1
- package/dist/common/decorators/index.mjs +0 -1
- package/dist/common/decorators/mask-in-logs/index.d.ts +0 -1
- package/dist/common/decorators/mask-in-logs/index.mjs +0 -1
- package/dist/common/decorators/mask-in-logs/mask-in-logs.d.ts +0 -2
- package/dist/common/decorators/mask-in-logs/mask-in-logs.js +0 -53
- package/dist/common/decorators/mask-in-logs/mask-in-logs.mjs +0 -29
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from '../../../common/base/base.use-case.js';
|
|
2
2
|
import { AutomationRepository } from '../repositories';
|
|
3
3
|
export interface Params extends BaseUseCaseParams {
|
|
4
4
|
id: string;
|
|
5
5
|
token: string;
|
|
6
6
|
}
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
}
|
|
7
|
+
export type Output = {
|
|
8
|
+
jti: string;
|
|
9
|
+
};
|
|
12
10
|
export declare class RevokeAutomationEventTokenUseCase extends BaseUseCase<Params, Output> {
|
|
13
|
-
private readonly automationRepository
|
|
14
|
-
constructor(automationRepository?: AutomationRepository
|
|
11
|
+
private readonly automationRepository;
|
|
12
|
+
constructor(automationRepository?: AutomationRepository);
|
|
15
13
|
execute(params: Params): Promise<Output>;
|
|
16
14
|
}
|
|
@@ -16,49 +16,36 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
20
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
21
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
22
|
-
if (decorator = decorators[i])
|
|
23
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
24
|
-
if (kind && result) __defProp(target, key, result);
|
|
25
|
-
return result;
|
|
26
|
-
};
|
|
27
|
-
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
28
19
|
var revoke_automation_event_token_use_case_exports = {};
|
|
29
20
|
__export(revoke_automation_event_token_use_case_exports, {
|
|
30
21
|
RevokeAutomationEventTokenUseCase: () => RevokeAutomationEventTokenUseCase
|
|
31
22
|
});
|
|
32
23
|
module.exports = __toCommonJS(revoke_automation_event_token_use_case_exports);
|
|
33
|
-
var import_tsyringe = require("tsyringe");
|
|
34
24
|
var import_base = require("../../../common/base/base.use-case.js");
|
|
35
25
|
var import_repositories = require("../../../common/repositories/index.js");
|
|
36
26
|
var import_authentication = require("../../authentication/index.js");
|
|
37
27
|
var import_repositories2 = require("../repositories");
|
|
28
|
+
var import_tokens = require("../../authentication/helpers/tokens.js");
|
|
38
29
|
var import_event_token = require("../utils/event-token");
|
|
39
|
-
|
|
40
|
-
constructor(automationRepository) {
|
|
30
|
+
class RevokeAutomationEventTokenUseCase extends import_base.BaseUseCase {
|
|
31
|
+
constructor(automationRepository = new import_repositories2.AutomationRepository()) {
|
|
41
32
|
super();
|
|
42
33
|
this.automationRepository = automationRepository;
|
|
43
34
|
}
|
|
44
35
|
automationRepository;
|
|
45
36
|
async execute(params) {
|
|
46
37
|
const { id, token, currentUser } = params;
|
|
47
|
-
const automation = await this.automationRepository
|
|
48
|
-
if (!automation)
|
|
38
|
+
const automation = await this.automationRepository.findById(id, params.scope ?? import_repositories.Scope.canManage(currentUser));
|
|
39
|
+
if (!automation) this.throwHttpError({ statusCode: 404, errorMessage: "{{resource_not_found}}" });
|
|
49
40
|
const claims = (0, import_event_token.readEventToken)(token, { ignoreExpiration: true });
|
|
50
41
|
if (claims.sub !== id) throw new Error("The token does not belong to this automation");
|
|
51
42
|
await (0, import_authentication.revokeToken)({
|
|
52
|
-
payload: { jti: claims.jti, audience:
|
|
43
|
+
payload: { jti: claims.jti, audience: import_tokens.AUTOMATION_EVENT_AUDIENCE, subject: id, expiresAt: claims.expiresAt },
|
|
53
44
|
currentUser
|
|
54
45
|
});
|
|
55
|
-
return {
|
|
46
|
+
return { jti: claims.jti };
|
|
56
47
|
}
|
|
57
|
-
}
|
|
58
|
-
RevokeAutomationEventTokenUseCase = __decorateClass([
|
|
59
|
-
(0, import_tsyringe.autoInjectable)(),
|
|
60
|
-
__decorateParam(0, (0, import_tsyringe.inject)(import_repositories2.AutomationRepository))
|
|
61
|
-
], RevokeAutomationEventTokenUseCase);
|
|
48
|
+
}
|
|
62
49
|
// Annotate the CommonJS export names for ESM import in node:
|
|
63
50
|
0 && (module.exports = {
|
|
64
51
|
RevokeAutomationEventTokenUseCase
|
|
@@ -1,36 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__decorateClass,
|
|
3
|
-
__decorateParam
|
|
4
|
-
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
|
-
import { autoInjectable, inject } from "tsyringe";
|
|
6
1
|
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
7
2
|
import { Scope } from "../../../common/repositories/index.js";
|
|
8
3
|
import { revokeToken } from "../../authentication/index.js";
|
|
9
4
|
import { AutomationRepository } from "../repositories";
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
import { AUTOMATION_EVENT_AUDIENCE } from "../../authentication/helpers/tokens.js";
|
|
6
|
+
import { readEventToken } from "../utils/event-token";
|
|
7
|
+
class RevokeAutomationEventTokenUseCase extends BaseUseCase {
|
|
8
|
+
constructor(automationRepository = new AutomationRepository()) {
|
|
13
9
|
super();
|
|
14
10
|
this.automationRepository = automationRepository;
|
|
15
11
|
}
|
|
16
12
|
automationRepository;
|
|
17
13
|
async execute(params) {
|
|
18
14
|
const { id, token, currentUser } = params;
|
|
19
|
-
const automation = await this.automationRepository
|
|
20
|
-
if (!automation)
|
|
15
|
+
const automation = await this.automationRepository.findById(id, params.scope ?? Scope.canManage(currentUser));
|
|
16
|
+
if (!automation) this.throwHttpError({ statusCode: 404, errorMessage: "{{resource_not_found}}" });
|
|
21
17
|
const claims = readEventToken(token, { ignoreExpiration: true });
|
|
22
18
|
if (claims.sub !== id) throw new Error("The token does not belong to this automation");
|
|
23
19
|
await revokeToken({
|
|
24
|
-
payload: { jti: claims.jti, audience:
|
|
20
|
+
payload: { jti: claims.jti, audience: AUTOMATION_EVENT_AUDIENCE, subject: id, expiresAt: claims.expiresAt },
|
|
25
21
|
currentUser
|
|
26
22
|
});
|
|
27
|
-
return {
|
|
23
|
+
return { jti: claims.jti };
|
|
28
24
|
}
|
|
29
|
-
}
|
|
30
|
-
RevokeAutomationEventTokenUseCase = __decorateClass([
|
|
31
|
-
autoInjectable(),
|
|
32
|
-
__decorateParam(0, inject(AutomationRepository))
|
|
33
|
-
], RevokeAutomationEventTokenUseCase);
|
|
25
|
+
}
|
|
34
26
|
export {
|
|
35
27
|
RevokeAutomationEventTokenUseCase
|
|
36
28
|
};
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from '../../../common/base/base.use-case.js';
|
|
2
2
|
import { AutomationProps } from '../entities';
|
|
3
3
|
import { AutomationRepository } from '../repositories';
|
|
4
4
|
export interface Params extends BaseUseCaseParams {
|
|
5
5
|
id: string;
|
|
6
6
|
}
|
|
7
|
-
export
|
|
8
|
-
data: AutomationProps;
|
|
9
|
-
}
|
|
7
|
+
export type Output = AutomationProps;
|
|
10
8
|
export declare class RotateAutomationEventTokensUseCase extends BaseUseCase<Params, Output> {
|
|
11
|
-
private readonly automationRepository
|
|
12
|
-
constructor(automationRepository?: AutomationRepository
|
|
9
|
+
private readonly automationRepository;
|
|
10
|
+
constructor(automationRepository?: AutomationRepository);
|
|
13
11
|
execute(params: Params): Promise<Output>;
|
|
14
12
|
}
|
|
@@ -16,27 +16,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
20
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
21
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
22
|
-
if (decorator = decorators[i])
|
|
23
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
24
|
-
if (kind && result) __defProp(target, key, result);
|
|
25
|
-
return result;
|
|
26
|
-
};
|
|
27
|
-
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
28
19
|
var rotate_automation_event_tokens_use_case_exports = {};
|
|
29
20
|
__export(rotate_automation_event_tokens_use_case_exports, {
|
|
30
21
|
RotateAutomationEventTokensUseCase: () => RotateAutomationEventTokensUseCase
|
|
31
22
|
});
|
|
32
23
|
module.exports = __toCommonJS(rotate_automation_event_tokens_use_case_exports);
|
|
33
|
-
var import_tsyringe = require("tsyringe");
|
|
34
24
|
var import_base = require("../../../common/base/base.use-case.js");
|
|
35
25
|
var import_repositories = require("../../../common/repositories/index.js");
|
|
36
26
|
var import_entities = require("../entities");
|
|
37
27
|
var import_repositories2 = require("../repositories");
|
|
38
|
-
|
|
39
|
-
constructor(automationRepository) {
|
|
28
|
+
class RotateAutomationEventTokensUseCase extends import_base.BaseUseCase {
|
|
29
|
+
constructor(automationRepository = new import_repositories2.AutomationRepository()) {
|
|
40
30
|
super();
|
|
41
31
|
this.automationRepository = automationRepository;
|
|
42
32
|
}
|
|
@@ -44,19 +34,15 @@ let RotateAutomationEventTokensUseCase = class extends import_base.BaseUseCase {
|
|
|
44
34
|
async execute(params) {
|
|
45
35
|
const { id, currentUser } = params;
|
|
46
36
|
const scope = params.scope ?? import_repositories.Scope.canManage(currentUser);
|
|
47
|
-
const existing = await this.automationRepository
|
|
48
|
-
if (!existing)
|
|
37
|
+
const existing = await this.automationRepository.findById(id, scope);
|
|
38
|
+
if (!existing) this.throwHttpError({ statusCode: 404, errorMessage: "{{resource_not_found}}" });
|
|
49
39
|
if (!existing.triggers?.event) throw new Error("Only an automation with an event trigger has tokens");
|
|
50
40
|
const automation = import_entities.Automation.fromJSON({ ...existing, eventTokenVersion: existing.eventTokenVersion + 1 });
|
|
51
|
-
const result = await this.automationRepository
|
|
52
|
-
if (!result)
|
|
53
|
-
return
|
|
41
|
+
const result = await this.automationRepository.update(automation, scope, { expectedVersion: existing.__v });
|
|
42
|
+
if (!result) this.throwHttpError({ statusCode: 404, errorMessage: "{{resource_not_found}}" });
|
|
43
|
+
return result;
|
|
54
44
|
}
|
|
55
|
-
}
|
|
56
|
-
RotateAutomationEventTokensUseCase = __decorateClass([
|
|
57
|
-
(0, import_tsyringe.autoInjectable)(),
|
|
58
|
-
__decorateParam(0, (0, import_tsyringe.inject)(import_repositories2.AutomationRepository))
|
|
59
|
-
], RotateAutomationEventTokensUseCase);
|
|
45
|
+
}
|
|
60
46
|
// Annotate the CommonJS export names for ESM import in node:
|
|
61
47
|
0 && (module.exports = {
|
|
62
48
|
RotateAutomationEventTokensUseCase
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__decorateClass,
|
|
3
|
-
__decorateParam
|
|
4
|
-
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
|
-
import { autoInjectable, inject } from "tsyringe";
|
|
6
1
|
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
7
2
|
import { Scope } from "../../../common/repositories/index.js";
|
|
8
3
|
import { Automation } from "../entities";
|
|
9
4
|
import { AutomationRepository } from "../repositories";
|
|
10
|
-
|
|
11
|
-
constructor(automationRepository) {
|
|
5
|
+
class RotateAutomationEventTokensUseCase extends BaseUseCase {
|
|
6
|
+
constructor(automationRepository = new AutomationRepository()) {
|
|
12
7
|
super();
|
|
13
8
|
this.automationRepository = automationRepository;
|
|
14
9
|
}
|
|
@@ -16,19 +11,15 @@ let RotateAutomationEventTokensUseCase = class extends BaseUseCase {
|
|
|
16
11
|
async execute(params) {
|
|
17
12
|
const { id, currentUser } = params;
|
|
18
13
|
const scope = params.scope ?? Scope.canManage(currentUser);
|
|
19
|
-
const existing = await this.automationRepository
|
|
20
|
-
if (!existing)
|
|
14
|
+
const existing = await this.automationRepository.findById(id, scope);
|
|
15
|
+
if (!existing) this.throwHttpError({ statusCode: 404, errorMessage: "{{resource_not_found}}" });
|
|
21
16
|
if (!existing.triggers?.event) throw new Error("Only an automation with an event trigger has tokens");
|
|
22
17
|
const automation = Automation.fromJSON({ ...existing, eventTokenVersion: existing.eventTokenVersion + 1 });
|
|
23
|
-
const result = await this.automationRepository
|
|
24
|
-
if (!result)
|
|
25
|
-
return
|
|
18
|
+
const result = await this.automationRepository.update(automation, scope, { expectedVersion: existing.__v });
|
|
19
|
+
if (!result) this.throwHttpError({ statusCode: 404, errorMessage: "{{resource_not_found}}" });
|
|
20
|
+
return result;
|
|
26
21
|
}
|
|
27
|
-
}
|
|
28
|
-
RotateAutomationEventTokensUseCase = __decorateClass([
|
|
29
|
-
autoInjectable(),
|
|
30
|
-
__decorateParam(0, inject(AutomationRepository))
|
|
31
|
-
], RotateAutomationEventTokensUseCase);
|
|
22
|
+
}
|
|
32
23
|
export {
|
|
33
24
|
RotateAutomationEventTokensUseCase
|
|
34
25
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from '../../../common/base/base.use-case.js';
|
|
2
2
|
import { AutomationProps, AutomationRunProps } from '../entities';
|
|
3
3
|
import { AutomationRepository, AutomationRunRepository } from '../repositories';
|
|
4
4
|
export interface Params extends BaseUseCaseParams {
|
|
@@ -7,15 +7,13 @@ export interface Params extends BaseUseCaseParams {
|
|
|
7
7
|
leaseMs?: number;
|
|
8
8
|
now?: Date;
|
|
9
9
|
}
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
}
|
|
10
|
+
export type Output = {
|
|
11
|
+
automation: AutomationProps;
|
|
12
|
+
run: AutomationRunProps;
|
|
13
|
+
};
|
|
16
14
|
export declare class StartAutomationRunUseCase extends BaseUseCase<Params, Output> {
|
|
17
|
-
private readonly automationRepository
|
|
18
|
-
private readonly automationRunRepository
|
|
19
|
-
constructor(automationRepository?: AutomationRepository
|
|
15
|
+
private readonly automationRepository;
|
|
16
|
+
private readonly automationRunRepository;
|
|
17
|
+
constructor(automationRepository?: AutomationRepository, automationRunRepository?: AutomationRunRepository);
|
|
20
18
|
execute(params: Params): Promise<Output>;
|
|
21
19
|
}
|
|
@@ -16,29 +16,19 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
20
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
21
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
22
|
-
if (decorator = decorators[i])
|
|
23
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
24
|
-
if (kind && result) __defProp(target, key, result);
|
|
25
|
-
return result;
|
|
26
|
-
};
|
|
27
|
-
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
28
19
|
var start_automation_run_use_case_exports = {};
|
|
29
20
|
__export(start_automation_run_use_case_exports, {
|
|
30
21
|
StartAutomationRunUseCase: () => StartAutomationRunUseCase
|
|
31
22
|
});
|
|
32
23
|
module.exports = __toCommonJS(start_automation_run_use_case_exports);
|
|
33
|
-
var import_tsyringe = require("tsyringe");
|
|
34
24
|
var import_base = require("../../../common/base/base.use-case.js");
|
|
35
25
|
var import_repositories = require("../repositories");
|
|
36
26
|
var import_open_run = require("../utils/open-run");
|
|
37
27
|
var import_settings = require("../utils/settings");
|
|
38
28
|
var import_runner_scope = require("../utils/runner-scope");
|
|
39
29
|
var import_repositories2 = require("../../../common/repositories/index.js");
|
|
40
|
-
|
|
41
|
-
constructor(automationRepository, automationRunRepository) {
|
|
30
|
+
class StartAutomationRunUseCase extends import_base.BaseUseCase {
|
|
31
|
+
constructor(automationRepository = new import_repositories.AutomationRepository(), automationRunRepository = new import_repositories.AutomationRunRepository()) {
|
|
42
32
|
super();
|
|
43
33
|
this.automationRepository = automationRepository;
|
|
44
34
|
this.automationRunRepository = automationRunRepository;
|
|
@@ -50,19 +40,14 @@ let StartAutomationRunUseCase = class extends import_base.BaseUseCase {
|
|
|
50
40
|
if (!automationId || !workerId) throw new Error("The automation and the worker are required");
|
|
51
41
|
const now = params.now ?? /* @__PURE__ */ new Date();
|
|
52
42
|
const existing = await this.automationRepository.findById(automationId, params.scope ?? import_repositories2.Scope.canEdit(currentUser));
|
|
53
|
-
if (!existing)
|
|
43
|
+
if (!existing) this.throwHttpError({ statusCode: 404, errorMessage: "{{resource_not_found}}" });
|
|
54
44
|
const automation = await this.automationRepository.claimManual({ id: automationId, workerId, now, leaseMs: params.leaseMs ?? (0, import_settings.leaseMs)() }, import_runner_scope.runnerScope);
|
|
55
45
|
if (!automation) throw new Error("The automation is already running");
|
|
56
46
|
const run = await (0, import_open_run.openRun)(this.automationRunRepository, { scope: import_runner_scope.runnerScope, automation, trigger: "manual", status: "running", workerId, now });
|
|
57
47
|
await this.automationRepository.setActiveRun(automationId, workerId, String(run._id), import_runner_scope.runnerScope);
|
|
58
|
-
return {
|
|
48
|
+
return { automation, run: run.toJSON() };
|
|
59
49
|
}
|
|
60
|
-
}
|
|
61
|
-
StartAutomationRunUseCase = __decorateClass([
|
|
62
|
-
(0, import_tsyringe.autoInjectable)(),
|
|
63
|
-
__decorateParam(0, (0, import_tsyringe.inject)(import_repositories.AutomationRepository)),
|
|
64
|
-
__decorateParam(1, (0, import_tsyringe.inject)(import_repositories.AutomationRunRepository))
|
|
65
|
-
], StartAutomationRunUseCase);
|
|
50
|
+
}
|
|
66
51
|
// Annotate the CommonJS export names for ESM import in node:
|
|
67
52
|
0 && (module.exports = {
|
|
68
53
|
StartAutomationRunUseCase
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__decorateClass,
|
|
3
|
-
__decorateParam
|
|
4
|
-
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
|
-
import { autoInjectable, inject } from "tsyringe";
|
|
6
1
|
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
7
2
|
import { AutomationRepository, AutomationRunRepository } from "../repositories";
|
|
8
3
|
import { openRun } from "../utils/open-run";
|
|
9
4
|
import { leaseMs as defaultLeaseMs } from "../utils/settings";
|
|
10
5
|
import { runnerScope } from "../utils/runner-scope";
|
|
11
6
|
import { Scope } from "../../../common/repositories/index.js";
|
|
12
|
-
|
|
13
|
-
constructor(automationRepository, automationRunRepository) {
|
|
7
|
+
class StartAutomationRunUseCase extends BaseUseCase {
|
|
8
|
+
constructor(automationRepository = new AutomationRepository(), automationRunRepository = new AutomationRunRepository()) {
|
|
14
9
|
super();
|
|
15
10
|
this.automationRepository = automationRepository;
|
|
16
11
|
this.automationRunRepository = automationRunRepository;
|
|
@@ -22,19 +17,14 @@ let StartAutomationRunUseCase = class extends BaseUseCase {
|
|
|
22
17
|
if (!automationId || !workerId) throw new Error("The automation and the worker are required");
|
|
23
18
|
const now = params.now ?? /* @__PURE__ */ new Date();
|
|
24
19
|
const existing = await this.automationRepository.findById(automationId, params.scope ?? Scope.canEdit(currentUser));
|
|
25
|
-
if (!existing)
|
|
20
|
+
if (!existing) this.throwHttpError({ statusCode: 404, errorMessage: "{{resource_not_found}}" });
|
|
26
21
|
const automation = await this.automationRepository.claimManual({ id: automationId, workerId, now, leaseMs: params.leaseMs ?? defaultLeaseMs() }, runnerScope);
|
|
27
22
|
if (!automation) throw new Error("The automation is already running");
|
|
28
23
|
const run = await openRun(this.automationRunRepository, { scope: runnerScope, automation, trigger: "manual", status: "running", workerId, now });
|
|
29
24
|
await this.automationRepository.setActiveRun(automationId, workerId, String(run._id), runnerScope);
|
|
30
|
-
return {
|
|
25
|
+
return { automation, run: run.toJSON() };
|
|
31
26
|
}
|
|
32
|
-
}
|
|
33
|
-
StartAutomationRunUseCase = __decorateClass([
|
|
34
|
-
autoInjectable(),
|
|
35
|
-
__decorateParam(0, inject(AutomationRepository)),
|
|
36
|
-
__decorateParam(1, inject(AutomationRunRepository))
|
|
37
|
-
], StartAutomationRunUseCase);
|
|
27
|
+
}
|
|
38
28
|
export {
|
|
39
29
|
StartAutomationRunUseCase
|
|
40
30
|
};
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from '../../../common/base/base.use-case.js';
|
|
2
2
|
import { AutomationRunProps } from '../entities';
|
|
3
3
|
import { AutomationRepository, AutomationRunRepository } from '../repositories';
|
|
4
4
|
export interface Params extends BaseUseCaseParams {
|
|
5
5
|
runId: string;
|
|
6
6
|
now?: Date;
|
|
7
7
|
}
|
|
8
|
-
export
|
|
9
|
-
data: AutomationRunProps | null;
|
|
10
|
-
}
|
|
8
|
+
export type Output = AutomationRunProps | null;
|
|
11
9
|
export declare const LOST_WORKER_MESSAGE = "The worker that was running this automation was lost before it finished";
|
|
12
10
|
export declare class SyncAutomationRunUseCase extends BaseUseCase<Params, Output> {
|
|
13
|
-
private readonly automationRepository
|
|
14
|
-
private readonly automationRunRepository
|
|
15
|
-
constructor(automationRepository?: AutomationRepository
|
|
11
|
+
private readonly automationRepository;
|
|
12
|
+
private readonly automationRunRepository;
|
|
13
|
+
constructor(automationRepository?: AutomationRepository, automationRunRepository?: AutomationRunRepository);
|
|
16
14
|
execute(params: Params): Promise<Output>;
|
|
17
15
|
private syncPaused;
|
|
18
16
|
private syncRunning;
|
|
@@ -16,30 +16,20 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
20
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
21
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
22
|
-
if (decorator = decorators[i])
|
|
23
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
24
|
-
if (kind && result) __defProp(target, key, result);
|
|
25
|
-
return result;
|
|
26
|
-
};
|
|
27
|
-
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
28
19
|
var sync_automation_run_use_case_exports = {};
|
|
29
20
|
__export(sync_automation_run_use_case_exports, {
|
|
30
21
|
LOST_WORKER_MESSAGE: () => LOST_WORKER_MESSAGE,
|
|
31
22
|
SyncAutomationRunUseCase: () => SyncAutomationRunUseCase
|
|
32
23
|
});
|
|
33
24
|
module.exports = __toCommonJS(sync_automation_run_use_case_exports);
|
|
34
|
-
var import_tsyringe = require("tsyringe");
|
|
35
25
|
var import_base = require("../../../common/base/base.use-case.js");
|
|
36
26
|
var import_chats = require("../../chats/index.js");
|
|
37
27
|
var import_entities = require("../entities");
|
|
38
28
|
var import_repositories = require("../repositories");
|
|
39
29
|
var import_runner_scope = require("../utils/runner-scope");
|
|
40
30
|
const LOST_WORKER_MESSAGE = "The worker that was running this automation was lost before it finished";
|
|
41
|
-
|
|
42
|
-
constructor(automationRepository, automationRunRepository) {
|
|
31
|
+
class SyncAutomationRunUseCase extends import_base.BaseUseCase {
|
|
32
|
+
constructor(automationRepository = new import_repositories.AutomationRepository(), automationRunRepository = new import_repositories.AutomationRunRepository()) {
|
|
43
33
|
super();
|
|
44
34
|
this.automationRepository = automationRepository;
|
|
45
35
|
this.automationRunRepository = automationRunRepository;
|
|
@@ -48,38 +38,33 @@ let SyncAutomationRunUseCase = class extends import_base.BaseUseCase {
|
|
|
48
38
|
automationRunRepository;
|
|
49
39
|
async execute(params) {
|
|
50
40
|
const now = params.now ?? /* @__PURE__ */ new Date();
|
|
51
|
-
const run = await this.automationRunRepository
|
|
52
|
-
if (!run) return
|
|
53
|
-
if (run.status === "paused") return
|
|
54
|
-
if (run.status === "running") return
|
|
55
|
-
return
|
|
41
|
+
const run = await this.automationRunRepository.findById(params.runId, import_runner_scope.runnerScope);
|
|
42
|
+
if (!run) return null;
|
|
43
|
+
if (run.status === "paused") return await this.syncPaused(run, now);
|
|
44
|
+
if (run.status === "running") return await this.syncRunning(run, now);
|
|
45
|
+
return run;
|
|
56
46
|
}
|
|
57
47
|
async syncPaused(run, now) {
|
|
58
48
|
if (!run.chatId) return run;
|
|
59
|
-
const
|
|
49
|
+
const chat = await (0, import_chats.getChatById)({ id: String(run.chatId), scope: import_runner_scope.runnerScope });
|
|
60
50
|
const status = chat?.state?.status;
|
|
61
51
|
if (status === "idle") return await this.settle(run, "completed", now);
|
|
62
52
|
if (status === "failed") return await this.settle(run, "failed", now, { code: chat?.state?.lastError?.code, message: chat?.state?.lastError?.message ?? "The run failed" });
|
|
63
53
|
return run;
|
|
64
54
|
}
|
|
65
55
|
async syncRunning(run, now) {
|
|
66
|
-
const automation = run.automationId ? await this.automationRepository
|
|
56
|
+
const automation = run.automationId ? await this.automationRepository.findById(String(run.automationId), import_runner_scope.runnerScope) : null;
|
|
67
57
|
const lockedUntil = automation?.lockedUntil ? new Date(automation.lockedUntil).getTime() : 0;
|
|
68
58
|
if (automation && lockedUntil > now.getTime()) return run;
|
|
69
59
|
return await this.settle(run, "failed", now, { code: "WORKER_LOST", message: LOST_WORKER_MESSAGE });
|
|
70
60
|
}
|
|
71
61
|
async settle(run, status, now, error) {
|
|
72
62
|
const updated = import_entities.AutomationRun.fromJSON({ ...run, status, finishedAt: now, ...error ? { error } : {} });
|
|
73
|
-
const saved = await this.automationRunRepository
|
|
74
|
-
if (run.automationId && run._id) await this.automationRepository
|
|
63
|
+
const saved = await this.automationRunRepository.update(updated, import_runner_scope.runnerScope);
|
|
64
|
+
if (run.automationId && run._id) await this.automationRepository.settleRun(String(run.automationId), String(run._id), status, now, import_runner_scope.runnerScope);
|
|
75
65
|
return saved ?? updated.toJSON();
|
|
76
66
|
}
|
|
77
|
-
}
|
|
78
|
-
SyncAutomationRunUseCase = __decorateClass([
|
|
79
|
-
(0, import_tsyringe.autoInjectable)(),
|
|
80
|
-
__decorateParam(0, (0, import_tsyringe.inject)(import_repositories.AutomationRepository)),
|
|
81
|
-
__decorateParam(1, (0, import_tsyringe.inject)(import_repositories.AutomationRunRepository))
|
|
82
|
-
], SyncAutomationRunUseCase);
|
|
67
|
+
}
|
|
83
68
|
// Annotate the CommonJS export names for ESM import in node:
|
|
84
69
|
0 && (module.exports = {
|
|
85
70
|
LOST_WORKER_MESSAGE,
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__decorateClass,
|
|
3
|
-
__decorateParam
|
|
4
|
-
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
|
-
import { autoInjectable, inject } from "tsyringe";
|
|
6
1
|
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
7
2
|
import { getChatById } from "../../chats/index.js";
|
|
8
3
|
import { AutomationRun } from "../entities";
|
|
9
4
|
import { AutomationRepository, AutomationRunRepository } from "../repositories";
|
|
10
5
|
import { runnerScope } from "../utils/runner-scope";
|
|
11
6
|
const LOST_WORKER_MESSAGE = "The worker that was running this automation was lost before it finished";
|
|
12
|
-
|
|
13
|
-
constructor(automationRepository, automationRunRepository) {
|
|
7
|
+
class SyncAutomationRunUseCase extends BaseUseCase {
|
|
8
|
+
constructor(automationRepository = new AutomationRepository(), automationRunRepository = new AutomationRunRepository()) {
|
|
14
9
|
super();
|
|
15
10
|
this.automationRepository = automationRepository;
|
|
16
11
|
this.automationRunRepository = automationRunRepository;
|
|
@@ -19,38 +14,33 @@ let SyncAutomationRunUseCase = class extends BaseUseCase {
|
|
|
19
14
|
automationRunRepository;
|
|
20
15
|
async execute(params) {
|
|
21
16
|
const now = params.now ?? /* @__PURE__ */ new Date();
|
|
22
|
-
const run = await this.automationRunRepository
|
|
23
|
-
if (!run) return
|
|
24
|
-
if (run.status === "paused") return
|
|
25
|
-
if (run.status === "running") return
|
|
26
|
-
return
|
|
17
|
+
const run = await this.automationRunRepository.findById(params.runId, runnerScope);
|
|
18
|
+
if (!run) return null;
|
|
19
|
+
if (run.status === "paused") return await this.syncPaused(run, now);
|
|
20
|
+
if (run.status === "running") return await this.syncRunning(run, now);
|
|
21
|
+
return run;
|
|
27
22
|
}
|
|
28
23
|
async syncPaused(run, now) {
|
|
29
24
|
if (!run.chatId) return run;
|
|
30
|
-
const
|
|
25
|
+
const chat = await getChatById({ id: String(run.chatId), scope: runnerScope });
|
|
31
26
|
const status = chat?.state?.status;
|
|
32
27
|
if (status === "idle") return await this.settle(run, "completed", now);
|
|
33
28
|
if (status === "failed") return await this.settle(run, "failed", now, { code: chat?.state?.lastError?.code, message: chat?.state?.lastError?.message ?? "The run failed" });
|
|
34
29
|
return run;
|
|
35
30
|
}
|
|
36
31
|
async syncRunning(run, now) {
|
|
37
|
-
const automation = run.automationId ? await this.automationRepository
|
|
32
|
+
const automation = run.automationId ? await this.automationRepository.findById(String(run.automationId), runnerScope) : null;
|
|
38
33
|
const lockedUntil = automation?.lockedUntil ? new Date(automation.lockedUntil).getTime() : 0;
|
|
39
34
|
if (automation && lockedUntil > now.getTime()) return run;
|
|
40
35
|
return await this.settle(run, "failed", now, { code: "WORKER_LOST", message: LOST_WORKER_MESSAGE });
|
|
41
36
|
}
|
|
42
37
|
async settle(run, status, now, error) {
|
|
43
38
|
const updated = AutomationRun.fromJSON({ ...run, status, finishedAt: now, ...error ? { error } : {} });
|
|
44
|
-
const saved = await this.automationRunRepository
|
|
45
|
-
if (run.automationId && run._id) await this.automationRepository
|
|
39
|
+
const saved = await this.automationRunRepository.update(updated, runnerScope);
|
|
40
|
+
if (run.automationId && run._id) await this.automationRepository.settleRun(String(run.automationId), String(run._id), status, now, runnerScope);
|
|
46
41
|
return saved ?? updated.toJSON();
|
|
47
42
|
}
|
|
48
|
-
}
|
|
49
|
-
SyncAutomationRunUseCase = __decorateClass([
|
|
50
|
-
autoInjectable(),
|
|
51
|
-
__decorateParam(0, inject(AutomationRepository)),
|
|
52
|
-
__decorateParam(1, inject(AutomationRunRepository))
|
|
53
|
-
], SyncAutomationRunUseCase);
|
|
43
|
+
}
|
|
54
44
|
export {
|
|
55
45
|
LOST_WORKER_MESSAGE,
|
|
56
46
|
SyncAutomationRunUseCase
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from '../../../common/base/base.use-case.js';
|
|
2
2
|
import { AutomationRunRepository } from '../repositories';
|
|
3
3
|
import { SyncAutomationRunUseCase } from './sync-automation-run.use-case';
|
|
4
4
|
export interface Params extends BaseUseCaseParams {
|
|
5
5
|
limit?: number;
|
|
6
6
|
now?: Date;
|
|
7
7
|
}
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
}
|
|
8
|
+
export type Output = {
|
|
9
|
+
checked: number;
|
|
10
|
+
settled: number;
|
|
11
|
+
};
|
|
14
12
|
export declare class SyncAutomationRunsUseCase extends BaseUseCase<Params, Output> {
|
|
15
|
-
private readonly automationRunRepository
|
|
16
|
-
private readonly syncRun
|
|
17
|
-
constructor(automationRunRepository?: AutomationRunRepository
|
|
13
|
+
private readonly automationRunRepository;
|
|
14
|
+
private readonly syncRun;
|
|
15
|
+
constructor(automationRunRepository?: AutomationRunRepository, syncRun?: SyncAutomationRunUseCase);
|
|
18
16
|
execute(params: Params): Promise<Output>;
|
|
19
17
|
}
|