@aristid/leav-types 1.7.0-bba65313 → 1.7.0-c6b5a95c

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 (29) hide show
  1. package/apps/core/src/__tests__/e2e/api/_fixtures/fakeplugin/index.d.ts +3 -1
  2. package/apps/core/src/__tests__/e2e/api/actionLists/actions/replaceAnotherAttributeAction.test.d.ts +1 -0
  3. package/apps/core/src/__tests__/e2e/api/e2eUtils.d.ts +3 -0
  4. package/apps/core/src/__tests__/e2e/api/notificationUtils.d.ts +4 -2
  5. package/apps/core/src/__tests__/e2e/api/notifications/notifications.test.d.ts +1 -0
  6. package/apps/core/src/__tests__/e2e/api/values/listDistinctValues.test.d.ts +1 -0
  7. package/apps/core/src/__tests__/mocks/attribute.d.ts +3 -0
  8. package/apps/core/src/__tests__/mocks/notification.d.ts +2 -0
  9. package/apps/core/src/_types/actionsList.d.ts +1 -1
  10. package/apps/core/src/_types/attribute.d.ts +6 -0
  11. package/apps/core/src/_types/eventsManager.d.ts +2 -4
  12. package/apps/core/src/_types/notification.d.ts +9 -1
  13. package/apps/core/src/_types/record.d.ts +1 -0
  14. package/apps/core/src/_types/value.d.ts +1 -5
  15. package/apps/core/src/app/core/notificationApp.d.ts +3 -1
  16. package/apps/core/src/domain/actions/excelCalculationAction.d.ts +4 -2
  17. package/apps/core/src/domain/actions/index.d.ts +1 -0
  18. package/apps/core/src/domain/actions/inheritanceCalculationAction.d.ts +4 -2
  19. package/apps/core/src/domain/actions/replaceAnotherAttributeAction.d.ts +13 -0
  20. package/apps/core/src/domain/notification/notificationDomain.d.ts +9 -3
  21. package/apps/core/src/domain/value/_types.d.ts +1 -0
  22. package/apps/core/src/domain/value/valueDomain.d.ts +2 -2
  23. package/apps/core/src/infra/attributeTypes/attributeTypesRepo.d.ts +10 -1
  24. package/apps/core/src/infra/db/helpers/runMigrationFiles.d.ts +2 -0
  25. package/apps/core/src/infra/db/migrations/014-notificationsCollection.d.ts +7 -0
  26. package/apps/core/src/infra/notification/index.d.ts +1 -0
  27. package/apps/core/src/infra/notification/notificationRepo.d.ts +18 -0
  28. package/apps/core/src/infra/value/valueRepo.d.ts +1 -1
  29. package/package.json +1 -1
@@ -4,12 +4,14 @@ import { type IValueRepo } from '../../../../../infra/value/valueRepo';
4
4
  import { type IAttributeDomain } from '../../../../../domain/attribute/attributeDomain';
5
5
  import { type ITasksManagerDomain } from 'domain/tasksManager/tasksManagerDomain';
6
6
  import { type IFakeDomain } from './domain/fakeDomain';
7
+ import { type INotificationDomain } from '../../../../../domain/notification/notificationDomain';
7
8
  interface IDeps {
8
9
  translator: i18n;
9
10
  'core.infra.value': IValueRepo;
10
11
  'core.domain.attribute': IAttributeDomain;
11
12
  'core.domain.tasksManager': ITasksManagerDomain;
13
+ 'core.domain.notification': INotificationDomain;
12
14
  'fakeplugin.domain': IFakeDomain;
13
15
  }
14
- export default function ({ translator, 'core.infra.value': valueRepo, 'core.domain.attribute': attributeDomain, 'core.domain.tasksManager': tasksManagerDomain, 'fakeplugin.domain': fakeDomain, }: IDeps): IPluginInitModule;
16
+ export default function ({ translator, 'core.infra.value': valueRepo, 'core.domain.attribute': attributeDomain, 'core.domain.tasksManager': tasksManagerDomain, 'core.domain.notification': notificationDomain, 'fakeplugin.domain': fakeDomain, }: IDeps): IPluginInitModule;
15
17
  export {};
@@ -6,6 +6,7 @@ import { type ActionsListConfig } from '_types/actionsList';
6
6
  import { type ITreeElement } from '_types/tree';
7
7
  import { AttributeFormats, type AttributeTypes, type IAttributeVersionsConf, type IEmbeddedAttribute } from '../../../_types/attribute';
8
8
  import { type ITreePermissionsDependentValuesConf } from '_types/permissions';
