@webiny/api-record-locking 0.0.0-unstable.a4637c5ce6 → 0.0.0-unstable.a4f3e4ea8b

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.
Files changed (285) hide show
  1. package/README.md +10 -9
  2. package/domain/LockRecord.d.ts +45 -0
  3. package/domain/LockRecord.js +73 -0
  4. package/domain/LockRecord.js.map +1 -0
  5. package/domain/RecordLockingModel.d.ts +9 -0
  6. package/domain/RecordLockingModel.js +32 -0
  7. package/domain/RecordLockingModel.js.map +1 -0
  8. package/domain/abstractions.d.ts +18 -0
  9. package/domain/abstractions.js +6 -0
  10. package/domain/abstractions.js.map +1 -0
  11. package/domain/calculateExpiresOn.d.ts +1 -0
  12. package/domain/calculateExpiresOn.js +8 -0
  13. package/domain/calculateExpiresOn.js.map +1 -0
  14. package/domain/errors.d.ts +71 -0
  15. package/domain/errors.js +85 -0
  16. package/domain/errors.js.map +1 -0
  17. package/domain/index.d.ts +4 -0
  18. package/domain/index.js +4 -0
  19. package/domain/types.d.ts +44 -0
  20. package/domain/types.js +9 -0
  21. package/domain/types.js.map +1 -0
  22. package/features/GetLockRecord/GetLockRecordRepository.d.ts +16 -0
  23. package/features/GetLockRecord/GetLockRecordRepository.js +40 -0
  24. package/features/GetLockRecord/GetLockRecordRepository.js.map +1 -0
  25. package/features/GetLockRecord/GetLockRecordUseCase.d.ts +12 -0
  26. package/features/GetLockRecord/GetLockRecordUseCase.js +18 -0
  27. package/features/GetLockRecord/GetLockRecordUseCase.js.map +1 -0
  28. package/features/GetLockRecord/abstractions.d.ts +41 -0
  29. package/features/GetLockRecord/abstractions.js +6 -0
  30. package/features/GetLockRecord/abstractions.js.map +1 -0
  31. package/features/GetLockRecord/feature.d.ts +4 -0
  32. package/features/GetLockRecord/feature.js +13 -0
  33. package/features/GetLockRecord/feature.js.map +1 -0
  34. package/features/GetLockRecord/index.d.ts +2 -0
  35. package/features/GetLockRecord/index.js +2 -0
  36. package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.d.ts +15 -0
  37. package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js +30 -0
  38. package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js.map +1 -0
  39. package/features/GetLockedEntryLockRecord/abstractions.d.ts +26 -0
  40. package/features/GetLockedEntryLockRecord/abstractions.js +5 -0
  41. package/features/GetLockedEntryLockRecord/abstractions.js.map +1 -0
  42. package/features/GetLockedEntryLockRecord/feature.d.ts +4 -0
  43. package/features/GetLockedEntryLockRecord/feature.js +11 -0
  44. package/features/GetLockedEntryLockRecord/feature.js.map +1 -0
  45. package/features/GetLockedEntryLockRecord/index.d.ts +2 -0
  46. package/features/GetLockedEntryLockRecord/index.js +2 -0
  47. package/features/IsEntryLocked/IsEntryLockedUseCase.d.ts +14 -0
  48. package/features/IsEntryLocked/IsEntryLockedUseCase.js +33 -0
  49. package/features/IsEntryLocked/IsEntryLockedUseCase.js.map +1 -0
  50. package/features/IsEntryLocked/abstractions.d.ts +24 -0
  51. package/features/IsEntryLocked/abstractions.js +5 -0
  52. package/features/IsEntryLocked/abstractions.js.map +1 -0
  53. package/features/IsEntryLocked/feature.d.ts +4 -0
  54. package/features/IsEntryLocked/feature.js +11 -0
  55. package/features/IsEntryLocked/feature.js.map +1 -0
  56. package/features/IsEntryLocked/index.d.ts +1 -0
  57. package/features/IsEntryLocked/index.js +1 -0
  58. package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.d.ts +15 -0
  59. package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js +36 -0
  60. package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js.map +1 -0
  61. package/features/KickOutCurrentUser/abstractions.d.ts +17 -0
  62. package/features/KickOutCurrentUser/abstractions.js +5 -0
  63. package/features/KickOutCurrentUser/abstractions.js.map +1 -0
  64. package/features/KickOutCurrentUser/feature.d.ts +4 -0
  65. package/features/KickOutCurrentUser/feature.js +11 -0
  66. package/features/KickOutCurrentUser/feature.js.map +1 -0
  67. package/features/KickOutCurrentUser/index.d.ts +1 -0
  68. package/features/KickOutCurrentUser/index.js +1 -0
  69. package/features/ListAllLockRecords/ListAllLockRecordsRepository.d.ts +18 -0
  70. package/features/ListAllLockRecords/ListAllLockRecordsRepository.js +49 -0
  71. package/features/ListAllLockRecords/ListAllLockRecordsRepository.js.map +1 -0
  72. package/features/ListAllLockRecords/ListAllLockRecordsUseCase.d.ts +11 -0
  73. package/features/ListAllLockRecords/ListAllLockRecordsUseCase.js +18 -0
  74. package/features/ListAllLockRecords/ListAllLockRecordsUseCase.js.map +1 -0
  75. package/features/ListAllLockRecords/abstractions.d.ts +40 -0
  76. package/features/ListAllLockRecords/abstractions.js +6 -0
  77. package/features/ListAllLockRecords/abstractions.js.map +1 -0
  78. package/features/ListAllLockRecords/feature.d.ts +4 -0
  79. package/features/ListAllLockRecords/feature.js +13 -0
  80. package/features/ListAllLockRecords/feature.js.map +1 -0
  81. package/features/ListAllLockRecords/index.d.ts +2 -0
  82. package/features/ListAllLockRecords/index.js +2 -0
  83. package/features/ListLockRecords/ListLockRecordsRepository.d.ts +17 -0
  84. package/features/ListLockRecords/ListLockRecordsRepository.js +49 -0
  85. package/features/ListLockRecords/ListLockRecordsRepository.js.map +1 -0
  86. package/features/ListLockRecords/ListLockRecordsUseCase.d.ts +15 -0
  87. package/features/ListLockRecords/ListLockRecordsUseCase.js +33 -0
  88. package/features/ListLockRecords/ListLockRecordsUseCase.js.map +1 -0
  89. package/features/ListLockRecords/abstractions.d.ts +45 -0
  90. package/features/ListLockRecords/abstractions.js +6 -0
  91. package/features/ListLockRecords/abstractions.js.map +1 -0
  92. package/features/ListLockRecords/feature.d.ts +4 -0
  93. package/features/ListLockRecords/feature.js +13 -0
  94. package/features/ListLockRecords/feature.js.map +1 -0
  95. package/features/ListLockRecords/index.d.ts +1 -0
  96. package/features/ListLockRecords/index.js +1 -0
  97. package/features/LockEntry/LockEntryEventsDecorator.d.ts +14 -0
  98. package/features/LockEntry/LockEntryEventsDecorator.js +40 -0
  99. package/features/LockEntry/LockEntryEventsDecorator.js.map +1 -0
  100. package/features/LockEntry/LockEntryRepository.d.ts +16 -0
  101. package/features/LockEntry/LockEntryRepository.js +45 -0
  102. package/features/LockEntry/LockEntryRepository.js.map +1 -0
  103. package/features/LockEntry/LockEntryUseCase.d.ts +14 -0
  104. package/features/LockEntry/LockEntryUseCase.js +31 -0
  105. package/features/LockEntry/LockEntryUseCase.js.map +1 -0
  106. package/features/LockEntry/abstractions.d.ts +41 -0
  107. package/features/LockEntry/abstractions.js +6 -0
  108. package/features/LockEntry/abstractions.js.map +1 -0
  109. package/features/LockEntry/events.d.ts +45 -0
  110. package/features/LockEntry/events.js +32 -0
  111. package/features/LockEntry/events.js.map +1 -0
  112. package/features/LockEntry/feature.d.ts +4 -0
  113. package/features/LockEntry/feature.js +15 -0
  114. package/features/LockEntry/feature.js.map +1 -0
  115. package/features/LockEntry/index.d.ts +1 -0
  116. package/features/LockEntry/index.js +1 -0
  117. package/features/RecordLockingFeature.d.ts +15 -0
  118. package/features/RecordLockingFeature.js +34 -0
  119. package/features/RecordLockingFeature.js.map +1 -0
  120. package/features/UnlockEntry/UnlockEntryEventsDecorator.d.ts +14 -0
  121. package/features/UnlockEntry/UnlockEntryEventsDecorator.js +41 -0
  122. package/features/UnlockEntry/UnlockEntryEventsDecorator.js.map +1 -0
  123. package/features/UnlockEntry/UnlockEntryRepository.d.ts +14 -0
  124. package/features/UnlockEntry/UnlockEntryRepository.js +42 -0
  125. package/features/UnlockEntry/UnlockEntryRepository.js.map +1 -0
  126. package/features/UnlockEntry/UnlockEntryUseCase.d.ts +18 -0
  127. package/features/UnlockEntry/UnlockEntryUseCase.js +65 -0
  128. package/features/UnlockEntry/UnlockEntryUseCase.js.map +1 -0
  129. package/features/UnlockEntry/abstractions.d.ts +44 -0
  130. package/features/UnlockEntry/abstractions.js +6 -0
  131. package/features/UnlockEntry/abstractions.js.map +1 -0
  132. package/features/UnlockEntry/events.d.ts +46 -0
  133. package/features/UnlockEntry/events.js +32 -0
  134. package/features/UnlockEntry/events.js.map +1 -0
  135. package/features/UnlockEntry/feature.d.ts +4 -0
  136. package/features/UnlockEntry/feature.js +15 -0
  137. package/features/UnlockEntry/feature.js.map +1 -0
  138. package/features/UnlockEntry/hasFullAccessPermission.d.ts +2 -0
  139. package/features/UnlockEntry/hasFullAccessPermission.js +9 -0
  140. package/features/UnlockEntry/hasFullAccessPermission.js.map +1 -0
  141. package/features/UnlockEntry/index.d.ts +1 -0
  142. package/features/UnlockEntry/index.js +1 -0
  143. package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.d.ts +14 -0
  144. package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js +40 -0
  145. package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js.map +1 -0
  146. package/features/UnlockEntryRequest/UnlockEntryRequestRepository.d.ts +17 -0
  147. package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js +44 -0
  148. package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js.map +1 -0
  149. package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.d.ts +16 -0
  150. package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js +75 -0
  151. package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js.map +1 -0
  152. package/features/UnlockEntryRequest/abstractions.d.ts +42 -0
  153. package/features/UnlockEntryRequest/abstractions.js +6 -0
  154. package/features/UnlockEntryRequest/abstractions.js.map +1 -0
  155. package/features/UnlockEntryRequest/events.d.ts +45 -0
  156. package/features/UnlockEntryRequest/events.js +32 -0
  157. package/features/UnlockEntryRequest/events.js.map +1 -0
  158. package/features/UnlockEntryRequest/feature.d.ts +4 -0
  159. package/features/UnlockEntryRequest/feature.js +15 -0
  160. package/features/UnlockEntryRequest/feature.js.map +1 -0
  161. package/features/UnlockEntryRequest/index.d.ts +3 -0
  162. package/features/UnlockEntryRequest/index.js +3 -0
  163. package/features/UpdateEntryLock/UpdateEntryLockRepository.d.ts +20 -0
  164. package/features/UpdateEntryLock/UpdateEntryLockRepository.js +60 -0
  165. package/features/UpdateEntryLock/UpdateEntryLockRepository.js.map +1 -0
  166. package/features/UpdateEntryLock/UpdateEntryLockUseCase.d.ts +18 -0
  167. package/features/UpdateEntryLock/UpdateEntryLockUseCase.js +51 -0
  168. package/features/UpdateEntryLock/UpdateEntryLockUseCase.js.map +1 -0
  169. package/features/UpdateEntryLock/abstractions.d.ts +42 -0
  170. package/features/UpdateEntryLock/abstractions.js +6 -0
  171. package/features/UpdateEntryLock/abstractions.js.map +1 -0
  172. package/features/UpdateEntryLock/feature.d.ts +4 -0
  173. package/features/UpdateEntryLock/feature.js +13 -0
  174. package/features/UpdateEntryLock/feature.js.map +1 -0
  175. package/features/UpdateEntryLock/index.d.ts +1 -0
  176. package/features/UpdateEntryLock/index.js +1 -0
  177. package/graphql/checkPermissions.d.ts +5 -0
  178. package/graphql/checkPermissions.js +10 -0
  179. package/graphql/checkPermissions.js.map +1 -0
  180. package/{utils → graphql}/resolve.d.ts +2 -2
  181. package/graphql/resolve.js +20 -0
  182. package/graphql/resolve.js.map +1 -0
  183. package/graphql/schema.d.ts +7 -3
  184. package/graphql/schema.js +162 -145
  185. package/graphql/schema.js.map +1 -1
  186. package/index.d.ts +3 -3
  187. package/index.js +55 -34
  188. package/index.js.map +1 -1
  189. package/package.json +29 -28
  190. package/types.d.ts +3 -132
  191. package/types.js +6 -27
  192. package/types.js.map +1 -1
  193. package/utils/convertWhereCondition.d.ts +1 -1
  194. package/utils/convertWhereCondition.js +21 -36
  195. package/utils/convertWhereCondition.js.map +1 -1
  196. package/utils/getTimeout.js +8 -22
  197. package/utils/getTimeout.js.map +1 -1
  198. package/utils/lockRecordDatabaseId.js +7 -20
  199. package/utils/lockRecordDatabaseId.js.map +1 -1
  200. package/abstractions/IGetLockRecordUseCase.d.ts +0 -8
  201. package/abstractions/IGetLockRecordUseCase.js +0 -7
  202. package/abstractions/IGetLockRecordUseCase.js.map +0 -1
  203. package/abstractions/IGetLockedEntryLockRecordUseCase.d.ts +0 -8
  204. package/abstractions/IGetLockedEntryLockRecordUseCase.js +0 -7
  205. package/abstractions/IGetLockedEntryLockRecordUseCase.js.map +0 -1
  206. package/abstractions/IIsEntryLocked.d.ts +0 -8
  207. package/abstractions/IIsEntryLocked.js +0 -7
  208. package/abstractions/IIsEntryLocked.js.map +0 -1
  209. package/abstractions/IKickOutCurrentUserUseCase.d.ts +0 -5
  210. package/abstractions/IKickOutCurrentUserUseCase.js +0 -7
  211. package/abstractions/IKickOutCurrentUserUseCase.js.map +0 -1
  212. package/abstractions/IListAllLockRecordsUseCase.d.ts +0 -9
  213. package/abstractions/IListAllLockRecordsUseCase.js +0 -7
  214. package/abstractions/IListAllLockRecordsUseCase.js.map +0 -1
  215. package/abstractions/IListLockRecordsUseCase.d.ts +0 -10
  216. package/abstractions/IListLockRecordsUseCase.js +0 -7
  217. package/abstractions/IListLockRecordsUseCase.js.map +0 -1
  218. package/abstractions/ILockEntryUseCase.d.ts +0 -11
  219. package/abstractions/ILockEntryUseCase.js +0 -7
  220. package/abstractions/ILockEntryUseCase.js.map +0 -1
  221. package/abstractions/IUnlockEntryRequestUseCase.d.ts +0 -11
  222. package/abstractions/IUnlockEntryRequestUseCase.js +0 -7
  223. package/abstractions/IUnlockEntryRequestUseCase.js.map +0 -1
  224. package/abstractions/IUnlockEntryUseCase.d.ts +0 -12
  225. package/abstractions/IUnlockEntryUseCase.js +0 -7
  226. package/abstractions/IUnlockEntryUseCase.js.map +0 -1
  227. package/abstractions/IUpdateEntryLockUseCase.d.ts +0 -11
  228. package/abstractions/IUpdateEntryLockUseCase.js +0 -7
  229. package/abstractions/IUpdateEntryLockUseCase.js.map +0 -1
  230. package/crud/crud.d.ts +0 -7
  231. package/crud/crud.js +0 -204
  232. package/crud/crud.js.map +0 -1
  233. package/crud/model.d.ts +0 -2
  234. package/crud/model.js +0 -127
  235. package/crud/model.js.map +0 -1
  236. package/useCases/GetLockRecord/GetLockRecordUseCase.d.ts +0 -16
  237. package/useCases/GetLockRecord/GetLockRecordUseCase.js +0 -39
  238. package/useCases/GetLockRecord/GetLockRecordUseCase.js.map +0 -1
  239. package/useCases/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.d.ts +0 -16
  240. package/useCases/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js +0 -29
  241. package/useCases/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js.map +0 -1
  242. package/useCases/IsEntryLocked/IsEntryLockedUseCase.d.ts +0 -13
  243. package/useCases/IsEntryLocked/IsEntryLockedUseCase.js +0 -31
  244. package/useCases/IsEntryLocked/IsEntryLockedUseCase.js.map +0 -1
  245. package/useCases/KickOutCurrentUser/KickOutCurrentUserUseCase.d.ts +0 -12
  246. package/useCases/KickOutCurrentUser/KickOutCurrentUserUseCase.js +0 -46
  247. package/useCases/KickOutCurrentUser/KickOutCurrentUserUseCase.js.map +0 -1
  248. package/useCases/ListAllLockRecordsUseCase/ListAllLockRecordsUseCase.d.ts +0 -13
  249. package/useCases/ListAllLockRecordsUseCase/ListAllLockRecordsUseCase.js +0 -34
  250. package/useCases/ListAllLockRecordsUseCase/ListAllLockRecordsUseCase.js.map +0 -1
  251. package/useCases/ListLockRecordsUseCase/ListLockRecordsUseCase.d.ts +0 -14
  252. package/useCases/ListLockRecordsUseCase/ListLockRecordsUseCase.js +0 -27
  253. package/useCases/ListLockRecordsUseCase/ListLockRecordsUseCase.js.map +0 -1
  254. package/useCases/LockEntryUseCase/LockEntryUseCase.d.ts +0 -21
  255. package/useCases/LockEntryUseCase/LockEntryUseCase.js +0 -64
  256. package/useCases/LockEntryUseCase/LockEntryUseCase.js.map +0 -1
  257. package/useCases/UnlockEntryUseCase/UnlockEntryUseCase.d.ts +0 -23
  258. package/useCases/UnlockEntryUseCase/UnlockEntryUseCase.js +0 -90
  259. package/useCases/UnlockEntryUseCase/UnlockEntryUseCase.js.map +0 -1
  260. package/useCases/UnlockRequestUseCase/UnlockEntryRequestUseCase.d.ts +0 -21
  261. package/useCases/UnlockRequestUseCase/UnlockEntryRequestUseCase.js +0 -82
  262. package/useCases/UnlockRequestUseCase/UnlockEntryRequestUseCase.js.map +0 -1
  263. package/useCases/UpdateEntryLock/UpdateEntryLockUseCase.d.ts +0 -26
  264. package/useCases/UpdateEntryLock/UpdateEntryLockUseCase.js +0 -93
  265. package/useCases/UpdateEntryLock/UpdateEntryLockUseCase.js.map +0 -1
  266. package/useCases/index.d.ts +0 -31
  267. package/useCases/index.js +0 -96
  268. package/useCases/index.js.map +0 -1
  269. package/useCases/types.d.ts +0 -5
  270. package/useCases/types.js +0 -7
  271. package/useCases/types.js.map +0 -1
  272. package/utils/calculateExpiresOn.d.ts +0 -2
  273. package/utils/calculateExpiresOn.js +0 -16
  274. package/utils/calculateExpiresOn.js.map +0 -1
  275. package/utils/checkPermissions.d.ts +0 -7
  276. package/utils/checkPermissions.js +0 -21
  277. package/utils/checkPermissions.js.map +0 -1
  278. package/utils/convertEntryToLockRecord.d.ts +0 -28
  279. package/utils/convertEntryToLockRecord.js +0 -91
  280. package/utils/convertEntryToLockRecord.js.map +0 -1
  281. package/utils/resolve.js +0 -30
  282. package/utils/resolve.js.map +0 -1
  283. package/utils/validateSameIdentity.d.ts +0 -6
  284. package/utils/validateSameIdentity.js +0 -24
  285. package/utils/validateSameIdentity.js.map +0 -1
