@aristid/leav-types 1.4.0 → 1.4.1-242090ba

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 (36) hide show
  1. package/apps/core/config/default.d.ts +13 -7
  2. package/apps/core/config/development.d.ts +0 -4
  3. package/apps/core/src/__tests__/e2e/api/permissions/extendedLibraryPermissions.test.d.ts +1 -0
  4. package/apps/core/src/__tests__/integration/infra/ramService.test.d.ts +1 -0
  5. package/apps/core/src/_types/config.d.ts +14 -5
  6. package/apps/core/src/_types/elasticSearch.d.ts +2 -0
  7. package/apps/core/src/_types/errors.d.ts +1 -0
  8. package/apps/core/src/_types/forms.d.ts +2 -2
  9. package/apps/core/src/app/auth/authApp.d.ts +3 -1
  10. package/apps/core/src/app/core/index.d.ts +1 -0
  11. package/apps/core/src/app/core/logsCollectorApp.d.ts +9 -0
  12. package/apps/core/src/domain/logsCollector/index.d.ts +1 -0
  13. package/apps/core/src/domain/logsCollector/logsCollectorDomain.d.ts +16 -0
  14. package/apps/core/src/domain/permission/helpers/index.d.ts +1 -1
  15. package/apps/core/src/domain/permission/helpers/recordInCreationBypass.d.ts +8 -3
  16. package/apps/core/src/domain/permission/recordAttributePermissionDomain.d.ts +2 -2
  17. package/apps/core/src/domain/permission/recordPermissionDomain.d.ts +2 -2
  18. package/apps/core/src/domain/record/helpers/getAccessPermissionFilters.d.ts +6 -5
  19. package/apps/core/src/domain/record/recordDomain.d.ts +1 -0
  20. package/apps/core/src/domain/value/valueDomain.d.ts +3 -1
  21. package/apps/core/src/infra/cache/ramService.d.ts +2 -2
  22. package/apps/core/src/infra/{elasticSearch/elasticSearchService.d.ts → elasticsearch/elasticsearchService.d.ts} +7 -6
  23. package/apps/core/src/infra/elasticsearch/index.d.ts +1 -0
  24. package/apps/core/src/infra/log/logRepo.d.ts +3 -3
  25. package/apps/core/src/interface/index.d.ts +1 -0
  26. package/apps/core/src/interface/logsCollector.d.ts +9 -0
  27. package/libs/logger/src/LoggerCallStack.d.ts +14 -0
  28. package/libs/logger/src/catchErrorFormatter.d.ts +2 -0
  29. package/libs/logger/src/config.d.ts +32 -3
  30. package/libs/logger/src/locationInfoFormatter.d.ts +2 -0
  31. package/libs/logger/src/logger.d.ts +1 -1
  32. package/libs/message-broker/src/amqpService.d.ts +2 -2
  33. package/libs/message-broker/src/types/amqp.d.ts +1 -1
  34. package/package.json +2 -2
  35. package/apps/core/src/infra/elasticSearch/index.d.ts +0 -1
  36. /package/apps/core/src/infra/{elasticSearch/elasticSearchClient.d.ts → elasticsearch/elasticsearchClient.d.ts} +0 -0
