@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
package/crud/model.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createLockingModel = exports.RECORD_LOCKING_MODEL_ID = void 0;
|
|
7
|
-
var _apiHeadlessCms = require("@webiny/api-headless-cms");
|
|
8
|
-
const RECORD_LOCKING_MODEL_ID = exports.RECORD_LOCKING_MODEL_ID = "wby_recordLocking";
|
|
9
|
-
const createLockingModel = () => {
|
|
10
|
-
return (0, _apiHeadlessCms.createCmsModel)((0, _apiHeadlessCms.createPrivateModel)({
|
|
11
|
-
modelId: RECORD_LOCKING_MODEL_ID,
|
|
12
|
-
name: "Record Lock Tracking",
|
|
13
|
-
fields: [{
|
|
14
|
-
id: "targetId",
|
|
15
|
-
type: "text",
|
|
16
|
-
fieldId: "targetId",
|
|
17
|
-
storageId: "text@targetId",
|
|
18
|
-
label: "Target ID",
|
|
19
|
-
validation: [{
|
|
20
|
-
name: "required",
|
|
21
|
-
message: "Target ID is required."
|
|
22
|
-
}]
|
|
23
|
-
},
|
|
24
|
-
/**
|
|
25
|
-
* Since we need a generic way to track records, we will use type to determine if it's a cms record or a page or a form, etc...
|
|
26
|
-
* Update IHeadlessCmsLockRecordValues in types.ts file with additional fields as required.
|
|
27
|
-
*
|
|
28
|
-
* @see IHeadlessCmsLockRecordValues
|
|
29
|
-
*/
|
|
30
|
-
{
|
|
31
|
-
id: "type",
|
|
32
|
-
type: "text",
|
|
33
|
-
fieldId: "type",
|
|
34
|
-
storageId: "text@type",
|
|
35
|
-
label: "Record Type",
|
|
36
|
-
validation: [{
|
|
37
|
-
name: "required",
|
|
38
|
-
message: "Record type is required."
|
|
39
|
-
}]
|
|
40
|
-
}, {
|
|
41
|
-
id: "actions",
|
|
42
|
-
type: "object",
|
|
43
|
-
fieldId: "actions",
|
|
44
|
-
storageId: "object@actions",
|
|
45
|
-
label: "Actions",
|
|
46
|
-
multipleValues: true,
|
|
47
|
-
settings: {
|
|
48
|
-
fields: [{
|
|
49
|
-
id: "type",
|
|
50
|
-
type: "text",
|
|
51
|
-
fieldId: "type",
|
|
52
|
-
storageId: "text@type",
|
|
53
|
-
label: "Action Type",
|
|
54
|
-
validation: [{
|
|
55
|
-
name: "required",
|
|
56
|
-
message: "Action type is required."
|
|
57
|
-
}]
|
|
58
|
-
}, {
|
|
59
|
-
id: "message",
|
|
60
|
-
type: "text",
|
|
61
|
-
fieldId: "message",
|
|
62
|
-
storageId: "text@message",
|
|
63
|
-
label: "Message"
|
|
64
|
-
}, {
|
|
65
|
-
id: "createdBy",
|
|
66
|
-
type: "object",
|
|
67
|
-
fieldId: "createdBy",
|
|
68
|
-
storageId: "object@createdBy",
|
|
69
|
-
label: "Created By",
|
|
70
|
-
validation: [{
|
|
71
|
-
name: "required",
|
|
72
|
-
message: "Created by is required."
|
|
73
|
-
}],
|
|
74
|
-
settings: {
|
|
75
|
-
fields: [{
|
|
76
|
-
id: "id",
|
|
77
|
-
type: "text",
|
|
78
|
-
fieldId: "id",
|
|
79
|
-
storageId: "text@id",
|
|
80
|
-
label: "ID",
|
|
81
|
-
validation: [{
|
|
82
|
-
name: "required",
|
|
83
|
-
message: "ID is required."
|
|
84
|
-
}]
|
|
85
|
-
}, {
|
|
86
|
-
id: "displayName",
|
|
87
|
-
type: "text",
|
|
88
|
-
fieldId: "displayName",
|
|
89
|
-
storageId: "text@displayName",
|
|
90
|
-
label: "Display Name",
|
|
91
|
-
validation: [{
|
|
92
|
-
name: "required",
|
|
93
|
-
message: "Display name is required."
|
|
94
|
-
}]
|
|
95
|
-
}, {
|
|
96
|
-
id: "type",
|
|
97
|
-
type: "text",
|
|
98
|
-
fieldId: "type",
|
|
99
|
-
storageId: "text@type",
|
|
100
|
-
label: "Type",
|
|
101
|
-
validation: [{
|
|
102
|
-
name: "required",
|
|
103
|
-
message: "Type is required."
|
|
104
|
-
}]
|
|
105
|
-
}]
|
|
106
|
-
}
|
|
107
|
-
}, {
|
|
108
|
-
id: "createdOn",
|
|
109
|
-
type: "datetime",
|
|
110
|
-
fieldId: "createdOn",
|
|
111
|
-
storageId: "datetime@createdOn",
|
|
112
|
-
settings: {
|
|
113
|
-
type: "dateTimeWithoutTimezone"
|
|
114
|
-
},
|
|
115
|
-
label: "Created On",
|
|
116
|
-
validation: [{
|
|
117
|
-
name: "required",
|
|
118
|
-
message: "Created on is required."
|
|
119
|
-
}]
|
|
120
|
-
}]
|
|
121
|
-
}
|
|
122
|
-
}]
|
|
123
|
-
}));
|
|
124
|
-
};
|
|
125
|
-
exports.createLockingModel = createLockingModel;
|
|
126
|
-
|
|
127
|
-
//# sourceMappingURL=model.js.map
|
package/crud/model.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_apiHeadlessCms","require","RECORD_LOCKING_MODEL_ID","exports","createLockingModel","createCmsModel","createPrivateModel","modelId","name","fields","id","type","fieldId","storageId","label","validation","message","multipleValues","settings"],"sources":["model.ts"],"sourcesContent":["import { createCmsModel, createPrivateModel } from \"@webiny/api-headless-cms\";\n\nexport const RECORD_LOCKING_MODEL_ID = \"wby_recordLocking\";\n\nexport const createLockingModel = () => {\n return createCmsModel(\n createPrivateModel({\n modelId: RECORD_LOCKING_MODEL_ID,\n name: \"Record Lock Tracking\",\n fields: [\n {\n id: \"targetId\",\n type: \"text\",\n fieldId: \"targetId\",\n storageId: \"text@targetId\",\n label: \"Target ID\",\n validation: [\n {\n name: \"required\",\n message: \"Target ID is required.\"\n }\n ]\n },\n /**\n * Since we need a generic way to track records, we will use type to determine if it's a cms record or a page or a form, etc...\n * Update IHeadlessCmsLockRecordValues in types.ts file with additional fields as required.\n *\n * @see IHeadlessCmsLockRecordValues\n */\n {\n id: \"type\",\n type: \"text\",\n fieldId: \"type\",\n storageId: \"text@type\",\n label: \"Record Type\",\n validation: [\n {\n name: \"required\",\n message: \"Record type is required.\"\n }\n ]\n },\n {\n id: \"actions\",\n type: \"object\",\n fieldId: \"actions\",\n storageId: \"object@actions\",\n label: \"Actions\",\n multipleValues: true,\n settings: {\n fields: [\n {\n id: \"type\",\n type: \"text\",\n fieldId: \"type\",\n storageId: \"text@type\",\n label: \"Action Type\",\n validation: [\n {\n name: \"required\",\n message: \"Action type is required.\"\n }\n ]\n },\n {\n id: \"message\",\n type: \"text\",\n fieldId: \"message\",\n storageId: \"text@message\",\n label: \"Message\"\n },\n {\n id: \"createdBy\",\n type: \"object\",\n fieldId: \"createdBy\",\n storageId: \"object@createdBy\",\n label: \"Created By\",\n validation: [\n {\n name: \"required\",\n message: \"Created by is required.\"\n }\n ],\n settings: {\n fields: [\n {\n id: \"id\",\n type: \"text\",\n fieldId: \"id\",\n storageId: \"text@id\",\n label: \"ID\",\n validation: [\n {\n name: \"required\",\n message: \"ID is required.\"\n }\n ]\n },\n {\n id: \"displayName\",\n type: \"text\",\n fieldId: \"displayName\",\n storageId: \"text@displayName\",\n label: \"Display Name\",\n validation: [\n {\n name: \"required\",\n message: \"Display name is required.\"\n }\n ]\n },\n {\n id: \"type\",\n type: \"text\",\n fieldId: \"type\",\n storageId: \"text@type\",\n label: \"Type\",\n validation: [\n {\n name: \"required\",\n message: \"Type is required.\"\n }\n ]\n }\n ]\n }\n },\n {\n id: \"createdOn\",\n type: \"datetime\",\n fieldId: \"createdOn\",\n storageId: \"datetime@createdOn\",\n settings: {\n type: \"dateTimeWithoutTimezone\"\n },\n label: \"Created On\",\n validation: [\n {\n name: \"required\",\n message: \"Created on is required.\"\n }\n ]\n }\n ]\n }\n }\n ]\n })\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAEO,MAAMC,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAG,mBAAmB;AAEnD,MAAME,kBAAkB,GAAGA,CAAA,KAAM;EACpC,OAAO,IAAAC,8BAAc,EACjB,IAAAC,kCAAkB,EAAC;IACfC,OAAO,EAAEL,uBAAuB;IAChCM,IAAI,EAAE,sBAAsB;IAC5BC,MAAM,EAAE,CACJ;MACIC,EAAE,EAAE,UAAU;MACdC,IAAI,EAAE,MAAM;MACZC,OAAO,EAAE,UAAU;MACnBC,SAAS,EAAE,eAAe;MAC1BC,KAAK,EAAE,WAAW;MAClBC,UAAU,EAAE,CACR;QACIP,IAAI,EAAE,UAAU;QAChBQ,OAAO,EAAE;MACb,CAAC;IAET,CAAC;IACD;AAChB;AACA;AACA;AACA;AACA;IACgB;MACIN,EAAE,EAAE,MAAM;MACVC,IAAI,EAAE,MAAM;MACZC,OAAO,EAAE,MAAM;MACfC,SAAS,EAAE,WAAW;MACtBC,KAAK,EAAE,aAAa;MACpBC,UAAU,EAAE,CACR;QACIP,IAAI,EAAE,UAAU;QAChBQ,OAAO,EAAE;MACb,CAAC;IAET,CAAC,EACD;MACIN,EAAE,EAAE,SAAS;MACbC,IAAI,EAAE,QAAQ;MACdC,OAAO,EAAE,SAAS;MAClBC,SAAS,EAAE,gBAAgB;MAC3BC,KAAK,EAAE,SAAS;MAChBG,cAAc,EAAE,IAAI;MACpBC,QAAQ,EAAE;QACNT,MAAM,EAAE,CACJ;UACIC,EAAE,EAAE,MAAM;UACVC,IAAI,EAAE,MAAM;UACZC,OAAO,EAAE,MAAM;UACfC,SAAS,EAAE,WAAW;UACtBC,KAAK,EAAE,aAAa;UACpBC,UAAU,EAAE,CACR;YACIP,IAAI,EAAE,UAAU;YAChBQ,OAAO,EAAE;UACb,CAAC;QAET,CAAC,EACD;UACIN,EAAE,EAAE,SAAS;UACbC,IAAI,EAAE,MAAM;UACZC,OAAO,EAAE,SAAS;UAClBC,SAAS,EAAE,cAAc;UACzBC,KAAK,EAAE;QACX,CAAC,EACD;UACIJ,EAAE,EAAE,WAAW;UACfC,IAAI,EAAE,QAAQ;UACdC,OAAO,EAAE,WAAW;UACpBC,SAAS,EAAE,kBAAkB;UAC7BC,KAAK,EAAE,YAAY;UACnBC,UAAU,EAAE,CACR;YACIP,IAAI,EAAE,UAAU;YAChBQ,OAAO,EAAE;UACb,CAAC,CACJ;UACDE,QAAQ,EAAE;YACNT,MAAM,EAAE,CACJ;cACIC,EAAE,EAAE,IAAI;cACRC,IAAI,EAAE,MAAM;cACZC,OAAO,EAAE,IAAI;cACbC,SAAS,EAAE,SAAS;cACpBC,KAAK,EAAE,IAAI;cACXC,UAAU,EAAE,CACR;gBACIP,IAAI,EAAE,UAAU;gBAChBQ,OAAO,EAAE;cACb,CAAC;YAET,CAAC,EACD;cACIN,EAAE,EAAE,aAAa;cACjBC,IAAI,EAAE,MAAM;cACZC,OAAO,EAAE,aAAa;cACtBC,SAAS,EAAE,kBAAkB;cAC7BC,KAAK,EAAE,cAAc;cACrBC,UAAU,EAAE,CACR;gBACIP,IAAI,EAAE,UAAU;gBAChBQ,OAAO,EAAE;cACb,CAAC;YAET,CAAC,EACD;cACIN,EAAE,EAAE,MAAM;cACVC,IAAI,EAAE,MAAM;cACZC,OAAO,EAAE,MAAM;cACfC,SAAS,EAAE,WAAW;cACtBC,KAAK,EAAE,MAAM;cACbC,UAAU,EAAE,CACR;gBACIP,IAAI,EAAE,UAAU;gBAChBQ,OAAO,EAAE;cACb,CAAC;YAET,CAAC;UAET;QACJ,CAAC,EACD;UACIN,EAAE,EAAE,WAAW;UACfC,IAAI,EAAE,UAAU;UAChBC,OAAO,EAAE,WAAW;UACpBC,SAAS,EAAE,oBAAoB;UAC/BK,QAAQ,EAAE;YACNP,IAAI,EAAE;UACV,CAAC;UACDG,KAAK,EAAE,YAAY;UACnBC,UAAU,EAAE,CACR;YACIP,IAAI,EAAE,UAAU;YAChBQ,OAAO,EAAE;UACb,CAAC;QAET,CAAC;MAET;IACJ,CAAC;EAET,CAAC,CACL,CAAC;AACL,CAAC;AAACb,OAAA,CAAAC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { IGetLockRecordUseCase, IGetLockRecordUseCaseExecuteParams } from "../../abstractions/IGetLockRecordUseCase";
|
|
2
|
-
import { IRecordLockingModelManager, IRecordLockingLockRecord } from "../../types";
|
|
3
|
-
export interface IGetLockRecordUseCaseParams {
|
|
4
|
-
getManager(): Promise<IRecordLockingModelManager>;
|
|
5
|
-
}
|
|
6
|
-
export declare class GetLockRecordUseCase implements IGetLockRecordUseCase {
|
|
7
|
-
private readonly getManager;
|
|
8
|
-
constructor(params: IGetLockRecordUseCaseParams);
|
|
9
|
-
execute(input: IGetLockRecordUseCaseExecuteParams): Promise<IRecordLockingLockRecord | null>;
|
|
10
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.GetLockRecordUseCase = void 0;
|
|
7
|
-
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
8
|
-
var _convertEntryToLockRecord = require("../../utils/convertEntryToLockRecord");
|
|
9
|
-
var _lockRecordDatabaseId = require("../../utils/lockRecordDatabaseId");
|
|
10
|
-
var _utils = require("@webiny/utils");
|
|
11
|
-
class GetLockRecordUseCase {
|
|
12
|
-
constructor(params) {
|
|
13
|
-
this.getManager = params.getManager;
|
|
14
|
-
}
|
|
15
|
-
async execute(input) {
|
|
16
|
-
const recordId = (0, _lockRecordDatabaseId.createLockRecordDatabaseId)(input.id);
|
|
17
|
-
const id = (0, _utils.createIdentifier)({
|
|
18
|
-
id: recordId,
|
|
19
|
-
version: 1
|
|
20
|
-
});
|
|
21
|
-
try {
|
|
22
|
-
const manager = await this.getManager();
|
|
23
|
-
const result = await manager.get(id);
|
|
24
|
-
return (0, _convertEntryToLockRecord.convertEntryToLockRecord)(result);
|
|
25
|
-
} catch (ex) {
|
|
26
|
-
if (ex instanceof _handlerGraphql.NotFoundError) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
throw ex;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.GetLockRecordUseCase = GetLockRecordUseCase;
|
|
34
|
-
|
|
35
|
-
//# sourceMappingURL=GetLockRecordUseCase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_handlerGraphql","require","_convertEntryToLockRecord","_lockRecordDatabaseId","_utils","GetLockRecordUseCase","constructor","params","getManager","execute","input","recordId","createLockRecordDatabaseId","id","createIdentifier","version","manager","result","get","convertEntryToLockRecord","ex","NotFoundError","exports"],"sources":["GetLockRecordUseCase.ts"],"sourcesContent":["import {\n IGetLockRecordUseCase,\n IGetLockRecordUseCaseExecuteParams\n} from \"~/abstractions/IGetLockRecordUseCase\";\nimport { IRecordLockingModelManager, IRecordLockingLockRecord } from \"~/types\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { convertEntryToLockRecord } from \"~/utils/convertEntryToLockRecord\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId\";\nimport { createIdentifier } from \"@webiny/utils\";\n\nexport interface IGetLockRecordUseCaseParams {\n getManager(): Promise<IRecordLockingModelManager>;\n}\n\nexport class GetLockRecordUseCase implements IGetLockRecordUseCase {\n private readonly getManager: IGetLockRecordUseCaseParams[\"getManager\"];\n\n public constructor(params: IGetLockRecordUseCaseParams) {\n this.getManager = params.getManager;\n }\n\n public async execute(\n input: IGetLockRecordUseCaseExecuteParams\n ): Promise<IRecordLockingLockRecord | null> {\n const recordId = createLockRecordDatabaseId(input.id);\n const id = createIdentifier({\n id: recordId,\n version: 1\n });\n try {\n const manager = await this.getManager();\n const result = await manager.get(id);\n return convertEntryToLockRecord(result);\n } catch (ex) {\n if (ex instanceof NotFoundError) {\n return null;\n }\n throw ex;\n }\n }\n}\n"],"mappings":";;;;;;AAKA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,yBAAA,GAAAD,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAMO,MAAMI,oBAAoB,CAAkC;EAGxDC,WAAWA,CAACC,MAAmC,EAAE;IACpD,IAAI,CAACC,UAAU,GAAGD,MAAM,CAACC,UAAU;EACvC;EAEA,MAAaC,OAAOA,CAChBC,KAAyC,EACD;IACxC,MAAMC,QAAQ,GAAG,IAAAC,gDAA0B,EAACF,KAAK,CAACG,EAAE,CAAC;IACrD,MAAMA,EAAE,GAAG,IAAAC,uBAAgB,EAAC;MACxBD,EAAE,EAAEF,QAAQ;MACZI,OAAO,EAAE;IACb,CAAC,CAAC;IACF,IAAI;MACA,MAAMC,OAAO,GAAG,MAAM,IAAI,CAACR,UAAU,CAAC,CAAC;MACvC,MAAMS,MAAM,GAAG,MAAMD,OAAO,CAACE,GAAG,CAACL,EAAE,CAAC;MACpC,OAAO,IAAAM,kDAAwB,EAACF,MAAM,CAAC;IAC3C,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,IAAIA,EAAE,YAAYC,6BAAa,EAAE;QAC7B,OAAO,IAAI;MACf;MACA,MAAMD,EAAE;IACZ;EACJ;AACJ;AAACE,OAAA,CAAAjB,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { IGetLockRecordUseCase } from "../../abstractions/IGetLockRecordUseCase";
|
|
2
|
-
import { IGetIdentity, IRecordLockingLockRecord } from "../../types";
|
|
3
|
-
import { IGetLockedEntryLockRecordUseCase, IGetLockedEntryLockRecordUseCaseExecuteParams } from "../../abstractions/IGetLockedEntryLockRecordUseCase";
|
|
4
|
-
import { IIsLocked } from "../../utils/isLockedFactory";
|
|
5
|
-
export interface IGetLockedEntryLockRecordUseCaseParams {
|
|
6
|
-
getLockRecordUseCase: IGetLockRecordUseCase;
|
|
7
|
-
isLocked: IIsLocked;
|
|
8
|
-
getIdentity: IGetIdentity;
|
|
9
|
-
}
|
|
10
|
-
export declare class GetLockedEntryLockRecordUseCase implements IGetLockedEntryLockRecordUseCase {
|
|
11
|
-
private readonly getLockRecordUseCase;
|
|
12
|
-
private readonly isLocked;
|
|
13
|
-
private readonly getIdentity;
|
|
14
|
-
constructor(params: IGetLockedEntryLockRecordUseCaseParams);
|
|
15
|
-
execute(params: IGetLockedEntryLockRecordUseCaseExecuteParams): Promise<IRecordLockingLockRecord | null>;
|
|
16
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.GetLockedEntryLockRecordUseCase = void 0;
|
|
7
|
-
class GetLockedEntryLockRecordUseCase {
|
|
8
|
-
constructor(params) {
|
|
9
|
-
this.getLockRecordUseCase = params.getLockRecordUseCase;
|
|
10
|
-
this.isLocked = params.isLocked;
|
|
11
|
-
this.getIdentity = params.getIdentity;
|
|
12
|
-
}
|
|
13
|
-
async execute(params) {
|
|
14
|
-
const result = await this.getLockRecordUseCase.execute(params);
|
|
15
|
-
if (!result?.lockedBy) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
const identity = this.getIdentity();
|
|
19
|
-
if (identity.id === result.lockedBy.id) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
return this.isLocked(result) ? result : null;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.GetLockedEntryLockRecordUseCase = GetLockedEntryLockRecordUseCase;
|
|
26
|
-
|
|
27
|
-
//# sourceMappingURL=GetLockedEntryLockRecordUseCase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["GetLockedEntryLockRecordUseCase","constructor","params","getLockRecordUseCase","isLocked","getIdentity","execute","result","lockedBy","identity","id","exports"],"sources":["GetLockedEntryLockRecordUseCase.ts"],"sourcesContent":["import { IGetLockRecordUseCase } from \"~/abstractions/IGetLockRecordUseCase\";\nimport { IGetIdentity, IRecordLockingLockRecord } from \"~/types\";\nimport {\n IGetLockedEntryLockRecordUseCase,\n IGetLockedEntryLockRecordUseCaseExecuteParams\n} from \"~/abstractions/IGetLockedEntryLockRecordUseCase\";\nimport { IIsLocked } from \"~/utils/isLockedFactory\";\n\nexport interface IGetLockedEntryLockRecordUseCaseParams {\n getLockRecordUseCase: IGetLockRecordUseCase;\n isLocked: IIsLocked;\n getIdentity: IGetIdentity;\n}\n\nexport class GetLockedEntryLockRecordUseCase implements IGetLockedEntryLockRecordUseCase {\n private readonly getLockRecordUseCase: IGetLockRecordUseCase;\n private readonly isLocked: IIsLocked;\n private readonly getIdentity: IGetIdentity;\n\n public constructor(params: IGetLockedEntryLockRecordUseCaseParams) {\n this.getLockRecordUseCase = params.getLockRecordUseCase;\n this.isLocked = params.isLocked;\n this.getIdentity = params.getIdentity;\n }\n\n public async execute(\n params: IGetLockedEntryLockRecordUseCaseExecuteParams\n ): Promise<IRecordLockingLockRecord | null> {\n const result = await this.getLockRecordUseCase.execute(params);\n if (!result?.lockedBy) {\n return null;\n }\n const identity = this.getIdentity();\n if (identity.id === result.lockedBy.id) {\n return null;\n }\n return this.isLocked(result) ? result : null;\n }\n}\n"],"mappings":";;;;;;AAcO,MAAMA,+BAA+B,CAA6C;EAK9EC,WAAWA,CAACC,MAA8C,EAAE;IAC/D,IAAI,CAACC,oBAAoB,GAAGD,MAAM,CAACC,oBAAoB;IACvD,IAAI,CAACC,QAAQ,GAAGF,MAAM,CAACE,QAAQ;IAC/B,IAAI,CAACC,WAAW,GAAGH,MAAM,CAACG,WAAW;EACzC;EAEA,MAAaC,OAAOA,CAChBJ,MAAqD,EACb;IACxC,MAAMK,MAAM,GAAG,MAAM,IAAI,CAACJ,oBAAoB,CAACG,OAAO,CAACJ,MAAM,CAAC;IAC9D,IAAI,CAACK,MAAM,EAAEC,QAAQ,EAAE;MACnB,OAAO,IAAI;IACf;IACA,MAAMC,QAAQ,GAAG,IAAI,CAACJ,WAAW,CAAC,CAAC;IACnC,IAAII,QAAQ,CAACC,EAAE,KAAKH,MAAM,CAACC,QAAQ,CAACE,EAAE,EAAE;MACpC,OAAO,IAAI;IACf;IACA,OAAO,IAAI,CAACN,QAAQ,CAACG,MAAM,CAAC,GAAGA,MAAM,GAAG,IAAI;EAChD;AACJ;AAACI,OAAA,CAAAX,+BAAA,GAAAA,+BAAA","ignoreList":[]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { IIsEntryLockedUseCase, IIsEntryLockedUseCaseExecuteParams } from "../../abstractions/IIsEntryLocked";
|
|
2
|
-
import { IGetLockRecordUseCase } from "../../abstractions/IGetLockRecordUseCase";
|
|
3
|
-
import { IIsLocked } from "../../utils/isLockedFactory";
|
|
4
|
-
import { IGetIdentity } from "../../types";
|
|
5
|
-
export interface IIsEntryLockedParams {
|
|
6
|
-
getLockRecordUseCase: IGetLockRecordUseCase;
|
|
7
|
-
isLocked: IIsLocked;
|
|
8
|
-
getIdentity: IGetIdentity;
|
|
9
|
-
}
|
|
10
|
-
export declare class IsEntryLockedUseCase implements IIsEntryLockedUseCase {
|
|
11
|
-
private readonly getLockRecordUseCase;
|
|
12
|
-
private readonly isLocked;
|
|
13
|
-
private readonly getIdentity;
|
|
14
|
-
constructor(params: IIsEntryLockedParams);
|
|
15
|
-
execute(params: IIsEntryLockedUseCaseExecuteParams): Promise<boolean>;
|
|
16
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.IsEntryLockedUseCase = void 0;
|
|
7
|
-
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
8
|
-
class IsEntryLockedUseCase {
|
|
9
|
-
constructor(params) {
|
|
10
|
-
this.getLockRecordUseCase = params.getLockRecordUseCase;
|
|
11
|
-
this.isLocked = params.isLocked;
|
|
12
|
-
this.getIdentity = params.getIdentity;
|
|
13
|
-
}
|
|
14
|
-
async execute(params) {
|
|
15
|
-
try {
|
|
16
|
-
const result = await this.getLockRecordUseCase.execute(params);
|
|
17
|
-
if (!result) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
const identity = this.getIdentity();
|
|
21
|
-
if (result.lockedBy.id === identity.id) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
return this.isLocked(result);
|
|
25
|
-
} catch (ex) {
|
|
26
|
-
if (ex instanceof _handlerGraphql.NotFoundError === false) {
|
|
27
|
-
throw ex;
|
|
28
|
-
}
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.IsEntryLockedUseCase = IsEntryLockedUseCase;
|
|
34
|
-
|
|
35
|
-
//# sourceMappingURL=IsEntryLockedUseCase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_handlerGraphql","require","IsEntryLockedUseCase","constructor","params","getLockRecordUseCase","isLocked","getIdentity","execute","result","identity","lockedBy","id","ex","NotFoundError","exports"],"sources":["IsEntryLockedUseCase.ts"],"sourcesContent":["import {\n IIsEntryLockedUseCase,\n IIsEntryLockedUseCaseExecuteParams\n} from \"~/abstractions/IIsEntryLocked\";\nimport { IGetLockRecordUseCase } from \"~/abstractions/IGetLockRecordUseCase\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { IIsLocked } from \"~/utils/isLockedFactory\";\nimport { IGetIdentity } from \"~/types\";\n\nexport interface IIsEntryLockedParams {\n getLockRecordUseCase: IGetLockRecordUseCase;\n isLocked: IIsLocked;\n getIdentity: IGetIdentity;\n}\n\nexport class IsEntryLockedUseCase implements IIsEntryLockedUseCase {\n private readonly getLockRecordUseCase: IGetLockRecordUseCase;\n private readonly isLocked: IIsLocked;\n private readonly getIdentity: IGetIdentity;\n\n public constructor(params: IIsEntryLockedParams) {\n this.getLockRecordUseCase = params.getLockRecordUseCase;\n this.isLocked = params.isLocked;\n this.getIdentity = params.getIdentity;\n }\n\n public async execute(params: IIsEntryLockedUseCaseExecuteParams): Promise<boolean> {\n try {\n const result = await this.getLockRecordUseCase.execute(params);\n if (!result) {\n return false;\n }\n const identity = this.getIdentity();\n if (result.lockedBy.id === identity.id) {\n return false;\n }\n\n return this.isLocked(result);\n } catch (ex) {\n if (ex instanceof NotFoundError === false) {\n throw ex;\n }\n return false;\n }\n }\n}\n"],"mappings":";;;;;;AAKA,IAAAA,eAAA,GAAAC,OAAA;AAUO,MAAMC,oBAAoB,CAAkC;EAKxDC,WAAWA,CAACC,MAA4B,EAAE;IAC7C,IAAI,CAACC,oBAAoB,GAAGD,MAAM,CAACC,oBAAoB;IACvD,IAAI,CAACC,QAAQ,GAAGF,MAAM,CAACE,QAAQ;IAC/B,IAAI,CAACC,WAAW,GAAGH,MAAM,CAACG,WAAW;EACzC;EAEA,MAAaC,OAAOA,CAACJ,MAA0C,EAAoB;IAC/E,IAAI;MACA,MAAMK,MAAM,GAAG,MAAM,IAAI,CAACJ,oBAAoB,CAACG,OAAO,CAACJ,MAAM,CAAC;MAC9D,IAAI,CAACK,MAAM,EAAE;QACT,OAAO,KAAK;MAChB;MACA,MAAMC,QAAQ,GAAG,IAAI,CAACH,WAAW,CAAC,CAAC;MACnC,IAAIE,MAAM,CAACE,QAAQ,CAACC,EAAE,KAAKF,QAAQ,CAACE,EAAE,EAAE;QACpC,OAAO,KAAK;MAChB;MAEA,OAAO,IAAI,CAACN,QAAQ,CAACG,MAAM,CAAC;IAChC,CAAC,CAAC,OAAOI,EAAE,EAAE;MACT,IAAIA,EAAE,YAAYC,6BAAa,KAAK,KAAK,EAAE;QACvC,MAAMD,EAAE;MACZ;MACA,OAAO,KAAK;IAChB;EACJ;AACJ;AAACE,OAAA,CAAAb,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { IKickOutCurrentUserUseCase, IKickOutCurrentUserUseCaseExecuteParams } from "../../abstractions/IKickOutCurrentUserUseCase";
|
|
2
|
-
import { IGetIdentity, IGetWebsocketsContextCallable } from "../../types";
|
|
3
|
-
export interface IKickOutCurrentUserUseCaseParams {
|
|
4
|
-
getWebsockets: IGetWebsocketsContextCallable;
|
|
5
|
-
getIdentity: IGetIdentity;
|
|
6
|
-
}
|
|
7
|
-
export declare class KickOutCurrentUserUseCase implements IKickOutCurrentUserUseCase {
|
|
8
|
-
private readonly getWebsockets;
|
|
9
|
-
private readonly getIdentity;
|
|
10
|
-
constructor(params: IKickOutCurrentUserUseCaseParams);
|
|
11
|
-
execute(record: IKickOutCurrentUserUseCaseExecuteParams): Promise<void>;
|
|
12
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.KickOutCurrentUserUseCase = void 0;
|
|
7
|
-
var _utils = require("@webiny/utils");
|
|
8
|
-
class KickOutCurrentUserUseCase {
|
|
9
|
-
constructor(params) {
|
|
10
|
-
this.getWebsockets = params.getWebsockets;
|
|
11
|
-
this.getIdentity = params.getIdentity;
|
|
12
|
-
}
|
|
13
|
-
async execute(record) {
|
|
14
|
-
const {
|
|
15
|
-
lockedBy,
|
|
16
|
-
id
|
|
17
|
-
} = record;
|
|
18
|
-
const websockets = this.getWebsockets();
|
|
19
|
-
const {
|
|
20
|
-
id: entryId
|
|
21
|
-
} = (0, _utils.parseIdentifier)(id);
|
|
22
|
-
const identity = this.getIdentity();
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* We do not want any errors to leak out of this method.
|
|
26
|
-
* Just log the error, if any.
|
|
27
|
-
*/
|
|
28
|
-
try {
|
|
29
|
-
await websockets.send({
|
|
30
|
-
id: lockedBy.id
|
|
31
|
-
}, {
|
|
32
|
-
action: `recordLocking.entry.kickOut.${entryId}`,
|
|
33
|
-
data: {
|
|
34
|
-
record: record.toObject(),
|
|
35
|
-
user: identity
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
} catch (ex) {
|
|
39
|
-
console.error(`Could not send the kickOut message to a user with identity id: ${lockedBy.id}. More info in next log line.`);
|
|
40
|
-
console.info(ex);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.KickOutCurrentUserUseCase = KickOutCurrentUserUseCase;
|
|
45
|
-
|
|
46
|
-
//# sourceMappingURL=KickOutCurrentUserUseCase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_utils","require","KickOutCurrentUserUseCase","constructor","params","getWebsockets","getIdentity","execute","record","lockedBy","id","websockets","entryId","parseIdentifier","identity","send","action","data","toObject","user","ex","console","error","info","exports"],"sources":["KickOutCurrentUserUseCase.ts"],"sourcesContent":["import {\n IKickOutCurrentUserUseCase,\n IKickOutCurrentUserUseCaseExecuteParams\n} from \"~/abstractions/IKickOutCurrentUserUseCase\";\nimport { IGetIdentity, IGetWebsocketsContextCallable } from \"~/types\";\nimport { parseIdentifier } from \"@webiny/utils\";\n\nexport interface IKickOutCurrentUserUseCaseParams {\n getWebsockets: IGetWebsocketsContextCallable;\n getIdentity: IGetIdentity;\n}\n\nexport class KickOutCurrentUserUseCase implements IKickOutCurrentUserUseCase {\n private readonly getWebsockets: IGetWebsocketsContextCallable;\n private readonly getIdentity: IGetIdentity;\n\n public constructor(params: IKickOutCurrentUserUseCaseParams) {\n this.getWebsockets = params.getWebsockets;\n this.getIdentity = params.getIdentity;\n }\n\n public async execute(record: IKickOutCurrentUserUseCaseExecuteParams): Promise<void> {\n const { lockedBy, id } = record;\n\n const websockets = this.getWebsockets();\n\n const { id: entryId } = parseIdentifier(id);\n\n const identity = this.getIdentity();\n\n /**\n * We do not want any errors to leak out of this method.\n * Just log the error, if any.\n */\n try {\n await websockets.send(\n { id: lockedBy.id },\n {\n action: `recordLocking.entry.kickOut.${entryId}`,\n data: {\n record: record.toObject(),\n user: identity\n }\n }\n );\n } catch (ex) {\n console.error(\n `Could not send the kickOut message to a user with identity id: ${lockedBy.id}. More info in next log line.`\n );\n console.info(ex);\n }\n }\n}\n"],"mappings":";;;;;;AAKA,IAAAA,MAAA,GAAAC,OAAA;AAOO,MAAMC,yBAAyB,CAAuC;EAIlEC,WAAWA,CAACC,MAAwC,EAAE;IACzD,IAAI,CAACC,aAAa,GAAGD,MAAM,CAACC,aAAa;IACzC,IAAI,CAACC,WAAW,GAAGF,MAAM,CAACE,WAAW;EACzC;EAEA,MAAaC,OAAOA,CAACC,MAA+C,EAAiB;IACjF,MAAM;MAAEC,QAAQ;MAAEC;IAAG,CAAC,GAAGF,MAAM;IAE/B,MAAMG,UAAU,GAAG,IAAI,CAACN,aAAa,CAAC,CAAC;IAEvC,MAAM;MAAEK,EAAE,EAAEE;IAAQ,CAAC,GAAG,IAAAC,sBAAe,EAACH,EAAE,CAAC;IAE3C,MAAMI,QAAQ,GAAG,IAAI,CAACR,WAAW,CAAC,CAAC;;IAEnC;AACR;AACA;AACA;IACQ,IAAI;MACA,MAAMK,UAAU,CAACI,IAAI,CACjB;QAAEL,EAAE,EAAED,QAAQ,CAACC;MAAG,CAAC,EACnB;QACIM,MAAM,EAAG,+BAA8BJ,OAAQ,EAAC;QAChDK,IAAI,EAAE;UACFT,MAAM,EAAEA,MAAM,CAACU,QAAQ,CAAC,CAAC;UACzBC,IAAI,EAAEL;QACV;MACJ,CACJ,CAAC;IACL,CAAC,CAAC,OAAOM,EAAE,EAAE;MACTC,OAAO,CAACC,KAAK,CACR,kEAAiEb,QAAQ,CAACC,EAAG,+BAClF,CAAC;MACDW,OAAO,CAACE,IAAI,CAACH,EAAE,CAAC;IACpB;EACJ;AACJ;AAACI,OAAA,CAAAtB,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { IListAllLockRecordsUseCase, IListAllLockRecordsUseCaseExecuteParams, IListAllLockRecordsUseCaseExecuteResponse } from "../../abstractions/IListAllLockRecordsUseCase";
|
|
2
|
-
import { IRecordLockingModelManager } from "../../types";
|
|
3
|
-
export interface IListAllLockRecordsUseCaseParams {
|
|
4
|
-
getManager(): Promise<IRecordLockingModelManager>;
|
|
5
|
-
}
|
|
6
|
-
export declare class ListAllLockRecordsUseCase implements IListAllLockRecordsUseCase {
|
|
7
|
-
private readonly getManager;
|
|
8
|
-
constructor(params: IListAllLockRecordsUseCaseParams);
|
|
9
|
-
execute(input: IListAllLockRecordsUseCaseExecuteParams): Promise<IListAllLockRecordsUseCaseExecuteResponse>;
|
|
10
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ListAllLockRecordsUseCase = void 0;
|
|
7
|
-
var _convertEntryToLockRecord = require("../../utils/convertEntryToLockRecord");
|
|
8
|
-
var _convertWhereCondition = require("../../utils/convertWhereCondition");
|
|
9
|
-
class ListAllLockRecordsUseCase {
|
|
10
|
-
constructor(params) {
|
|
11
|
-
this.getManager = params.getManager;
|
|
12
|
-
}
|
|
13
|
-
async execute(input) {
|
|
14
|
-
try {
|
|
15
|
-
const manager = await this.getManager();
|
|
16
|
-
const params = {
|
|
17
|
-
...input,
|
|
18
|
-
where: (0, _convertWhereCondition.convertWhereCondition)(input.where)
|
|
19
|
-
};
|
|
20
|
-
const [items, meta] = await manager.listLatest(params);
|
|
21
|
-
return {
|
|
22
|
-
items: items.map(_convertEntryToLockRecord.convertEntryToLockRecord),
|
|
23
|
-
meta
|
|
24
|
-
};
|
|
25
|
-
} catch (ex) {
|
|
26
|
-
throw ex;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.ListAllLockRecordsUseCase = ListAllLockRecordsUseCase;
|
|
31
|
-
|
|
32
|
-
//# sourceMappingURL=ListAllLockRecordsUseCase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_convertEntryToLockRecord","require","_convertWhereCondition","ListAllLockRecordsUseCase","constructor","params","getManager","execute","input","manager","where","convertWhereCondition","items","meta","listLatest","map","convertEntryToLockRecord","ex","exports"],"sources":["ListAllLockRecordsUseCase.ts"],"sourcesContent":["import {\n IListAllLockRecordsUseCase,\n IListAllLockRecordsUseCaseExecuteParams,\n IListAllLockRecordsUseCaseExecuteResponse\n} from \"~/abstractions/IListAllLockRecordsUseCase\";\nimport { IRecordLockingModelManager } from \"~/types\";\nimport { convertEntryToLockRecord } from \"~/utils/convertEntryToLockRecord\";\nimport { convertWhereCondition } from \"~/utils/convertWhereCondition\";\n\nexport interface IListAllLockRecordsUseCaseParams {\n getManager(): Promise<IRecordLockingModelManager>;\n}\n\nexport class ListAllLockRecordsUseCase implements IListAllLockRecordsUseCase {\n private readonly getManager: () => Promise<IRecordLockingModelManager>;\n public constructor(params: IListAllLockRecordsUseCaseParams) {\n this.getManager = params.getManager;\n }\n public async execute(\n input: IListAllLockRecordsUseCaseExecuteParams\n ): Promise<IListAllLockRecordsUseCaseExecuteResponse> {\n try {\n const manager = await this.getManager();\n const params: IListAllLockRecordsUseCaseExecuteParams = {\n ...input,\n where: convertWhereCondition(input.where)\n };\n\n const [items, meta] = await manager.listLatest(params);\n return {\n items: items.map(convertEntryToLockRecord),\n meta\n };\n } catch (ex) {\n throw ex;\n }\n }\n}\n"],"mappings":";;;;;;AAMA,IAAAA,yBAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AAMO,MAAME,yBAAyB,CAAuC;EAElEC,WAAWA,CAACC,MAAwC,EAAE;IACzD,IAAI,CAACC,UAAU,GAAGD,MAAM,CAACC,UAAU;EACvC;EACA,MAAaC,OAAOA,CAChBC,KAA8C,EACI;IAClD,IAAI;MACA,MAAMC,OAAO,GAAG,MAAM,IAAI,CAACH,UAAU,CAAC,CAAC;MACvC,MAAMD,MAA+C,GAAG;QACpD,GAAGG,KAAK;QACRE,KAAK,EAAE,IAAAC,4CAAqB,EAACH,KAAK,CAACE,KAAK;MAC5C,CAAC;MAED,MAAM,CAACE,KAAK,EAAEC,IAAI,CAAC,GAAG,MAAMJ,OAAO,CAACK,UAAU,CAACT,MAAM,CAAC;MACtD,OAAO;QACHO,KAAK,EAAEA,KAAK,CAACG,GAAG,CAACC,kDAAwB,CAAC;QAC1CH;MACJ,CAAC;IACL,CAAC,CAAC,OAAOI,EAAE,EAAE;MACT,MAAMA,EAAE;IACZ;EACJ;AACJ;AAACC,OAAA,CAAAf,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { IListLockRecordsUseCase, IListLockRecordsUseCaseExecuteParams, IListLockRecordsUseCaseExecuteResponse } from "../../abstractions/IListLockRecordsUseCase";
|
|
2
|
-
import { IGetIdentity } from "../../types";
|
|
3
|
-
export interface IListLockRecordsUseCaseParams {
|
|
4
|
-
listAllLockRecordsUseCase: IListLockRecordsUseCase;
|
|
5
|
-
timeout: number;
|
|
6
|
-
getIdentity: IGetIdentity;
|
|
7
|
-
}
|
|
8
|
-
export declare class ListLockRecordsUseCase implements IListLockRecordsUseCase {
|
|
9
|
-
private readonly listAllLockRecordsUseCase;
|
|
10
|
-
private readonly timeout;
|
|
11
|
-
private readonly getIdentity;
|
|
12
|
-
constructor(params: IListLockRecordsUseCaseParams);
|
|
13
|
-
execute(input: IListLockRecordsUseCaseExecuteParams): Promise<IListLockRecordsUseCaseExecuteResponse>;
|
|
14
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ListLockRecordsUseCase = void 0;
|
|
7
|
-
class ListLockRecordsUseCase {
|
|
8
|
-
constructor(params) {
|
|
9
|
-
this.listAllLockRecordsUseCase = params.listAllLockRecordsUseCase;
|
|
10
|
-
this.timeout = params.timeout;
|
|
11
|
-
this.getIdentity = params.getIdentity;
|
|
12
|
-
}
|
|
13
|
-
async execute(input) {
|
|
14
|
-
const identity = this.getIdentity();
|
|
15
|
-
return this.listAllLockRecordsUseCase.execute({
|
|
16
|
-
...input,
|
|
17
|
-
where: {
|
|
18
|
-
...input.where,
|
|
19
|
-
createdBy_not: identity.id,
|
|
20
|
-
savedOn_gte: new Date(new Date().getTime() - this.timeout)
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.ListLockRecordsUseCase = ListLockRecordsUseCase;
|
|
26
|
-
|
|
27
|
-
//# sourceMappingURL=ListLockRecordsUseCase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["ListLockRecordsUseCase","constructor","params","listAllLockRecordsUseCase","timeout","getIdentity","execute","input","identity","where","createdBy_not","id","savedOn_gte","Date","getTime","exports"],"sources":["ListLockRecordsUseCase.ts"],"sourcesContent":["import {\n IListLockRecordsUseCase,\n IListLockRecordsUseCaseExecuteParams,\n IListLockRecordsUseCaseExecuteResponse\n} from \"~/abstractions/IListLockRecordsUseCase\";\nimport { IGetIdentity } from \"~/types\";\n\nexport interface IListLockRecordsUseCaseParams {\n listAllLockRecordsUseCase: IListLockRecordsUseCase;\n timeout: number;\n getIdentity: IGetIdentity;\n}\n\nexport class ListLockRecordsUseCase implements IListLockRecordsUseCase {\n private readonly listAllLockRecordsUseCase: IListLockRecordsUseCase;\n private readonly timeout: number;\n private readonly getIdentity: IGetIdentity;\n\n public constructor(params: IListLockRecordsUseCaseParams) {\n this.listAllLockRecordsUseCase = params.listAllLockRecordsUseCase;\n this.timeout = params.timeout;\n this.getIdentity = params.getIdentity;\n }\n public async execute(\n input: IListLockRecordsUseCaseExecuteParams\n ): Promise<IListLockRecordsUseCaseExecuteResponse> {\n const identity = this.getIdentity();\n return this.listAllLockRecordsUseCase.execute({\n ...input,\n where: {\n ...input.where,\n createdBy_not: identity.id,\n savedOn_gte: new Date(new Date().getTime() - this.timeout)\n }\n });\n }\n}\n"],"mappings":";;;;;;AAaO,MAAMA,sBAAsB,CAAoC;EAK5DC,WAAWA,CAACC,MAAqC,EAAE;IACtD,IAAI,CAACC,yBAAyB,GAAGD,MAAM,CAACC,yBAAyB;IACjE,IAAI,CAACC,OAAO,GAAGF,MAAM,CAACE,OAAO;IAC7B,IAAI,CAACC,WAAW,GAAGH,MAAM,CAACG,WAAW;EACzC;EACA,MAAaC,OAAOA,CAChBC,KAA2C,EACI;IAC/C,MAAMC,QAAQ,GAAG,IAAI,CAACH,WAAW,CAAC,CAAC;IACnC,OAAO,IAAI,CAACF,yBAAyB,CAACG,OAAO,CAAC;MAC1C,GAAGC,KAAK;MACRE,KAAK,EAAE;QACH,GAAGF,KAAK,CAACE,KAAK;QACdC,aAAa,EAAEF,QAAQ,CAACG,EAAE;QAC1BC,WAAW,EAAE,IAAIC,IAAI,CAAC,IAAIA,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC,GAAG,IAAI,CAACV,OAAO;MAC7D;IACJ,CAAC,CAAC;EACN;AACJ;AAACW,OAAA,CAAAf,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ILockEntryUseCase, ILockEntryUseCaseExecuteParams } from "../../abstractions/ILockEntryUseCase";
|
|
2
|
-
import { IRecordLockingLockRecord, IRecordLockingModelManager } from "../../types";
|
|
3
|
-
import { IIsEntryLockedUseCase } from "../../abstractions/IIsEntryLocked";
|
|
4
|
-
export interface ILockEntryUseCaseParams {
|
|
5
|
-
isEntryLockedUseCase: IIsEntryLockedUseCase;
|
|
6
|
-
getManager(): Promise<IRecordLockingModelManager>;
|
|
7
|
-
}
|
|
8
|
-
export declare class LockEntryUseCase implements ILockEntryUseCase {
|
|
9
|
-
private readonly isEntryLockedUseCase;
|
|
10
|
-
private readonly getManager;
|
|
11
|
-
constructor(params: ILockEntryUseCaseParams);
|
|
12
|
-
execute(params: ILockEntryUseCaseExecuteParams): Promise<IRecordLockingLockRecord>;
|
|
13
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.LockEntryUseCase = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
var _convertEntryToLockRecord = require("../../utils/convertEntryToLockRecord");
|
|
10
|
-
var _lockRecordDatabaseId = require("../../utils/lockRecordDatabaseId");
|
|
11
|
-
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
12
|
-
class LockEntryUseCase {
|
|
13
|
-
constructor(params) {
|
|
14
|
-
this.isEntryLockedUseCase = params.isEntryLockedUseCase;
|
|
15
|
-
this.getManager = params.getManager;
|
|
16
|
-
}
|
|
17
|
-
async execute(params) {
|
|
18
|
-
let locked = false;
|
|
19
|
-
try {
|
|
20
|
-
locked = await this.isEntryLockedUseCase.execute(params);
|
|
21
|
-
} catch (ex) {
|
|
22
|
-
if (ex instanceof _handlerGraphql.NotFoundError === false) {
|
|
23
|
-
throw ex;
|
|
24
|
-
}
|
|
25
|
-
locked = false;
|
|
26
|
-
}
|
|
27
|
-
if (locked) {
|
|
28
|
-
throw new _error.default("Entry is already locked for editing.", "ENTRY_ALREADY_LOCKED", {
|
|
29
|
-
...params
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
try {
|
|
33
|
-
const manager = await this.getManager();
|
|
34
|
-
const id = (0, _lockRecordDatabaseId.createLockRecordDatabaseId)(params.id);
|
|
35
|
-
const entry = await manager.create({
|
|
36
|
-
id,
|
|
37
|
-
targetId: params.id,
|
|
38
|
-
type: params.type,
|
|
39
|
-
actions: []
|
|
40
|
-
});
|
|
41
|
-
return (0, _convertEntryToLockRecord.convertEntryToLockRecord)(entry);
|
|
42
|
-
} catch (ex) {
|
|
43
|
-
throw new _error.default(`Could not lock entry: ${ex.message}`, ex.code || "LOCK_ENTRY_ERROR", {
|
|
44
|
-
...ex.data
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.LockEntryUseCase = LockEntryUseCase;
|
|
50
|
-
|
|
51
|
-
//# sourceMappingURL=LockEntryUseCase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_convertEntryToLockRecord","_lockRecordDatabaseId","_handlerGraphql","LockEntryUseCase","constructor","params","isEntryLockedUseCase","getManager","execute","locked","ex","NotFoundError","WebinyError","manager","id","createLockRecordDatabaseId","entry","create","targetId","type","actions","convertEntryToLockRecord","message","code","data","exports"],"sources":["LockEntryUseCase.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport {\n ILockEntryUseCase,\n ILockEntryUseCaseExecuteParams\n} from \"~/abstractions/ILockEntryUseCase\";\nimport {\n IRecordLockingLockRecord,\n IRecordLockingLockRecordValues,\n IRecordLockingModelManager\n} from \"~/types\";\nimport { IIsEntryLockedUseCase } from \"~/abstractions/IIsEntryLocked\";\nimport { convertEntryToLockRecord } from \"~/utils/convertEntryToLockRecord\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\n\nexport interface ILockEntryUseCaseParams {\n isEntryLockedUseCase: IIsEntryLockedUseCase;\n getManager(): Promise<IRecordLockingModelManager>;\n}\n\nexport class LockEntryUseCase implements ILockEntryUseCase {\n private readonly isEntryLockedUseCase: IIsEntryLockedUseCase;\n private readonly getManager: () => Promise<IRecordLockingModelManager>;\n\n public constructor(params: ILockEntryUseCaseParams) {\n this.isEntryLockedUseCase = params.isEntryLockedUseCase;\n this.getManager = params.getManager;\n }\n\n public async execute(\n params: ILockEntryUseCaseExecuteParams\n ): Promise<IRecordLockingLockRecord> {\n let locked = false;\n try {\n locked = await this.isEntryLockedUseCase.execute(params);\n } catch (ex) {\n if (ex instanceof NotFoundError === false) {\n throw ex;\n }\n locked = false;\n }\n if (locked) {\n throw new WebinyError(\"Entry is already locked for editing.\", \"ENTRY_ALREADY_LOCKED\", {\n ...params\n });\n }\n try {\n const manager = await this.getManager();\n\n const id = createLockRecordDatabaseId(params.id);\n const entry = await manager.create<IRecordLockingLockRecordValues>({\n id,\n targetId: params.id,\n type: params.type,\n actions: []\n });\n return convertEntryToLockRecord(entry);\n } catch (ex) {\n throw new WebinyError(\n `Could not lock entry: ${ex.message}`,\n ex.code || \"LOCK_ENTRY_ERROR\",\n {\n ...ex.data\n }\n );\n }\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAWA,IAAAC,yBAAA,GAAAD,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAOO,MAAMI,gBAAgB,CAA8B;EAIhDC,WAAWA,CAACC,MAA+B,EAAE;IAChD,IAAI,CAACC,oBAAoB,GAAGD,MAAM,CAACC,oBAAoB;IACvD,IAAI,CAACC,UAAU,GAAGF,MAAM,CAACE,UAAU;EACvC;EAEA,MAAaC,OAAOA,CAChBH,MAAsC,EACL;IACjC,IAAII,MAAM,GAAG,KAAK;IAClB,IAAI;MACAA,MAAM,GAAG,MAAM,IAAI,CAACH,oBAAoB,CAACE,OAAO,CAACH,MAAM,CAAC;IAC5D,CAAC,CAAC,OAAOK,EAAE,EAAE;MACT,IAAIA,EAAE,YAAYC,6BAAa,KAAK,KAAK,EAAE;QACvC,MAAMD,EAAE;MACZ;MACAD,MAAM,GAAG,KAAK;IAClB;IACA,IAAIA,MAAM,EAAE;MACR,MAAM,IAAIG,cAAW,CAAC,sCAAsC,EAAE,sBAAsB,EAAE;QAClF,GAAGP;MACP,CAAC,CAAC;IACN;IACA,IAAI;MACA,MAAMQ,OAAO,GAAG,MAAM,IAAI,CAACN,UAAU,CAAC,CAAC;MAEvC,MAAMO,EAAE,GAAG,IAAAC,gDAA0B,EAACV,MAAM,CAACS,EAAE,CAAC;MAChD,MAAME,KAAK,GAAG,MAAMH,OAAO,CAACI,MAAM,CAAiC;QAC/DH,EAAE;QACFI,QAAQ,EAAEb,MAAM,CAACS,EAAE;QACnBK,IAAI,EAAEd,MAAM,CAACc,IAAI;QACjBC,OAAO,EAAE;MACb,CAAC,CAAC;MACF,OAAO,IAAAC,kDAAwB,EAACL,KAAK,CAAC;IAC1C,CAAC,CAAC,OAAON,EAAE,EAAE;MACT,MAAM,IAAIE,cAAW,CAChB,yBAAwBF,EAAE,CAACY,OAAQ,EAAC,EACrCZ,EAAE,CAACa,IAAI,IAAI,kBAAkB,EAC7B;QACI,GAAGb,EAAE,CAACc;MACV,CACJ,CAAC;IACL;EACJ;AACJ;AAACC,OAAA,CAAAtB,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { IUnlockEntryUseCase, IUnlockEntryUseCaseExecuteParams } from "../../abstractions/IUnlockEntryUseCase";
|
|
2
|
-
import { IGetIdentity, IHasFullAccessCallable, IRecordLockingLockRecord, IRecordLockingModelManager } from "../../types";
|
|
3
|
-
import { IGetLockRecordUseCase } from "../../abstractions/IGetLockRecordUseCase";
|
|
4
|
-
import { IKickOutCurrentUserUseCase } from "../../abstractions/IKickOutCurrentUserUseCase";
|
|
5
|
-
export interface IUnlockEntryUseCaseParams {
|
|
6
|
-
readonly getLockRecordUseCase: IGetLockRecordUseCase;
|
|
7
|
-
readonly kickOutCurrentUserUseCase: IKickOutCurrentUserUseCase;
|
|
8
|
-
getManager(): Promise<IRecordLockingModelManager>;
|
|
9
|
-
getIdentity: IGetIdentity;
|
|
10
|
-
hasFullAccess: IHasFullAccessCallable;
|
|
11
|
-
}
|
|
12
|
-
export declare class UnlockEntryUseCase implements IUnlockEntryUseCase {
|
|
13
|
-
private readonly getLockRecordUseCase;
|
|
14
|
-
private readonly kickOutCurrentUserUseCase;
|
|
15
|
-
private readonly getManager;
|
|
16
|
-
private readonly getIdentity;
|
|
17
|
-
private readonly hasFullAccess;
|
|
18
|
-
constructor(params: IUnlockEntryUseCaseParams);
|
|
19
|
-
execute(params: IUnlockEntryUseCaseExecuteParams): Promise<IRecordLockingLockRecord>;
|
|
20
|
-
}
|