@aristid/leav-types 0.0.7-9f9d1cc7 → 0.0.7-a04a265e

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 (50) hide show
  1. package/apps/core/config/default.d.ts +12 -0
  2. package/apps/core/config/development.d.ts +1 -0
  3. package/apps/core/config/test.d.ts +1 -0
  4. package/apps/core/src/__tests__/e2e/api/e2eUtils.d.ts +1 -0
  5. package/apps/core/src/__tests__/e2e/api/getConditionPart/getConditionPart.test.d.ts +1 -0
  6. package/apps/core/src/__tests__/e2e/api/globalSetup.d.ts +6 -1
  7. package/apps/core/src/__tests__/integration/globalSetup.d.ts +1 -0
  8. package/apps/core/src/__tests__/integration/globalSetupHook.d.ts +1 -0
  9. package/apps/core/src/__tests__/integration/infra/attributeAdvancedLinkRepo.test.d.ts +1 -0
  10. package/apps/core/src/__tests__/integration/infra/attributeAdvancedRepo.test.d.ts +1 -0
  11. package/apps/core/src/__tests__/integration/infra/attributeSimpleLinkRepo.test.d.ts +1 -0
  12. package/apps/core/src/__tests__/integration/infra/attributeSimpleRepo.test.d.ts +1 -0
  13. package/apps/core/src/__tests__/integration/infra/attributeTreeRepo.test.d.ts +1 -0
  14. package/apps/core/src/__tests__/integration/infra/integrationTestRepoUtils.d.ts +7 -0
  15. package/apps/core/src/__tests__/integration/infra/recordRepo.test.d.ts +1 -0
  16. package/apps/core/src/__tests__/integration/infra/treeRepo.test.d.ts +1 -0
  17. package/apps/core/src/__tests__/integration/teardown.d.ts +1 -0
  18. package/apps/core/src/_types/config.d.ts +34 -1
  19. package/apps/core/src/_types/errors.d.ts +1 -0
  20. package/apps/core/src/_types/events.d.ts +45 -0
  21. package/apps/core/src/_types/library.d.ts +7 -0
  22. package/apps/core/src/_types/permissions.d.ts +3 -1
  23. package/apps/core/src/_types/queryInfos.d.ts +5 -0
  24. package/apps/core/src/_types/record.d.ts +4 -4
  25. package/apps/core/src/_types/tree.d.ts +1 -1
  26. package/apps/core/src/_types/value.d.ts +2 -2
  27. package/apps/core/src/_types/views.d.ts +1 -1
  28. package/apps/core/src/app/graphql/graphqlApp.d.ts +4 -0
  29. package/apps/core/src/domain/eventsManager/eventsManagerDomain.d.ts +3 -2
  30. package/apps/core/src/domain/import/importDomain.d.ts +11 -1
  31. package/apps/core/src/domain/indexationManager/indexationManagerDomain.d.ts +3 -1
  32. package/apps/core/src/domain/log/logDomain.d.ts +3 -1
  33. package/apps/core/src/domain/permission/_types.d.ts +2 -2
  34. package/apps/core/src/domain/permission/helpers/globalPermission.d.ts +3 -12
  35. package/apps/core/src/domain/permission/helpers/permissionByUserGroups.d.ts +7 -7
  36. package/apps/core/src/domain/permission/helpers/treeBasedPermissions.d.ts +0 -4
  37. package/apps/core/src/domain/permission/permissionDomain.d.ts +1 -0
  38. package/apps/core/src/domain/permission/treeNodePermissionDomain.d.ts +2 -2
  39. package/apps/core/src/domain/record/helpers/createRecord.d.ts +1 -0
  40. package/apps/core/src/domain/record/recordDomain.d.ts +22 -1
  41. package/apps/core/src/domain/tree/treeDomain.d.ts +2 -2
  42. package/apps/core/src/infra/attributeTypes/attributeTypesRepo.d.ts +25 -1
  43. package/apps/core/src/infra/record/recordRepo.d.ts +9 -0
  44. package/apps/core/src/infra/tree/treeRepo.d.ts +3 -2
  45. package/apps/core/src/infra/value/valueRepo.d.ts +8 -6
  46. package/apps/core/src/utils/dataloader.d.ts +9 -0
  47. package/apps/core/src/utils/dataloader.spec.d.ts +1 -0
  48. package/apps/core/src/utils/helpers/getSystemQueryContext.d.ts +8 -0
  49. package/apps/core/src/utils/index.d.ts +1 -0
  50. package/package.json +1 -1
