@aristid/leav-types 1.5.0-01ca96c4 → 1.5.0-3c3ef771

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.
@@ -17,5 +17,13 @@ interface IMailpitMsgFull extends IMailpitMsgLight {
17
17
  HTML: string;
18
18
  Text: string;
19
19
  }
20
+ interface IMailpitSearchResult {
21
+ messages: IMailpitMsgLight[];
22
+ total: number;
23
+ unread: number;
24
+ }
20
25
  export declare function waitMailpitMessage(acceptMessage: (msg: IMailpitMsgLight) => boolean): Promise<IMailpitMsgFull>;
26
+ export declare function deleteMailpitMessagesBySearch(search: string): Promise<void>;
27
+ export declare function searchMailpitMessages(search: string): Promise<IMailpitSearchResult>;
28
+ export declare function waitForMailpitSearchMessage(search: string, timeoutMs?: number, intervalMs?: number): Promise<IMailpitMsgLight[]>;
21
29
  export {};
@@ -0,0 +1 @@
1
+ export declare const MASKED_VALUE = "\u25CF\u25CF\u25CF\u25CF\u25CF\u25CF\u25CF";
@@ -8,15 +8,16 @@ import { type IRecord } from './record';
8
8
  import { type IValue } from './value';
9
9
  import { type IVersionProfile } from './versionProfile';
10
10
  import { type IPermission } from './permissions';
11
- import { type ITree } from './tree';
11
+ import { type ITreeDbEvent, type ITree } from './tree';
12
+ type OnlyObject<T> = T extends object ? T : never;
12
13
  /**
13
14
  * Maybe move all DBPayloadData types in @leav/utils type to allow event consumers outside core to use them
14
15
  * without having to redeclare them. For now before and after are any in @leav/utils
15
16
  */
16
17
  export interface IDbPayloadInternal<DBPayloadAction extends EventAction> extends IDbPayload {
17
18
  action: DBPayloadAction;
18
- before?: IDBPayloadData<DBPayloadAction>;
19
- after?: IDBPayloadData<DBPayloadAction>;
19
+ before?: OnlyObject<IDBPayloadData<DBPayloadAction>>;
20
+ after?: OnlyObject<IDBPayloadData<DBPayloadAction>>;
20
21
  }
