@webiny/api-record-locking 6.0.0-alpha.5 → 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} +10 -21
- 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 +7 -3
- package/graphql/schema.js +99 -61
- package/graphql/schema.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.js +48 -25
- package/index.js.map +1 -1
- package/package.json +21 -25
- package/types.d.ts +3 -132
- package/types.js +2 -20
- package/types.js.map +1 -1
- package/utils/convertWhereCondition.d.ts +1 -1
- package/utils/convertWhereCondition.js +11 -14
- package/utils/convertWhereCondition.js.map +1 -1
- package/utils/getTimeout.js +1 -8
- 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 -7
- package/crud/crud.js +0 -204
- package/crud/crud.js.map +0 -1
- package/crud/model.d.ts +0 -2
- package/crud/model.js +0 -127
- package/crud/model.js.map +0 -1
- package/useCases/GetLockRecord/GetLockRecordUseCase.d.ts +0 -16
- package/useCases/GetLockRecord/GetLockRecordUseCase.js +0 -39
- package/useCases/GetLockRecord/GetLockRecordUseCase.js.map +0 -1
- package/useCases/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.d.ts +0 -16
- package/useCases/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js +0 -29
- package/useCases/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js.map +0 -1
- package/useCases/IsEntryLocked/IsEntryLockedUseCase.d.ts +0 -13
- package/useCases/IsEntryLocked/IsEntryLockedUseCase.js +0 -31
- package/useCases/IsEntryLocked/IsEntryLockedUseCase.js.map +0 -1
- package/useCases/KickOutCurrentUser/KickOutCurrentUserUseCase.d.ts +0 -12
- package/useCases/KickOutCurrentUser/KickOutCurrentUserUseCase.js +0 -46
- package/useCases/KickOutCurrentUser/KickOutCurrentUserUseCase.js.map +0 -1
- package/useCases/ListAllLockRecordsUseCase/ListAllLockRecordsUseCase.d.ts +0 -13
- package/useCases/ListAllLockRecordsUseCase/ListAllLockRecordsUseCase.js +0 -34
- package/useCases/ListAllLockRecordsUseCase/ListAllLockRecordsUseCase.js.map +0 -1
- package/useCases/ListLockRecordsUseCase/ListLockRecordsUseCase.d.ts +0 -14
- package/useCases/ListLockRecordsUseCase/ListLockRecordsUseCase.js +0 -27
- package/useCases/ListLockRecordsUseCase/ListLockRecordsUseCase.js.map +0 -1
- package/useCases/LockEntryUseCase/LockEntryUseCase.d.ts +0 -21
- package/useCases/LockEntryUseCase/LockEntryUseCase.js +0 -64
- package/useCases/LockEntryUseCase/LockEntryUseCase.js.map +0 -1
- package/useCases/UnlockEntryUseCase/UnlockEntryUseCase.d.ts +0 -23
- package/useCases/UnlockEntryUseCase/UnlockEntryUseCase.js +0 -90
- package/useCases/UnlockEntryUseCase/UnlockEntryUseCase.js.map +0 -1
- package/useCases/UnlockRequestUseCase/UnlockEntryRequestUseCase.d.ts +0 -21
- package/useCases/UnlockRequestUseCase/UnlockEntryRequestUseCase.js +0 -82
- package/useCases/UnlockRequestUseCase/UnlockEntryRequestUseCase.js.map +0 -1
- package/useCases/UpdateEntryLock/UpdateEntryLockUseCase.d.ts +0 -26
- package/useCases/UpdateEntryLock/UpdateEntryLockUseCase.js +0 -93
- package/useCases/UpdateEntryLock/UpdateEntryLockUseCase.js.map +0 -1
- package/useCases/index.d.ts +0 -31
- package/useCases/index.js +0 -96
- package/useCases/index.js.map +0 -1
- package/useCases/types.d.ts +0 -5
- package/useCases/types.js +0 -7
- package/useCases/types.js.map +0 -1
- package/utils/calculateExpiresOn.d.ts +0 -2
- package/utils/calculateExpiresOn.js +0 -16
- package/utils/calculateExpiresOn.js.map +0 -1
- package/utils/checkPermissions.d.ts +0 -7
- package/utils/checkPermissions.js +0 -21
- package/utils/checkPermissions.js.map +0 -1
- package/utils/convertEntryToLockRecord.d.ts +0 -28
- package/utils/convertEntryToLockRecord.js.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,16 +0,0 @@
|
|
|
1
|
-
import type { IGetLockRecordUseCase, IGetLockRecordUseCaseExecuteParams } from "../../abstractions/IGetLockRecordUseCase";
|
|
2
|
-
import type { IRecordLockingLockRecord, IRecordLockingModelManager } from "../../types";
|
|
3
|
-
import type { ConvertEntryToLockRecordCb } from "../types";
|
|
4
|
-
import type { Security } from "@webiny/api-security/types";
|
|
5
|
-
export interface IGetLockRecordUseCaseParams {
|
|
6
|
-
getManager(): Promise<IRecordLockingModelManager>;
|
|
7
|
-
getSecurity(): Pick<Security, "withoutAuthorization">;
|
|
8
|
-
convert: ConvertEntryToLockRecordCb;
|
|
9
|
-
}
|
|
10
|
-
export declare class GetLockRecordUseCase implements IGetLockRecordUseCase {
|
|
11
|
-
private readonly getManager;
|
|
12
|
-
private readonly getSecurity;
|
|
13
|
-
private readonly convert;
|
|
14
|
-
constructor(params: IGetLockRecordUseCaseParams);
|
|
15
|
-
execute(input: IGetLockRecordUseCaseExecuteParams): Promise<IRecordLockingLockRecord | null>;
|
|
16
|
-
}
|
|
@@ -1,39 +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 _lockRecordDatabaseId = require("../../utils/lockRecordDatabaseId");
|
|
9
|
-
var _utils = require("@webiny/utils");
|
|
10
|
-
class GetLockRecordUseCase {
|
|
11
|
-
constructor(params) {
|
|
12
|
-
this.getManager = params.getManager;
|
|
13
|
-
this.getSecurity = params.getSecurity;
|
|
14
|
-
this.convert = params.convert;
|
|
15
|
-
}
|
|
16
|
-
async execute(input) {
|
|
17
|
-
const recordId = (0, _lockRecordDatabaseId.createLockRecordDatabaseId)(input.id);
|
|
18
|
-
const id = (0, _utils.createIdentifier)({
|
|
19
|
-
id: recordId,
|
|
20
|
-
version: 1
|
|
21
|
-
});
|
|
22
|
-
const security = this.getSecurity();
|
|
23
|
-
try {
|
|
24
|
-
const manager = await this.getManager();
|
|
25
|
-
return await security.withoutAuthorization(async () => {
|
|
26
|
-
const result = await manager.get(id);
|
|
27
|
-
return this.convert(result);
|
|
28
|
-
});
|
|
29
|
-
} catch (ex) {
|
|
30
|
-
if (ex instanceof _handlerGraphql.NotFoundError) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
throw ex;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.GetLockRecordUseCase = GetLockRecordUseCase;
|
|
38
|
-
|
|
39
|
-
//# sourceMappingURL=GetLockRecordUseCase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_handlerGraphql","require","_lockRecordDatabaseId","_utils","GetLockRecordUseCase","constructor","params","getManager","getSecurity","convert","execute","input","recordId","createLockRecordDatabaseId","id","createIdentifier","version","security","manager","withoutAuthorization","result","get","ex","NotFoundError","exports"],"sources":["GetLockRecordUseCase.ts"],"sourcesContent":["import type {\n IGetLockRecordUseCase,\n IGetLockRecordUseCaseExecuteParams\n} from \"~/abstractions/IGetLockRecordUseCase\";\nimport type { IRecordLockingLockRecord, IRecordLockingModelManager } from \"~/types\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId\";\nimport { createIdentifier } from \"@webiny/utils\";\nimport type { ConvertEntryToLockRecordCb } from \"~/useCases/types\";\nimport type { Security } from \"@webiny/api-security/types\";\n\nexport interface IGetLockRecordUseCaseParams {\n getManager(): Promise<IRecordLockingModelManager>;\n getSecurity(): Pick<Security, \"withoutAuthorization\">;\n convert: ConvertEntryToLockRecordCb;\n}\n\nexport class GetLockRecordUseCase implements IGetLockRecordUseCase {\n private readonly getManager: IGetLockRecordUseCaseParams[\"getManager\"];\n private readonly getSecurity: IGetLockRecordUseCaseParams[\"getSecurity\"];\n private readonly convert: ConvertEntryToLockRecordCb;\n\n public constructor(params: IGetLockRecordUseCaseParams) {\n this.getManager = params.getManager;\n this.getSecurity = params.getSecurity;\n this.convert = params.convert;\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 const security = this.getSecurity();\n try {\n const manager = await this.getManager();\n return await security.withoutAuthorization(async () => {\n const result = await manager.get(id);\n return this.convert(result);\n });\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,qBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAUO,MAAMG,oBAAoB,CAAkC;EAKxDC,WAAWA,CAACC,MAAmC,EAAE;IACpD,IAAI,CAACC,UAAU,GAAGD,MAAM,CAACC,UAAU;IACnC,IAAI,CAACC,WAAW,GAAGF,MAAM,CAACE,WAAW;IACrC,IAAI,CAACC,OAAO,GAAGH,MAAM,CAACG,OAAO;EACjC;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,MAAMC,QAAQ,GAAG,IAAI,CAACT,WAAW,CAAC,CAAC;IACnC,IAAI;MACA,MAAMU,OAAO,GAAG,MAAM,IAAI,CAACX,UAAU,CAAC,CAAC;MACvC,OAAO,MAAMU,QAAQ,CAACE,oBAAoB,CAAC,YAAY;QACnD,MAAMC,MAAM,GAAG,MAAMF,OAAO,CAACG,GAAG,CAACP,EAAE,CAAC;QACpC,OAAO,IAAI,CAACL,OAAO,CAACW,MAAM,CAAC;MAC/B,CAAC,CAAC;IACN,CAAC,CAAC,OAAOE,EAAE,EAAE;MACT,IAAIA,EAAE,YAAYC,6BAAa,EAAE;QAC7B,OAAO,IAAI;MACf;MACA,MAAMD,EAAE;IACZ;EACJ;AACJ;AAACE,OAAA,CAAApB,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { IGetLockRecordUseCase } from "../../abstractions/IGetLockRecordUseCase";
|
|
2
|
-
import type { IGetIdentity, IRecordLockingLockRecord } from "../../types";
|
|
3
|
-
import type { IGetLockedEntryLockRecordUseCase, IGetLockedEntryLockRecordUseCaseExecuteParams } from "../../abstractions/IGetLockedEntryLockRecordUseCase";
|
|
4
|
-
export interface IGetLockedEntryLockRecordUseCaseParams {
|
|
5
|
-
getLockRecordUseCase: IGetLockRecordUseCase;
|
|
6
|
-
getIdentity: IGetIdentity;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* This use case is used to get a lock record for an entry - and the entry is still locked by someone other than the current user.
|
|
10
|
-
*/
|
|
11
|
-
export declare class GetLockedEntryLockRecordUseCase implements IGetLockedEntryLockRecordUseCase {
|
|
12
|
-
private readonly getLockRecordUseCase;
|
|
13
|
-
private readonly getIdentity;
|
|
14
|
-
constructor(params: IGetLockedEntryLockRecordUseCaseParams);
|
|
15
|
-
execute(params: IGetLockedEntryLockRecordUseCaseExecuteParams): Promise<IRecordLockingLockRecord | null>;
|
|
16
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.GetLockedEntryLockRecordUseCase = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* This use case is used to get a lock record for an entry - and the entry is still locked by someone other than the current user.
|
|
9
|
-
*/
|
|
10
|
-
class GetLockedEntryLockRecordUseCase {
|
|
11
|
-
constructor(params) {
|
|
12
|
-
this.getLockRecordUseCase = params.getLockRecordUseCase;
|
|
13
|
-
this.getIdentity = params.getIdentity;
|
|
14
|
-
}
|
|
15
|
-
async execute(params) {
|
|
16
|
-
const result = await this.getLockRecordUseCase.execute(params);
|
|
17
|
-
if (!result?.lockedBy?.id || result.isExpired()) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
const identity = this.getIdentity();
|
|
21
|
-
if (identity.id === result.lockedBy.id) {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
return result;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.GetLockedEntryLockRecordUseCase = GetLockedEntryLockRecordUseCase;
|
|
28
|
-
|
|
29
|
-
//# sourceMappingURL=GetLockedEntryLockRecordUseCase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["GetLockedEntryLockRecordUseCase","constructor","params","getLockRecordUseCase","getIdentity","execute","result","lockedBy","id","isExpired","identity","exports"],"sources":["GetLockedEntryLockRecordUseCase.ts"],"sourcesContent":["import type { IGetLockRecordUseCase } from \"~/abstractions/IGetLockRecordUseCase\";\nimport type { IGetIdentity, IRecordLockingLockRecord } from \"~/types\";\nimport type {\n IGetLockedEntryLockRecordUseCase,\n IGetLockedEntryLockRecordUseCaseExecuteParams\n} from \"~/abstractions/IGetLockedEntryLockRecordUseCase\";\n\nexport interface IGetLockedEntryLockRecordUseCaseParams {\n getLockRecordUseCase: IGetLockRecordUseCase;\n getIdentity: IGetIdentity;\n}\n\n/**\n * This use case is used to get a lock record for an entry - and the entry is still locked by someone other than the current user.\n */\nexport class GetLockedEntryLockRecordUseCase implements IGetLockedEntryLockRecordUseCase {\n private readonly getLockRecordUseCase: IGetLockRecordUseCase;\n private readonly getIdentity: IGetIdentity;\n\n public constructor(params: IGetLockedEntryLockRecordUseCaseParams) {\n this.getLockRecordUseCase = params.getLockRecordUseCase;\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?.id || result.isExpired()) {\n return null;\n }\n const identity = this.getIdentity();\n if (identity.id === result.lockedBy.id) {\n return null;\n }\n return result;\n }\n}\n"],"mappings":";;;;;;AAYA;AACA;AACA;AACO,MAAMA,+BAA+B,CAA6C;EAI9EC,WAAWA,CAACC,MAA8C,EAAE;IAC/D,IAAI,CAACC,oBAAoB,GAAGD,MAAM,CAACC,oBAAoB;IACvD,IAAI,CAACC,WAAW,GAAGF,MAAM,CAACE,WAAW;EACzC;EAEA,MAAaC,OAAOA,CAChBH,MAAqD,EACb;IACxC,MAAMI,MAAM,GAAG,MAAM,IAAI,CAACH,oBAAoB,CAACE,OAAO,CAACH,MAAM,CAAC;IAC9D,IAAI,CAACI,MAAM,EAAEC,QAAQ,EAAEC,EAAE,IAAIF,MAAM,CAACG,SAAS,CAAC,CAAC,EAAE;MAC7C,OAAO,IAAI;IACf;IACA,MAAMC,QAAQ,GAAG,IAAI,CAACN,WAAW,CAAC,CAAC;IACnC,IAAIM,QAAQ,CAACF,EAAE,KAAKF,MAAM,CAACC,QAAQ,CAACC,EAAE,EAAE;MACpC,OAAO,IAAI;IACf;IACA,OAAOF,MAAM;EACjB;AACJ;AAACK,OAAA,CAAAX,+BAAA,GAAAA,+BAAA","ignoreList":[]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { IIsEntryLockedUseCase, IIsEntryLockedUseCaseExecuteParams } from "../../abstractions/IIsEntryLocked";
|
|
2
|
-
import type { IGetLockRecordUseCase } from "../../abstractions/IGetLockRecordUseCase";
|
|
3
|
-
import type { IGetIdentity } from "../../types";
|
|
4
|
-
export interface IIsEntryLockedParams {
|
|
5
|
-
getLockRecordUseCase: IGetLockRecordUseCase;
|
|
6
|
-
getIdentity: IGetIdentity;
|
|
7
|
-
}
|
|
8
|
-
export declare class IsEntryLockedUseCase implements IIsEntryLockedUseCase {
|
|
9
|
-
private readonly getLockRecordUseCase;
|
|
10
|
-
private readonly getIdentity;
|
|
11
|
-
constructor(params: IIsEntryLockedParams);
|
|
12
|
-
execute(params: IIsEntryLockedUseCaseExecuteParams): Promise<boolean>;
|
|
13
|
-
}
|
|
@@ -1,31 +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.getIdentity = params.getIdentity;
|
|
12
|
-
}
|
|
13
|
-
async execute(params) {
|
|
14
|
-
try {
|
|
15
|
-
const result = await this.getLockRecordUseCase.execute(params);
|
|
16
|
-
if (!result || result.isExpired()) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
const identity = this.getIdentity();
|
|
20
|
-
return result.lockedBy.id !== identity.id;
|
|
21
|
-
} catch (ex) {
|
|
22
|
-
if (ex instanceof _handlerGraphql.NotFoundError === false) {
|
|
23
|
-
throw ex;
|
|
24
|
-
}
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.IsEntryLockedUseCase = IsEntryLockedUseCase;
|
|
30
|
-
|
|
31
|
-
//# sourceMappingURL=IsEntryLockedUseCase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_handlerGraphql","require","IsEntryLockedUseCase","constructor","params","getLockRecordUseCase","getIdentity","execute","result","isExpired","identity","lockedBy","id","ex","NotFoundError","exports"],"sources":["IsEntryLockedUseCase.ts"],"sourcesContent":["import type {\n IIsEntryLockedUseCase,\n IIsEntryLockedUseCaseExecuteParams\n} from \"~/abstractions/IIsEntryLocked\";\nimport type { IGetLockRecordUseCase } from \"~/abstractions/IGetLockRecordUseCase\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport type { IGetIdentity } from \"~/types\";\n\nexport interface IIsEntryLockedParams {\n getLockRecordUseCase: IGetLockRecordUseCase;\n getIdentity: IGetIdentity;\n}\n\nexport class IsEntryLockedUseCase implements IIsEntryLockedUseCase {\n private readonly getLockRecordUseCase: IGetLockRecordUseCase;\n private readonly getIdentity: IGetIdentity;\n\n public constructor(params: IIsEntryLockedParams) {\n this.getLockRecordUseCase = params.getLockRecordUseCase;\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 || result.isExpired()) {\n return false;\n }\n const identity = this.getIdentity();\n\n return result.lockedBy.id !== identity.id;\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;AAQO,MAAMC,oBAAoB,CAAkC;EAIxDC,WAAWA,CAACC,MAA4B,EAAE;IAC7C,IAAI,CAACC,oBAAoB,GAAGD,MAAM,CAACC,oBAAoB;IACvD,IAAI,CAACC,WAAW,GAAGF,MAAM,CAACE,WAAW;EACzC;EAEA,MAAaC,OAAOA,CAACH,MAA0C,EAAoB;IAC/E,IAAI;MACA,MAAMI,MAAM,GAAG,MAAM,IAAI,CAACH,oBAAoB,CAACE,OAAO,CAACH,MAAM,CAAC;MAC9D,IAAI,CAACI,MAAM,IAAIA,MAAM,CAACC,SAAS,CAAC,CAAC,EAAE;QAC/B,OAAO,KAAK;MAChB;MACA,MAAMC,QAAQ,GAAG,IAAI,CAACJ,WAAW,CAAC,CAAC;MAEnC,OAAOE,MAAM,CAACG,QAAQ,CAACC,EAAE,KAAKF,QAAQ,CAACE,EAAE;IAC7C,CAAC,CAAC,OAAOC,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 type { IKickOutCurrentUserUseCase, IKickOutCurrentUserUseCaseExecuteParams } from "../../abstractions/IKickOutCurrentUserUseCase";
|
|
2
|
-
import type { 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 type {\n IKickOutCurrentUserUseCase,\n IKickOutCurrentUserUseCaseExecuteParams\n} from \"~/abstractions/IKickOutCurrentUserUseCase\";\nimport type { 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,EAAE,+BAA+BJ,OAAO,EAAE;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,CACT,kEAAkEb,QAAQ,CAACC,EAAE,+BACjF,CAAC;MACDW,OAAO,CAACE,IAAI,CAACH,EAAE,CAAC;IACpB;EACJ;AACJ;AAACI,OAAA,CAAAtB,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { IListAllLockRecordsUseCase, IListAllLockRecordsUseCaseExecuteParams, IListAllLockRecordsUseCaseExecuteResponse } from "../../abstractions/IListAllLockRecordsUseCase";
|
|
2
|
-
import type { IRecordLockingModelManager } from "../../types";
|
|
3
|
-
import type { ConvertEntryToLockRecordCb } from "../types";
|
|
4
|
-
export interface IListAllLockRecordsUseCaseParams {
|
|
5
|
-
getManager(): Promise<IRecordLockingModelManager>;
|
|
6
|
-
convert: ConvertEntryToLockRecordCb;
|
|
7
|
-
}
|
|
8
|
-
export declare class ListAllLockRecordsUseCase implements IListAllLockRecordsUseCase {
|
|
9
|
-
private readonly getManager;
|
|
10
|
-
private readonly convert;
|
|
11
|
-
constructor(params: IListAllLockRecordsUseCaseParams);
|
|
12
|
-
execute(input: IListAllLockRecordsUseCaseExecuteParams): Promise<IListAllLockRecordsUseCaseExecuteResponse>;
|
|
13
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.ListAllLockRecordsUseCase = void 0;
|
|
7
|
-
var _convertWhereCondition = require("../../utils/convertWhereCondition");
|
|
8
|
-
class ListAllLockRecordsUseCase {
|
|
9
|
-
constructor(params) {
|
|
10
|
-
this.getManager = params.getManager;
|
|
11
|
-
this.convert = params.convert;
|
|
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(item => {
|
|
23
|
-
return this.convert(item);
|
|
24
|
-
}),
|
|
25
|
-
meta
|
|
26
|
-
};
|
|
27
|
-
} catch (ex) {
|
|
28
|
-
throw ex;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.ListAllLockRecordsUseCase = ListAllLockRecordsUseCase;
|
|
33
|
-
|
|
34
|
-
//# sourceMappingURL=ListAllLockRecordsUseCase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_convertWhereCondition","require","ListAllLockRecordsUseCase","constructor","params","getManager","convert","execute","input","manager","where","convertWhereCondition","items","meta","listLatest","map","item","ex","exports"],"sources":["ListAllLockRecordsUseCase.ts"],"sourcesContent":["import type {\n IListAllLockRecordsUseCase,\n IListAllLockRecordsUseCaseExecuteParams,\n IListAllLockRecordsUseCaseExecuteResponse\n} from \"~/abstractions/IListAllLockRecordsUseCase\";\nimport type { IRecordLockingModelManager } from \"~/types\";\nimport { convertWhereCondition } from \"~/utils/convertWhereCondition\";\nimport type { ConvertEntryToLockRecordCb } from \"~/useCases/types\";\n\nexport interface IListAllLockRecordsUseCaseParams {\n getManager(): Promise<IRecordLockingModelManager>;\n convert: ConvertEntryToLockRecordCb;\n}\n\nexport class ListAllLockRecordsUseCase implements IListAllLockRecordsUseCase {\n private readonly getManager: () => Promise<IRecordLockingModelManager>;\n private readonly convert: ConvertEntryToLockRecordCb;\n\n public constructor(params: IListAllLockRecordsUseCaseParams) {\n this.getManager = params.getManager;\n this.convert = params.convert;\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(item => {\n return this.convert(item);\n }),\n meta\n };\n } catch (ex) {\n throw ex;\n }\n }\n}\n"],"mappings":";;;;;;AAMA,IAAAA,sBAAA,GAAAC,OAAA;AAQO,MAAMC,yBAAyB,CAAuC;EAIlEC,WAAWA,CAACC,MAAwC,EAAE;IACzD,IAAI,CAACC,UAAU,GAAGD,MAAM,CAACC,UAAU;IACnC,IAAI,CAACC,OAAO,GAAGF,MAAM,CAACE,OAAO;EACjC;EACA,MAAaC,OAAOA,CAChBC,KAA8C,EACI;IAClD,IAAI;MACA,MAAMC,OAAO,GAAG,MAAM,IAAI,CAACJ,UAAU,CAAC,CAAC;MACvC,MAAMD,MAA+C,GAAG;QACpD,GAAGI,KAAK;QACRE,KAAK,EAAE,IAAAC,4CAAqB,EAACH,KAAK,CAACE,KAAK;MAC5C,CAAC;MAED,MAAM,CAACE,KAAK,EAAEC,IAAI,CAAC,GAAG,MAAMJ,OAAO,CAACK,UAAU,CAACV,MAAM,CAAC;MACtD,OAAO;QACHQ,KAAK,EAAEA,KAAK,CAACG,GAAG,CAACC,IAAI,IAAI;UACrB,OAAO,IAAI,CAACV,OAAO,CAACU,IAAI,CAAC;QAC7B,CAAC,CAAC;QACFH;MACJ,CAAC;IACL,CAAC,CAAC,OAAOI,EAAE,EAAE;MACT,MAAMA,EAAE;IACZ;EACJ;AACJ;AAACC,OAAA,CAAAhB,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { IListLockRecordsUseCase, IListLockRecordsUseCaseExecuteParams, IListLockRecordsUseCaseExecuteResponse } from "../../abstractions/IListLockRecordsUseCase";
|
|
2
|
-
import type { 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 type {\n IListLockRecordsUseCase,\n IListLockRecordsUseCaseExecuteParams,\n IListLockRecordsUseCaseExecuteResponse\n} from \"~/abstractions/IListLockRecordsUseCase\";\nimport type { 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,21 +0,0 @@
|
|
|
1
|
-
import type { ILockEntryUseCase, ILockEntryUseCaseExecuteParams } from "../../abstractions/ILockEntryUseCase";
|
|
2
|
-
import type { IRecordLockingLockRecord, IRecordLockingModelManager } from "../../types";
|
|
3
|
-
import type { IIsEntryLockedUseCase } from "../../abstractions/IIsEntryLocked";
|
|
4
|
-
import type { ConvertEntryToLockRecordCb } from "../types";
|
|
5
|
-
import type { Security, SecurityIdentity } from "@webiny/api-security/types";
|
|
6
|
-
export interface ILockEntryUseCaseParams {
|
|
7
|
-
isEntryLockedUseCase: IIsEntryLockedUseCase;
|
|
8
|
-
getManager(): Promise<IRecordLockingModelManager>;
|
|
9
|
-
getSecurity(): Pick<Security, "withoutAuthorization">;
|
|
10
|
-
getIdentity(): SecurityIdentity;
|
|
11
|
-
convert: ConvertEntryToLockRecordCb;
|
|
12
|
-
}
|
|
13
|
-
export declare class LockEntryUseCase implements ILockEntryUseCase {
|
|
14
|
-
private readonly isEntryLockedUseCase;
|
|
15
|
-
private readonly getManager;
|
|
16
|
-
private readonly getSecurity;
|
|
17
|
-
private readonly getIdentity;
|
|
18
|
-
private readonly convert;
|
|
19
|
-
constructor(params: ILockEntryUseCaseParams);
|
|
20
|
-
execute(params: ILockEntryUseCaseExecuteParams): Promise<IRecordLockingLockRecord>;
|
|
21
|
-
}
|
|
@@ -1,64 +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 _lockRecordDatabaseId = require("../../utils/lockRecordDatabaseId");
|
|
10
|
-
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
11
|
-
class LockEntryUseCase {
|
|
12
|
-
constructor(params) {
|
|
13
|
-
this.isEntryLockedUseCase = params.isEntryLockedUseCase;
|
|
14
|
-
this.getManager = params.getManager;
|
|
15
|
-
this.getSecurity = params.getSecurity;
|
|
16
|
-
this.getIdentity = params.getIdentity;
|
|
17
|
-
this.convert = params.convert;
|
|
18
|
-
}
|
|
19
|
-
async execute(params) {
|
|
20
|
-
let locked = false;
|
|
21
|
-
try {
|
|
22
|
-
locked = await this.isEntryLockedUseCase.execute(params);
|
|
23
|
-
} catch (ex) {
|
|
24
|
-
if (ex instanceof _handlerGraphql.NotFoundError === false) {
|
|
25
|
-
throw ex;
|
|
26
|
-
}
|
|
27
|
-
locked = false;
|
|
28
|
-
}
|
|
29
|
-
if (locked) {
|
|
30
|
-
throw new _error.default("Entry is already locked for editing.", "ENTRY_ALREADY_LOCKED", {
|
|
31
|
-
...params
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
const security = this.getSecurity();
|
|
35
|
-
const identity = this.getIdentity();
|
|
36
|
-
try {
|
|
37
|
-
const user = {
|
|
38
|
-
id: identity.id,
|
|
39
|
-
displayName: identity.displayName,
|
|
40
|
-
type: identity.type
|
|
41
|
-
};
|
|
42
|
-
const manager = await this.getManager();
|
|
43
|
-
const id = (0, _lockRecordDatabaseId.createLockRecordDatabaseId)(params.id);
|
|
44
|
-
return await security.withoutAuthorization(async () => {
|
|
45
|
-
const entry = await manager.create({
|
|
46
|
-
id,
|
|
47
|
-
createdBy: user,
|
|
48
|
-
savedBy: user,
|
|
49
|
-
targetId: params.id,
|
|
50
|
-
type: params.type,
|
|
51
|
-
actions: []
|
|
52
|
-
});
|
|
53
|
-
return this.convert(entry);
|
|
54
|
-
});
|
|
55
|
-
} catch (ex) {
|
|
56
|
-
throw new _error.default(`Could not lock entry: ${ex.message}`, ex.code || "LOCK_ENTRY_ERROR", {
|
|
57
|
-
...ex.data
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
exports.LockEntryUseCase = LockEntryUseCase;
|
|
63
|
-
|
|
64
|
-
//# sourceMappingURL=LockEntryUseCase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_lockRecordDatabaseId","_handlerGraphql","LockEntryUseCase","constructor","params","isEntryLockedUseCase","getManager","getSecurity","getIdentity","convert","execute","locked","ex","NotFoundError","WebinyError","security","identity","user","id","displayName","type","manager","createLockRecordDatabaseId","withoutAuthorization","entry","create","createdBy","savedBy","targetId","actions","message","code","data","exports"],"sources":["LockEntryUseCase.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n ILockEntryUseCase,\n ILockEntryUseCaseExecuteParams\n} from \"~/abstractions/ILockEntryUseCase\";\nimport type {\n IRecordLockingLockRecord,\n IRecordLockingLockRecordValues,\n IRecordLockingModelManager\n} from \"~/types\";\nimport type { IIsEntryLockedUseCase } from \"~/abstractions/IIsEntryLocked\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport type { ConvertEntryToLockRecordCb } from \"~/useCases/types\";\nimport type { Security, SecurityIdentity } from \"@webiny/api-security/types\";\n\nexport interface ILockEntryUseCaseParams {\n isEntryLockedUseCase: IIsEntryLockedUseCase;\n getManager(): Promise<IRecordLockingModelManager>;\n getSecurity(): Pick<Security, \"withoutAuthorization\">;\n getIdentity(): SecurityIdentity;\n convert: ConvertEntryToLockRecordCb;\n}\n\nexport class LockEntryUseCase implements ILockEntryUseCase {\n private readonly isEntryLockedUseCase: IIsEntryLockedUseCase;\n private readonly getManager: ILockEntryUseCaseParams[\"getManager\"];\n private readonly getSecurity: ILockEntryUseCaseParams[\"getSecurity\"];\n private readonly getIdentity: ILockEntryUseCaseParams[\"getIdentity\"];\n private readonly convert: ConvertEntryToLockRecordCb;\n\n public constructor(params: ILockEntryUseCaseParams) {\n this.isEntryLockedUseCase = params.isEntryLockedUseCase;\n this.getManager = params.getManager;\n this.getSecurity = params.getSecurity;\n this.getIdentity = params.getIdentity;\n this.convert = params.convert;\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 const security = this.getSecurity();\n const identity = this.getIdentity();\n try {\n const user: SecurityIdentity = {\n id: identity.id,\n displayName: identity.displayName,\n type: identity.type\n };\n const manager = await this.getManager();\n\n const id = createLockRecordDatabaseId(params.id);\n return await security.withoutAuthorization(async () => {\n const entry = await manager.create<IRecordLockingLockRecordValues>({\n id,\n createdBy: user,\n savedBy: user,\n targetId: params.id,\n type: params.type,\n actions: []\n });\n return this.convert(entry);\n });\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,qBAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAYO,MAAMG,gBAAgB,CAA8B;EAOhDC,WAAWA,CAACC,MAA+B,EAAE;IAChD,IAAI,CAACC,oBAAoB,GAAGD,MAAM,CAACC,oBAAoB;IACvD,IAAI,CAACC,UAAU,GAAGF,MAAM,CAACE,UAAU;IACnC,IAAI,CAACC,WAAW,GAAGH,MAAM,CAACG,WAAW;IACrC,IAAI,CAACC,WAAW,GAAGJ,MAAM,CAACI,WAAW;IACrC,IAAI,CAACC,OAAO,GAAGL,MAAM,CAACK,OAAO;EACjC;EAEA,MAAaC,OAAOA,CAChBN,MAAsC,EACL;IACjC,IAAIO,MAAM,GAAG,KAAK;IAClB,IAAI;MACAA,MAAM,GAAG,MAAM,IAAI,CAACN,oBAAoB,CAACK,OAAO,CAACN,MAAM,CAAC;IAC5D,CAAC,CAAC,OAAOQ,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,GAAGV;MACP,CAAC,CAAC;IACN;IACA,MAAMW,QAAQ,GAAG,IAAI,CAACR,WAAW,CAAC,CAAC;IACnC,MAAMS,QAAQ,GAAG,IAAI,CAACR,WAAW,CAAC,CAAC;IACnC,IAAI;MACA,MAAMS,IAAsB,GAAG;QAC3BC,EAAE,EAAEF,QAAQ,CAACE,EAAE;QACfC,WAAW,EAAEH,QAAQ,CAACG,WAAW;QACjCC,IAAI,EAAEJ,QAAQ,CAACI;MACnB,CAAC;MACD,MAAMC,OAAO,GAAG,MAAM,IAAI,CAACf,UAAU,CAAC,CAAC;MAEvC,MAAMY,EAAE,GAAG,IAAAI,gDAA0B,EAAClB,MAAM,CAACc,EAAE,CAAC;MAChD,OAAO,MAAMH,QAAQ,CAACQ,oBAAoB,CAAC,YAAY;QACnD,MAAMC,KAAK,GAAG,MAAMH,OAAO,CAACI,MAAM,CAAiC;UAC/DP,EAAE;UACFQ,SAAS,EAAET,IAAI;UACfU,OAAO,EAAEV,IAAI;UACbW,QAAQ,EAAExB,MAAM,CAACc,EAAE;UACnBE,IAAI,EAAEhB,MAAM,CAACgB,IAAI;UACjBS,OAAO,EAAE;QACb,CAAC,CAAC;QACF,OAAO,IAAI,CAACpB,OAAO,CAACe,KAAK,CAAC;MAC9B,CAAC,CAAC;IACN,CAAC,CAAC,OAAOZ,EAAE,EAAE;MACT,MAAM,IAAIE,cAAW,CACjB,yBAAyBF,EAAE,CAACkB,OAAO,EAAE,EACrClB,EAAE,CAACmB,IAAI,IAAI,kBAAkB,EAC7B;QACI,GAAGnB,EAAE,CAACoB;MACV,CACJ,CAAC;IACL;EACJ;AACJ;AAACC,OAAA,CAAA/B,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { IUnlockEntryUseCase, IUnlockEntryUseCaseExecuteParams } from "../../abstractions/IUnlockEntryUseCase";
|
|
2
|
-
import type { IGetIdentity, IHasRecordLockingAccessCallable, IRecordLockingLockRecord, IRecordLockingModelManager } from "../../types";
|
|
3
|
-
import type { IGetLockRecordUseCase } from "../../abstractions/IGetLockRecordUseCase";
|
|
4
|
-
import type { IKickOutCurrentUserUseCase } from "../../abstractions/IKickOutCurrentUserUseCase";
|
|
5
|
-
import type { Security } from "@webiny/api-security/types";
|
|
6
|
-
export interface IUnlockEntryUseCaseParams {
|
|
7
|
-
readonly getLockRecordUseCase: IGetLockRecordUseCase;
|
|
8
|
-
readonly kickOutCurrentUserUseCase: IKickOutCurrentUserUseCase;
|
|
9
|
-
getManager(): Promise<IRecordLockingModelManager>;
|
|
10
|
-
getSecurity(): Pick<Security, "withoutAuthorization">;
|
|
11
|
-
getIdentity: IGetIdentity;
|
|
12
|
-
hasRecordLockingAccess: IHasRecordLockingAccessCallable;
|
|
13
|
-
}
|
|
14
|
-
export declare class UnlockEntryUseCase implements IUnlockEntryUseCase {
|
|
15
|
-
private readonly getLockRecordUseCase;
|
|
16
|
-
private readonly kickOutCurrentUserUseCase;
|
|
17
|
-
private readonly getManager;
|
|
18
|
-
private readonly getSecurity;
|
|
19
|
-
private readonly getIdentity;
|
|
20
|
-
private readonly hasRecordLockingAccess;
|
|
21
|
-
constructor(params: IUnlockEntryUseCaseParams);
|
|
22
|
-
execute(params: IUnlockEntryUseCaseExecuteParams): Promise<IRecordLockingLockRecord>;
|
|
23
|
-
}
|