@webiny/api-record-locking 0.0.0-unstable.06b2ede40f → 0.0.0-unstable.0d717d18dd
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.
- package/README.md +10 -9
- package/RecordLockingAppFeature.d.ts +11 -0
- package/RecordLockingAppFeature.js +18 -0
- package/RecordLockingAppFeature.js.map +1 -0
- package/domain/LockRecord.d.ts +45 -0
- package/domain/LockRecord.js +73 -0
- package/domain/LockRecord.js.map +1 -0
- package/domain/RecordLockingAppConfig.d.ts +4 -0
- package/domain/RecordLockingAppConfig.js +5 -0
- package/domain/RecordLockingAppConfig.js.map +1 -0
- package/domain/RecordLockingModel.d.ts +9 -0
- package/domain/RecordLockingModel.js +32 -0
- package/domain/RecordLockingModel.js.map +1 -0
- package/domain/abstractions.d.ts +18 -0
- package/domain/abstractions.js +6 -0
- package/domain/abstractions.js.map +1 -0
- package/domain/calculateExpiresOn.d.ts +1 -0
- package/domain/calculateExpiresOn.js +8 -0
- package/domain/calculateExpiresOn.js.map +1 -0
- package/domain/errors.d.ts +71 -0
- package/domain/errors.js +85 -0
- package/domain/errors.js.map +1 -0
- package/domain/index.d.ts +4 -0
- package/domain/index.js +4 -0
- package/domain/types.d.ts +44 -0
- package/domain/types.js +9 -0
- package/domain/types.js.map +1 -0
- package/features/GetLockRecord/GetLockRecordRepository.d.ts +16 -0
- package/features/GetLockRecord/GetLockRecordRepository.js +40 -0
- package/features/GetLockRecord/GetLockRecordRepository.js.map +1 -0
- package/features/GetLockRecord/GetLockRecordUseCase.d.ts +12 -0
- package/features/GetLockRecord/GetLockRecordUseCase.js +18 -0
- package/features/GetLockRecord/GetLockRecordUseCase.js.map +1 -0
- package/features/GetLockRecord/abstractions.d.ts +41 -0
- package/features/GetLockRecord/abstractions.js +6 -0
- package/features/GetLockRecord/abstractions.js.map +1 -0
- package/features/GetLockRecord/feature.d.ts +4 -0
- package/features/GetLockRecord/feature.js +13 -0
- package/features/GetLockRecord/feature.js.map +1 -0
- package/features/GetLockRecord/index.d.ts +2 -0
- package/features/GetLockRecord/index.js +2 -0
- package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.d.ts +15 -0
- package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js +30 -0
- package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js.map +1 -0
- package/features/GetLockedEntryLockRecord/abstractions.d.ts +26 -0
- package/features/GetLockedEntryLockRecord/abstractions.js +5 -0
- package/features/GetLockedEntryLockRecord/abstractions.js.map +1 -0
- package/features/GetLockedEntryLockRecord/feature.d.ts +4 -0
- package/features/GetLockedEntryLockRecord/feature.js +11 -0
- package/features/GetLockedEntryLockRecord/feature.js.map +1 -0
- package/features/GetLockedEntryLockRecord/index.d.ts +2 -0
- package/features/GetLockedEntryLockRecord/index.js +2 -0
- package/features/IsEntryLocked/IsEntryLockedUseCase.d.ts +14 -0
- package/features/IsEntryLocked/IsEntryLockedUseCase.js +33 -0
- package/features/IsEntryLocked/IsEntryLockedUseCase.js.map +1 -0
- package/features/IsEntryLocked/abstractions.d.ts +24 -0
- package/features/IsEntryLocked/abstractions.js +5 -0
- package/features/IsEntryLocked/abstractions.js.map +1 -0
- package/features/IsEntryLocked/feature.d.ts +4 -0
- package/features/IsEntryLocked/feature.js +11 -0
- package/features/IsEntryLocked/feature.js.map +1 -0
- package/features/IsEntryLocked/index.d.ts +1 -0
- package/features/IsEntryLocked/index.js +1 -0
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.d.ts +15 -0
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js +36 -0
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js.map +1 -0
- package/features/KickOutCurrentUser/abstractions.d.ts +17 -0
- package/features/KickOutCurrentUser/abstractions.js +5 -0
- package/features/KickOutCurrentUser/abstractions.js.map +1 -0
- package/features/KickOutCurrentUser/feature.d.ts +4 -0
- package/features/KickOutCurrentUser/feature.js +11 -0
- package/features/KickOutCurrentUser/feature.js.map +1 -0
- package/features/KickOutCurrentUser/index.d.ts +1 -0
- package/features/KickOutCurrentUser/index.js +1 -0
- package/features/ListAllLockRecords/ListAllLockRecordsRepository.d.ts +18 -0
- package/features/ListAllLockRecords/ListAllLockRecordsRepository.js +49 -0
- package/features/ListAllLockRecords/ListAllLockRecordsRepository.js.map +1 -0
- package/features/ListAllLockRecords/ListAllLockRecordsUseCase.d.ts +11 -0
- package/features/ListAllLockRecords/ListAllLockRecordsUseCase.js +18 -0
- package/features/ListAllLockRecords/ListAllLockRecordsUseCase.js.map +1 -0
- package/features/ListAllLockRecords/abstractions.d.ts +40 -0
- package/features/ListAllLockRecords/abstractions.js +6 -0
- package/features/ListAllLockRecords/abstractions.js.map +1 -0
- package/features/ListAllLockRecords/feature.d.ts +4 -0
- package/features/ListAllLockRecords/feature.js +13 -0
- package/features/ListAllLockRecords/feature.js.map +1 -0
- package/features/ListAllLockRecords/index.d.ts +2 -0
- package/features/ListAllLockRecords/index.js +2 -0
- package/features/ListLockRecords/ListLockRecordsRepository.d.ts +17 -0
- package/features/ListLockRecords/ListLockRecordsRepository.js +49 -0
- package/features/ListLockRecords/ListLockRecordsRepository.js.map +1 -0
- package/features/ListLockRecords/ListLockRecordsUseCase.d.ts +15 -0
- package/features/ListLockRecords/ListLockRecordsUseCase.js +33 -0
- package/features/ListLockRecords/ListLockRecordsUseCase.js.map +1 -0
- package/features/ListLockRecords/abstractions.d.ts +45 -0
- package/features/ListLockRecords/abstractions.js +6 -0
- package/features/ListLockRecords/abstractions.js.map +1 -0
- package/features/ListLockRecords/feature.d.ts +4 -0
- package/features/ListLockRecords/feature.js +13 -0
- package/features/ListLockRecords/feature.js.map +1 -0
- package/features/ListLockRecords/index.d.ts +1 -0
- package/features/ListLockRecords/index.js +1 -0
- package/features/LockEntry/LockEntryEventsDecorator.d.ts +14 -0
- package/features/LockEntry/LockEntryEventsDecorator.js +40 -0
- package/features/LockEntry/LockEntryEventsDecorator.js.map +1 -0
- package/features/LockEntry/LockEntryRepository.d.ts +16 -0
- package/features/LockEntry/LockEntryRepository.js +45 -0
- package/features/LockEntry/LockEntryRepository.js.map +1 -0
- package/features/LockEntry/LockEntryUseCase.d.ts +14 -0
- package/features/LockEntry/LockEntryUseCase.js +31 -0
- package/features/LockEntry/LockEntryUseCase.js.map +1 -0
- package/features/LockEntry/abstractions.d.ts +41 -0
- package/features/LockEntry/abstractions.js +6 -0
- package/features/LockEntry/abstractions.js.map +1 -0
- package/features/LockEntry/events.d.ts +45 -0
- package/features/LockEntry/events.js +32 -0
- package/features/LockEntry/events.js.map +1 -0
- package/features/LockEntry/feature.d.ts +4 -0
- package/features/LockEntry/feature.js +15 -0
- package/features/LockEntry/feature.js.map +1 -0
- package/features/LockEntry/index.d.ts +1 -0
- package/features/LockEntry/index.js +1 -0
- package/features/RecordLockingFeature.d.ts +15 -0
- package/features/RecordLockingFeature.js +34 -0
- package/features/RecordLockingFeature.js.map +1 -0
- package/features/UnlockEntry/UnlockEntryEventsDecorator.d.ts +14 -0
- package/features/UnlockEntry/UnlockEntryEventsDecorator.js +41 -0
- package/features/UnlockEntry/UnlockEntryEventsDecorator.js.map +1 -0
- package/features/UnlockEntry/UnlockEntryRepository.d.ts +14 -0
- package/features/UnlockEntry/UnlockEntryRepository.js +42 -0
- package/features/UnlockEntry/UnlockEntryRepository.js.map +1 -0
- package/features/UnlockEntry/UnlockEntryUseCase.d.ts +18 -0
- package/features/UnlockEntry/UnlockEntryUseCase.js +65 -0
- package/features/UnlockEntry/UnlockEntryUseCase.js.map +1 -0
- package/features/UnlockEntry/abstractions.d.ts +44 -0
- package/features/UnlockEntry/abstractions.js +6 -0
- package/features/UnlockEntry/abstractions.js.map +1 -0
- package/features/UnlockEntry/events.d.ts +46 -0
- package/features/UnlockEntry/events.js +32 -0
- package/features/UnlockEntry/events.js.map +1 -0
- package/features/UnlockEntry/feature.d.ts +4 -0
- package/features/UnlockEntry/feature.js +15 -0
- package/features/UnlockEntry/feature.js.map +1 -0
- package/features/UnlockEntry/hasFullAccessPermission.d.ts +2 -0
- package/features/UnlockEntry/hasFullAccessPermission.js +9 -0
- package/features/UnlockEntry/hasFullAccessPermission.js.map +1 -0
- package/features/UnlockEntry/index.d.ts +1 -0
- package/features/UnlockEntry/index.js +1 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.d.ts +14 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js +40 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js.map +1 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.d.ts +17 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js +44 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js.map +1 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.d.ts +16 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js +75 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js.map +1 -0
- package/features/UnlockEntryRequest/abstractions.d.ts +42 -0
- package/features/UnlockEntryRequest/abstractions.js +6 -0
- package/features/UnlockEntryRequest/abstractions.js.map +1 -0
- package/features/UnlockEntryRequest/events.d.ts +45 -0
- package/features/UnlockEntryRequest/events.js +32 -0
- package/features/UnlockEntryRequest/events.js.map +1 -0
- package/features/UnlockEntryRequest/feature.d.ts +4 -0
- package/features/UnlockEntryRequest/feature.js +15 -0
- package/features/UnlockEntryRequest/feature.js.map +1 -0
- package/features/UnlockEntryRequest/index.d.ts +3 -0
- package/features/UnlockEntryRequest/index.js +3 -0
- package/features/UpdateEntryLock/UpdateEntryLockRepository.d.ts +20 -0
- package/features/UpdateEntryLock/UpdateEntryLockRepository.js +60 -0
- package/features/UpdateEntryLock/UpdateEntryLockRepository.js.map +1 -0
- package/features/UpdateEntryLock/UpdateEntryLockUseCase.d.ts +18 -0
- package/features/UpdateEntryLock/UpdateEntryLockUseCase.js +51 -0
- package/features/UpdateEntryLock/UpdateEntryLockUseCase.js.map +1 -0
- package/features/UpdateEntryLock/abstractions.d.ts +42 -0
- package/features/UpdateEntryLock/abstractions.js +6 -0
- package/features/UpdateEntryLock/abstractions.js.map +1 -0
- package/features/UpdateEntryLock/feature.d.ts +4 -0
- package/features/UpdateEntryLock/feature.js +13 -0
- package/features/UpdateEntryLock/feature.js.map +1 -0
- package/features/UpdateEntryLock/index.d.ts +1 -0
- package/features/UpdateEntryLock/index.js +1 -0
- package/graphql/RecordLockingContextualSchema.d.ts +18 -0
- package/graphql/RecordLockingContextualSchema.js +77 -0
- package/graphql/RecordLockingContextualSchema.js.map +1 -0
- package/graphql/checkPermissions.d.ts +5 -0
- package/graphql/checkPermissions.js +10 -0
- package/graphql/checkPermissions.js.map +1 -0
- package/{utils → graphql}/resolve.d.ts +4 -4
- package/graphql/resolve.js +20 -0
- package/graphql/resolve.js.map +1 -0
- package/graphql/schema.d.ts +8 -4
- package/graphql/schema.js +162 -145
- package/graphql/schema.js.map +1 -1
- package/index.d.ts +2 -9
- package/index.js +1 -39
- package/package.json +32 -28
- package/types.d.ts +3 -132
- package/types.js +6 -27
- package/types.js.map +1 -1
- package/utils/convertWhereCondition.d.ts +1 -1
- package/utils/convertWhereCondition.js +21 -36
- package/utils/convertWhereCondition.js.map +1 -1
- package/utils/getTimeout.js +8 -22
- package/utils/getTimeout.js.map +1 -1
- package/utils/lockRecordDatabaseId.js +7 -20
- package/utils/lockRecordDatabaseId.js.map +1 -1
- package/abstractions/IGetLockRecordUseCase.d.ts +0 -8
- package/abstractions/IGetLockRecordUseCase.js +0 -7
- package/abstractions/IGetLockRecordUseCase.js.map +0 -1
- package/abstractions/IGetLockedEntryLockRecordUseCase.d.ts +0 -8
- package/abstractions/IGetLockedEntryLockRecordUseCase.js +0 -7
- package/abstractions/IGetLockedEntryLockRecordUseCase.js.map +0 -1
- package/abstractions/IIsEntryLocked.d.ts +0 -8
- package/abstractions/IIsEntryLocked.js +0 -7
- package/abstractions/IIsEntryLocked.js.map +0 -1
- package/abstractions/IKickOutCurrentUserUseCase.d.ts +0 -5
- package/abstractions/IKickOutCurrentUserUseCase.js +0 -7
- package/abstractions/IKickOutCurrentUserUseCase.js.map +0 -1
- package/abstractions/IListAllLockRecordsUseCase.d.ts +0 -9
- package/abstractions/IListAllLockRecordsUseCase.js +0 -7
- package/abstractions/IListAllLockRecordsUseCase.js.map +0 -1
- package/abstractions/IListLockRecordsUseCase.d.ts +0 -10
- package/abstractions/IListLockRecordsUseCase.js +0 -7
- package/abstractions/IListLockRecordsUseCase.js.map +0 -1
- package/abstractions/ILockEntryUseCase.d.ts +0 -11
- package/abstractions/ILockEntryUseCase.js +0 -7
- package/abstractions/ILockEntryUseCase.js.map +0 -1
- package/abstractions/IUnlockEntryRequestUseCase.d.ts +0 -11
- package/abstractions/IUnlockEntryRequestUseCase.js +0 -7
- package/abstractions/IUnlockEntryRequestUseCase.js.map +0 -1
- package/abstractions/IUnlockEntryUseCase.d.ts +0 -12
- package/abstractions/IUnlockEntryUseCase.js +0 -7
- package/abstractions/IUnlockEntryUseCase.js.map +0 -1
- package/abstractions/IUpdateEntryLockUseCase.d.ts +0 -11
- package/abstractions/IUpdateEntryLockUseCase.js +0 -7
- package/abstractions/IUpdateEntryLockUseCase.js.map +0 -1
- package/crud/crud.d.ts +0 -7
- package/crud/crud.js +0 -204
- package/crud/crud.js.map +0 -1
- package/crud/model.d.ts +0 -2
- package/crud/model.js +0 -127
- package/crud/model.js.map +0 -1
- package/index.js.map +0 -1
- package/useCases/GetLockRecord/GetLockRecordUseCase.d.ts +0 -16
- package/useCases/GetLockRecord/GetLockRecordUseCase.js +0 -39
- package/useCases/GetLockRecord/GetLockRecordUseCase.js.map +0 -1
- package/useCases/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.d.ts +0 -16
- package/useCases/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js +0 -29
- package/useCases/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js.map +0 -1
- package/useCases/IsEntryLocked/IsEntryLockedUseCase.d.ts +0 -13
- package/useCases/IsEntryLocked/IsEntryLockedUseCase.js +0 -31
- package/useCases/IsEntryLocked/IsEntryLockedUseCase.js.map +0 -1
- package/useCases/KickOutCurrentUser/KickOutCurrentUserUseCase.d.ts +0 -12
- package/useCases/KickOutCurrentUser/KickOutCurrentUserUseCase.js +0 -46
- package/useCases/KickOutCurrentUser/KickOutCurrentUserUseCase.js.map +0 -1
- package/useCases/ListAllLockRecordsUseCase/ListAllLockRecordsUseCase.d.ts +0 -13
- package/useCases/ListAllLockRecordsUseCase/ListAllLockRecordsUseCase.js +0 -34
- package/useCases/ListAllLockRecordsUseCase/ListAllLockRecordsUseCase.js.map +0 -1
- package/useCases/ListLockRecordsUseCase/ListLockRecordsUseCase.d.ts +0 -14
- package/useCases/ListLockRecordsUseCase/ListLockRecordsUseCase.js +0 -27
- package/useCases/ListLockRecordsUseCase/ListLockRecordsUseCase.js.map +0 -1
- package/useCases/LockEntryUseCase/LockEntryUseCase.d.ts +0 -21
- package/useCases/LockEntryUseCase/LockEntryUseCase.js +0 -64
- package/useCases/LockEntryUseCase/LockEntryUseCase.js.map +0 -1
- package/useCases/UnlockEntryUseCase/UnlockEntryUseCase.d.ts +0 -23
- package/useCases/UnlockEntryUseCase/UnlockEntryUseCase.js +0 -90
- package/useCases/UnlockEntryUseCase/UnlockEntryUseCase.js.map +0 -1
- package/useCases/UnlockRequestUseCase/UnlockEntryRequestUseCase.d.ts +0 -21
- package/useCases/UnlockRequestUseCase/UnlockEntryRequestUseCase.js +0 -82
- package/useCases/UnlockRequestUseCase/UnlockEntryRequestUseCase.js.map +0 -1
- package/useCases/UpdateEntryLock/UpdateEntryLockUseCase.d.ts +0 -26
- package/useCases/UpdateEntryLock/UpdateEntryLockUseCase.js +0 -93
- package/useCases/UpdateEntryLock/UpdateEntryLockUseCase.js.map +0 -1
- package/useCases/index.d.ts +0 -31
- package/useCases/index.js +0 -96
- package/useCases/index.js.map +0 -1
- package/useCases/types.d.ts +0 -5
- package/useCases/types.js +0 -7
- package/useCases/types.js.map +0 -1
- package/utils/calculateExpiresOn.d.ts +0 -2
- package/utils/calculateExpiresOn.js +0 -16
- package/utils/calculateExpiresOn.js.map +0 -1
- package/utils/checkPermissions.d.ts +0 -7
- package/utils/checkPermissions.js +0 -21
- package/utils/checkPermissions.js.map +0 -1
- package/utils/convertEntryToLockRecord.d.ts +0 -28
- package/utils/convertEntryToLockRecord.js +0 -91
- package/utils/convertEntryToLockRecord.js.map +0 -1
- package/utils/resolve.js +0 -30
- package/utils/resolve.js.map +0 -1
- package/utils/validateSameIdentity.d.ts +0 -6
- package/utils/validateSameIdentity.js +0 -24
- package/utils/validateSameIdentity.js.map +0 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
2
|
+
import type { IEventHandler } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
|
+
import type { ILockRecord } from "../../domain/LockRecord.js";
|
|
4
|
+
import type { LockRecordEntryType } from "../../domain/types.js";
|
|
5
|
+
export interface EntryBeforeLockPayload {
|
|
6
|
+
id: string;
|
|
7
|
+
type: LockRecordEntryType;
|
|
8
|
+
}
|
|
9
|
+
export declare class EntryBeforeLockEvent extends DomainEvent<EntryBeforeLockPayload> {
|
|
10
|
+
eventType: "RecordLocking/Entry/BeforeLock";
|
|
11
|
+
getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryBeforeLockEvent>>;
|
|
12
|
+
}
|
|
13
|
+
export declare const EntryBeforeLockEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryBeforeLockEvent>>;
|
|
14
|
+
export declare namespace EntryBeforeLockEventHandler {
|
|
15
|
+
type Interface = IEventHandler<EntryBeforeLockEvent>;
|
|
16
|
+
type Event = EntryBeforeLockEvent;
|
|
17
|
+
}
|
|
18
|
+
export interface EntryAfterLockPayload {
|
|
19
|
+
id: string;
|
|
20
|
+
type: LockRecordEntryType;
|
|
21
|
+
record: ILockRecord;
|
|
22
|
+
}
|
|
23
|
+
export declare class EntryAfterLockEvent extends DomainEvent<EntryAfterLockPayload> {
|
|
24
|
+
eventType: "RecordLocking/Entry/AfterLock";
|
|
25
|
+
getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryAfterLockEvent>>;
|
|
26
|
+
}
|
|
27
|
+
export declare const EntryAfterLockEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryAfterLockEvent>>;
|
|
28
|
+
export declare namespace EntryAfterLockEventHandler {
|
|
29
|
+
type Interface = IEventHandler<EntryAfterLockEvent>;
|
|
30
|
+
type Event = EntryAfterLockEvent;
|
|
31
|
+
}
|
|
32
|
+
export interface EntryLockErrorPayload {
|
|
33
|
+
id: string;
|
|
34
|
+
type: LockRecordEntryType;
|
|
35
|
+
error: Error;
|
|
36
|
+
}
|
|
37
|
+
export declare class EntryLockErrorEvent extends DomainEvent<EntryLockErrorPayload> {
|
|
38
|
+
eventType: "RecordLocking/Entry/LockError";
|
|
39
|
+
getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryLockErrorEvent>>;
|
|
40
|
+
}
|
|
41
|
+
export declare const EntryLockErrorEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryLockErrorEvent>>;
|
|
42
|
+
export declare namespace EntryLockErrorEventHandler {
|
|
43
|
+
type Interface = IEventHandler<EntryLockErrorEvent>;
|
|
44
|
+
type Event = EntryLockErrorEvent;
|
|
45
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
|
+
class EntryBeforeLockEvent extends DomainEvent {
|
|
4
|
+
getHandlerAbstraction() {
|
|
5
|
+
return EntryBeforeLockEventHandler;
|
|
6
|
+
}
|
|
7
|
+
constructor(...args){
|
|
8
|
+
super(...args), this.eventType = "RecordLocking/Entry/BeforeLock";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const EntryBeforeLockEventHandler = createAbstraction("EntryBeforeLockEventHandler");
|
|
12
|
+
class EntryAfterLockEvent extends DomainEvent {
|
|
13
|
+
getHandlerAbstraction() {
|
|
14
|
+
return EntryAfterLockEventHandler;
|
|
15
|
+
}
|
|
16
|
+
constructor(...args){
|
|
17
|
+
super(...args), this.eventType = "RecordLocking/Entry/AfterLock";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const EntryAfterLockEventHandler = createAbstraction("EntryAfterLockEventHandler");
|
|
21
|
+
class EntryLockErrorEvent extends DomainEvent {
|
|
22
|
+
getHandlerAbstraction() {
|
|
23
|
+
return EntryLockErrorEventHandler;
|
|
24
|
+
}
|
|
25
|
+
constructor(...args){
|
|
26
|
+
super(...args), this.eventType = "RecordLocking/Entry/LockError";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const EntryLockErrorEventHandler = createAbstraction("EntryLockErrorEventHandler");
|
|
30
|
+
export { EntryAfterLockEvent, EntryAfterLockEventHandler, EntryBeforeLockEvent, EntryBeforeLockEventHandler, EntryLockErrorEvent, EntryLockErrorEventHandler };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/LockEntry/events.js","sources":["../../../src/features/LockEntry/events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordEntryType } from \"~/domain/types.js\";\n\n// ============================================================================\n// EntryBeforeLock Event\n// ============================================================================\n\nexport interface EntryBeforeLockPayload {\n id: string;\n type: LockRecordEntryType;\n}\n\nexport class EntryBeforeLockEvent extends DomainEvent<EntryBeforeLockPayload> {\n eventType = \"RecordLocking/Entry/BeforeLock\" as const;\n\n getHandlerAbstraction() {\n return EntryBeforeLockEventHandler;\n }\n}\n\nexport const EntryBeforeLockEventHandler = createAbstraction<IEventHandler<EntryBeforeLockEvent>>(\n \"EntryBeforeLockEventHandler\"\n);\n\nexport namespace EntryBeforeLockEventHandler {\n export type Interface = IEventHandler<EntryBeforeLockEvent>;\n export type Event = EntryBeforeLockEvent;\n}\n\n// ============================================================================\n// EntryAfterLock Event\n// ============================================================================\n\nexport interface EntryAfterLockPayload {\n id: string;\n type: LockRecordEntryType;\n record: ILockRecord;\n}\n\nexport class EntryAfterLockEvent extends DomainEvent<EntryAfterLockPayload> {\n eventType = \"RecordLocking/Entry/AfterLock\" as const;\n\n getHandlerAbstraction() {\n return EntryAfterLockEventHandler;\n }\n}\n\nexport const EntryAfterLockEventHandler = createAbstraction<IEventHandler<EntryAfterLockEvent>>(\n \"EntryAfterLockEventHandler\"\n);\n\nexport namespace EntryAfterLockEventHandler {\n export type Interface = IEventHandler<EntryAfterLockEvent>;\n export type Event = EntryAfterLockEvent;\n}\n\n// ============================================================================\n// EntryLockError Event\n// ============================================================================\n\nexport interface EntryLockErrorPayload {\n id: string;\n type: LockRecordEntryType;\n error: Error;\n}\n\nexport class EntryLockErrorEvent extends DomainEvent<EntryLockErrorPayload> {\n eventType = \"RecordLocking/Entry/LockError\" as const;\n\n getHandlerAbstraction() {\n return EntryLockErrorEventHandler;\n }\n}\n\nexport const EntryLockErrorEventHandler = createAbstraction<IEventHandler<EntryLockErrorEvent>>(\n \"EntryLockErrorEventHandler\"\n);\n\nexport namespace EntryLockErrorEventHandler {\n export type Interface = IEventHandler<EntryLockErrorEvent>;\n export type Event = EntryLockErrorEvent;\n}\n"],"names":["EntryBeforeLockEvent","DomainEvent","EntryBeforeLockEventHandler","createAbstraction","EntryAfterLockEvent","EntryAfterLockEventHandler","EntryLockErrorEvent","EntryLockErrorEventHandler"],"mappings":";;AAeO,MAAMA,6BAA6BC;IAGtC,wBAAwB;QACpB,OAAOC;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB;AAEO,MAAMA,8BAA8BC,kBACvC;AAkBG,MAAMC,4BAA4BH;IAGrC,wBAAwB;QACpB,OAAOI;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB;AAEO,MAAMA,6BAA6BF,kBACtC;AAkBG,MAAMG,4BAA4BL;IAGrC,wBAAwB;QACpB,OAAOM;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB;AAEO,MAAMA,6BAA6BJ,kBACtC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { LockEntryUseCase } from "./LockEntryUseCase.js";
|
|
3
|
+
import { LockEntryRepository } from "./LockEntryRepository.js";
|
|
4
|
+
import { LockEntryEventsDecorator } from "./LockEntryEventsDecorator.js";
|
|
5
|
+
const LockEntryFeature = createFeature({
|
|
6
|
+
name: "LockEntry",
|
|
7
|
+
register (container) {
|
|
8
|
+
container.register(LockEntryUseCase);
|
|
9
|
+
container.register(LockEntryRepository).inSingletonScope();
|
|
10
|
+
container.registerDecorator(LockEntryEventsDecorator);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
export { LockEntryFeature };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/LockEntry/feature.js","sources":["../../../src/features/LockEntry/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { LockEntryUseCase } from \"./LockEntryUseCase.js\";\nimport { LockEntryRepository } from \"./LockEntryRepository.js\";\nimport { LockEntryEventsDecorator } from \"./LockEntryEventsDecorator.js\";\n\nexport const LockEntryFeature = createFeature({\n name: \"LockEntry\",\n register(container) {\n container.register(LockEntryUseCase);\n container.register(LockEntryRepository).inSingletonScope();\n container.registerDecorator(LockEntryEventsDecorator);\n }\n});\n"],"names":["LockEntryFeature","createFeature","container","LockEntryUseCase","LockEntryRepository","LockEntryEventsDecorator"],"mappings":";;;;AAKO,MAAMA,mBAAmBC,cAAc;IAC1C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,qBAAqB,gBAAgB;QACxDF,UAAU,iBAAiB,CAACG;IAChC;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./abstractions.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./abstractions.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CmsModel } from "@webiny/api-headless-cms/types";
|
|
2
|
+
export interface RecordLockingParams {
|
|
3
|
+
/**
|
|
4
|
+
* Timeout in milliseconds after which a lock expires
|
|
5
|
+
*/
|
|
6
|
+
timeout: number;
|
|
7
|
+
/**
|
|
8
|
+
* The CMS model for storing lock records
|
|
9
|
+
*/
|
|
10
|
+
model: CmsModel;
|
|
11
|
+
}
|
|
12
|
+
export declare const RecordLockingFeature: {
|
|
13
|
+
name: string;
|
|
14
|
+
register(container: import("@webiny/di").Container, context: RecordLockingParams): void;
|
|
15
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { RecordLockingConfig, RecordLockingModel } from "../domain/abstractions.js";
|
|
3
|
+
import { GetLockRecordFeature } from "./GetLockRecord/feature.js";
|
|
4
|
+
import { GetLockedEntryLockRecordFeature } from "./GetLockedEntryLockRecord/feature.js";
|
|
5
|
+
import { KickOutCurrentUserFeature } from "./KickOutCurrentUser/feature.js";
|
|
6
|
+
import { ListLockRecordsFeature } from "./ListLockRecords/feature.js";
|
|
7
|
+
import { ListAllLockRecordsFeature } from "./ListAllLockRecords/feature.js";
|
|
8
|
+
import { IsEntryLockedFeature } from "./IsEntryLocked/feature.js";
|
|
9
|
+
import { LockEntryFeature } from "./LockEntry/feature.js";
|
|
10
|
+
import { UpdateEntryLockFeature } from "./UpdateEntryLock/feature.js";
|
|
11
|
+
import { UnlockEntryFeature } from "./UnlockEntry/feature.js";
|
|
12
|
+
import { UnlockEntryRequestFeature } from "./UnlockEntryRequest/feature.js";
|
|
13
|
+
const RecordLockingFeature = createFeature({
|
|
14
|
+
name: "RecordLockingManagement",
|
|
15
|
+
register (container, params) {
|
|
16
|
+
container.registerInstance(RecordLockingConfig, {
|
|
17
|
+
timeout: params.timeout
|
|
18
|
+
});
|
|
19
|
+
container.registerInstance(RecordLockingModel, params.model);
|
|
20
|
+
GetLockRecordFeature.register(container);
|
|
21
|
+
GetLockedEntryLockRecordFeature.register(container);
|
|
22
|
+
KickOutCurrentUserFeature.register(container);
|
|
23
|
+
ListLockRecordsFeature.register(container);
|
|
24
|
+
ListAllLockRecordsFeature.register(container);
|
|
25
|
+
IsEntryLockedFeature.register(container);
|
|
26
|
+
LockEntryFeature.register(container);
|
|
27
|
+
UpdateEntryLockFeature.register(container);
|
|
28
|
+
UnlockEntryFeature.register(container);
|
|
29
|
+
UnlockEntryRequestFeature.register(container);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
export { RecordLockingFeature };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=RecordLockingFeature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/RecordLockingFeature.js","sources":["../../src/features/RecordLockingFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { RecordLockingConfig, RecordLockingModel } from \"~/domain/abstractions.js\";\nimport { GetLockRecordFeature } from \"./GetLockRecord/feature.js\";\nimport { GetLockedEntryLockRecordFeature } from \"./GetLockedEntryLockRecord/feature.js\";\nimport { KickOutCurrentUserFeature } from \"./KickOutCurrentUser/feature.js\";\nimport { ListLockRecordsFeature } from \"./ListLockRecords/feature.js\";\nimport { ListAllLockRecordsFeature } from \"./ListAllLockRecords/feature.js\";\nimport { IsEntryLockedFeature } from \"./IsEntryLocked/feature.js\";\nimport { LockEntryFeature } from \"./LockEntry/feature.js\";\nimport { UpdateEntryLockFeature } from \"./UpdateEntryLock/feature.js\";\nimport { UnlockEntryFeature } from \"./UnlockEntry/feature.js\";\nimport { UnlockEntryRequestFeature } from \"./UnlockEntryRequest/feature.js\";\n\nexport interface RecordLockingParams {\n /**\n * Timeout in milliseconds after which a lock expires\n */\n timeout: number;\n /**\n * The CMS model for storing lock records\n */\n model: CmsModel;\n}\n\nexport const RecordLockingFeature = createFeature<RecordLockingParams>({\n name: \"RecordLockingManagement\",\n register(container, params) {\n // Register domain abstractions\n container.registerInstance(RecordLockingConfig, { timeout: params.timeout });\n container.registerInstance(RecordLockingModel, params.model);\n\n // Register all sub-features\n GetLockRecordFeature.register(container);\n GetLockedEntryLockRecordFeature.register(container);\n KickOutCurrentUserFeature.register(container);\n ListLockRecordsFeature.register(container);\n ListAllLockRecordsFeature.register(container);\n IsEntryLockedFeature.register(container);\n LockEntryFeature.register(container);\n UpdateEntryLockFeature.register(container);\n UnlockEntryFeature.register(container);\n UnlockEntryRequestFeature.register(container);\n }\n});\n"],"names":["RecordLockingFeature","createFeature","container","params","RecordLockingConfig","RecordLockingModel","GetLockRecordFeature","GetLockedEntryLockRecordFeature","KickOutCurrentUserFeature","ListLockRecordsFeature","ListAllLockRecordsFeature","IsEntryLockedFeature","LockEntryFeature","UpdateEntryLockFeature","UnlockEntryFeature","UnlockEntryRequestFeature"],"mappings":";;;;;;;;;;;;AAyBO,MAAMA,uBAAuBC,cAAmC;IACnE,MAAM;IACN,UAASC,SAAS,EAAEC,MAAM;QAEtBD,UAAU,gBAAgB,CAACE,qBAAqB;YAAE,SAASD,OAAO,OAAO;QAAC;QAC1ED,UAAU,gBAAgB,CAACG,oBAAoBF,OAAO,KAAK;QAG3DG,qBAAqB,QAAQ,CAACJ;QAC9BK,gCAAgC,QAAQ,CAACL;QACzCM,0BAA0B,QAAQ,CAACN;QACnCO,uBAAuB,QAAQ,CAACP;QAChCQ,0BAA0B,QAAQ,CAACR;QACnCS,qBAAqB,QAAQ,CAACT;QAC9BU,iBAAiB,QAAQ,CAACV;QAC1BW,uBAAuB,QAAQ,CAACX;QAChCY,mBAAmB,QAAQ,CAACZ;QAC5Ba,0BAA0B,QAAQ,CAACb;IACvC;AACJ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type UnlockEntryInput, UnlockEntryUseCase as UseCaseAbstraction, UnlockEntryUseCase } from "./abstractions.js";
|
|
2
|
+
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
|
+
import type { ILockRecord } from "../../domain/index.js";
|
|
4
|
+
import { Result } from "@webiny/feature/api/index.js";
|
|
5
|
+
declare class UnlockEntryEventsDecoratorImpl implements UnlockEntryUseCase.Interface {
|
|
6
|
+
private readonly eventPublisher;
|
|
7
|
+
private readonly decoratee;
|
|
8
|
+
constructor(eventPublisher: EventPublisher.Interface, decoratee: UnlockEntryUseCase.Interface);
|
|
9
|
+
execute(input: UnlockEntryInput): Promise<Result<ILockRecord, UseCaseAbstraction.Error>>;
|
|
10
|
+
}
|
|
11
|
+
export declare const UnlockEntryEventsDecorator: typeof UnlockEntryEventsDecoratorImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IUnlockEntryUseCase>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { UnlockEntryUseCase } from "./abstractions.js";
|
|
2
|
+
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
|
+
import { EntryAfterUnlockEvent, EntryBeforeUnlockEvent, EntryUnlockErrorEvent } from "./events.js";
|
|
4
|
+
class UnlockEntryEventsDecoratorImpl {
|
|
5
|
+
constructor(eventPublisher, decoratee){
|
|
6
|
+
this.eventPublisher = eventPublisher;
|
|
7
|
+
this.decoratee = decoratee;
|
|
8
|
+
}
|
|
9
|
+
async execute(input) {
|
|
10
|
+
await this.eventPublisher.publish(new EntryBeforeUnlockEvent({
|
|
11
|
+
id: input.id,
|
|
12
|
+
type: input.type,
|
|
13
|
+
force: input.force
|
|
14
|
+
}));
|
|
15
|
+
const result = await this.decoratee.execute(input);
|
|
16
|
+
if (result.isFail()) {
|
|
17
|
+
const error = result.error;
|
|
18
|
+
await this.eventPublisher.publish(new EntryUnlockErrorEvent({
|
|
19
|
+
id: input.id,
|
|
20
|
+
type: input.type,
|
|
21
|
+
error
|
|
22
|
+
}));
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
await this.eventPublisher.publish(new EntryAfterUnlockEvent({
|
|
26
|
+
id: input.id,
|
|
27
|
+
type: input.type,
|
|
28
|
+
record: result.value
|
|
29
|
+
}));
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const UnlockEntryEventsDecorator = UnlockEntryUseCase.createDecorator({
|
|
34
|
+
decorator: UnlockEntryEventsDecoratorImpl,
|
|
35
|
+
dependencies: [
|
|
36
|
+
EventPublisher
|
|
37
|
+
]
|
|
38
|
+
});
|
|
39
|
+
export { UnlockEntryEventsDecorator };
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=UnlockEntryEventsDecorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/UnlockEntry/UnlockEntryEventsDecorator.js","sources":["../../../src/features/UnlockEntry/UnlockEntryEventsDecorator.ts"],"sourcesContent":["import {\n type UnlockEntryInput,\n UnlockEntryUseCase as UseCaseAbstraction,\n UnlockEntryUseCase\n} from \"./abstractions.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { ILockRecord } from \"~/domain/index.js\";\nimport { Result } from \"@webiny/feature/api/index.js\";\nimport { EntryAfterUnlockEvent, EntryBeforeUnlockEvent, EntryUnlockErrorEvent } from \"./events.js\";\n\nclass UnlockEntryEventsDecoratorImpl implements UnlockEntryUseCase.Interface {\n constructor(\n private readonly eventPublisher: EventPublisher.Interface,\n private readonly decoratee: UnlockEntryUseCase.Interface\n ) {}\n\n async execute(input: UnlockEntryInput): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Publish before event\n await this.eventPublisher.publish(\n new EntryBeforeUnlockEvent({\n id: input.id,\n type: input.type,\n force: input.force\n })\n );\n\n const result = await this.decoratee.execute(input);\n\n if (result.isFail()) {\n const error = result.error;\n\n await this.eventPublisher.publish(\n new EntryUnlockErrorEvent({\n id: input.id,\n type: input.type,\n error\n })\n );\n\n return result;\n }\n\n // Publish after event\n await this.eventPublisher.publish(\n new EntryAfterUnlockEvent({\n id: input.id,\n type: input.type,\n record: result.value\n })\n );\n\n return result;\n }\n}\n\nexport const UnlockEntryEventsDecorator = UnlockEntryUseCase.createDecorator({\n decorator: UnlockEntryEventsDecoratorImpl,\n dependencies: [EventPublisher]\n});\n"],"names":["UnlockEntryEventsDecoratorImpl","eventPublisher","decoratee","input","EntryBeforeUnlockEvent","result","error","EntryUnlockErrorEvent","EntryAfterUnlockEvent","UnlockEntryEventsDecorator","UnlockEntryUseCase","EventPublisher"],"mappings":";;;AAUA,MAAMA;IACF,YACqBC,cAAwC,EACxCC,SAAuC,CAC1D;aAFmBD,cAAc,GAAdA;aACAC,SAAS,GAATA;IAClB;IAEH,MAAM,QAAQC,KAAuB,EAA0D;QAE3F,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIC,uBAAuB;YACvB,IAAID,MAAM,EAAE;YACZ,MAAMA,MAAM,IAAI;YAChB,OAAOA,MAAM,KAAK;QACtB;QAGJ,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACF;QAE5C,IAAIE,OAAO,MAAM,IAAI;YACjB,MAAMC,QAAQD,OAAO,KAAK;YAE1B,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIE,sBAAsB;gBACtB,IAAIJ,MAAM,EAAE;gBACZ,MAAMA,MAAM,IAAI;gBAChBG;YACJ;YAGJ,OAAOD;QACX;QAGA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIG,sBAAsB;YACtB,IAAIL,MAAM,EAAE;YACZ,MAAMA,MAAM,IAAI;YAChB,QAAQE,OAAO,KAAK;QACxB;QAGJ,OAAOA;IACX;AACJ;AAEO,MAAMI,6BAA6BC,mBAAmB,eAAe,CAAC;IACzE,WAAWV;IACX,cAAc;QAACW;KAAe;AAClC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { DeleteEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/DeleteEntry";
|
|
3
|
+
import { UnlockEntryRepository as RepositoryAbstraction } from "./abstractions.js";
|
|
4
|
+
import { RecordLockingModel } from "../../domain/abstractions.js";
|
|
5
|
+
declare class UnlockEntryRepositoryImpl implements RepositoryAbstraction.Interface {
|
|
6
|
+
private model;
|
|
7
|
+
private deleteEntry;
|
|
8
|
+
constructor(model: RecordLockingModel.Interface, deleteEntry: DeleteEntryUseCase.Interface);
|
|
9
|
+
delete(lockRecordId: string): Promise<Result<void, RepositoryAbstraction.Error>>;
|
|
10
|
+
}
|
|
11
|
+
export declare const UnlockEntryRepository: typeof UnlockEntryRepositoryImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IUnlockEntryRepository>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { DeleteEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/DeleteEntry";
|
|
3
|
+
import { createIdentifier } from "@webiny/utils";
|
|
4
|
+
import { UnlockEntryRepository } from "./abstractions.js";
|
|
5
|
+
import { RecordLockingModel } from "../../domain/abstractions.js";
|
|
6
|
+
import { LockRecordNotFoundError, UnlockEntryError } from "../../domain/errors.js";
|
|
7
|
+
import { createLockRecordDatabaseId } from "../../utils/lockRecordDatabaseId.js";
|
|
8
|
+
class UnlockEntryRepositoryImpl {
|
|
9
|
+
constructor(model, deleteEntry){
|
|
10
|
+
this.model = model;
|
|
11
|
+
this.deleteEntry = deleteEntry;
|
|
12
|
+
}
|
|
13
|
+
async delete(lockRecordId) {
|
|
14
|
+
try {
|
|
15
|
+
const entryId = createLockRecordDatabaseId(lockRecordId);
|
|
16
|
+
const id = createIdentifier({
|
|
17
|
+
id: entryId,
|
|
18
|
+
version: 1
|
|
19
|
+
});
|
|
20
|
+
const result = await this.deleteEntry.execute(this.model, id, {
|
|
21
|
+
permanently: true
|
|
22
|
+
});
|
|
23
|
+
if (result.isFail()) {
|
|
24
|
+
if ("Cms/Entry/NotFound" === result.error.code) return Result.fail(new LockRecordNotFoundError());
|
|
25
|
+
return Result.fail(new UnlockEntryError(result.error));
|
|
26
|
+
}
|
|
27
|
+
return Result.ok();
|
|
28
|
+
} catch (error) {
|
|
29
|
+
return Result.fail(new UnlockEntryError(error));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const UnlockEntryRepository_UnlockEntryRepository = UnlockEntryRepository.createImplementation({
|
|
34
|
+
implementation: UnlockEntryRepositoryImpl,
|
|
35
|
+
dependencies: [
|
|
36
|
+
RecordLockingModel,
|
|
37
|
+
DeleteEntryUseCase
|
|
38
|
+
]
|
|
39
|
+
});
|
|
40
|
+
export { UnlockEntryRepository_UnlockEntryRepository as UnlockEntryRepository };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=UnlockEntryRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/UnlockEntry/UnlockEntryRepository.js","sources":["../../../src/features/UnlockEntry/UnlockEntryRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { DeleteEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/DeleteEntry\";\nimport { createIdentifier } from \"@webiny/utils\";\nimport { UnlockEntryRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { RecordLockingModel } from \"~/domain/abstractions.js\";\nimport { LockRecordNotFoundError, UnlockEntryError } from \"~/domain/errors.js\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId.js\";\n\nclass UnlockEntryRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private model: RecordLockingModel.Interface,\n private deleteEntry: DeleteEntryUseCase.Interface\n ) {}\n\n async delete(lockRecordId: string): Promise<Result<void, RepositoryAbstraction.Error>> {\n try {\n const entryId = createLockRecordDatabaseId(lockRecordId);\n const id = createIdentifier({\n id: entryId,\n version: 1\n });\n\n const result = await this.deleteEntry.execute(this.model, id, {\n permanently: true\n });\n\n if (result.isFail()) {\n if (result.error.code === \"Cms/Entry/NotFound\") {\n return Result.fail(new LockRecordNotFoundError());\n }\n return Result.fail(new UnlockEntryError(result.error));\n }\n\n return Result.ok();\n } catch (error) {\n return Result.fail(new UnlockEntryError(error as Error));\n }\n }\n}\n\nexport const UnlockEntryRepository = RepositoryAbstraction.createImplementation({\n implementation: UnlockEntryRepositoryImpl,\n dependencies: [RecordLockingModel, DeleteEntryUseCase]\n});\n"],"names":["UnlockEntryRepositoryImpl","model","deleteEntry","lockRecordId","entryId","createLockRecordDatabaseId","id","createIdentifier","result","Result","LockRecordNotFoundError","UnlockEntryError","error","UnlockEntryRepository","RepositoryAbstraction","RecordLockingModel","DeleteEntryUseCase"],"mappings":";;;;;;;AAQA,MAAMA;IACF,YACYC,KAAmC,EACnCC,WAAyC,CACnD;aAFUD,KAAK,GAALA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,OAAOC,YAAoB,EAAsD;QACnF,IAAI;YACA,MAAMC,UAAUC,2BAA2BF;YAC3C,MAAMG,KAAKC,iBAAiB;gBACxB,IAAIH;gBACJ,SAAS;YACb;YAEA,MAAMI,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAEF,IAAI;gBAC1D,aAAa;YACjB;YAEA,IAAIE,OAAO,MAAM,IAAI;gBACjB,IAAIA,AAAsB,yBAAtBA,OAAO,KAAK,CAAC,IAAI,EACjB,OAAOC,OAAO,IAAI,CAAC,IAAIC;gBAE3B,OAAOD,OAAO,IAAI,CAAC,IAAIE,iBAAiBH,OAAO,KAAK;YACxD;YAEA,OAAOC,OAAO,EAAE;QACpB,EAAE,OAAOG,OAAO;YACZ,OAAOH,OAAO,IAAI,CAAC,IAAIE,iBAAiBC;QAC5C;IACJ;AACJ;AAEO,MAAMC,8CAAwBC,sBAAAA,oBAA0C,CAAC;IAC5E,gBAAgBd;IAChB,cAAc;QAACe;QAAoBC;KAAmB;AAC1D"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { UnlockEntryUseCase as UseCaseAbstraction, UnlockEntryRepository, UnlockEntryInput } from "./abstractions.js";
|
|
3
|
+
import { GetLockRecordUseCase } from "../GetLockRecord/abstractions.js";
|
|
4
|
+
import { KickOutCurrentUserUseCase } from "../KickOutCurrentUser/abstractions.js";
|
|
5
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
6
|
+
import type { ILockRecord } from "../../domain/LockRecord.js";
|
|
7
|
+
declare class UnlockEntryUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
8
|
+
private getLockRecord;
|
|
9
|
+
private kickOutCurrentUser;
|
|
10
|
+
private repository;
|
|
11
|
+
private identityContext;
|
|
12
|
+
constructor(getLockRecord: GetLockRecordUseCase.Interface, kickOutCurrentUser: KickOutCurrentUserUseCase.Interface, repository: UnlockEntryRepository.Interface, identityContext: IdentityContext.Interface);
|
|
13
|
+
execute(input: UnlockEntryInput): Promise<Result<ILockRecord, UseCaseAbstraction.Error>>;
|
|
14
|
+
}
|
|
15
|
+
export declare const UnlockEntryUseCase: typeof UnlockEntryUseCaseImpl & {
|
|
16
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IUnlockEntryUseCase>;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { UnlockEntryRepository, UnlockEntryUseCase } from "./abstractions.js";
|
|
3
|
+
import { GetLockRecordUseCase } from "../GetLockRecord/abstractions.js";
|
|
4
|
+
import { KickOutCurrentUserUseCase } from "../KickOutCurrentUser/abstractions.js";
|
|
5
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
6
|
+
import { IdentityMismatchError, LockRecordNotFoundError } from "../../domain/errors.js";
|
|
7
|
+
import { hasFullAccessPermission } from "./hasFullAccessPermission.js";
|
|
8
|
+
class UnlockEntryUseCaseImpl {
|
|
9
|
+
constructor(getLockRecord, kickOutCurrentUser, repository, identityContext){
|
|
10
|
+
this.getLockRecord = getLockRecord;
|
|
11
|
+
this.kickOutCurrentUser = kickOutCurrentUser;
|
|
12
|
+
this.repository = repository;
|
|
13
|
+
this.identityContext = identityContext;
|
|
14
|
+
}
|
|
15
|
+
async execute(input) {
|
|
16
|
+
const recordResult = await this.getLockRecord.execute(input);
|
|
17
|
+
if (recordResult.isFail()) {
|
|
18
|
+
if (recordResult.error instanceof LockRecordNotFoundError) await this.repository.delete(input.id);
|
|
19
|
+
return Result.fail(recordResult.error);
|
|
20
|
+
}
|
|
21
|
+
const record = recordResult.value;
|
|
22
|
+
if (record.isExpired()) {
|
|
23
|
+
await this.repository.delete(record.id);
|
|
24
|
+
const error = new LockRecordNotFoundError();
|
|
25
|
+
return Result.fail(error);
|
|
26
|
+
}
|
|
27
|
+
const identity = this.identityContext.getIdentity();
|
|
28
|
+
const isSameUser = record.lockedBy.id === identity.id;
|
|
29
|
+
let shouldKickOut = false;
|
|
30
|
+
if (!isSameUser) {
|
|
31
|
+
if (!input.force) {
|
|
32
|
+
const error = new IdentityMismatchError({
|
|
33
|
+
currentId: identity.id,
|
|
34
|
+
targetId: record.lockedBy.id
|
|
35
|
+
});
|
|
36
|
+
return Result.fail(error);
|
|
37
|
+
}
|
|
38
|
+
const hasAccess = await hasFullAccessPermission(this.identityContext);
|
|
39
|
+
if (!hasAccess) {
|
|
40
|
+
const error = new IdentityMismatchError({
|
|
41
|
+
currentId: identity.id,
|
|
42
|
+
targetId: record.lockedBy.id
|
|
43
|
+
});
|
|
44
|
+
return Result.fail(error);
|
|
45
|
+
}
|
|
46
|
+
shouldKickOut = true;
|
|
47
|
+
}
|
|
48
|
+
const deleteResult = await this.repository.delete(record.id);
|
|
49
|
+
if (deleteResult.isFail()) return Result.fail(deleteResult.error);
|
|
50
|
+
if (shouldKickOut) await this.kickOutCurrentUser.execute(record);
|
|
51
|
+
return Result.ok(record);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const UnlockEntryUseCase_UnlockEntryUseCase = UnlockEntryUseCase.createImplementation({
|
|
55
|
+
implementation: UnlockEntryUseCaseImpl,
|
|
56
|
+
dependencies: [
|
|
57
|
+
GetLockRecordUseCase,
|
|
58
|
+
KickOutCurrentUserUseCase,
|
|
59
|
+
UnlockEntryRepository,
|
|
60
|
+
IdentityContext
|
|
61
|
+
]
|
|
62
|
+
});
|
|
63
|
+
export { UnlockEntryUseCase_UnlockEntryUseCase as UnlockEntryUseCase };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=UnlockEntryUseCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/UnlockEntry/UnlockEntryUseCase.js","sources":["../../../src/features/UnlockEntry/UnlockEntryUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n UnlockEntryUseCase as UseCaseAbstraction,\n UnlockEntryRepository,\n UnlockEntryInput\n} from \"./abstractions.js\";\nimport { GetLockRecordUseCase } from \"../GetLockRecord/abstractions.js\";\nimport { KickOutCurrentUserUseCase } from \"../KickOutCurrentUser/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport { LockRecordNotFoundError, IdentityMismatchError } from \"~/domain/errors.js\";\nimport { hasFullAccessPermission } from \"./hasFullAccessPermission.js\";\n\nclass UnlockEntryUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getLockRecord: GetLockRecordUseCase.Interface,\n private kickOutCurrentUser: KickOutCurrentUserUseCase.Interface,\n private repository: UnlockEntryRepository.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute(input: UnlockEntryInput): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Get the lock record\n const recordResult = await this.getLockRecord.execute(input);\n\n // If not found or expired, attempt cleanup and return error\n if (recordResult.isFail()) {\n if (recordResult.error instanceof LockRecordNotFoundError) {\n // Try to cleanup any stale data\n await this.repository.delete(input.id);\n }\n\n return Result.fail(recordResult.error);\n }\n\n const record = recordResult.value;\n\n // If expired, cleanup and return error\n if (record.isExpired()) {\n await this.repository.delete(record.id);\n const error = new LockRecordNotFoundError();\n return Result.fail(error);\n }\n\n // Check if user is the owner\n const identity = this.identityContext.getIdentity();\n const isSameUser = record.lockedBy.id === identity.id;\n\n let shouldKickOut = false;\n\n // If not the owner, check if force unlock is allowed\n if (!isSameUser) {\n if (!input.force) {\n const error = new IdentityMismatchError({\n currentId: identity.id,\n targetId: record.lockedBy.id\n });\n return Result.fail(error);\n }\n\n // Check if user has permission to force unlock\n const hasAccess = await hasFullAccessPermission(this.identityContext);\n if (!hasAccess) {\n const error = new IdentityMismatchError({\n currentId: identity.id,\n targetId: record.lockedBy.id\n });\n return Result.fail(error);\n }\n\n shouldKickOut = true;\n }\n\n // Delete the lock record\n const deleteResult = await this.repository.delete(record.id);\n\n if (deleteResult.isFail()) {\n return Result.fail(deleteResult.error);\n }\n\n // If forced by another user, kick out the original lock owner\n if (shouldKickOut) {\n await this.kickOutCurrentUser.execute(record);\n }\n\n return Result.ok(record);\n }\n}\n\nexport const UnlockEntryUseCase = UseCaseAbstraction.createImplementation({\n implementation: UnlockEntryUseCaseImpl,\n dependencies: [\n GetLockRecordUseCase,\n KickOutCurrentUserUseCase,\n UnlockEntryRepository,\n IdentityContext\n ]\n});\n"],"names":["UnlockEntryUseCaseImpl","getLockRecord","kickOutCurrentUser","repository","identityContext","input","recordResult","LockRecordNotFoundError","Result","record","error","identity","isSameUser","shouldKickOut","IdentityMismatchError","hasAccess","hasFullAccessPermission","deleteResult","UnlockEntryUseCase","UseCaseAbstraction","GetLockRecordUseCase","KickOutCurrentUserUseCase","UnlockEntryRepository","IdentityContext"],"mappings":";;;;;;;AAaA,MAAMA;IACF,YACYC,aAA6C,EAC7CC,kBAAuD,EACvDC,UAA2C,EAC3CC,eAA0C,CACpD;aAJUH,aAAa,GAAbA;aACAC,kBAAkB,GAAlBA;aACAC,UAAU,GAAVA;aACAC,eAAe,GAAfA;IACT;IAEH,MAAM,QAAQC,KAAuB,EAA0D;QAE3F,MAAMC,eAAe,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAACD;QAGtD,IAAIC,aAAa,MAAM,IAAI;YACvB,IAAIA,aAAa,KAAK,YAAYC,yBAE9B,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAACF,MAAM,EAAE;YAGzC,OAAOG,OAAO,IAAI,CAACF,aAAa,KAAK;QACzC;QAEA,MAAMG,SAASH,aAAa,KAAK;QAGjC,IAAIG,OAAO,SAAS,IAAI;YACpB,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAACA,OAAO,EAAE;YACtC,MAAMC,QAAQ,IAAIH;YAClB,OAAOC,OAAO,IAAI,CAACE;QACvB;QAGA,MAAMC,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;QACjD,MAAMC,aAAaH,OAAO,QAAQ,CAAC,EAAE,KAAKE,SAAS,EAAE;QAErD,IAAIE,gBAAgB;QAGpB,IAAI,CAACD,YAAY;YACb,IAAI,CAACP,MAAM,KAAK,EAAE;gBACd,MAAMK,QAAQ,IAAII,sBAAsB;oBACpC,WAAWH,SAAS,EAAE;oBACtB,UAAUF,OAAO,QAAQ,CAAC,EAAE;gBAChC;gBACA,OAAOD,OAAO,IAAI,CAACE;YACvB;YAGA,MAAMK,YAAY,MAAMC,wBAAwB,IAAI,CAAC,eAAe;YACpE,IAAI,CAACD,WAAW;gBACZ,MAAML,QAAQ,IAAII,sBAAsB;oBACpC,WAAWH,SAAS,EAAE;oBACtB,UAAUF,OAAO,QAAQ,CAAC,EAAE;gBAChC;gBACA,OAAOD,OAAO,IAAI,CAACE;YACvB;YAEAG,gBAAgB;QACpB;QAGA,MAAMI,eAAe,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAACR,OAAO,EAAE;QAE3D,IAAIQ,aAAa,MAAM,IACnB,OAAOT,OAAO,IAAI,CAACS,aAAa,KAAK;QAIzC,IAAIJ,eACA,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAACJ;QAG1C,OAAOD,OAAO,EAAE,CAACC;IACrB;AACJ;AAEO,MAAMS,wCAAqBC,mBAAAA,oBAAuC,CAAC;IACtE,gBAAgBnB;IAChB,cAAc;QACVoB;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import type { ILockRecord } from "../../domain/LockRecord.js";
|
|
3
|
+
import type { LockRecordEntryType } from "../../domain/types.js";
|
|
4
|
+
import { type LockRecordNotFoundError, LockRecordPersistenceError, type IdentityMismatchError, type UnlockEntryError } from "../../domain/errors.js";
|
|
5
|
+
export interface UnlockEntryInput {
|
|
6
|
+
id: string;
|
|
7
|
+
type: LockRecordEntryType;
|
|
8
|
+
force?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* UnlockEntry Use Case - Unlocks an entry by deleting the lock record
|
|
12
|
+
*/
|
|
13
|
+
export interface IUnlockEntryUseCase {
|
|
14
|
+
execute(input: UnlockEntryInput): Promise<Result<ILockRecord, UseCaseError>>;
|
|
15
|
+
}
|
|
16
|
+
export interface IUnlockEntryUseCaseErrors {
|
|
17
|
+
notFound: LockRecordNotFoundError;
|
|
18
|
+
notSameIdentity: IdentityMismatchError;
|
|
19
|
+
unlockError: UnlockEntryError;
|
|
20
|
+
persistence: LockRecordPersistenceError;
|
|
21
|
+
}
|
|
22
|
+
type UseCaseError = IUnlockEntryUseCaseErrors[keyof IUnlockEntryUseCaseErrors];
|
|
23
|
+
export declare const UnlockEntryUseCase: import("@webiny/di").Abstraction<IUnlockEntryUseCase>;
|
|
24
|
+
export declare namespace UnlockEntryUseCase {
|
|
25
|
+
type Interface = IUnlockEntryUseCase;
|
|
26
|
+
type Error = UseCaseError;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* UnlockEntryRepository - Deletes lock record from storage
|
|
30
|
+
*/
|
|
31
|
+
export interface IUnlockEntryRepository {
|
|
32
|
+
delete(lockRecordId: string): Promise<Result<void, RepositoryError>>;
|
|
33
|
+
}
|
|
34
|
+
export interface IUnlockEntryRepositoryErrors {
|
|
35
|
+
notFound: LockRecordNotFoundError;
|
|
36
|
+
unlockError: UnlockEntryError;
|
|
37
|
+
}
|
|
38
|
+
type RepositoryError = IUnlockEntryRepositoryErrors[keyof IUnlockEntryRepositoryErrors];
|
|
39
|
+
export declare const UnlockEntryRepository: import("@webiny/di").Abstraction<IUnlockEntryRepository>;
|
|
40
|
+
export declare namespace UnlockEntryRepository {
|
|
41
|
+
type Interface = IUnlockEntryRepository;
|
|
42
|
+
type Error = RepositoryError;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
const UnlockEntryUseCase = createAbstraction("UnlockEntryUseCase");
|
|
3
|
+
const UnlockEntryRepository = createAbstraction("UnlockEntryRepository");
|
|
4
|
+
export { UnlockEntryRepository, UnlockEntryUseCase };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=abstractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/UnlockEntry/abstractions.js","sources":["../../../src/features/UnlockEntry/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordEntryType } from \"~/domain/types.js\";\nimport {\n type LockRecordNotFoundError,\n LockRecordPersistenceError,\n type IdentityMismatchError,\n type UnlockEntryError\n} from \"~/domain/errors.js\";\n\n// Input types\nexport interface UnlockEntryInput {\n id: string;\n type: LockRecordEntryType;\n force?: boolean;\n}\n\n/**\n * UnlockEntry Use Case - Unlocks an entry by deleting the lock record\n */\nexport interface IUnlockEntryUseCase {\n execute(input: UnlockEntryInput): Promise<Result<ILockRecord, UseCaseError>>;\n}\n\nexport interface IUnlockEntryUseCaseErrors {\n notFound: LockRecordNotFoundError;\n notSameIdentity: IdentityMismatchError;\n unlockError: UnlockEntryError;\n persistence: LockRecordPersistenceError;\n}\n\ntype UseCaseError = IUnlockEntryUseCaseErrors[keyof IUnlockEntryUseCaseErrors];\n\nexport const UnlockEntryUseCase = createAbstraction<IUnlockEntryUseCase>(\"UnlockEntryUseCase\");\n\nexport namespace UnlockEntryUseCase {\n export type Interface = IUnlockEntryUseCase;\n export type Error = UseCaseError;\n}\n\n/**\n * UnlockEntryRepository - Deletes lock record from storage\n */\nexport interface IUnlockEntryRepository {\n delete(lockRecordId: string): Promise<Result<void, RepositoryError>>;\n}\n\nexport interface IUnlockEntryRepositoryErrors {\n notFound: LockRecordNotFoundError;\n unlockError: UnlockEntryError;\n}\n\ntype RepositoryError = IUnlockEntryRepositoryErrors[keyof IUnlockEntryRepositoryErrors];\n\nexport const UnlockEntryRepository =\n createAbstraction<IUnlockEntryRepository>(\"UnlockEntryRepository\");\n\nexport namespace UnlockEntryRepository {\n export type Interface = IUnlockEntryRepository;\n export type Error = RepositoryError;\n}\n"],"names":["UnlockEntryUseCase","createAbstraction","UnlockEntryRepository"],"mappings":";AAkCO,MAAMA,qBAAqBC,kBAAuC;AAqBlE,MAAMC,wBACTD,kBAA0C"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
2
|
+
import type { IEventHandler } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
|
+
import type { ILockRecord } from "../../domain/LockRecord.js";
|
|
4
|
+
import type { LockRecordEntryType } from "../../domain/types.js";
|
|
5
|
+
export interface EntryBeforeUnlockPayload {
|
|
6
|
+
id: string;
|
|
7
|
+
type: LockRecordEntryType;
|
|
8
|
+
force?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare class EntryBeforeUnlockEvent extends DomainEvent<EntryBeforeUnlockPayload> {
|
|
11
|
+
eventType: "RecordLocking/Entry/BeforeUnlock";
|
|
12
|
+
getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryBeforeUnlockEvent>>;
|
|
13
|
+
}
|
|
14
|
+
export declare const EntryBeforeUnlockEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryBeforeUnlockEvent>>;
|
|
15
|
+
export declare namespace EntryBeforeUnlockEventHandler {
|
|
16
|
+
type Interface = IEventHandler<EntryBeforeUnlockEvent>;
|
|
17
|
+
type Event = EntryBeforeUnlockEvent;
|
|
18
|
+
}
|
|
19
|
+
export interface EntryAfterUnlockPayload {
|
|
20
|
+
id: string;
|
|
21
|
+
type: LockRecordEntryType;
|
|
22
|
+
record: ILockRecord;
|
|
23
|
+
}
|
|
24
|
+
export declare class EntryAfterUnlockEvent extends DomainEvent<EntryAfterUnlockPayload> {
|
|
25
|
+
eventType: "RecordLocking/Entry/AfterUnlock";
|
|
26
|
+
getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryAfterUnlockEvent>>;
|
|
27
|
+
}
|
|
28
|
+
export declare const EntryAfterUnlockEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryAfterUnlockEvent>>;
|
|
29
|
+
export declare namespace EntryAfterUnlockEventHandler {
|
|
30
|
+
type Interface = IEventHandler<EntryAfterUnlockEvent>;
|
|
31
|
+
type Event = EntryAfterUnlockEvent;
|
|
32
|
+
}
|
|
33
|
+
export interface EntryUnlockErrorPayload {
|
|
34
|
+
id: string;
|
|
35
|
+
type: LockRecordEntryType;
|
|
36
|
+
error: Error;
|
|
37
|
+
}
|
|
38
|
+
export declare class EntryUnlockErrorEvent extends DomainEvent<EntryUnlockErrorPayload> {
|
|
39
|
+
eventType: "RecordLocking/Entry/UnlockError";
|
|
40
|
+
getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryUnlockErrorEvent>>;
|
|
41
|
+
}
|
|
42
|
+
export declare const EntryUnlockErrorEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryUnlockErrorEvent>>;
|
|
43
|
+
export declare namespace EntryUnlockErrorEventHandler {
|
|
44
|
+
type Interface = IEventHandler<EntryUnlockErrorEvent>;
|
|
45
|
+
type Event = EntryUnlockErrorEvent;
|
|
46
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
|
+
class EntryBeforeUnlockEvent extends DomainEvent {
|
|
4
|
+
getHandlerAbstraction() {
|
|
5
|
+
return EntryBeforeUnlockEventHandler;
|
|
6
|
+
}
|
|
7
|
+
constructor(...args){
|
|
8
|
+
super(...args), this.eventType = "RecordLocking/Entry/BeforeUnlock";
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const EntryBeforeUnlockEventHandler = createAbstraction("EntryBeforeUnlockEventHandler");
|
|
12
|
+
class EntryAfterUnlockEvent extends DomainEvent {
|
|
13
|
+
getHandlerAbstraction() {
|
|
14
|
+
return EntryAfterUnlockEventHandler;
|
|
15
|
+
}
|
|
16
|
+
constructor(...args){
|
|
17
|
+
super(...args), this.eventType = "RecordLocking/Entry/AfterUnlock";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const EntryAfterUnlockEventHandler = createAbstraction("EntryAfterUnlockEventHandler");
|
|
21
|
+
class EntryUnlockErrorEvent extends DomainEvent {
|
|
22
|
+
getHandlerAbstraction() {
|
|
23
|
+
return EntryUnlockErrorEventHandler;
|
|
24
|
+
}
|
|
25
|
+
constructor(...args){
|
|
26
|
+
super(...args), this.eventType = "RecordLocking/Entry/UnlockError";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const EntryUnlockErrorEventHandler = createAbstraction("EntryUnlockErrorEventHandler");
|
|
30
|
+
export { EntryAfterUnlockEvent, EntryAfterUnlockEventHandler, EntryBeforeUnlockEvent, EntryBeforeUnlockEventHandler, EntryUnlockErrorEvent, EntryUnlockErrorEventHandler };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/UnlockEntry/events.js","sources":["../../../src/features/UnlockEntry/events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordEntryType } from \"~/domain/types.js\";\n\n// ============================================================================\n// EntryBeforeUnlock Event\n// ============================================================================\n\nexport interface EntryBeforeUnlockPayload {\n id: string;\n type: LockRecordEntryType;\n force?: boolean;\n}\n\nexport class EntryBeforeUnlockEvent extends DomainEvent<EntryBeforeUnlockPayload> {\n eventType = \"RecordLocking/Entry/BeforeUnlock\" as const;\n\n getHandlerAbstraction() {\n return EntryBeforeUnlockEventHandler;\n }\n}\n\nexport const EntryBeforeUnlockEventHandler = createAbstraction<\n IEventHandler<EntryBeforeUnlockEvent>\n>(\"EntryBeforeUnlockEventHandler\");\n\nexport namespace EntryBeforeUnlockEventHandler {\n export type Interface = IEventHandler<EntryBeforeUnlockEvent>;\n export type Event = EntryBeforeUnlockEvent;\n}\n\n// ============================================================================\n// EntryAfterUnlock Event\n// ============================================================================\n\nexport interface EntryAfterUnlockPayload {\n id: string;\n type: LockRecordEntryType;\n record: ILockRecord;\n}\n\nexport class EntryAfterUnlockEvent extends DomainEvent<EntryAfterUnlockPayload> {\n eventType = \"RecordLocking/Entry/AfterUnlock\" as const;\n\n getHandlerAbstraction() {\n return EntryAfterUnlockEventHandler;\n }\n}\n\nexport const EntryAfterUnlockEventHandler = createAbstraction<IEventHandler<EntryAfterUnlockEvent>>(\n \"EntryAfterUnlockEventHandler\"\n);\n\nexport namespace EntryAfterUnlockEventHandler {\n export type Interface = IEventHandler<EntryAfterUnlockEvent>;\n export type Event = EntryAfterUnlockEvent;\n}\n\n// ============================================================================\n// EntryUnlockError Event\n// ============================================================================\n\nexport interface EntryUnlockErrorPayload {\n id: string;\n type: LockRecordEntryType;\n error: Error;\n}\n\nexport class EntryUnlockErrorEvent extends DomainEvent<EntryUnlockErrorPayload> {\n eventType = \"RecordLocking/Entry/UnlockError\" as const;\n\n getHandlerAbstraction() {\n return EntryUnlockErrorEventHandler;\n }\n}\n\nexport const EntryUnlockErrorEventHandler = createAbstraction<IEventHandler<EntryUnlockErrorEvent>>(\n \"EntryUnlockErrorEventHandler\"\n);\n\nexport namespace EntryUnlockErrorEventHandler {\n export type Interface = IEventHandler<EntryUnlockErrorEvent>;\n export type Event = EntryUnlockErrorEvent;\n}\n"],"names":["EntryBeforeUnlockEvent","DomainEvent","EntryBeforeUnlockEventHandler","createAbstraction","EntryAfterUnlockEvent","EntryAfterUnlockEventHandler","EntryUnlockErrorEvent","EntryUnlockErrorEventHandler"],"mappings":";;AAgBO,MAAMA,+BAA+BC;IAGxC,wBAAwB;QACpB,OAAOC;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB;AAEO,MAAMA,gCAAgCC,kBAE3C;AAiBK,MAAMC,8BAA8BH;IAGvC,wBAAwB;QACpB,OAAOI;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB;AAEO,MAAMA,+BAA+BF,kBACxC;AAkBG,MAAMG,8BAA8BL;IAGvC,wBAAwB;QACpB,OAAOM;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB;AAEO,MAAMA,+BAA+BJ,kBACxC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { UnlockEntryUseCase } from "./UnlockEntryUseCase.js";
|
|
3
|
+
import { UnlockEntryRepository } from "./UnlockEntryRepository.js";
|
|
4
|
+
import { UnlockEntryEventsDecorator } from "./UnlockEntryEventsDecorator.js";
|
|
5
|
+
const UnlockEntryFeature = createFeature({
|
|
6
|
+
name: "UnlockEntry",
|
|
7
|
+
register (container) {
|
|
8
|
+
container.register(UnlockEntryUseCase);
|
|
9
|
+
container.register(UnlockEntryRepository).inSingletonScope();
|
|
10
|
+
container.registerDecorator(UnlockEntryEventsDecorator);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
export { UnlockEntryFeature };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/UnlockEntry/feature.js","sources":["../../../src/features/UnlockEntry/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { UnlockEntryUseCase } from \"./UnlockEntryUseCase.js\";\nimport { UnlockEntryRepository } from \"./UnlockEntryRepository.js\";\nimport { UnlockEntryEventsDecorator } from \"./UnlockEntryEventsDecorator.js\";\n\nexport const UnlockEntryFeature = createFeature({\n name: \"UnlockEntry\",\n register(container) {\n container.register(UnlockEntryUseCase);\n container.register(UnlockEntryRepository).inSingletonScope();\n container.registerDecorator(UnlockEntryEventsDecorator);\n }\n});\n"],"names":["UnlockEntryFeature","createFeature","container","UnlockEntryUseCase","UnlockEntryRepository","UnlockEntryEventsDecorator"],"mappings":";;;;AAKO,MAAMA,qBAAqBC,cAAc;IAC5C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,uBAAuB,gBAAgB;QAC1DF,UAAU,iBAAiB,CAACG;IAChC;AACJ"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const hasFullAccessPermission = async (identityContext)=>{
|
|
2
|
+
const hasFullAccess = await identityContext.hasFullAccess();
|
|
3
|
+
if (hasFullAccess) return true;
|
|
4
|
+
const permission = await identityContext.getPermission("recordLocking");
|
|
5
|
+
return permission?.canForceUnlock === true;
|
|
6
|
+
};
|
|
7
|
+
export { hasFullAccessPermission };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=hasFullAccessPermission.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/UnlockEntry/hasFullAccessPermission.js","sources":["../../../src/features/UnlockEntry/hasFullAccessPermission.ts"],"sourcesContent":["import type { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type { SecurityPermission } from \"@webiny/api-core/types/security.js\";\n\ninterface RecordLockingSecurityPermission extends SecurityPermission {\n canForceUnlock?: boolean;\n}\n\nexport const hasFullAccessPermission = async (\n identityContext: IdentityContext.Interface\n): Promise<boolean> => {\n const hasFullAccess = await identityContext.hasFullAccess();\n if (hasFullAccess) {\n return true;\n }\n\n const permission =\n await identityContext.getPermission<RecordLockingSecurityPermission>(\"recordLocking\");\n return permission?.canForceUnlock === true;\n};\n"],"names":["hasFullAccessPermission","identityContext","hasFullAccess","permission"],"mappings":"AAOO,MAAMA,0BAA0B,OACnCC;IAEA,MAAMC,gBAAgB,MAAMD,gBAAgB,aAAa;IACzD,IAAIC,eACA,OAAO;IAGX,MAAMC,aACF,MAAMF,gBAAgB,aAAa,CAAkC;IACzE,OAAOE,YAAY,mBAAmB;AAC1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./abstractions.js";
|