@aristid/leav-types 1.0.0-6e54bb6d → 1.0.0-78735ccf

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.
@@ -37,3 +37,7 @@ export interface ILogPagination {
37
37
  offset: number;
38
38
  }
39
39
  export type Log<EA extends EventAction = EventAction> = LogExternal & IDbPayloadInternal<EA>;
40
+ export interface ILogResponse {
41
+ logs: Log[];
42
+ total: number;
43
+ }
@@ -1,5 +1,5 @@
1
1
  import { ILogRepo } from 'infra/log/logRepo';
2
- import { ILogFilters, ILogPagination, ILogSort, Log } from '_types/log';
2
+ import { ILogFilters, ILogPagination, ILogResponse, ILogSort } from '_types/log';
3
3
  import { IQueryInfos } from '_types/queryInfos';
4
4
  import { IPermissionDomain } from 'domain/permission/permissionDomain';
5
5
  import { IRecordPermissionDomain } from 'domain/permission/recordPermissionDomain';
@@ -8,7 +8,7 @@ export interface ILogDomain {
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;
@@ -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,13 +1,13 @@
1
1
  import { IElasticSearchService } from 'infra/elasticSearch/elasticSearchService';
2
2
  import { IConfig } from '_types/config';
3
- import { ILogFilters, ILogPagination, ILogSort, Log } from '_types/log';
3
+ import { ILogFilters, ILogPagination, ILogResponse, ILogSort } from '_types/log';
4
4
  import { IQueryInfos } from '_types/queryInfos';
5
5
  export interface ILogRepo {
6
6
  getLogs(params: {
7
7
  filters?: ILogFilters;
8
8
  sort?: ILogSort;
9
9
  pagination?: ILogPagination;
10
- }, ctx: IQueryInfos): Promise<Log[]>;
10
+ }, ctx: IQueryInfos): Promise<ILogResponse>;
11
11
  }
12
12
  interface IDeps {
13
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-6e54bb6d",
3
+ "version": "1.0.0-78735ccf",
4
4
  "description": "Shared Leav types",
5
5
  "scripts": {
6
6
  "tscheck": "",