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,14 @@
|
|
|
1
|
+
import { BaseUseCase, BaseUseCaseParams, BaseUseCaseOutput } from '../../../common/base/base.use-case.js';
|
|
2
|
+
import { RevokedTokenProps } from '../entities';
|
|
3
|
+
import { RevokedTokenRepository } from '../repositories';
|
|
4
|
+
export interface Params extends BaseUseCaseParams {
|
|
5
|
+
payload?: Pick<RevokedTokenProps, 'jti' | 'audience' | 'subject' | 'expiresAt'>;
|
|
6
|
+
}
|
|
7
|
+
export interface Output extends BaseUseCaseOutput {
|
|
8
|
+
data: RevokedTokenProps;
|
|
9
|
+
}
|
|
10
|
+
export declare class RevokeTokenUseCase extends BaseUseCase<Params, Output> {
|
|
11
|
+
private readonly revokedTokenRepository?;
|
|
12
|
+
constructor(revokedTokenRepository?: RevokedTokenRepository | undefined);
|
|
13
|
+
execute(params: Params): Promise<Output>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
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 revoke_token_use_case_exports = {};
|
|
29
|
+
__export(revoke_token_use_case_exports, {
|
|
30
|
+
RevokeTokenUseCase: () => RevokeTokenUseCase
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(revoke_token_use_case_exports);
|
|
33
|
+
var import_tsyringe = require("tsyringe");
|
|
34
|
+
var import_base = require("../../../common/base/base.use-case.js");
|
|
35
|
+
var import_entities = require("../entities");
|
|
36
|
+
var import_repositories = require("../repositories");
|
|
37
|
+
let RevokeTokenUseCase = class extends import_base.BaseUseCase {
|
|
38
|
+
constructor(revokedTokenRepository) {
|
|
39
|
+
super();
|
|
40
|
+
this.revokedTokenRepository = revokedTokenRepository;
|
|
41
|
+
}
|
|
42
|
+
revokedTokenRepository;
|
|
43
|
+
async execute(params) {
|
|
44
|
+
const { payload, currentUser } = params;
|
|
45
|
+
if (!payload?.jti || !payload.audience || !payload.subject) throw new Error("The jti, the audience and the subject are required to revoke a token");
|
|
46
|
+
const existing = await this.revokedTokenRepository.findByJti(payload.jti);
|
|
47
|
+
if (existing) return { data: existing };
|
|
48
|
+
const revoked = import_entities.RevokedToken.fromJSON({ jti: payload.jti, audience: payload.audience, subject: payload.subject, expiresAt: payload.expiresAt });
|
|
49
|
+
revoked.setCreatedBy(currentUser);
|
|
50
|
+
try {
|
|
51
|
+
await this.revokedTokenRepository.create(revoked);
|
|
52
|
+
} catch (error) {
|
|
53
|
+
if (error?.code !== 11e3) throw error;
|
|
54
|
+
}
|
|
55
|
+
return { data: revoked.toJSON() };
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
RevokeTokenUseCase = __decorateClass([
|
|
59
|
+
(0, import_tsyringe.autoInjectable)(),
|
|
60
|
+
__decorateParam(0, (0, import_tsyringe.inject)(import_repositories.RevokedTokenRepository))
|
|
61
|
+
], RevokeTokenUseCase);
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 && (module.exports = {
|
|
64
|
+
RevokeTokenUseCase
|
|
65
|
+
});
|
|
@@ -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 { RevokedToken } from "../entities";
|
|
8
|
+
import { RevokedTokenRepository } from "../repositories";
|
|
9
|
+
let RevokeTokenUseCase = class extends BaseUseCase {
|
|
10
|
+
constructor(revokedTokenRepository) {
|
|
11
|
+
super();
|
|
12
|
+
this.revokedTokenRepository = revokedTokenRepository;
|
|
13
|
+
}
|
|
14
|
+
revokedTokenRepository;
|
|
15
|
+
async execute(params) {
|
|
16
|
+
const { payload, currentUser } = params;
|
|
17
|
+
if (!payload?.jti || !payload.audience || !payload.subject) throw new Error("The jti, the audience and the subject are required to revoke a token");
|
|
18
|
+
const existing = await this.revokedTokenRepository.findByJti(payload.jti);
|
|
19
|
+
if (existing) return { data: existing };
|
|
20
|
+
const revoked = RevokedToken.fromJSON({ jti: payload.jti, audience: payload.audience, subject: payload.subject, expiresAt: payload.expiresAt });
|
|
21
|
+
revoked.setCreatedBy(currentUser);
|
|
22
|
+
try {
|
|
23
|
+
await this.revokedTokenRepository.create(revoked);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
if (error?.code !== 11e3) throw error;
|
|
26
|
+
}
|
|
27
|
+
return { data: revoked.toJSON() };
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
RevokeTokenUseCase = __decorateClass([
|
|
31
|
+
autoInjectable(),
|
|
32
|
+
__decorateParam(0, inject(RevokedTokenRepository))
|
|
33
|
+
], RevokeTokenUseCase);
|
|
34
|
+
export {
|
|
35
|
+
RevokeTokenUseCase
|
|
36
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ObjectId } from 'mongodb';
|
|
2
|
+
import { BaseEntity, BaseEntityProps } from '../../../common/base/base.entity.js';
|
|
3
|
+
export type AutomationRunStatus = 'queued' | 'running' | 'completed' | 'paused' | 'failed' | 'skipped';
|
|
4
|
+
export type AutomationRunTrigger = 'schedule' | 'manual' | 'event';
|
|
5
|
+
export interface AutomationRunError {
|
|
6
|
+
code?: string;
|
|
7
|
+
message: string;
|
|
8
|
+
}
|
|
9
|
+
export interface AutomationRunProps extends BaseEntityProps {
|
|
10
|
+
automationId?: string | ObjectId;
|
|
11
|
+
chatId?: string | ObjectId;
|
|
12
|
+
trigger?: AutomationRunTrigger;
|
|
13
|
+
status?: AutomationRunStatus;
|
|
14
|
+
scheduledFor?: string | Date;
|
|
15
|
+
startedAt?: string | Date;
|
|
16
|
+
finishedAt?: string | Date;
|
|
17
|
+
instructions?: string;
|
|
18
|
+
modelProvider?: string;
|
|
19
|
+
modelName?: string;
|
|
20
|
+
error?: AutomationRunError;
|
|
21
|
+
skipReason?: string;
|
|
22
|
+
workerId?: string;
|
|
23
|
+
payload?: string;
|
|
24
|
+
idempotencyKey?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare class AutomationRun extends BaseEntity {
|
|
27
|
+
private readonly props;
|
|
28
|
+
automationId?: ObjectId | undefined;
|
|
29
|
+
chatId?: ObjectId | undefined;
|
|
30
|
+
trigger?: AutomationRunTrigger | undefined;
|
|
31
|
+
status?: AutomationRunStatus | undefined;
|
|
32
|
+
scheduledFor?: Date | undefined;
|
|
33
|
+
startedAt?: Date | undefined;
|
|
34
|
+
finishedAt?: Date | undefined;
|
|
35
|
+
instructions?: string | undefined;
|
|
36
|
+
modelProvider?: string | undefined;
|
|
37
|
+
modelName?: string | undefined;
|
|
38
|
+
error?: AutomationRunError | undefined;
|
|
39
|
+
skipReason?: string | undefined;
|
|
40
|
+
workerId?: string | undefined;
|
|
41
|
+
payload?: string | undefined;
|
|
42
|
+
idempotencyKey?: string | undefined;
|
|
43
|
+
static fromJSON(props: AutomationRunProps): AutomationRun;
|
|
44
|
+
constructor(props: AutomationRunProps, automationId?: ObjectId | undefined, chatId?: ObjectId | undefined, trigger?: AutomationRunTrigger | undefined, status?: AutomationRunStatus | undefined, scheduledFor?: Date | undefined, startedAt?: Date | undefined, finishedAt?: Date | undefined, instructions?: string | undefined, modelProvider?: string | undefined, modelName?: string | undefined, error?: AutomationRunError | undefined, skipReason?: string | undefined, workerId?: string | undefined, payload?: string | undefined, idempotencyKey?: string | undefined);
|
|
45
|
+
toJSON(): AutomationRunProps;
|
|
46
|
+
}
|
|
@@ -16,11 +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
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var automation_run_entity_exports = {};
|
|
20
|
+
__export(automation_run_entity_exports, {
|
|
21
|
+
AutomationRun: () => AutomationRun
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(automation_run_entity_exports);
|
|
24
24
|
var import_base = require("../../../common/base/base.entity.js");
|
|
25
25
|
const toDate = (value) => {
|
|
26
26
|
if (!value) return void 0;
|
|
@@ -28,11 +28,11 @@ const toDate = (value) => {
|
|
|
28
28
|
if (Number.isNaN(date.getTime())) throw new Error("{{value_must_be_a_date}}");
|
|
29
29
|
return date;
|
|
30
30
|
};
|
|
31
|
-
class
|
|
32
|
-
constructor(props,
|
|
31
|
+
class AutomationRun extends import_base.BaseEntity {
|
|
32
|
+
constructor(props, automationId, chatId, trigger, status, scheduledFor, startedAt, finishedAt, instructions, modelProvider, modelName, error, skipReason, workerId, payload, idempotencyKey) {
|
|
33
33
|
super(props);
|
|
34
34
|
this.props = props;
|
|
35
|
-
this.
|
|
35
|
+
this.automationId = automationId;
|
|
36
36
|
this.chatId = chatId;
|
|
37
37
|
this.trigger = trigger;
|
|
38
38
|
this.status = status;
|
|
@@ -45,9 +45,11 @@ class AgenticJobRun extends import_base.BaseEntity {
|
|
|
45
45
|
this.error = error;
|
|
46
46
|
this.skipReason = skipReason;
|
|
47
47
|
this.workerId = workerId;
|
|
48
|
+
this.payload = payload;
|
|
49
|
+
this.idempotencyKey = idempotencyKey;
|
|
48
50
|
}
|
|
49
51
|
props;
|
|
50
|
-
|
|
52
|
+
automationId;
|
|
51
53
|
chatId;
|
|
52
54
|
trigger;
|
|
53
55
|
status;
|
|
@@ -60,10 +62,12 @@ class AgenticJobRun extends import_base.BaseEntity {
|
|
|
60
62
|
error;
|
|
61
63
|
skipReason;
|
|
62
64
|
workerId;
|
|
65
|
+
payload;
|
|
66
|
+
idempotencyKey;
|
|
63
67
|
static fromJSON(props) {
|
|
64
|
-
return new
|
|
68
|
+
return new AutomationRun(
|
|
65
69
|
props,
|
|
66
|
-
import_base.BaseEntity.toObjectId(props.
|
|
70
|
+
import_base.BaseEntity.toObjectId(props.automationId),
|
|
67
71
|
import_base.BaseEntity.toObjectId(props.chatId),
|
|
68
72
|
props.trigger,
|
|
69
73
|
props.status,
|
|
@@ -75,13 +79,15 @@ class AgenticJobRun extends import_base.BaseEntity {
|
|
|
75
79
|
props.modelName || void 0,
|
|
76
80
|
props.error,
|
|
77
81
|
props.skipReason || void 0,
|
|
78
|
-
props.workerId || void 0
|
|
82
|
+
props.workerId || void 0,
|
|
83
|
+
props.payload || void 0,
|
|
84
|
+
props.idempotencyKey || void 0
|
|
79
85
|
);
|
|
80
86
|
}
|
|
81
87
|
toJSON() {
|
|
82
88
|
return {
|
|
83
89
|
...super.toJSON(),
|
|
84
|
-
|
|
90
|
+
automationId: this.automationId,
|
|
85
91
|
chatId: this.chatId,
|
|
86
92
|
trigger: this.trigger,
|
|
87
93
|
status: this.status,
|
|
@@ -93,11 +99,13 @@ class AgenticJobRun extends import_base.BaseEntity {
|
|
|
93
99
|
modelName: this.modelName,
|
|
94
100
|
error: this.error,
|
|
95
101
|
skipReason: this.skipReason,
|
|
96
|
-
workerId: this.workerId
|
|
102
|
+
workerId: this.workerId,
|
|
103
|
+
payload: this.payload,
|
|
104
|
+
idempotencyKey: this.idempotencyKey
|
|
97
105
|
};
|
|
98
106
|
}
|
|
99
107
|
}
|
|
100
108
|
// Annotate the CommonJS export names for ESM import in node:
|
|
101
109
|
0 && (module.exports = {
|
|
102
|
-
|
|
110
|
+
AutomationRun
|
|
103
111
|
});
|
|
@@ -6,11 +6,11 @@ const toDate = (value) => {
|
|
|
6
6
|
if (Number.isNaN(date.getTime())) throw new Error("{{value_must_be_a_date}}");
|
|
7
7
|
return date;
|
|
8
8
|
};
|
|
9
|
-
class
|
|
10
|
-
constructor(props,
|
|
9
|
+
class AutomationRun extends BaseEntity {
|
|
10
|
+
constructor(props, automationId, chatId, trigger, status, scheduledFor, startedAt, finishedAt, instructions, modelProvider, modelName, error, skipReason, workerId, payload, idempotencyKey) {
|
|
11
11
|
super(props);
|
|
12
12
|
this.props = props;
|
|
13
|
-
this.
|
|
13
|
+
this.automationId = automationId;
|
|
14
14
|
this.chatId = chatId;
|
|
15
15
|
this.trigger = trigger;
|
|
16
16
|
this.status = status;
|
|
@@ -23,9 +23,11 @@ class AgenticJobRun extends BaseEntity {
|
|
|
23
23
|
this.error = error;
|
|
24
24
|
this.skipReason = skipReason;
|
|
25
25
|
this.workerId = workerId;
|
|
26
|
+
this.payload = payload;
|
|
27
|
+
this.idempotencyKey = idempotencyKey;
|
|
26
28
|
}
|
|
27
29
|
props;
|
|
28
|
-
|
|
30
|
+
automationId;
|
|
29
31
|
chatId;
|
|
30
32
|
trigger;
|
|
31
33
|
status;
|
|
@@ -38,10 +40,12 @@ class AgenticJobRun extends BaseEntity {
|
|
|
38
40
|
error;
|
|
39
41
|
skipReason;
|
|
40
42
|
workerId;
|
|
43
|
+
payload;
|
|
44
|
+
idempotencyKey;
|
|
41
45
|
static fromJSON(props) {
|
|
42
|
-
return new
|
|
46
|
+
return new AutomationRun(
|
|
43
47
|
props,
|
|
44
|
-
BaseEntity.toObjectId(props.
|
|
48
|
+
BaseEntity.toObjectId(props.automationId),
|
|
45
49
|
BaseEntity.toObjectId(props.chatId),
|
|
46
50
|
props.trigger,
|
|
47
51
|
props.status,
|
|
@@ -53,13 +57,15 @@ class AgenticJobRun extends BaseEntity {
|
|
|
53
57
|
props.modelName || void 0,
|
|
54
58
|
props.error,
|
|
55
59
|
props.skipReason || void 0,
|
|
56
|
-
props.workerId || void 0
|
|
60
|
+
props.workerId || void 0,
|
|
61
|
+
props.payload || void 0,
|
|
62
|
+
props.idempotencyKey || void 0
|
|
57
63
|
);
|
|
58
64
|
}
|
|
59
65
|
toJSON() {
|
|
60
66
|
return {
|
|
61
67
|
...super.toJSON(),
|
|
62
|
-
|
|
68
|
+
automationId: this.automationId,
|
|
63
69
|
chatId: this.chatId,
|
|
64
70
|
trigger: this.trigger,
|
|
65
71
|
status: this.status,
|
|
@@ -71,10 +77,12 @@ class AgenticJobRun extends BaseEntity {
|
|
|
71
77
|
modelName: this.modelName,
|
|
72
78
|
error: this.error,
|
|
73
79
|
skipReason: this.skipReason,
|
|
74
|
-
workerId: this.workerId
|
|
80
|
+
workerId: this.workerId,
|
|
81
|
+
payload: this.payload,
|
|
82
|
+
idempotencyKey: this.idempotencyKey
|
|
75
83
|
};
|
|
76
84
|
}
|
|
77
85
|
}
|
|
78
86
|
export {
|
|
79
|
-
|
|
87
|
+
AutomationRun
|
|
80
88
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ObjectId } from 'mongodb';
|
|
2
|
+
import { BaseEntity, BaseEntityProps } from '../../../common/base/base.entity.js';
|
|
3
|
+
import { AutomationTrigger } from './trigger';
|
|
4
|
+
import type { AutomationRunStatus } from './automation-run.entity';
|
|
5
|
+
export interface AutomationProps extends BaseEntityProps {
|
|
6
|
+
name?: string;
|
|
7
|
+
instructions?: string;
|
|
8
|
+
enabled?: boolean;
|
|
9
|
+
trigger?: AutomationTrigger;
|
|
10
|
+
modelProvider?: string;
|
|
11
|
+
modelName?: string;
|
|
12
|
+
nextRunAt?: string | Date | null;
|
|
13
|
+
lastRunAt?: string | Date | null;
|
|
14
|
+
lastRunStatus?: AutomationRunStatus;
|
|
15
|
+
lockedBy?: string | null;
|
|
16
|
+
lockedUntil?: string | Date | null;
|
|
17
|
+
activeRunId?: string | ObjectId | null;
|
|
18
|
+
}
|
|
19
|
+
export declare class Automation extends BaseEntity {
|
|
20
|
+
private readonly props;
|
|
21
|
+
name?: string | undefined;
|
|
22
|
+
instructions?: string | undefined;
|
|
23
|
+
enabled?: boolean | undefined;
|
|
24
|
+
trigger?: AutomationTrigger | undefined;
|
|
25
|
+
modelProvider?: string | undefined;
|
|
26
|
+
modelName?: string | undefined;
|
|
27
|
+
nextRunAt?: Date | undefined;
|
|
28
|
+
lastRunAt?: Date | undefined;
|
|
29
|
+
lastRunStatus?: AutomationRunStatus | undefined;
|
|
30
|
+
lockedBy?: string | undefined;
|
|
31
|
+
lockedUntil?: Date | undefined;
|
|
32
|
+
activeRunId?: ObjectId | undefined;
|
|
33
|
+
static fromJSON(props: AutomationProps): Automation;
|
|
34
|
+
constructor(props: AutomationProps, name?: string | undefined, instructions?: string | undefined, enabled?: boolean | undefined, trigger?: AutomationTrigger | undefined, modelProvider?: string | undefined, modelName?: string | undefined, nextRunAt?: Date | undefined, lastRunAt?: Date | undefined, lastRunStatus?: AutomationRunStatus | undefined, lockedBy?: string | undefined, lockedUntil?: Date | undefined, activeRunId?: ObjectId | undefined);
|
|
35
|
+
toJSON(): AutomationProps;
|
|
36
|
+
isScheduled(): boolean;
|
|
37
|
+
scheduleNextRun(from?: Date): this;
|
|
38
|
+
}
|
|
@@ -16,11 +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
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var automation_entity_exports = {};
|
|
20
|
+
__export(automation_entity_exports, {
|
|
21
|
+
Automation: () => Automation
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
23
|
+
module.exports = __toCommonJS(automation_entity_exports);
|
|
24
24
|
var import_base = require("../../../common/base/base.entity.js");
|
|
25
25
|
var import_next_run = require("../utils/next-run");
|
|
26
26
|
const toDate = (value) => {
|
|
@@ -29,15 +29,14 @@ const toDate = (value) => {
|
|
|
29
29
|
if (Number.isNaN(date.getTime())) throw new Error("{{value_must_be_a_date}}");
|
|
30
30
|
return date;
|
|
31
31
|
};
|
|
32
|
-
class
|
|
33
|
-
constructor(props, name, instructions, enabled,
|
|
32
|
+
class Automation extends import_base.BaseEntity {
|
|
33
|
+
constructor(props, name, instructions, enabled, trigger, modelProvider, modelName, nextRunAt, lastRunAt, lastRunStatus, lockedBy, lockedUntil, activeRunId) {
|
|
34
34
|
super(props);
|
|
35
35
|
this.props = props;
|
|
36
36
|
this.name = name;
|
|
37
37
|
this.instructions = instructions;
|
|
38
38
|
this.enabled = enabled;
|
|
39
|
-
this.
|
|
40
|
-
this.timezone = timezone;
|
|
39
|
+
this.trigger = trigger;
|
|
41
40
|
this.modelProvider = modelProvider;
|
|
42
41
|
this.modelName = modelName;
|
|
43
42
|
this.nextRunAt = nextRunAt;
|
|
@@ -51,8 +50,7 @@ class AgenticJob extends import_base.BaseEntity {
|
|
|
51
50
|
name;
|
|
52
51
|
instructions;
|
|
53
52
|
enabled;
|
|
54
|
-
|
|
55
|
-
timezone;
|
|
53
|
+
trigger;
|
|
56
54
|
modelProvider;
|
|
57
55
|
modelName;
|
|
58
56
|
nextRunAt;
|
|
@@ -62,13 +60,12 @@ class AgenticJob extends import_base.BaseEntity {
|
|
|
62
60
|
lockedUntil;
|
|
63
61
|
activeRunId;
|
|
64
62
|
static fromJSON(props) {
|
|
65
|
-
return new
|
|
63
|
+
return new Automation(
|
|
66
64
|
props,
|
|
67
65
|
props.name || void 0,
|
|
68
66
|
props.instructions || void 0,
|
|
69
67
|
props.enabled,
|
|
70
|
-
props.
|
|
71
|
-
props.timezone || void 0,
|
|
68
|
+
props.trigger,
|
|
72
69
|
props.modelProvider || void 0,
|
|
73
70
|
props.modelName || void 0,
|
|
74
71
|
toDate(props.nextRunAt),
|
|
@@ -85,8 +82,7 @@ class AgenticJob extends import_base.BaseEntity {
|
|
|
85
82
|
name: this.name,
|
|
86
83
|
instructions: this.instructions,
|
|
87
84
|
enabled: this.enabled,
|
|
88
|
-
|
|
89
|
-
timezone: this.timezone,
|
|
85
|
+
trigger: this.trigger,
|
|
90
86
|
modelProvider: this.modelProvider,
|
|
91
87
|
modelName: this.modelName,
|
|
92
88
|
nextRunAt: this.nextRunAt,
|
|
@@ -97,8 +93,12 @@ class AgenticJob extends import_base.BaseEntity {
|
|
|
97
93
|
activeRunId: this.activeRunId
|
|
98
94
|
};
|
|
99
95
|
}
|
|
96
|
+
isScheduled() {
|
|
97
|
+
return this.trigger?.type === "schedule";
|
|
98
|
+
}
|
|
100
99
|
scheduleNextRun(from = /* @__PURE__ */ new Date()) {
|
|
101
|
-
const
|
|
100
|
+
const trigger = this.trigger;
|
|
101
|
+
const next = this.enabled && trigger?.type === "schedule" ? (0, import_next_run.computeNextRun)(trigger.recurrence, trigger.timezone, from) : null;
|
|
102
102
|
if (next) {
|
|
103
103
|
this.nextRunAt = next;
|
|
104
104
|
} else {
|
|
@@ -109,5 +109,5 @@ class AgenticJob extends import_base.BaseEntity {
|
|
|
109
109
|
}
|
|
110
110
|
// Annotate the CommonJS export names for ESM import in node:
|
|
111
111
|
0 && (module.exports = {
|
|
112
|
-
|
|
112
|
+
Automation
|
|
113
113
|
});
|
|
@@ -7,15 +7,14 @@ const toDate = (value) => {
|
|
|
7
7
|
if (Number.isNaN(date.getTime())) throw new Error("{{value_must_be_a_date}}");
|
|
8
8
|
return date;
|
|
9
9
|
};
|
|
10
|
-
class
|
|
11
|
-
constructor(props, name, instructions, enabled,
|
|
10
|
+
class Automation extends BaseEntity {
|
|
11
|
+
constructor(props, name, instructions, enabled, trigger, modelProvider, modelName, nextRunAt, lastRunAt, lastRunStatus, lockedBy, lockedUntil, activeRunId) {
|
|
12
12
|
super(props);
|
|
13
13
|
this.props = props;
|
|
14
14
|
this.name = name;
|
|
15
15
|
this.instructions = instructions;
|
|
16
16
|
this.enabled = enabled;
|
|
17
|
-
this.
|
|
18
|
-
this.timezone = timezone;
|
|
17
|
+
this.trigger = trigger;
|
|
19
18
|
this.modelProvider = modelProvider;
|
|
20
19
|
this.modelName = modelName;
|
|
21
20
|
this.nextRunAt = nextRunAt;
|
|
@@ -29,8 +28,7 @@ class AgenticJob extends BaseEntity {
|
|
|
29
28
|
name;
|
|
30
29
|
instructions;
|
|
31
30
|
enabled;
|
|
32
|
-
|
|
33
|
-
timezone;
|
|
31
|
+
trigger;
|
|
34
32
|
modelProvider;
|
|
35
33
|
modelName;
|
|
36
34
|
nextRunAt;
|
|
@@ -40,13 +38,12 @@ class AgenticJob extends BaseEntity {
|
|
|
40
38
|
lockedUntil;
|
|
41
39
|
activeRunId;
|
|
42
40
|
static fromJSON(props) {
|
|
43
|
-
return new
|
|
41
|
+
return new Automation(
|
|
44
42
|
props,
|
|
45
43
|
props.name || void 0,
|
|
46
44
|
props.instructions || void 0,
|
|
47
45
|
props.enabled,
|
|
48
|
-
props.
|
|
49
|
-
props.timezone || void 0,
|
|
46
|
+
props.trigger,
|
|
50
47
|
props.modelProvider || void 0,
|
|
51
48
|
props.modelName || void 0,
|
|
52
49
|
toDate(props.nextRunAt),
|
|
@@ -63,8 +60,7 @@ class AgenticJob extends BaseEntity {
|
|
|
63
60
|
name: this.name,
|
|
64
61
|
instructions: this.instructions,
|
|
65
62
|
enabled: this.enabled,
|
|
66
|
-
|
|
67
|
-
timezone: this.timezone,
|
|
63
|
+
trigger: this.trigger,
|
|
68
64
|
modelProvider: this.modelProvider,
|
|
69
65
|
modelName: this.modelName,
|
|
70
66
|
nextRunAt: this.nextRunAt,
|
|
@@ -75,8 +71,12 @@ class AgenticJob extends BaseEntity {
|
|
|
75
71
|
activeRunId: this.activeRunId
|
|
76
72
|
};
|
|
77
73
|
}
|
|
74
|
+
isScheduled() {
|
|
75
|
+
return this.trigger?.type === "schedule";
|
|
76
|
+
}
|
|
78
77
|
scheduleNextRun(from = /* @__PURE__ */ new Date()) {
|
|
79
|
-
const
|
|
78
|
+
const trigger = this.trigger;
|
|
79
|
+
const next = this.enabled && trigger?.type === "schedule" ? computeNextRun(trigger.recurrence, trigger.timezone, from) : null;
|
|
80
80
|
if (next) {
|
|
81
81
|
this.nextRunAt = next;
|
|
82
82
|
} else {
|
|
@@ -86,5 +86,5 @@ class AgenticJob extends BaseEntity {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
export {
|
|
89
|
-
|
|
89
|
+
Automation
|
|
90
90
|
};
|
|
@@ -16,11 +16,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
16
16
|
var entities_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(entities_exports);
|
|
18
18
|
__reExport(entities_exports, require("./recurrence"), module.exports);
|
|
19
|
-
__reExport(entities_exports, require("./
|
|
20
|
-
__reExport(entities_exports, require("./
|
|
19
|
+
__reExport(entities_exports, require("./automation.entity"), module.exports);
|
|
20
|
+
__reExport(entities_exports, require("./automation-run.entity"), module.exports);
|
|
21
|
+
__reExport(entities_exports, require("./trigger"), module.exports);
|
|
21
22
|
// Annotate the CommonJS export names for ESM import in node:
|
|
22
23
|
0 && (module.exports = {
|
|
23
24
|
...require("./recurrence"),
|
|
24
|
-
...require("./
|
|
25
|
-
...require("./
|
|
25
|
+
...require("./automation.entity"),
|
|
26
|
+
...require("./automation-run.entity"),
|
|
27
|
+
...require("./trigger")
|
|
26
28
|
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Recurrence } from './recurrence';
|
|
2
|
+
export type AutomationTrigger = {
|
|
3
|
+
type: 'schedule';
|
|
4
|
+
recurrence: Recurrence;
|
|
5
|
+
timezone: string;
|
|
6
|
+
} | {
|
|
7
|
+
type: 'event';
|
|
8
|
+
tokenVersion: number;
|
|
9
|
+
timezone?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function readTrigger(input: unknown, existing?: AutomationTrigger): AutomationTrigger;
|
|
@@ -0,0 +1,49 @@
|
|
|
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 trigger_exports = {};
|
|
20
|
+
__export(trigger_exports, {
|
|
21
|
+
readTrigger: () => readTrigger
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(trigger_exports);
|
|
24
|
+
var import_recurrence = require("./recurrence");
|
|
25
|
+
var import_next_run = require("../utils/next-run");
|
|
26
|
+
const isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
27
|
+
function readTrigger(input, existing) {
|
|
28
|
+
if (!isRecord(input)) throw new Error("The trigger is required");
|
|
29
|
+
const type = input.type ?? existing?.type;
|
|
30
|
+
if (type !== "schedule" && type !== "event") throw new Error("The trigger type must be schedule or event");
|
|
31
|
+
if (existing && type !== existing.type) throw new Error("The type of the trigger cannot be changed");
|
|
32
|
+
const previous = existing?.type === type ? existing : void 0;
|
|
33
|
+
const has = (key) => input[key] !== void 0;
|
|
34
|
+
if (type === "event") {
|
|
35
|
+
const event = previous;
|
|
36
|
+
const timezone = has("timezone") ? (0, import_next_run.assertTimezone)(input.timezone) : event?.timezone;
|
|
37
|
+
return { type, tokenVersion: event?.tokenVersion ?? 1, ...timezone ? { timezone } : {} };
|
|
38
|
+
}
|
|
39
|
+
const schedule = previous;
|
|
40
|
+
return {
|
|
41
|
+
type,
|
|
42
|
+
recurrence: has("recurrence") || !schedule ? (0, import_recurrence.validateRecurrence)(input.recurrence) : schedule.recurrence,
|
|
43
|
+
timezone: has("timezone") || !schedule ? (0, import_next_run.assertTimezone)(input.timezone) : schedule.timezone
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
readTrigger
|
|
49
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import "../../../chunk-CF3WOMB3.mjs";
|
|
2
|
+
import { validateRecurrence } from "./recurrence";
|
|
3
|
+
import { assertTimezone } from "../utils/next-run";
|
|
4
|
+
const isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
5
|
+
function readTrigger(input, existing) {
|
|
6
|
+
if (!isRecord(input)) throw new Error("The trigger is required");
|
|
7
|
+
const type = input.type ?? existing?.type;
|
|
8
|
+
if (type !== "schedule" && type !== "event") throw new Error("The trigger type must be schedule or event");
|
|
9
|
+
if (existing && type !== existing.type) throw new Error("The type of the trigger cannot be changed");
|
|
10
|
+
const previous = existing?.type === type ? existing : void 0;
|
|
11
|
+
const has = (key) => input[key] !== void 0;
|
|
12
|
+
if (type === "event") {
|
|
13
|
+
const event = previous;
|
|
14
|
+
const timezone = has("timezone") ? assertTimezone(input.timezone) : event?.timezone;
|
|
15
|
+
return { type, tokenVersion: event?.tokenVersion ?? 1, ...timezone ? { timezone } : {} };
|
|
16
|
+
}
|
|
17
|
+
const schedule = previous;
|
|
18
|
+
return {
|
|
19
|
+
type,
|
|
20
|
+
recurrence: has("recurrence") || !schedule ? validateRecurrence(input.recurrence) : schedule.recurrence,
|
|
21
|
+
timezone: has("timezone") || !schedule ? assertTimezone(input.timezone) : schedule.timezone
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
readTrigger
|
|
26
|
+
};
|