@aristid/leav-types 1.13.0 → 1.14.0-099d7b51
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/CLAUDE.md +2 -2
- package/apps/core/config/default.d.ts +5 -1
- package/apps/core/config/test.d.ts +4 -0
- package/apps/core/src/_types/automation.d.ts +7 -2
- package/apps/core/src/_types/config.d.ts +19 -3
- package/apps/core/src/_types/errors.d.ts +1 -0
- package/apps/core/src/_types/extensionPoints.d.ts +2 -0
- package/apps/core/src/_types/jsonSchemaForm.d.ts +7 -0
- package/apps/core/src/_types/viewsV2.d.ts +91 -0
- package/apps/core/src/app/core/automationApp.d.ts +6 -5
- package/apps/core/src/app/core/index.d.ts +1 -0
- package/apps/core/src/app/core/viewV2App.d.ts +14 -0
- package/apps/core/src/domain/automation/actions/_types.d.ts +12 -4
- package/apps/core/src/domain/automation/actions/conditionAction.d.ts +6 -2
- package/apps/core/src/domain/automation/actions/index.d.ts +1 -0
- package/apps/core/src/domain/automation/actions/jexlCalculationAutomationAction.d.ts +3 -3
- package/apps/core/src/domain/automation/actions/modifyAttributeAction.d.ts +3 -1
- package/apps/core/src/domain/automation/actions/notificationAction.d.ts +17 -0
- package/apps/core/src/domain/automation/automationActionsRegistry.d.ts +1 -0
- package/apps/core/src/domain/automation/automationDomain.d.ts +22 -9
- package/apps/core/src/domain/automation/automationRulesCache.d.ts +66 -0
- package/apps/core/src/domain/automation/fakeRulesToTrigger.d.ts +2 -2
- package/apps/core/src/domain/automation/form/automationJsonSchemaForm.d.ts +21 -0
- package/apps/core/src/domain/automation/form/automationUiJsonSchemaForm.d.ts +19 -0
- package/apps/core/src/domain/automation/form/index.d.ts +2 -0
- package/apps/core/src/domain/automation/index.d.ts +2 -0
- package/apps/core/src/domain/automation/jexl/index.d.ts +1 -0
- package/apps/core/src/domain/automation/jexl/jexlAutomation.d.ts +16 -0
- package/apps/core/src/domain/automation/pipeline/_types.d.ts +10 -6
- package/apps/core/src/domain/automation/pipeline/pipeline.d.ts +3 -8
- package/apps/core/src/domain/automation/pipeline/stepValidation.d.ts +3 -0
- package/apps/core/src/domain/automation/triggers/automationTriggers.d.ts +0 -4
- package/apps/core/src/domain/automation/triggers/automationTriggersRegistry.d.ts +2 -2
- package/apps/core/src/domain/automation/triggers/automationTriggersTopics.d.ts +2 -2
- package/apps/core/src/domain/helpers/getCoreEntityById.d.ts +4 -2
- package/apps/core/src/domain/jexl/jexlDomain.d.ts +8 -2
- package/apps/core/src/domain/jexl/types.d.ts +6 -0
- package/apps/core/src/domain/record/recordDomain.d.ts +0 -8
- package/apps/core/src/domain/value/valueDomain.d.ts +3 -1
- package/apps/core/src/domain/viewV2/index.d.ts +1 -0
- package/apps/core/src/domain/viewV2/viewV2Domain.d.ts +21 -0
- package/apps/core/src/domain/viewV2/viewV2ZodSchema.d.ts +50 -0
- package/apps/core/src/infra/automation/automationRuleRepo.d.ts +6 -2
- package/apps/core/src/infra/db/migrations/020-addViewsV2Collection.d.ts +7 -0
- package/apps/core/src/infra/viewV2/index.d.ts +1 -0
- package/apps/core/src/infra/viewV2/viewV2Repo.d.ts +40 -0
- package/apps/core/src/interface/cli.d.ts +8 -3
- package/apps/core/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +2 -2
package/CLAUDE.md
CHANGED
|
@@ -15,8 +15,8 @@ depuis `apps/core`, destinée aux **développeurs de plugins** qui étendent le
|
|
|
15
15
|
Publié automatiquement sur **npm public** (`@aristid/leav-types`) via GitLab CI,
|
|
16
16
|
déclenché par tout changement dans `apps/core/**/*` :
|
|
17
17
|
|
|
18
|
-
-
|
|
19
|
-
-
|
|
18
|
+
- **`next`** — à chaque push sur `develop`
|
|
19
|
+
- **`latest`** — sur les releases taguées
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
22
|
# Commande de génération (lancée par le CI)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare let instanceId: string;
|
|
2
|
-
export declare let
|
|
2
|
+
export declare let coreModes: string[];
|
|
3
3
|
export declare namespace server {
|
|
4
4
|
let host: string;
|
|
5
5
|
let port: number;
|
|
@@ -297,5 +297,9 @@ export declare let pluginsPath: string[];
|
|
|
297
297
|
export declare namespace automation {
|
|
298
298
|
let enable_7: boolean;
|
|
299
299
|
export { enable_7 as enable };
|
|
300
|
+
export namespace cache {
|
|
301
|
+
let enable_8: boolean;
|
|
302
|
+
export { enable_8 as enable };
|
|
303
|
+
}
|
|
300
304
|
}
|
|
301
305
|
export { debug_2 as debug, _export as export, _import as import };
|
|
@@ -27,13 +27,18 @@ export type IUpdateAutomationRule = {
|
|
|
27
27
|
trigger?: AutomationRuleTrigger;
|
|
28
28
|
pipeline?: AutomationRulePipeline;
|
|
29
29
|
};
|
|
30
|
+
export declare enum AutomationRuleJsonSchemaFormType {
|
|
31
|
+
CREATION = "creation",
|
|
32
|
+
EDITION = "edition"
|
|
33
|
+
}
|
|
30
34
|
export declare enum SyncAutomationRuleEventAction {
|
|
31
35
|
RECORD_INIT = "RECORD_INIT"
|
|
32
36
|
}
|
|
33
37
|
export type AutomationRuleEventAction = EventAction | SyncAutomationRuleEventAction;
|
|
34
|
-
export type
|
|
38
|
+
export type AutomationRuleEventTopic = IDbPayload['topic'];
|
|
35
39
|
export type AutomationRuleTrigger = {
|
|
36
40
|
synchronous: boolean;
|
|
37
41
|
eventAction: AutomationRuleEventAction;
|
|
38
|
-
eventTopic?:
|
|
42
|
+
eventTopic?: AutomationRuleEventTopic;
|
|
39
43
|
};
|
|
44
|
+
export type AutomationRuleIndexEntry = Pick<IAutomationRule, 'id' | 'trigger'>;
|
|
@@ -2,7 +2,7 @@ import { type Options } from 'amqplib';
|
|
|
2
2
|
import { type IKeyValue } from './shared';
|
|
3
3
|
import { type PermissionsActions, type AdminPermissionsActions, type ApplicationPermissionsActions, type AttributePermissionsActions, type LibraryPermissionsActions, type PermissionTypes, type RecordAttributePermissionsActions, type RecordPermissionsActions, type TreeNodePermissionsActions, type TreePermissionsActions, type AttributeDependentValuesPermissionsActions } from './permissions';
|
|
4
4
|
export interface IConfig {
|
|
5
|
-
|
|
5
|
+
coreModes: CoreMode[];
|
|
6
6
|
server: IServer;
|
|
7
7
|
db: IDb;
|
|
8
8
|
diskCache: IDiskCache;
|
|
@@ -39,6 +39,10 @@ export interface IConfig {
|
|
|
39
39
|
}
|
|
40
40
|
export interface IAutomation {
|
|
41
41
|
enable: boolean;
|
|
42
|
+
cache: IAutomationCache;
|
|
43
|
+
}
|
|
44
|
+
export interface IAutomationCache {
|
|
45
|
+
enable: boolean;
|
|
42
46
|
}
|
|
43
47
|
export declare enum CoreMode {
|
|
44
48
|
SERVER = "server",
|
|
@@ -48,9 +52,21 @@ export declare enum CoreMode {
|
|
|
48
52
|
TASKS_MANAGER_MASTER = "tasksManager:master",
|
|
49
53
|
TASKS_MANAGER_WORKER = "tasksManager:worker",
|
|
50
54
|
LOGS_COLLECTOR = "logsCollector",
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Default, to do db migration, or import ...
|
|
57
|
+
*/
|
|
58
|
+
CLI = "cli",
|
|
59
|
+
/**
|
|
60
|
+
* Alias for [
|
|
61
|
+
* CoreMode.SERVER,
|
|
62
|
+
* CoreMode.INDEXATION_MANAGER,
|
|
63
|
+
* CoreMode.TASKS_MANAGER_MASTER,
|
|
64
|
+
* CoreMode.TASKS_MANAGER_WORKER,
|
|
65
|
+
* ]
|
|
66
|
+
*/
|
|
67
|
+
E2E_PLAYWRIGHT = "e2ePlaywright"
|
|
53
68
|
}
|
|
69
|
+
export declare const CORE_MODES_E2E_PLAYWRIGHT: CoreMode[];
|
|
54
70
|
export interface IServer {
|
|
55
71
|
host: string;
|
|
56
72
|
port: number;
|
|
@@ -60,6 +60,7 @@ export declare enum Errors {
|
|
|
60
60
|
INVALID_VALUES_VERSIONS_SETTINGS_BAD_NODE_ID = "INVALID_VALUES_VERSIONS_SETTINGS_BAD_NODE_ID",
|
|
61
61
|
INVALID_VARIABLE_FUNCTION = "INVALID_VARIABLE_FUNCTION",
|
|
62
62
|
INVALID_VERSION = "INVALID_VERSION",
|
|
63
|
+
INVALID_VIEW_V2_INPUT = "INVALID_VIEW_V2_INPUT",
|
|
63
64
|
LIBRARY_FORBIDDEN_AS_CHILD = "LIBRARY FORBIDDEN AS CHILD",
|
|
64
65
|
METADATA_PERMISSION_ERROR = "METADATA_PERMISSION_ERROR",
|
|
65
66
|
MISSING_ACTION_PREFIX = "MISSING_ACTION_PREFIX",
|
|
@@ -5,6 +5,7 @@ import { type PluginRegisterRoute } from './endpoint';
|
|
|
5
5
|
import { type AuthPostOidcLoginCallback } from './auth';
|
|
6
6
|
import { type RegisterCronTask } from './cronTask';
|
|
7
7
|
import { type ITRPCRouterFactory } from '../app/trpc/trpcApp';
|
|
8
|
+
import { type IAutomationAction } from '../domain/automation/actions/_types';
|
|
8
9
|
export interface IExtensionPoints {
|
|
9
10
|
[name: string]: (...args: any[]) => void;
|
|
10
11
|
}
|
|
@@ -22,6 +23,7 @@ export interface IExtensionPointsFunctions extends IExtensionPoints {
|
|
|
22
23
|
registerPermissionActions: (type: PermissionTypes, actions: string[], applyOn?: string[]) => void;
|
|
23
24
|
registerEventActions: (actions: string[], prefix: string) => void;
|
|
24
25
|
registerActions: (actions: IActionsListFunction[]) => void;
|
|
26
|
+
registerAutomationAction: <P = Record<string, unknown>>(action: IAutomationAction<P>) => void;
|
|
25
27
|
registerTaskTypes: (types: string[]) => void;
|
|
26
28
|
registerStart: (fct: () => Promise<void>) => void;
|
|
27
29
|
/**
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { type SortOrder } from './list';
|
|
2
|
+
import { type AttributeCondition, type TreeCondition } from './record';
|
|
3
|
+
import { type ISystemTranslation } from './systemTranslation';
|
|
4
|
+
export declare enum ViewV2Types {
|
|
5
|
+
LIST = "list",
|
|
6
|
+
CARDS = "cards",
|
|
7
|
+
TIMELINE = "timeline"
|
|
8
|
+
}
|
|
9
|
+
export interface IViewV2DisplayAttribute {
|
|
10
|
+
attributeId: string;
|
|
11
|
+
visible: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface IViewV2Display {
|
|
14
|
+
type: ViewV2Types;
|
|
15
|
+
attributes: IViewV2DisplayAttribute[];
|
|
16
|
+
}
|
|
17
|
+
export interface IViewV2ValuesVersion {
|
|
18
|
+
[treeId: string]: string;
|
|
19
|
+
}
|
|
20
|
+
export interface IViewV2Filter {
|
|
21
|
+
pinned: boolean;
|
|
22
|
+
attributes: string[];
|
|
23
|
+
values: Array<string | null>;
|
|
24
|
+
condition: AttributeCondition | TreeCondition;
|
|
25
|
+
}
|
|
26
|
+
export interface IViewV2Sort {
|
|
27
|
+
attributes: string[];
|
|
28
|
+
order: SortOrder;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* User-facing fields of a view v2 with their natural required/optional cardinality.
|
|
32
|
+
* Source of truth for both the stored entity and the create/update inputs — every other
|
|
33
|
+
* shape in this file is derived from it.
|
|
34
|
+
*/
|
|
35
|
+
interface IViewV2UserFields {
|
|
36
|
+
library: string;
|
|
37
|
+
label: ISystemTranslation;
|
|
38
|
+
display: IViewV2Display;
|
|
39
|
+
shared: boolean;
|
|
40
|
+
filters: IViewV2Filter[];
|
|
41
|
+
sorts: IViewV2Sort[];
|
|
42
|
+
valuesVersions?: IViewV2ValuesVersion | null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Server-managed fields, populated by the domain layer.
|
|
46
|
+
*/
|
|
47
|
+
interface IViewV2ServerFields {
|
|
48
|
+
id: string;
|
|
49
|
+
created_by: string;
|
|
50
|
+
created_at: number;
|
|
51
|
+
modified_at: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Stored view v2 entity, as persisted in ArangoDB and returned by the domain.
|
|
55
|
+
*/
|
|
56
|
+
export type IViewV2 = IViewV2UserFields & IViewV2ServerFields;
|
|
57
|
+
/**
|
|
58
|
+
* Domain create input: user fields, with `columns` made optional (the domain
|
|
59
|
+
* defaults it to `[]`).
|
|
60
|
+
*/
|
|
61
|
+
export type IViewV2CreateInput = IViewV2UserFields;
|
|
62
|
+
/**
|
|
63
|
+
* Domain update input: only `id` is mandatory; every other user field is optional
|
|
64
|
+
* and only the provided ones are updated.
|
|
65
|
+
*/
|
|
66
|
+
export type IViewV2UpdateInput = Pick<IViewV2ServerFields, 'id'> & Partial<IViewV2UserFields>;
|
|
67
|
+
export interface IViewV2ValuesVersionForGraphql {
|
|
68
|
+
treeId: string;
|
|
69
|
+
treeNode: {
|
|
70
|
+
id: string;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* GraphQL-shaped create input: same as the domain input but `valuesVersions` arrives as
|
|
75
|
+
* an array of `{treeId, treeNode}` pairs.
|
|
76
|
+
*/
|
|
77
|
+
export type IViewV2CreateInputFromGraphQL = Omit<IViewV2CreateInput, 'valuesVersions'> & {
|
|
78
|
+
valuesVersions?: IViewV2ValuesVersionForGraphql[];
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* GraphQL-shaped update input: same as the domain input with array-shaped `valuesVersions`.
|
|
82
|
+
*/
|
|
83
|
+
export type IViewV2UpdateInputFromGraphQL = Omit<IViewV2UpdateInput, 'valuesVersions'> & {
|
|
84
|
+
valuesVersions?: IViewV2ValuesVersionForGraphql[];
|
|
85
|
+
};
|
|
86
|
+
export interface IViewV2FilterOptions extends ICoreEntityFilterOptions {
|
|
87
|
+
created_by?: string;
|
|
88
|
+
library?: string;
|
|
89
|
+
type?: ViewV2Types;
|
|
90
|
+
}
|
|
91
|
+
export {};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { type IGraphqlAppModule } from '../graphql/graphqlApp';
|
|
2
1
|
import { type IAutomationDomain } from '../../domain/automation/automationDomain';
|
|
3
2
|
import { type IAutomationRule } from '../../_types/automation';
|
|
4
3
|
import { type IPaginationParams, type ISortParams } from '../../_types/list';
|
|
5
|
-
import { type IAutomationTriggers } from '../../domain/automation/triggers/automationTriggers';
|
|
6
4
|
import { type IAutomationTriggersRegistry } from '../..//domain/automation/triggers/automationTriggersRegistry';
|
|
7
|
-
|
|
5
|
+
import { type IAutomationActionsRegistry } from '../../domain/automation/automationActionsRegistry';
|
|
6
|
+
import { type IAppModule } from '../../_types/shared';
|
|
7
|
+
import { type IGraphqlAppModule } from '../graphql/graphqlApp';
|
|
8
|
+
export type ICoreAutomationApp = IAppModule & IGraphqlAppModule;
|
|
8
9
|
interface IAutomationAppDeps {
|
|
9
10
|
'core.domain.automation': IAutomationDomain;
|
|
10
|
-
'core.domain.automation.triggers': IAutomationTriggers;
|
|
11
11
|
'core.domain.automation.triggers.registry': IAutomationTriggersRegistry;
|
|
12
|
+
'core.domain.automation.actionsRegistry': IAutomationActionsRegistry;
|
|
12
13
|
}
|
|
13
14
|
export interface IGetAutomationRulesArgs {
|
|
14
15
|
filters?: ICoreEntityFilterOptions & {
|
|
@@ -20,5 +21,5 @@ export interface IGetAutomationRulesArgs {
|
|
|
20
21
|
pagination?: IPaginationParams;
|
|
21
22
|
sort?: ISortParams;
|
|
22
23
|
}
|
|
23
|
-
export default function ({ 'core.domain.automation': automationDomain, 'core.domain.automation.triggers':
|
|
24
|
+
export default function ({ 'core.domain.automation': automationDomain, 'core.domain.automation.triggers.registry': automationTriggersRegistry, 'core.domain.automation.actionsRegistry': automationActionsRegistry, }: IAutomationAppDeps): ICoreAutomationApp;
|
|
24
25
|
export {};
|
|
@@ -24,4 +24,5 @@ export { default as userData } from './userDataApp';
|
|
|
24
24
|
export { default as value } from './valueApp';
|
|
25
25
|
export { default as versionProfile } from './versionProfileApp/versionProfileApp';
|
|
26
26
|
export { default as view } from './viewApp';
|
|
27
|
+
export { default as viewV2 } from './viewV2App';
|
|
27
28
|
export { default as discussion } from './discussionApp';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type IAttributeDomain } from '../../domain/attribute/attributeDomain';
|
|
2
|
+
import { type IRecordDomain } from '../../domain/record/recordDomain';
|
|
3
|
+
import { type IViewV2Domain } from '../../domain/viewV2/viewV2Domain';
|
|
4
|
+
import { type IUtils } from '../../utils/utils';
|
|
5
|
+
import { type IGraphqlAppModule } from '../graphql/graphqlApp';
|
|
6
|
+
interface IDeps {
|
|
7
|
+
'core.domain.attribute': IAttributeDomain;
|
|
8
|
+
'core.domain.record': IRecordDomain;
|
|
9
|
+
'core.domain.viewV2': IViewV2Domain;
|
|
10
|
+
'core.utils': IUtils;
|
|
11
|
+
}
|
|
12
|
+
export type IViewV2App = IGraphqlAppModule;
|
|
13
|
+
export default function ({ 'core.domain.attribute': attributeDomain, 'core.domain.viewV2': viewV2Domain, 'core.domain.record': recordDomain, 'core.utils': utils, }: IDeps): IViewV2App;
|
|
14
|
+
export {};
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import { type ZodObject } from 'zod';
|
|
2
|
-
import { type IAutomationPipelineExecutionState } from '../pipeline/_types';
|
|
2
|
+
import { type AutomationRulePipelineStep, type IAutomationPipelineExecutionState } from '../pipeline/_types';
|
|
3
3
|
import { type IQueryInfos } from '../../../_types/queryInfos';
|
|
4
|
+
import { type AutomationRuleTrigger } from '../../../_types/automation';
|
|
4
5
|
export declare enum AutomationRuleActions {
|
|
5
6
|
LOG = "log",
|
|
6
7
|
CONDITION = "condition",
|
|
7
8
|
ERROR = "error",
|
|
8
9
|
JEXL_CALCULATION = "jexlCalculation",
|
|
9
|
-
MODIFY_ATTRIBUTE = "modifyAttribute"
|
|
10
|
+
MODIFY_ATTRIBUTE = "modifyAttribute",
|
|
11
|
+
NOTIFICATION = "notification"
|
|
10
12
|
}
|
|
11
|
-
export
|
|
13
|
+
export type AutomationPipelineStepValidation<Params = Record<string, unknown>> = {
|
|
14
|
+
readonly step: AutomationRulePipelineStep<Params>;
|
|
15
|
+
readonly stepIndex: number;
|
|
16
|
+
readonly trigger: AutomationRuleTrigger;
|
|
17
|
+
readonly precedingStepsByExecOrder: AutomationRulePipelineStep[];
|
|
18
|
+
};
|
|
19
|
+
export interface IAutomationAction<Params = Record<string, unknown>> {
|
|
12
20
|
readonly type: AutomationRuleActions | string;
|
|
13
21
|
readonly paramsSchema: ZodObject<any>;
|
|
14
|
-
|
|
22
|
+
validateStep?: (params: AutomationPipelineStepValidation<Params>, ctx: IQueryInfos) => Promise<void>;
|
|
15
23
|
execute(params: Params, state: IAutomationPipelineExecutionState, ctx: IQueryInfos): Promise<IActionExecutionResult | void>;
|
|
16
24
|
}
|
|
17
25
|
export declare enum ActionExecutionResultStatus {
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { type IAutomationAction } from './_types';
|
|
3
|
+
import { type IJexlAutomation } from '../jexl/jexlAutomation';
|
|
3
4
|
declare const conditionActionParamsSchema: z.ZodObject<{
|
|
4
|
-
|
|
5
|
+
expression: z.ZodString;
|
|
5
6
|
}, z.core.$strip>;
|
|
6
7
|
export type ConditionActionParams = z.infer<typeof conditionActionParamsSchema>;
|
|
7
|
-
|
|
8
|
+
interface IConditionActionDeps {
|
|
9
|
+
'core.domain.automation.jexl': IJexlAutomation;
|
|
10
|
+
}
|
|
11
|
+
export default function ({ 'core.domain.automation.jexl': jexlAutomation, }: IConditionActionDeps): IAutomationAction<ConditionActionParams>;
|
|
8
12
|
export {};
|
|
@@ -3,3 +3,4 @@ export { default as error } from './errorAction';
|
|
|
3
3
|
export { default as log } from './logAction';
|
|
4
4
|
export { default as jexlCalculation } from './jexlCalculationAutomationAction';
|
|
5
5
|
export { default as modifyAttribute } from './modifyAttributeAction';
|
|
6
|
+
export { default as notification } from './notificationAction';
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { type IJexlDomain } from '../../jexl/jexlDomain';
|
|
3
2
|
import { type IConfig } from '../../../_types/config';
|
|
4
3
|
import { type IAutomationAction } from './_types';
|
|
4
|
+
import { type IJexlAutomation } from '../jexl/jexlAutomation';
|
|
5
5
|
declare const jexlCalculationActionParamsSchema: z.ZodObject<{
|
|
6
6
|
formula: z.ZodString;
|
|
7
7
|
}, z.core.$strip>;
|
|
8
8
|
export type JexlCalculationActionParams = z.infer<typeof jexlCalculationActionParamsSchema>;
|
|
9
9
|
interface IDeps {
|
|
10
|
-
'core.domain.jexl':
|
|
10
|
+
'core.domain.automation.jexl': IJexlAutomation;
|
|
11
11
|
config: IConfig;
|
|
12
12
|
}
|
|
13
|
-
export default function ({ 'core.domain.jexl':
|
|
13
|
+
export default function ({ 'core.domain.automation.jexl': jexlAutomation, config, }: IDeps): IAutomationAction<JexlCalculationActionParams>;
|
|
14
14
|
export {};
|
|
@@ -2,6 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { type IAutomationAction } from './_types';
|
|
3
3
|
import { type IValueDomain } from '../../value/valueDomain';
|
|
4
4
|
import { type IAttributeDomain } from '../../attribute/attributeDomain';
|
|
5
|
+
import { type IValidateHelper } from '../../helpers/validate';
|
|
5
6
|
declare const modifyAttributeActionParamsSchema: z.ZodObject<{
|
|
6
7
|
attributePath: z.ZodString;
|
|
7
8
|
mode: z.ZodEnum<{
|
|
@@ -13,6 +14,7 @@ export type ModifyAttributeActionParams = z.infer<typeof modifyAttributeActionPa
|
|
|
13
14
|
interface IDeps {
|
|
14
15
|
'core.domain.value': IValueDomain;
|
|
15
16
|
'core.domain.attribute': IAttributeDomain;
|
|
17
|
+
'core.domain.helpers.validate': IValidateHelper;
|
|
16
18
|
}
|
|
17
|
-
export default function ({ 'core.domain.value': valueDomain, 'core.domain.attribute': attributeDomain, }: IDeps): IAutomationAction<ModifyAttributeActionParams>;
|
|
19
|
+
export default function ({ 'core.domain.value': valueDomain, 'core.domain.attribute': attributeDomain, 'core.domain.helpers.validate': validateHelper, }: IDeps): IAutomationAction<ModifyAttributeActionParams>;
|
|
18
20
|
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type IAutomationAction } from './_types';
|
|
3
|
+
import { type INotificationDomain } from '../../notification/notificationDomain';
|
|
4
|
+
import { type IJexlAutomation } from '../jexl/jexlAutomation';
|
|
5
|
+
declare const notificationActionParamsSchema: z.ZodObject<{
|
|
6
|
+
title: z.ZodString;
|
|
7
|
+
recipients: z.ZodString;
|
|
8
|
+
message: z.ZodString;
|
|
9
|
+
mail: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export type NotificationActionParams = z.infer<typeof notificationActionParamsSchema>;
|
|
12
|
+
interface INotificationActionDeps {
|
|
13
|
+
'core.domain.automation.jexl': IJexlAutomation;
|
|
14
|
+
'core.domain.notification': INotificationDomain;
|
|
15
|
+
}
|
|
16
|
+
export default function ({ 'core.domain.automation.jexl': jexlAutomation, 'core.domain.notification': notification, }: INotificationActionDeps): IAutomationAction<NotificationActionParams>;
|
|
17
|
+
export {};
|
|
@@ -2,6 +2,7 @@ import { type AwilixContainer } from 'awilix';
|
|
|
2
2
|
import { type IAutomationAction, type AutomationRuleActions } from './actions/_types';
|
|
3
3
|
export interface IAutomationActionsRegistry {
|
|
4
4
|
getAction(type: AutomationRuleActions | string): IAutomationAction | undefined;
|
|
5
|
+
registerAction(actions: IAutomationAction): void;
|
|
5
6
|
listAvailableActions(): IAutomationAction[];
|
|
6
7
|
}
|
|
7
8
|
export interface IAutomationActionsRegistryDeps {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ICreateAutomationRule, type IAutomationRule, type IUpdateAutomationRule, type
|
|
1
|
+
import { type ICreateAutomationRule, type IAutomationRule, type IUpdateAutomationRule, type AutomationRuleEventTopic, type AutomationRuleEventAction, type AutomationRuleJsonSchemaFormType } from '../../_types/automation';
|
|
2
2
|
import { type IList } from '../../_types/list';
|
|
3
3
|
import { type IQueryInfos } from '../../_types/queryInfos';
|
|
4
4
|
import { type IGetCoreEntitiesParams } from '../../_types/shared';
|
|
@@ -7,20 +7,24 @@ import { type IAdminPermissionDomain } from '../permission/adminPermissionDomain
|
|
|
7
7
|
import { type IEventsManagerDomain } from '../eventsManager/eventsManagerDomain';
|
|
8
8
|
import { type IConfig } from '../../_types/config';
|
|
9
9
|
import { type IAutomationPipelineDomain } from './pipeline/pipeline';
|
|
10
|
+
import { type IAutomationRulesCache } from './automationRulesCache';
|
|
10
11
|
import { type IAutomationTriggers } from './triggers/automationTriggers';
|
|
11
|
-
import { type
|
|
12
|
+
import { type IAutomationActionsRegistry } from './automationActionsRegistry';
|
|
13
|
+
import { type IAutomationJsonSchemaFormDomain } from './form/automationJsonSchemaForm';
|
|
14
|
+
import { type IAutomationUiJsonSchemaFormDomain } from './form/automationUiJsonSchemaForm';
|
|
15
|
+
import { type UiSchema, type RJSFSchema } from '@rjsf/utils';
|
|
12
16
|
export interface IGetAutomationRulesParams extends IGetCoreEntitiesParams {
|
|
13
17
|
filters?: ICoreEntityFilterOptions & {
|
|
14
18
|
active?: boolean;
|
|
15
19
|
synchronous?: boolean;
|
|
16
20
|
eventAction?: AutomationRuleEventAction;
|
|
17
|
-
eventTopic?:
|
|
21
|
+
eventTopic?: AutomationRuleEventTopic;
|
|
18
22
|
};
|
|
19
23
|
}
|
|
20
24
|
interface ITriggerRulesParams {
|
|
21
25
|
event: {
|
|
22
|
-
action:
|
|
23
|
-
topic?:
|
|
26
|
+
action: AutomationRuleEventAction;
|
|
27
|
+
topic?: AutomationRuleEventTopic;
|
|
24
28
|
};
|
|
25
29
|
synchronous: boolean;
|
|
26
30
|
ctx: IQueryInfos;
|
|
@@ -30,6 +34,14 @@ export interface IAutomationDomain {
|
|
|
30
34
|
params: IGetAutomationRulesParams;
|
|
31
35
|
ctx: IQueryInfos;
|
|
32
36
|
}): Promise<IList<IAutomationRule>>;
|
|
37
|
+
getAutomationRuleJsonSchemaForm({ formType, ctx, }: {
|
|
38
|
+
formType: AutomationRuleJsonSchemaFormType;
|
|
39
|
+
ctx: IQueryInfos;
|
|
40
|
+
}): Promise<RJSFSchema>;
|
|
41
|
+
getAutomationRuleUiJsonSchemaForm({ formType, ctx, }: {
|
|
42
|
+
formType: AutomationRuleJsonSchemaFormType;
|
|
43
|
+
ctx: IQueryInfos;
|
|
44
|
+
}): Promise<UiSchema>;
|
|
33
45
|
createAutomationRule({ rule, ctx }: {
|
|
34
46
|
rule: ICreateAutomationRule;
|
|
35
47
|
ctx: IQueryInfos;
|
|
@@ -43,17 +55,18 @@ export interface IAutomationDomain {
|
|
|
43
55
|
ctx: IQueryInfos;
|
|
44
56
|
}): Promise<IAutomationRule>;
|
|
45
57
|
triggerRules(params: ITriggerRulesParams): Promise<void>;
|
|
46
|
-
listAutomationTriggersDef({ ctx }: {
|
|
47
|
-
ctx: IQueryInfos;
|
|
48
|
-
}): Promise<AutomationTriggerDef[]>;
|
|
49
58
|
}
|
|
50
59
|
export interface IAutomationDomainDeps {
|
|
51
60
|
'core.domain.automation.triggers': IAutomationTriggers;
|
|
61
|
+
'core.domain.automation.form': IAutomationJsonSchemaFormDomain;
|
|
62
|
+
'core.domain.automation.form.uiJsonSchemaForm': IAutomationUiJsonSchemaFormDomain;
|
|
52
63
|
'core.domain.permission.admin': IAdminPermissionDomain;
|
|
53
64
|
'core.domain.eventsManager': IEventsManagerDomain;
|
|
54
65
|
'core.domain.automation.pipeline': IAutomationPipelineDomain;
|
|
66
|
+
'core.domain.automation.rulesCache': IAutomationRulesCache;
|
|
55
67
|
'core.infra.automation.rule': IAutomationRuleRepo;
|
|
68
|
+
'core.domain.automation.actionsRegistry': IAutomationActionsRegistry;
|
|
56
69
|
config: IConfig;
|
|
57
70
|
}
|
|
58
|
-
export default function ({ 'core.domain.automation.triggers': automationTriggers, 'core.domain.permission.admin': adminPermissionDomain, 'core.domain.eventsManager': eventsManagerDomain, 'core.domain.automation.pipeline': pipelineDomain, 'core.infra.automation.rule': automationRuleRepo, config, }: IAutomationDomainDeps): IAutomationDomain;
|
|
71
|
+
export default function ({ 'core.domain.automation.triggers': automationTriggers, 'core.domain.automation.form': automationJsonSchemaFormDomain, 'core.domain.automation.form.uiJsonSchemaForm': automationUiJsonSchemaFormDomain, 'core.domain.permission.admin': adminPermissionDomain, 'core.domain.eventsManager': eventsManagerDomain, 'core.domain.automation.pipeline': pipelineDomain, 'core.domain.automation.rulesCache': automationRulesCache, 'core.infra.automation.rule': automationRuleRepo, 'core.domain.automation.actionsRegistry': automationActionsRegistry, config, }: IAutomationDomainDeps): IAutomationDomain;
|
|
59
72
|
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type AutomationRuleEventAction, type AutomationRuleEventTopic, type IAutomationRule } from '../../_types/automation';
|
|
2
|
+
import { type IConfig } from '../../_types/config';
|
|
3
|
+
import { type IQueryInfos } from '../../_types/queryInfos';
|
|
4
|
+
import { type IAutomationRuleRepo } from '../../infra/automation/automationRuleRepo';
|
|
5
|
+
import { type ICachesService } from '../../infra/cache/cacheService';
|
|
6
|
+
/**
|
|
7
|
+
* Two-tier cache for automation rules, shared across every `core` replica
|
|
8
|
+
* via Redis.
|
|
9
|
+
*
|
|
10
|
+
* ## Structure
|
|
11
|
+
*
|
|
12
|
+
* 1. **Index** under the key `automation:rules:index` → `AutomationRuleIndexEntry[]`
|
|
13
|
+
* (= `Pick<IAutomationRule, 'id' | 'trigger'>[]`). Holds the bare minimum
|
|
14
|
+
* needed to decide which rules match an event (action, sync, topic).
|
|
15
|
+
* Built on the ArangoDB side via a dedicated AQL projection
|
|
16
|
+
* (`automationRuleRepo.getActiveAutomationRulesForCache`) — pipelines and
|
|
17
|
+
* metadata never leave the Arango server.
|
|
18
|
+
*
|
|
19
|
+
* 2. **Per-rule cache** under `automation:rules:{ruleId}` → the full
|
|
20
|
+
* `IAutomationRule` (pipeline included). Populated **lazily**: only a rule
|
|
21
|
+
* that is actually matched by an event triggers the fetch + caching of its
|
|
22
|
+
* full payload.
|
|
23
|
+
*
|
|
24
|
+
* ## Why this split
|
|
25
|
+
*
|
|
26
|
+
* Selecting which rules to execute only depends on `trigger`; the `pipeline`
|
|
27
|
+
* is only required when the rule actually runs. With a naive "full-list"
|
|
28
|
+
* cache, every event would load all pipelines (potentially large) to execute
|
|
29
|
+
* 0 to a handful of them. The lightweight index bounds the selection cost to
|
|
30
|
+
* an `{id, trigger}` payload × number of active rules; only the pipelines of
|
|
31
|
+
* matching rules are fetched.
|
|
32
|
+
*
|
|
33
|
+
* ## Targeted invalidation
|
|
34
|
+
*
|
|
35
|
+
* `invalidate(ruleId)` removes only `[INDEX_RULES_CACHE_KEY,
|
|
36
|
+
* ruleCacheKey(ruleId)]`. Other rules keep their Redis entry intact — their
|
|
37
|
+
* pipelines are not reloaded until a modification targets them. Relevant
|
|
38
|
+
* when an admin edits a single rule among dozens (the typical case).
|
|
39
|
+
*
|
|
40
|
+
* `invalidate()` without an argument performs a full wipe via the
|
|
41
|
+
* `RULES_CACHE_KEYS_PATTERN` glob (useful for tests and global admin purges).
|
|
42
|
+
*
|
|
43
|
+
* ## Lazy per-rule population (not eager)
|
|
44
|
+
*
|
|
45
|
+
* On an index rebuild, per-rule caches are NOT re-written. Otherwise,
|
|
46
|
+
* re-writing every rule on each modification would defeat the "preserve
|
|
47
|
+
* other rules" guarantee. Acceptable trade-off: if a matched rule has never
|
|
48
|
+
* been cached, `_loadRuleById` performs an extra repo fetch — the debt is
|
|
49
|
+
* amortized by subsequent hits.
|
|
50
|
+
*/
|
|
51
|
+
export declare const INDEX_RULES_CACHE_KEY = "automation:rules:index";
|
|
52
|
+
export declare const RULES_CACHE_KEYS_PATTERN = "automation:rules:*";
|
|
53
|
+
export declare const ruleCacheKey: (id: string) => string;
|
|
54
|
+
export interface IAutomationRulesCache {
|
|
55
|
+
getRulesToTrigger(event: {
|
|
56
|
+
action: AutomationRuleEventAction;
|
|
57
|
+
topic?: AutomationRuleEventTopic;
|
|
58
|
+
}, synchronous: boolean, ctx: IQueryInfos): Promise<IAutomationRule[]>;
|
|
59
|
+
invalidate(ruleId?: string): Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
export interface IAutomationRulesCacheDeps {
|
|
62
|
+
'core.infra.cache.cacheService': ICachesService;
|
|
63
|
+
'core.infra.automation.rule': IAutomationRuleRepo;
|
|
64
|
+
config: IConfig;
|
|
65
|
+
}
|
|
66
|
+
export default function ({ 'core.infra.cache.cacheService': cachesService, 'core.infra.automation.rule': automationRuleRepo, config, }: IAutomationRulesCacheDeps): IAutomationRulesCache;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type AutomationRuleEventAction, type
|
|
1
|
+
import { type AutomationRuleEventAction, type AutomationRuleEventTopic, type IAutomationRule } from '../../_types/automation';
|
|
2
2
|
import { type IQueryInfos } from '../../_types/queryInfos';
|
|
3
3
|
export declare const TRIGGER_FAKER_RULES_FOR_DEV = false;
|
|
4
4
|
export declare const buildFakeRulesToTrigger: (event: {
|
|
5
5
|
action: AutomationRuleEventAction;
|
|
6
|
-
topic?:
|
|
6
|
+
topic?: AutomationRuleEventTopic;
|
|
7
7
|
}, synchronous: boolean, ctx: IQueryInfos) => Promise<IAutomationRule[]>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AutomationRuleJsonSchemaFormType } from '../../../_types/automation';
|
|
2
|
+
import { type IQueryInfos } from '../../../_types/queryInfos';
|
|
3
|
+
import { type IAutomationTriggersRegistry } from '../triggers/automationTriggersRegistry';
|
|
4
|
+
import { type IAutomationActionsRegistry } from '../automationActionsRegistry';
|
|
5
|
+
import { type RJSFSchema } from '@rjsf/utils';
|
|
6
|
+
export interface IAutomationJsonSchemaFormDomain {
|
|
7
|
+
getAutomationRuleJsonSchemaForm({ formType, ctx, }: {
|
|
8
|
+
formType: AutomationRuleJsonSchemaFormType;
|
|
9
|
+
ctx: IQueryInfos;
|
|
10
|
+
}): Promise<RJSFSchema>;
|
|
11
|
+
}
|
|
12
|
+
interface IAutomationJsonSchemaFormDomainDeps {
|
|
13
|
+
'core.domain.automation.triggers.registry': IAutomationTriggersRegistry;
|
|
14
|
+
'core.domain.automation.actionsRegistry': IAutomationActionsRegistry;
|
|
15
|
+
}
|
|
16
|
+
export declare const extractAndLiftDefs: (jsonSchema: RJSFSchema) => {
|
|
17
|
+
schema: RJSFSchema;
|
|
18
|
+
defs: Record<string, RJSFSchema>;
|
|
19
|
+
};
|
|
20
|
+
export default function ({ 'core.domain.automation.triggers.registry': automationTriggersRegistry, 'core.domain.automation.actionsRegistry': actionsRegistry, }: IAutomationJsonSchemaFormDomainDeps): IAutomationJsonSchemaFormDomain;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type i18n } from 'i18next';
|
|
2
|
+
import { type UiSchema } from '@rjsf/utils';
|
|
3
|
+
import { AutomationRuleJsonSchemaFormType } from '../../../_types/automation';
|
|
4
|
+
import { type IQueryInfos } from '../../../_types/queryInfos';
|
|
5
|
+
import { type IAutomationTriggersRegistry } from '../triggers/automationTriggersRegistry';
|
|
6
|
+
import { type IAutomationActionsRegistry } from '../automationActionsRegistry';
|
|
7
|
+
export interface IAutomationUiJsonSchemaFormDomain {
|
|
8
|
+
getAutomationRuleUiJsonSchemaForm({ formType, ctx, }: {
|
|
9
|
+
formType: AutomationRuleJsonSchemaFormType;
|
|
10
|
+
ctx: IQueryInfos;
|
|
11
|
+
}): Promise<UiSchema>;
|
|
12
|
+
}
|
|
13
|
+
interface IAutomationUiJsonSchemaFormDomainDeps {
|
|
14
|
+
translator: i18n;
|
|
15
|
+
'core.domain.automation.triggers.registry': IAutomationTriggersRegistry;
|
|
16
|
+
'core.domain.automation.actionsRegistry': IAutomationActionsRegistry;
|
|
17
|
+
}
|
|
18
|
+
export default function ({ translator, 'core.domain.automation.triggers.registry': automationTriggersRegistry, 'core.domain.automation.actionsRegistry': actionsRegistry, }: IAutomationUiJsonSchemaFormDomainDeps): IAutomationUiJsonSchemaFormDomain;
|
|
19
|
+
export {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { default } from './automationDomain';
|
|
2
2
|
export { default as actionsRegistry } from './automationActionsRegistry';
|
|
3
|
+
export { default as form } from './form';
|
|
3
4
|
export { default as pipeline } from './pipeline';
|
|
5
|
+
export { default as rulesCache } from './automationRulesCache';
|
|
4
6
|
export { default as triggers } from './triggers';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './jexlAutomation';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type IQueryInfos } from '../../../_types/queryInfos';
|
|
2
|
+
import { type IJexlDomain } from '../../jexl/jexlDomain';
|
|
3
|
+
import { type IAutomationPipelineExecutionState } from '../pipeline/_types';
|
|
4
|
+
import { type JexlRootContext, type JexlRecordContext } from '../../jexl/types';
|
|
5
|
+
interface IDeps {
|
|
6
|
+
'core.domain.jexl': IJexlDomain;
|
|
7
|
+
}
|
|
8
|
+
type JexlAutomationContext = JexlRootContext<{
|
|
9
|
+
results: IAutomationPipelineExecutionState['results'];
|
|
10
|
+
currentRecord?: JexlRecordContext;
|
|
11
|
+
}>;
|
|
12
|
+
export interface IJexlAutomation extends Pick<IJexlDomain, 'eval' | 'validate'> {
|
|
13
|
+
buildAutomationContext: (executionState: IAutomationPipelineExecutionState, ctx: IQueryInfos) => JexlAutomationContext;
|
|
14
|
+
}
|
|
15
|
+
export default function ({ 'core.domain.jexl': jexlDomain }: IDeps): IJexlAutomation;
|
|
16
|
+
export {};
|