@@ -3,6 +3,7 @@ export declare let coreMode: string;
3
3
  export declare namespace server {
4
4
  let host: string;
5
5
  let port: number;
6
+ let keepAliveTimeout: number;
6
7
  let publicUrl: string;
7
8
  let basePath: string;
8
9
  let allowIntrospection: boolean;
@@ -62,6 +63,12 @@ export declare namespace mailer {
62
63
  export { port_1 as port };
63
64
  let secure_1: boolean;
64
65
  export { secure_1 as secure };
66
+ export namespace from {
67
+ let name_1: string;
68
+ export { name_1 as name };
69
+ let email_2: string;
70
+ export { email_2 as email };
71
+ }
65
72
  export namespace auth_1 {
66
73
  export let user: string;
67
74
  let password_1: string;
@@ -89,12 +96,6 @@ export declare namespace lang {
89
96
  let _default: string;
90
97
  export { _default as default };
91
98
  }
92
- export declare namespace logs {
93
- let level: string;
94
- let transport: string;
95
- let destinationFile: string;
96
- let useJsonFormat: boolean;
97
- }
98
99
  export declare namespace permissions {
99
100
  let _default_1: boolean;
100
101
  export { _default_1 as default };
@@ -210,10 +211,15 @@ export declare namespace dbProfiler {
210
211
  let enable_3: boolean;
211
212
  export { enable_3 as enable };
212
213
  }
213
- export declare namespace elasticSearch {
214
+ export declare namespace elasticsearch {
214
215
  export let indexPrefix: string;
215
216
  let url_2: string;
216
217
  export { url_2 as url };
218
+ export let ilmPolicyName: string;
219
+ export let templateName: string;
220
+ }
221
+ export declare namespace logsCollector {
222
+ let queue: string;
217
223
  }
218
224
  export declare let pluginsPath: string | any[];
219
225
  export { _export as export, _import as import };
@@ -1,10 +1,6 @@
1
1
  export namespace server {
2
2
  let allowIntrospection: boolean;
3
3
  }
4
- export namespace logs {
5
- let level: string;
6
- let transport: string;
7
- }
8
4
  export namespace auth {
9
5
  let refreshTokenExpiration: string;
10
6
  namespace cookie {
@@ -1,4 +1,3 @@
1
- import { type ILoggerConfig } from '@leav/logger';
2
1
  import { type Options } from 'amqplib';
3
2
  import { type IKeyValue } from './shared';
4
3
  export interface IConfig {
@@ -10,7 +9,6 @@ export interface IConfig {
10
9
  auth: IAuth;
11
10
  mailer: IMailer;
12
11
  lang: ILang;
13
- logs: ILogs;
14
12
  permissions: IPermissions;
15
13
  amqp: IAmqp;
16
14
  redis: IRedis;
@@ -29,7 +27,8 @@ export interface IConfig {
29
27
  files: IFilesConfig;
30
28
  dbProfiler: IDbProfilerConfig;
31
29
  instanceId: string;
32
- elasticSearch: IElasticSearchConfig;
30
+ elasticsearch: IElasticsearchConfig;
31
+ logsCollector: ILogsCollector;
33
32
  pluginsPath: string[];
34
33
  bugsnag: IBugsnag;
35
34
  matomo: IMatomo;
@@ -41,11 +40,13 @@ export declare enum CoreMode {
41
40
  INDEXATION_MANAGER = "indexationManager",
42
41
  TASKS_MANAGER_MASTER = "tasksManager:master",
43
42
  TASKS_MANAGER_WORKER = "tasksManager:worker",
43
+ LOGS_COLLECTOR = "logsCollector",
44
44
  CLI = "cli"
45
45
  }
46
46
  export interface IServer {
47
47
  host: string;
48
48
  port: number;
49
+ keepAliveTimeout: number;
49
50
  publicUrl: string;
50
51
  basePath: string;
51
52
  allowIntrospection: boolean;
@@ -97,6 +98,10 @@ export interface IMailer {
97
98
  host: string;
98
99
  port: number;
99
100
  secure: boolean;
101
+ from: {
102
+ name: string;
103
+ email: string;
104
+ };
100
105
  auth: {
101
106
  user: string;
102
107
  password: string;
@@ -106,7 +111,6 @@ export interface ILang {
106
111
  available: string[];
107
112
  default: string;
108
113
  }
109
- export type ILogs = ILoggerConfig;
110
114
  export interface IPermissions {
111
115
  default: boolean;
112
116
  enableCache: boolean;
@@ -222,9 +226,11 @@ export interface IFilesConfig {
222
226
  export interface IDbProfilerConfig {
223
227
  enable: boolean;
224
228
  }
225
- export interface IElasticSearchConfig {
229
+ export interface IElasticsearchConfig {
226
230
  indexPrefix: string;
227
231
  url: string;
232
+ ilmPolicyName: string;
233
+ templateName: string;
228
234
  }
229
235
  export interface IBugsnag {
230
236
  enable: boolean;
@@ -238,3 +244,6 @@ export interface IMatomo {
238
244
  url?: string;
239
245
  siteId?: string;
240
246
  }
247
+ export interface ILogsCollector {
248
+ queue: string;
249
+ }
@@ -0,0 +1,2 @@
1
+ import { type IDbEvent, type IDbPayload } from '@leav/utils';
2
+ export type WritableMessage = Omit<IDbEvent, 'payload' | 'emitter'> & IDbPayload;
@@ -4,6 +4,7 @@ export declare enum ErrorTypes {
4
4
  INTERNAL_ERROR = "INTERNAL_ERROR"
5
5
  }
6
6
  export declare enum Errors {
7
+ ATTRIBUTE_USED_BY_LIBRARY = "ATTRIBUTE_USED_BY_LIBRARY",
7
8
  ATTRIBUTE_USED_IN_METADATA = "ATTRIBUTE_USED_IN_METADATA",
8
9
  CANNOT_SAVE_METADATA = "CANNOT_SAVE_METADATA",
9
10
  DUPLICATE_DIRECTORY_NAMES = "DUPLICATE_DIRECTORY_NAMES",
@@ -22,8 +22,8 @@ export interface IRecordForm {
22
22
  sidePanel: IFormSidePanel;
23
23
  }
24
24
  export declare enum FormElementTypes {
25
- field = "field",
26
- layout = "layout"
25
+ FIELD = "field",
26
+ LAYOUT = "layout"
27
27
  }
28
28
  export type IFormStrict = Required<IForm>;
29
29
  export interface IFormElementsDependency {
@@ -15,6 +15,7 @@ import { type IncomingHttpHeaders } from 'http';
15
15
  import { type IRecordRepo } from '../../infra/record/recordRepo';
16
16
  import { type IGraphqlAppModule } from 'app/graphql/graphqlApp';
17
17
  import { type IServerRouteAppModule } from 'interface/server';
18
+ import { type GetSystemQueryContext } from 'utils/helpers/getSystemQueryContext';
18
19
  export interface IAuthApp extends IGraphqlAppModule, IServerRouteAppModule {
19
20
  validateRequestToken(params: {
20
21
  apiKey?: string;
@@ -34,6 +35,7 @@ export interface IAuthAppDeps {
34
35
  'core.infra.oidc.oidcClientService': IOIDCClientService;
35
36
  'core.app.helpers.initQueryContext': InitQueryContextFunc;
36
37
  'core.app.helpers.convertOIDCIdentifier': IConvertOIDCIdentifier;
38
+ 'core.utils.getSystemQueryContext': GetSystemQueryContext;
37
39
  config: IConfig;
38
40
  }
39
- export default function ({ 'core.domain.value': valueDomain, 'core.domain.record': recordDomain, 'core.infra.record': recordRepo, 'core.domain.apiKey': apiKeyDomain, 'core.domain.user': userDomain, 'core.utils.logger': logger, 'core.infra.cache.cacheService': cacheService, 'core.infra.oidc.oidcClientService': oidcClientService, 'core.app.helpers.initQueryContext': initQueryContext, 'core.app.helpers.convertOIDCIdentifier': convertOIDCIdentifier, config }: IAuthAppDeps): IAuthApp;
41
+ export default function ({ 'core.domain.value': valueDomain, 'core.domain.record': recordDomain, 'core.infra.record': recordRepo, 'core.domain.apiKey': apiKeyDomain, 'core.domain.user': userDomain, 'core.utils.logger': logger, 'core.infra.cache.cacheService': cacheService, 'core.infra.oidc.oidcClientService': oidcClientService, 'core.app.helpers.initQueryContext': initQueryContext, 'core.app.helpers.convertOIDCIdentifier': convertOIDCIdentifier, 'core.utils.getSystemQueryContext': getSystemQueryContext, config }: IAuthAppDeps): IAuthApp;
@@ -10,6 +10,7 @@ export { default as globalSettings } from './globalSettingsApp';
10
10
  export { default as subscriptionsHelper } from './helpers/subscriptions';
11
11
  export { default as import } from './importApp';
12
12
  export { default as indexationManager } from './indexationManagerApp';
13
+ export { default as logsCollector } from './logsCollectorApp';
13
14
  export { default as library } from './libraryApp/libraryApp';
14
15
  export { default as log } from './logApp';
15
16
  export { default as permission } from './permissionApp/permissionApp';
@@ -0,0 +1,9 @@
1
+ import { type ILogsCollectorDomain } from 'domain/logsCollector/logsCollectorDomain';
2
+ export interface ILogsCollectorApp {
3
+ init(): Promise<void>;
4
+ }
5
+ interface IDeps {
6
+ 'core.domain.logsCollector': ILogsCollectorDomain;
7
+ }
8
+ export default function ({ 'core.domain.logsCollector': logsCollector }: IDeps): ILogsCollectorApp;
9
+ export {};
@@ -0,0 +1 @@
1
+ export { default } from './logsCollectorDomain';
@@ -0,0 +1,16 @@
1
+ import { type IAmqpService } from '@leav/message-broker';
2
+ import { type ILogger } from '@leav/logger';
3
+ import type * as Config from '_types/config';
4
+ import { type IIndexationService } from '../../infra/indexation/indexationService';
5
+ import { type IElasticsearchService } from '../../infra/elasticsearch/elasticsearchService';
6
+ export interface ILogsCollectorDomain {
7
+ init(): Promise<void>;
8
+ }
9
+ export interface ILogsCollectorDomainDeps {
10
+ config: Config.IConfig;
11
+ 'core.infra.amqpService': IAmqpService;
12
+ 'core.infra.indexation.indexationService': IIndexationService;
13
+ 'core.utils.logger': ILogger;
14
+ 'core.infra.elasticsearch.service': IElasticsearchService;
15
+ }
16
+ export default function ({ config, 'core.infra.amqpService': amqpService, 'core.infra.indexation.indexationService': indexationService, 'core.utils.logger': logger, 'core.infra.elasticsearch.service': esService }: ILogsCollectorDomainDeps): ILogsCollectorDomain;
@@ -5,4 +5,4 @@ export { default as permissionsByActions } from './permissionsByActions';
5
5
  export { default as reducePermissionsArray } from './reducePermissionsArray';
6
6
  export { default as simplePermission } from './simplePermission';
7
7
  export { default as treeBasedPermissions } from './treeBasedPermissions';
8
- export { default as recordInCreationByPass } from './recordInCreationBypass';
8
+ export { default as recordInCreationBypass } from './recordInCreationBypass';
@@ -1,6 +1,11 @@
1
1
  import { type IRecord } from '../../../_types/record';
2
2
  import { type IQueryInfos } from '../../../_types/queryInfos';
3
- export interface IRecordInCreationByPassHelper {
4
- recordInCreationByPass: (record: IRecord, ctx: IQueryInfos) => boolean;
3
+ import { type IRecordRepo } from '../../../infra/record/recordRepo';
4
+ export interface IRecordInCreationBypassHelper {
5
+ recordInCreationBypass: (record: IRecord, ctx: IQueryInfos) => boolean;
6
+ recordInCreationBypassById: (libraryId: string, recordId: string, ctx: IQueryInfos) => Promise<boolean>;
5
7
  }
6
- export default function (): IRecordInCreationByPassHelper;
8
+ export interface IRecordInCreationBypassHelperDeps {
9
+ 'core.infra.record': IRecordRepo;
10
+ }
11
+ export default function ({ 'core.infra.record': recordRepo }: IRecordInCreationBypassHelperDeps): IRecordInCreationBypassHelper;
@@ -8,7 +8,7 @@ import { type IPermissionByUserGroupsHelper } from './helpers/permissionByUserGr
8
8
  import { type ITreeBasedPermissionHelper } from './helpers/treeBasedPermissions';
9
9
  import { type IGetRecordAttributeHeritedPermissionsParams as IGetRecordAttributeInheritedPermissionsParams } from './_types';
10
10
  import { type IRecordRepo } from '../../infra/record/recordRepo';
11
- import { type IRecordInCreationByPassHelper } from './helpers/recordInCreationBypass';
11
+ import { type IRecordInCreationBypassHelper } from './helpers/recordInCreationBypass';
12
12
  export interface IRecordAttributePermissionDomain {
13
13
  getRecordAttributePermission(action: RecordAttributePermissionsActions, userGroupId: string, attributeId: string, recordLibrary: string, recordId: string, ctx: IQueryInfos): Promise<boolean>;
14
14
  getInheritedRecordAttributePermission(params: IGetRecordAttributeInheritedPermissionsParams, ctx: IQueryInfos): Promise<boolean>;
@@ -18,7 +18,7 @@ export interface IRecordAttributePermissionDomainDeps {
18
18
  'core.domain.permission.helpers.treeBasedPermissions': ITreeBasedPermissionHelper;
19
19
  'core.domain.permission.helpers.permissionByUserGroups': IPermissionByUserGroupsHelper;
20
20
  'core.domain.permission.helpers.defaultPermission': IDefaultPermissionHelper;
21
- 'core.domain.permission.helpers.recordInCreationByPass': IRecordInCreationByPassHelper;
21
+ 'core.domain.permission.helpers.recordInCreationBypass': IRecordInCreationBypassHelper;
22
22
  'core.domain.attribute': IAttributeDomain;
23
23
  'core.infra.value': IValueRepo;
24
24
  'core.infra.record': IRecordRepo;
@@ -8,7 +8,7 @@ import { type ILibraryPermissionDomain } from './libraryPermissionDomain';
8
8
  import { type IEstimateTreeValueRecordPermissionParams, type IGetInheritedRecordPermissionParams, type IGetRecordPermissionParams } from './_types';
9
9
  import { type ITreeRepo } from '../../infra/tree/treeRepo';
10
10
  import { type IRecordRepo } from '../../infra/record/recordRepo';
11
- import { type IRecordInCreationByPassHelper } from './helpers/recordInCreationBypass';
11
+ import { type IRecordInCreationBypassHelper } from './helpers/recordInCreationBypass';
12
12
  export interface IRecordPermissionDomain {
13
13
  getRecordPermission(params: IGetRecordPermissionParams): Promise<boolean>;
14
14
  getInheritedRecordPermission(params: IGetInheritedRecordPermissionParams): Promise<boolean>;
@@ -19,7 +19,7 @@ export interface IRecordPermissionDomainDeps {
19
19
  'core.domain.permission.helpers.treeBasedPermissions': ITreeBasedPermissionHelper;
20
20
  'core.domain.permission.helpers.permissionByUserGroups': IPermissionByUserGroupsHelper;
21
21
  'core.domain.permission.helpers.defaultPermission': IDefaultPermissionHelper;
22
- 'core.domain.permission.helpers.recordInCreationByPass': IRecordInCreationByPassHelper;
22
+ 'core.domain.permission.helpers.recordInCreationBypass': IRecordInCreationBypassHelper;
23
23
  'core.domain.attribute': IAttributeDomain;
24
24
  'core.domain.helpers.getCoreEntityById': GetCoreEntityByIdFunc;
25
25
  'core.infra.value': IValueRepo;
@@ -11,14 +11,15 @@ interface IAccessPermissionFilterDeps {
11
11
  'core.infra.permission': IPermissionRepo;
12
12
  'core.domain.permission.helpers.defaultPermission': IDefaultPermissionHelper;
13
13
  }
14
+ interface INodeIdsByPermissions {
15
+ true: Array<ITreeNode['id']>;
16
+ false: Array<ITreeNode['id']>;
17
+ }
14
18
  export interface IGetAccessPermissionsValue {
15
19
  treeId: string;
16
20
  attribute: IAttribute;
17
- permissions: {
18
- true: Array<ITreeNode['id']>;
19
- false: Array<ITreeNode['id']>;
20
- };
21
+ permissions: INodeIdsByPermissions;
21
22
  }
22
- export type IGetAccessPermissions = (groupsIds: string[][], library: string, deps: IAccessPermissionFilterDeps, ctx: IQueryInfos) => Promise<IGetAccessPermissionsValue[]>;
23
+ export type IGetAccessPermissions = (groupsIds: string[][], library: string, existingFiltersOnTreeIds: string[], deps: IAccessPermissionFilterDeps, ctx: IQueryInfos) => Promise<IGetAccessPermissionsValue[]>;
23
24
  declare const getAccessPermissionsFilters: IGetAccessPermissions;
24
25
  export default getAccessPermissionsFilters;
@@ -26,6 +26,7 @@ import { type DeleteRecordHelper } from './helpers/deleteRecord';
26
26
  import { type CreateRecordHelper } from './helpers/createRecord';
27
27
  import { type IElementAncestorsHelper } from 'domain/tree/helpers/elementAncestors';
28
28
  import { type ILogger } from '@leav/logger';
29
+ export declare const ATTRIBUTE_ACTIVE = "active";
29
30
  export interface IRecordDomain {
30
31
  /**
31
32
  * Create empty record
@@ -24,6 +24,7 @@ import { type IDeleteValueParams, type IRunActionListParams } from './_types';
24
24
  import { type DeleteRecordHelper } from 'domain/record/helpers/deleteRecord';
25
25
  import { type CreateRecordHelper } from 'domain/record/helpers/createRecord';
26
26
  import { type IfLibraryJoinLinkAttribute } from '../attribute/helpers/ifLibraryJoinLinkAttribute';
27
+ import { type IRecordInCreationBypassHelper } from '../permission/helpers/recordInCreationBypass';
27
28
  export interface ISaveBatchValueError {
28
29
  type: string;
29
30
  message: string;
@@ -107,6 +108,7 @@ export interface IValueDomainDeps {
107
108
  'core.domain.record.helpers.sendRecordUpdateEvent': SendRecordUpdateEventHelper;
108
109
  'core.domain.record.helpers.createRecord': CreateRecordHelper;
109
110
  'core.domain.record.helpers.deleteRecord': DeleteRecordHelper;
111
+ 'core.domain.permission.helpers.recordInCreationBypass': IRecordInCreationBypassHelper;
110
112
  'core.domain.attribute.helpers.ifLibraryJoinLinkAttribute': IfLibraryJoinLinkAttribute;
111
113
  'core.domain.versionProfile': IVersionProfileDomain;
112
114
  'core.infra.record': IRecordRepo;
@@ -116,5 +118,5 @@ export interface IValueDomainDeps {
116
118
  'core.utils.logger': ILogger;
117
119
  'core.domain.tree': ITreeDomain;
118
120
  }
119
- declare const valueDomain: ({ config, "core.domain.actionsList": actionsListDomain, "core.domain.attribute": attributeDomain, "core.domain.permission.recordAttribute": recordAttributePermissionDomain, "core.domain.permission.record": recordPermissionDomain, "core.domain.eventsManager": eventsManager, "core.domain.helpers.validate": validate, "core.domain.helpers.updateRecordLastModif": updateRecordLastModif, "core.domain.tree.helpers.elementAncestors": elementAncestors, "core.domain.tree.helpers.getDefaultElement": getDefaultElementHelper, "core.domain.record.helpers.sendRecordUpdateEvent": sendRecordUpdateEvent, "core.domain.record.helpers.createRecord": createRecordHelper, "core.domain.record.helpers.deleteRecord": deleteRecordHelper, "core.domain.attribute.helpers.ifLibraryJoinLinkAttribute": ifLibraryJoinLinkAttribute, "core.domain.versionProfile": versionProfileDomain, "core.infra.record": recordRepo, "core.infra.tree": treeRepo, "core.infra.value": valueRepo, "core.utils": utils, "core.utils.logger": logger }: IValueDomainDeps) => IValueDomain;
121
+ declare const valueDomain: ({ config, "core.domain.actionsList": actionsListDomain, "core.domain.attribute": attributeDomain, "core.domain.permission.recordAttribute": recordAttributePermissionDomain, "core.domain.permission.record": recordPermissionDomain, "core.domain.eventsManager": eventsManager, "core.domain.helpers.validate": validate, "core.domain.helpers.updateRecordLastModif": updateRecordLastModif, "core.domain.tree.helpers.elementAncestors": elementAncestors, "core.domain.tree.helpers.getDefaultElement": getDefaultElementHelper, "core.domain.record.helpers.sendRecordUpdateEvent": sendRecordUpdateEvent, "core.domain.record.helpers.createRecord": createRecordHelper, "core.domain.permission.helpers.recordInCreationBypass": recordInCreationBypassHelper, "core.domain.record.helpers.deleteRecord": deleteRecordHelper, "core.domain.attribute.helpers.ifLibraryJoinLinkAttribute": ifLibraryJoinLinkAttribute, "core.domain.versionProfile": versionProfileDomain, "core.infra.record": recordRepo, "core.infra.tree": treeRepo, "core.infra.value": valueRepo, "core.utils": utils, "core.utils.logger": logger }: IValueDomainDeps) => IValueDomain;
120
122
  export default valueDomain;
@@ -1,9 +1,9 @@
1
- import { type IConfig } from '_types/config';
2
1
  import { type ICacheService } from './cacheService';
3
2
  import { type RedisClientType } from './redis';
3
+ import { type IConfig } from '../../_types/config';
4
4
  interface IDeps {
5
5
  config?: IConfig;
6
6
  'core.infra.redis'?: RedisClientType;
7
7
  }
8
- export default function ({ config, 'core.infra.redis': redis }: IDeps): ICacheService;
8
+ export default function ({ 'core.infra.redis': redis, config }: IDeps): ICacheService;
9
9
  export {};
@@ -1,6 +1,6 @@
1
1
  import { Client, type estypes } from '@elastic/elasticsearch';
2
2
  import { type IConfig } from '_types/config';
3
- import { type IQueryInfos } from '_types/queryInfos';
3
+ import { type Log } from '@leav/utils';
4
4
  export interface IElasticsearchServiceSearchResponse<T> {
5
5
  total: number;
6
6
  hits: T[];
@@ -15,13 +15,14 @@ interface IElasticsearchServiceSearchParams {
15
15
  };
16
16
  query?: estypes.QueryDslQueryContainer;
17
17
  }
18
- export interface IElasticSearchService {
18
+ export interface IElasticsearchService {
19
19
  client: Client;
20
- search: <T>(params: IElasticsearchServiceSearchParams, ctx: IQueryInfos) => Promise<IElasticsearchServiceSearchResponse<T>>;
20
+ search: <T>(params: IElasticsearchServiceSearchParams) => Promise<IElasticsearchServiceSearchResponse<T>>;
21
+ writeData: (indexName: string, data: Log) => Promise<void>;
21
22
  }
22
- interface IDeps {
23
- 'core.infra.elasticSearch.client'?: Client;
23
+ export interface IElasticsearchServiceDeps {
24
+ 'core.infra.elasticsearch.client'?: Client;
24
25
  config?: IConfig;
25
26
  }
26
- export default function ({ config }: IDeps): IElasticSearchService;
27
+ export default function ({ config }: IElasticsearchServiceDeps): IElasticsearchService;
27
28
  export {};
@@ -0,0 +1 @@
1
+ export { default as service } from './elasticsearchService';
@@ -1,4 +1,4 @@
1
- import { type IElasticSearchService } from 'infra/elasticSearch/elasticSearchService';
1
+ import { type IElasticsearchService } from 'infra/elasticsearch/elasticsearchService';
2
2
  import { type IConfig } from '_types/config';
3
3
  import { type ILogFilters, type ILogPagination, type ILogResponse, type ILogSort } from '_types/log';
4
4
  import { type IQueryInfos } from '_types/queryInfos';
@@ -10,8 +10,8 @@ export interface ILogRepo {
10
10
  }, ctx: IQueryInfos): Promise<ILogResponse>;
11
11
  }
12
12
  interface IDeps {
13
- 'core.infra.elasticSearch.service'?: IElasticSearchService;
13
+ 'core.infra.elasticsearch.service'?: IElasticsearchService;
14
14
  config?: IConfig;
15
15
  }
16
- export default function ({ 'core.infra.elasticSearch.service': esService, config }: IDeps): ILogRepo;
16
+ export default function ({ 'core.infra.elasticsearch.service': esService, config }: IDeps): ILogRepo;
17
17
  export {};
@@ -1,5 +1,6 @@
1
1
  export { default as cli } from './cli';
2
2
  export { default as filesManager } from './filesManager';
3
3
  export { default as indexationManager } from './indexationManager';
4
+ export { default as logsCollector } from './logsCollector';
4
5
  export { default as tasksManager } from './tasksManager';
5
6
  export { default as server } from './server';
@@ -0,0 +1,9 @@
1
+ import { type ILogsCollectorApp } from 'app/core/logsCollectorApp';
2
+ export interface ILogsCollectorInterface {
3
+ init(): Promise<void>;
4
+ }
5
+ interface IDeps {
6
+ 'core.app.core.logsCollector': ILogsCollectorApp;
7
+ }
8
+ export default function ({ 'core.app.core.logsCollector': logsCollector }: IDeps): ILogsCollectorInterface;
9
+ export {};
@@ -0,0 +1,14 @@
1
+ interface ICallerInfo {
2
+ path: string;
3
+ line: string;
4
+ col: string;
5
+ }
6
+ export declare class LoggerCallStack {
7
+ private callerLineIndexInStack;
8
+ getCallStackTrace(): string | null;
9
+ getLocationInfo(): ICallerInfo | null;
10
+ private getStackLines;
11
+ private detectCallLineIndexInStack;
12
+ private callStackTraceLongEnough;
13
+ }
14
+ export {};
@@ -0,0 +1,2 @@
1
+ import winston from 'winston';
2
+ export declare function catchErrorFormatter(onErrorLog?: (message: string, meta: any, getCallStackTrace: () => string) => void): winston.Logform.FormatWrap | null;
@@ -3,7 +3,7 @@ export interface ILoggerConfig {
3
3
  * Log level (error, warn, info, log, verbose, debug, silly)
4
4
  * @default info
5
5
  */
6
- level: string;
6
+ level?: string;
7
7
  /**
8
8
  * If true, disable all logging
9
9
  * Default: true if TS_JEST=1 (tests), false otherwise
@@ -18,7 +18,36 @@ export interface ILoggerConfig {
18
18
  * Default: false (plain text)
19
19
  */
20
20
  useJsonFormat?: boolean;
21
- onErrorLog?: (message: string, meta: any) => void;
21
+ /**
22
+ * If true, add timestamp to each log line, ISO format
23
+ */
24
+ addTimestamp?: boolean;
25
+ /**
26
+ * If true, add file and line number of the code that called the logger function (error, warn, info, debug, etc.)
27
+ */
28
+ addLocationInfo?: boolean;
29
+ /**
30
+ * Add those metadata to all logs
31
+ */
32
+ additionalMeta?: {
33
+ /**
34
+ * any string to identify the application those logs came from
35
+ */
36
+ app?: string;
37
+ /**
38
+ * any string to identify each client those logs came from
39
+ */
40
+ client?: string;
41
+ /**
42
+ * environment, like production, development, test, integration
43
+ */
44
+ env?: string;
45
+ /**
46
+ * application version, maybe semver format
47
+ */
48
+ version?: string;
49
+ };
50
+ onErrorLog?: (message: string, meta: any, getCallStackTrace: () => string) => void;
22
51
  }
23
52
  export declare function envToBool(value: string, defaultValue?: boolean): boolean;
24
- export declare const defaultLoggerConfig: ILoggerConfig;
53
+ export declare const defaultLoggerConfig: ILoggerConfig & Required<Omit<ILoggerConfig, 'onErrorLog'>>;
@@ -0,0 +1,2 @@
1
+ import winston from 'winston';
2
+ export declare const addLocationInfoInLog: winston.Logform.FormatWrap;
@@ -1,4 +1,4 @@
1
- import * as winston from 'winston';
1
+ import winston from 'winston';
2
2
  import { type ILoggerConfig } from './config';
3
3
  export type ILogger = Pick<typeof winston, 'error' | 'warn' | 'info' | 'log' | 'verbose' | 'debug' | 'silly'>;
4
4
  export declare function configureLogger(config: ILoggerConfig): void;
@@ -1,5 +1,5 @@
1
1
  import * as amqp from 'amqplib';
2
- import { type IAmqp, type onMessageFunc } from './types/amqp';
2
+ import { type IAmqp, type OnMessageFunc } from './types/amqp';
3
3
  export interface IAmqpService {
4
4
  publisher: {
5
5
  connection: amqp.ChannelModel;
@@ -10,7 +10,7 @@ export interface IAmqpService {
10
10
  channel: amqp.ConfirmChannel;
11
11
  };
12
12
  publish(exchange: string, routingKey: string, msg: string, priority?: number): Promise<void>;
13
- consume(queue: string, routingKey: string, onMessage: onMessageFunc, consumerTag?: string): Promise<amqp.Replies.Consume>;
13
+ consume(queue: string, routingKey: string, onMessage: OnMessageFunc, consumerTag?: string): Promise<amqp.Replies.Consume>;
14
14
  close(): Promise<void>;
15
15
  }
16
16
  interface IDeps {
@@ -12,4 +12,4 @@ export interface IAmqpConn {
12
12
  export interface IMessageBody {
13
13
  [key: string]: any;
14
14
  }
15
- export type onMessageFunc = (msg: amqp.ConsumeMessage) => Promise<void>;
15
+ export type OnMessageFunc = (msg: amqp.ConsumeMessage) => Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aristid/leav-types",
3
- "version": "1.4.0",
3
+ "version": "1.4.1-242090ba",
4
4
  "description": "Shared Leav types",
5
5
  "scripts": {
6
6
  "tscheck": "",
@@ -14,7 +14,7 @@
14
14
  "license": "LGPL3",
15
15
  "repository": "https://github.com/leav-solutions/leav-engine",
16
16
  "dependencies": {
17
- "@leav/utils": "1.4.0",
17
+ "@leav/utils": "1.4.1",
18
18
  "@types/amqplib": "0.10.7",
19
19
  "@types/express": "5.0.0",
20
20
  "@types/jest": "29.5.14",
@@ -1 +0,0 @@
1
- export { default as service } from './elasticSearchService';