9
+ import { type ISaveValue } from '_types/value';
9
10
  export interface IGlobalThis {
10
11
  guestUser: IE2EUserParams;
11
12
  nonAdminUser: IE2EUserParams;
@@ -67,6 +68,8 @@ export declare function gqlCreateRecord(library: string): Promise<string>;
67
68
  export declare function gqlAddElemToTree(treeId: string, element: ITreeElement, parent?: string | null, order?: number): Promise<string>;
68
69
  export declare function gqlGetValue(libraryId: string, recordId: string, attributeId: string): Promise<any>;
69
70
  export declare function gqlSaveValue(attributeId: string, libraryId: string, recordId: string, value: string | number): Promise<void>;
71
+ export declare function gqlSaveValueBis(attributeId: string, libraryId: string, recordId: string, value: ISaveValue): Promise<string | null>;
72
+ export declare function gqlDeleteValue(attributeId: string, libraryId: string, recordId: string, idValue: string | null): Promise<void>;
70
73
  export declare function gqlSaveVersionProfile(profileId: string, label: string, trees: string[]): Promise<void>;
71
74
  /**
72
75
  * Convert object to JSON, escaping quotes to be able to use it in a graphql query
@@ -1,5 +1,7 @@
1
- import { type IPubSubNotificationData } from '_types/eventsManager';
2
1
  import { type Client as GraphqlWsClient } from 'graphql-ws';
3
2
  import { type IMailpitMsgFull } from './mailpitUtils';
4
- export declare const waitWebSocketNotification: (graphqlClient: GraphqlWsClient, taskId: string) => Promise<Pick<IPubSubNotificationData, "notification">>;
3
+ import { type INotification } from '../../../_types/notification';
4
+ export declare const waitWebSocketNotification: (graphqlClient: GraphqlWsClient, taskId: string) => Promise<{
5
+ notification: Omit<INotification, "content"> & INotification["content"];
6
+ }>;
5
7
  export declare const waitEmailNotification: (taskId: string) => Promise<IMailpitMsgFull>;
@@ -34,6 +34,9 @@ export declare const mockAttrTree: {
34
34
  multi_link_display_option?: MultiDisplayOption;
35
35
  multi_tree_display_option?: MultiDisplayOption;
36
36
  permissions_conf_dependent_values?: import("../../_types/permissions").ITreePermissionsDependentValuesConf;
37
+ smart_filter?: {
38
+ enable: boolean;
39
+ };
37
40
  label?: import("../../_types/systemTranslation").ISystemTranslation | string;
38
41
  };
39
42
  export declare const mockAttrTreeVersionable: IAttribute;
@@ -0,0 +1,2 @@
1
+ import { type INotification } from '../../_types/notification';
2
+ export declare const mockNotification: MandatoryId<INotification>;
@@ -26,7 +26,7 @@ export interface IActionsListContext extends IQueryInfos {
26
26
  library?: string;
27
27
  recordId?: string;
28
28
  }
29
- export type ActionsListParams<T extends string | number | symbol> = Record<T, any>;
29
+ export type ActionsListParams<T extends string | number | symbol> = Record<T, string>;
30
30
  export type ActionsListParamsConfig<ParamsRequired extends Record<string, boolean>> = {
31
31
  [Name in keyof ParamsRequired]: {
32
32
  name: Name;
@@ -32,6 +32,12 @@ export interface IAttribute extends ICoreEntity {
32
32
  * only for tree attribute
33
33
  */
34
34
  permissions_conf_dependent_values?: ITreePermissionsDependentValuesConf;
35
+ /**
36
+ * only for link attribute
37
+ */
38
+ smart_filter?: {
39
+ enable: boolean;
40
+ };
35
41
  }
