@aristid/leav-types 1.12.0-a0a98764 → 1.12.0-b0c6d69c

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.
Files changed (40) hide show
  1. package/CLAUDE.md +42 -0
  2. package/apps/core/config/default.d.ts +4 -0
  3. package/apps/core/config/development.d.ts +4 -0
  4. package/apps/core/config/test.d.ts +4 -0
  5. package/apps/core/src/__tests__/e2e/_gqlTypes/index.d.ts +123 -49
  6. package/apps/core/src/__tests__/e2e/api/e2eUtils.d.ts +0 -7
  7. package/apps/core/src/__tests__/integration/domain/automation/pipelineExecutor.test.d.ts +1 -0
  8. package/apps/core/src/_types/automation.d.ts +38 -11
  9. package/apps/core/src/_types/config.d.ts +4 -0
  10. package/apps/core/src/app/core/automationApp.d.ts +9 -4
  11. package/apps/core/src/app/core/eventsManagerApp.d.ts +2 -1
  12. package/apps/core/src/domain/automation/actions/conditionAction.d.ts +8 -0
  13. package/apps/core/src/domain/automation/actions/errorAction.d.ts +8 -0
  14. package/apps/core/src/domain/automation/actions/index.d.ts +3 -0
  15. package/apps/core/src/domain/automation/actions/logAction.d.ts +16 -0
  16. package/apps/core/src/domain/automation/automationDomain.d.ts +13 -2
  17. package/apps/core/src/domain/automation/fakeRulesToTrigger.d.ts +7 -0
  18. package/apps/core/src/domain/automation/index.d.ts +1 -0
  19. package/apps/core/src/domain/automation/pipelineExecutor.d.ts +16 -0
  20. package/apps/core/src/domain/automation/pipelineExecutor.spec.d.ts +1 -0
  21. package/apps/core/src/domain/automation/types.d.ts +22 -0
  22. package/apps/core/src/domain/record/helpers/createRecord.d.ts +3 -1
  23. package/apps/core/src/domain/record/helpers/getRecordIdentity.d.ts +27 -0
  24. package/apps/core/src/domain/record/helpers/getRecordIdentity.spec.d.ts +1 -0
  25. package/apps/core/src/domain/record/helpers/index.d.ts +1 -0
  26. package/apps/core/src/domain/record/recordDomain.d.ts +3 -11
  27. package/apps/core/src/domain/value/helpers/formatValue.d.ts +17 -0
  28. package/apps/core/src/domain/value/helpers/getRecordFieldValue.d.ts +27 -0
  29. package/apps/core/src/domain/value/helpers/getRecordFieldValue.spec.d.ts +1 -0
  30. package/apps/core/src/domain/value/helpers/getValues.d.ts +26 -0
  31. package/apps/core/src/domain/value/helpers/getValues.spec.d.ts +1 -0
  32. package/apps/core/src/domain/value/helpers/index.d.ts +7 -0
  33. package/apps/core/src/domain/value/helpers/manageEventMetadata.d.ts +4 -0
  34. package/apps/core/src/domain/value/helpers/runActionsList.d.ts +10 -0
  35. package/apps/core/src/domain/value/valueDomain.d.ts +11 -1
  36. package/apps/core/src/infra/automation/automationRuleRepo.d.ts +7 -1
  37. package/apps/core/src/infra/db/dbUtils.d.ts +5 -1
  38. package/apps/core/tsconfig.types.tsbuildinfo +1 -1
  39. package/package.json +1 -1
  40. package/apps/core/src/domain/record/helpers/getRecordFieldValue.spec.d.ts +0 -0
package/CLAUDE.md ADDED
@@ -0,0 +1,42 @@
1
+ # libs/types — CLAUDE.md
2
+
3
+ `@aristid/leav-types` — Types TypeScript de `apps/core` publiés sur npm pour les plugins externes.
4
+
5
+ ## Ce que c'est
6
+
7
+ Ce package ne contient **pas de code source** — c'est une projection des types générés
8
+ depuis `apps/core`, destinée aux **développeurs de plugins** qui étendent le core.
9
+
10
+ > ⚠️ Ce package **n'est pas utilisé dans le monorepo lui-même**. Il est uniquement
11
+ > consommé par des repos externes (plugins tiers du core).
12
+
13
+ ## Publication CI (GitLab)
14
+
15
+ Publié automatiquement sur **npm public** (`@aristid/leav-types`) via GitLab CI,
16
+ déclenché par tout changement dans `apps/core/**/*` :
17
+
18
+ - **`next`** — à chaque push sur `develop`
19
+ - **`latest`** — sur les releases taguées
20
+
21
+ ```bash
22
+ # Commande de génération (lancée par le CI)
23
+ yarn workspace @aristid/leav-types generate
24
+ ```
25
+
26
+ ## Problème connu : les enums ne sont pas exportés ⚠️
27
+
28
+ La commande `generate` (basée sur `build-types` du core) n'exporte pas les enums TypeScript.
29
+ Les consommateurs du package doivent **réécrire les enums manuellement** de leur côté —
30
+ ce qui est une source de désynchronisation et de maintenance coûteuse.
31
+
32
+ **Piste de résolution envisagée :** publier davantage de code du core directement
33
+ (pas uniquement les types), de façon à exposer les enums comme du code exécutable.
34
+ C'est un chantier à prioriser.
35
+
36
+ ## Ne jamais modifier manuellement
37
+
38
+ Toujours régénérer via le CI ou :
39
+
40
+ ```bash
41
+ yarn workspace @aristid/leav-types generate
42
+ ```
@@ -287,4 +287,8 @@ export declare namespace logsCollector {
287
287
  let queue: string;
288
288
  }