@@ -25,6 +25,14 @@ export declare namespace db {
25
25
  export declare namespace diskCache {
26
26
  let directory: string;
27
27
  }
28
+ export declare namespace dataLoaders {
29
+ namespace valueRepo {
30
+ namespace getValues {
31
+ let enableCache: string | boolean;
32
+ let useBatch: string | boolean;
33
+ }
34
+ }
35
+ }
28
36
  export declare namespace auth {
29
37
  let scheme: string;
30
38
  let key: string;
@@ -43,6 +51,7 @@ export declare namespace auth {
43
51
  let postLogoutRedirectUri: string;
44
52
  let skipLogoutConfirmationPage: string | boolean;
45
53
  let idTokenUserClaim: string;
54
+ let enableAutoProvisioning: string | boolean;
46
55
  }
47
56
  let testApiKey: string;
48
57
  }
@@ -74,6 +83,8 @@ export declare namespace logs {
74
83
  export declare namespace permissions {
75
84
  let _default_1: boolean;
76
85
  export { _default_1 as default };
86
+ let enableCache_1: string | boolean;
87
+ export { enableCache_1 as enableCache };
77
88
  }
78
89
  export declare namespace amqp {
79
90
  namespace connOpt {
@@ -169,6 +180,7 @@ export declare namespace _import {
169
180
  export let sizeLimit: string | number;
170
181
  export let groupData: string | number;
171
182
  export let maxStackedElements: string | number;
183
+ export let delayTaskExecMs: string | number;
172
184
  }
173
185
  export declare namespace preview {
174
186
  let directory_3: string;
@@ -1,5 +1,6 @@
1
1
  export namespace server {
2
2
  let publicUrl: string;
3
+ let allowIntrospection: boolean;
3
4
  }
4
5
  export namespace logs {
5
6
  let level: string;
@@ -6,6 +6,7 @@ export namespace server {
6
6
  let password: string;
7
7
  let email: string;
8
8
  }
9
+ let allowIntrospection: boolean;
9
10
  }
10
11
  export namespace db {
11
12
  let name: string;
@@ -20,6 +20,7 @@ export declare function gqlSaveAttribute(params: {
20
20
  multipleValues?: boolean;
21
21
  reverseLink?: string;
22
22
  actionsList?: ActionsListConfig;
23
+ required?: boolean;
23
24
  }): Promise<any>;
24
25
  export declare function gqlSaveTree(id: string, label: string, libraries: string[]): Promise<any>;
25
26
  export declare function gqlCreateRecord(library: string): Promise<string>;
@@ -1,3 +1,8 @@
1
+ import { AwilixContainer } from 'awilix';
1
2
  import { IConfig } from '../../../_types/config';
2
- export declare const init: (conf: IConfig) => Promise<any>;
3
+ import { IDbUtils } from 'infra/db/dbUtils';
4
+ export declare const init: (conf: IConfig) => Promise<{
5
+ coreContainer: AwilixContainer;
6
+ dbUtils: IDbUtils;
7
+ }>;
3
8
  export declare function setup(): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare function setup(): Promise<void>;
@@ -0,0 +1 @@
1
+ export default function (): Promise<any>;
@@ -0,0 +1,7 @@
1
+ import { ILibraryRepo } from 'infra/library/libraryRepo';
2
+ import { IRecordRepo } from 'infra/record/recordRepo';
3
+ import { ITreeRepo } from 'infra/tree/treeRepo';
4
+ export declare const getCoreDep: <T>(path: any) => T;
5
+ export declare const getLibraryRepo: () => ILibraryRepo;
6
+ export declare const getRecordRepo: () => IRecordRepo;
7
+ export declare const getTreeRepo: () => ITreeRepo;
@@ -0,0 +1 @@
1
+ export default function (): Promise<void>;
@@ -5,6 +5,7 @@ export interface IConfig {
5
5
  server: IServer;
6
6
  db: IDb;
7
7
  diskCache: IDiskCache;
8
+ dataLoaders: IDataLoaders;
8
9
  auth: IAuth;
9
10
  mailer: IMailer;
10
11
  lang: ILang;
@@ -36,7 +37,8 @@ export declare enum CoreMode {
36
37
  FILES_MANAGER = "filesManager",
37
38
  INDEXATION_MANAGER = "indexationManager",
38
39
  TASKS_MANAGER_MASTER = "tasksManager:master",
39
- TASKS_MANAGER_WORKER = "tasksManager:worker"
40
+ TASKS_MANAGER_WORKER = "tasksManager:worker",
41
+ CLI = "cli"
40
42
  }
41
43
  export interface IServer {
42
44
  host: string;
@@ -84,6 +86,7 @@ export interface IAuth {
84
86
  postLogoutRedirectUri: string;
85
87
  skipLogoutConfirmationPage?: boolean;
86
88
  idTokenUserClaim: string;
89
+ enableAutoProvisioning: boolean;
87
90
  };
88
91
  testApiKey?: string;
89
92
  }
@@ -107,6 +110,7 @@ export interface ILogs {
107
110
  }
108
111
  export interface IPermissions {
109
112
  default: boolean;
113
+ enableCache: boolean;
110
114
  }
111
115
  export interface IAmqp {
112
116
  connOpt: Options.Connect;
@@ -175,6 +179,35 @@ export interface IImport {
175
179
  sizeLimit: number;
176
180
  groupData: number;
177
181
  maxStackedElements: number;
182
+ /**
183
+ * Hack for leav deploy on nfs which is asynchronous for file write (by default)
184
+ * Wait this delay before submitting import data job
185
+ */
186
+ delayTaskExecMs: number;
187
+ }
188
+ /**
189
+ * Data loaders configuration for performances
190
+ */
191
+ export interface IDataLoaders {
192
+ valueRepo: {
193
+ getValues: {
194
+ /**
195
+ * @default false
196
+ *
197
+ * Enable cache inside data loaders in the query context
198
+ * Before enable, ensure that it has no side effects, for instance on saveValue/deleteValue mutations
199
+ */
200
+ enableCache: boolean;
201
+ /**
202
+ * @default true
203
+ *
204
+ * Enable: do batch arangodb query
205
+ * Disable: do one arangodb query per value, as before data loader use. For rollback if issue with batch query
206
+ * Temporary, to be removed in future
207
+ */
208
+ useBatch: boolean;
209
+ };
210
+ };
178
211
  }
179
212
  export interface IDiskCache {
180
213
  directory: string;
@@ -63,6 +63,7 @@ export declare enum Errors {
63
63
  PREVIEWS_SETTINGS_NOT_ALLOWED = "PREVIEWS_SETTINGS_NOT_ALLOWED",
64
64
  PROTECTED_ENDPOINT = "PROTECTED_ENDPOINT",
65
65
  READONLY_ATTRIBUTE = "READONLY_ATTRIBUTE",
66
+ RECORD_ACTIVATION_FAILED = "RECORD_ACTIVATION_FAILED",
66
67
  REQUIRED_ATTRIBUTE = "REQUIRED_ATTRIBUTE",
67
68
  REQUIRED_ATTRIBUTE_FORMAT = "REQUIRED_ATTRIBUTE_FORMAT",
68
69
  REQUIRED_ATTRIBUTE_LABEL = "REQUIRED_ATTRIBUTE_LABEL",
@@ -0,0 +1,45 @@
1
+ import { EventAction, IDbPayload } from '@leav/utils';
2
+ import { IApiKey } from './apiKey';
3
+ import { IApplication } from './application';
4
+ import { IAttribute } from './attribute';
5
+ import { IGlobalSettings } from './globalSettings';
6
+ import { ILibraryDbEvent } from './library';
7
+ import { IRecord } from './record';
8
+ import { IValue } from './value';
9
+ import { IVersionProfile } from './versionProfile';
10
+ import { IPermission } from './permissions';
11
+ import { ITree } from './tree';
12
+ /**
13
+ * Maybe move all DBPayloadData types in @leav/utils type to allow event consumers outside core to use them
14
+ * without having to redeclare them. For now before and after are any in @leav/utils
15
+ */
16
+ export interface IDbPayloadInternal<DBPayloadAction extends EventAction> extends IDbPayload {
17
+ action: DBPayloadAction;
18
+ before?: IDBPayloadData<DBPayloadAction>;
19
+ after?: IDBPayloadData<DBPayloadAction>;
20
+ }
21
+ interface IDBPayloadDataMap {
22
+ [EventAction.VALUE_SAVE]: IValue;
23
+ [EventAction.VALUE_DELETE]: IValue;
24
+ [EventAction.ATTRIBUTE_SAVE]: IAttribute;
25
+ [EventAction.ATTRIBUTE_DELETE]: IAttribute;
26
+ [EventAction.RECORD_SAVE]: IRecord;
27
+ [EventAction.RECORD_DELETE]: IRecord;
28
+ [EventAction.API_KEY_SAVE]: IApiKey;
29
+ [EventAction.API_KEY_DELETE]: IApiKey;
30
+ [EventAction.APP_SAVE]: IApplication;
31
+ [EventAction.APP_DELETE]: IApplication;
32
+ [EventAction.GLOBAL_SETTINGS_SAVE]: IGlobalSettings;
33
+ [EventAction.LIBRARY_SAVE]: ILibraryDbEvent;
34
+ [EventAction.LIBRARY_DELETE]: ILibraryDbEvent;
35
+ [EventAction.VERSION_PROFILE_SAVE]: IVersionProfile;
36
+ [EventAction.VERSION_PROFILE_DELETE]: IVersionProfile;
37
+ [EventAction.TREE_ADD_ELEMENT]: string;
38
+ [EventAction.TREE_DELETE_ELEMENT]: string;
39
+ [EventAction.TREE_MOVE_ELEMENT]: string;
40
+ [EventAction.TREE_SAVE]: ITree;
41
+ [EventAction.TREE_DELETE]: ITree;
42
+ [EventAction.PERMISSION_SAVE]: IPermission;
43
+ }
44
+ type IDBPayloadData<DBPayloadAction extends EventAction> = DBPayloadAction extends keyof IDBPayloadDataMap ? IDBPayloadDataMap[DBPayloadAction] : never;
45
+ export {};
@@ -35,6 +35,13 @@ export interface ILibrary extends ICoreEntity {
35
35
  previewsSettings?: ILibraryPreviewsSettings[];
36
36
  settings?: IKeyValue<any>;
37
37
  }
38
+ /**
39
+ * Library as stored in the DB, without embedded attributes
40
+ */
41
+ export interface ILibraryDbEvent extends Omit<ILibrary, 'attributes' | 'fullTextAttributes'> {
42
+ attributes?: string[];
43
+ fullTextAttributes?: string[];
44
+ }
38
45
  export interface ILibraryFilterOptions extends ICoreEntityFilterOptions {
39
46
  system?: boolean;
40
47
  }
@@ -76,7 +76,9 @@ export declare enum AdminPermissionsActions {
76
76
  CREATE_API_KEY = "admin_create_api_key",
77
77
  EDIT_API_KEY = "admin_edit_api_key",
78
78
  DELETE_API_KEY = "admin_delete_api_key",
79
- EDIT_GLOBAL_SETTINGS = "admin_edit_global_settings"
79
+ EDIT_GLOBAL_SETTINGS = "admin_edit_global_settings",
80
+ ACCESS_LOGS = "admin_access_logs",
81
+ IMPORT_CONFIG_CLEAR_DATABASE = "admin_import_config_clear_database"
80
82
  }
81
83
  export type PermissionsActions = LibraryPermissionsActions | RecordPermissionsActions | RecordAttributePermissionsActions | AdminPermissionsActions | AttributePermissionsActions | TreePermissionsActions | TreeNodePermissionsActions | ApplicationPermissionsActions;
82
84
  export interface ILabeledPermissionsAction {
@@ -1,3 +1,4 @@
1
+ import DataLoader from 'dataloader';
1
2
  import type LeavError from 'errors/LeavError';
2
3
  import { IDbProfiler } from './dbProfiler';
3
4
  import { IValueVersion } from './value';
@@ -13,4 +14,8 @@ export interface IQueryInfos {
13
14
  dbProfiler?: IDbProfiler;
14
15
  trigger?: string;
15
16
  errors?: Array<LeavError<unknown>>;
17
+ /**
18
+ * For request duration store dataloader on demand with getOrCreateDataLoaderInCtx
19
+ */
20
+ dataLoaders?: Record<string, DataLoader<unknown, unknown>>;
16
21
  }
@@ -75,10 +75,10 @@ export interface IQueryField {
75
75
  export interface IRecordIdentity {
76
76
  id: string;
77
77
  library: ILibrary;
78
- label?: string;
79
- subLabel?: string;
80
- color?: string;
81
- preview?: IPreview;
78
+ getLabel?: () => Promise<string | null>;
79
+ getSubLabel?: () => Promise<string | null>;
80
+ getColor?: () => Promise<string | null>;
81
+ getPreview?: () => Promise<IPreview | null>;
82
82
  }
83
83
  export interface IRecordIdentityConf {
84
84
  label?: string;
@@ -38,7 +38,7 @@ export type ITreeNodeLight = Pick<ITreeNode, 'id' | 'order'>;
38
38
  export interface ITreeNodeWithTreeId extends ITreeNode {
39
39
  treeId: string;
40
40
  }
41
- export type TreePaths = ITreeNode[];
41
+ export type TreePath = ITreeNode[];
42
42
  export declare enum TreeBehavior {
43
43
  STANDARD = "standard",
44
44
  FILES = "files"
@@ -1,7 +1,7 @@
1
1
  import { AnyPrimitive, Override } from '@leav/utils';
2
2
  import { IDbEdge } from 'infra/db/_types';
3
3
  import { IRecord } from './record';
4
- import { ITreeNode, TreePaths } from './tree';
4
+ import { ITreeNode, TreePath } from './tree';
5
5
  import { EMPTY_VALUE } from 'infra/value/valueRepo';
6
6
  import { AttributeTypes } from './attribute';
7
7
  export type IValueFromGql = Override<Omit<IValue, 'version'>, {
@@ -111,7 +111,7 @@ export interface IValuesOptions {
111
111
  export interface IFindValueTree {
112
112
  name: string;
113
113
  currentIndex: number;
114
- elements: TreePaths;
114
+ elements: TreePath;
115
115
  }
116
116
  export interface IValueEdge extends IDbEdge {
117
117
  attribute: string;
@@ -29,7 +29,7 @@ export interface IView extends ICoreEntity {
29
29
  filters?: IRecordFilterLight[];
30
30
  sort?: IRecordSortLight[];
31
31
  valuesVersions?: IViewValuesVersion;
32
- attributes?: string[];
32
+ attributes: string[];
33
33
  }
34
34
  export interface IViewValuesVersionForGraphql {
35
35
  treeId: string;
@@ -5,6 +5,10 @@ import { IAppGraphQLSchema } from '_types/graphql';
5
5
  import { IAppModule } from '_types/shared';
6
6
  import { IQueryField } from '../../_types/record';
7
7
  export interface IGraphqlApp extends IAppModule {
8
+ /**
9
+ * Parse all registered GraphQL schemas and return a single schema
10
+ * Very costly operation, should be called only once at application startup
11
+ */
8
12
  getSchema(): Promise<GraphQLSchema>;
9
13
  getQueryFields(info: GraphQLResolveInfo): IQueryField[];
10
14
  }
@@ -1,12 +1,13 @@
1
1
  import { IAmqpService } from '@leav/message-broker';
2
- import { IDbPayload, IPubSubPayload } from '@leav/utils';
2
+ import { EventAction, IPubSubPayload } from '@leav/utils';
3
3
  import * as amqp from 'amqplib';
4
4
  import { IUtils } from 'utils/utils';
5
5
  import winston from 'winston';
6
6
  import * as Config from '_types/config';
7
7
  import { IQueryInfos } from '_types/queryInfos';
8
+ import { IDbPayloadInternal } from '_types/events';
8
9
  export interface IEventsManagerDomain {
9
- sendDatabaseEvent(payload: IDbPayload, ctx: IQueryInfos): Promise<boolean>;
10
+ sendDatabaseEvent<DBPayloadAction extends EventAction>(payload: IDbPayloadInternal<DBPayloadAction>, ctx: IQueryInfos): Promise<boolean>;
10
11
  sendPubSubEvent(payload: IPubSubPayload, ctx: IQueryInfos): Promise<boolean>;
11
12
  subscribe(triggersName: string[]): AsyncIterator<any>;
12
13
  initPubSubEventsConsumer(): Promise<void>;
@@ -6,15 +6,19 @@ import { IRecordDomain } from 'domain/record/recordDomain';
6
6
  import { ITasksManagerDomain } from 'domain/tasksManager/tasksManagerDomain';
7
7
  import { ITreeDomain } from 'domain/tree/treeDomain';
8
8
  import { IValueDomain } from 'domain/value/valueDomain';
9
+ import { IPermissionDomain } from 'domain/permission/permissionDomain';
10
+ import { AwilixContainer } from 'awilix';
9
11
  import { i18n } from 'i18next';
10
12
  import { IUtils } from 'utils/utils';
11
13
  import * as Config from '_types/config';
12
14
  import { ICachesService } from '../../infra/cache/cacheService';
15
+ import { IDbUtils } from '../../infra/db/dbUtils';
13
16
  import { ImportMode, ImportType } from '../../_types/import';
14
17
  import { IQueryInfos } from '../../_types/queryInfos';
15
18
  import { ITaskFuncParams } from '../../_types/tasksManager';
16
19
  import { IValidateHelper } from '../helpers/validate';
17
20
  import { IVersionProfileDomain } from '../versionProfile/versionProfileDomain';
21
+ import winston from 'winston';
18
22
  export declare const IMPORT_DATA_SCHEMA_PATH: string;
19
23
  export declare const IMPORT_CONFIG_SCHEMA_PATH: string;
20
24
  export interface IImportExcelParams {
@@ -40,6 +44,8 @@ interface IImportConfigParams {
40
44
  filepath: string;
41
45
  ctx: IQueryInfos;
42
46
  forceNoTask?: boolean;
47
+ clearDatabase?: boolean;
48
+ dbMigrate?: boolean;
43
49
  }
44
50
  export interface IImportDomain {
45
51
  importConfig(params: IImportConfigParams, task?: ITaskFuncParams): Promise<string | undefined>;
@@ -61,12 +67,16 @@ export interface IImportDomainDeps {
61
67
  'core.domain.tree': ITreeDomain;
62
68
  'core.domain.versionProfile': IVersionProfileDomain;
63
69
  'core.domain.tasksManager': ITasksManagerDomain;
70
+ 'core.domain.permission': IPermissionDomain;
64
71
  'core.domain.helpers.updateTaskProgress': UpdateTaskProgress;
65
72
  'core.domain.eventsManager': IEventsManagerDomain;
66
73
  'core.infra.cache.cacheService': ICachesService;
74
+ 'core.infra.db.dbUtils': IDbUtils;
75
+ 'core.depsManager': AwilixContainer;
67
76
  config: Config.IConfig;
68
77
  translator: i18n;
69
78
  'core.utils': IUtils;
79
+ 'core.utils.logger'?: winston.Winston;
70
80
  }
71
- export default function ({ 'core.domain.library': libraryDomain, 'core.domain.record': recordDomain, 'core.domain.helpers.validate': validateHelper, 'core.domain.attribute': attributeDomain, 'core.domain.value': valueDomain, 'core.domain.tree': treeDomain, 'core.domain.versionProfile': versionProfileDomain, 'core.domain.tasksManager': tasksManagerDomain, 'core.domain.helpers.updateTaskProgress': updateTaskProgress, 'core.domain.eventsManager': eventsManagerDomain, 'core.infra.cache.cacheService': cacheService, 'core.utils': utils, config, translator }: IImportDomainDeps): IImportDomain;
81
+ export default function ({ 'core.domain.library': libraryDomain, 'core.domain.record': recordDomain, 'core.domain.helpers.validate': validateHelper, 'core.domain.attribute': attributeDomain, 'core.domain.value': valueDomain, 'core.domain.tree': treeDomain, 'core.domain.versionProfile': versionProfileDomain, 'core.domain.tasksManager': tasksManagerDomain, 'core.domain.permission': permissionDomain, 'core.domain.helpers.updateTaskProgress': updateTaskProgress, 'core.domain.eventsManager': eventsManagerDomain, 'core.infra.cache.cacheService': cacheService, 'core.infra.db.dbUtils': dbUtils, 'core.depsManager': depsManager, 'core.utils': utils, 'core.utils.logger': logger, config, translator }: IImportDomainDeps): IImportDomain;
72
82
  export {};
@@ -11,6 +11,7 @@ import * as Config from '_types/config';
11
11
  import { IQueryInfos } from '_types/queryInfos';
12
12
  import { IIndexationService } from '../../infra/indexation/indexationService';
13
13
  import { ITaskFuncParams } from '../../_types/tasksManager';
14
+ import { GetSystemQueryContext } from '../../utils/helpers/getSystemQueryContext';
14
15
  interface IIndexDatabaseParams {
15
16
  findRecordParams: IFindRecordParams | IFindRecordParams[];
16
17
  attributes?: {
@@ -34,7 +35,8 @@ export interface IIndexationManagerDomainDeps {
34
35
  'core.domain.tasksManager': ITasksManagerDomain;
35
36
  'core.domain.eventsManager': IEventsManagerDomain;
36
37
  'core.utils.logger': winston.Winston;
38
+ 'core.utils.getSystemQueryContext': GetSystemQueryContext;
37
39
  translator: i18n;
38
40
  }
39
- export default function ({ config, 'core.infra.amqpService': amqpService, 'core.domain.record': recordDomain, 'core.domain.library': libraryDomain, 'core.domain.attribute': attributeDomain, 'core.domain.tasksManager': tasksManagerDomain, 'core.infra.indexation.indexationService': indexationService, 'core.domain.eventsManager': eventsManager, 'core.utils.logger': logger, translator }: IIndexationManagerDomainDeps): IIndexationManagerDomain;
41
+ export default function ({ config, 'core.infra.amqpService': amqpService, 'core.domain.record': recordDomain, 'core.domain.library': libraryDomain, 'core.domain.attribute': attributeDomain, 'core.domain.tasksManager': tasksManagerDomain, 'core.infra.indexation.indexationService': indexationService, 'core.domain.eventsManager': eventsManager, 'core.utils.logger': logger, 'core.utils.getSystemQueryContext': getSystemQueryContext, translator }: IIndexationManagerDomainDeps): IIndexationManagerDomain;
40
42
  export {};
@@ -2,6 +2,7 @@ import { Log } from '@leav/utils';
2
2
  import { ILogRepo } from 'infra/log/logRepo';
3
3
  import { ILogFilters, ILogPagination, ILogSort } from '_types/log';
4
4
  import { IQueryInfos } from '_types/queryInfos';
5
+ import { IPermissionDomain } from 'domain/permission/permissionDomain';
5
6
  export interface ILogDomain {
6
7
  getLogs: (params: {
7
8
  filters?: ILogFilters;
@@ -11,6 +12,7 @@ export interface ILogDomain {
11
12
  }
12
13
  interface IDeps {
13
14
  'core.infra.log': ILogRepo;
15
+ 'core.domain.permission': IPermissionDomain;
14
16
  }
15
- export default function ({ 'core.infra.log': logRepo }: IDeps): ILogDomain;
17
+ export default function ({ 'core.infra.log': logRepo, 'core.domain.permission': permissionDomain }: IDeps): ILogDomain;
16
18
  export {};
@@ -1,6 +1,6 @@
1
1
  import { AdminPermissionsActions, ApplicationPermissionsActions, AttributePermissionsActions, IPermissionsTreeTarget, ITreePermissionsConf, LibraryPermissionsActions, PermissionsActions, PermissionTypes, RecordAttributePermissionsActions, RecordPermissionsActions, TreeNodePermissionsActions, TreePermissionsActions } from '_types/permissions';
2
2
  import { IQueryInfos } from '_types/queryInfos';
3
- import { TreePaths } from '_types/tree';
3
+ import { TreePath } from '_types/tree';
4
4
  export declare const PERMISSIONS_CACHE_HEADER = "permissions";
5
5
  export declare const PERMISSIONS_NULL_PLACEHOLDER = "__null__";
6
6
  export interface IPermissionTarget {
@@ -163,7 +163,7 @@ export interface IGetDefaultPermissionParams {
163
163
  action?: any;
164
164
  applyTo?: string;
165
165
  userId?: string;
166
- userGroups?: TreePaths[];
166
+ userGroups?: TreePath[];
167
167
  }
168
168
  export interface IGetTreeBasedPermissionParams {
169
169
  type: PermissionTypes;
@@ -1,16 +1,11 @@
1
- import { IAttributeRepo } from 'infra/attribute/attributeRepo';
2
- import { IPermissionRepo } from 'infra/permission/permissionRepo';
3
- import { ITreeRepo } from 'infra/tree/treeRepo';
4
- import { IValueRepo } from 'infra/value/valueRepo';
5
1
  import { IQueryInfos } from '_types/queryInfos';
6
- import { ICachesService } from '../../../infra/cache/cacheService';
7
2
  import { PermissionsActions, PermissionTypes } from '../../../_types/permissions';
8
3
  import { IDefaultPermissionHelper } from './defaultPermission';
9
4
  import { IPermissionByUserGroupsHelper } from './permissionByUserGroups';
5
+ import { IElementAncestorsHelper } from 'domain/tree/helpers/elementAncestors';
10
6
  interface IGetGlobalPermissionParams {
11
7
  type: PermissionTypes;
12
8
  applyTo?: string;
13
- userId: string;
14
9
  action: PermissionsActions;
15
10
  getDefaultPermission?: (params?: IGetDefaultGlobalPermissionParams) => Promise<boolean> | boolean;
16
11
  }
@@ -35,11 +30,7 @@ export interface IGlobalPermissionHelper {
35
30
  export interface IGlobalPermissionDeps {
36
31
  'core.domain.permission.helpers.permissionByUserGroups': IPermissionByUserGroupsHelper;
37
32
  'core.domain.permission.helpers.defaultPermission': IDefaultPermissionHelper;
38
- 'core.infra.permission': IPermissionRepo;
39
- 'core.infra.attribute': IAttributeRepo;
40
- 'core.infra.tree': ITreeRepo;
41
- 'core.infra.value': IValueRepo;
42
- 'core.infra.cache.cacheService': ICachesService;
33
+ 'core.domain.tree.helpers.elementAncestors': IElementAncestorsHelper;
43
34
  }
44
- export default function ({ 'core.domain.permission.helpers.permissionByUserGroups': permByUserGroupsHelper, 'core.domain.permission.helpers.defaultPermission': defaultPermHelper, 'core.infra.attribute': attributeRepo, 'core.infra.value': valueRepo, 'core.infra.tree': treeRepo, 'core.infra.cache.cacheService': cacheService }: IGlobalPermissionDeps): IGlobalPermissionHelper;
35
+ export default function ({ 'core.domain.permission.helpers.permissionByUserGroups': permByUserGroupsHelper, 'core.domain.permission.helpers.defaultPermission': defaultPermHelper, 'core.domain.tree.helpers.elementAncestors': elementAncestorsHelper }: IGlobalPermissionDeps): IGlobalPermissionHelper;
45
36
  export {};
@@ -1,26 +1,26 @@
1
- import { IPermissionRepo } from 'infra/permission/permissionRepo';
2
1
  import { IReducePermissionsArrayHelper } from './reducePermissionsArray';
3
2
  import { ISimplePermissionHelper } from './simplePermission';
4
3
  import { IDefaultPermissionHelper } from './defaultPermission';
5
- import { IElementAncestorsHelper } from 'domain/tree/helpers/elementAncestors';
6
- import { ITreeNode, TreePaths } from '../../../_types/tree';
4
+ import { TreePath } from '../../../_types/tree';
7
5
  import { PermissionsActions, PermissionTypes } from '../../../_types/permissions';
8
6
  import { IQueryInfos } from '../../../_types/queryInfos';
7
+ import { ICachesService } from '../../../infra/cache/cacheService';
8
+ import { IConfig } from '_types/config';
9
9
  export interface IPermissionByUserGroupsHelperDeps {
10
10
  'core.domain.permission.helpers.simplePermission': ISimplePermissionHelper;
11
11
  'core.domain.permission.helpers.reducePermissionsArray': IReducePermissionsArrayHelper;
12
12
  'core.domain.permission.helpers.defaultPermission': IDefaultPermissionHelper;
13
- 'core.domain.tree.helpers.elementAncestors': IElementAncestorsHelper;
14
- 'core.infra.permission'?: IPermissionRepo;
13
+ 'core.infra.cache.cacheService': ICachesService;
14
+ config: IConfig;
15
15
  }
16
16
  interface IGetPermissionByUserGroupsParams {
17
17
  type: PermissionTypes;
18
18
  action: PermissionsActions;
19
- userGroupsPaths: TreePaths[];
19
+ userGroupsPaths: TreePath[];
20
20
  applyTo?: string;
21
21
  treeTarget?: {
22
22
  tree: string;
23
- path: ITreeNode[];
23
+ path: TreePath;
24
24
  };
25
25
  getDefaultPermission?: () => Promise<boolean> | boolean;
26
26
  ctx: IQueryInfos;
@@ -2,19 +2,15 @@ import { IAttributeDomain } from 'domain/attribute/attributeDomain';
2
2
  import { IElementAncestorsHelper } from 'domain/tree/helpers/elementAncestors';
3
3
  import { IPermissionRepo } from 'infra/permission/permissionRepo';
4
4
  import { IQueryInfos } from '_types/queryInfos';
5
- import { ICachesService } from '../../../infra/cache/cacheService';
6
5
  import { IGetInheritedTreeBasedPermissionParams, IGetTreeBasedPermissionParams } from '../_types';
7
- import { IDefaultPermissionHelper } from './defaultPermission';
8
6
  import { IPermissionByUserGroupsHelper } from './permissionByUserGroups';
9
7
  import { IReducePermissionsArrayHelper } from './reducePermissionsArray';
10
8
  export interface ITreeBasedPermissionsDeps {
11
9
  'core.domain.attribute': IAttributeDomain;
12
10
  'core.domain.permission.helpers.permissionByUserGroups': IPermissionByUserGroupsHelper;
13
- 'core.domain.permission.helpers.defaultPermission': IDefaultPermissionHelper;
14
11
  'core.domain.permission.helpers.reducePermissionsArray': IReducePermissionsArrayHelper;
15
12
  'core.domain.tree.helpers.elementAncestors': IElementAncestorsHelper;
16
13
  'core.infra.permission': IPermissionRepo;
17
- 'core.infra.cache.cacheService': ICachesService;
18
14
  }
19
15
  export interface ITreeBasedPermissionHelper {
20
16
  getTreeBasedPermission(params: IGetTreeBasedPermissionParams, ctx: IQueryInfos): Promise<boolean>;
@@ -25,6 +25,7 @@ export interface IPermissionDomain {
25
25
  isAllowed({ type, action, userId, applyTo, target, ctx }: IIsAllowedParams): Promise<boolean>;
26
26
  getActionsByType(params: IGetActionsByTypeParams): ILabeledPermissionsAction[];
27
27
  registerActions(type: PermissionTypes, actions: string[], applyOn?: string[]): void;
28
+ isAdminOrSystemUser(ctx: IQueryInfos): boolean;
28
29
  }
29
30
  export interface IPermissionDomainDeps {
30
31
  'core.domain.permission.admin': IAdminPermissionDomain;
@@ -2,12 +2,12 @@ import { GetCoreEntityByIdFunc } from 'domain/helpers/getCoreEntityById';
2
2
  import { ITreeRepo } from 'infra/tree/treeRepo';
3
3
  import { IValueRepo } from 'infra/value/valueRepo';
4
4
  import { IAttributeDomain } from '../attribute/attributeDomain';
5
- import { IDefaultPermissionHelper } from './helpers/defaultPermission';
6
5
  import { IPermissionByUserGroupsHelper } from './helpers/permissionByUserGroups';
7
6
  import { ITreeBasedPermissionHelper } from './helpers/treeBasedPermissions';
8
7
  import { ITreeLibraryPermissionDomain } from './treeLibraryPermissionDomain';
9
8
  import { ITreePermissionDomain } from './treePermissionDomain';
10
9
  import { IGetInheritedTreeNodePermissionParams, IGetTreeNodePermissionParams } from './_types';
10
+ import { IElementAncestorsHelper } from 'domain/tree/helpers/elementAncestors';
11
11
  export interface ITreeNodePermissionDomain {
12
12
  getTreeNodePermission(params: IGetTreeNodePermissionParams): Promise<boolean>;
13
13
  getInheritedTreeNodePermission(params: IGetInheritedTreeNodePermissionParams): Promise<boolean>;
@@ -17,7 +17,7 @@ export interface ITreeNodePermissionDomainDeps {
17
17
  'core.domain.permission.treeLibrary': ITreeLibraryPermissionDomain;
18
18
  'core.domain.permission.helpers.treeBasedPermissions': ITreeBasedPermissionHelper;
19
19
  'core.domain.permission.helpers.permissionByUserGroups': IPermissionByUserGroupsHelper;
20
- 'core.domain.permission.helpers.defaultPermission': IDefaultPermissionHelper;
20
+ 'core.domain.tree.helpers.elementAncestors': IElementAncestorsHelper;
21
21
  'core.domain.helpers.getCoreEntityById': GetCoreEntityByIdFunc;
22
22
  'core.infra.tree': ITreeRepo;
23
23
  'core.domain.attribute': IAttributeDomain;
@@ -11,6 +11,7 @@ export type CreateRecordHelper = (params: {
11
11
  */
12
12
  preCreateCallback?: IPreCreateRecordCallback;
13
13
  ctx: IQueryInfos;
14
+ active?: boolean;
14
15
  }) => Promise<ICreateRecordResult>;
15
16
  interface IDeps {
16
17
  'core.domain.eventsManager': IEventsManagerDomain;
@@ -27,7 +27,22 @@ import { IDefaultPermissionHelper } from 'domain/permission/helpers/defaultPermi
27
27
  import { DeleteRecordHelper } from './helpers/deleteRecord';
28
28
  import { CreateRecordHelper } from './helpers/createRecord';
29
29
  import { IElementAncestorsHelper } from 'domain/tree/helpers/elementAncestors';
30
+ import winston from 'winston';
30
31
  export interface IRecordDomain {
32
+ /**
33
+ * Create empty record
34
+ * Used when create a record, set active to false and inCreation to true
35
+ */
36
+ createEmptyRecord(params: {
37
+ library: string;
38
+ ctx: IQueryInfos;
39
+ }): Promise<ICreateRecordResult>;
40
+ activateNewRecord(params: {
41
+ library: string;
42
+ recordId: string;
43
+ formId?: string;
44
+ ctx: IQueryInfos;
45
+ }): Promise<ICreateRecordResult>;
31
46
  createRecord(params: {
32
47
  library: string;
33
48
  values?: ISaveValue[];
@@ -95,6 +110,11 @@ export interface IRecordDomain {
95
110
  libraryId: string;
96
111
  ctx: IQueryInfos;
97
112
  }): Promise<IRecord[]>;
113
+ purgeRecord(params: {
114
+ libraryId: string;
115
+ recordId: string;
116
+ ctx: IQueryInfos;
117
+ }): Promise<IRecord>;
98
118
  }
99
119
  export interface IRecordDomainDeps {
100
120
  config: Config.IConfig;
@@ -119,7 +139,8 @@ export interface IRecordDomainDeps {
119
139
  'core.infra.permission': IPermissionRepo;
120
140
  'core.domain.eventsManager': IEventsManagerDomain;
121
141
  'core.infra.cache.cacheService': ICachesService;
142
+ 'core.utils.logger': winston.Winston;
122
143
  'core.utils': IUtils;
123
144
  translator: i18n;
124
145
  }
125
- export default function ({ config, 'core.infra.record': recordRepo, 'core.domain.attribute': attributeDomain, 'core.domain.value': valueDomain, 'core.domain.permission.record': recordPermissionDomain, 'core.domain.permission.library': libraryPermissionDomain, 'core.domain.permission.attribute': attrPermissionDomain, 'core.domain.permission.recordAttribute': recordAttributePermissionDomain, 'core.domain.permission.helpers.defaultPermission': defaultPermHelper, 'core.domain.helpers.getCoreEntityById': getCoreEntityById, 'core.domain.helpers.validate': validateHelper, 'core.domain.record.helpers.createRecord': createRecordHelper, 'core.domain.record.helpers.deleteRecord': deleteRecordHelper, 'core.domain.record.helpers.sendRecordUpdateEvent': sendRecordUpdateEvent, 'core.infra.library': libraryRepo, 'core.infra.tree': treeRepo, 'core.domain.tree.helpers.elementAncestors': elementAncestorsHelper, 'core.infra.value': valueRepo, 'core.infra.form': formRepo, 'core.infra.permission': permissionRepo, 'core.domain.eventsManager': eventsManager, 'core.infra.cache.cacheService': cacheService, 'core.utils': utils, translator }: IRecordDomainDeps): IRecordDomain;
146
+ export default function ({ config, 'core.infra.record': recordRepo, 'core.domain.attribute': attributeDomain, 'core.domain.value': valueDomain, 'core.domain.permission.record': recordPermissionDomain, 'core.domain.permission.library': libraryPermissionDomain, 'core.domain.permission.attribute': attrPermissionDomain, 'core.domain.permission.recordAttribute': recordAttributePermissionDomain, 'core.domain.permission.helpers.defaultPermission': defaultPermHelper, 'core.domain.helpers.getCoreEntityById': getCoreEntityById, 'core.domain.helpers.validate': validateHelper, 'core.domain.record.helpers.createRecord': createRecordHelper, 'core.domain.record.helpers.deleteRecord': deleteRecordHelper, 'core.domain.record.helpers.sendRecordUpdateEvent': sendRecordUpdateEvent, 'core.infra.library': libraryRepo, 'core.infra.tree': treeRepo, 'core.domain.tree.helpers.elementAncestors': elementAncestorsHelper, 'core.infra.value': valueRepo, 'core.infra.form': formRepo, 'core.infra.permission': permissionRepo, 'core.domain.eventsManager': eventsManager, 'core.infra.cache.cacheService': cacheService, 'core.utils.logger': logger, 'core.utils': utils, translator }: IRecordDomainDeps): IRecordDomain;
@@ -11,7 +11,7 @@ import { IQueryInfos } from '_types/queryInfos';
11
11
  import { ICachesService } from '../../infra/cache/cacheService';
12
12
  import { IList, IPaginationParams } from '../../_types/list';
13
13
  import { IRecord } from '../../_types/record';
14
- import { IGetCoreTreesParams, ITree, ITreeElement, ITreeNode, ITreeNodeLight, TreePaths } from '../../_types/tree';
14
+ import { IGetCoreTreesParams, ITree, ITreeElement, ITreeNode, ITreeNodeLight, TreePath } from '../../_types/tree';
15
15
  import { IAttributeDomain } from '../attribute/attributeDomain';
16
16
  import { IRecordDomain } from '../record/recordDomain';
17
17
  import { IElementAncestorsHelper } from './helpers/elementAncestors';
@@ -112,7 +112,7 @@ export interface ITreeDomain {
112
112
  treeId: string;
113
113
  nodeId: string;
114
114
  ctx: IQueryInfos;
115
- }): Promise<TreePaths>;
115
+ }): Promise<TreePath>;
116
116
  /**
117
117
  * Retrieve all records linked to an element via given attribute
118
118
  */
@@ -19,6 +19,7 @@ export interface IAttributeWithRevLink extends IAttribute {
19
19
  reverse_link?: IAttribute;
20
20
  }
21
21
  export type GetConditionPartParentFunc = (condition: AttributeCondition, value: string | number | boolean, attribute: IAttribute) => GetConditionPartFunc;
22
+ export type IGetValuesOptions = Pick<IValuesOptions, 'forceGetAllValues' | 'version'>;
22
23
  export type GetConditionPartFunc = (valueIdentifier: string | AqlLiteral) => GeneratedAqlQuery;
23
24
  /**
24
25
  * Define interface used for all attribute type specific files
@@ -71,9 +72,21 @@ export interface IAttributeTypeRepo<AttributeType extends AttributeTypes = Attri
71
72
  recordId: string;
72
73
  attribute: IAttributeWithRevLink;
73
74
  forceGetAllValues?: boolean;
74
- options?: IValuesOptions;
75
+ options?: IGetValuesOptions;
75
76
  ctx: IQueryInfos;
76
77
  }): Promise<Value[]>;
78
+ /**
79
+ * Get all values for given records and attribute
80
+ *
81
+ * @return Array<{}> Return an empty array if no value found for each record
82
+ */
83
+ getValuesBatch({ library, attribute, recordIds, options, ctx }: {
84
+ library: string;
85
+ attribute: IAttributeWithRevLink;
86
+ recordIds: string[];
87
+ options?: IGetValuesOptions;
88
+ ctx: IQueryInfos;
89
+ }): Promise<Value[][]>;
77
90
  /**
78
91
  * Get all reverse values for given attribute / value
79
92
  *
@@ -85,6 +98,17 @@ export interface IAttributeTypeRepo<AttributeType extends AttributeTypes = Attri
85
98
  forceGetAllValues: boolean;
86
99
  ctx: IQueryInfos;
87
100
  }): Promise<Value[]>;
101
+ /**
102
+ * Get all reverse values for given attribute / values
103
+ *
104
+ * @return Array<{}> Return an empty array if no value found for each record
105
+ */
106
+ getReverseValuesBatch?({ advancedLinkAttr, ctx }: {
107
+ advancedLinkAttr: IAttributeWithRevLink;
108
+ values: string[];
109
+ forceGetAllValues: boolean;
110
+ ctx: IQueryInfos;
111
+ }): Promise<Value[][]>;
88
112
  /**
89
113
  * Return a specific value based on its ID. Field "id" is expect on the value
90
114
  *
@@ -47,6 +47,15 @@ export interface IRecordRepo {
47
47
  ctx: IQueryInfos;
48
48
  accessPermissionFilters?: IGetAccessPermissionsValue[];
49
49
  }): Promise<IListWithCursor<IRecord>>;
50
+ /**
51
+ * get record by recordId, return null if record not found
52
+ * NB: use internal dataloader to mutualize query when possible for a given ctx
53
+ */
54
+ getRecord(params: {
55
+ libraryId: string;
56
+ recordId: string;
57
+ ctx: IQueryInfos;
58
+ }): Promise<IRecord | null>;
50
59
  }
51
60
  export interface IRecordRepoDeps {
52
61
  'core.infra.db.dbService': IDbService;
@@ -1,7 +1,7 @@
1
1
  import { IList, IPaginationParams } from '_types/list';
2
2
  import { IQueryInfos } from '_types/queryInfos';
3
3
  import { IRecord } from '_types/record';
4
- import { IGetCoreTreesParams, ITree, ITreeElement, ITreeNode, ITreeNodeLight, TreePaths } from '_types/tree';
4
+ import { IGetCoreTreesParams, ITree, ITreeElement, ITreeNode, ITreeNodeLight, TreePath } from '_types/tree';
5
5
  import { IDbService } from '../db/dbService';
6
6
  import { IDbUtils } from '../db/dbUtils';
7
7
  export interface ITreeRepo {
@@ -116,6 +116,7 @@ export interface ITreeRepo {
116
116
  }): Promise<IList<ITreeNode>>;
117
117
  /**
118
118
  * Return all ancestors of an element, from root to element, but excluding tree root
119
+ * Prefer use core.domain.tree.helpers.elementAncestors.getCachedElementAncestors
119
120
  *
120
121
  * @param treeId
121
122
  * @param element
@@ -124,7 +125,7 @@ export interface ITreeRepo {
124
125
  treeId: string;
125
126
  nodeId: string;
126
127
  ctx: IQueryInfos;
127
- }): Promise<TreePaths>;
128
+ }): Promise<TreePath>;
128
129
  getLinkedRecords(params: {
129
130
  treeId: string;
130
131
  attribute: string;
@@ -1,8 +1,9 @@
1
1
  import { IDbService } from 'infra/db/dbService';
2
+ import { IConfig } from '_types/config';
2
3
  import { IAttribute } from '_types/attribute';
3
4
  import { IQueryInfos } from '_types/queryInfos';
4
- import { ISaveValue, IValue, IValuesOptions } from '_types/value';
5
- import { IAttributeTypesRepo, IAttributeWithRevLink } from '../attributeTypes/attributeTypesRepo';
5
+ import { ISaveValue, IValue } from '_types/value';
6
+ import { IAttributeTypesRepo, IAttributeWithRevLink, IGetValuesOptions } from '../attributeTypes/attributeTypesRepo';
6
7
  export declare const VALUES_LINKS_COLLECTION = "core_edge_values_links";
7
8
  export declare const VALUES_COLLECTION = "core_values";
8
9
  export declare const EMPTY_VALUE = "__empty_value__";
@@ -55,7 +56,7 @@ export interface IValueRepo {
55
56
  recordId: string;
56
57
  attribute: IAttributeWithRevLink;
57
58
  forceGetAllValues?: boolean;
58
- options?: IValuesOptions;
59
+ options?: IGetValuesOptions;
59
60
  ctx: IQueryInfos;
60
61
  }): Promise<IValue[]>;
61
62
  /**
@@ -81,8 +82,9 @@ export interface IValueRepo {
81
82
  }): Promise<void>;
82
83
  }
83
84
  interface IDeps {
84
- 'core.infra.attributeTypes'?: IAttributeTypesRepo;
85
- 'core.infra.db.dbService'?: IDbService;
85
+ config?: IConfig;
86
+ 'core.infra.attributeTypes': IAttributeTypesRepo;
87
+ 'core.infra.db.dbService': IDbService;
86
88
  }
87
- export default function ({ 'core.infra.attributeTypes': attributeTypesRepo, 'core.infra.db.dbService': dbService }?: IDeps): IValueRepo;
89
+ export default function ({ config, 'core.infra.attributeTypes': attributeTypesRepo, 'core.infra.db.dbService': dbService }: IDeps): IValueRepo;
88
90
  export {};
@@ -0,0 +1,9 @@
1
+ import DataLoader from 'dataloader';
2
+ import { IQueryInfos } from '_types/queryInfos';
3
+ export declare const dataloaderCtxKey: keyof IQueryInfos;
4
+ /**
5
+ * Get or create a DataLoader in the request context.
6
+ * Each usage (not each call) of this function should use a unique name to avoid conflicts among different DataLoaders.
7
+ * Name is used has key to store the DataLoader in ctx.dataLoaders.
8
+ */
9
+ export declare function getOrCreateDataLoaderInCtx<DL extends DataLoader<unknown, unknown>>(ctx: IQueryInfos, name: string, create: () => DL): DL;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { IConfig } from '_types/config';
2
+ import { IQueryInfos } from '_types/queryInfos';
3
+ interface IDeps {
4
+ config?: IConfig;
5
+ }
6
+ export type GetSystemQueryContext = () => IQueryInfos;
7
+ export default function ({ config }: IDeps): GetSystemQueryContext;
8
+ export {};
@@ -1,3 +1,4 @@
1
1
  export { default as logger } from './logger/logger';
2
2
  export { default } from './utils';
3
+ export { default as getSystemQueryContext } from './helpers/getSystemQueryContext';
3
4
  export { TypeGuards } from './typeGuards';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aristid/leav-types",
3
- "version": "0.0.7-9f9d1cc7",
3
+ "version": "0.0.7-a04a265e",
4
4
  "description": "Shared Leav types",
5
5
  "scripts": {
6
6
  "tscheck": "",