openloops 0.5.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 +60 -0
- package/README.md +3 -2
- 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 +7 -25
- package/dist/common/base/base.entity.js +26 -133
- package/dist/common/base/base.entity.mjs +26 -128
- package/dist/common/base/base.use-case.d.ts +3 -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/index.d.ts +1 -0
- package/dist/common/base/index.js +3 -1
- package/dist/common/base/index.mjs +1 -0
- package/dist/common/base/share.d.ts +12 -0
- package/dist/common/base/share.js +45 -0
- package/dist/common/base/share.mjs +20 -0
- 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/index.d.ts +1 -0
- package/dist/common/repositories/index.js +3 -1
- package/dist/common/repositories/index.mjs +1 -0
- package/dist/common/repositories/mongo-db.client.mjs +0 -1
- package/dist/common/repositories/mongo-db.repository.d.ts +42 -11
- package/dist/common/repositories/mongo-db.repository.js +152 -42
- package/dist/common/repositories/mongo-db.repository.mjs +152 -43
- package/dist/common/repositories/scope.d.ts +19 -0
- package/dist/common/repositories/scope.js +63 -0
- package/dist/common/repositories/scope.mjs +39 -0
- 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/admin-only/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/owner-only/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.d.ts +3 -3
- package/dist/services/authentication/repositories/revoked-token.repository.js +9 -20
- package/dist/services/authentication/repositories/revoked-token.repository.mjs +9 -15
- 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 +6 -19
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.mjs +6 -14
- 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 -53
- package/dist/services/authentication/use-cases/login.use-case.mjs +18 -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 -25
- package/dist/services/authentication/use-cases/revoke-token.use-case.mjs +11 -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.d.ts +10 -10
- package/dist/services/automations/repositories/automation-run.repository.js +26 -38
- package/dist/services/automations/repositories/automation-run.repository.mjs +26 -33
- package/dist/services/automations/repositories/automation.repository.d.ts +14 -13
- package/dist/services/automations/repositories/automation.repository.js +52 -54
- package/dist/services/automations/repositories/automation.repository.mjs +52 -49
- package/dist/services/automations/runner/automation-runner.d.ts +3 -0
- 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 +8 -21
- package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.mjs +8 -16
- 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 +11 -26
- package/dist/services/automations/use-cases/claim-due-automations.use-case.mjs +11 -21
- 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 +13 -28
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.mjs +13 -23
- 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 +7 -22
- package/dist/services/automations/use-cases/create-automation.use-case.mjs +6 -16
- 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 +10 -27
- package/dist/services/automations/use-cases/delete-automation.use-case.mjs +9 -21
- 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 +9 -23
- package/dist/services/automations/use-cases/finish-automation-run.use-case.mjs +9 -18
- 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 +8 -21
- package/dist/services/automations/use-cases/get-automation-by-id.use-case.mjs +7 -15
- 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 +8 -22
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.mjs +7 -16
- 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 +8 -20
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.mjs +8 -15
- 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 +7 -19
- package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.mjs +7 -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 +7 -19
- package/dist/services/automations/use-cases/list-automations-by-user.use-case.mjs +7 -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 +15 -29
- package/dist/services/automations/use-cases/receive-automation-event.use-case.mjs +15 -24
- 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 +6 -19
- package/dist/services/automations/use-cases/renew-automation-lease.use-case.mjs +6 -14
- 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 +10 -23
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.mjs +10 -18
- 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 +11 -25
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.mjs +10 -19
- 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 +12 -25
- package/dist/services/automations/use-cases/start-automation-run.use-case.mjs +12 -20
- 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 +13 -27
- package/dist/services/automations/use-cases/sync-automation-run.use-case.mjs +13 -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 +8 -22
- package/dist/services/automations/use-cases/sync-automation-runs.use-case.mjs +8 -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 +13 -26
- package/dist/services/automations/use-cases/update-automation.use-case.mjs +12 -20
- 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.d.ts +2 -0
- package/dist/services/automations/utils/open-run.js +2 -2
- package/dist/services/automations/utils/open-run.mjs +2 -3
- package/dist/services/automations/utils/previous-run.js +4 -3
- package/dist/services/automations/utils/previous-run.mjs +4 -4
- package/dist/services/automations/utils/runner-scope.d.ts +3 -0
- package/dist/{common/base/utils/flatten-object.js → services/automations/utils/runner-scope.js} +10 -23
- package/dist/services/automations/utils/runner-scope.mjs +7 -0
- 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.d.ts +7 -6
- package/dist/services/chats/repositories/chat.repository.js +19 -29
- package/dist/services/chats/repositories/chat.repository.mjs +19 -24
- 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 +7 -22
- package/dist/services/chats/use-cases/create-chat.use-case.mjs +6 -16
- 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 +10 -26
- package/dist/services/chats/use-cases/delete-chat.use-case.mjs +9 -20
- 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 +8 -21
- package/dist/services/chats/use-cases/get-chat-by-id.use-case.mjs +8 -16
- 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 +8 -24
- package/dist/services/chats/use-cases/interrupt-execution.use-case.mjs +7 -18
- 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 +7 -20
- package/dist/services/chats/use-cases/list-chats-by-props.use-case.mjs +7 -15
- 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 +7 -19
- package/dist/services/chats/use-cases/list-chats-by-user.use-case.mjs +7 -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 +10 -30
- package/dist/services/chats/use-cases/update-chat.use-case.mjs +9 -24
- 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.d.ts +7 -6
- package/dist/services/llmcalls/repositories/llmcall.repository.js +19 -29
- package/dist/services/llmcalls/repositories/llmcall.repository.mjs +19 -24
- 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 +7 -22
- package/dist/services/llmcalls/use-cases/create-llmcall.use-case.mjs +6 -16
- 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 +10 -26
- package/dist/services/llmcalls/use-cases/delete-llmcall.use-case.mjs +9 -20
- 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 +8 -21
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.mjs +7 -15
- 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 +8 -21
- package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.mjs +7 -15
- 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 +6 -19
- package/dist/services/llmcalls/use-cases/get-llm-usage-stats.use-case.mjs +6 -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 +9 -21
- package/dist/services/llmcalls/use-cases/get-llmcall-by-id.use-case.mjs +8 -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 +7 -20
- package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.mjs +7 -15
- 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 +9 -25
- package/dist/services/llmcalls/use-cases/update-llmcall.use-case.mjs +8 -19
- 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.d.ts +8 -7
- package/dist/services/mcp-servers/repositories/mcpserver.repository.js +21 -31
- package/dist/services/mcp-servers/repositories/mcpserver.repository.mjs +21 -26
- 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 +7 -24
- package/dist/services/mcp-servers/use-cases/create-mcpserver.use-case.mjs +6 -18
- 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 +11 -26
- package/dist/services/mcp-servers/use-cases/decide-mcpserver-trust.use-case.mjs +10 -20
- 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 +10 -26
- package/dist/services/mcp-servers/use-cases/delete-mcpserver.use-case.mjs +9 -20
- 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 +8 -21
- package/dist/services/mcp-servers/use-cases/get-mcpserver-by-id.use-case.mjs +7 -15
- 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 +7 -20
- package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.mjs +6 -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 +12 -31
- package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.mjs +11 -25
- 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 +13 -27
- package/dist/services/mcp-servers/use-cases/verify-mcpserver-connection.use-case.mjs +12 -21
- 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.d.ts +4 -4
- package/dist/services/tasks/repositories/agent-action.repository.js +12 -26
- package/dist/services/tasks/repositories/agent-action.repository.mjs +12 -21
- package/dist/services/tasks/repositories/agent-task.repository.d.ts +5 -5
- package/dist/services/tasks/repositories/agent-task.repository.js +14 -28
- package/dist/services/tasks/repositories/agent-task.repository.mjs +14 -23
- 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 +7 -22
- package/dist/services/tasks/use-cases/create-agent-action.use-case.mjs +6 -16
- 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 +7 -22
- package/dist/services/tasks/use-cases/create-agent-task.use-case.mjs +6 -16
- 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 +8 -21
- package/dist/services/tasks/use-cases/get-agent-task-by-id.use-case.mjs +7 -15
- 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 +8 -20
- package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.mjs +8 -15
- 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 +8 -20
- package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.mjs +8 -15
- 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 +8 -24
- package/dist/services/tasks/use-cases/update-agent-action.use-case.mjs +7 -18
- 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 +8 -24
- package/dist/services/tasks/use-cases/update-agent-task.use-case.mjs +7 -18
- 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.d.ts +3 -3
- package/dist/services/traces/repositories/agent-trace.repository.js +8 -19
- package/dist/services/traces/repositories/agent-trace.repository.mjs +8 -14
- 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 +8 -26
- package/dist/services/traces/use-cases/create-agent-traces.use-case.mjs +7 -20
- 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 +8 -20
- package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.mjs +8 -15
- package/dist/services/users/entities/user-acquisition.js +4 -17
- package/dist/services/users/entities/user-acquisition.mjs +4 -12
- 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 +4 -17
- package/dist/services/users/entities/user-marketing.mjs +4 -12
- 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 -25
- package/dist/services/users/entities/user.entity.mjs +9 -20
- 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 +10 -7
- package/dist/services/users/repositories/user.repository.js +34 -29
- package/dist/services/users/repositories/user.repository.mjs +34 -24
- 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 -7
- package/dist/services/users/use-cases/create-user.use-case.js +8 -22
- package/dist/services/users/use-cases/create-user.use-case.mjs +7 -16
- 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 +10 -26
- package/dist/services/users/use-cases/delete-user.use-case.mjs +9 -20
- 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 +9 -21
- package/dist/services/users/use-cases/get-user-by-id.use-case.mjs +8 -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 +7 -20
- package/dist/services/users/use-cases/list-users-by-props.use-case.mjs +7 -15
- 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 +11 -26
- package/dist/services/users/use-cases/update-user.use-case.mjs +10 -20
- 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.d.ts +8 -8
- package/dist/services/workspaces/repositories/workspace-item.repository.js +20 -32
- package/dist/services/workspaces/repositories/workspace-item.repository.mjs +20 -27
- 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 +11 -22
- package/dist/services/workspaces/use-cases/delete-workspace-item.use-case.mjs +10 -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 +8 -21
- package/dist/services/workspaces/use-cases/get-workspace-item.use-case.mjs +7 -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 +7 -19
- package/dist/services/workspaces/use-cases/list-workspace-items.use-case.mjs +7 -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 +14 -28
- package/dist/services/workspaces/use-cases/save-workspace-item.use-case.mjs +13 -22
- 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 +7 -19
- package/dist/services/workspaces/use-cases/search-workspace-items.use-case.mjs +7 -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/README.md +2 -1
- package/docs/authentication.md +95 -16
- package/docs/authorization.md +77 -0
- package/docs/automations.md +10 -9
- package/docs/chats.md +1 -1
- package/docs/configuration.md +1 -1
- package/docs/integration-guide.md +9 -11
- package/docs/llms.txt +1 -0
- package/docs/mcp-servers.md +1 -1
- package/docs/usage.md +5 -5
- package/docs/users.md +7 -5
- 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 +4 -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/run-automation-now.ts +3 -1
- package/examples/automations/update-automation.ts +2 -2
- package/examples/chats/delete-chat.ts +1 -1
- 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/create-user.ts +2 -1
- package/examples/users/list-users.ts +1 -0
- 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.mjs +0 -22
- package/dist/common/decorators/admin-only/admin-only.d.ts +0 -2
- package/dist/common/decorators/admin-only/admin-only.js +0 -52
- package/dist/common/decorators/admin-only/admin-only.mjs +0 -28
- package/dist/common/decorators/admin-only/index.d.ts +0 -1
- package/dist/common/decorators/admin-only/index.mjs +0 -1
- package/dist/common/decorators/index.d.ts +0 -3
- package/dist/common/decorators/index.js +0 -26
- package/dist/common/decorators/index.mjs +0 -3
- package/dist/common/decorators/mask-in-logs/index.d.ts +0 -1
- package/dist/common/decorators/mask-in-logs/index.js +0 -22
- 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
- package/dist/common/decorators/owner-only/index.d.ts +0 -1
- package/dist/common/decorators/owner-only/index.mjs +0 -1
- package/dist/common/decorators/owner-only/owner-only.d.ts +0 -2
- package/dist/common/decorators/owner-only/owner-only.js +0 -52
- package/dist/common/decorators/owner-only/owner-only.mjs +0 -28
|
@@ -16,26 +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 list_automations_by_user_use_case_exports = {};
|
|
29
20
|
__export(list_automations_by_user_use_case_exports, {
|
|
30
21
|
ListAutomationsByUserUseCase: () => ListAutomationsByUserUseCase
|
|
31
22
|
});
|
|
32
23
|
module.exports = __toCommonJS(list_automations_by_user_use_case_exports);
|
|
33
|
-
var import_tsyringe = require("tsyringe");
|
|
34
24
|
var import_mongodb = require("mongodb");
|
|
25
|
+
var import_repositories = require("../../../common/repositories/index.js");
|
|
35
26
|
var import_base = require("../../../common/base/base.use-case.js");
|
|
36
27
|
var import_repositories2 = require("../repositories");
|
|
37
|
-
|
|
38
|
-
constructor(automationRepository) {
|
|
28
|
+
class ListAutomationsByUserUseCase extends import_base.BaseUseCase {
|
|
29
|
+
constructor(automationRepository = new import_repositories2.AutomationRepository()) {
|
|
39
30
|
super();
|
|
40
31
|
this.automationRepository = automationRepository;
|
|
41
32
|
}
|
|
@@ -44,17 +35,14 @@ let ListAutomationsByUserUseCase = class extends import_base.BaseUseCase {
|
|
|
44
35
|
const { options, currentUser } = params;
|
|
45
36
|
if (!currentUser?.userId) throw new Error("CurrentUser is required to list the automations");
|
|
46
37
|
const { page = 1, limit = 10, sortBy = { createdAt: -1 } } = options || {};
|
|
47
|
-
const result = await this.automationRepository
|
|
38
|
+
const result = await this.automationRepository._.findManyPaginated({
|
|
39
|
+
scope: params.scope ?? import_repositories.Scope.canView(currentUser),
|
|
48
40
|
where: { ownerId: new import_mongodb.ObjectId(currentUser.userId) },
|
|
49
41
|
options: { page, limit, sortBy }
|
|
50
42
|
});
|
|
51
|
-
return {
|
|
43
|
+
return { items: result?.items ?? [], hasMore: result?.hasMore ?? false };
|
|
52
44
|
}
|
|
53
|
-
}
|
|
54
|
-
ListAutomationsByUserUseCase = __decorateClass([
|
|
55
|
-
(0, import_tsyringe.autoInjectable)(),
|
|
56
|
-
__decorateParam(0, (0, import_tsyringe.inject)(import_repositories2.AutomationRepository))
|
|
57
|
-
], ListAutomationsByUserUseCase);
|
|
45
|
+
}
|
|
58
46
|
// Annotate the CommonJS export names for ESM import in node:
|
|
59
47
|
0 && (module.exports = {
|
|
60
48
|
ListAutomationsByUserUseCase
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__decorateClass,
|
|
3
|
-
__decorateParam
|
|
4
|
-
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
|
-
import { autoInjectable, inject } from "tsyringe";
|
|
6
1
|
import { ObjectId } from "mongodb";
|
|
2
|
+
import { Scope } from "../../../common/repositories/index.js";
|
|
7
3
|
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
8
4
|
import { AutomationRepository } from "../repositories";
|
|
9
|
-
|
|
10
|
-
constructor(automationRepository) {
|
|
5
|
+
class ListAutomationsByUserUseCase extends BaseUseCase {
|
|
6
|
+
constructor(automationRepository = new AutomationRepository()) {
|
|
11
7
|
super();
|
|
12
8
|
this.automationRepository = automationRepository;
|
|
13
9
|
}
|
|
@@ -16,17 +12,14 @@ let ListAutomationsByUserUseCase = class extends BaseUseCase {
|
|
|
16
12
|
const { options, currentUser } = params;
|
|
17
13
|
if (!currentUser?.userId) throw new Error("CurrentUser is required to list the automations");
|
|
18
14
|
const { page = 1, limit = 10, sortBy = { createdAt: -1 } } = options || {};
|
|
19
|
-
const result = await this.automationRepository
|
|
15
|
+
const result = await this.automationRepository._.findManyPaginated({
|
|
16
|
+
scope: params.scope ?? Scope.canView(currentUser),
|
|
20
17
|
where: { ownerId: new ObjectId(currentUser.userId) },
|
|
21
18
|
options: { page, limit, sortBy }
|
|
22
19
|
});
|
|
23
|
-
return {
|
|
20
|
+
return { items: result?.items ?? [], hasMore: result?.hasMore ?? false };
|
|
24
21
|
}
|
|
25
|
-
}
|
|
26
|
-
ListAutomationsByUserUseCase = __decorateClass([
|
|
27
|
-
autoInjectable(),
|
|
28
|
-
__decorateParam(0, inject(AutomationRepository))
|
|
29
|
-
], ListAutomationsByUserUseCase);
|
|
22
|
+
}
|
|
30
23
|
export {
|
|
31
24
|
ListAutomationsByUserUseCase
|
|
32
25
|
};
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { BaseUseCase, BaseUseCaseParams
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams } from '../../../common/base/base.use-case.js';
|
|
2
2
|
export interface Params extends BaseUseCaseParams {
|
|
3
3
|
recurrence: unknown;
|
|
4
4
|
timezone: string;
|
|
5
5
|
count?: number;
|
|
6
6
|
from?: string | Date;
|
|
7
7
|
}
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
}
|
|
8
|
+
export type Output = {
|
|
9
|
+
runs: Date[];
|
|
10
|
+
};
|
|
13
11
|
export declare class PreviewAutomationRunsUseCase extends BaseUseCase<Params, Output> {
|
|
14
12
|
execute(params: Params): Promise<Output>;
|
|
15
13
|
}
|
|
@@ -16,36 +16,24 @@ 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
19
|
var preview_automation_runs_use_case_exports = {};
|
|
28
20
|
__export(preview_automation_runs_use_case_exports, {
|
|
29
21
|
PreviewAutomationRunsUseCase: () => PreviewAutomationRunsUseCase
|
|
30
22
|
});
|
|
31
23
|
module.exports = __toCommonJS(preview_automation_runs_use_case_exports);
|
|
32
|
-
var import_tsyringe = require("tsyringe");
|
|
33
24
|
var import_base = require("../../../common/base/base.use-case.js");
|
|
34
25
|
var import_entities = require("../entities");
|
|
35
26
|
var import_next_run = require("../utils/next-run");
|
|
36
27
|
const DEFAULT_COUNT = 5;
|
|
37
|
-
|
|
28
|
+
class PreviewAutomationRunsUseCase extends import_base.BaseUseCase {
|
|
38
29
|
async execute(params) {
|
|
39
30
|
const recurrence = (0, import_entities.validateRecurrence)(params.recurrence);
|
|
40
31
|
const timezone = (0, import_next_run.assertTimezone)(params.timezone);
|
|
41
32
|
const from = params.from ? new Date(params.from) : /* @__PURE__ */ new Date();
|
|
42
33
|
if (Number.isNaN(from.getTime())) throw new Error("The date to start from is not valid");
|
|
43
|
-
return {
|
|
34
|
+
return { runs: (0, import_next_run.previewNextRuns)(recurrence, timezone, params.count ?? DEFAULT_COUNT, from) };
|
|
44
35
|
}
|
|
45
|
-
}
|
|
46
|
-
PreviewAutomationRunsUseCase = __decorateClass([
|
|
47
|
-
(0, import_tsyringe.autoInjectable)()
|
|
48
|
-
], PreviewAutomationRunsUseCase);
|
|
36
|
+
}
|
|
49
37
|
// Annotate the CommonJS export names for ESM import in node:
|
|
50
38
|
0 && (module.exports = {
|
|
51
39
|
PreviewAutomationRunsUseCase
|
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__decorateClass
|
|
3
|
-
} from "../../../chunk-CF3WOMB3.mjs";
|
|
4
|
-
import { autoInjectable } from "tsyringe";
|
|
5
1
|
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
6
2
|
import { validateRecurrence } from "../entities";
|
|
7
3
|
import { assertTimezone, previewNextRuns } from "../utils/next-run";
|
|
8
4
|
const DEFAULT_COUNT = 5;
|
|
9
|
-
|
|
5
|
+
class PreviewAutomationRunsUseCase extends BaseUseCase {
|
|
10
6
|
async execute(params) {
|
|
11
7
|
const recurrence = validateRecurrence(params.recurrence);
|
|
12
8
|
const timezone = assertTimezone(params.timezone);
|
|
13
9
|
const from = params.from ? new Date(params.from) : /* @__PURE__ */ new Date();
|
|
14
10
|
if (Number.isNaN(from.getTime())) throw new Error("The date to start from is not valid");
|
|
15
|
-
return {
|
|
11
|
+
return { runs: previewNextRuns(recurrence, timezone, params.count ?? DEFAULT_COUNT, from) };
|
|
16
12
|
}
|
|
17
|
-
}
|
|
18
|
-
PreviewAutomationRunsUseCase = __decorateClass([
|
|
19
|
-
autoInjectable()
|
|
20
|
-
], PreviewAutomationRunsUseCase);
|
|
13
|
+
}
|
|
21
14
|
export {
|
|
22
15
|
PreviewAutomationRunsUseCase
|
|
23
16
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
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 type AutomationEventStatus = 'queued' | 'duplicate' | 'skipped';
|
|
@@ -9,15 +9,13 @@ export interface Params extends BaseUseCaseParams {
|
|
|
9
9
|
idempotencyKey?: string;
|
|
10
10
|
now?: Date;
|
|
11
11
|
}
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
}
|
|
12
|
+
export type Output = {
|
|
13
|
+
status: AutomationEventStatus;
|
|
14
|
+
run: AutomationRunProps;
|
|
15
|
+
};
|
|
18
16
|
export declare class ReceiveAutomationEventUseCase extends BaseUseCase<Params, Output> {
|
|
19
|
-
private readonly automationRepository
|
|
20
|
-
private readonly automationRunRepository
|
|
21
|
-
constructor(automationRepository?: AutomationRepository
|
|
17
|
+
private readonly automationRepository;
|
|
18
|
+
private readonly automationRunRepository;
|
|
19
|
+
constructor(automationRepository?: AutomationRepository, automationRunRepository?: AutomationRunRepository);
|
|
22
20
|
execute(params: Params): Promise<Output>;
|
|
23
21
|
}
|
|
@@ -16,21 +16,11 @@ 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 receive_automation_event_use_case_exports = {};
|
|
29
20
|
__export(receive_automation_event_use_case_exports, {
|
|
30
21
|
ReceiveAutomationEventUseCase: () => ReceiveAutomationEventUseCase
|
|
31
22
|
});
|
|
32
23
|
module.exports = __toCommonJS(receive_automation_event_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_authentication = require("../../authentication/index.js");
|
|
36
26
|
var import_repositories = require("../repositories");
|
|
@@ -38,14 +28,15 @@ var import_automation_event_error = require("../utils/automation-event-error");
|
|
|
38
28
|
var import_event_token = require("../utils/event-token");
|
|
39
29
|
var import_open_run = require("../utils/open-run");
|
|
40
30
|
var import_settings = require("../utils/settings");
|
|
31
|
+
var import_runner_scope = require("../utils/runner-scope");
|
|
41
32
|
const MAX_PAYLOAD_CHARS = 5e4;
|
|
42
33
|
const MAX_KEY_CHARS = 200;
|
|
43
34
|
const serialize = (payload) => {
|
|
44
35
|
const text = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
45
36
|
return text || void 0;
|
|
46
37
|
};
|
|
47
|
-
|
|
48
|
-
constructor(automationRepository, automationRunRepository) {
|
|
38
|
+
class ReceiveAutomationEventUseCase extends import_base.BaseUseCase {
|
|
39
|
+
constructor(automationRepository = new import_repositories.AutomationRepository(), automationRunRepository = new import_repositories.AutomationRunRepository()) {
|
|
49
40
|
super();
|
|
50
41
|
this.automationRepository = automationRepository;
|
|
51
42
|
this.automationRunRepository = automationRunRepository;
|
|
@@ -57,41 +48,36 @@ let ReceiveAutomationEventUseCase = class extends import_base.BaseUseCase {
|
|
|
57
48
|
const now = params.now ?? /* @__PURE__ */ new Date();
|
|
58
49
|
const claims = (0, import_event_token.readEventToken)(token);
|
|
59
50
|
if (claims.sub !== automationId) throw new import_automation_event_error.AutomationEventError("invalid");
|
|
60
|
-
const automation = await this.automationRepository.findById(automationId);
|
|
51
|
+
const automation = await this.automationRepository.findById(automationId, import_runner_scope.eventScope);
|
|
61
52
|
if (!automation) throw new import_automation_event_error.AutomationEventError("not_found");
|
|
62
53
|
const event = automation.triggers?.event;
|
|
63
54
|
if (!event || automation.eventTokenVersion !== claims.v) throw new import_automation_event_error.AutomationEventError("invalid");
|
|
64
55
|
if (!event.enabled) throw new import_automation_event_error.AutomationEventError("disabled");
|
|
65
|
-
const {
|
|
56
|
+
const { revoked } = await (0, import_authentication.isTokenRevoked)({ jti: claims.jti });
|
|
66
57
|
if (revoked) throw new import_automation_event_error.AutomationEventError("revoked");
|
|
67
58
|
const payload = serialize(params.payload);
|
|
68
59
|
if (payload && payload.length > MAX_PAYLOAD_CHARS) throw new import_automation_event_error.AutomationEventError("payload_too_large");
|
|
69
60
|
const idempotencyKey = params.idempotencyKey?.trim() || void 0;
|
|
70
61
|
if (idempotencyKey && idempotencyKey.length > MAX_KEY_CHARS) throw new Error(`The idempotency key cannot be longer than ${MAX_KEY_CHARS} characters`);
|
|
71
62
|
if (idempotencyKey) {
|
|
72
|
-
const duplicate = await this.automationRunRepository.findByIdempotencyKey(automationId, idempotencyKey);
|
|
73
|
-
if (duplicate) return {
|
|
63
|
+
const duplicate = await this.automationRunRepository.findByIdempotencyKey(automationId, idempotencyKey, import_runner_scope.eventScope);
|
|
64
|
+
if (duplicate) return { status: "duplicate", run: duplicate };
|
|
74
65
|
}
|
|
75
|
-
if (await this.automationRunRepository.countQueued(automationId) >= (0, import_settings.maxQueuedRuns)()) {
|
|
76
|
-
const skipped = await (0, import_open_run.openRun)(this.automationRunRepository, { automation, trigger: "event", status: "skipped", now, payload, skipReason: "The queue of this automation is full" });
|
|
77
|
-
return {
|
|
66
|
+
if (await this.automationRunRepository.countQueued(automationId, import_runner_scope.eventScope) >= (0, import_settings.maxQueuedRuns)()) {
|
|
67
|
+
const skipped = await (0, import_open_run.openRun)(this.automationRunRepository, { scope: import_runner_scope.eventScope, automation, trigger: "event", status: "skipped", now, payload, skipReason: "The queue of this automation is full" });
|
|
68
|
+
return { status: "skipped", run: skipped.toJSON() };
|
|
78
69
|
}
|
|
79
70
|
try {
|
|
80
|
-
const run = await (0, import_open_run.openRun)(this.automationRunRepository, { automation, trigger: "event", status: "queued", now, payload, idempotencyKey });
|
|
81
|
-
return {
|
|
71
|
+
const run = await (0, import_open_run.openRun)(this.automationRunRepository, { scope: import_runner_scope.eventScope, automation, trigger: "event", status: "queued", now, payload, idempotencyKey });
|
|
72
|
+
return { status: "queued", run: run.toJSON() };
|
|
82
73
|
} catch (error) {
|
|
83
74
|
if (!idempotencyKey || error?.code !== 11e3) throw error;
|
|
84
|
-
const duplicate = await this.automationRunRepository.findByIdempotencyKey(automationId, idempotencyKey);
|
|
75
|
+
const duplicate = await this.automationRunRepository.findByIdempotencyKey(automationId, idempotencyKey, import_runner_scope.eventScope);
|
|
85
76
|
if (!duplicate) throw error;
|
|
86
|
-
return {
|
|
77
|
+
return { status: "duplicate", run: duplicate };
|
|
87
78
|
}
|
|
88
79
|
}
|
|
89
|
-
}
|
|
90
|
-
ReceiveAutomationEventUseCase = __decorateClass([
|
|
91
|
-
(0, import_tsyringe.autoInjectable)(),
|
|
92
|
-
__decorateParam(0, (0, import_tsyringe.inject)(import_repositories.AutomationRepository)),
|
|
93
|
-
__decorateParam(1, (0, import_tsyringe.inject)(import_repositories.AutomationRunRepository))
|
|
94
|
-
], ReceiveAutomationEventUseCase);
|
|
80
|
+
}
|
|
95
81
|
// Annotate the CommonJS export names for ESM import in node:
|
|
96
82
|
0 && (module.exports = {
|
|
97
83
|
ReceiveAutomationEventUseCase
|
|
@@ -1,8 +1,3 @@
|
|
|
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 { isTokenRevoked } from "../../authentication/index.js";
|
|
8
3
|
import { AutomationRepository, AutomationRunRepository } from "../repositories";
|
|
@@ -10,14 +5,15 @@ import { AutomationEventError } from "../utils/automation-event-error";
|
|
|
10
5
|
import { readEventToken } from "../utils/event-token";
|
|
11
6
|
import { openRun } from "../utils/open-run";
|
|
12
7
|
import { maxQueuedRuns } from "../utils/settings";
|
|
8
|
+
import { eventScope } from "../utils/runner-scope";
|
|
13
9
|
const MAX_PAYLOAD_CHARS = 5e4;
|
|
14
10
|
const MAX_KEY_CHARS = 200;
|
|
15
11
|
const serialize = (payload) => {
|
|
16
12
|
const text = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
17
13
|
return text || void 0;
|
|
18
14
|
};
|
|
19
|
-
|
|
20
|
-
constructor(automationRepository, automationRunRepository) {
|
|
15
|
+
class ReceiveAutomationEventUseCase extends BaseUseCase {
|
|
16
|
+
constructor(automationRepository = new AutomationRepository(), automationRunRepository = new AutomationRunRepository()) {
|
|
21
17
|
super();
|
|
22
18
|
this.automationRepository = automationRepository;
|
|
23
19
|
this.automationRunRepository = automationRunRepository;
|
|
@@ -29,41 +25,36 @@ let ReceiveAutomationEventUseCase = class extends BaseUseCase {
|
|
|
29
25
|
const now = params.now ?? /* @__PURE__ */ new Date();
|
|
30
26
|
const claims = readEventToken(token);
|
|
31
27
|
if (claims.sub !== automationId) throw new AutomationEventError("invalid");
|
|
32
|
-
const automation = await this.automationRepository.findById(automationId);
|
|
28
|
+
const automation = await this.automationRepository.findById(automationId, eventScope);
|
|
33
29
|
if (!automation) throw new AutomationEventError("not_found");
|
|
34
30
|
const event = automation.triggers?.event;
|
|
35
31
|
if (!event || automation.eventTokenVersion !== claims.v) throw new AutomationEventError("invalid");
|
|
36
32
|
if (!event.enabled) throw new AutomationEventError("disabled");
|
|
37
|
-
const {
|
|
33
|
+
const { revoked } = await isTokenRevoked({ jti: claims.jti });
|
|
38
34
|
if (revoked) throw new AutomationEventError("revoked");
|
|
39
35
|
const payload = serialize(params.payload);
|
|
40
36
|
if (payload && payload.length > MAX_PAYLOAD_CHARS) throw new AutomationEventError("payload_too_large");
|
|
41
37
|
const idempotencyKey = params.idempotencyKey?.trim() || void 0;
|
|
42
38
|
if (idempotencyKey && idempotencyKey.length > MAX_KEY_CHARS) throw new Error(`The idempotency key cannot be longer than ${MAX_KEY_CHARS} characters`);
|
|
43
39
|
if (idempotencyKey) {
|
|
44
|
-
const duplicate = await this.automationRunRepository.findByIdempotencyKey(automationId, idempotencyKey);
|
|
45
|
-
if (duplicate) return {
|
|
40
|
+
const duplicate = await this.automationRunRepository.findByIdempotencyKey(automationId, idempotencyKey, eventScope);
|
|
41
|
+
if (duplicate) return { status: "duplicate", run: duplicate };
|
|
46
42
|
}
|
|
47
|
-
if (await this.automationRunRepository.countQueued(automationId) >= maxQueuedRuns()) {
|
|
48
|
-
const skipped = await openRun(this.automationRunRepository, { automation, trigger: "event", status: "skipped", now, payload, skipReason: "The queue of this automation is full" });
|
|
49
|
-
return {
|
|
43
|
+
if (await this.automationRunRepository.countQueued(automationId, eventScope) >= maxQueuedRuns()) {
|
|
44
|
+
const skipped = await openRun(this.automationRunRepository, { scope: eventScope, automation, trigger: "event", status: "skipped", now, payload, skipReason: "The queue of this automation is full" });
|
|
45
|
+
return { status: "skipped", run: skipped.toJSON() };
|
|
50
46
|
}
|
|
51
47
|
try {
|
|
52
|
-
const run = await openRun(this.automationRunRepository, { automation, trigger: "event", status: "queued", now, payload, idempotencyKey });
|
|
53
|
-
return {
|
|
48
|
+
const run = await openRun(this.automationRunRepository, { scope: eventScope, automation, trigger: "event", status: "queued", now, payload, idempotencyKey });
|
|
49
|
+
return { status: "queued", run: run.toJSON() };
|
|
54
50
|
} catch (error) {
|
|
55
51
|
if (!idempotencyKey || error?.code !== 11e3) throw error;
|
|
56
|
-
const duplicate = await this.automationRunRepository.findByIdempotencyKey(automationId, idempotencyKey);
|
|
52
|
+
const duplicate = await this.automationRunRepository.findByIdempotencyKey(automationId, idempotencyKey, eventScope);
|
|
57
53
|
if (!duplicate) throw error;
|
|
58
|
-
return {
|
|
54
|
+
return { status: "duplicate", run: duplicate };
|
|
59
55
|
}
|
|
60
56
|
}
|
|
61
|
-
}
|
|
62
|
-
ReceiveAutomationEventUseCase = __decorateClass([
|
|
63
|
-
autoInjectable(),
|
|
64
|
-
__decorateParam(0, inject(AutomationRepository)),
|
|
65
|
-
__decorateParam(1, inject(AutomationRunRepository))
|
|
66
|
-
], ReceiveAutomationEventUseCase);
|
|
57
|
+
}
|
|
67
58
|
export {
|
|
68
59
|
ReceiveAutomationEventUseCase
|
|
69
60
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
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
|
automationId: string;
|
|
@@ -6,13 +6,11 @@ export interface Params extends BaseUseCaseParams {
|
|
|
6
6
|
leaseMs?: number;
|
|
7
7
|
now?: Date;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
}
|
|
9
|
+
export type Output = {
|
|
10
|
+
renewed: boolean;
|
|
11
|
+
};
|
|
14
12
|
export declare class RenewAutomationLeaseUseCase extends BaseUseCase<Params, Output> {
|
|
15
|
-
private readonly automationRepository
|
|
16
|
-
constructor(automationRepository?: AutomationRepository
|
|
13
|
+
private readonly automationRepository;
|
|
14
|
+
constructor(automationRepository?: AutomationRepository);
|
|
17
15
|
execute(params: Params): Promise<Output>;
|
|
18
16
|
}
|
|
@@ -16,26 +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 renew_automation_lease_use_case_exports = {};
|
|
29
20
|
__export(renew_automation_lease_use_case_exports, {
|
|
30
21
|
RenewAutomationLeaseUseCase: () => RenewAutomationLeaseUseCase
|
|
31
22
|
});
|
|
32
23
|
module.exports = __toCommonJS(renew_automation_lease_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_settings = require("../utils/settings");
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
var import_runner_scope = require("../utils/runner-scope");
|
|
28
|
+
class RenewAutomationLeaseUseCase extends import_base.BaseUseCase {
|
|
29
|
+
constructor(automationRepository = new import_repositories.AutomationRepository()) {
|
|
39
30
|
super();
|
|
40
31
|
this.automationRepository = automationRepository;
|
|
41
32
|
}
|
|
@@ -44,14 +35,10 @@ let RenewAutomationLeaseUseCase = class extends import_base.BaseUseCase {
|
|
|
44
35
|
const { automationId, workerId } = params;
|
|
45
36
|
const now = params.now ?? /* @__PURE__ */ new Date();
|
|
46
37
|
const until = new Date(now.getTime() + (params.leaseMs ?? (0, import_settings.leaseMs)()));
|
|
47
|
-
const automation = await this.automationRepository.renewLease(automationId, workerId, until);
|
|
48
|
-
return {
|
|
38
|
+
const automation = await this.automationRepository.renewLease(automationId, workerId, until, import_runner_scope.runnerScope);
|
|
39
|
+
return { renewed: Boolean(automation) };
|
|
49
40
|
}
|
|
50
|
-
}
|
|
51
|
-
RenewAutomationLeaseUseCase = __decorateClass([
|
|
52
|
-
(0, import_tsyringe.autoInjectable)(),
|
|
53
|
-
__decorateParam(0, (0, import_tsyringe.inject)(import_repositories.AutomationRepository))
|
|
54
|
-
], RenewAutomationLeaseUseCase);
|
|
41
|
+
}
|
|
55
42
|
// Annotate the CommonJS export names for ESM import in node:
|
|
56
43
|
0 && (module.exports = {
|
|
57
44
|
RenewAutomationLeaseUseCase
|
|
@@ -1,13 +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 { AutomationRepository } from "../repositories";
|
|
8
3
|
import { leaseMs as defaultLeaseMs } from "../utils/settings";
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
import { runnerScope } from "../utils/runner-scope";
|
|
5
|
+
class RenewAutomationLeaseUseCase extends BaseUseCase {
|
|
6
|
+
constructor(automationRepository = new AutomationRepository()) {
|
|
11
7
|
super();
|
|
12
8
|
this.automationRepository = automationRepository;
|
|
13
9
|
}
|
|
@@ -16,14 +12,10 @@ let RenewAutomationLeaseUseCase = class extends BaseUseCase {
|
|
|
16
12
|
const { automationId, workerId } = params;
|
|
17
13
|
const now = params.now ?? /* @__PURE__ */ new Date();
|
|
18
14
|
const until = new Date(now.getTime() + (params.leaseMs ?? defaultLeaseMs()));
|
|
19
|
-
const automation = await this.automationRepository.renewLease(automationId, workerId, until);
|
|
20
|
-
return {
|
|
15
|
+
const automation = await this.automationRepository.renewLease(automationId, workerId, until, runnerScope);
|
|
16
|
+
return { renewed: Boolean(automation) };
|
|
21
17
|
}
|
|
22
|
-
}
|
|
23
|
-
RenewAutomationLeaseUseCase = __decorateClass([
|
|
24
|
-
autoInjectable(),
|
|
25
|
-
__decorateParam(0, inject(AutomationRepository))
|
|
26
|
-
], RenewAutomationLeaseUseCase);
|
|
18
|
+
}
|
|
27
19
|
export {
|
|
28
20
|
RenewAutomationLeaseUseCase
|
|
29
21
|
};
|
|
@@ -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");
|
|
25
|
+
var import_repositories = require("../../../common/repositories/index.js");
|
|
35
26
|
var import_authentication = require("../../authentication/index.js");
|
|
36
|
-
var
|
|
27
|
+
var import_repositories2 = require("../repositories");
|
|
28
|
+
var import_tokens = require("../../authentication/helpers/tokens.js");
|
|
37
29
|
var import_event_token = require("../utils/event-token");
|
|
38
|
-
|
|
39
|
-
constructor(automationRepository) {
|
|
30
|
+
class RevokeAutomationEventTokenUseCase extends import_base.BaseUseCase {
|
|
31
|
+
constructor(automationRepository = new import_repositories2.AutomationRepository()) {
|
|
40
32
|
super();
|
|
41
33
|
this.automationRepository = automationRepository;
|
|
42
34
|
}
|
|
43
35
|
automationRepository;
|
|
44
36
|
async execute(params) {
|
|
45
37
|
const { id, token, currentUser } = params;
|
|
46
|
-
const automation = await this.automationRepository
|
|
47
|
-
if (!automation)
|
|
48
|
-
if (!currentUser?.isAdmin() && String(automation.ownerId) !== currentUser?.userId) this.throwError403();
|
|
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_repositories.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";
|
|
2
|
+
import { Scope } from "../../../common/repositories/index.js";
|
|
7
3
|
import { revokeToken } from "../../authentication/index.js";
|
|
8
4
|
import { AutomationRepository } from "../repositories";
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
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()) {
|
|
12
9
|
super();
|
|
13
10
|
this.automationRepository = automationRepository;
|
|
14
11
|
}
|
|
15
12
|
automationRepository;
|
|
16
13
|
async execute(params) {
|
|
17
14
|
const { id, token, currentUser } = params;
|
|
18
|
-
const automation = await this.automationRepository
|
|
19
|
-
if (!automation)
|
|
20
|
-
if (!currentUser?.isAdmin() && String(automation.ownerId) !== currentUser?.userId) this.throwError403();
|
|
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
|
};
|