36
42
  export declare enum ValueVersionMode {
37
43
  SIMPLE = "simple",
@@ -1,4 +1,4 @@
1
- import { type INotificationContent } from './notification';
1
+ import { type INotification } from './notification';
2
2
  import { type ITask } from './tasksManager';
3
3
  export declare enum TriggerNames {
4
4
  APPLICATION_EVENT = "APPLICATION_EVENT",
@@ -10,9 +10,7 @@ export declare enum TriggerNames {
10
10
  NOTIFICATION = "NOTIFICATION"
11
11
  }
12
12
  export interface IPubSubNotificationData {
13
- notification: INotificationContent & {
14
- date: number;
15
- };
13
+ notification: INotification;
16
14
  recipientUserIds: string[];
17
15
  }
18
16
  export interface IPubSubTaskData {
@@ -1,5 +1,5 @@
1
1
  import { type IQueryInfos } from './queryInfos';
2
- export interface INotification {
2
+ export interface INotification extends ICoreEntity {
3
3
  /**
4
4
  * Timestamp of the notification creation in milliseconds since epoch
5
5
  */
@@ -9,6 +9,7 @@ export interface INotification {
9
9
  */
10
10
  recipientUserId: string;
11
11
  content: INotificationContent;
12
+ displayDuration?: number;
12
13
  }
13
14
  export interface INotificationContent {
14
15
  level: 'success' | 'info' | 'warning' | 'error';
@@ -45,6 +46,10 @@ export interface ICreateNotification {
45
46
  */
46
47
  priority: 'urgent' | 'normal';
47
48
  content: INotificationContent;
49
+ /**
50
+ * Duration of the notification in ms, 0 for persistent
51
+ */
52
+ displayDuration?: number;
48
53
  /**
49
54
  * Channels to send the notification to (if not set, all channels will be used)
50
55
  */
@@ -58,3 +63,6 @@ export interface INotificationChannel {
58
63
  type: NotificationChannels;
59
64
  sendNotifications(notifications: INotification[], ctx: IQueryInfos): Promise<void>;
60
65
  }
66
+ export interface INotificationFilterOptions extends ICoreEntityFilterOptions {
67
+ recipientUserId?: string;
68
+ }
@@ -81,6 +81,7 @@ export interface IRecordIdentity {
81
81
  getSubLabel?: () => Promise<string | null>;
82
82
  getColor?: () => Promise<string | null>;
83
83
  getPreview?: () => Promise<IPreview | null>;
84
+ getParentContext?: () => Promise<IRecordIdentity[] | null>;
84
85
  }
85
86
  export interface IRecordIdentityConf {
86
87
  label?: string;
@@ -152,11 +152,7 @@ export interface IBaseValueByAttributeType {
152
152
  [AttributeTypes.TREE]: ITreeBaseValue;
153
153
  }
154
154
  export type IValuesOccurrences<SimpleValueType extends IBaseValue = IBaseValue> = Array<{
155
- value: SimpleValueType;
155
+ value: SimpleValueType['payload'] | null;
156
156
  count: number;
157
157
  }>;
158
- export interface IValuesOccurrencesResult<BaseValueType extends IBaseValue = IBaseValue> {
159
- occurrences: IValuesOccurrences<BaseValueType>;
160
- noValueCount: number;
161
- }
162
158
  export {};
@@ -1,10 +1,12 @@
1
1
  import { type IGraphqlAppModule } from 'app/graphql/graphqlApp';
2
2
  import { type IEventsManagerDomain } from 'domain/eventsManager/eventsManagerDomain';
3
3
  import { type IUtils } from 'utils/utils';
4
+ import { type INotificationDomain } from '../../domain/notification/notificationDomain';
4
5
  export type INotificationApp = IGraphqlAppModule;
5
6
  interface IDeps {
6
7
  'core.utils'?: IUtils;
7
8
  'core.domain.eventsManager'?: IEventsManagerDomain;
9
+ 'core.domain.notification'?: INotificationDomain;
8
10
  }
9
- export default function ({ 'core.domain.eventsManager': eventsManager }: IDeps): INotificationApp;
11
+ export default function ({ 'core.domain.eventsManager': eventsManager, 'core.domain.notification': notificationDomain, }: IDeps): INotificationApp;
10
12
  export {};
@@ -7,8 +7,10 @@ interface IDeps {
7
7
  config: IConfig;
8
8
  'core.utils.logger': ILogger;
9
9
  }
10
- export default function ({ 'core.domain.helpers.calculationVariable': calculationVariable, 'core.utils.logger': logger, config, }: IDeps): IActionsListFunction<{
10
+ type ActionParams = {
11
11
  Formula: true;
12
12
  Description: true;
13
- }>;
13
+ ['Return only calculated value']: false;
14
+ };
15
+ export default function ({ 'core.domain.helpers.calculationVariable': calculationVariable, 'core.utils.logger': logger, config, }: IDeps): IActionsListFunction<ActionParams>;
14
16
  export {};
@@ -17,3 +17,4 @@ export { default as validateRegexAction } from './validateRegexAction';
17
17
  export { default as validateURLAction } from './validateURLAction';
18
18
  export { default as toUppercaseAction } from './toUppercaseAction';
19
19
  export { default as toLowercaseAction } from './toLowercaseAction';
20
+ export { default as replaceAnotherAttribute } from './replaceAnotherAttributeAction';
@@ -5,8 +5,10 @@ interface IDeps {
5
5
  'core.domain.helpers.calculationVariable'?: ICalculationVariable;
6
6
  'core.domain.attribute'?: IAttributeDomain;
7
7
  }
8
- export default function ({ 'core.domain.helpers.calculationVariable': calculationVariable, 'core.domain.attribute': attributeDomain, }?: IDeps): IActionsListFunction<{
8
+ type ActionParams = {
9
9
  Formula: true;
10
10
  Description: true;
11
- }>;
11
+ ['Return only calculated value']: false;
12
+ };
13
+ export default function ({ 'core.domain.helpers.calculationVariable': calculationVariable, 'core.domain.attribute': attributeDomain, }?: IDeps): IActionsListFunction<ActionParams>;
12
14
  export {};
@@ -0,0 +1,13 @@
1
+ import { type IAttributeDomain } from 'domain/attribute/attributeDomain';
2
+ import { type IValueDomain } from 'domain/value/valueDomain';
3
+ import { type IActionsListFunction } from '../../_types/actionsList';
4
+ import { type IUtils } from 'utils/utils';
5
+ interface IDeps {
6
+ 'core.domain.value'?: IValueDomain;
7
+ 'core.domain.attribute'?: IAttributeDomain;
8
+ 'core.utils': IUtils;
9
+ }
10
+ export default function ({ 'core.domain.value': valueDomain, 'core.domain.attribute': attributeDomain, 'core.utils': utils, }: IDeps): IActionsListFunction<{
11
+ attributePath: true;
12
+ }>;
13
+ export {};
@@ -1,12 +1,18 @@
1
1
  import { type IConfig } from '_types/config';
2
- import { type INotificationChannel, type ICreateNotification } from '_types/notification';
2
+ import { type INotificationChannel, type ICreateNotification, type INotification } from '_types/notification';
3
3
  import { type IQueryInfos } from '_types/queryInfos';
4
+ import { type INotificationRepo } from '../../infra/notification/notificationRepo';
5
+ import { type IList } from '../../_types/list';
4
6
  export interface INotificationDomain {
5
- createNotification(notification: ICreateNotification, ctx: IQueryInfos): Promise<void>;
7
+ createNotification(notification: ICreateNotification, ctx: IQueryInfos): Promise<INotification[]>;
8
+ getNotifications(ctx: IQueryInfos): Promise<IList<INotification>>;
9
+ deleteAllNotifications(ctx: IQueryInfos): Promise<INotification[]>;
10
+ deleteNotification(notificationId: string, ctx: IQueryInfos): Promise<INotification>;
6
11
  }
7
12
  export interface INotificationDomainDeps {
8
13
  'core.domain.notification.emailChannel': INotificationChannel;
9
14
  'core.domain.notification.webSocketChannel': INotificationChannel;
15
+ 'core.infra.notification': INotificationRepo;
10
16
  config: IConfig;
11
17
  }
12
- export default function ({ 'core.domain.notification.emailChannel': emailChannel, 'core.domain.notification.webSocketChannel': webSocketChannel, config, }: INotificationDomainDeps): INotificationDomain;
18
+ export default function ({ 'core.domain.notification.emailChannel': emailChannel, 'core.domain.notification.webSocketChannel': webSocketChannel, 'core.infra.notification': notificationRepo, config, }: INotificationDomainDeps): INotificationDomain;
@@ -9,6 +9,7 @@ export interface IDeleteValueParams {
9
9
  attribute: string;
10
10
  value?: IValue;
11
11
  skipReadonly?: boolean;
12
+ skipActions?: boolean;
12
13
  ctx: IQueryInfos;
13
14
  }
14
15
  export interface IRunActionListParams {
@@ -14,7 +14,7 @@ import type * as Config from '_types/config';
14
14
  import { type IRecordFilterLight, type IRecord } from '_types/record';
15
15
  import { type IAttribute } from '../../_types/attribute';
16
16
  import { type IQueryInfos } from '../../_types/queryInfos';
17
- import { type IValueVersion, type ISaveValue, type IValue, type IValuesOptions, type IValuesOccurrencesResult } from '../../_types/value';
17
+ import { type IValueVersion, type ISaveValue, type IValue, type IValuesOptions, type IValuesOccurrences } from '../../_types/value';
18
18
  import { type IActionsListDomain } from '../actionsList/actionsListDomain';
19
19
  import { type IAttributeDomain } from '../attribute/attributeDomain';
20
20
  import { type IValidateHelper } from '../helpers/validate';
@@ -118,7 +118,7 @@ export interface IValueDomain {
118
118
  version?: IValueVersion;
119
119
  };
120
120
  ctx: IQueryInfos;
121
- }): Promise<IValuesOccurrencesResult>;
121
+ }): Promise<IValuesOccurrences>;
122
122
  }
123
123
  export interface IValueDomainDeps {
124
124
  config: Config.IConfig;
@@ -111,13 +111,22 @@ export interface IAttributeTypeRepo<AttributeType extends AttributeTypes = Attri
111
111
  }): Promise<Value[][]>;
112
112
  countValuesOccurrences?({ library, attribute, recordIds, options, ctx, }: {
113
113
  library: string;
114
- attribute: IAttribute;
114
+ attribute: IAttributeWithRevLink;
115
115
  recordIds: string[];
116
116
  options?: {
117
117
  version?: IValueVersion;
118
118
  };
119
119
  ctx: IQueryInfos;
120
120
  }): Promise<IValuesOccurrences<IBaseValueByAttributeType[AttributeType]>>;
121
+ /**
122
+ * Count occurrences of reverse link values for given records
123
+ * Only for simple link reverse attributes
124
+ */
125
+ countReverseValuesOccurrences?({ advancedLinkAttr, recordIds, ctx, }: {
126
+ advancedLinkAttr: IAttributeWithRevLink;
127
+ recordIds: string[];
128
+ ctx: IQueryInfos;
129
+ }): Promise<IValuesOccurrences<IBaseValueByAttributeType[AttributeType]>>;
121
130
  /**
122
131
  * Return a specific value based on its ID. Field "id" is expect on the value
123
132
  *
@@ -2,6 +2,7 @@ import { type AwilixContainer } from 'awilix';
2
2
  import { type ILogger } from '@leav/logger';
3
3
  import { type IQueryInfos } from '_types/queryInfos';
4
4
  import { type IDbService } from '../dbService';
5
+ import { type ICachesService } from '../../../infra/cache/cacheService';
5
6
  interface IExecuteMigrationParams {
6
7
  files: string[];
7
8
  executedMigrations: string[];
@@ -11,6 +12,7 @@ interface IExecuteMigrationParams {
11
12
  depsManager: AwilixContainer;
12
13
  dbService: IDbService;
13
14
  logger: ILogger;
15
+ cacheService: ICachesService;
14
16
  };
15
17
  ctx: IQueryInfos;
16
18
  }
@@ -0,0 +1,7 @@
1
+ import { type IMigration } from '_types/migration';
2
+ import { type IDbService } from '../dbService';
3
+ interface IDeps {
4
+ 'core.infra.db.dbService'?: IDbService;
5
+ }
6
+ export default function ({ 'core.infra.db.dbService': dbService }?: IDeps): IMigration;
7
+ export {};
@@ -0,0 +1 @@
1
+ export { default } from './notificationRepo';
@@ -0,0 +1,18 @@
1
+ import { type IList } from '_types/list';
2
+ import { type IQueryInfos } from '_types/queryInfos';
3
+ import { type IGetCoreEntitiesParams } from '_types/shared';
4
+ import { type IDbService } from '../db/dbService';
5
+ import { type IDbUtils } from '../db/dbUtils';
6
+ import { type INotification } from '../../_types/notification';
7
+ export declare const NOTIFICATIONS_COLLECTION_NAME = "core_notifications";
8
+ export interface INotificationRepo {
9
+ createNotification(notification: INotification, ctx: IQueryInfos): Promise<INotification>;
10
+ getNotifications(params: IGetCoreEntitiesParams, ctx: IQueryInfos): Promise<IList<INotification>>;
11
+ deleteNotificationById(notificationId: string, ctx: IQueryInfos): Promise<INotification>;
12
+ deleteNotificationsByRecipientUserId(recipientUserId: string, ctx: IQueryInfos): Promise<INotification[]>;
13
+ }
14
+ export interface INotificationRepoDeps {
15
+ 'core.infra.db.dbService': IDbService;
16
+ 'core.infra.db.dbUtils': IDbUtils;
17
+ }
18
+ export default function ({ 'core.infra.db.dbService': dbService, 'core.infra.db.dbUtils': dbUtils, }: INotificationRepoDeps): INotificationRepo;
@@ -73,7 +73,7 @@ export interface IValueRepo {
73
73
  }): Promise<IValue>;
74
74
  countValuesOccurrences?({ library, attribute, recordIds, options, ctx, }: {
75
75
  library: string;
76
- attribute: IAttribute;
76
+ attribute: IAttributeWithRevLink;
77
77
  recordIds: string[];
78
78
  options?: {
79
79
  version?: IValueVersion;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aristid/leav-types",
3
- "version": "1.7.0-bba65313",
3
+ "version": "1.7.0-c6b5a95c",
4
4
  "description": "Shared Leav types",
5
5
  "scripts": {
6
6
  "tscheck": "",