@aristid/leav-types 1.0.0-7bbc7ed2 → 1.0.0-e9dbc3eb

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.
@@ -41,5 +41,5 @@ interface IDBPayloadDataMap {
41
41
  [EventAction.TREE_DELETE]: ITree;
42
42
  [EventAction.PERMISSION_SAVE]: IPermission;
43
43
  }
44
- type IDBPayloadData<DBPayloadAction extends EventAction> = DBPayloadAction extends keyof IDBPayloadDataMap ? IDBPayloadDataMap[DBPayloadAction] : never;
44
+ export type IDBPayloadData<DBPayloadAction extends EventAction> = DBPayloadAction extends keyof IDBPayloadDataMap ? IDBPayloadDataMap[DBPayloadAction] : never;
45
45
  export {};
@@ -1,4 +1,5 @@
1
- import { EventAction } from '@leav/utils';
1
+ import { EventAction, Log as LogExternal } from '@leav/utils';
2
+ import { IDbPayloadInternal } from './events';
2
3
  export interface ILogTopicFilter {
3
4
  record?: {
4
5
  id: string;
@@ -35,3 +36,8 @@ export interface ILogPagination {
35
36
  limit: number;
36
37
  offset: number;
37
38
  }
39
+ export type Log<EA extends EventAction = EventAction> = LogExternal & IDbPayloadInternal<EA>;
40
+ export interface ILogResponse {
41
+ logs: Log[];
42
+ total: number;
43
+ }
@@ -7,6 +7,7 @@ import { ITreeDomain } from 'domain/tree/treeDomain';
7
7
  import { IVersionProfileDomain } from 'domain/versionProfile/versionProfileDomain';
8
8
  import { IAppModule } from '_types/shared';
9
9
  import { IGraphqlAppModule } from 'app/graphql/graphqlApp';
10
+ import { IFormatLogValueHelper } from 'domain/value/helpers/formatLogValue';
10
11
  export type ICoreLogApp = IAppModule & IGraphqlAppModule;
11
12
  interface IDeps {
12
13
  'core.domain.log': ILogDomain;
@@ -14,8 +15,9 @@ interface IDeps {
14
15
  'core.domain.library': ILibraryDomain;
15
16
  'core.domain.attribute': IAttributeDomain;
16
17
  'core.domain.tree': ITreeDomain;
18
+ 'core.domain.value.helpers.formatLogValue': IFormatLogValueHelper;
17
19
  'core.domain.versionProfile': IVersionProfileDomain;
18
20
  'core.domain.application': IApplicationDomain;
19
21
  }
20
- export default function ({ 'core.domain.log': logDomain, 'core.domain.eventsManager': eventsManagerDomain, 'core.domain.library': libraryDomain, 'core.domain.attribute': attributeDomain, 'core.domain.tree': treeDomain, 'core.domain.versionProfile': versionProfileDomain, 'core.domain.application': applicationDomain }: IDeps): ICoreLogApp;
22
+ export default function ({ 'core.domain.log': logDomain, 'core.domain.eventsManager': eventsManagerDomain, 'core.domain.library': libraryDomain, 'core.domain.attribute': attributeDomain, 'core.domain.tree': treeDomain, 'core.domain.value.helpers.formatLogValue': formatLogValue, 'core.domain.versionProfile': versionProfileDomain, 'core.domain.application': applicationDomain }: IDeps): ICoreLogApp;
21
23
  export {};
@@ -1,18 +1,19 @@
1
- import { Log } from '@leav/utils';
2
1
  import { ILogRepo } from 'infra/log/logRepo';
3
- import { ILogFilters, ILogPagination, ILogSort } from '_types/log';
2
+ import { ILogFilters, ILogPagination, ILogResponse, ILogSort } from '_types/log';
4
3
  import { IQueryInfos } from '_types/queryInfos';
5
4
  import { IPermissionDomain } from 'domain/permission/permissionDomain';
5
+ import { IRecordPermissionDomain } from 'domain/permission/recordPermissionDomain';
6
6
  export interface ILogDomain {
7
7
  getLogs: (params: {
8
8
  filters?: ILogFilters;
9
9
  sort?: ILogSort;
10
10
  pagination?: ILogPagination;
11
- }, ctx: IQueryInfos) => Promise<Log[]>;
11
+ }, ctx: IQueryInfos) => Promise<ILogResponse>;
12
12
  }
13
13
  interface IDeps {
14
14
  'core.infra.log': ILogRepo;
15
15
  'core.domain.permission': IPermissionDomain;
16
+ 'core.domain.permission.record': IRecordPermissionDomain;
16
17
  }
17
- export default function ({ 'core.infra.log': logRepo, 'core.domain.permission': permissionDomain }: IDeps): ILogDomain;
18
+ export default function ({ 'core.infra.log': logRepo, 'core.domain.permission': permissionDomain, 'core.domain.permission.record': recordPermissionDomain }: IDeps): ILogDomain;
18
19
  export {};
@@ -0,0 +1,23 @@
1
+ import { EventAction } from '@leav/utils';
2
+ import { IDBPayloadData } from '_types/events';
3
+ import { Log } from '_types/log';
4
+ import { IActionsListDomain } from 'domain/actionsList/actionsListDomain';
5
+ import { IAttributeDomain } from 'domain/attribute/attributeDomain';
6
+ import { IRecordDomain } from 'domain/record/recordDomain';
7
+ import { ITreeDomain } from 'domain/tree/treeDomain';
8
+ import { i18n } from 'i18next';
9
+ import winston from 'winston';
10
+ import { IQueryInfos } from '../../../_types/queryInfos';
11
+ export interface IFormatLogValueHelper {
12
+ formatAsString(log: Log, rawData: IDBPayloadData<EventAction.VALUE_DELETE | EventAction.VALUE_SAVE>, ctx: IQueryInfos): Promise<string | null>;
13
+ }
14
+ interface IDeps {
15
+ 'core.domain.actionsList': IActionsListDomain;
16
+ 'core.domain.record': IRecordDomain;
17
+ 'core.domain.attribute': IAttributeDomain;
18
+ 'core.domain.tree': ITreeDomain;
19
+ 'core.utils.logger': winston.Winston;
20
+ translator: i18n;
21
+ }
22
+ export default function ({ 'core.domain.actionsList': actionsListDomain, 'core.domain.record': recordDomain, 'core.domain.attribute': attributeDomain, 'core.domain.tree': treeDomain, 'core.utils.logger': logger, translator }: IDeps): IFormatLogValueHelper;
23
+ export {};
@@ -0,0 +1 @@
1
+ export { default as formatLogValue } from './formatLogValue';
@@ -1,18 +1,23 @@
1
1
  import { Client, estypes } from '@elastic/elasticsearch';
2
2
  import { IConfig } from '_types/config';
3
3
  import { IQueryInfos } from '_types/queryInfos';
4
+ export interface IElasticsearchServiceSearchResponse<T> {
5
+ total: number;
6
+ hits: T[];
7
+ }
8
+ interface IElasticsearchServiceSearchParams {
9
+ index: string;
10
+ offset?: number;
11
+ limit?: number;
12
+ sort?: {
13
+ field: string;
14
+ order: 'asc' | 'desc';
15
+ };
16
+ query?: estypes.QueryDslQueryContainer;
17
+ }
4
18
  export interface IElasticSearchService {
5
19
  client: Client;
6
- search: (params: {
7
- index: string;
8
- offset?: number;
9
- limit?: number;
10
- sort?: {
11
- field: string;
12
- order: 'asc' | 'desc';
13
- };
14
- query?: estypes.QueryDslQueryContainer;
15
- }, ctx: IQueryInfos) => Promise<Array<Record<string, any>>>;
20
+ search: <T>(params: IElasticsearchServiceSearchParams, ctx: IQueryInfos) => Promise<IElasticsearchServiceSearchResponse<T>>;
16
21
  }
17
22
  interface IDeps {
18
23
  'core.infra.elasticSearch.client'?: Client;
@@ -1,14 +1,13 @@
1
- import { Log } from '@leav/utils';
2
1
  import { IElasticSearchService } from 'infra/elasticSearch/elasticSearchService';
3
2
  import { IConfig } from '_types/config';
4
- import { ILogFilters, ILogPagination, ILogSort } from '_types/log';
3
+ import { ILogFilters, ILogPagination, ILogResponse, ILogSort } from '_types/log';
5
4
  import { IQueryInfos } from '_types/queryInfos';
6
5
  export interface ILogRepo {
7
6
  getLogs(params: {
8
7
  filters?: ILogFilters;
9
8
  sort?: ILogSort;
10
9
  pagination?: ILogPagination;
11
- }, ctx: IQueryInfos): Promise<Log[]>;
10
+ }, ctx: IQueryInfos): Promise<ILogResponse>;
12
11
  }
13
12
  interface IDeps {
14
13
  'core.infra.elasticSearch.service'?: IElasticSearchService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aristid/leav-types",
3
- "version": "1.0.0-7bbc7ed2",
3
+ "version": "1.0.0-e9dbc3eb",
4
4
  "description": "Shared Leav types",
5
5
  "scripts": {
6
6
  "tscheck": "",