289
289
  export declare let pluginsPath: string[];
290
+ export declare namespace automation {
291
+ let enable_7: boolean;
292
+ export { enable_7 as enable };
293
+ }
290
294
  export { debug_1 as debug, _export as export, _import as import };
@@ -14,3 +14,7 @@ export namespace dbProfiler {
14
14
  export namespace bugsnag {
15
15
  let releaseStage: string;
16
16
  }
17
+ export namespace automation {
18
+ let enable_1: boolean;
19
+ export { enable_1 as enable };
20
+ }
@@ -90,3 +90,7 @@ export namespace applications {
90
90
  let rootFolder: string;
91
91
  let assetsMaxAge: string;
92
92
  }
93
+ export namespace automation {
94
+ let enable_3: boolean;
95
+ export { enable_3 as enable };
96
+ }
@@ -244,12 +244,53 @@ export declare enum AttributesSortableFields {
244
244
  multiple_values = "multiple_values",
245
245
  type = "type"
246
246
  }
247
+ export declare enum AutomationRuleEventAction {
248
+ API_KEY_DELETE = "API_KEY_DELETE",
249
+ API_KEY_SAVE = "API_KEY_SAVE",
250
+ APP_DELETE = "APP_DELETE",
251
+ APP_SAVE = "APP_SAVE",
252
+ ATTRIBUTE_DELETE = "ATTRIBUTE_DELETE",
253
+ ATTRIBUTE_SAVE = "ATTRIBUTE_SAVE",
254
+ AUTOMATION_RULE_CREATE = "AUTOMATION_RULE_CREATE",
255
+ AUTOMATION_RULE_UPDATE = "AUTOMATION_RULE_UPDATE",
256
+ CONFIG_IMPORT_END = "CONFIG_IMPORT_END",
257
+ CONFIG_IMPORT_START = "CONFIG_IMPORT_START",
258
+ DATA_IMPORT_END = "DATA_IMPORT_END",
259
+ DATA_IMPORT_START = "DATA_IMPORT_START",
260
+ EXPORT_END = "EXPORT_END",
261
+ EXPORT_START = "EXPORT_START",
262
+ GLOBAL_SETTINGS_SAVE = "GLOBAL_SETTINGS_SAVE",
263
+ LIBRARY_DELETE = "LIBRARY_DELETE",
264
+ LIBRARY_PURGE = "LIBRARY_PURGE",
265
+ LIBRARY_SAVE = "LIBRARY_SAVE",
266
+ PERMISSION_SAVE = "PERMISSION_SAVE",
267
+ RECORD_DELETE = "RECORD_DELETE",
268
+ RECORD_INIT = "RECORD_INIT",
269
+ RECORD_SAVE = "RECORD_SAVE",
270
+ TASKS_DELETE = "TASKS_DELETE",
271
+ TREE_ADD_ELEMENT = "TREE_ADD_ELEMENT",
272
+ TREE_DELETE = "TREE_DELETE",
273
+ TREE_DELETE_ELEMENT = "TREE_DELETE_ELEMENT",
274
+ TREE_MOVE_ELEMENT = "TREE_MOVE_ELEMENT",
275
+ TREE_SAVE = "TREE_SAVE",
276
+ VALUE_DELETE = "VALUE_DELETE",
277
+ VALUE_SAVE = "VALUE_SAVE",
278
+ VERSION_PROFILE_DELETE = "VERSION_PROFILE_DELETE",
279
+ VERSION_PROFILE_SAVE = "VERSION_PROFILE_SAVE"
280
+ }
247
281
  export declare enum AutomationRuleSortableFields {
248
282
  id = "id"
249
283
  }
284
+ export type AutomationRuleTriggerInput = {
285
+ eventAction: AutomationRuleEventAction;
286
+ eventTopic?: InputMaybe<EventTopicInput>;
287
+ synchronous: Scalars['Boolean']['input'];
288
+ };
250
289
  export type AutomationRulesFiltersInput = {
290
+ active?: InputMaybe<Scalars['Boolean']['input']>;
251
291
  id?: InputMaybe<Scalars['ID']['input']>;
252
292
  label?: InputMaybe<Scalars['String']['input']>;
293
+ trigger?: InputMaybe<PartialAutomationRuleTriggerInput>;
253
294
  };
254
295
  export type AutomationRulesSortInput = {
255
296
  field: AutomationRuleSortableFields;
@@ -259,16 +300,6 @@ export declare enum AvailableLanguage {
259
300
  en = "en",
260
301
  fr = "fr"
261
302
  }
262
- export type CampaignToRenew = {
263
- endDate: Scalars['String']['input'];
264
- id: Scalars['String']['input'];
265
- startDate: Scalars['String']['input'];
266
- };
267
- export type CampaignToUpdateDates = {
268
- endDate: Scalars['String']['input'];
269
- id: Scalars['String']['input'];
270
- startDate: Scalars['String']['input'];
271
- };
272
303
  export type ChildrenAsRecordValuePermissionFilterInput = {
273
304
  action: RecordPermissionsActions;
274
305
  attributeId: Scalars['ID']['input'];
@@ -277,6 +308,7 @@ export type ChildrenAsRecordValuePermissionFilterInput = {
277
308
  export type CreateAutomationRuleInput = {
278
309
  description?: InputMaybe<Scalars['SystemTranslationOptional']['input']>;
279
310
  label: Scalars['SystemTranslation']['input'];
311
+ trigger: AutomationRuleTriggerInput;
280
312
  };
281
313
  export type CreateRecordDataInput = {
282
314
  values?: InputMaybe<Array<ValueBatchInput>>;
@@ -313,6 +345,59 @@ export type EmbeddedAttributeInput = {
313
345
  label?: InputMaybe<Scalars['SystemTranslation']['input']>;
314
346
  validation_regex?: InputMaybe<Scalars['String']['input']>;
315
347
  };
348
+ export declare enum EventAction {
349
+ API_KEY_DELETE = "API_KEY_DELETE",
350
+ API_KEY_SAVE = "API_KEY_SAVE",
351
+ APP_DELETE = "APP_DELETE",
352
+ APP_SAVE = "APP_SAVE",
353
+ ATTRIBUTE_DELETE = "ATTRIBUTE_DELETE",
354
+ ATTRIBUTE_SAVE = "ATTRIBUTE_SAVE",
355
+ AUTOMATION_RULE_CREATE = "AUTOMATION_RULE_CREATE",
356
+ AUTOMATION_RULE_UPDATE = "AUTOMATION_RULE_UPDATE",
357
+ CONFIG_IMPORT_END = "CONFIG_IMPORT_END",
358
+ CONFIG_IMPORT_START = "CONFIG_IMPORT_START",
359
+ DATA_IMPORT_END = "DATA_IMPORT_END",
360
+ DATA_IMPORT_START = "DATA_IMPORT_START",
361
+ EXPORT_END = "EXPORT_END",
362
+ EXPORT_START = "EXPORT_START",
363
+ GLOBAL_SETTINGS_SAVE = "GLOBAL_SETTINGS_SAVE",
364
+ LIBRARY_DELETE = "LIBRARY_DELETE",
365
+ LIBRARY_PURGE = "LIBRARY_PURGE",
366
+ LIBRARY_SAVE = "LIBRARY_SAVE",
367
+ PERMISSION_SAVE = "PERMISSION_SAVE",
368
+ RECORD_DELETE = "RECORD_DELETE",
369
+ RECORD_SAVE = "RECORD_SAVE",
370
+ TASKS_DELETE = "TASKS_DELETE",
371
+ TREE_ADD_ELEMENT = "TREE_ADD_ELEMENT",
372
+ TREE_DELETE = "TREE_DELETE",
373
+ TREE_DELETE_ELEMENT = "TREE_DELETE_ELEMENT",
374
+ TREE_MOVE_ELEMENT = "TREE_MOVE_ELEMENT",
375
+ TREE_SAVE = "TREE_SAVE",
376
+ VALUE_DELETE = "VALUE_DELETE",
377
+ VALUE_SAVE = "VALUE_SAVE",
378
+ VERSION_PROFILE_DELETE = "VERSION_PROFILE_DELETE",
379
+ VERSION_PROFILE_SAVE = "VERSION_PROFILE_SAVE"
380
+ }
381
+ export type EventTopicInput = {
382
+ apiKey?: InputMaybe<Scalars['String']['input']>;
383
+ application?: InputMaybe<Scalars['String']['input']>;
384
+ attribute?: InputMaybe<Scalars['String']['input']>;
385
+ automationRule?: InputMaybe<Scalars['String']['input']>;
386
+ filename?: InputMaybe<Scalars['String']['input']>;
387
+ library?: InputMaybe<Scalars['String']['input']>;
388
+ permission?: InputMaybe<EventTopicPermissionInput>;
389
+ profile?: InputMaybe<Scalars['String']['input']>;
390
+ record?: InputMaybe<EventTopicRecordInput>;
391
+ tree?: InputMaybe<Scalars['String']['input']>;
392
+ };
393
+ export type EventTopicPermissionInput = {
394
+ applyTo?: InputMaybe<Scalars['String']['input']>;
395
+ id: Scalars['String']['input'];
396
+ };
397
+ export type EventTopicRecordInput = {
398
+ id: Scalars['String']['input'];
399
+ libraryId: Scalars['String']['input'];
400
+ };
316
401
  export type FileInput = {
317
402
  data: Scalars['Upload']['input'];
318
403
  replace?: InputMaybe<Scalars['Boolean']['input']>;
@@ -373,16 +458,6 @@ export declare enum FormsSortableFields {
373
458
  library = "library",
374
459
  system = "system"
375
460
  }
376
- export declare enum GenerationStatus {
377
- DONE = "DONE",
378
- GENERATION_FAILED = "GENERATION_FAILED",
379
- GENERATION_IN_PROGRESS = "GENERATION_IN_PROGRESS",
380
- GENERATION_IN_PROGRESS_WITH_FAILURE = "GENERATION_IN_PROGRESS_WITH_FAILURE",
381
- PREPARATION_FAILED = "PREPARATION_FAILED",
382
- PREPARATION_IN_PROGRESS = "PREPARATION_IN_PROGRESS",
383
- TRANSMISSION_FAILED = "TRANSMISSION_FAILED",
384
- TRANSMISSION_IN_PROGRESS = "TRANSMISSION_IN_PROGRESS"
385
- }
386
461
  export type GlobalSettingsFileInput = {
387
462
  library: Scalars['String']['input'];
388
463
  recordId: Scalars['String']['input'];
@@ -470,8 +545,6 @@ export declare enum LogAction {
470
545
  LIBRARY_PURGE = "LIBRARY_PURGE",
471
546
  LIBRARY_SAVE = "LIBRARY_SAVE",
472
547
  PERMISSION_SAVE = "PERMISSION_SAVE",
473
- PLANNING_RECONDUCTION_END = "PLANNING_RECONDUCTION_END",
474
- PLANNING_RECONDUCTION_START = "PLANNING_RECONDUCTION_START",
475
548
  RECORD_DELETE = "RECORD_DELETE",
476
549
  RECORD_SAVE = "RECORD_SAVE",
477
550
  TASKS_DELETE = "TASKS_DELETE",
@@ -544,6 +617,11 @@ export type Pagination = {
544
617
  limit: Scalars['Int']['input'];
545
618
  offset: Scalars['Int']['input'];
546
619
  };
620
+ export type PartialAutomationRuleTriggerInput = {
621
+ eventAction?: InputMaybe<AutomationRuleEventAction>;
622
+ eventTopic?: InputMaybe<EventTopicInput>;
623
+ synchronous?: InputMaybe<Scalars['Boolean']['input']>;
624
+ };
547
625
  export type PermissionActionInput = {
548
626
  allowed?: InputMaybe<Scalars['Boolean']['input']>;
549
627
  name: PermissionsActions;
@@ -724,26 +802,6 @@ export type RecordsPagination = {
724
802
  limit: Scalars['Int']['input'];
725
803
  offset?: InputMaybe<Scalars['Int']['input']>;
726
804
  };
727
- export type ReportFramingAttributeFilterItemInput = {
728
- attributeId: Scalars['String']['input'];
729
- values: Array<ReportFramingAttributeFilterValueItemInput>;
730
- withEmptyValues?: InputMaybe<Scalars['Boolean']['input']>;
731
- };
732
- export type ReportFramingAttributeFilterValueItemInput = {
733
- formattedValue?: InputMaybe<Scalars['String']['input']>;
734
- rawValue: Scalars['String']['input'];
735
- };
736
- export type ReportFramingContentInput = {
737
- filters?: InputMaybe<ReportFramingFiltersInput>;
738
- };
739
- export type ReportFramingFiltersInput = {
740
- /** only for excel header filter display */
741
- attributes?: InputMaybe<Array<ReportFramingAttributeFilterItemInput>>;
742
- campaigns?: InputMaybe<Array<RecordFilterInput>>;
743
- categories?: InputMaybe<Array<Scalars['String']['input']>>;
744
- categoryStatus?: InputMaybe<Array<Scalars['String']['input']>>;
745
- search?: InputMaybe<Scalars['String']['input']>;
746
- };
747
805
  export type SaveValueBulkMappingInput = {
748
806
  dependenciesFilters?: InputMaybe<Array<InputMaybe<RecordFilterInput>>>;
749
807
  values: Array<SaveValueBulkMappingValueInput>;
@@ -815,18 +873,12 @@ export declare enum TaskStatus {
815
873
  }
816
874
  export declare enum TaskType {
817
875
  EXPORT = "EXPORT",
818
- FRAMING_REPORT = "FRAMING_REPORT",
819
876
  IMPORT_CONFIG = "IMPORT_CONFIG",
820
877
  IMPORT_DATA = "IMPORT_DATA",
821
878
  INDEXATION = "INDEXATION",
822
879
  PURGE_MULTIPLE_VALUES = "PURGE_MULTIPLE_VALUES",
823
- RENEW_CAMPAIGNS = "RENEW_CAMPAIGNS",
824
880
  SAVE_VALUE_BULK = "SAVE_VALUE_BULK"
825
881
  }
826
- export type ThematicToRenew = {
827
- campaignId: Scalars['String']['input'];
828
- thematicId: Scalars['String']['input'];
829
- };
830
882
  export declare enum TreeBehavior {
831
883
  files = "files",
832
884
  standard = "standard"
@@ -892,6 +944,7 @@ export type UpdateAutomationRuleInput = {
892
944
  description?: InputMaybe<Scalars['SystemTranslationOptional']['input']>;
893
945
  id: Scalars['ID']['input'];
894
946
  label?: InputMaybe<Scalars['SystemTranslation']['input']>;
947
+ trigger?: InputMaybe<PartialAutomationRuleTriggerInput>;
895
948
  };
896
949
  export type UploadFiltersInput = {
897
950
  uid?: InputMaybe<Scalars['String']['input']>;
@@ -1083,7 +1136,7 @@ export type MeQuery = {
1083
1136
  } | null;
1084
1137
  };
1085
1138
  export type GetAutomationRulesQueryVariables = Exact<{
1086
- [key: string]: never;
1139
+ filters?: InputMaybe<AutomationRulesFiltersInput>;
1087
1140
  }>;
1088
1141
  export type GetAutomationRulesQuery = {
1089
1142
  automationRules: {
@@ -1096,6 +1149,13 @@ export type GetAutomationRulesQuery = {
1096
1149
  createdBy: string;
1097
1150
  modifiedAt: number;
1098
1151
  modifiedBy: string;
1152
+ trigger: {
1153
+ synchronous: boolean;
1154
+ eventAction: AutomationRuleEventAction;
1155
+ eventTopic?: {
1156
+ library?: string | null;
1157
+ } | null;
1158
+ };
1099
1159
  }>;
1100
1160
  };
1101
1161
  };
@@ -1107,6 +1167,13 @@ export type CreateAutomationRuleMutation = {
1107
1167
  id: string;
1108
1168
  label: any;
1109
1169
  modifiedAt: number;
1170
+ trigger: {
1171
+ synchronous: boolean;
1172
+ eventAction: AutomationRuleEventAction;
1173
+ eventTopic?: {
1174
+ library?: string | null;
1175
+ } | null;
1176
+ };
1110
1177
  };
1111
1178
  };
1112
1179
  export type UpdateAutomationRuleMutationVariables = Exact<{
@@ -1119,6 +1186,13 @@ export type UpdateAutomationRuleMutation = {
1119
1186
  description?: any | null;
1120
1187
  active: boolean;
1121
1188
  modifiedAt: number;
1189
+ trigger: {
1190
+ synchronous: boolean;
1191
+ eventAction: AutomationRuleEventAction;
1192
+ eventTopic?: {
1193
+ library?: string | null;
1194
+ } | null;
1195
+ };
1122
1196
  };
1123
1197
  };
1124
1198
  export type GetRecordsLinkValuesPropertyQueryVariables = Exact<{
@@ -104,13 +104,6 @@ export declare const nonAdminUserSdk: {
104
104
  };
105
105
  export declare function makeGraphQlCall(query: string | FormData, options?: IMakeGraphQlCallOptions): Promise<any>;
106
106
  export declare function importFileGraphQlCall(query: string, filePath: string, sheets?: any): Promise<any>;
107
- export declare function gqlSaveLibrary(id: string, label: string, additionalAttributes?: string[], settings?: string, recordIdentityConf?: {
108
- label: string;
109
- subLabel?: string;
110
- preview?: string;
111
- color?: string;
112
- treeColorPreview?: string;
113
- }): Promise<any>;
114
107
  export declare function gqlSaveApplication(id: string, label: string, endpoint: string): Promise<any>;
115
108
  export declare function gqlSaveAttribute(params: {
116
109
  id: string;
@@ -1,21 +1,48 @@
1
- import { type ISystemTranslation } from './systemTranslation';
1
+ import { type EventAction, type IDbPayload } from '@leav/utils';
2
2
  export type IAutomationRule = ICoreEntity & {
3
+ createdAt: number;
4
+ createdBy: string;
5
+ modifiedAt: number;
6
+ modifiedBy: string;
3
7
  id: string;
4
- label: ISystemTranslation;
5
- description?: ISystemTranslation;
8
+ label: string;
9
+ description?: string;
6
10
  active: boolean;
7
- createdAt?: number;
8
- createdBy?: string;
9
- modifiedAt?: number;
10
- modifiedBy?: string;
11
+ trigger: AutomationRuleTrigger;
12
+ pipeline: AutomationRulePipeline;
11
13
  };
12
14
  export type ICreateAutomationRule = {
13
- label: ISystemTranslation;
14
- description?: ISystemTranslation;
15
+ label: string;
16
+ description?: string;
17
+ trigger: AutomationRuleTrigger;
15
18
  };
16
19
  export type IUpdateAutomationRule = {
17
20
  id: string;
18
- label?: ISystemTranslation;
19
- description?: ISystemTranslation;
21
+ label?: string;
22
+ description?: string;
20
23
  active?: boolean;
24
+ trigger?: Partial<AutomationRuleTrigger>;
25
+ };
26
+ export declare enum SyncAutomationRuleEventAction {
27
+ RECORD_INIT = "RECORD_INIT"
28
+ }
29
+ export type AutomationRuleEventAction = EventAction | SyncAutomationRuleEventAction;
30
+ export type AutomationRulesEventTopic = IDbPayload['topic'];
31
+ export type AutomationRuleTrigger = {
32
+ synchronous: boolean;
33
+ eventAction: AutomationRuleEventAction;
34
+ eventTopic?: AutomationRulesEventTopic;
35
+ };
36
+ export type AutomationRulePipeline = {
37
+ steps: AutomationRulePipelineStep[];
38
+ };
39
+ export declare enum AutomationRuleActions {
40
+ LOG = "log",
41
+ CONDITION = "condition",
42
+ ERROR = "error"
43
+ }
44
+ export type AutomationRulePipelineStep = {
45
+ type: AutomationRuleActions | string;
46
+ name?: string;
47
+ params: Record<string, unknown>;
21
48
  };
@@ -35,6 +35,10 @@ export interface IConfig {
35
35
  pluginsPath: string[];
36
36
  bugsnag: IBugsnag;
37
37
  matomo: IMatomo;
38
+ automation: IAutomation;
39
+ }
40
+ export interface IAutomation {
41
+ enable: boolean;
38
42
  }
39
43
  export declare enum CoreMode {
40
44
  SERVER = "server",
@@ -1,17 +1,22 @@
1
1
  import { type IGraphqlAppModule } from '../graphql/graphqlApp';
2
2
  import { type IAutomationDomain } from '../../domain/automation/automationDomain';
3
+ import { type IAutomationRule } from '../../_types/automation';
3
4
  import { type IPaginationParams, type ISortParams } from '../../_types/list';
5
+ import { type IEventsManagerDomain } from '../../domain/eventsManager/eventsManagerDomain';
4
6
  export type ICoreImportApp = IGraphqlAppModule;
5
- interface IDeps {
7
+ interface IAutomationAppDeps {
6
8
  'core.domain.automation': IAutomationDomain;
9
+ 'core.domain.eventsManager': IEventsManagerDomain;
7
10
  }
8
11
  export interface IGetAutomationRulesArgs {
9
12
  filters?: ICoreEntityFilterOptions & {
10
- id: string;
11
- active: boolean;
13
+ active?: boolean;
14
+ synchronous?: boolean;
15
+ eventAction?: IAutomationRule['trigger']['eventAction'];
16
+ eventTopic?: IAutomationRule['trigger']['eventTopic'];
12
17
  };
13
18
  pagination?: IPaginationParams;
14
19
  sort?: ISortParams;
15
20
  }
16
- export default function ({ 'core.domain.automation': automationDomain }: IDeps): ICoreImportApp;
21
+ export default function ({ 'core.domain.automation': automationDomain, 'core.domain.eventsManager': eventsManagerDomain, }: IAutomationAppDeps): ICoreImportApp;
17
22
  export {};
@@ -2,7 +2,8 @@ import { type InitQueryContextFunc } from '../helpers/initQueryContext';
2
2
  import { type IEventsManagerDomain } from '../../domain/eventsManager/eventsManagerDomain';
3
3
  import { type IConfig } from '../../_types/config';
4
4
  import { type IAppModule } from '../../_types/shared';
5
- export type IEventsManagerApp = IAppModule;
5
+ import { type IGraphqlAppModule } from '../graphql/graphqlApp';
6
+ export type IEventsManagerApp = IAppModule & IGraphqlAppModule;
6
7
  interface IDeps {
7
8
  'core.domain.eventsManager': IEventsManagerDomain;
8
9
  'core.app.helpers.initQueryContext': InitQueryContextFunc;
@@ -0,0 +1,8 @@
1
+ import { z } from 'zod';
2
+ import { type IAutomationAction } from '../types';
3
+ declare const conditionActionParamsSchema: z.ZodObject<{
4
+ result: z.ZodBoolean;
5
+ }, z.core.$strip>;
6
+ export type ConditionActionParams = z.infer<typeof conditionActionParamsSchema>;
7
+ export default function (): IAutomationAction<ConditionActionParams>;
8
+ export {};
@@ -0,0 +1,8 @@
1
+ import { z } from 'zod';
2
+ import { type IAutomationAction } from '../types';
3
+ declare const errorActionParamsSchema: z.ZodObject<{
4
+ message: z.ZodString;
5
+ }, z.core.$strip>;
6
+ export type ErrorActionParams = z.infer<typeof errorActionParamsSchema>;
7
+ export default function (): IAutomationAction<ErrorActionParams>;
8
+ export {};
@@ -0,0 +1,3 @@
1
+ export { default as condition } from './conditionAction';
2
+ export { default as error } from './errorAction';
3
+ export { default as log } from './logAction';
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ import { type IAutomationAction } from '../types';
3
+ declare const logActionParamsSchema: z.ZodObject<{
4
+ message: z.ZodString;
5
+ level: z.ZodOptional<z.ZodEnum<{
6
+ error: "error";
7
+ info: "info";
8
+ debug: "debug";
9
+ silly: "silly";
10
+ verbose: "verbose";
11
+ warn: "warn";
12
+ }>>;
13
+ }, z.core.$strip>;
14
+ export type LogActionParams = z.infer<typeof logActionParamsSchema>;
15
+ export default function (): IAutomationAction<LogActionParams>;
16
+ export {};
@@ -1,13 +1,18 @@
1
- import { type ICreateAutomationRule, type IAutomationRule, type IUpdateAutomationRule } from '../../_types/automation';
1
+ import { type ICreateAutomationRule, type IAutomationRule, type IUpdateAutomationRule, type AutomationRulesEventTopic, type AutomationRuleEventAction } 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';
5
5
  import { type IAutomationRuleRepo } from '../../infra/automation/automationRuleRepo';
6
6
  import { type IAdminPermissionDomain } from '../permission/adminPermissionDomain';
7
7
  import { type IEventsManagerDomain } from '../eventsManager/eventsManagerDomain';
8
+ import { type IConfig } from '../../_types/config';
9
+ import { type IPipelineExecutor } from './pipelineExecutor';
8
10
  export interface IGetAutomationRulesParams extends IGetCoreEntitiesParams {
9
11
  filters?: ICoreEntityFilterOptions & {
10
12
  active?: boolean;
13
+ synchronous?: boolean;
14
+ eventAction?: AutomationRuleEventAction;
15
+ eventTopic?: AutomationRulesEventTopic;
11
16
  };
12
17
  }
13
18
  export interface IAutomationDomain {
@@ -23,10 +28,16 @@ export interface IAutomationDomain {
23
28
  rule: IUpdateAutomationRule;
24
29
  ctx: IQueryInfos;
25
30
  }): Promise<IAutomationRule>;
31
+ triggerRules(event: {
32
+ action: AutomationRuleEventAction;
33
+ topic?: AutomationRulesEventTopic;
34
+ }, synchronous: boolean, ctx: IQueryInfos): Promise<void>;
26
35
  }
27
36
  export interface IAutomationDomainDeps {
28
37
  'core.domain.permission.admin': IAdminPermissionDomain;
29
38
  'core.domain.eventsManager': IEventsManagerDomain;
39
+ 'core.domain.automation.pipelineExecutor': IPipelineExecutor;
30
40
  'core.infra.automation.rule': IAutomationRuleRepo;
41
+ config: IConfig;
31
42
  }
32
- export default function ({ 'core.domain.permission.admin': adminPermissionDomain, 'core.domain.eventsManager': eventsManagerDomain, 'core.infra.automation.rule': automationRuleRepo, }: IAutomationDomainDeps): IAutomationDomain;
43
+ export default function ({ 'core.domain.permission.admin': adminPermissionDomain, 'core.domain.eventsManager': eventsManagerDomain, 'core.domain.automation.pipelineExecutor': pipelineExecutor, 'core.infra.automation.rule': automationRuleRepo, config, }: IAutomationDomainDeps): IAutomationDomain;
@@ -0,0 +1,7 @@
1
+ import { type AutomationRuleEventAction, type AutomationRulesEventTopic, type IAutomationRule } from '../../_types/automation';
2
+ import { type IQueryInfos } from '../../_types/queryInfos';
3
+ export declare const TRIGGER_FAKER_RULES_FOR_DEV = false;
4
+ export declare const buildFakeRulesToTrigger: (event: {
5
+ action: AutomationRuleEventAction;
6
+ topic?: AutomationRulesEventTopic;
7
+ }, synchronous: boolean, ctx: IQueryInfos) => Promise<IAutomationRule[]>;
@@ -1 +1,2 @@
1
1
  export { default } from './automationDomain';
2
+ export { default as pipelineExecutor } from './pipelineExecutor';
@@ -0,0 +1,16 @@
1
+ import { type AwilixContainer } from 'awilix';
2
+ import { type AutomationRuleTrigger, type AutomationRulePipeline } from '../../_types/automation';
3
+ import { type IAutomationAction } from './types';
4
+ import { type IQueryInfos } from '../../_types/queryInfos';
5
+ export type AutomationPipelineToExecute = AutomationRulePipeline & {
6
+ ruleId: string;
7
+ trigger: AutomationRuleTrigger;
8
+ };
9
+ export interface IPipelineExecutor {
10
+ getAvailableActions(): IAutomationAction[];
11
+ executePipeline(pipelineExec: AutomationPipelineToExecute, ctx: IQueryInfos): Promise<boolean>;
12
+ }
13
+ export interface IPipelineExecutorDeps {
14
+ 'core.depsManager': AwilixContainer;
15
+ }
16
+ export default function ({ 'core.depsManager': depsManager }: IPipelineExecutorDeps): IPipelineExecutor;
@@ -0,0 +1,22 @@
1
+ import { type ZodObject } from 'zod';
2
+ import { type AutomationRuleActions, type AutomationRuleTrigger } from '../../_types/automation';
3
+ import { type IQueryInfos } from '../../_types/queryInfos';
4
+ export declare enum ActionExecutionResultStatus {
5
+ CONTINUE = "continue",
6
+ STOP = "stop"
7
+ }
8
+ export type IActionExecutionResult = {
9
+ status: ActionExecutionResultStatus.CONTINUE;
10
+ } | {
11
+ status: ActionExecutionResultStatus.STOP;
12
+ reason?: string;
13
+ };
14
+ export type IAutomationPipelineExecutionState = {
15
+ readonly trigger: AutomationRuleTrigger;
16
+ };
17
+ export interface IAutomationAction<Params = unknown> {
18
+ readonly type: AutomationRuleActions | string;
19
+ readonly paramsSchema: ZodObject<any>;
20
+ validateParams?: (params: Params) => Promise<void>;
21
+ execute(params: Params, state: IAutomationPipelineExecutionState, ctx: IQueryInfos): Promise<IActionExecutionResult | void>;
22
+ }
@@ -4,6 +4,7 @@ import { type IRecordRepo } from '../../../infra/record/recordRepo';
4
4
  import { type IQueryInfos } from '../../../_types/queryInfos';
5
5
  import { type IRecord } from '../../../_types/record';
6
6
  import { type ICreateRecordValueError } from '../_types';
7
+ import { type IAutomationDomain } from '../../automation/automationDomain';
7
8
  export type IPreCreateRecordCallback = () => Promise<ICreateRecordValueError[]>;
8
9
  export type CreateRecordHelper = (params: {
9
10
  library: string;
@@ -14,6 +15,7 @@ interface IDeps {
14
15
  'core.domain.eventsManager': IEventsManagerDomain;
15
16
  'core.domain.permission.library': ILibraryPermissionDomain;
16
17
  'core.infra.record': IRecordRepo;
18
+ 'core.domain.automation': IAutomationDomain;
17
19
  }
18
- export default function ({ 'core.domain.eventsManager': eventsManager, 'core.domain.permission.library': libraryPermissionDomain, 'core.infra.record': recordRepo, }: IDeps): CreateRecordHelper;
20
+ export default function ({ 'core.domain.eventsManager': eventsManager, 'core.domain.permission.library': libraryPermissionDomain, 'core.infra.record': recordRepo, 'core.domain.automation': automationDomain, }: IDeps): CreateRecordHelper;
19
21
  export {};