@aristid/leav-types 0.0.7-81dd3cf8 → 0.0.7-83000546

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 (47) hide show
  1. package/apps/core/config/default.d.ts +11 -0
  2. package/apps/core/src/__tests__/e2e/api/getConditionPart/getConditionPart.test.d.ts +1 -0
  3. package/apps/core/src/__tests__/e2e/api/globalSetup.d.ts +6 -1
  4. package/apps/core/src/__tests__/integration/globalSetup.d.ts +1 -0
  5. package/apps/core/src/__tests__/integration/globalSetupHook.d.ts +1 -0
  6. package/apps/core/src/__tests__/integration/infra/attributeAdvancedLinkRepo.test.d.ts +1 -0
  7. package/apps/core/src/__tests__/integration/infra/attributeAdvancedRepo.test.d.ts +1 -0
  8. package/apps/core/src/__tests__/integration/infra/attributeSimpleLinkRepo.test.d.ts +1 -0
  9. package/apps/core/src/__tests__/integration/infra/attributeSimpleRepo.test.d.ts +1 -0
  10. package/apps/core/src/__tests__/integration/infra/attributeTreeRepo.test.d.ts +1 -0
  11. package/apps/core/src/__tests__/integration/infra/integrationTestRepoUtils.d.ts +7 -0
  12. package/apps/core/src/__tests__/integration/infra/recordRepo.test.d.ts +1 -0
  13. package/apps/core/src/__tests__/integration/teardown.d.ts +1 -0
  14. package/apps/core/src/__tests__/mockers/amqp.d.ts +1 -1
  15. package/apps/core/src/__tests__/mockers/logger.d.ts +4 -4
  16. package/apps/core/src/_types/config.d.ts +27 -0
  17. package/apps/core/src/_types/dbProfiler.d.ts +20 -1
  18. package/apps/core/src/_types/forms.d.ts +7 -7
  19. package/apps/core/src/_types/permissions.d.ts +2 -1
  20. package/apps/core/src/_types/queryInfos.d.ts +5 -0
  21. package/apps/core/src/_types/record.d.ts +4 -4
  22. package/apps/core/src/_types/tree.d.ts +1 -1
  23. package/apps/core/src/_types/value.d.ts +2 -2
  24. package/apps/core/src/app/core/formApp/_types.d.ts +10 -0
  25. package/apps/core/src/app/core/formApp/formApp.d.ts +0 -2
  26. package/apps/core/src/app/core/treeApp/treeApp.d.ts +3 -1
  27. package/apps/core/src/app/graphql/graphqlApp.d.ts +4 -0
  28. package/apps/core/src/domain/form/formDomain.d.ts +9 -1
  29. package/apps/core/src/domain/indexationManager/indexationManagerDomain.d.ts +3 -1
  30. package/apps/core/src/domain/permission/_types.d.ts +10 -2
  31. package/apps/core/src/domain/permission/helpers/globalPermission.d.ts +3 -12
  32. package/apps/core/src/domain/permission/helpers/permissionByUserGroups.d.ts +7 -7
  33. package/apps/core/src/domain/permission/helpers/treeBasedPermissions.d.ts +0 -4
  34. package/apps/core/src/domain/permission/recordPermissionDomain.d.ts +4 -1
  35. package/apps/core/src/domain/permission/treeNodePermissionDomain.d.ts +2 -2
  36. package/apps/core/src/domain/record/helpers/createRecord.d.ts +1 -0
  37. package/apps/core/src/domain/record/recordDomain.d.ts +8 -0
  38. package/apps/core/src/domain/tree/treeDomain.d.ts +2 -2
  39. package/apps/core/src/infra/attributeTypes/attributeTypesRepo.d.ts +25 -1
  40. package/apps/core/src/infra/record/recordRepo.d.ts +9 -0
  41. package/apps/core/src/infra/tree/treeRepo.d.ts +3 -2
  42. package/apps/core/src/infra/value/valueRepo.d.ts +8 -6
  43. package/apps/core/src/utils/dataloader.d.ts +8 -0
  44. package/apps/core/src/utils/helpers/getSystemQueryContext.d.ts +8 -0
  45. package/apps/core/src/utils/index.d.ts +1 -0
  46. package/libs/utils/src/types/forms.d.ts +2 -1
  47. package/package.json +2 -2
