openloops 0.3.4 → 0.4.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/README.md +9 -8
- package/dist/clients/llm/llm-client.js +6 -5
- package/dist/clients/llm/llm-client.mjs +6 -5
- package/dist/clients/llm/llm-types.d.ts +3 -0
- package/dist/clients/llm/llm-types.js +15 -0
- package/dist/clients/llm/llm-types.mjs +7 -0
- package/dist/db/index.d.ts +1 -0
- package/dist/db/index.js +3 -1
- package/dist/db/index.mjs +1 -0
- package/dist/db/indexes/automation-runs.d.ts +2 -0
- package/dist/db/indexes/automation-runs.js +33 -0
- package/dist/db/indexes/automation-runs.mjs +10 -0
- package/dist/db/indexes/automations.d.ts +2 -0
- package/dist/db/indexes/{agentic-jobs.js → automations.js} +6 -6
- package/dist/db/indexes/{agentic-jobs.mjs → automations.mjs} +2 -2
- package/dist/db/indexes/index.js +6 -4
- package/dist/db/indexes/index.mjs +6 -4
- package/dist/db/indexes/revoked-tokens.d.ts +2 -0
- package/dist/db/indexes/{agentic-job-runs.js → revoked-tokens.js} +8 -9
- package/dist/db/indexes/revoked-tokens.mjs +8 -0
- package/dist/db/migrations/automations.d.ts +12 -0
- package/dist/db/migrations/automations.js +70 -0
- package/dist/db/migrations/automations.mjs +47 -0
- package/dist/harness/agent-loop.d.ts +2 -0
- package/dist/harness/agent.d.ts +1 -0
- package/dist/harness/agent.js +8 -0
- package/dist/harness/agent.mjs +8 -0
- package/dist/loops/agi/loop.js +2 -1
- package/dist/loops/agi/loop.mjs +2 -1
- package/dist/loops/agi/skills/reasoning-engine.js +3 -2
- package/dist/loops/agi/skills/reasoning-engine.mjs +3 -2
- package/dist/loops/shared/skills/fast-responder.js +2 -2
- package/dist/loops/shared/skills/fast-responder.mjs +2 -2
- package/dist/services/authentication/entities/index.d.ts +1 -0
- package/dist/services/authentication/entities/index.js +22 -0
- package/dist/services/authentication/entities/index.mjs +1 -0
- package/dist/services/authentication/entities/revoked-token.entity.d.ts +17 -0
- package/dist/services/authentication/entities/revoked-token.entity.js +67 -0
- package/dist/services/authentication/entities/revoked-token.entity.mjs +44 -0
- package/dist/services/authentication/index.d.ts +1 -0
- package/dist/services/authentication/index.js +3 -1
- package/dist/services/authentication/index.mjs +1 -0
- package/dist/services/authentication/module.d.ts +4 -0
- package/dist/services/authentication/module.js +16 -2
- package/dist/services/authentication/module.mjs +13 -1
- package/dist/services/authentication/repositories/index.d.ts +1 -0
- package/dist/services/{agentic-jobs → authentication}/repositories/index.js +2 -4
- package/dist/services/authentication/repositories/index.mjs +1 -0
- package/dist/services/authentication/repositories/revoked-token.repository.d.ts +7 -0
- package/dist/services/authentication/repositories/revoked-token.repository.js +55 -0
- package/dist/services/authentication/repositories/revoked-token.repository.mjs +26 -0
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.d.ts +15 -0
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.js +55 -0
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.mjs +26 -0
- package/dist/services/authentication/use-cases/revoke-token.use-case.d.ts +14 -0
- package/dist/services/authentication/use-cases/revoke-token.use-case.js +65 -0
- package/dist/services/authentication/use-cases/revoke-token.use-case.mjs +36 -0
- package/dist/services/automations/entities/automation-run.entity.d.ts +46 -0
- package/dist/services/{agentic-jobs/entities/agentic-job-run.entity.js → automations/entities/automation-run.entity.js} +22 -14
- package/dist/services/{agentic-jobs/entities/agentic-job-run.entity.mjs → automations/entities/automation-run.entity.mjs} +18 -10
- package/dist/services/automations/entities/automation.entity.d.ts +38 -0
- package/dist/services/{agentic-jobs/entities/agentic-job.entity.js → automations/entities/automation.entity.js} +17 -17
- package/dist/services/{agentic-jobs/entities/agentic-job.entity.mjs → automations/entities/automation.entity.mjs} +13 -13
- package/dist/services/automations/entities/index.d.ts +4 -0
- package/dist/services/{agentic-jobs → automations}/entities/index.js +6 -4
- package/dist/services/automations/entities/index.mjs +4 -0
- package/dist/services/automations/entities/trigger.d.ts +11 -0
- package/dist/services/automations/entities/trigger.js +49 -0
- package/dist/services/automations/entities/trigger.mjs +26 -0
- package/dist/services/automations/index.d.ts +5 -0
- package/dist/services/{agentic-jobs → automations}/index.js +9 -7
- package/dist/services/automations/index.mjs +5 -0
- package/dist/services/automations/module.d.ts +41 -0
- package/dist/services/automations/module.js +167 -0
- package/dist/services/automations/module.mjs +125 -0
- package/dist/services/automations/repositories/automation-run.repository.d.ts +14 -0
- package/dist/services/{agentic-jobs/repositories/agentic-job-run.repository.js → automations/repositories/automation-run.repository.js} +23 -11
- package/dist/services/{agentic-jobs/repositories/agentic-job-run.repository.mjs → automations/repositories/automation-run.repository.mjs} +19 -7
- package/dist/services/automations/repositories/automation.repository.d.ts +27 -0
- package/dist/services/{agentic-jobs/repositories/agentic-job.repository.js → automations/repositories/automation.repository.js} +17 -17
- package/dist/services/{agentic-jobs/repositories/agentic-job.repository.mjs → automations/repositories/automation.repository.mjs} +13 -13
- package/dist/services/automations/repositories/index.d.ts +2 -0
- package/dist/services/automations/repositories/index.js +24 -0
- package/dist/services/automations/repositories/index.mjs +2 -0
- package/dist/services/automations/runner/automation-runner.d.ts +49 -0
- package/dist/services/{agentic-jobs/runner/agentic-job-runner.js → automations/runner/automation-runner.js} +55 -45
- package/dist/services/{agentic-jobs/runner/agentic-job-runner.mjs → automations/runner/automation-runner.mjs} +50 -40
- package/dist/services/{agentic-jobs/use-cases/attach-agentic-job-run-chat.use-case.d.ts → automations/use-cases/attach-automation-run-chat.use-case.d.ts} +6 -6
- package/dist/services/{agentic-jobs/use-cases/attach-agentic-job-run-chat.use-case.js → automations/use-cases/attach-automation-run-chat.use-case.js} +14 -14
- package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.mjs +29 -0
- package/dist/services/automations/use-cases/claim-due-automations.use-case.d.ts +28 -0
- package/dist/services/{agentic-jobs/use-cases/claim-due-agentic-jobs.use-case.js → automations/use-cases/claim-due-automations.use-case.js} +32 -43
- package/dist/services/automations/use-cases/claim-due-automations.use-case.mjs +70 -0
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.d.ts +27 -0
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.js +106 -0
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.mjs +77 -0
- package/dist/services/automations/use-cases/create-automation.use-case.d.ts +14 -0
- package/dist/services/{agentic-jobs/use-cases/create-agentic-job.use-case.js → automations/use-cases/create-automation.use-case.js} +24 -25
- package/dist/services/automations/use-cases/create-automation.use-case.mjs +43 -0
- package/dist/services/{agentic-jobs/use-cases/delete-agentic-job.use-case.d.ts → automations/use-cases/delete-automation.use-case.d.ts} +6 -6
- package/dist/services/{agentic-jobs/use-cases/delete-agentic-job.use-case.js → automations/use-cases/delete-automation.use-case.js} +17 -17
- package/dist/services/automations/use-cases/delete-automation.use-case.mjs +36 -0
- package/dist/services/{agentic-jobs/use-cases/finish-agentic-job-run.use-case.d.ts → automations/use-cases/finish-automation-run.use-case.d.ts} +8 -8
- package/dist/services/{agentic-jobs/use-cases/finish-agentic-job-run.use-case.js → automations/use-cases/finish-automation-run.use-case.js} +20 -20
- package/dist/services/automations/use-cases/finish-automation-run.use-case.mjs +46 -0
- package/dist/services/{agentic-jobs/use-cases/get-agentic-job-by-id.use-case.d.ts → automations/use-cases/get-automation-by-id.use-case.d.ts} +6 -6
- package/dist/services/{agentic-jobs/use-cases/get-agentic-job-by-id.use-case.js → automations/use-cases/get-automation-by-id.use-case.js} +13 -13
- package/dist/services/automations/use-cases/get-automation-by-id.use-case.mjs +26 -0
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.d.ts +17 -0
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.js +59 -0
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.mjs +30 -0
- package/dist/services/{agentic-jobs/use-cases/list-agentic-job-runs-by-job.use-case.d.ts → automations/use-cases/list-automation-runs-by-automation.use-case.d.ts} +7 -7
- package/dist/services/{agentic-jobs/use-cases/list-agentic-job-runs-by-job.use-case.js → automations/use-cases/list-automation-runs-by-automation.use-case.js} +15 -15
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.mjs +28 -0
- package/dist/services/{agentic-jobs/use-cases/list-agentic-job-runs-by-user.use-case.d.ts → automations/use-cases/list-automation-runs-by-user.use-case.d.ts} +7 -7
- package/dist/services/{agentic-jobs/use-cases/list-agentic-job-runs-by-user.use-case.js → automations/use-cases/list-automation-runs-by-user.use-case.js} +14 -14
- package/dist/services/{agentic-jobs/use-cases/list-agentic-job-runs-by-user.use-case.mjs → automations/use-cases/list-automation-runs-by-user.use-case.mjs} +11 -11
- package/dist/services/{agentic-jobs/use-cases/list-agentic-jobs-by-user.use-case.d.ts → automations/use-cases/list-automations-by-user.use-case.d.ts} +6 -6
- package/dist/services/{agentic-jobs/use-cases/list-agentic-jobs-by-user.use-case.js → automations/use-cases/list-automations-by-user.use-case.js} +14 -14
- package/dist/services/{agentic-jobs/use-cases/list-agentic-jobs-by-user.use-case.mjs → automations/use-cases/list-automations-by-user.use-case.mjs} +11 -11
- package/dist/services/{agentic-jobs/use-cases/preview-agentic-job-runs.use-case.d.ts → automations/use-cases/preview-automation-runs.use-case.d.ts} +1 -1
- package/dist/services/{agentic-jobs/use-cases/preview-agentic-job-runs.use-case.js → automations/use-cases/preview-automation-runs.use-case.js} +8 -8
- package/dist/services/{agentic-jobs/use-cases/preview-agentic-job-runs.use-case.mjs → automations/use-cases/preview-automation-runs.use-case.mjs} +4 -4
- package/dist/services/automations/use-cases/receive-automation-event.use-case.d.ts +23 -0
- package/dist/services/automations/use-cases/receive-automation-event.use-case.js +97 -0
- package/dist/services/automations/use-cases/receive-automation-event.use-case.mjs +68 -0
- package/dist/services/{agentic-jobs/use-cases/renew-agentic-job-lease.use-case.d.ts → automations/use-cases/renew-automation-lease.use-case.d.ts} +5 -5
- package/dist/services/{agentic-jobs/use-cases/renew-agentic-job-lease.use-case.js → automations/use-cases/renew-automation-lease.use-case.js} +15 -15
- package/dist/services/automations/use-cases/renew-automation-lease.use-case.mjs +29 -0
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.d.ts +16 -0
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.js +65 -0
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.mjs +36 -0
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.d.ts +14 -0
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.js +63 -0
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.mjs +34 -0
- package/dist/services/automations/use-cases/start-automation-run.use-case.d.ts +21 -0
- package/dist/services/{agentic-jobs/use-cases/start-agentic-job-run.use-case.js → automations/use-cases/start-automation-run.use-case.js} +24 -24
- package/dist/services/automations/use-cases/start-automation-run.use-case.mjs +38 -0
- package/dist/services/automations/use-cases/sync-automation-run.use-case.d.ts +20 -0
- package/dist/services/{agentic-jobs/use-cases/sync-agentic-job-run.use-case.js → automations/use-cases/sync-automation-run.use-case.js} +23 -23
- package/dist/services/{agentic-jobs/use-cases/sync-agentic-job-run.use-case.mjs → automations/use-cases/sync-automation-run.use-case.mjs} +21 -21
- package/dist/services/{agentic-jobs/use-cases/sync-agentic-job-runs.use-case.d.ts → automations/use-cases/sync-automation-runs.use-case.d.ts} +5 -5
- package/dist/services/{agentic-jobs/use-cases/sync-agentic-job-runs.use-case.js → automations/use-cases/sync-automation-runs.use-case.js} +16 -16
- package/dist/services/{agentic-jobs/use-cases/sync-agentic-job-runs.use-case.mjs → automations/use-cases/sync-automation-runs.use-case.mjs} +13 -13
- package/dist/services/automations/use-cases/update-automation.use-case.d.ts +15 -0
- package/dist/services/{agentic-jobs/use-cases/update-agentic-job.use-case.js → automations/use-cases/update-automation.use-case.js} +27 -27
- package/dist/services/automations/use-cases/update-automation.use-case.mjs +54 -0
- package/dist/services/automations/utils/automation-event-error.d.ts +6 -0
- package/dist/services/automations/utils/automation-event-error.js +37 -0
- package/dist/services/automations/utils/automation-event-error.mjs +14 -0
- package/dist/services/automations/utils/automation-fields.d.ts +14 -0
- package/dist/services/{agentic-jobs/utils/job-fields.js → automations/utils/automation-fields.js} +8 -10
- package/dist/services/{agentic-jobs/utils/job-fields.mjs → automations/utils/automation-fields.mjs} +4 -6
- package/dist/services/automations/utils/event-message.d.ts +1 -0
- package/dist/services/automations/utils/event-message.js +37 -0
- package/dist/services/automations/utils/event-message.mjs +14 -0
- package/dist/services/automations/utils/event-token.d.ts +18 -0
- package/dist/services/automations/utils/event-token.js +78 -0
- package/dist/services/automations/utils/event-token.mjs +43 -0
- package/dist/services/automations/utils/open-run.d.ts +14 -0
- package/dist/services/{agentic-jobs → automations}/utils/open-run.js +10 -8
- package/dist/services/automations/utils/open-run.mjs +26 -0
- package/dist/services/automations/utils/previous-run.d.ts +4 -0
- package/dist/services/automations/utils/previous-run.js +42 -0
- package/dist/services/automations/utils/previous-run.mjs +19 -0
- package/dist/services/{agentic-jobs → automations}/utils/settings.d.ts +1 -0
- package/dist/services/{agentic-jobs → automations}/utils/settings.js +6 -2
- package/dist/services/automations/utils/settings.mjs +13 -0
- package/dist/services/chats/entities/chat-settings.entity.d.ts +5 -1
- package/dist/services/chats/entities/chat-settings.entity.js +10 -3
- package/dist/services/chats/entities/chat-settings.entity.mjs +10 -3
- package/dist/skills/skill.d.ts +2 -1
- package/dist/skills/skill.js +4 -3
- package/dist/skills/skill.mjs +4 -3
- package/docs/README.md +1 -1
- package/docs/agent.md +3 -2
- package/docs/authentication.md +18 -1
- package/docs/automations.md +341 -0
- package/docs/chats.md +1 -1
- package/docs/configuration.md +8 -7
- package/docs/harness.md +1 -1
- package/docs/integration-guide.md +22 -18
- package/docs/llms.txt +1 -1
- package/docs/mcp-servers.md +1 -1
- package/docs/skills.md +1 -1
- package/examples/{agentic-jobs/create-agentic-job.ts → automations/create-automation.ts} +10 -7
- package/examples/automations/create-event-automation.ts +24 -0
- package/examples/{agentic-jobs/list-agentic-job-runs.ts → automations/list-automation-runs.ts} +8 -8
- package/examples/automations/list-automations.ts +25 -0
- package/examples/{agentic-jobs/preview-agentic-job-runs.ts → automations/preview-automation-runs.ts} +2 -2
- package/examples/automations/receive-automation-event.ts +26 -0
- package/examples/automations/revoke-automation-event-token.ts +25 -0
- package/examples/{agentic-jobs/run-agentic-job-now.ts → automations/run-automation-now.ts} +3 -3
- package/examples/{agentic-jobs/run-agentic-job-worker.ts → automations/run-automation-worker.ts} +6 -6
- package/examples/{agentic-jobs/update-agentic-job.ts → automations/update-automation.ts} +10 -10
- package/package.json +14 -13
- package/dist/db/indexes/agentic-job-runs.d.ts +0 -2
- package/dist/db/indexes/agentic-job-runs.mjs +0 -9
- package/dist/db/indexes/agentic-jobs.d.ts +0 -2
- package/dist/services/agentic-jobs/entities/agentic-job-run.entity.d.ts +0 -42
- package/dist/services/agentic-jobs/entities/agentic-job.entity.d.ts +0 -39
- package/dist/services/agentic-jobs/entities/index.d.ts +0 -3
- package/dist/services/agentic-jobs/entities/index.mjs +0 -3
- package/dist/services/agentic-jobs/index.d.ts +0 -4
- package/dist/services/agentic-jobs/index.mjs +0 -4
- package/dist/services/agentic-jobs/module.d.ts +0 -31
- package/dist/services/agentic-jobs/module.js +0 -132
- package/dist/services/agentic-jobs/module.mjs +0 -95
- package/dist/services/agentic-jobs/repositories/agentic-job-run.repository.d.ts +0 -11
- package/dist/services/agentic-jobs/repositories/agentic-job.repository.d.ts +0 -27
- package/dist/services/agentic-jobs/repositories/index.d.ts +0 -2
- package/dist/services/agentic-jobs/repositories/index.mjs +0 -2
- package/dist/services/agentic-jobs/runner/agentic-job-runner.d.ts +0 -48
- package/dist/services/agentic-jobs/use-cases/attach-agentic-job-run-chat.use-case.mjs +0 -29
- package/dist/services/agentic-jobs/use-cases/claim-due-agentic-jobs.use-case.d.ts +0 -29
- package/dist/services/agentic-jobs/use-cases/claim-due-agentic-jobs.use-case.mjs +0 -81
- package/dist/services/agentic-jobs/use-cases/create-agentic-job.use-case.d.ts +0 -14
- package/dist/services/agentic-jobs/use-cases/create-agentic-job.use-case.mjs +0 -44
- package/dist/services/agentic-jobs/use-cases/delete-agentic-job.use-case.mjs +0 -36
- package/dist/services/agentic-jobs/use-cases/finish-agentic-job-run.use-case.mjs +0 -46
- package/dist/services/agentic-jobs/use-cases/get-agentic-job-by-id.use-case.mjs +0 -26
- package/dist/services/agentic-jobs/use-cases/list-agentic-job-runs-by-job.use-case.mjs +0 -28
- package/dist/services/agentic-jobs/use-cases/renew-agentic-job-lease.use-case.mjs +0 -29
- package/dist/services/agentic-jobs/use-cases/start-agentic-job-run.use-case.d.ts +0 -21
- package/dist/services/agentic-jobs/use-cases/start-agentic-job-run.use-case.mjs +0 -38
- package/dist/services/agentic-jobs/use-cases/sync-agentic-job-run.use-case.d.ts +0 -20
- package/dist/services/agentic-jobs/use-cases/update-agentic-job.use-case.d.ts +0 -15
- package/dist/services/agentic-jobs/use-cases/update-agentic-job.use-case.mjs +0 -54
- package/dist/services/agentic-jobs/utils/job-fields.d.ts +0 -14
- package/dist/services/agentic-jobs/utils/open-run.d.ts +0 -12
- package/dist/services/agentic-jobs/utils/open-run.mjs +0 -24
- package/dist/services/agentic-jobs/utils/settings.mjs +0 -10
- package/docs/agentic-jobs.md +0 -217
- package/examples/agentic-jobs/list-agentic-jobs.ts +0 -25
- /package/dist/services/{agentic-jobs → automations}/entities/recurrence.d.ts +0 -0
- /package/dist/services/{agentic-jobs → automations}/entities/recurrence.js +0 -0
- /package/dist/services/{agentic-jobs → automations}/entities/recurrence.mjs +0 -0
- /package/dist/services/{agentic-jobs → automations}/utils/next-run.d.ts +0 -0
- /package/dist/services/{agentic-jobs → automations}/utils/next-run.js +0 -0
- /package/dist/services/{agentic-jobs → automations}/utils/next-run.mjs +0 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__decorateClass,
|
|
3
|
+
__decorateParam
|
|
4
|
+
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
|
+
import { autoInjectable, inject } from "tsyringe";
|
|
6
|
+
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
7
|
+
import { Automation } from "../entities";
|
|
8
|
+
import { AutomationRepository } from "../repositories";
|
|
9
|
+
let DeleteAutomationUseCase = class extends BaseUseCase {
|
|
10
|
+
constructor(automationRepository) {
|
|
11
|
+
super();
|
|
12
|
+
this.automationRepository = automationRepository;
|
|
13
|
+
}
|
|
14
|
+
automationRepository;
|
|
15
|
+
async execute(params) {
|
|
16
|
+
const { id, hardDelete, currentUser } = params;
|
|
17
|
+
if (!id) throw new Error("Missing id");
|
|
18
|
+
if (hardDelete) {
|
|
19
|
+
if (!currentUser?.isAdmin()) this.throwError403();
|
|
20
|
+
const result2 = await this.automationRepository?.deleteById(id);
|
|
21
|
+
return { data: { deletedCount: result2 } };
|
|
22
|
+
}
|
|
23
|
+
const automation = Automation.fromJSON({ _id: id });
|
|
24
|
+
automation.setDeletedBy(currentUser);
|
|
25
|
+
automation.unset(["nextRunAt"]);
|
|
26
|
+
const result = await this.automationRepository?.update(automation);
|
|
27
|
+
return { data: result };
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
DeleteAutomationUseCase = __decorateClass([
|
|
31
|
+
autoInjectable(),
|
|
32
|
+
__decorateParam(0, inject(AutomationRepository))
|
|
33
|
+
], DeleteAutomationUseCase);
|
|
34
|
+
export {
|
|
35
|
+
DeleteAutomationUseCase
|
|
36
|
+
};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { BaseUseCase, BaseUseCaseParams, BaseUseCaseOutput } from '../../../common/base/base.use-case.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { AutomationRunError, AutomationRunProps } from '../entities';
|
|
3
|
+
import { AutomationRepository, AutomationRunRepository } from '../repositories';
|
|
4
4
|
export interface Params extends BaseUseCaseParams {
|
|
5
5
|
runId: string;
|
|
6
6
|
workerId: string;
|
|
7
7
|
status: 'completed' | 'paused' | 'failed';
|
|
8
|
-
error?:
|
|
8
|
+
error?: AutomationRunError;
|
|
9
9
|
now?: Date;
|
|
10
10
|
}
|
|
11
11
|
export interface Output extends BaseUseCaseOutput {
|
|
12
|
-
data:
|
|
12
|
+
data: AutomationRunProps | null;
|
|
13
13
|
}
|
|
14
|
-
export declare class
|
|
15
|
-
private readonly
|
|
16
|
-
private readonly
|
|
17
|
-
constructor(
|
|
14
|
+
export declare class FinishAutomationRunUseCase extends BaseUseCase<Params, Output> {
|
|
15
|
+
private readonly automationRepository?;
|
|
16
|
+
private readonly automationRunRepository?;
|
|
17
|
+
constructor(automationRepository?: AutomationRepository | undefined, automationRunRepository?: AutomationRunRepository | undefined);
|
|
18
18
|
execute(params: Params): Promise<Output>;
|
|
19
19
|
}
|
|
@@ -25,37 +25,37 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
25
25
|
return result;
|
|
26
26
|
};
|
|
27
27
|
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
28
|
-
var
|
|
29
|
-
__export(
|
|
30
|
-
|
|
28
|
+
var finish_automation_run_use_case_exports = {};
|
|
29
|
+
__export(finish_automation_run_use_case_exports, {
|
|
30
|
+
FinishAutomationRunUseCase: () => FinishAutomationRunUseCase
|
|
31
31
|
});
|
|
32
|
-
module.exports = __toCommonJS(
|
|
32
|
+
module.exports = __toCommonJS(finish_automation_run_use_case_exports);
|
|
33
33
|
var import_tsyringe = require("tsyringe");
|
|
34
34
|
var import_base = require("../../../common/base/base.use-case.js");
|
|
35
35
|
var import_entities = require("../entities");
|
|
36
36
|
var import_repositories = require("../repositories");
|
|
37
|
-
let
|
|
38
|
-
constructor(
|
|
37
|
+
let FinishAutomationRunUseCase = class extends import_base.BaseUseCase {
|
|
38
|
+
constructor(automationRepository, automationRunRepository) {
|
|
39
39
|
super();
|
|
40
|
-
this.
|
|
41
|
-
this.
|
|
40
|
+
this.automationRepository = automationRepository;
|
|
41
|
+
this.automationRunRepository = automationRunRepository;
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
automationRepository;
|
|
44
|
+
automationRunRepository;
|
|
45
45
|
async execute(params) {
|
|
46
46
|
const { runId, workerId, status, error } = params;
|
|
47
47
|
const now = params.now ?? /* @__PURE__ */ new Date();
|
|
48
|
-
const run = await this.
|
|
48
|
+
const run = await this.automationRunRepository.findById(runId);
|
|
49
49
|
if (!run) return { data: null };
|
|
50
|
-
const finished = import_entities.
|
|
50
|
+
const finished = import_entities.AutomationRun.fromJSON({
|
|
51
51
|
...run,
|
|
52
52
|
status,
|
|
53
53
|
...status === "paused" ? {} : { finishedAt: now },
|
|
54
54
|
...error ? { error } : {}
|
|
55
55
|
});
|
|
56
|
-
const saved = await this.
|
|
57
|
-
if (run.
|
|
58
|
-
await this.
|
|
56
|
+
const saved = await this.automationRunRepository.update(finished);
|
|
57
|
+
if (run.automationId) {
|
|
58
|
+
await this.automationRepository.release(String(run.automationId), workerId, {
|
|
59
59
|
lastRunAt: now,
|
|
60
60
|
lastRunStatus: status,
|
|
61
61
|
...status === "paused" ? { activeRunId: run._id } : {}
|
|
@@ -64,12 +64,12 @@ let FinishAgenticJobRunUseCase = class extends import_base.BaseUseCase {
|
|
|
64
64
|
return { data: saved ?? finished.toJSON() };
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
-
|
|
67
|
+
FinishAutomationRunUseCase = __decorateClass([
|
|
68
68
|
(0, import_tsyringe.autoInjectable)(),
|
|
69
|
-
__decorateParam(0, (0, import_tsyringe.inject)(import_repositories.
|
|
70
|
-
__decorateParam(1, (0, import_tsyringe.inject)(import_repositories.
|
|
71
|
-
],
|
|
69
|
+
__decorateParam(0, (0, import_tsyringe.inject)(import_repositories.AutomationRepository)),
|
|
70
|
+
__decorateParam(1, (0, import_tsyringe.inject)(import_repositories.AutomationRunRepository))
|
|
71
|
+
], FinishAutomationRunUseCase);
|
|
72
72
|
// Annotate the CommonJS export names for ESM import in node:
|
|
73
73
|
0 && (module.exports = {
|
|
74
|
-
|
|
74
|
+
FinishAutomationRunUseCase
|
|
75
75
|
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__decorateClass,
|
|
3
|
+
__decorateParam
|
|
4
|
+
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
|
+
import { autoInjectable, inject } from "tsyringe";
|
|
6
|
+
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
7
|
+
import { AutomationRun } from "../entities";
|
|
8
|
+
import { AutomationRepository, AutomationRunRepository } from "../repositories";
|
|
9
|
+
let FinishAutomationRunUseCase = class extends BaseUseCase {
|
|
10
|
+
constructor(automationRepository, automationRunRepository) {
|
|
11
|
+
super();
|
|
12
|
+
this.automationRepository = automationRepository;
|
|
13
|
+
this.automationRunRepository = automationRunRepository;
|
|
14
|
+
}
|
|
15
|
+
automationRepository;
|
|
16
|
+
automationRunRepository;
|
|
17
|
+
async execute(params) {
|
|
18
|
+
const { runId, workerId, status, error } = params;
|
|
19
|
+
const now = params.now ?? /* @__PURE__ */ new Date();
|
|
20
|
+
const run = await this.automationRunRepository.findById(runId);
|
|
21
|
+
if (!run) return { data: null };
|
|
22
|
+
const finished = AutomationRun.fromJSON({
|
|
23
|
+
...run,
|
|
24
|
+
status,
|
|
25
|
+
...status === "paused" ? {} : { finishedAt: now },
|
|
26
|
+
...error ? { error } : {}
|
|
27
|
+
});
|
|
28
|
+
const saved = await this.automationRunRepository.update(finished);
|
|
29
|
+
if (run.automationId) {
|
|
30
|
+
await this.automationRepository.release(String(run.automationId), workerId, {
|
|
31
|
+
lastRunAt: now,
|
|
32
|
+
lastRunStatus: status,
|
|
33
|
+
...status === "paused" ? { activeRunId: run._id } : {}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return { data: saved ?? finished.toJSON() };
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
FinishAutomationRunUseCase = __decorateClass([
|
|
40
|
+
autoInjectable(),
|
|
41
|
+
__decorateParam(0, inject(AutomationRepository)),
|
|
42
|
+
__decorateParam(1, inject(AutomationRunRepository))
|
|
43
|
+
], FinishAutomationRunUseCase);
|
|
44
|
+
export {
|
|
45
|
+
FinishAutomationRunUseCase
|
|
46
|
+
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { BaseUseCase, BaseUseCaseParams, BaseUseCaseOutput } from '../../../common/base/base.use-case.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { AutomationProps } from '../entities';
|
|
3
|
+
import { AutomationRepository } from '../repositories';
|
|
4
4
|
export interface Params extends BaseUseCaseParams {
|
|
5
5
|
id: string;
|
|
6
6
|
}
|
|
7
7
|
export interface Output extends BaseUseCaseOutput {
|
|
8
|
-
data:
|
|
8
|
+
data: AutomationProps | null;
|
|
9
9
|
}
|
|
10
|
-
export declare class
|
|
11
|
-
private readonly
|
|
12
|
-
constructor(
|
|
10
|
+
export declare class GetAutomationByIdUseCase extends BaseUseCase<Params, Output> {
|
|
11
|
+
private readonly automationRepository?;
|
|
12
|
+
constructor(automationRepository?: AutomationRepository | undefined);
|
|
13
13
|
execute(params: Params): Promise<Output>;
|
|
14
14
|
}
|
|
@@ -25,31 +25,31 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
25
25
|
return result;
|
|
26
26
|
};
|
|
27
27
|
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
28
|
-
var
|
|
29
|
-
__export(
|
|
30
|
-
|
|
28
|
+
var get_automation_by_id_use_case_exports = {};
|
|
29
|
+
__export(get_automation_by_id_use_case_exports, {
|
|
30
|
+
GetAutomationByIdUseCase: () => GetAutomationByIdUseCase
|
|
31
31
|
});
|
|
32
|
-
module.exports = __toCommonJS(
|
|
32
|
+
module.exports = __toCommonJS(get_automation_by_id_use_case_exports);
|
|
33
33
|
var import_tsyringe = require("tsyringe");
|
|
34
34
|
var import_base = require("../../../common/base/base.use-case.js");
|
|
35
35
|
var import_repositories = require("../repositories");
|
|
36
|
-
let
|
|
37
|
-
constructor(
|
|
36
|
+
let GetAutomationByIdUseCase = class extends import_base.BaseUseCase {
|
|
37
|
+
constructor(automationRepository) {
|
|
38
38
|
super();
|
|
39
|
-
this.
|
|
39
|
+
this.automationRepository = automationRepository;
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
automationRepository;
|
|
42
42
|
async execute(params) {
|
|
43
43
|
const { id } = params;
|
|
44
|
-
const result = await this.
|
|
44
|
+
const result = await this.automationRepository?.findById(id);
|
|
45
45
|
return { data: result ?? null };
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
|
|
48
|
+
GetAutomationByIdUseCase = __decorateClass([
|
|
49
49
|
(0, import_tsyringe.autoInjectable)(),
|
|
50
|
-
__decorateParam(0, (0, import_tsyringe.inject)(import_repositories.
|
|
51
|
-
],
|
|
50
|
+
__decorateParam(0, (0, import_tsyringe.inject)(import_repositories.AutomationRepository))
|
|
51
|
+
], GetAutomationByIdUseCase);
|
|
52
52
|
// Annotate the CommonJS export names for ESM import in node:
|
|
53
53
|
0 && (module.exports = {
|
|
54
|
-
|
|
54
|
+
GetAutomationByIdUseCase
|
|
55
55
|
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__decorateClass,
|
|
3
|
+
__decorateParam
|
|
4
|
+
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
|
+
import { autoInjectable, inject } from "tsyringe";
|
|
6
|
+
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
7
|
+
import { AutomationRepository } from "../repositories";
|
|
8
|
+
let GetAutomationByIdUseCase = class extends BaseUseCase {
|
|
9
|
+
constructor(automationRepository) {
|
|
10
|
+
super();
|
|
11
|
+
this.automationRepository = automationRepository;
|
|
12
|
+
}
|
|
13
|
+
automationRepository;
|
|
14
|
+
async execute(params) {
|
|
15
|
+
const { id } = params;
|
|
16
|
+
const result = await this.automationRepository?.findById(id);
|
|
17
|
+
return { data: result ?? null };
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
GetAutomationByIdUseCase = __decorateClass([
|
|
21
|
+
autoInjectable(),
|
|
22
|
+
__decorateParam(0, inject(AutomationRepository))
|
|
23
|
+
], GetAutomationByIdUseCase);
|
|
24
|
+
export {
|
|
25
|
+
GetAutomationByIdUseCase
|
|
26
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams, BaseUseCaseOutput } from '../../../common/base/base.use-case.js';
|
|
2
|
+
import { AutomationRepository } from '../repositories';
|
|
3
|
+
export interface Params extends BaseUseCaseParams {
|
|
4
|
+
id: string;
|
|
5
|
+
expiresIn?: string | null;
|
|
6
|
+
}
|
|
7
|
+
export interface Output extends BaseUseCaseOutput {
|
|
8
|
+
data: {
|
|
9
|
+
token: string;
|
|
10
|
+
expiresAt?: Date;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare class IssueAutomationEventTokenUseCase extends BaseUseCase<Params, Output> {
|
|
14
|
+
private readonly automationRepository?;
|
|
15
|
+
constructor(automationRepository?: AutomationRepository | undefined);
|
|
16
|
+
execute(params: Params): Promise<Output>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
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
|
+
var issue_automation_event_token_use_case_exports = {};
|
|
29
|
+
__export(issue_automation_event_token_use_case_exports, {
|
|
30
|
+
IssueAutomationEventTokenUseCase: () => IssueAutomationEventTokenUseCase
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(issue_automation_event_token_use_case_exports);
|
|
33
|
+
var import_tsyringe = require("tsyringe");
|
|
34
|
+
var import_base = require("../../../common/base/base.use-case.js");
|
|
35
|
+
var import_repositories = require("../repositories");
|
|
36
|
+
var import_event_token = require("../utils/event-token");
|
|
37
|
+
let IssueAutomationEventTokenUseCase = class extends import_base.BaseUseCase {
|
|
38
|
+
constructor(automationRepository) {
|
|
39
|
+
super();
|
|
40
|
+
this.automationRepository = automationRepository;
|
|
41
|
+
}
|
|
42
|
+
automationRepository;
|
|
43
|
+
async execute(params) {
|
|
44
|
+
const { id, expiresIn, currentUser } = params;
|
|
45
|
+
const automation = await this.automationRepository?.findById(id);
|
|
46
|
+
if (!automation) throw new Error("Automation not found");
|
|
47
|
+
if (!currentUser?.isAdmin() && String(automation.ownerId) !== currentUser?.userId) this.throwError403();
|
|
48
|
+
if (automation.trigger?.type !== "event") throw new Error("Only an automation with an event trigger has a token");
|
|
49
|
+
return { data: (0, import_event_token.signEventToken)({ automationId: id, tokenVersion: automation.trigger.tokenVersion, expiresIn }) };
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
IssueAutomationEventTokenUseCase = __decorateClass([
|
|
53
|
+
(0, import_tsyringe.autoInjectable)(),
|
|
54
|
+
__decorateParam(0, (0, import_tsyringe.inject)(import_repositories.AutomationRepository))
|
|
55
|
+
], IssueAutomationEventTokenUseCase);
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
IssueAutomationEventTokenUseCase
|
|
59
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__decorateClass,
|
|
3
|
+
__decorateParam
|
|
4
|
+
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
|
+
import { autoInjectable, inject } from "tsyringe";
|
|
6
|
+
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
7
|
+
import { AutomationRepository } from "../repositories";
|
|
8
|
+
import { signEventToken } from "../utils/event-token";
|
|
9
|
+
let IssueAutomationEventTokenUseCase = class extends BaseUseCase {
|
|
10
|
+
constructor(automationRepository) {
|
|
11
|
+
super();
|
|
12
|
+
this.automationRepository = automationRepository;
|
|
13
|
+
}
|
|
14
|
+
automationRepository;
|
|
15
|
+
async execute(params) {
|
|
16
|
+
const { id, expiresIn, currentUser } = params;
|
|
17
|
+
const automation = await this.automationRepository?.findById(id);
|
|
18
|
+
if (!automation) throw new Error("Automation not found");
|
|
19
|
+
if (!currentUser?.isAdmin() && String(automation.ownerId) !== currentUser?.userId) this.throwError403();
|
|
20
|
+
if (automation.trigger?.type !== "event") throw new Error("Only an automation with an event trigger has a token");
|
|
21
|
+
return { data: signEventToken({ automationId: id, tokenVersion: automation.trigger.tokenVersion, expiresIn }) };
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
IssueAutomationEventTokenUseCase = __decorateClass([
|
|
25
|
+
autoInjectable(),
|
|
26
|
+
__decorateParam(0, inject(AutomationRepository))
|
|
27
|
+
], IssueAutomationEventTokenUseCase);
|
|
28
|
+
export {
|
|
29
|
+
IssueAutomationEventTokenUseCase
|
|
30
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { QueryOptions } from '../../../common/repositories/index.js';
|
|
2
2
|
import { BaseUseCase, BaseUseCaseParams, BaseUseCaseOutput } from '../../../common/base/base.use-case.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { AutomationRunProps } from '../entities';
|
|
4
|
+
import { AutomationRunRepository } from '../repositories';
|
|
5
5
|
export interface Params extends BaseUseCaseParams {
|
|
6
|
-
|
|
6
|
+
automationId: string;
|
|
7
7
|
options?: QueryOptions;
|
|
8
8
|
}
|
|
9
9
|
export interface Output extends BaseUseCaseOutput {
|
|
10
|
-
data:
|
|
10
|
+
data: AutomationRunProps[];
|
|
11
11
|
}
|
|
12
|
-
export declare class
|
|
13
|
-
private readonly
|
|
14
|
-
constructor(
|
|
12
|
+
export declare class ListAutomationRunsByAutomationUseCase extends BaseUseCase<Params, Output> {
|
|
13
|
+
private readonly automationRunRepository?;
|
|
14
|
+
constructor(automationRunRepository?: AutomationRunRepository | undefined);
|
|
15
15
|
execute(params: Params): Promise<Output>;
|
|
16
16
|
}
|
|
@@ -25,33 +25,33 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
25
25
|
return result;
|
|
26
26
|
};
|
|
27
27
|
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
28
|
-
var
|
|
29
|
-
__export(
|
|
30
|
-
|
|
28
|
+
var list_automation_runs_by_automation_use_case_exports = {};
|
|
29
|
+
__export(list_automation_runs_by_automation_use_case_exports, {
|
|
30
|
+
ListAutomationRunsByAutomationUseCase: () => ListAutomationRunsByAutomationUseCase
|
|
31
31
|
});
|
|
32
|
-
module.exports = __toCommonJS(
|
|
32
|
+
module.exports = __toCommonJS(list_automation_runs_by_automation_use_case_exports);
|
|
33
33
|
var import_tsyringe = require("tsyringe");
|
|
34
34
|
var import_base = require("../../../common/base/base.use-case.js");
|
|
35
35
|
var import_repositories2 = require("../repositories");
|
|
36
|
-
let
|
|
37
|
-
constructor(
|
|
36
|
+
let ListAutomationRunsByAutomationUseCase = class extends import_base.BaseUseCase {
|
|
37
|
+
constructor(automationRunRepository) {
|
|
38
38
|
super();
|
|
39
|
-
this.
|
|
39
|
+
this.automationRunRepository = automationRunRepository;
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
automationRunRepository;
|
|
42
42
|
async execute(params) {
|
|
43
|
-
const {
|
|
44
|
-
if (!
|
|
43
|
+
const { automationId, options } = params;
|
|
44
|
+
if (!automationId) throw new Error("Missing automationId");
|
|
45
45
|
const { page = 1, limit = 10, sortBy = { createdAt: -1 } } = options || {};
|
|
46
|
-
const results = await this.
|
|
46
|
+
const results = await this.automationRunRepository?.findByAutomation(automationId, { page, limit, sortBy });
|
|
47
47
|
return { data: results ?? [] };
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
-
|
|
50
|
+
ListAutomationRunsByAutomationUseCase = __decorateClass([
|
|
51
51
|
(0, import_tsyringe.autoInjectable)(),
|
|
52
|
-
__decorateParam(0, (0, import_tsyringe.inject)(import_repositories2.
|
|
53
|
-
],
|
|
52
|
+
__decorateParam(0, (0, import_tsyringe.inject)(import_repositories2.AutomationRunRepository))
|
|
53
|
+
], ListAutomationRunsByAutomationUseCase);
|
|
54
54
|
// Annotate the CommonJS export names for ESM import in node:
|
|
55
55
|
0 && (module.exports = {
|
|
56
|
-
|
|
56
|
+
ListAutomationRunsByAutomationUseCase
|
|
57
57
|
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__decorateClass,
|
|
3
|
+
__decorateParam
|
|
4
|
+
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
|
+
import { autoInjectable, inject } from "tsyringe";
|
|
6
|
+
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
7
|
+
import { AutomationRunRepository } from "../repositories";
|
|
8
|
+
let ListAutomationRunsByAutomationUseCase = class extends BaseUseCase {
|
|
9
|
+
constructor(automationRunRepository) {
|
|
10
|
+
super();
|
|
11
|
+
this.automationRunRepository = automationRunRepository;
|
|
12
|
+
}
|
|
13
|
+
automationRunRepository;
|
|
14
|
+
async execute(params) {
|
|
15
|
+
const { automationId, options } = params;
|
|
16
|
+
if (!automationId) throw new Error("Missing automationId");
|
|
17
|
+
const { page = 1, limit = 10, sortBy = { createdAt: -1 } } = options || {};
|
|
18
|
+
const results = await this.automationRunRepository?.findByAutomation(automationId, { page, limit, sortBy });
|
|
19
|
+
return { data: results ?? [] };
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
ListAutomationRunsByAutomationUseCase = __decorateClass([
|
|
23
|
+
autoInjectable(),
|
|
24
|
+
__decorateParam(0, inject(AutomationRunRepository))
|
|
25
|
+
], ListAutomationRunsByAutomationUseCase);
|
|
26
|
+
export {
|
|
27
|
+
ListAutomationRunsByAutomationUseCase
|
|
28
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { QueryOptions } from '../../../common/repositories/index.js';
|
|
2
2
|
import { BaseUseCase, BaseUseCaseParams, BaseUseCaseOutput } from '../../../common/base/base.use-case.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { AutomationRunProps, AutomationRunStatus } from '../entities';
|
|
4
|
+
import { AutomationRunRepository } from '../repositories';
|
|
5
5
|
export interface Params extends BaseUseCaseParams {
|
|
6
|
-
status?:
|
|
6
|
+
status?: AutomationRunStatus;
|
|
7
7
|
options?: QueryOptions;
|
|
8
8
|
}
|
|
9
9
|
export interface Output extends BaseUseCaseOutput {
|
|
10
|
-
data:
|
|
10
|
+
data: AutomationRunProps[];
|
|
11
11
|
}
|
|
12
|
-
export declare class
|
|
13
|
-
private readonly
|
|
14
|
-
constructor(
|
|
12
|
+
export declare class ListAutomationRunsByUserUseCase extends BaseUseCase<Params, Output> {
|
|
13
|
+
private readonly automationRunRepository?;
|
|
14
|
+
constructor(automationRunRepository?: AutomationRunRepository | undefined);
|
|
15
15
|
execute(params: Params): Promise<Output>;
|
|
16
16
|
}
|
|
@@ -25,33 +25,33 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
25
25
|
return result;
|
|
26
26
|
};
|
|
27
27
|
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
28
|
-
var
|
|
29
|
-
__export(
|
|
30
|
-
|
|
28
|
+
var list_automation_runs_by_user_use_case_exports = {};
|
|
29
|
+
__export(list_automation_runs_by_user_use_case_exports, {
|
|
30
|
+
ListAutomationRunsByUserUseCase: () => ListAutomationRunsByUserUseCase
|
|
31
31
|
});
|
|
32
|
-
module.exports = __toCommonJS(
|
|
32
|
+
module.exports = __toCommonJS(list_automation_runs_by_user_use_case_exports);
|
|
33
33
|
var import_tsyringe = require("tsyringe");
|
|
34
34
|
var import_base = require("../../../common/base/base.use-case.js");
|
|
35
35
|
var import_repositories2 = require("../repositories");
|
|
36
|
-
let
|
|
37
|
-
constructor(
|
|
36
|
+
let ListAutomationRunsByUserUseCase = class extends import_base.BaseUseCase {
|
|
37
|
+
constructor(automationRunRepository) {
|
|
38
38
|
super();
|
|
39
|
-
this.
|
|
39
|
+
this.automationRunRepository = automationRunRepository;
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
automationRunRepository;
|
|
42
42
|
async execute(params) {
|
|
43
43
|
const { status, options, currentUser } = params;
|
|
44
|
-
if (!currentUser?.userId) throw new Error("CurrentUser is required to list the runs of the
|
|
44
|
+
if (!currentUser?.userId) throw new Error("CurrentUser is required to list the runs of the automations");
|
|
45
45
|
const { page = 1, limit = 10, sortBy = { createdAt: -1 } } = options || {};
|
|
46
|
-
const results = await this.
|
|
46
|
+
const results = await this.automationRunRepository?.findByOwner(currentUser.userId, { page, limit, sortBy }, status);
|
|
47
47
|
return { data: results ?? [] };
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
-
|
|
50
|
+
ListAutomationRunsByUserUseCase = __decorateClass([
|
|
51
51
|
(0, import_tsyringe.autoInjectable)(),
|
|
52
|
-
__decorateParam(0, (0, import_tsyringe.inject)(import_repositories2.
|
|
53
|
-
],
|
|
52
|
+
__decorateParam(0, (0, import_tsyringe.inject)(import_repositories2.AutomationRunRepository))
|
|
53
|
+
], ListAutomationRunsByUserUseCase);
|
|
54
54
|
// Annotate the CommonJS export names for ESM import in node:
|
|
55
55
|
0 && (module.exports = {
|
|
56
|
-
|
|
56
|
+
ListAutomationRunsByUserUseCase
|
|
57
57
|
});
|
|
@@ -4,25 +4,25 @@ import {
|
|
|
4
4
|
} from "../../../chunk-CF3WOMB3.mjs";
|
|
5
5
|
import { autoInjectable, inject } from "tsyringe";
|
|
6
6
|
import { BaseUseCase } from "../../../common/base/base.use-case.js";
|
|
7
|
-
import {
|
|
8
|
-
let
|
|
9
|
-
constructor(
|
|
7
|
+
import { AutomationRunRepository } from "../repositories";
|
|
8
|
+
let ListAutomationRunsByUserUseCase = class extends BaseUseCase {
|
|
9
|
+
constructor(automationRunRepository) {
|
|
10
10
|
super();
|
|
11
|
-
this.
|
|
11
|
+
this.automationRunRepository = automationRunRepository;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
automationRunRepository;
|
|
14
14
|
async execute(params) {
|
|
15
15
|
const { status, options, currentUser } = params;
|
|
16
|
-
if (!currentUser?.userId) throw new Error("CurrentUser is required to list the runs of the
|
|
16
|
+
if (!currentUser?.userId) throw new Error("CurrentUser is required to list the runs of the automations");
|
|
17
17
|
const { page = 1, limit = 10, sortBy = { createdAt: -1 } } = options || {};
|
|
18
|
-
const results = await this.
|
|
18
|
+
const results = await this.automationRunRepository?.findByOwner(currentUser.userId, { page, limit, sortBy }, status);
|
|
19
19
|
return { data: results ?? [] };
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
ListAutomationRunsByUserUseCase = __decorateClass([
|
|
23
23
|
autoInjectable(),
|
|
24
|
-
__decorateParam(0, inject(
|
|
25
|
-
],
|
|
24
|
+
__decorateParam(0, inject(AutomationRunRepository))
|
|
25
|
+
], ListAutomationRunsByUserUseCase);
|
|
26
26
|
export {
|
|
27
|
-
|
|
27
|
+
ListAutomationRunsByUserUseCase
|
|
28
28
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { QueryOptions } from '../../../common/repositories/index.js';
|
|
2
2
|
import { BaseUseCase, BaseUseCaseParams, BaseUseCaseOutput } from '../../../common/base/base.use-case.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { AutomationProps } from '../entities';
|
|
4
|
+
import { AutomationRepository } from '../repositories';
|
|
5
5
|
export interface Params extends BaseUseCaseParams {
|
|
6
6
|
options?: QueryOptions;
|
|
7
7
|
}
|
|
8
8
|
export interface Output extends BaseUseCaseOutput {
|
|
9
|
-
data:
|
|
9
|
+
data: AutomationProps[];
|
|
10
10
|
}
|
|
11
|
-
export declare class
|
|
12
|
-
private readonly
|
|
13
|
-
constructor(
|
|
11
|
+
export declare class ListAutomationsByUserUseCase extends BaseUseCase<Params, Output> {
|
|
12
|
+
private readonly automationRepository?;
|
|
13
|
+
constructor(automationRepository?: AutomationRepository | undefined);
|
|
14
14
|
execute(params: Params): Promise<Output>;
|
|
15
15
|
}
|