@@ -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
- }
@@ -1,90 +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.UnlockEntryUseCase = void 0;
8
- var _error = _interopRequireDefault(require("@webiny/error"));
9
- var _lockRecordDatabaseId = require("../../utils/lockRecordDatabaseId");
10
- var _validateSameIdentity = require("../../utils/validateSameIdentity");
11
- var _apiSecurity = require("@webiny/api-security");
12
- var _handlerGraphql = require("@webiny/handler-graphql");
13
- class UnlockEntryUseCase {
14
- constructor(params) {
15
- this.getLockRecordUseCase = params.getLockRecordUseCase;
16
- this.kickOutCurrentUserUseCase = params.kickOutCurrentUserUseCase;
17
- this.getManager = params.getManager;
18
- this.getSecurity = params.getSecurity;
19
- this.getIdentity = params.getIdentity;
20
- this.hasRecordLockingAccess = params.hasRecordLockingAccess;
21
- }
22
- async execute(params) {
23
- const record = await this.getLockRecordUseCase.execute(params);
24
- if (!record || record.isExpired()) {
25
- const security = this.getSecurity();
26
- try {
27
- const manager = await this.getManager();
28
- await security.withoutAuthorization(async () => {
29
- await manager.delete((0, _lockRecordDatabaseId.createLockRecordDatabaseId)(params.id), {
30
- force: true,
31
- permanently: true
32
- });
33
- });
34
- } catch (ex) {
35
- if (ex instanceof _handlerGraphql.NotFoundError === false) {
36
- console.log("Could not forcefully delete lock record.");
37
- console.error(ex);
38
- }
39
- }
40
- throw new _error.default("Lock Record not found.", "LOCK_RECORD_NOT_FOUND", {
41
- ...params
42
- });
43
- }
44
-
45
- /**
46
- * We need to validate that the user executing unlock is the same user that locked the entry.
47
- * In case it is not the same user, there is a possibility that it is a user which has full access,
48
- * and at that point, we allow unlocking, but we also need to message the user who locked the entry.
49
- *
50
- */
51
- let kickOutCurrentUser = false;
52
- try {
53
- (0, _validateSameIdentity.validateSameIdentity)({
54
- getIdentity: this.getIdentity,
55
- target: record.lockedBy
56
- });
57
- } catch (ex) {
58
- if (!params.force) {
59
- throw ex;
60
- }
61
- const hasAccess = await this.hasRecordLockingAccess();
62
- if (ex instanceof _apiSecurity.NotAuthorizedError === false || !hasAccess) {
63
- throw ex;
64
- }
65
- kickOutCurrentUser = true;
66
- }
67
- const security = this.getSecurity();
68
- try {
69
- const manager = await this.getManager();
70
- return await security.withoutAuthorization(async () => {
71
- await manager.delete((0, _lockRecordDatabaseId.createLockRecordDatabaseId)(params.id), {
72
- force: true,
73
- permanently: true
74
- });
75
- if (!kickOutCurrentUser) {
76
- return record;
77
- }
78
- await this.kickOutCurrentUserUseCase.execute(record);
79
- return record;
80
- });
81
- } catch (ex) {
82
- throw new _error.default(`Could not unlock entry: ${ex.message}`, ex.code || "UNLOCK_ENTRY_ERROR", {
83
- ...ex.data
84
- });
85
- }
86
- }
87
- }
88
- exports.UnlockEntryUseCase = UnlockEntryUseCase;
89
-
90
- //# sourceMappingURL=UnlockEntryUseCase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_lockRecordDatabaseId","_validateSameIdentity","_apiSecurity","_handlerGraphql","UnlockEntryUseCase","constructor","params","getLockRecordUseCase","kickOutCurrentUserUseCase","getManager","getSecurity","getIdentity","hasRecordLockingAccess","execute","record","isExpired","security","manager","withoutAuthorization","delete","createLockRecordDatabaseId","id","force","permanently","ex","NotFoundError","console","log","error","WebinyError","kickOutCurrentUser","validateSameIdentity","target","lockedBy","hasAccess","NotAuthorizedError","message","code","data","exports"],"sources":["UnlockEntryUseCase.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n IUnlockEntryUseCase,\n IUnlockEntryUseCaseExecuteParams\n} from \"~/abstractions/IUnlockEntryUseCase\";\nimport type {\n IGetIdentity,\n IHasRecordLockingAccessCallable,\n IRecordLockingLockRecord,\n IRecordLockingModelManager\n} from \"~/types\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId\";\nimport type { IGetLockRecordUseCase } from \"~/abstractions/IGetLockRecordUseCase\";\nimport { validateSameIdentity } from \"~/utils/validateSameIdentity\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\nimport type { IKickOutCurrentUserUseCase } from \"~/abstractions/IKickOutCurrentUserUseCase\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport type { Security } from \"@webiny/api-security/types\";\n\nexport interface IUnlockEntryUseCaseParams {\n readonly getLockRecordUseCase: IGetLockRecordUseCase;\n readonly kickOutCurrentUserUseCase: IKickOutCurrentUserUseCase;\n getManager(): Promise<IRecordLockingModelManager>;\n getSecurity(): Pick<Security, \"withoutAuthorization\">;\n getIdentity: IGetIdentity;\n hasRecordLockingAccess: IHasRecordLockingAccessCallable;\n}\n\nexport class UnlockEntryUseCase implements IUnlockEntryUseCase {\n private readonly getLockRecordUseCase: IGetLockRecordUseCase;\n private readonly kickOutCurrentUserUseCase: IKickOutCurrentUserUseCase;\n private readonly getManager: IUnlockEntryUseCaseParams[\"getManager\"];\n private readonly getSecurity: IUnlockEntryUseCaseParams[\"getSecurity\"];\n private readonly getIdentity: IGetIdentity;\n private readonly hasRecordLockingAccess: IHasRecordLockingAccessCallable;\n\n public constructor(params: IUnlockEntryUseCaseParams) {\n this.getLockRecordUseCase = params.getLockRecordUseCase;\n this.kickOutCurrentUserUseCase = params.kickOutCurrentUserUseCase;\n this.getManager = params.getManager;\n this.getSecurity = params.getSecurity;\n this.getIdentity = params.getIdentity;\n this.hasRecordLockingAccess = params.hasRecordLockingAccess;\n }\n\n public async execute(\n params: IUnlockEntryUseCaseExecuteParams\n ): Promise<IRecordLockingLockRecord> {\n const record = await this.getLockRecordUseCase.execute(params);\n if (!record || record.isExpired()) {\n const security = this.getSecurity();\n try {\n const manager = await this.getManager();\n await security.withoutAuthorization(async () => {\n await manager.delete(createLockRecordDatabaseId(params.id), {\n force: true,\n permanently: true\n });\n });\n } catch (ex) {\n if (ex instanceof NotFoundError === false) {\n console.log(\"Could not forcefully delete lock record.\");\n console.error(ex);\n }\n }\n\n throw new WebinyError(\"Lock Record not found.\", \"LOCK_RECORD_NOT_FOUND\", {\n ...params\n });\n }\n\n /**\n * We need to validate that the user executing unlock is the same user that locked the entry.\n * In case it is not the same user, there is a possibility that it is a user which has full access,\n * and at that point, we allow unlocking, but we also need to message the user who locked the entry.\n *\n */\n let kickOutCurrentUser = false;\n try {\n validateSameIdentity({\n getIdentity: this.getIdentity,\n target: record.lockedBy\n });\n } catch (ex) {\n if (!params.force) {\n throw ex;\n }\n const hasAccess = await this.hasRecordLockingAccess();\n if (ex instanceof NotAuthorizedError === false || !hasAccess) {\n throw ex;\n }\n\n kickOutCurrentUser = true;\n }\n\n const security = this.getSecurity();\n try {\n const manager = await this.getManager();\n return await security.withoutAuthorization(async () => {\n await manager.delete(createLockRecordDatabaseId(params.id), {\n force: true,\n permanently: true\n });\n\n if (!kickOutCurrentUser) {\n return record;\n }\n await this.kickOutCurrentUserUseCase.execute(record);\n return record;\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not unlock entry: ${ex.message}`,\n ex.code || \"UNLOCK_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;AAEA,IAAAE,qBAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAEA,IAAAI,eAAA,GAAAJ,OAAA;AAYO,MAAMK,kBAAkB,CAAgC;EAQpDC,WAAWA,CAACC,MAAiC,EAAE;IAClD,IAAI,CAACC,oBAAoB,GAAGD,MAAM,CAACC,oBAAoB;IACvD,IAAI,CAACC,yBAAyB,GAAGF,MAAM,CAACE,yBAAyB;IACjE,IAAI,CAACC,UAAU,GAAGH,MAAM,CAACG,UAAU;IACnC,IAAI,CAACC,WAAW,GAAGJ,MAAM,CAACI,WAAW;IACrC,IAAI,CAACC,WAAW,GAAGL,MAAM,CAACK,WAAW;IACrC,IAAI,CAACC,sBAAsB,GAAGN,MAAM,CAACM,sBAAsB;EAC/D;EAEA,MAAaC,OAAOA,CAChBP,MAAwC,EACP;IACjC,MAAMQ,MAAM,GAAG,MAAM,IAAI,CAACP,oBAAoB,CAACM,OAAO,CAACP,MAAM,CAAC;IAC9D,IAAI,CAACQ,MAAM,IAAIA,MAAM,CAACC,SAAS,CAAC,CAAC,EAAE;MAC/B,MAAMC,QAAQ,GAAG,IAAI,CAACN,WAAW,CAAC,CAAC;MACnC,IAAI;QACA,MAAMO,OAAO,GAAG,MAAM,IAAI,CAACR,UAAU,CAAC,CAAC;QACvC,MAAMO,QAAQ,CAACE,oBAAoB,CAAC,YAAY;UAC5C,MAAMD,OAAO,CAACE,MAAM,CAAC,IAAAC,gDAA0B,EAACd,MAAM,CAACe,EAAE,CAAC,EAAE;YACxDC,KAAK,EAAE,IAAI;YACXC,WAAW,EAAE;UACjB,CAAC,CAAC;QACN,CAAC,CAAC;MACN,CAAC,CAAC,OAAOC,EAAE,EAAE;QACT,IAAIA,EAAE,YAAYC,6BAAa,KAAK,KAAK,EAAE;UACvCC,OAAO,CAACC,GAAG,CAAC,0CAA0C,CAAC;UACvDD,OAAO,CAACE,KAAK,CAACJ,EAAE,CAAC;QACrB;MACJ;MAEA,MAAM,IAAIK,cAAW,CAAC,wBAAwB,EAAE,uBAAuB,EAAE;QACrE,GAAGvB;MACP,CAAC,CAAC;IACN;;IAEA;AACR;AACA;AACA;AACA;AACA;IACQ,IAAIwB,kBAAkB,GAAG,KAAK;IAC9B,IAAI;MACA,IAAAC,0CAAoB,EAAC;QACjBpB,WAAW,EAAE,IAAI,CAACA,WAAW;QAC7BqB,MAAM,EAAElB,MAAM,CAACmB;MACnB,CAAC,CAAC;IACN,CAAC,CAAC,OAAOT,EAAE,EAAE;MACT,IAAI,CAAClB,MAAM,CAACgB,KAAK,EAAE;QACf,MAAME,EAAE;MACZ;MACA,MAAMU,SAAS,GAAG,MAAM,IAAI,CAACtB,sBAAsB,CAAC,CAAC;MACrD,IAAIY,EAAE,YAAYW,+BAAkB,KAAK,KAAK,IAAI,CAACD,SAAS,EAAE;QAC1D,MAAMV,EAAE;MACZ;MAEAM,kBAAkB,GAAG,IAAI;IAC7B;IAEA,MAAMd,QAAQ,GAAG,IAAI,CAACN,WAAW,CAAC,CAAC;IACnC,IAAI;MACA,MAAMO,OAAO,GAAG,MAAM,IAAI,CAACR,UAAU,CAAC,CAAC;MACvC,OAAO,MAAMO,QAAQ,CAACE,oBAAoB,CAAC,YAAY;QACnD,MAAMD,OAAO,CAACE,MAAM,CAAC,IAAAC,gDAA0B,EAACd,MAAM,CAACe,EAAE,CAAC,EAAE;UACxDC,KAAK,EAAE,IAAI;UACXC,WAAW,EAAE;QACjB,CAAC,CAAC;QAEF,IAAI,CAACO,kBAAkB,EAAE;UACrB,OAAOhB,MAAM;QACjB;QACA,MAAM,IAAI,CAACN,yBAAyB,CAACK,OAAO,CAACC,MAAM,CAAC;QACpD,OAAOA,MAAM;MACjB,CAAC,CAAC;IACN,CAAC,CAAC,OAAOU,EAAE,EAAE;MACT,MAAM,IAAIK,cAAW,CACjB,2BAA2BL,EAAE,CAACY,OAAO,EAAE,EACvCZ,EAAE,CAACa,IAAI,IAAI,oBAAoB,EAC/B;QACI,GAAGb,EAAE,CAACc;MACV,CACJ,CAAC;IACL;EACJ;AACJ;AAACC,OAAA,CAAAnC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -1,21 +0,0 @@
1
- import type { IUnlockEntryRequestUseCase, IUnlockEntryRequestUseCaseExecuteParams } from "../../abstractions/IUnlockEntryRequestUseCase";
2
- import type { IGetIdentity, IRecordLockingLockRecord, IRecordLockingModelManager } from "../../types";
3
- import type { IGetLockRecordUseCase } from "../../abstractions/IGetLockRecordUseCase";
4
- import type { ConvertEntryToLockRecordCb } from "../types";
5
- import type { Security } from "@webiny/api-security/types";
6
- export interface IUnlockEntryRequestUseCaseParams {
7
- getLockRecordUseCase: IGetLockRecordUseCase;
8
- getManager(): Promise<IRecordLockingModelManager>;
9
- getSecurity(): Pick<Security, "withoutAuthorization">;
10
- getIdentity: IGetIdentity;
11
- convert: ConvertEntryToLockRecordCb;
12
- }
13
- export declare class UnlockEntryRequestUseCase implements IUnlockEntryRequestUseCase {
14
- private readonly getLockRecordUseCase;
15
- private readonly getManager;
16
- private readonly getSecurity;
17
- private readonly getIdentity;
18
- private readonly convert;
19
- constructor(params: IUnlockEntryRequestUseCaseParams);
20
- execute(params: IUnlockEntryRequestUseCaseExecuteParams): Promise<IRecordLockingLockRecord>;
21
- }