@@ -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 {
@@ -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>;
@@ -1,7 +1,7 @@
1
1
  declare const _default: {
2
2
  consumer: {
3
3
  channel: {
4
- ack: jest.Mock<any, any, any>;
4
+ ack: jest.Mock<any, any>;
5
5
  };
6
6
  };
7
7
  };
@@ -1,7 +1,7 @@
1
1
  declare const _default: {
2
- info: jest.Mock<any, any, any>;
3
- warn: jest.Mock<any, any, any>;
4
- error: jest.Mock<any, any, any>;
5
- debug: jest.Mock<any, any, any>;
2
+ info: jest.Mock<any, any>;
3
+ warn: jest.Mock<any, any>;
4
+ error: jest.Mock<any, any>;
5
+ debug: jest.Mock<any, any>;
6
6
  };
7
7
  export default _default;
@@ -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;
@@ -84,6 +85,7 @@ export interface IAuth {
84
85
  postLogoutRedirectUri: string;
85
86
  skipLogoutConfirmationPage?: boolean;
86
87
  idTokenUserClaim: string;
88
+ enableAutoProvisioning: boolean;
87
89
  };
88
90
  testApiKey?: string;
89
91
  }
@@ -107,6 +109,7 @@ export interface ILogs {
107
109
  }
108
110
  export interface IPermissions {
109
111
  default: boolean;
112
+ enableCache: boolean;
110
113
  }
