@webiny/api-record-locking 6.0.0-beta.0 → 6.0.0-rc.0
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/domain/LockRecord.d.ts +45 -0
- package/{utils/convertEntryToLockRecord.js → domain/LockRecord.js} +14 -22
- package/domain/LockRecord.js.map +1 -0
- package/domain/RecordLockingModel.d.ts +9 -0
- package/domain/RecordLockingModel.js +29 -0
- package/domain/RecordLockingModel.js.map +1 -0
- package/domain/abstractions.d.ts +18 -0
- package/domain/abstractions.js +10 -0
- package/domain/abstractions.js.map +1 -0
- package/domain/calculateExpiresOn.d.ts +1 -0
- package/domain/calculateExpiresOn.js +9 -0
- package/domain/calculateExpiresOn.js.map +1 -0
- package/domain/errors.d.ts +71 -0
- package/domain/errors.js +95 -0
- package/domain/errors.js.map +1 -0
- package/domain/index.d.ts +4 -0
- package/domain/index.js +6 -0
- package/domain/index.js.map +1 -0
- package/domain/types.d.ts +44 -0
- package/domain/types.js +12 -0
- package/domain/types.js.map +1 -0
- package/features/GetLockRecord/GetLockRecordRepository.d.ts +16 -0
- package/features/GetLockRecord/GetLockRecordRepository.js +37 -0
- package/features/GetLockRecord/GetLockRecordRepository.js.map +1 -0
- package/features/GetLockRecord/GetLockRecordUseCase.d.ts +12 -0
- package/features/GetLockRecord/GetLockRecordUseCase.js +15 -0
- package/features/GetLockRecord/GetLockRecordUseCase.js.map +1 -0
- package/features/GetLockRecord/abstractions.d.ts +41 -0
- package/features/GetLockRecord/abstractions.js +17 -0
- package/features/GetLockRecord/abstractions.js.map +1 -0
- package/features/GetLockRecord/feature.d.ts +1 -0
- package/features/GetLockRecord/feature.js +12 -0
- package/features/GetLockRecord/feature.js.map +1 -0
- package/features/GetLockRecord/index.d.ts +2 -0
- package/features/GetLockRecord/index.js +4 -0
- package/features/GetLockRecord/index.js.map +1 -0
- package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.d.ts +15 -0
- package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js +39 -0
- package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js.map +1 -0
- package/features/GetLockedEntryLockRecord/abstractions.d.ts +26 -0
- package/features/GetLockedEntryLockRecord/abstractions.js +13 -0
- package/features/GetLockedEntryLockRecord/abstractions.js.map +1 -0
- package/features/GetLockedEntryLockRecord/feature.d.ts +1 -0
- package/features/GetLockedEntryLockRecord/feature.js +10 -0
- package/features/GetLockedEntryLockRecord/feature.js.map +1 -0
- package/features/GetLockedEntryLockRecord/index.d.ts +2 -0
- package/features/GetLockedEntryLockRecord/index.js +4 -0
- package/features/GetLockedEntryLockRecord/index.js.map +1 -0
- package/features/IsEntryLocked/IsEntryLockedUseCase.d.ts +14 -0
- package/features/IsEntryLocked/IsEntryLockedUseCase.js +39 -0
- package/features/IsEntryLocked/IsEntryLockedUseCase.js.map +1 -0
- package/features/IsEntryLocked/abstractions.d.ts +24 -0
- package/features/IsEntryLocked/abstractions.js +12 -0
- package/features/IsEntryLocked/abstractions.js.map +1 -0
- package/features/IsEntryLocked/feature.d.ts +1 -0
- package/features/IsEntryLocked/feature.js +10 -0
- package/features/IsEntryLocked/feature.js.map +1 -0
- package/features/IsEntryLocked/index.d.ts +1 -0
- package/features/IsEntryLocked/index.js +3 -0
- package/features/IsEntryLocked/index.js.map +1 -0
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.d.ts +15 -0
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js +42 -0
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js.map +1 -0
- package/features/KickOutCurrentUser/abstractions.d.ts +17 -0
- package/features/KickOutCurrentUser/abstractions.js +9 -0
- package/features/KickOutCurrentUser/abstractions.js.map +1 -0
- package/features/KickOutCurrentUser/feature.d.ts +1 -0
- package/features/KickOutCurrentUser/feature.js +10 -0
- package/features/KickOutCurrentUser/feature.js.map +1 -0
- package/features/KickOutCurrentUser/index.d.ts +1 -0
- package/features/KickOutCurrentUser/index.js +3 -0
- package/features/KickOutCurrentUser/index.js.map +1 -0
- package/features/ListAllLockRecords/ListAllLockRecordsRepository.d.ts +16 -0
- package/features/ListAllLockRecords/ListAllLockRecordsRepository.js +43 -0
- package/features/ListAllLockRecords/ListAllLockRecordsRepository.js.map +1 -0
- package/features/ListAllLockRecords/ListAllLockRecordsUseCase.d.ts +11 -0
- package/features/ListAllLockRecords/ListAllLockRecordsUseCase.js +15 -0
- package/features/ListAllLockRecords/ListAllLockRecordsUseCase.js.map +1 -0
- package/features/ListAllLockRecords/abstractions.d.ts +40 -0
- package/features/ListAllLockRecords/abstractions.js +17 -0
- package/features/ListAllLockRecords/abstractions.js.map +1 -0
- package/features/ListAllLockRecords/feature.d.ts +1 -0
- package/features/ListAllLockRecords/feature.js +12 -0
- package/features/ListAllLockRecords/feature.js.map +1 -0
- package/features/ListAllLockRecords/index.d.ts +2 -0
- package/features/ListAllLockRecords/index.js +4 -0
- package/features/ListAllLockRecords/index.js.map +1 -0
- package/features/ListLockRecords/ListLockRecordsRepository.d.ts +15 -0
- package/features/ListLockRecords/ListLockRecordsRepository.js +43 -0
- package/features/ListLockRecords/ListLockRecordsRepository.js.map +1 -0
- package/features/ListLockRecords/ListLockRecordsUseCase.d.ts +15 -0
- package/features/ListLockRecords/ListLockRecordsUseCase.js +30 -0
- package/features/ListLockRecords/ListLockRecordsUseCase.js.map +1 -0
- package/features/ListLockRecords/abstractions.d.ts +45 -0
- package/features/ListLockRecords/abstractions.js +17 -0
- package/features/ListLockRecords/abstractions.js.map +1 -0
- package/features/ListLockRecords/feature.d.ts +1 -0
- package/features/ListLockRecords/feature.js +12 -0
- package/features/ListLockRecords/feature.js.map +1 -0
- package/features/ListLockRecords/index.d.ts +1 -0
- package/features/ListLockRecords/index.js +3 -0
- package/features/ListLockRecords/index.js.map +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 +42 -0
- package/features/LockEntry/LockEntryRepository.js.map +1 -0
- package/features/LockEntry/LockEntryUseCase.d.ts +14 -0
- package/features/LockEntry/LockEntryUseCase.js +36 -0
- package/features/LockEntry/LockEntryUseCase.js.map +1 -0
- package/features/LockEntry/abstractions.d.ts +41 -0
- package/features/LockEntry/abstractions.js +17 -0
- package/features/LockEntry/abstractions.js.map +1 -0
- package/features/LockEntry/events.d.ts +45 -0
- package/features/LockEntry/events.js +40 -0
- package/features/LockEntry/events.js.map +1 -0
- package/features/LockEntry/feature.d.ts +1 -0
- package/features/LockEntry/feature.js +14 -0
- package/features/LockEntry/feature.js.map +1 -0
- package/features/LockEntry/index.d.ts +1 -0
- package/features/LockEntry/index.js +3 -0
- package/features/LockEntry/index.js.map +1 -0
- package/features/RecordLockingFeature.d.ts +12 -0
- package/features/RecordLockingFeature.js +36 -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 +40 -0
- package/features/UnlockEntry/UnlockEntryRepository.js.map +1 -0
- package/features/UnlockEntry/UnlockEntryUseCase.d.ts +18 -0
- package/features/UnlockEntry/UnlockEntryUseCase.js +81 -0
- package/features/UnlockEntry/UnlockEntryUseCase.js.map +1 -0
- package/features/UnlockEntry/abstractions.d.ts +44 -0
- package/features/UnlockEntry/abstractions.js +17 -0
- package/features/UnlockEntry/abstractions.js.map +1 -0
- package/features/UnlockEntry/events.d.ts +46 -0
- package/features/UnlockEntry/events.js +40 -0
- package/features/UnlockEntry/events.js.map +1 -0
- package/features/UnlockEntry/feature.d.ts +1 -0
- package/features/UnlockEntry/feature.js +14 -0
- package/features/UnlockEntry/feature.js.map +1 -0
- package/features/UnlockEntry/hasFullAccessPermission.d.ts +2 -0
- package/features/UnlockEntry/hasFullAccessPermission.js +10 -0
- package/features/UnlockEntry/hasFullAccessPermission.js.map +1 -0
- package/features/UnlockEntry/index.d.ts +1 -0
- package/features/UnlockEntry/index.js +3 -0
- package/features/UnlockEntry/index.js.map +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 +43 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js.map +1 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.d.ts +16 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js +92 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js.map +1 -0
- package/features/UnlockEntryRequest/abstractions.d.ts +42 -0
- package/features/UnlockEntryRequest/abstractions.js +17 -0
- package/features/UnlockEntryRequest/abstractions.js.map +1 -0
- package/features/UnlockEntryRequest/events.d.ts +45 -0
- package/features/UnlockEntryRequest/events.js +40 -0
- package/features/UnlockEntryRequest/events.js.map +1 -0
- package/features/UnlockEntryRequest/feature.d.ts +1 -0
- package/features/UnlockEntryRequest/feature.js +14 -0
- package/features/UnlockEntryRequest/feature.js.map +1 -0
- package/features/UnlockEntryRequest/index.d.ts +3 -0
- package/features/UnlockEntryRequest/index.js +5 -0
- package/features/UnlockEntryRequest/index.js.map +1 -0
- package/features/UpdateEntryLock/UpdateEntryLockRepository.d.ts +20 -0
- package/features/UpdateEntryLock/UpdateEntryLockRepository.js +63 -0
- package/features/UpdateEntryLock/UpdateEntryLockRepository.js.map +1 -0
- package/features/UpdateEntryLock/UpdateEntryLockUseCase.d.ts +18 -0
- package/features/UpdateEntryLock/UpdateEntryLockUseCase.js +62 -0
- package/features/UpdateEntryLock/UpdateEntryLockUseCase.js.map +1 -0
- package/features/UpdateEntryLock/abstractions.d.ts +42 -0
- package/features/UpdateEntryLock/abstractions.js +17 -0
- package/features/UpdateEntryLock/abstractions.js.map +1 -0
- package/features/UpdateEntryLock/feature.d.ts +1 -0
- package/features/UpdateEntryLock/feature.js +12 -0
- package/features/UpdateEntryLock/feature.js.map +1 -0
- package/features/UpdateEntryLock/index.d.ts +1 -0
- package/features/UpdateEntryLock/index.js +3 -0
- package/features/UpdateEntryLock/index.js.map +1 -0
- package/graphql/checkPermissions.d.ts +5 -0
- package/graphql/checkPermissions.js +14 -0
- package/graphql/checkPermissions.js.map +1 -0
- package/{utils → graphql}/resolve.d.ts +2 -2
- package/graphql/resolve.js +22 -0
- package/graphql/resolve.js.map +1 -0
- package/graphql/schema.d.ts +8 -4
- package/graphql/schema.js +99 -61
- package/graphql/schema.js.map +1 -1
- package/index.d.ts +8 -2
- package/index.js +50 -26
- package/index.js.map +1 -1
- package/package.json +21 -43
- package/types.d.ts +14 -133
- package/types.js +6 -24
- package/types.js.map +1 -1
- package/utils/convertWhereCondition.d.ts +2 -2
- package/utils/convertWhereCondition.js +11 -14
- package/utils/convertWhereCondition.js.map +1 -1
- package/utils/getTimeout.d.ts +3 -2
- package/utils/getTimeout.js +11 -10
- package/utils/getTimeout.js.map +1 -1
- package/utils/lockRecordDatabaseId.js +4 -12
- 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 -6
- package/crud/crud.js +0 -188
- 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/useCases/GetLockRecord/GetLockRecordUseCase.d.ts +0 -10
- package/useCases/GetLockRecord/GetLockRecordUseCase.js +0 -35
- package/useCases/GetLockRecord/GetLockRecordUseCase.js.map +0 -1
- package/useCases/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.d.ts +0 -16
- package/useCases/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js +0 -27
- package/useCases/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js.map +0 -1
- package/useCases/IsEntryLocked/IsEntryLockedUseCase.d.ts +0 -16
- package/useCases/IsEntryLocked/IsEntryLockedUseCase.js +0 -35
- 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 -10
- package/useCases/ListAllLockRecordsUseCase/ListAllLockRecordsUseCase.js +0 -32
- 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 -13
- package/useCases/LockEntryUseCase/LockEntryUseCase.js +0 -51
- package/useCases/LockEntryUseCase/LockEntryUseCase.js.map +0 -1
- package/useCases/UnlockEntryUseCase/UnlockEntryUseCase.d.ts +0 -20
- package/useCases/UnlockEntryUseCase/UnlockEntryUseCase.js +0 -67
- package/useCases/UnlockEntryUseCase/UnlockEntryUseCase.js.map +0 -1
- package/useCases/UnlockRequestUseCase/UnlockEntryRequestUseCase.d.ts +0 -15
- package/useCases/UnlockRequestUseCase/UnlockEntryRequestUseCase.js +0 -78
- package/useCases/UnlockRequestUseCase/UnlockEntryRequestUseCase.js.map +0 -1
- package/useCases/UpdateEntryLock/UpdateEntryLockUseCase.d.ts +0 -18
- package/useCases/UpdateEntryLock/UpdateEntryLockUseCase.js +0 -48
- package/useCases/UpdateEntryLock/UpdateEntryLockUseCase.js.map +0 -1
- package/useCases/index.d.ts +0 -28
- package/useCases/index.js +0 -83
- package/useCases/index.js.map +0 -1
- package/utils/calculateExpiresOn.d.ts +0 -2
- package/utils/calculateExpiresOn.js +0 -15
- 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.map +0 -1
- package/utils/isLockedFactory.d.ts +0 -5
- package/utils/isLockedFactory.js +0 -20
- package/utils/isLockedFactory.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 @@
|
|
|
1
|
+
{"version":3,"names":["createAbstraction","LockEntryUseCase","LockEntryRepository"],"sources":["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 type {\n EntryAlreadyLockedError,\n LockEntryError,\n LockRecordPersistenceError\n} from \"~/domain/errors.js\";\n\n// Input types\nexport interface LockEntryInput {\n id: string;\n type: LockRecordEntryType;\n}\n\n/**\n * LockEntry Use Case - Creates a lock on an entry\n */\nexport interface ILockEntryUseCase {\n execute(input: LockEntryInput): Promise<Result<ILockRecord, UseCaseError>>;\n}\n\nexport interface ILockEntryUseCaseErrors {\n alreadyLocked: EntryAlreadyLockedError;\n persistence: LockRecordPersistenceError;\n lockError: LockEntryError;\n}\n\ntype UseCaseError = ILockEntryUseCaseErrors[keyof ILockEntryUseCaseErrors];\n\nexport const LockEntryUseCase = createAbstraction<ILockEntryUseCase>(\"LockEntryUseCase\");\n\nexport namespace LockEntryUseCase {\n export type Interface = ILockEntryUseCase;\n export type Error = UseCaseError;\n}\n\n/**\n * LockEntryRepository - Creates lock record in storage\n */\nexport interface ILockEntryRepository {\n create(input: LockEntryInput): Promise<Result<ILockRecord, RepositoryError>>;\n}\n\nexport interface ILockEntryRepositoryErrors {\n persistence: LockRecordPersistenceError;\n}\n\ntype RepositoryError = ILockEntryRepositoryErrors[keyof ILockEntryRepositoryErrors];\n\nexport const LockEntryRepository = createAbstraction<ILockEntryRepository>(\"LockEntryRepository\");\n\nexport namespace LockEntryRepository {\n export type Interface = ILockEntryRepository;\n export type Error = RepositoryError;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAUvD;;AAMA;AACA;AACA;;AAaA,OAAO,MAAMC,gBAAgB,GAAGD,iBAAiB,CAAoB,kBAAkB,CAAC;;AAOxF;AACA;AACA;;AAWA,OAAO,MAAME,mBAAmB,GAAGF,iBAAiB,CAAuB,qBAAqB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { DomainEvent } from "@webiny/api-core/features/EventPublisher";
|
|
2
|
+
import type { IEventHandler } from "@webiny/api-core/features/EventPublisher";
|
|
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 EntryBeforeLockHandler: import("@webiny/di").Abstraction<IEventHandler<EntryBeforeLockEvent>>;
|
|
14
|
+
export declare namespace EntryBeforeLockHandler {
|
|
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 EntryAfterLockHandler: import("@webiny/di").Abstraction<IEventHandler<EntryAfterLockEvent>>;
|
|
28
|
+
export declare namespace EntryAfterLockHandler {
|
|
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 EntryLockErrorHandler: import("@webiny/di").Abstraction<IEventHandler<EntryLockErrorEvent>>;
|
|
42
|
+
export declare namespace EntryLockErrorHandler {
|
|
43
|
+
type Interface = IEventHandler<EntryLockErrorEvent>;
|
|
44
|
+
type Event = EntryLockErrorEvent;
|
|
45
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
import { DomainEvent } from "@webiny/api-core/features/EventPublisher";
|
|
3
|
+
|
|
4
|
+
// ============================================================================
|
|
5
|
+
// EntryBeforeLock Event
|
|
6
|
+
// ============================================================================
|
|
7
|
+
|
|
8
|
+
export class EntryBeforeLockEvent extends DomainEvent {
|
|
9
|
+
eventType = "RecordLocking/Entry/BeforeLock";
|
|
10
|
+
getHandlerAbstraction() {
|
|
11
|
+
return EntryBeforeLockHandler;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export const EntryBeforeLockHandler = createAbstraction("EntryBeforeLockHandler");
|
|
15
|
+
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// EntryAfterLock Event
|
|
18
|
+
// ============================================================================
|
|
19
|
+
|
|
20
|
+
export class EntryAfterLockEvent extends DomainEvent {
|
|
21
|
+
eventType = "RecordLocking/Entry/AfterLock";
|
|
22
|
+
getHandlerAbstraction() {
|
|
23
|
+
return EntryAfterLockHandler;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export const EntryAfterLockHandler = createAbstraction("EntryAfterLockHandler");
|
|
27
|
+
|
|
28
|
+
// ============================================================================
|
|
29
|
+
// EntryLockError Event
|
|
30
|
+
// ============================================================================
|
|
31
|
+
|
|
32
|
+
export class EntryLockErrorEvent extends DomainEvent {
|
|
33
|
+
eventType = "RecordLocking/Entry/LockError";
|
|
34
|
+
getHandlerAbstraction() {
|
|
35
|
+
return EntryLockErrorHandler;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export const EntryLockErrorHandler = createAbstraction("EntryLockErrorHandler");
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAbstraction","DomainEvent","EntryBeforeLockEvent","eventType","getHandlerAbstraction","EntryBeforeLockHandler","EntryAfterLockEvent","EntryAfterLockHandler","EntryLockErrorEvent","EntryLockErrorHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"@webiny/api-core/features/EventPublisher\";\nimport type { IEventHandler } from \"@webiny/api-core/features/EventPublisher\";\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 EntryBeforeLockHandler;\n }\n}\n\nexport const EntryBeforeLockHandler =\n createAbstraction<IEventHandler<EntryBeforeLockEvent>>(\"EntryBeforeLockHandler\");\n\nexport namespace EntryBeforeLockHandler {\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 EntryAfterLockHandler;\n }\n}\n\nexport const EntryAfterLockHandler =\n createAbstraction<IEventHandler<EntryAfterLockEvent>>(\"EntryAfterLockHandler\");\n\nexport namespace EntryAfterLockHandler {\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 EntryLockErrorHandler;\n }\n}\n\nexport const EntryLockErrorHandler =\n createAbstraction<IEventHandler<EntryLockErrorEvent>>(\"EntryLockErrorHandler\");\n\nexport namespace EntryLockErrorHandler {\n export type Interface = IEventHandler<EntryLockErrorEvent>;\n export type Event = EntryLockErrorEvent;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW,QAAQ,0CAA0C;;AAKtE;AACA;AACA;;AAOA,OAAO,MAAMC,oBAAoB,SAASD,WAAW,CAAyB;EAC1EE,SAAS,GAAG,gCAAgC;EAE5CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,sBAAsB;EACjC;AACJ;AAEA,OAAO,MAAMA,sBAAsB,GAC/BL,iBAAiB,CAAsC,wBAAwB,CAAC;;AAOpF;AACA;AACA;;AAQA,OAAO,MAAMM,mBAAmB,SAASL,WAAW,CAAwB;EACxEE,SAAS,GAAG,+BAA+B;EAE3CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,qBAAqB;EAChC;AACJ;AAEA,OAAO,MAAMA,qBAAqB,GAC9BP,iBAAiB,CAAqC,uBAAuB,CAAC;;AAOlF;AACA;AACA;;AAQA,OAAO,MAAMQ,mBAAmB,SAASP,WAAW,CAAwB;EACxEE,SAAS,GAAG,+BAA+B;EAE3CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOK,qBAAqB;EAChC;AACJ;AAEA,OAAO,MAAMA,qBAAqB,GAC9BT,iBAAiB,CAAqC,uBAAuB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LockEntryFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
export 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
|
+
|
|
14
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFeature","LockEntryUseCase","LockEntryRepository","LockEntryEventsDecorator","LockEntryFeature","name","register","container","inSingletonScope","registerDecorator"],"sources":["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"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,gBAAgB;AACzB,SAASC,mBAAmB;AAC5B,SAASC,wBAAwB;AAEjC,OAAO,MAAMC,gBAAgB,GAAGJ,aAAa,CAAC;EAC1CK,IAAI,EAAE,WAAW;EACjBC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACL,gBAAgB,CAAC;IACpCM,SAAS,CAACD,QAAQ,CAACJ,mBAAmB,CAAC,CAACM,gBAAgB,CAAC,CAAC;IAC1DD,SAAS,CAACE,iBAAiB,CAACN,wBAAwB,CAAC;EACzD;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./abstractions.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
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: import("@webiny/feature/api/createFeature.js").FeatureDefinition<RecordLockingParams>;
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
export const RecordLockingFeature = createFeature({
|
|
14
|
+
name: "RecordLockingManagement",
|
|
15
|
+
register(container, params) {
|
|
16
|
+
// Register domain abstractions
|
|
17
|
+
container.registerInstance(RecordLockingConfig, {
|
|
18
|
+
timeout: params.timeout
|
|
19
|
+
});
|
|
20
|
+
container.registerInstance(RecordLockingModel, params.model);
|
|
21
|
+
|
|
22
|
+
// Register all sub-features
|
|
23
|
+
GetLockRecordFeature.register(container);
|
|
24
|
+
GetLockedEntryLockRecordFeature.register(container);
|
|
25
|
+
KickOutCurrentUserFeature.register(container);
|
|
26
|
+
ListLockRecordsFeature.register(container);
|
|
27
|
+
ListAllLockRecordsFeature.register(container);
|
|
28
|
+
IsEntryLockedFeature.register(container);
|
|
29
|
+
LockEntryFeature.register(container);
|
|
30
|
+
UpdateEntryLockFeature.register(container);
|
|
31
|
+
UnlockEntryFeature.register(container);
|
|
32
|
+
UnlockEntryRequestFeature.register(container);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=RecordLockingFeature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFeature","RecordLockingConfig","RecordLockingModel","GetLockRecordFeature","GetLockedEntryLockRecordFeature","KickOutCurrentUserFeature","ListLockRecordsFeature","ListAllLockRecordsFeature","IsEntryLockedFeature","LockEntryFeature","UpdateEntryLockFeature","UnlockEntryFeature","UnlockEntryRequestFeature","RecordLockingFeature","name","register","container","params","registerInstance","timeout","model"],"sources":["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({\n name: \"RecordLockingManagement\",\n register(container, params: RecordLockingParams) {\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"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AAEnD,SAASC,mBAAmB,EAAEC,kBAAkB;AAChD,SAASC,oBAAoB;AAC7B,SAASC,+BAA+B;AACxC,SAASC,yBAAyB;AAClC,SAASC,sBAAsB;AAC/B,SAASC,yBAAyB;AAClC,SAASC,oBAAoB;AAC7B,SAASC,gBAAgB;AACzB,SAASC,sBAAsB;AAC/B,SAASC,kBAAkB;AAC3B,SAASC,yBAAyB;AAalC,OAAO,MAAMC,oBAAoB,GAAGb,aAAa,CAAC;EAC9Cc,IAAI,EAAE,yBAAyB;EAC/BC,QAAQA,CAACC,SAAS,EAAEC,MAA2B,EAAE;IAC7C;IACAD,SAAS,CAACE,gBAAgB,CAACjB,mBAAmB,EAAE;MAAEkB,OAAO,EAAEF,MAAM,CAACE;IAAQ,CAAC,CAAC;IAC5EH,SAAS,CAACE,gBAAgB,CAAChB,kBAAkB,EAAEe,MAAM,CAACG,KAAK,CAAC;;IAE5D;IACAjB,oBAAoB,CAACY,QAAQ,CAACC,SAAS,CAAC;IACxCZ,+BAA+B,CAACW,QAAQ,CAACC,SAAS,CAAC;IACnDX,yBAAyB,CAACU,QAAQ,CAACC,SAAS,CAAC;IAC7CV,sBAAsB,CAACS,QAAQ,CAACC,SAAS,CAAC;IAC1CT,yBAAyB,CAACQ,QAAQ,CAACC,SAAS,CAAC;IAC7CR,oBAAoB,CAACO,QAAQ,CAACC,SAAS,CAAC;IACxCP,gBAAgB,CAACM,QAAQ,CAACC,SAAS,CAAC;IACpCN,sBAAsB,CAACK,QAAQ,CAACC,SAAS,CAAC;IAC1CL,kBAAkB,CAACI,QAAQ,CAACC,SAAS,CAAC;IACtCJ,yBAAyB,CAACG,QAAQ,CAACC,SAAS,CAAC;EACjD;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type UnlockEntryInput, UnlockEntryUseCase as UseCaseAbstraction, UnlockEntryUseCase } from "./abstractions.js";
|
|
2
|
+
import { EventPublisher } from "@webiny/api-core/features/EventPublisher";
|
|
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";
|
|
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
|
+
// Publish before event
|
|
11
|
+
await this.eventPublisher.publish(new EntryBeforeUnlockEvent({
|
|
12
|
+
id: input.id,
|
|
13
|
+
type: input.type,
|
|
14
|
+
force: input.force
|
|
15
|
+
}));
|
|
16
|
+
const result = await this.decoratee.execute(input);
|
|
17
|
+
if (result.isFail()) {
|
|
18
|
+
const error = result.error;
|
|
19
|
+
await this.eventPublisher.publish(new EntryUnlockErrorEvent({
|
|
20
|
+
id: input.id,
|
|
21
|
+
type: input.type,
|
|
22
|
+
error
|
|
23
|
+
}));
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Publish after event
|
|
28
|
+
await this.eventPublisher.publish(new EntryAfterUnlockEvent({
|
|
29
|
+
id: input.id,
|
|
30
|
+
type: input.type,
|
|
31
|
+
record: result.value
|
|
32
|
+
}));
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export const UnlockEntryEventsDecorator = UnlockEntryUseCase.createDecorator({
|
|
37
|
+
decorator: UnlockEntryEventsDecoratorImpl,
|
|
38
|
+
dependencies: [EventPublisher]
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=UnlockEntryEventsDecorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["UnlockEntryUseCase","EventPublisher","EntryAfterUnlockEvent","EntryBeforeUnlockEvent","EntryUnlockErrorEvent","UnlockEntryEventsDecoratorImpl","constructor","eventPublisher","decoratee","execute","input","publish","id","type","force","result","isFail","error","record","value","UnlockEntryEventsDecorator","createDecorator","decorator","dependencies"],"sources":["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\";\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"],"mappings":"AAAA,SAGIA,kBAAkB;AAEtB,SAASC,cAAc,QAAQ,0CAA0C;AAGzE,SAASC,qBAAqB,EAAEC,sBAAsB,EAAEC,qBAAqB;AAE7E,MAAMC,8BAA8B,CAAyC;EACzEC,WAAWA,CACUC,cAAwC,EACxCC,SAAuC,EAC1D;IAAA,KAFmBD,cAAwC,GAAxCA,cAAwC;IAAA,KACxCC,SAAuC,GAAvCA,SAAuC;EACzD;EAEH,MAAMC,OAAOA,CAACC,KAAuB,EAA0D;IAC3F;IACA,MAAM,IAAI,CAACH,cAAc,CAACI,OAAO,CAC7B,IAAIR,sBAAsB,CAAC;MACvBS,EAAE,EAAEF,KAAK,CAACE,EAAE;MACZC,IAAI,EAAEH,KAAK,CAACG,IAAI;MAChBC,KAAK,EAAEJ,KAAK,CAACI;IACjB,CAAC,CACL,CAAC;IAED,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACP,SAAS,CAACC,OAAO,CAACC,KAAK,CAAC;IAElD,IAAIK,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;MACjB,MAAMC,KAAK,GAAGF,MAAM,CAACE,KAAK;MAE1B,MAAM,IAAI,CAACV,cAAc,CAACI,OAAO,CAC7B,IAAIP,qBAAqB,CAAC;QACtBQ,EAAE,EAAEF,KAAK,CAACE,EAAE;QACZC,IAAI,EAAEH,KAAK,CAACG,IAAI;QAChBI;MACJ,CAAC,CACL,CAAC;MAED,OAAOF,MAAM;IACjB;;IAEA;IACA,MAAM,IAAI,CAACR,cAAc,CAACI,OAAO,CAC7B,IAAIT,qBAAqB,CAAC;MACtBU,EAAE,EAAEF,KAAK,CAACE,EAAE;MACZC,IAAI,EAAEH,KAAK,CAACG,IAAI;MAChBK,MAAM,EAAEH,MAAM,CAACI;IACnB,CAAC,CACL,CAAC;IAED,OAAOJ,MAAM;EACjB;AACJ;AAEA,OAAO,MAAMK,0BAA0B,GAAGpB,kBAAkB,CAACqB,eAAe,CAAC;EACzEC,SAAS,EAAEjB,8BAA8B;EACzCkB,YAAY,EAAE,CAACtB,cAAc;AACjC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -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,40 @@
|
|
|
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 as RepositoryAbstraction } 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 (result.error.code === "Cms/Entry/NotFound") {
|
|
25
|
+
return Result.fail(new LockRecordNotFoundError());
|
|
26
|
+
}
|
|
27
|
+
return Result.fail(new UnlockEntryError(result.error));
|
|
28
|
+
}
|
|
29
|
+
return Result.ok();
|
|
30
|
+
} catch (error) {
|
|
31
|
+
return Result.fail(new UnlockEntryError(error));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export const UnlockEntryRepository = RepositoryAbstraction.createImplementation({
|
|
36
|
+
implementation: UnlockEntryRepositoryImpl,
|
|
37
|
+
dependencies: [RecordLockingModel, DeleteEntryUseCase]
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=UnlockEntryRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Result","DeleteEntryUseCase","createIdentifier","UnlockEntryRepository","RepositoryAbstraction","RecordLockingModel","LockRecordNotFoundError","UnlockEntryError","createLockRecordDatabaseId","UnlockEntryRepositoryImpl","constructor","model","deleteEntry","delete","lockRecordId","entryId","id","version","result","execute","permanently","isFail","error","code","fail","ok","createImplementation","implementation","dependencies"],"sources":["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"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,kBAAkB,QAAQ,4DAA4D;AAC/F,SAASC,gBAAgB,QAAQ,eAAe;AAChD,SAASC,qBAAqB,IAAIC,qBAAqB;AACvD,SAASC,kBAAkB;AAC3B,SAASC,uBAAuB,EAAEC,gBAAgB;AAClD,SAASC,0BAA0B;AAEnC,MAAMC,yBAAyB,CAA4C;EACvEC,WAAWA,CACCC,KAAmC,EACnCC,WAAyC,EACnD;IAAA,KAFUD,KAAmC,GAAnCA,KAAmC;IAAA,KACnCC,WAAyC,GAAzCA,WAAyC;EAClD;EAEH,MAAMC,MAAMA,CAACC,YAAoB,EAAsD;IACnF,IAAI;MACA,MAAMC,OAAO,GAAGP,0BAA0B,CAACM,YAAY,CAAC;MACxD,MAAME,EAAE,GAAGd,gBAAgB,CAAC;QACxBc,EAAE,EAAED,OAAO;QACXE,OAAO,EAAE;MACb,CAAC,CAAC;MAEF,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACN,WAAW,CAACO,OAAO,CAAC,IAAI,CAACR,KAAK,EAAEK,EAAE,EAAE;QAC1DI,WAAW,EAAE;MACjB,CAAC,CAAC;MAEF,IAAIF,MAAM,CAACG,MAAM,CAAC,CAAC,EAAE;QACjB,IAAIH,MAAM,CAACI,KAAK,CAACC,IAAI,KAAK,oBAAoB,EAAE;UAC5C,OAAOvB,MAAM,CAACwB,IAAI,CAAC,IAAIlB,uBAAuB,CAAC,CAAC,CAAC;QACrD;QACA,OAAON,MAAM,CAACwB,IAAI,CAAC,IAAIjB,gBAAgB,CAACW,MAAM,CAACI,KAAK,CAAC,CAAC;MAC1D;MAEA,OAAOtB,MAAM,CAACyB,EAAE,CAAC,CAAC;IACtB,CAAC,CAAC,OAAOH,KAAK,EAAE;MACZ,OAAOtB,MAAM,CAACwB,IAAI,CAAC,IAAIjB,gBAAgB,CAACe,KAAc,CAAC,CAAC;IAC5D;EACJ;AACJ;AAEA,OAAO,MAAMnB,qBAAqB,GAAGC,qBAAqB,CAACsB,oBAAoB,CAAC;EAC5EC,cAAc,EAAElB,yBAAyB;EACzCmB,YAAY,EAAE,CAACvB,kBAAkB,EAAEJ,kBAAkB;AACzD,CAAC,CAAC","ignoreList":[]}
|
|
@@ -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/IdentityContext";
|
|
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,81 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { UnlockEntryUseCase as UseCaseAbstraction, UnlockEntryRepository } 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/IdentityContext";
|
|
6
|
+
import { LockRecordNotFoundError, IdentityMismatchError } 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
|
+
// Get the lock record
|
|
17
|
+
const recordResult = await this.getLockRecord.execute(input);
|
|
18
|
+
|
|
19
|
+
// If not found or expired, attempt cleanup and return error
|
|
20
|
+
if (recordResult.isFail()) {
|
|
21
|
+
if (recordResult.error instanceof LockRecordNotFoundError) {
|
|
22
|
+
// Try to cleanup any stale data
|
|
23
|
+
await this.repository.delete(input.id);
|
|
24
|
+
}
|
|
25
|
+
return Result.fail(recordResult.error);
|
|
26
|
+
}
|
|
27
|
+
const record = recordResult.value;
|
|
28
|
+
|
|
29
|
+
// If expired, cleanup and return error
|
|
30
|
+
if (record.isExpired()) {
|
|
31
|
+
await this.repository.delete(record.id);
|
|
32
|
+
const error = new LockRecordNotFoundError();
|
|
33
|
+
return Result.fail(error);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Check if user is the owner
|
|
37
|
+
const identity = this.identityContext.getIdentity();
|
|
38
|
+
const isSameUser = record.lockedBy.id === identity.id;
|
|
39
|
+
let shouldKickOut = false;
|
|
40
|
+
|
|
41
|
+
// If not the owner, check if force unlock is allowed
|
|
42
|
+
if (!isSameUser) {
|
|
43
|
+
if (!input.force) {
|
|
44
|
+
const error = new IdentityMismatchError({
|
|
45
|
+
currentId: identity.id,
|
|
46
|
+
targetId: record.lockedBy.id
|
|
47
|
+
});
|
|
48
|
+
return Result.fail(error);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Check if user has permission to force unlock
|
|
52
|
+
const hasAccess = await hasFullAccessPermission(this.identityContext);
|
|
53
|
+
if (!hasAccess) {
|
|
54
|
+
const error = new IdentityMismatchError({
|
|
55
|
+
currentId: identity.id,
|
|
56
|
+
targetId: record.lockedBy.id
|
|
57
|
+
});
|
|
58
|
+
return Result.fail(error);
|
|
59
|
+
}
|
|
60
|
+
shouldKickOut = true;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Delete the lock record
|
|
64
|
+
const deleteResult = await this.repository.delete(record.id);
|
|
65
|
+
if (deleteResult.isFail()) {
|
|
66
|
+
return Result.fail(deleteResult.error);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// If forced by another user, kick out the original lock owner
|
|
70
|
+
if (shouldKickOut) {
|
|
71
|
+
await this.kickOutCurrentUser.execute(record);
|
|
72
|
+
}
|
|
73
|
+
return Result.ok(record);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export const UnlockEntryUseCase = UseCaseAbstraction.createImplementation({
|
|
77
|
+
implementation: UnlockEntryUseCaseImpl,
|
|
78
|
+
dependencies: [GetLockRecordUseCase, KickOutCurrentUserUseCase, UnlockEntryRepository, IdentityContext]
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
//# sourceMappingURL=UnlockEntryUseCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Result","UnlockEntryUseCase","UseCaseAbstraction","UnlockEntryRepository","GetLockRecordUseCase","KickOutCurrentUserUseCase","IdentityContext","LockRecordNotFoundError","IdentityMismatchError","hasFullAccessPermission","UnlockEntryUseCaseImpl","constructor","getLockRecord","kickOutCurrentUser","repository","identityContext","execute","input","recordResult","isFail","error","delete","id","fail","record","value","isExpired","identity","getIdentity","isSameUser","lockedBy","shouldKickOut","force","currentId","targetId","hasAccess","deleteResult","ok","createImplementation","implementation","dependencies"],"sources":["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/IdentityContext\";\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"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SACIC,kBAAkB,IAAIC,kBAAkB,EACxCC,qBAAqB;AAGzB,SAASC,oBAAoB;AAC7B,SAASC,yBAAyB;AAClC,SAASC,eAAe,QAAQ,2CAA2C;AAE3E,SAASC,uBAAuB,EAAEC,qBAAqB;AACvD,SAASC,uBAAuB;AAEhC,MAAMC,sBAAsB,CAAyC;EACjEC,WAAWA,CACCC,aAA6C,EAC7CC,kBAAuD,EACvDC,UAA2C,EAC3CC,eAA0C,EACpD;IAAA,KAJUH,aAA6C,GAA7CA,aAA6C;IAAA,KAC7CC,kBAAuD,GAAvDA,kBAAuD;IAAA,KACvDC,UAA2C,GAA3CA,UAA2C;IAAA,KAC3CC,eAA0C,GAA1CA,eAA0C;EACnD;EAEH,MAAMC,OAAOA,CAACC,KAAuB,EAA0D;IAC3F;IACA,MAAMC,YAAY,GAAG,MAAM,IAAI,CAACN,aAAa,CAACI,OAAO,CAACC,KAAK,CAAC;;IAE5D;IACA,IAAIC,YAAY,CAACC,MAAM,CAAC,CAAC,EAAE;MACvB,IAAID,YAAY,CAACE,KAAK,YAAYb,uBAAuB,EAAE;QACvD;QACA,MAAM,IAAI,CAACO,UAAU,CAACO,MAAM,CAACJ,KAAK,CAACK,EAAE,CAAC;MAC1C;MAEA,OAAOtB,MAAM,CAACuB,IAAI,CAACL,YAAY,CAACE,KAAK,CAAC;IAC1C;IAEA,MAAMI,MAAM,GAAGN,YAAY,CAACO,KAAK;;IAEjC;IACA,IAAID,MAAM,CAACE,SAAS,CAAC,CAAC,EAAE;MACpB,MAAM,IAAI,CAACZ,UAAU,CAACO,MAAM,CAACG,MAAM,CAACF,EAAE,CAAC;MACvC,MAAMF,KAAK,GAAG,IAAIb,uBAAuB,CAAC,CAAC;MAC3C,OAAOP,MAAM,CAACuB,IAAI,CAACH,KAAK,CAAC;IAC7B;;IAEA;IACA,MAAMO,QAAQ,GAAG,IAAI,CAACZ,eAAe,CAACa,WAAW,CAAC,CAAC;IACnD,MAAMC,UAAU,GAAGL,MAAM,CAACM,QAAQ,CAACR,EAAE,KAAKK,QAAQ,CAACL,EAAE;IAErD,IAAIS,aAAa,GAAG,KAAK;;IAEzB;IACA,IAAI,CAACF,UAAU,EAAE;MACb,IAAI,CAACZ,KAAK,CAACe,KAAK,EAAE;QACd,MAAMZ,KAAK,GAAG,IAAIZ,qBAAqB,CAAC;UACpCyB,SAAS,EAAEN,QAAQ,CAACL,EAAE;UACtBY,QAAQ,EAAEV,MAAM,CAACM,QAAQ,CAACR;QAC9B,CAAC,CAAC;QACF,OAAOtB,MAAM,CAACuB,IAAI,CAACH,KAAK,CAAC;MAC7B;;MAEA;MACA,MAAMe,SAAS,GAAG,MAAM1B,uBAAuB,CAAC,IAAI,CAACM,eAAe,CAAC;MACrE,IAAI,CAACoB,SAAS,EAAE;QACZ,MAAMf,KAAK,GAAG,IAAIZ,qBAAqB,CAAC;UACpCyB,SAAS,EAAEN,QAAQ,CAACL,EAAE;UACtBY,QAAQ,EAAEV,MAAM,CAACM,QAAQ,CAACR;QAC9B,CAAC,CAAC;QACF,OAAOtB,MAAM,CAACuB,IAAI,CAACH,KAAK,CAAC;MAC7B;MAEAW,aAAa,GAAG,IAAI;IACxB;;IAEA;IACA,MAAMK,YAAY,GAAG,MAAM,IAAI,CAACtB,UAAU,CAACO,MAAM,CAACG,MAAM,CAACF,EAAE,CAAC;IAE5D,IAAIc,YAAY,CAACjB,MAAM,CAAC,CAAC,EAAE;MACvB,OAAOnB,MAAM,CAACuB,IAAI,CAACa,YAAY,CAAChB,KAAK,CAAC;IAC1C;;IAEA;IACA,IAAIW,aAAa,EAAE;MACf,MAAM,IAAI,CAAClB,kBAAkB,CAACG,OAAO,CAACQ,MAAM,CAAC;IACjD;IAEA,OAAOxB,MAAM,CAACqC,EAAE,CAACb,MAAM,CAAC;EAC5B;AACJ;AAEA,OAAO,MAAMvB,kBAAkB,GAAGC,kBAAkB,CAACoC,oBAAoB,CAAC;EACtEC,cAAc,EAAE7B,sBAAsB;EACtC8B,YAAY,EAAE,CACVpC,oBAAoB,EACpBC,yBAAyB,EACzBF,qBAAqB,EACrBG,eAAe;AAEvB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -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,17 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
|
|
3
|
+
// Input types
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* UnlockEntry Use Case - Unlocks an entry by deleting the lock record
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const UnlockEntryUseCase = createAbstraction("UnlockEntryUseCase");
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* UnlockEntryRepository - Deletes lock record from storage
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export const UnlockEntryRepository = createAbstraction("UnlockEntryRepository");
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=abstractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAbstraction","UnlockEntryUseCase","UnlockEntryRepository"],"sources":["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"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAWvD;;AAOA;AACA;AACA;;AAcA,OAAO,MAAMC,kBAAkB,GAAGD,iBAAiB,CAAsB,oBAAoB,CAAC;;AAO9F;AACA;AACA;;AAYA,OAAO,MAAME,qBAAqB,GAC9BF,iBAAiB,CAAyB,uBAAuB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { DomainEvent } from "@webiny/api-core/features/EventPublisher";
|
|
2
|
+
import type { IEventHandler } from "@webiny/api-core/features/EventPublisher";
|
|
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 EntryBeforeUnlockHandler: import("@webiny/di").Abstraction<IEventHandler<EntryBeforeUnlockEvent>>;
|
|
15
|
+
export declare namespace EntryBeforeUnlockHandler {
|
|
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 EntryAfterUnlockHandler: import("@webiny/di").Abstraction<IEventHandler<EntryAfterUnlockEvent>>;
|
|
29
|
+
export declare namespace EntryAfterUnlockHandler {
|
|
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 EntryUnlockErrorHandler: import("@webiny/di").Abstraction<IEventHandler<EntryUnlockErrorEvent>>;
|
|
43
|
+
export declare namespace EntryUnlockErrorHandler {
|
|
44
|
+
type Interface = IEventHandler<EntryUnlockErrorEvent>;
|
|
45
|
+
type Event = EntryUnlockErrorEvent;
|
|
46
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
import { DomainEvent } from "@webiny/api-core/features/EventPublisher";
|
|
3
|
+
|
|
4
|
+
// ============================================================================
|
|
5
|
+
// EntryBeforeUnlock Event
|
|
6
|
+
// ============================================================================
|
|
7
|
+
|
|
8
|
+
export class EntryBeforeUnlockEvent extends DomainEvent {
|
|
9
|
+
eventType = "RecordLocking/Entry/BeforeUnlock";
|
|
10
|
+
getHandlerAbstraction() {
|
|
11
|
+
return EntryBeforeUnlockHandler;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export const EntryBeforeUnlockHandler = createAbstraction("EntryBeforeUnlockHandler");
|
|
15
|
+
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// EntryAfterUnlock Event
|
|
18
|
+
// ============================================================================
|
|
19
|
+
|
|
20
|
+
export class EntryAfterUnlockEvent extends DomainEvent {
|
|
21
|
+
eventType = "RecordLocking/Entry/AfterUnlock";
|
|
22
|
+
getHandlerAbstraction() {
|
|
23
|
+
return EntryAfterUnlockHandler;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export const EntryAfterUnlockHandler = createAbstraction("EntryAfterUnlockHandler");
|
|
27
|
+
|
|
28
|
+
// ============================================================================
|
|
29
|
+
// EntryUnlockError Event
|
|
30
|
+
// ============================================================================
|
|
31
|
+
|
|
32
|
+
export class EntryUnlockErrorEvent extends DomainEvent {
|
|
33
|
+
eventType = "RecordLocking/Entry/UnlockError";
|
|
34
|
+
getHandlerAbstraction() {
|
|
35
|
+
return EntryUnlockErrorHandler;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export const EntryUnlockErrorHandler = createAbstraction("EntryUnlockErrorHandler");
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAbstraction","DomainEvent","EntryBeforeUnlockEvent","eventType","getHandlerAbstraction","EntryBeforeUnlockHandler","EntryAfterUnlockEvent","EntryAfterUnlockHandler","EntryUnlockErrorEvent","EntryUnlockErrorHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"@webiny/api-core/features/EventPublisher\";\nimport type { IEventHandler } from \"@webiny/api-core/features/EventPublisher\";\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 EntryBeforeUnlockHandler;\n }\n}\n\nexport const EntryBeforeUnlockHandler = createAbstraction<IEventHandler<EntryBeforeUnlockEvent>>(\n \"EntryBeforeUnlockHandler\"\n);\n\nexport namespace EntryBeforeUnlockHandler {\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 EntryAfterUnlockHandler;\n }\n}\n\nexport const EntryAfterUnlockHandler =\n createAbstraction<IEventHandler<EntryAfterUnlockEvent>>(\"EntryAfterUnlockHandler\");\n\nexport namespace EntryAfterUnlockHandler {\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 EntryUnlockErrorHandler;\n }\n}\n\nexport const EntryUnlockErrorHandler =\n createAbstraction<IEventHandler<EntryUnlockErrorEvent>>(\"EntryUnlockErrorHandler\");\n\nexport namespace EntryUnlockErrorHandler {\n export type Interface = IEventHandler<EntryUnlockErrorEvent>;\n export type Event = EntryUnlockErrorEvent;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW,QAAQ,0CAA0C;;AAKtE;AACA;AACA;;AAQA,OAAO,MAAMC,sBAAsB,SAASD,WAAW,CAA2B;EAC9EE,SAAS,GAAG,kCAAkC;EAE9CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,wBAAwB;EACnC;AACJ;AAEA,OAAO,MAAMA,wBAAwB,GAAGL,iBAAiB,CACrD,0BACJ,CAAC;;AAOD;AACA;AACA;;AAQA,OAAO,MAAMM,qBAAqB,SAASL,WAAW,CAA0B;EAC5EE,SAAS,GAAG,iCAAiC;EAE7CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,uBAAuB;EAClC;AACJ;AAEA,OAAO,MAAMA,uBAAuB,GAChCP,iBAAiB,CAAuC,yBAAyB,CAAC;;AAOtF;AACA;AACA;;AAQA,OAAO,MAAMQ,qBAAqB,SAASP,WAAW,CAA0B;EAC5EE,SAAS,GAAG,iCAAiC;EAE7CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOK,uBAAuB;EAClC;AACJ;AAEA,OAAO,MAAMA,uBAAuB,GAChCT,iBAAiB,CAAuC,yBAAyB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const UnlockEntryFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
|