21
22
  interface IDBPayloadDataMap {
22
23
  [EventAction.VALUE_SAVE]: IValue;
@@ -34,9 +35,9 @@ interface IDBPayloadDataMap {
34
35
  [EventAction.LIBRARY_DELETE]: ILibraryDbEvent;
35
36
  [EventAction.VERSION_PROFILE_SAVE]: IVersionProfile;
36
37
  [EventAction.VERSION_PROFILE_DELETE]: IVersionProfile;
37
- [EventAction.TREE_ADD_ELEMENT]: string;
38
- [EventAction.TREE_DELETE_ELEMENT]: string;
39
- [EventAction.TREE_MOVE_ELEMENT]: string;
38
+ [EventAction.TREE_ADD_ELEMENT]: ITreeDbEvent;
39
+ [EventAction.TREE_DELETE_ELEMENT]: ITreeDbEvent;
40
+ [EventAction.TREE_MOVE_ELEMENT]: ITreeDbEvent;
40
41
  [EventAction.TREE_SAVE]: ITree;
41
42
  [EventAction.TREE_DELETE]: ITree;
42
43
  [EventAction.PERMISSION_SAVE]: IPermission;
@@ -62,3 +62,8 @@ export interface ITreeEvent {
62
62
  };
63
63
  order: number;
64
64
  }
65
+ export interface ITreeDbEvent {
66
+ parentNode: {
67
+ id: string;
68
+ };
69
+ }
@@ -106,6 +106,7 @@ export interface IValuesOptions {
106
106
  version?: IValueVersion;
107
107
  forceArray?: boolean;
108
108
  forceGetAllValues?: boolean;
109
+ skipActions?: boolean;
109
110
  [optionName: string]: any;
110
111
  }
111
112
  export interface IFindValueTree {
@@ -0,0 +1,38 @@
1
+ import { type ILibraryPermissionDomain } from 'domain/permission/libraryPermissionDomain';
2
+ import { type IRecordRepo } from 'infra/record/recordRepo';
3
+ import { type IQueryInfos } from '../../../_types/queryInfos';
4
+ import { type IRecord } from '../../../_types/record';
5
+ import { type IFindRecordParams } from '../_types';
6
+ import { type IPermissionRepo } from '../../../infra/permission/permissionRepo';
7
+ import { type IListWithCursor } from '../../../_types/list';
8
+ import { type IValidateHelper } from '../../helpers/validate';
9
+ import { type IUtils } from '../../../utils/utils';
10
+ import { type IAttributeDomain } from '../../attribute/attributeDomain';
11
+ import { type ILibraryRepo } from '../../../infra/library/libraryRepo';
12
+ import { type ITreeRepo } from '../../../infra/tree/treeRepo';
13
+ import { type GetCoreEntityByIdFunc } from '../../helpers/getCoreEntityById';
14
+ import { type IElementAncestorsHelper } from '../../tree/helpers/elementAncestors';
15
+ import { type IDefaultPermissionHelper } from '../../permission/helpers/defaultPermission';
16
+ /**
17
+ * Search records
18
+ * Filters to apply on records selection
19
+ * Fields to retrieve on each records
20
+ */
21
+ export type FindRecordsHelper = ({ params, ctx, }: {
22
+ params: IFindRecordParams;
23
+ ctx: IQueryInfos;
24
+ }) => Promise<IListWithCursor<IRecord>>;
25
+ export interface IFindRecordsHelperDeps {
26
+ 'core.domain.helpers.validate': IValidateHelper;
27
+ 'core.domain.permission.library': ILibraryPermissionDomain;
28
+ 'core.domain.attribute': IAttributeDomain;
29
+ 'core.infra.record': IRecordRepo;
30
+ 'core.infra.library': ILibraryRepo;
31
+ 'core.infra.tree': ITreeRepo;
32
+ 'core.utils': IUtils;
33
+ 'core.domain.helpers.getCoreEntityById': GetCoreEntityByIdFunc;
34
+ 'core.domain.tree.helpers.elementAncestors': IElementAncestorsHelper;
35
+ 'core.domain.permission.helpers.defaultPermission': IDefaultPermissionHelper;
36
+ 'core.infra.permission': IPermissionRepo;
37
+ }
38
+ export default function ({ 'core.domain.helpers.validate': validateHelper, 'core.domain.attribute': attributeDomain, 'core.domain.permission.helpers.defaultPermission': defaultPermHelper, 'core.infra.library': libraryRepo, 'core.domain.permission.library': libraryPermissionDomain, 'core.infra.record': recordRepo, 'core.domain.helpers.getCoreEntityById': getCoreEntityById, 'core.infra.tree': treeRepo, 'core.domain.tree.helpers.elementAncestors': elementAncestorsHelper, 'core.infra.permission': permissionRepo, 'core.utils': utils, }: IFindRecordsHelperDeps): FindRecordsHelper;
@@ -0,0 +1,31 @@
1
+ import { type IQueryInfos } from '../../../_types/queryInfos';
2
+ import { type IRecord } from '../../../_types/record';
3
+ import { type IAttributeDomain } from '../../attribute/attributeDomain';
4
+ import { type IValue, type IValuesOptions } from '../../../_types/value';
5
+ import { type IRecordAttributePermissionDomain } from '../../permission/recordAttributePermissionDomain';
6
+ import { type IValueDomain } from '../../value/valueDomain';
7
+ /**
8
+ * Get the value of targeted attribute with actions applied on it including metadata.
9
+ *
10
+ * Avoid requesting DB if attribute already found in `record` param.
11
+ *
12
+ * @param {Object} params
13
+ * @param params.library
14
+ * @param params.record Could be emulated with only `{ id: <real_id> }`
15
+ * @param params.attributeId
16
+ * @param params.options
17
+ * @param params.ctx
18
+ */
19
+ export type GetRecordFieldValueHelper = ({ library, record, attributeId, options, ctx, }: {
20
+ library: string;
21
+ record: IRecord;
22
+ attributeId: string;
23
+ options?: IValuesOptions;
24
+ ctx: IQueryInfos;
25
+ }) => Promise<IValue[]>;
26
+ export interface IGetRecordFieldValueHelperDeps {
27
+ 'core.domain.attribute': IAttributeDomain;
28
+ 'core.domain.value': IValueDomain;
29
+ 'core.domain.permission.recordAttribute': IRecordAttributePermissionDomain;
30
+ }
31
+ export default function ({ 'core.domain.attribute': attributeDomain, 'core.domain.value': valueDomain, 'core.domain.permission.recordAttribute': recordAttributePermissionDomain, }: IGetRecordFieldValueHelperDeps): GetRecordFieldValueHelper;
@@ -2,3 +2,5 @@ export { default as createRecord } from './createRecord';
2
2
  export { default as deleteRecord } from './deleteRecord';
3
3
  export { default as sendRecordUpdateEvent } from './sendRecordUpdateEvent';
4
4
  export { default as getAccessPermissionFilters } from './getAccessPermissionFilters';
5
+ export { default as findRecords } from './findRecords';
6
+ export { default as getRecordFieldValue } from './getRecordFieldValue';
@@ -1,12 +1,9 @@
1
1
  import { type IEventsManagerDomain } from 'domain/eventsManager/eventsManagerDomain';
2
2
  import { type GetCoreEntityByIdFunc } from 'domain/helpers/getCoreEntityById';
3
3
  import { type IValidateHelper } from 'domain/helpers/validate';
4
- import { type ILibraryPermissionDomain } from 'domain/permission/libraryPermissionDomain';
5
4
  import { type IValueDomain } from 'domain/value/valueDomain';
6
5
  import { type i18n } from 'i18next';
7
- import { type ILibraryRepo } from 'infra/library/libraryRepo';
8
6
  import { type IRecordRepo } from 'infra/record/recordRepo';
9
- import { type ITreeRepo } from 'infra/tree/treeRepo';
10
7
  import { type IUtils } from 'utils/utils';
11
8
  import type * as Config from '_types/config';
12
9
  import { type IListWithCursor } from '_types/list';
@@ -19,13 +16,12 @@ import { type IRecordPermissionDomain } from '../permission/recordPermissionDoma
19
16
  import { type SendRecordUpdateEventHelper } from './helpers/sendRecordUpdateEvent';
20
17
  import { type ICreateRecordResult, type IFindRecordParams } from './_types';
21
18
  import { type IFormRepo } from 'infra/form/formRepo';
22
- import { type IRecordAttributePermissionDomain } from '../permission/recordAttributePermissionDomain';
23
- import { type IPermissionRepo } from '../../infra/permission/permissionRepo';
24
- import { type IDefaultPermissionHelper } from 'domain/permission/helpers/defaultPermission';
25
19
  import { type DeleteRecordHelper } from './helpers/deleteRecord';
26
20
  import { type CreateRecordHelper } from './helpers/createRecord';
27
21
  import { type IElementAncestorsHelper } from 'domain/tree/helpers/elementAncestors';
28
22
  import { type ILogger } from '@leav/logger';
23
+ import { type FindRecordsHelper } from './helpers/findRecords';
24
+ import { type GetRecordFieldValueHelper } from './helpers/getRecordFieldValue';
29
25
  export declare const ATTRIBUTE_ACTIVE = "active";
30
26
  export interface IRecordDomain {
31
27
  /**
@@ -122,23 +118,19 @@ export interface IRecordDomainDeps {
122
118
  'core.domain.attribute': IAttributeDomain;
123
119
  'core.domain.value': IValueDomain;
124
120
  'core.domain.permission.record': IRecordPermissionDomain;
125
- 'core.domain.permission.library': ILibraryPermissionDomain;
126
- 'core.domain.permission.recordAttribute': IRecordAttributePermissionDomain;
127
- 'core.domain.permission.helpers.defaultPermission': IDefaultPermissionHelper;
128
121
  'core.domain.helpers.getCoreEntityById': GetCoreEntityByIdFunc;
129
122
  'core.domain.helpers.validate': IValidateHelper;
130
123
  'core.domain.record.helpers.createRecord': CreateRecordHelper;
131
124
  'core.domain.record.helpers.deleteRecord': DeleteRecordHelper;
125
+ 'core.domain.record.helpers.findRecords': FindRecordsHelper;
126
+ 'core.domain.record.helpers.getRecordFieldValue': GetRecordFieldValueHelper;
132
127
  'core.domain.record.helpers.sendRecordUpdateEvent': SendRecordUpdateEventHelper;
133
- 'core.infra.library': ILibraryRepo;
134
- 'core.infra.tree': ITreeRepo;
135
128
  'core.domain.tree.helpers.elementAncestors': IElementAncestorsHelper;
136
129
  'core.infra.form': IFormRepo;
137
- 'core.infra.permission': IPermissionRepo;
138
130
  'core.domain.eventsManager': IEventsManagerDomain;
139
131
  'core.infra.cache.cacheService': ICachesService;
140
132
  'core.utils.logger': ILogger;
141
133
  'core.utils': IUtils;
142
134
  translator: i18n;
143
135
  }
144
- 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.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.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;
136
+ export default function ({ config, 'core.infra.record': recordRepo, 'core.domain.attribute': attributeDomain, 'core.domain.value': valueDomain, 'core.domain.permission.record': recordPermissionDomain, 'core.domain.record.helpers.findRecords': findRecordsHelper, 'core.domain.record.helpers.getRecordFieldValue': getRecordFieldValueHelper, '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.domain.tree.helpers.elementAncestors': elementAncestorsHelper, 'core.infra.form': formRepo, 'core.domain.eventsManager': eventsManager, 'core.infra.cache.cacheService': cacheService, 'core.utils.logger': logger, 'core.utils': utils, translator, }: IRecordDomainDeps): IRecordDomain;
@@ -20,6 +20,7 @@ export interface IUserDomain {
20
20
  saveUserData(params: ISaveUserDataParams): Promise<IUserData>;
21
21
  getUserData(keys: string[], global: boolean, ctx: IQueryInfos): Promise<IUserData>;
22
22
  sendResetPasswordEmail(email: string, token: string, login: string, browser: string, os: string, lang: 'fr' | 'en', ctx: IQueryInfos): Promise<void>;
23
+ verifyPassword(userId: string, password: string, ctx: IQueryInfos): Promise<boolean>;
23
24
  }
24
25
  export interface IUserDomainDeps {
25
26
  config: Config.IConfig;
@@ -0,0 +1,7 @@
1
+ import { type IAttributeRepo } from 'infra/attribute/attributeRepo';
2
+ import { type IMigration } from '../../../_types/migration';
3
+ interface IDeps {
4
+ 'core.infra.attribute'?: IAttributeRepo;
5
+ }
6
+ export default function ({ 'core.infra.attribute': attributeRepo }: IDeps): IMigration;
7
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aristid/leav-types",
3
- "version": "1.5.0-01ca96c4",
3
+ "version": "1.5.0-3c3ef771",
4
4
  "description": "Shared Leav types",
5
5
  "scripts": {
6
6
  "tscheck": "",