111
114
  export interface IAmqp {
112
115
  connOpt: Options.Connect;
@@ -176,6 +179,30 @@ export interface IImport {
176
179
  groupData: number;
177
180
  maxStackedElements: number;
178
181
  }
182
+ /**
183
+ * Data loaders configuration for performances
184
+ */
185
+ export interface IDataLoaders {
186
+ valueRepo: {
187
+ getValues: {
188
+ /**
189
+ * @default false
190
+ *
191
+ * Enable cache inside data loaders in the query context
192
+ * Before enable, ensure that it has no side effects, for instance on saveValue/deleteValue mutations
193
+ */
194
+ enableCache: boolean;
195
+ /**
196
+ * @default true
197
+ *
198
+ * Enable: do batch arangodb query
199
+ * Disable: do one arangodb query per value, as before data loader use. For rollback if issue with batch query
200
+ * Temporary, to be removed in future
201
+ */
202
+ useBatch: boolean;
203
+ };
204
+ };
205
+ }
179
206
  export interface IDiskCache {
180
207
  directory: string;
181
208
  }
@@ -2,7 +2,26 @@ import { AqlQuery } from 'arangojs/aql';
2
2
  export interface IDbProfilerQuery {
3
3
  count: number;
4
4
  query: string | AqlQuery;
5
- callers: Set<string>;
5
+ callers: Record<string, {
6
+ /**
7
+ * Stacktrace of caller
8
+ */
9
+ stack: string;
10
+ count: number;
11
+ /**
12
+ * Stats for each call for that query
13
+ */
14
+ stats: Array<{
15
+ /**
16
+ * Arangodb query execution time in ms
17
+ */
18
+ executionTimeMs: number | null;
19
+ /**
20
+ * Time spent in nodejs to process the query in ms
21
+ */
22
+ nodejsTimeMs: number;
23
+ }>;
24
+ }>;
6
25
  }
7
26
  export interface IDbProfiler {
8
27
  totalCount: number;
@@ -18,11 +18,12 @@ export interface IRecordForm {
18
18
  system: boolean;
19
19
  recordId: string;
20
20
  dependencyAttributes?: string[];
21
- elements: IFormElementWithValues[];
21
+ elements: IFormElement[];
22
22
  sidePanel: IFormSidePanel;
23
23
  }
24
24
  export declare enum FormElementTypes {
25
25
  field = "field",
26
+ tabs = "tabs",
26
27
  layout = "layout"
27
28
  }
28
29
  export type IFormStrict = Required<IForm>;
@@ -41,16 +42,15 @@ export interface IFormElement {
41
42
  uiElementType: string;
42
43
  containerId: string;
43
44
  settings?: IKeyValue<any>;
45
+ children?: IFormElement[];
44
46
  }
45
- export interface IFormElementWithValues extends IFormElement {
46
- values?: IValue[];
47
+ export interface IFormElementValues {
48
+ id: string;
49
+ values: IValue[];
47
50
  valueError?: string;
48
51
  }
49
- export type IFormElementWithValuesAndChildren = IFormElementWithValues & {
50
- children: IFormElementWithValuesAndChildren[];
51
- };
52
52
  /**
53
- * Accepted fields to filter attributes list
53
+ * Accepted fields to filter an attribute list
54
54
  */
55
55
  export interface IFormFilterOptions extends ICoreEntityFilterOptions {
56
56
  library?: string;
@@ -76,7 +76,8 @@ 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"
80
81
  }
81
82
  export type PermissionsActions = LibraryPermissionsActions | RecordPermissionsActions | RecordAttributePermissionsActions | AdminPermissionsActions | AttributePermissionsActions | TreePermissionsActions | TreeNodePermissionsActions | ApplicationPermissionsActions;
82
83
  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,6 +29,16 @@ export interface IGetRecordFormArgs {
29
29
  treeNodeId: string;
30
30
  }>;
31
31
  }
32
+ export interface IGetElementFormValuesArgs {
33
+ recordId: string;
34
+ libraryId: string;
35
+ formId: string;
36
+ version?: Array<{
37
+ treeId: string;
38
+ treeNodeId: string;
39
+ }>;
40
+ elementIds: string[];
41
+ }
32
42
  export interface ISaveFormArgs {
33
43
  form: IFormForGraphql;
34
44
  }
@@ -5,8 +5,6 @@ import { ILibraryDomain } from 'domain/library/libraryDomain';
5
5
  import { IUtils } from 'utils/utils';
6
6
  import { IAppGraphQLSchema } from '_types/graphql';
7
7
  import { IfLibraryJoinLinkAttribute } from 'domain/attribute/helpers/ifLibraryJoinLinkAttribute';
8
- import { IGraphqlAppModule } from 'app/graphql/graphqlApp';
9
- export type ICoreFormApp = IGraphqlAppModule;
10
8
  interface IDeps {
11
9
  'core.domain.attribute': IAttributeDomain;
12
10
  'core.domain.form': IFormDomain;
@@ -6,6 +6,7 @@ import { ITreeDomain } from '../../../domain/tree/treeDomain';
6
6
  import { IGraphqlAppModule, IGraphqlApp } from '../../graphql/graphqlApp';
7
7
  import { ICoreApp } from '../coreApp';
8
8
  import { ICoreSubscriptionsHelpersApp } from '../helpers/subscriptions';
9
+ import { IRecordPermissionDomain } from '../../../domain/permission/recordPermissionDomain';
9
10
  export type ITreeAttributeApp = IGraphqlAppModule;
10
11
  interface IDeps {
11
12
  'core.domain.tree': ITreeDomain;
@@ -16,6 +17,7 @@ interface IDeps {
16
17
  'core.app.core': ICoreApp;
17
18
  'core.app.core.subscriptionsHelper': ICoreSubscriptionsHelpersApp;
18
19
  'core.domain.library': ILibraryDomain;
20
+ 'core.domain.permission.record': IRecordPermissionDomain;
19
21
  }
20
- export default function ({ 'core.domain.tree': treeDomain, 'core.domain.attribute': attributeDomain, 'core.domain.permission': permissionDomain, 'core.domain.eventsManager': eventsManagerDomain, 'core.app.core': coreApp, 'core.app.graphql': graphqlApp, 'core.app.core.subscriptionsHelper': subscriptionsHelper, 'core.domain.library': libraryDomain }: IDeps): ITreeAttributeApp;
22
+ export default function ({ 'core.domain.tree': treeDomain, 'core.domain.attribute': attributeDomain, 'core.domain.permission': permissionDomain, 'core.domain.eventsManager': eventsManagerDomain, 'core.app.core': coreApp, 'core.app.graphql': graphqlApp, 'core.app.core.subscriptionsHelper': subscriptionsHelper, 'core.domain.library': libraryDomain, 'core.domain.permission.record': recordPermissionDomain }: IDeps): ITreeAttributeApp;
21
23
  export {};
@@ -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
  }
@@ -13,7 +13,7 @@ import winston from 'winston';
13
13
  import { IQueryInfos } from '_types/queryInfos';
14
14
  import { IGetCoreEntitiesParams } from '_types/shared';
15
15
  import { IValueVersion } from '_types/value';
16
- import { IForm, IRecordForm } from '../../_types/forms';
16
+ import { IForm, IFormElementValues, IRecordForm } from '../../_types/forms';
17
17
  import { IList } from '../../_types/list';
18
18
  export interface IFormDomain {
19
19
  getFormsByLib({ library, params, ctx }: {
@@ -28,6 +28,14 @@ export interface IFormDomain {
28
28
  version?: IValueVersion;
29
29
  ctx: IQueryInfos;
30
30
  }): Promise<IRecordForm>;
31
+ getRecordFormElementsValues(params: {
32
+ recordId: string;
33
+ libraryId: string;
34
+ formId: string;
35
+ version?: IValueVersion;
36
+ ctx: IQueryInfos;
37
+ elementIds: string[];
38
+ }): Promise<IFormElementValues[]>;
31
39
  getFormProperties({ library, id, ctx }: {
32
40
  library: string;
33
41
  id: string;
@@ -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 {};
@@ -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;
@@ -199,3 +199,11 @@ export interface IGetInheritedRecordPermissionParams {
199
199
  permTreeNode: string;
200
200
  ctx: IQueryInfos;
201
201
  }
202
+ export interface IEstimateTreeValueRecordPermissionParams {
203
+ action: RecordPermissionsActions;
204
+ userId: string;
205
+ libraryId: string;
206
+ attributeId: string;
207
+ nodeId: string;
208
+ ctx: IQueryInfos;
209
+ }
@@ -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>;
@@ -5,10 +5,12 @@ import { IDefaultPermissionHelper } from './helpers/defaultPermission';
5
5
  import { IPermissionByUserGroupsHelper } from './helpers/permissionByUserGroups';
6
6
  import { ITreeBasedPermissionHelper } from './helpers/treeBasedPermissions';
7
7
  import { ILibraryPermissionDomain } from './libraryPermissionDomain';
8
- import { IGetInheritedRecordPermissionParams, IGetRecordPermissionParams } from './_types';
8
+ import { IGetInheritedRecordPermissionParams, IGetRecordPermissionParams, IEstimateTreeValueRecordPermissionParams } from './_types';
9
+ import { ITreeRepo } from '../../infra/tree/treeRepo';
9
10
  export interface IRecordPermissionDomain {
10
11
  getRecordPermission(params: IGetRecordPermissionParams): Promise<boolean>;
11
12
  getInheritedRecordPermission(params: IGetInheritedRecordPermissionParams): Promise<boolean>;
13
+ evaluateTreeValueRecordPermission(params: IEstimateTreeValueRecordPermissionParams): Promise<boolean>;
12
14
  }
13
15
  export interface IRecordPermissionDomainDeps {
14
16
  'core.domain.permission.library': ILibraryPermissionDomain;
@@ -18,5 +20,6 @@ export interface IRecordPermissionDomainDeps {
18
20
  'core.domain.attribute': IAttributeDomain;
19
21
  'core.domain.helpers.getCoreEntityById': GetCoreEntityByIdFunc;
20
22
  'core.infra.value': IValueRepo;
23
+ 'core.infra.tree': ITreeRepo;
21
24
  }
22
25
  export default function (deps: IRecordPermissionDomainDeps): IRecordPermissionDomain;
@@ -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;
@@ -28,6 +28,14 @@ import { DeleteRecordHelper } from './helpers/deleteRecord';
28
28
  import { CreateRecordHelper } from './helpers/createRecord';
29
29
  import { IElementAncestorsHelper } from 'domain/tree/helpers/elementAncestors';
30
30
  export interface IRecordDomain {
31
+ /**
32
+ * Create empty record
33
+ * Used when create a record, set active to false and inCreation to true
34
+ */
35
+ createEmptyRecord(params: {
36
+ library: string;
37
+ ctx: IQueryInfos;
38
+ }): Promise<ICreateRecordResult>;
31
39
  createRecord(params: {
32
40
  library: string;
33
41
  values?: ISaveValue[];
@@ -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,8 @@
1
+ import DataLoader from 'dataloader';
2
+ import { IQueryInfos } from '_types/queryInfos';
3
+ /**
4
+ * Get or create a DataLoader in the request context.
5
+ * Each usage (not each call) of this function should use a unique name to avoid conflicts among different DataLoaders.
6
+ * Name is used has key to store the DataLoader in ctx.dataLoaders.
7
+ */
8
+ export declare function getOrCreateDataLoaderInCtx<DL extends DataLoader<unknown, unknown>>(ctx: IQueryInfos, name: string, create: () => DL): DL;
@@ -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';
@@ -5,7 +5,8 @@ export declare enum FormUIElementTypes {
5
5
  TAB_FIELDS_CONTAINER = "tab_fields_container",
6
6
  TEXT_BLOCK = "text_block",
7
7
  TABS = "tabs",
8
- FRAME = "frame"
8
+ FRAME = "frame",
9
+ LINK = "link"
9
10
  }
10
11
  export declare enum FormFieldTypes {
11
12
  TEXT_INPUT = "input_field",
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@aristid/leav-types",
3
- "version": "0.0.7-81dd3cf8",
3
+ "version": "0.0.7-83000546",
4
4
  "description": "Shared Leav types",
5
5
  "scripts": {
6
6
  "tscheck": "",
7
7
  "test:ci": "",
8
8
  "test:commit": "",
9
9
  "publish-types": "npm publish --access public",
10
- "generate": "yarn workspace core tsc --emitDeclarationOnly --declaration --outDir dist-types && mv ../../apps/core/dist-types/* . && rmdir ../../apps/core/dist-types",
10
+ "generate": "yarn workspace core build-types && mv ../../apps/core/dist-types/* . && rmdir ../../apps/core/dist-types",
11
11
  "get-version": "jq -r '.version' package.json",
12
12
  "set-version": "jq --arg v $1 '.version = $v' package.json > package.tmp.json && mv package.tmp.json package.json"
13
13
  },