@webiny/api-record-locking 0.0.0-unstable.e53eceafb5 → 0.0.0-unstable.e6f0dc8ca7

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 (295) hide show
  1. package/README.md +10 -9
  2. package/domain/LockRecord.d.ts +45 -0
  3. package/{utils/convertEntryToLockRecord.js → domain/LockRecord.js} +10 -21
  4. package/domain/LockRecord.js.map +1 -0
  5. package/domain/RecordLockingModel.d.ts +9 -0
  6. package/domain/RecordLockingModel.js +29 -0
  7. package/domain/RecordLockingModel.js.map +1 -0
  8. package/domain/abstractions.d.ts +18 -0
  9. package/domain/abstractions.js +10 -0
  10. package/domain/abstractions.js.map +1 -0
  11. package/domain/calculateExpiresOn.d.ts +1 -0
  12. package/domain/calculateExpiresOn.js +9 -0
  13. package/domain/calculateExpiresOn.js.map +1 -0
  14. package/domain/errors.d.ts +71 -0
  15. package/domain/errors.js +95 -0
  16. package/domain/errors.js.map +1 -0
  17. package/domain/index.d.ts +4 -0
  18. package/domain/index.js +6 -0
  19. package/domain/index.js.map +1 -0
  20. package/domain/types.d.ts +44 -0
  21. package/domain/types.js +12 -0
  22. package/domain/types.js.map +1 -0
  23. package/features/GetLockRecord/GetLockRecordRepository.d.ts +16 -0
  24. package/features/GetLockRecord/GetLockRecordRepository.js +37 -0
  25. package/features/GetLockRecord/GetLockRecordRepository.js.map +1 -0
  26. package/features/GetLockRecord/GetLockRecordUseCase.d.ts +12 -0
  27. package/features/GetLockRecord/GetLockRecordUseCase.js +15 -0
  28. package/features/GetLockRecord/GetLockRecordUseCase.js.map +1 -0
  29. package/features/GetLockRecord/abstractions.d.ts +41 -0
  30. package/features/GetLockRecord/abstractions.js +17 -0
  31. package/features/GetLockRecord/abstractions.js.map +1 -0
  32. package/features/GetLockRecord/feature.d.ts +4 -0
  33. package/features/GetLockRecord/feature.js +12 -0
  34. package/features/GetLockRecord/feature.js.map +1 -0
  35. package/features/GetLockRecord/index.d.ts +2 -0
  36. package/features/GetLockRecord/index.js +4 -0
  37. package/features/GetLockRecord/index.js.map +1 -0
  38. package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.d.ts +15 -0
  39. package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js +39 -0
  40. package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js.map +1 -0
  41. package/features/GetLockedEntryLockRecord/abstractions.d.ts +26 -0
  42. package/features/GetLockedEntryLockRecord/abstractions.js +13 -0
  43. package/features/GetLockedEntryLockRecord/abstractions.js.map +1 -0
  44. package/features/GetLockedEntryLockRecord/feature.d.ts +4 -0
  45. package/features/GetLockedEntryLockRecord/feature.js +10 -0
  46. package/features/GetLockedEntryLockRecord/feature.js.map +1 -0
  47. package/features/GetLockedEntryLockRecord/index.d.ts +2 -0
  48. package/features/GetLockedEntryLockRecord/index.js +4 -0
  49. package/features/GetLockedEntryLockRecord/index.js.map +1 -0
  50. package/features/IsEntryLocked/IsEntryLockedUseCase.d.ts +14 -0
  51. package/features/IsEntryLocked/IsEntryLockedUseCase.js +39 -0
  52. package/features/IsEntryLocked/IsEntryLockedUseCase.js.map +1 -0
  53. package/features/IsEntryLocked/abstractions.d.ts +24 -0
  54. package/features/IsEntryLocked/abstractions.js +12 -0
  55. package/features/IsEntryLocked/abstractions.js.map +1 -0
  56. package/features/IsEntryLocked/feature.d.ts +4 -0
  57. package/features/IsEntryLocked/feature.js +10 -0
  58. package/features/IsEntryLocked/feature.js.map +1 -0
  59. package/features/IsEntryLocked/index.d.ts +1 -0
  60. package/features/IsEntryLocked/index.js +3 -0
  61. package/features/IsEntryLocked/index.js.map +1 -0
  62. package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.d.ts +15 -0
  63. package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js +42 -0
  64. package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js.map +1 -0
  65. package/features/KickOutCurrentUser/abstractions.d.ts +17 -0
  66. package/features/KickOutCurrentUser/abstractions.js +9 -0
  67. package/features/KickOutCurrentUser/abstractions.js.map +1 -0
  68. package/features/KickOutCurrentUser/feature.d.ts +4 -0
  69. package/features/KickOutCurrentUser/feature.js +10 -0
  70. package/features/KickOutCurrentUser/feature.js.map +1 -0
  71. package/features/KickOutCurrentUser/index.d.ts +1 -0
  72. package/features/KickOutCurrentUser/index.js +3 -0
  73. package/features/KickOutCurrentUser/index.js.map +1 -0
  74. package/features/ListAllLockRecords/ListAllLockRecordsRepository.d.ts +16 -0
  75. package/features/ListAllLockRecords/ListAllLockRecordsRepository.js +43 -0
  76. package/features/ListAllLockRecords/ListAllLockRecordsRepository.js.map +1 -0
  77. package/features/ListAllLockRecords/ListAllLockRecordsUseCase.d.ts +11 -0
  78. package/features/ListAllLockRecords/ListAllLockRecordsUseCase.js +15 -0
  79. package/features/ListAllLockRecords/ListAllLockRecordsUseCase.js.map +1 -0
  80. package/features/ListAllLockRecords/abstractions.d.ts +40 -0
  81. package/features/ListAllLockRecords/abstractions.js +17 -0
  82. package/features/ListAllLockRecords/abstractions.js.map +1 -0
  83. package/features/ListAllLockRecords/feature.d.ts +4 -0
  84. package/features/ListAllLockRecords/feature.js +12 -0
  85. package/features/ListAllLockRecords/feature.js.map +1 -0
  86. package/features/ListAllLockRecords/index.d.ts +2 -0
  87. package/features/ListAllLockRecords/index.js +4 -0
  88. package/features/ListAllLockRecords/index.js.map +1 -0
  89. package/features/ListLockRecords/ListLockRecordsRepository.d.ts +15 -0
  90. package/features/ListLockRecords/ListLockRecordsRepository.js +43 -0
  91. package/features/ListLockRecords/ListLockRecordsRepository.js.map +1 -0
  92. package/features/ListLockRecords/ListLockRecordsUseCase.d.ts +15 -0
  93. package/features/ListLockRecords/ListLockRecordsUseCase.js +30 -0
  94. package/features/ListLockRecords/ListLockRecordsUseCase.js.map +1 -0
  95. package/features/ListLockRecords/abstractions.d.ts +45 -0
  96. package/features/ListLockRecords/abstractions.js +17 -0
  97. package/features/ListLockRecords/abstractions.js.map +1 -0
  98. package/features/ListLockRecords/feature.d.ts +4 -0
  99. package/features/ListLockRecords/feature.js +12 -0
  100. package/features/ListLockRecords/feature.js.map +1 -0
  101. package/features/ListLockRecords/index.d.ts +1 -0
  102. package/features/ListLockRecords/index.js +3 -0
  103. package/features/ListLockRecords/index.js.map +1 -0
  104. package/features/LockEntry/LockEntryEventsDecorator.d.ts +14 -0
  105. package/features/LockEntry/LockEntryEventsDecorator.js +40 -0
  106. package/features/LockEntry/LockEntryEventsDecorator.js.map +1 -0
  107. package/features/LockEntry/LockEntryRepository.d.ts +16 -0
  108. package/features/LockEntry/LockEntryRepository.js +42 -0
  109. package/features/LockEntry/LockEntryRepository.js.map +1 -0
  110. package/features/LockEntry/LockEntryUseCase.d.ts +14 -0
  111. package/features/LockEntry/LockEntryUseCase.js +36 -0
  112. package/features/LockEntry/LockEntryUseCase.js.map +1 -0
  113. package/features/LockEntry/abstractions.d.ts +41 -0
  114. package/features/LockEntry/abstractions.js +17 -0
  115. package/features/LockEntry/abstractions.js.map +1 -0
  116. package/features/LockEntry/events.d.ts +45 -0
  117. package/features/LockEntry/events.js +40 -0
  118. package/features/LockEntry/events.js.map +1 -0
  119. package/features/LockEntry/feature.d.ts +4 -0
  120. package/features/LockEntry/feature.js +14 -0
  121. package/features/LockEntry/feature.js.map +1 -0
  122. package/features/LockEntry/index.d.ts +1 -0
  123. package/features/LockEntry/index.js +3 -0
  124. package/features/LockEntry/index.js.map +1 -0
  125. package/features/RecordLockingFeature.d.ts +15 -0
  126. package/features/RecordLockingFeature.js +36 -0
  127. package/features/RecordLockingFeature.js.map +1 -0
  128. package/features/UnlockEntry/UnlockEntryEventsDecorator.d.ts +14 -0
  129. package/features/UnlockEntry/UnlockEntryEventsDecorator.js +41 -0
  130. package/features/UnlockEntry/UnlockEntryEventsDecorator.js.map +1 -0
  131. package/features/UnlockEntry/UnlockEntryRepository.d.ts +14 -0
  132. package/features/UnlockEntry/UnlockEntryRepository.js +40 -0
  133. package/features/UnlockEntry/UnlockEntryRepository.js.map +1 -0
  134. package/features/UnlockEntry/UnlockEntryUseCase.d.ts +18 -0
  135. package/features/UnlockEntry/UnlockEntryUseCase.js +81 -0
  136. package/features/UnlockEntry/UnlockEntryUseCase.js.map +1 -0
  137. package/features/UnlockEntry/abstractions.d.ts +44 -0
  138. package/features/UnlockEntry/abstractions.js +17 -0
  139. package/features/UnlockEntry/abstractions.js.map +1 -0
  140. package/features/UnlockEntry/events.d.ts +46 -0
  141. package/features/UnlockEntry/events.js +40 -0
  142. package/features/UnlockEntry/events.js.map +1 -0
  143. package/features/UnlockEntry/feature.d.ts +4 -0
  144. package/features/UnlockEntry/feature.js +14 -0
  145. package/features/UnlockEntry/feature.js.map +1 -0
  146. package/features/UnlockEntry/hasFullAccessPermission.d.ts +2 -0
  147. package/features/UnlockEntry/hasFullAccessPermission.js +10 -0
  148. package/features/UnlockEntry/hasFullAccessPermission.js.map +1 -0
  149. package/features/UnlockEntry/index.d.ts +1 -0
  150. package/features/UnlockEntry/index.js +3 -0
  151. package/features/UnlockEntry/index.js.map +1 -0
  152. package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.d.ts +14 -0
  153. package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js +40 -0
  154. package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js.map +1 -0
  155. package/features/UnlockEntryRequest/UnlockEntryRequestRepository.d.ts +17 -0
  156. package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js +43 -0
  157. package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js.map +1 -0
  158. package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.d.ts +16 -0
  159. package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js +92 -0
  160. package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js.map +1 -0
  161. package/features/UnlockEntryRequest/abstractions.d.ts +42 -0
  162. package/features/UnlockEntryRequest/abstractions.js +17 -0
  163. package/features/UnlockEntryRequest/abstractions.js.map +1 -0
  164. package/features/UnlockEntryRequest/events.d.ts +45 -0
  165. package/features/UnlockEntryRequest/events.js +40 -0
  166. package/features/UnlockEntryRequest/events.js.map +1 -0
  167. package/features/UnlockEntryRequest/feature.d.ts +4 -0
  168. package/features/UnlockEntryRequest/feature.js +14 -0
  169. package/features/UnlockEntryRequest/feature.js.map +1 -0
  170. package/features/UnlockEntryRequest/index.d.ts +3 -0
  171. package/features/UnlockEntryRequest/index.js +5 -0
  172. package/features/UnlockEntryRequest/index.js.map +1 -0
  173. package/features/UpdateEntryLock/UpdateEntryLockRepository.d.ts +20 -0
  174. package/features/UpdateEntryLock/UpdateEntryLockRepository.js +63 -0
  175. package/features/UpdateEntryLock/UpdateEntryLockRepository.js.map +1 -0
  176. package/features/UpdateEntryLock/UpdateEntryLockUseCase.d.ts +18 -0
  177. package/features/UpdateEntryLock/UpdateEntryLockUseCase.js +62 -0
  178. package/features/UpdateEntryLock/UpdateEntryLockUseCase.js.map +1 -0
  179. package/features/UpdateEntryLock/abstractions.d.ts +42 -0
  180. package/features/UpdateEntryLock/abstractions.js +17 -0
  181. package/features/UpdateEntryLock/abstractions.js.map +1 -0
  182. package/features/UpdateEntryLock/feature.d.ts +4 -0
  183. package/features/UpdateEntryLock/feature.js +12 -0
  184. package/features/UpdateEntryLock/feature.js.map +1 -0
  185. package/features/UpdateEntryLock/index.d.ts +1 -0
  186. package/features/UpdateEntryLock/index.js +3 -0
  187. package/features/UpdateEntryLock/index.js.map +1 -0
  188. package/graphql/checkPermissions.d.ts +5 -0
  189. package/graphql/checkPermissions.js +14 -0
  190. package/graphql/checkPermissions.js.map +1 -0
  191. package/{utils → graphql}/resolve.d.ts +3 -3
  192. package/graphql/resolve.js +22 -0
  193. package/graphql/resolve.js.map +1 -0
  194. package/graphql/schema.d.ts +7 -3
  195. package/graphql/schema.js +101 -66
  196. package/graphql/schema.js.map +1 -1
  197. package/index.d.ts +3 -3
  198. package/index.js +49 -25
  199. package/index.js.map +1 -1
  200. package/package.json +25 -26
  201. package/types.d.ts +3 -132
  202. package/types.js +2 -20
  203. package/types.js.map +1 -1
  204. package/utils/convertWhereCondition.d.ts +1 -1
  205. package/utils/convertWhereCondition.js +11 -14
  206. package/utils/convertWhereCondition.js.map +1 -1
  207. package/utils/getTimeout.js +1 -8
  208. package/utils/getTimeout.js.map +1 -1
  209. package/utils/lockRecordDatabaseId.js +4 -12
  210. package/utils/lockRecordDatabaseId.js.map +1 -1
  211. package/abstractions/IGetLockRecordUseCase.d.ts +0 -8
  212. package/abstractions/IGetLockRecordUseCase.js +0 -7
  213. package/abstractions/IGetLockRecordUseCase.js.map +0 -1
  214. package/abstractions/IGetLockedEntryLockRecordUseCase.d.ts +0 -8
  215. package/abstractions/IGetLockedEntryLockRecordUseCase.js +0 -7
  216. package/abstractions/IGetLockedEntryLockRecordUseCase.js.map +0 -1
  217. package/abstractions/IIsEntryLocked.d.ts +0 -8
  218. package/abstractions/IIsEntryLocked.js +0 -7
  219. package/abstractions/IIsEntryLocked.js.map +0 -1
  220. package/abstractions/IKickOutCurrentUserUseCase.d.ts +0 -5
  221. package/abstractions/IKickOutCurrentUserUseCase.js +0 -7
  222. package/abstractions/IKickOutCurrentUserUseCase.js.map +0 -1
  223. package/abstractions/IListAllLockRecordsUseCase.d.ts +0 -9
  224. package/abstractions/IListAllLockRecordsUseCase.js +0 -7
  225. package/abstractions/IListAllLockRecordsUseCase.js.map +0 -1
  226. package/abstractions/IListLockRecordsUseCase.d.ts +0 -10
  227. package/abstractions/IListLockRecordsUseCase.js +0 -7
  228. package/abstractions/IListLockRecordsUseCase.js.map +0 -1
  229. package/abstractions/ILockEntryUseCase.d.ts +0 -11
  230. package/abstractions/ILockEntryUseCase.js +0 -7
  231. package/abstractions/ILockEntryUseCase.js.map +0 -1
  232. package/abstractions/IUnlockEntryRequestUseCase.d.ts +0 -11
  233. package/abstractions/IUnlockEntryRequestUseCase.js +0 -7
  234. package/abstractions/IUnlockEntryRequestUseCase.js.map +0 -1
  235. package/abstractions/IUnlockEntryUseCase.d.ts +0 -12
  236. package/abstractions/IUnlockEntryUseCase.js +0 -7
  237. package/abstractions/IUnlockEntryUseCase.js.map +0 -1
  238. package/abstractions/IUpdateEntryLockUseCase.d.ts +0 -11
  239. package/abstractions/IUpdateEntryLockUseCase.js +0 -7
  240. package/abstractions/IUpdateEntryLockUseCase.js.map +0 -1
  241. package/crud/crud.d.ts +0 -7
  242. package/crud/crud.js +0 -204
  243. package/crud/crud.js.map +0 -1
  244. package/crud/model.d.ts +0 -2
  245. package/crud/model.js +0 -127
  246. package/crud/model.js.map +0 -1
  247. package/useCases/GetLockRecord/GetLockRecordUseCase.d.ts +0 -16
  248. package/useCases/GetLockRecord/GetLockRecordUseCase.js +0 -39
  249. package/useCases/GetLockRecord/GetLockRecordUseCase.js.map +0 -1
  250. package/useCases/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.d.ts +0 -16
  251. package/useCases/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js +0 -29
  252. package/useCases/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js.map +0 -1
  253. package/useCases/IsEntryLocked/IsEntryLockedUseCase.d.ts +0 -13
  254. package/useCases/IsEntryLocked/IsEntryLockedUseCase.js +0 -31
  255. package/useCases/IsEntryLocked/IsEntryLockedUseCase.js.map +0 -1
  256. package/useCases/KickOutCurrentUser/KickOutCurrentUserUseCase.d.ts +0 -12
  257. package/useCases/KickOutCurrentUser/KickOutCurrentUserUseCase.js +0 -46
  258. package/useCases/KickOutCurrentUser/KickOutCurrentUserUseCase.js.map +0 -1
  259. package/useCases/ListAllLockRecordsUseCase/ListAllLockRecordsUseCase.d.ts +0 -13
  260. package/useCases/ListAllLockRecordsUseCase/ListAllLockRecordsUseCase.js +0 -34
  261. package/useCases/ListAllLockRecordsUseCase/ListAllLockRecordsUseCase.js.map +0 -1
  262. package/useCases/ListLockRecordsUseCase/ListLockRecordsUseCase.d.ts +0 -14
  263. package/useCases/ListLockRecordsUseCase/ListLockRecordsUseCase.js +0 -27
  264. package/useCases/ListLockRecordsUseCase/ListLockRecordsUseCase.js.map +0 -1
  265. package/useCases/LockEntryUseCase/LockEntryUseCase.d.ts +0 -21
  266. package/useCases/LockEntryUseCase/LockEntryUseCase.js +0 -64
  267. package/useCases/LockEntryUseCase/LockEntryUseCase.js.map +0 -1
  268. package/useCases/UnlockEntryUseCase/UnlockEntryUseCase.d.ts +0 -23
  269. package/useCases/UnlockEntryUseCase/UnlockEntryUseCase.js +0 -90
  270. package/useCases/UnlockEntryUseCase/UnlockEntryUseCase.js.map +0 -1
  271. package/useCases/UnlockRequestUseCase/UnlockEntryRequestUseCase.d.ts +0 -21
  272. package/useCases/UnlockRequestUseCase/UnlockEntryRequestUseCase.js +0 -82
  273. package/useCases/UnlockRequestUseCase/UnlockEntryRequestUseCase.js.map +0 -1
  274. package/useCases/UpdateEntryLock/UpdateEntryLockUseCase.d.ts +0 -26
  275. package/useCases/UpdateEntryLock/UpdateEntryLockUseCase.js +0 -93
  276. package/useCases/UpdateEntryLock/UpdateEntryLockUseCase.js.map +0 -1
  277. package/useCases/index.d.ts +0 -31
  278. package/useCases/index.js +0 -96
  279. package/useCases/index.js.map +0 -1
  280. package/useCases/types.d.ts +0 -5
  281. package/useCases/types.js +0 -7
  282. package/useCases/types.js.map +0 -1
  283. package/utils/calculateExpiresOn.d.ts +0 -2
  284. package/utils/calculateExpiresOn.js +0 -16
  285. package/utils/calculateExpiresOn.js.map +0 -1
  286. package/utils/checkPermissions.d.ts +0 -7
  287. package/utils/checkPermissions.js +0 -21
  288. package/utils/checkPermissions.js.map +0 -1
  289. package/utils/convertEntryToLockRecord.d.ts +0 -28
  290. package/utils/convertEntryToLockRecord.js.map +0 -1
  291. package/utils/resolve.js +0 -30
  292. package/utils/resolve.js.map +0 -1
  293. package/utils/validateSameIdentity.d.ts +0 -6
  294. package/utils/validateSameIdentity.js +0 -24
  295. package/utils/validateSameIdentity.js.map +0 -1
@@ -0,0 +1,41 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import type { ILockRecord } from "../../domain/LockRecord.js";
3
+ import type { LockRecordEntryType } from "../../domain/types.js";
4
+ import type { EntryAlreadyLockedError, LockEntryError, LockRecordPersistenceError } from "../../domain/errors.js";
5
+ export interface LockEntryInput {
6
+ id: string;
7
+ type: LockRecordEntryType;
8
+ }
9
+ /**
10
+ * LockEntry Use Case - Creates a lock on an entry
11
+ */
12
+ export interface ILockEntryUseCase {
13
+ execute(input: LockEntryInput): Promise<Result<ILockRecord, UseCaseError>>;
14
+ }
15
+ export interface ILockEntryUseCaseErrors {
16
+ alreadyLocked: EntryAlreadyLockedError;
17
+ persistence: LockRecordPersistenceError;
18
+ lockError: LockEntryError;
19
+ }
20
+ type UseCaseError = ILockEntryUseCaseErrors[keyof ILockEntryUseCaseErrors];
21
+ export declare const LockEntryUseCase: import("@webiny/di").Abstraction<ILockEntryUseCase>;
22
+ export declare namespace LockEntryUseCase {
23
+ type Interface = ILockEntryUseCase;
24
+ type Error = UseCaseError;
25
+ }
26
+ /**
27
+ * LockEntryRepository - Creates lock record in storage
28
+ */
29
+ export interface ILockEntryRepository {
30
+ create(input: LockEntryInput): Promise<Result<ILockRecord, RepositoryError>>;
31
+ }
32
+ export interface ILockEntryRepositoryErrors {
33
+ persistence: LockRecordPersistenceError;
34
+ }
35
+ type RepositoryError = ILockEntryRepositoryErrors[keyof ILockEntryRepositoryErrors];
36
+ export declare const LockEntryRepository: import("@webiny/di").Abstraction<ILockEntryRepository>;
37
+ export declare namespace LockEntryRepository {
38
+ type Interface = ILockEntryRepository;
39
+ type Error = RepositoryError;
40
+ }
41
+ export {};
@@ -0,0 +1,17 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+
3
+ // Input types
4
+
5
+ /**
6
+ * LockEntry Use Case - Creates a lock on an entry
7
+ */
8
+
9
+ export const LockEntryUseCase = createAbstraction("LockEntryUseCase");
10
+
11
+ /**
12
+ * LockEntryRepository - Creates lock record in storage
13
+ */
14
+
15
+ export const LockEntryRepository = createAbstraction("LockEntryRepository");
16
+
17
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createAbstraction","LockEntryUseCase","LockEntryRepository"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordEntryType } from \"~/domain/types.js\";\nimport type {\n EntryAlreadyLockedError,\n LockEntryError,\n LockRecordPersistenceError\n} from \"~/domain/errors.js\";\n\n// Input types\nexport interface LockEntryInput {\n id: string;\n type: LockRecordEntryType;\n}\n\n/**\n * LockEntry Use Case - Creates a lock on an entry\n */\nexport interface ILockEntryUseCase {\n execute(input: LockEntryInput): Promise<Result<ILockRecord, UseCaseError>>;\n}\n\nexport interface ILockEntryUseCaseErrors {\n alreadyLocked: EntryAlreadyLockedError;\n persistence: LockRecordPersistenceError;\n lockError: LockEntryError;\n}\n\ntype UseCaseError = ILockEntryUseCaseErrors[keyof ILockEntryUseCaseErrors];\n\nexport const LockEntryUseCase = createAbstraction<ILockEntryUseCase>(\"LockEntryUseCase\");\n\nexport namespace LockEntryUseCase {\n export type Interface = ILockEntryUseCase;\n export type Error = UseCaseError;\n}\n\n/**\n * LockEntryRepository - Creates lock record in storage\n */\nexport interface ILockEntryRepository {\n create(input: LockEntryInput): Promise<Result<ILockRecord, RepositoryError>>;\n}\n\nexport interface ILockEntryRepositoryErrors {\n persistence: LockRecordPersistenceError;\n}\n\ntype RepositoryError = ILockEntryRepositoryErrors[keyof ILockEntryRepositoryErrors];\n\nexport const LockEntryRepository = createAbstraction<ILockEntryRepository>(\"LockEntryRepository\");\n\nexport namespace LockEntryRepository {\n export type Interface = ILockEntryRepository;\n export type Error = RepositoryError;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAUvD;;AAMA;AACA;AACA;;AAaA,OAAO,MAAMC,gBAAgB,GAAGD,iBAAiB,CAAoB,kBAAkB,CAAC;;AAOxF;AACA;AACA;;AAWA,OAAO,MAAME,mBAAmB,GAAGF,iBAAiB,CAAuB,qBAAqB,CAAC","ignoreList":[]}
@@ -0,0 +1,45 @@
1
+ import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
2
+ import type { IEventHandler } from "@webiny/api-core/features/eventPublisher/index.js";
3
+ import type { ILockRecord } from "../../domain/LockRecord.js";
4
+ import type { LockRecordEntryType } from "../../domain/types.js";
5
+ export interface EntryBeforeLockPayload {
6
+ id: string;
7
+ type: LockRecordEntryType;
8
+ }
9
+ export declare class EntryBeforeLockEvent extends DomainEvent<EntryBeforeLockPayload> {
10
+ eventType: "RecordLocking/Entry/BeforeLock";
11
+ getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryBeforeLockEvent>>;
12
+ }
13
+ export declare const EntryBeforeLockEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryBeforeLockEvent>>;
14
+ export declare namespace EntryBeforeLockEventHandler {
15
+ type Interface = IEventHandler<EntryBeforeLockEvent>;
16
+ type Event = EntryBeforeLockEvent;
17
+ }
18
+ export interface EntryAfterLockPayload {
19
+ id: string;
20
+ type: LockRecordEntryType;
21
+ record: ILockRecord;
22
+ }
23
+ export declare class EntryAfterLockEvent extends DomainEvent<EntryAfterLockPayload> {
24
+ eventType: "RecordLocking/Entry/AfterLock";
25
+ getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryAfterLockEvent>>;
26
+ }
27
+ export declare const EntryAfterLockEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryAfterLockEvent>>;
28
+ export declare namespace EntryAfterLockEventHandler {
29
+ type Interface = IEventHandler<EntryAfterLockEvent>;
30
+ type Event = EntryAfterLockEvent;
31
+ }
32
+ export interface EntryLockErrorPayload {
33
+ id: string;
34
+ type: LockRecordEntryType;
35
+ error: Error;
36
+ }
37
+ export declare class EntryLockErrorEvent extends DomainEvent<EntryLockErrorPayload> {
38
+ eventType: "RecordLocking/Entry/LockError";
39
+ getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryLockErrorEvent>>;
40
+ }
41
+ export declare const EntryLockErrorEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryLockErrorEvent>>;
42
+ export declare namespace EntryLockErrorEventHandler {
43
+ type Interface = IEventHandler<EntryLockErrorEvent>;
44
+ type Event = EntryLockErrorEvent;
45
+ }
@@ -0,0 +1,40 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
3
+
4
+ // ============================================================================
5
+ // EntryBeforeLock Event
6
+ // ============================================================================
7
+
8
+ export class EntryBeforeLockEvent extends DomainEvent {
9
+ eventType = "RecordLocking/Entry/BeforeLock";
10
+ getHandlerAbstraction() {
11
+ return EntryBeforeLockEventHandler;
12
+ }
13
+ }
14
+ export const EntryBeforeLockEventHandler = createAbstraction("EntryBeforeLockEventHandler");
15
+
16
+ // ============================================================================
17
+ // EntryAfterLock Event
18
+ // ============================================================================
19
+
20
+ export class EntryAfterLockEvent extends DomainEvent {
21
+ eventType = "RecordLocking/Entry/AfterLock";
22
+ getHandlerAbstraction() {
23
+ return EntryAfterLockEventHandler;
24
+ }
25
+ }
26
+ export const EntryAfterLockEventHandler = createAbstraction("EntryAfterLockEventHandler");
27
+
28
+ // ============================================================================
29
+ // EntryLockError Event
30
+ // ============================================================================
31
+
32
+ export class EntryLockErrorEvent extends DomainEvent {
33
+ eventType = "RecordLocking/Entry/LockError";
34
+ getHandlerAbstraction() {
35
+ return EntryLockErrorEventHandler;
36
+ }
37
+ }
38
+ export const EntryLockErrorEventHandler = createAbstraction("EntryLockErrorEventHandler");
39
+
40
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createAbstraction","DomainEvent","EntryBeforeLockEvent","eventType","getHandlerAbstraction","EntryBeforeLockEventHandler","EntryAfterLockEvent","EntryAfterLockEventHandler","EntryLockErrorEvent","EntryLockErrorEventHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordEntryType } from \"~/domain/types.js\";\n\n// ============================================================================\n// EntryBeforeLock Event\n// ============================================================================\n\nexport interface EntryBeforeLockPayload {\n id: string;\n type: LockRecordEntryType;\n}\n\nexport class EntryBeforeLockEvent extends DomainEvent<EntryBeforeLockPayload> {\n eventType = \"RecordLocking/Entry/BeforeLock\" as const;\n\n getHandlerAbstraction() {\n return EntryBeforeLockEventHandler;\n }\n}\n\nexport const EntryBeforeLockEventHandler = createAbstraction<IEventHandler<EntryBeforeLockEvent>>(\n \"EntryBeforeLockEventHandler\"\n);\n\nexport namespace EntryBeforeLockEventHandler {\n export type Interface = IEventHandler<EntryBeforeLockEvent>;\n export type Event = EntryBeforeLockEvent;\n}\n\n// ============================================================================\n// EntryAfterLock Event\n// ============================================================================\n\nexport interface EntryAfterLockPayload {\n id: string;\n type: LockRecordEntryType;\n record: ILockRecord;\n}\n\nexport class EntryAfterLockEvent extends DomainEvent<EntryAfterLockPayload> {\n eventType = \"RecordLocking/Entry/AfterLock\" as const;\n\n getHandlerAbstraction() {\n return EntryAfterLockEventHandler;\n }\n}\n\nexport const EntryAfterLockEventHandler = createAbstraction<IEventHandler<EntryAfterLockEvent>>(\n \"EntryAfterLockEventHandler\"\n);\n\nexport namespace EntryAfterLockEventHandler {\n export type Interface = IEventHandler<EntryAfterLockEvent>;\n export type Event = EntryAfterLockEvent;\n}\n\n// ============================================================================\n// EntryLockError Event\n// ============================================================================\n\nexport interface EntryLockErrorPayload {\n id: string;\n type: LockRecordEntryType;\n error: Error;\n}\n\nexport class EntryLockErrorEvent extends DomainEvent<EntryLockErrorPayload> {\n eventType = \"RecordLocking/Entry/LockError\" as const;\n\n getHandlerAbstraction() {\n return EntryLockErrorEventHandler;\n }\n}\n\nexport const EntryLockErrorEventHandler = createAbstraction<IEventHandler<EntryLockErrorEvent>>(\n \"EntryLockErrorEventHandler\"\n);\n\nexport namespace EntryLockErrorEventHandler {\n export type Interface = IEventHandler<EntryLockErrorEvent>;\n export type Event = EntryLockErrorEvent;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW,QAAQ,mDAAmD;;AAK/E;AACA;AACA;;AAOA,OAAO,MAAMC,oBAAoB,SAASD,WAAW,CAAyB;EAC1EE,SAAS,GAAG,gCAAgC;EAE5CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,2BAA2B;EACtC;AACJ;AAEA,OAAO,MAAMA,2BAA2B,GAAGL,iBAAiB,CACxD,6BACJ,CAAC;;AAOD;AACA;AACA;;AAQA,OAAO,MAAMM,mBAAmB,SAASL,WAAW,CAAwB;EACxEE,SAAS,GAAG,+BAA+B;EAE3CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,0BAA0B;EACrC;AACJ;AAEA,OAAO,MAAMA,0BAA0B,GAAGP,iBAAiB,CACvD,4BACJ,CAAC;;AAOD;AACA;AACA;;AAQA,OAAO,MAAMQ,mBAAmB,SAASP,WAAW,CAAwB;EACxEE,SAAS,GAAG,+BAA+B;EAE3CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOK,0BAA0B;EACrC;AACJ;AAEA,OAAO,MAAMA,0BAA0B,GAAGT,iBAAiB,CACvD,4BACJ,CAAC","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ export declare const LockEntryFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,14 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { LockEntryUseCase } from "./LockEntryUseCase.js";
3
+ import { LockEntryRepository } from "./LockEntryRepository.js";
4
+ import { LockEntryEventsDecorator } from "./LockEntryEventsDecorator.js";
5
+ export const LockEntryFeature = createFeature({
6
+ name: "LockEntry",
7
+ register(container) {
8
+ container.register(LockEntryUseCase);
9
+ container.register(LockEntryRepository).inSingletonScope();
10
+ container.registerDecorator(LockEntryEventsDecorator);
11
+ }
12
+ });
13
+
14
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createFeature","LockEntryUseCase","LockEntryRepository","LockEntryEventsDecorator","LockEntryFeature","name","register","container","inSingletonScope","registerDecorator"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { LockEntryUseCase } from \"./LockEntryUseCase.js\";\nimport { LockEntryRepository } from \"./LockEntryRepository.js\";\nimport { LockEntryEventsDecorator } from \"./LockEntryEventsDecorator.js\";\n\nexport const LockEntryFeature = createFeature({\n name: \"LockEntry\",\n register(container) {\n container.register(LockEntryUseCase);\n container.register(LockEntryRepository).inSingletonScope();\n container.registerDecorator(LockEntryEventsDecorator);\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,gBAAgB;AACzB,SAASC,mBAAmB;AAC5B,SAASC,wBAAwB;AAEjC,OAAO,MAAMC,gBAAgB,GAAGJ,aAAa,CAAC;EAC1CK,IAAI,EAAE,WAAW;EACjBC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACL,gBAAgB,CAAC;IACpCM,SAAS,CAACD,QAAQ,CAACJ,mBAAmB,CAAC,CAACM,gBAAgB,CAAC,CAAC;IAC1DD,SAAS,CAACE,iBAAiB,CAACN,wBAAwB,CAAC;EACzD;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ export * from "./abstractions.js";
@@ -0,0 +1,3 @@
1
+ export * from "./abstractions.js";
2
+
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
@@ -0,0 +1,15 @@
1
+ import type { CmsModel } from "@webiny/api-headless-cms/types";
2
+ export interface RecordLockingParams {
3
+ /**
4
+ * Timeout in milliseconds after which a lock expires
5
+ */
6
+ timeout: number;
7
+ /**
8
+ * The CMS model for storing lock records
9
+ */
10
+ model: CmsModel;
11
+ }
12
+ export declare const RecordLockingFeature: {
13
+ name: string;
14
+ register(container: import("@webiny/di").Container, context: RecordLockingParams): void;
15
+ };
@@ -0,0 +1,36 @@
1
+ import { createFeature } from "@webiny/feature/api";
2
+ import { RecordLockingConfig, RecordLockingModel } from "../domain/abstractions.js";
3
+ import { GetLockRecordFeature } from "./GetLockRecord/feature.js";
4
+ import { GetLockedEntryLockRecordFeature } from "./GetLockedEntryLockRecord/feature.js";
5
+ import { KickOutCurrentUserFeature } from "./KickOutCurrentUser/feature.js";
6
+ import { ListLockRecordsFeature } from "./ListLockRecords/feature.js";
7
+ import { ListAllLockRecordsFeature } from "./ListAllLockRecords/feature.js";
8
+ import { IsEntryLockedFeature } from "./IsEntryLocked/feature.js";
9
+ import { LockEntryFeature } from "./LockEntry/feature.js";
10
+ import { UpdateEntryLockFeature } from "./UpdateEntryLock/feature.js";
11
+ import { UnlockEntryFeature } from "./UnlockEntry/feature.js";
12
+ import { UnlockEntryRequestFeature } from "./UnlockEntryRequest/feature.js";
13
+ export const RecordLockingFeature = createFeature({
14
+ name: "RecordLockingManagement",
15
+ register(container, params) {
16
+ // Register domain abstractions
17
+ container.registerInstance(RecordLockingConfig, {
18
+ timeout: params.timeout
19
+ });
20
+ container.registerInstance(RecordLockingModel, params.model);
21
+
22
+ // Register all sub-features
23
+ GetLockRecordFeature.register(container);
24
+ GetLockedEntryLockRecordFeature.register(container);
25
+ KickOutCurrentUserFeature.register(container);
26
+ ListLockRecordsFeature.register(container);
27
+ ListAllLockRecordsFeature.register(container);
28
+ IsEntryLockedFeature.register(container);
29
+ LockEntryFeature.register(container);
30
+ UpdateEntryLockFeature.register(container);
31
+ UnlockEntryFeature.register(container);
32
+ UnlockEntryRequestFeature.register(container);
33
+ }
34
+ });
35
+
36
+ //# sourceMappingURL=RecordLockingFeature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createFeature","RecordLockingConfig","RecordLockingModel","GetLockRecordFeature","GetLockedEntryLockRecordFeature","KickOutCurrentUserFeature","ListLockRecordsFeature","ListAllLockRecordsFeature","IsEntryLockedFeature","LockEntryFeature","UpdateEntryLockFeature","UnlockEntryFeature","UnlockEntryRequestFeature","RecordLockingFeature","name","register","container","params","registerInstance","timeout","model"],"sources":["RecordLockingFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { RecordLockingConfig, RecordLockingModel } from \"~/domain/abstractions.js\";\nimport { GetLockRecordFeature } from \"./GetLockRecord/feature.js\";\nimport { GetLockedEntryLockRecordFeature } from \"./GetLockedEntryLockRecord/feature.js\";\nimport { KickOutCurrentUserFeature } from \"./KickOutCurrentUser/feature.js\";\nimport { ListLockRecordsFeature } from \"./ListLockRecords/feature.js\";\nimport { ListAllLockRecordsFeature } from \"./ListAllLockRecords/feature.js\";\nimport { IsEntryLockedFeature } from \"./IsEntryLocked/feature.js\";\nimport { LockEntryFeature } from \"./LockEntry/feature.js\";\nimport { UpdateEntryLockFeature } from \"./UpdateEntryLock/feature.js\";\nimport { UnlockEntryFeature } from \"./UnlockEntry/feature.js\";\nimport { UnlockEntryRequestFeature } from \"./UnlockEntryRequest/feature.js\";\n\nexport interface RecordLockingParams {\n /**\n * Timeout in milliseconds after which a lock expires\n */\n timeout: number;\n /**\n * The CMS model for storing lock records\n */\n model: CmsModel;\n}\n\nexport const RecordLockingFeature = createFeature<RecordLockingParams>({\n name: \"RecordLockingManagement\",\n register(container, params) {\n // Register domain abstractions\n container.registerInstance(RecordLockingConfig, { timeout: params.timeout });\n container.registerInstance(RecordLockingModel, params.model);\n\n // Register all sub-features\n GetLockRecordFeature.register(container);\n GetLockedEntryLockRecordFeature.register(container);\n KickOutCurrentUserFeature.register(container);\n ListLockRecordsFeature.register(container);\n ListAllLockRecordsFeature.register(container);\n IsEntryLockedFeature.register(container);\n LockEntryFeature.register(container);\n UpdateEntryLockFeature.register(container);\n UnlockEntryFeature.register(container);\n UnlockEntryRequestFeature.register(container);\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AAEnD,SAASC,mBAAmB,EAAEC,kBAAkB;AAChD,SAASC,oBAAoB;AAC7B,SAASC,+BAA+B;AACxC,SAASC,yBAAyB;AAClC,SAASC,sBAAsB;AAC/B,SAASC,yBAAyB;AAClC,SAASC,oBAAoB;AAC7B,SAASC,gBAAgB;AACzB,SAASC,sBAAsB;AAC/B,SAASC,kBAAkB;AAC3B,SAASC,yBAAyB;AAalC,OAAO,MAAMC,oBAAoB,GAAGb,aAAa,CAAsB;EACnEc,IAAI,EAAE,yBAAyB;EAC/BC,QAAQA,CAACC,SAAS,EAAEC,MAAM,EAAE;IACxB;IACAD,SAAS,CAACE,gBAAgB,CAACjB,mBAAmB,EAAE;MAAEkB,OAAO,EAAEF,MAAM,CAACE;IAAQ,CAAC,CAAC;IAC5EH,SAAS,CAACE,gBAAgB,CAAChB,kBAAkB,EAAEe,MAAM,CAACG,KAAK,CAAC;;IAE5D;IACAjB,oBAAoB,CAACY,QAAQ,CAACC,SAAS,CAAC;IACxCZ,+BAA+B,CAACW,QAAQ,CAACC,SAAS,CAAC;IACnDX,yBAAyB,CAACU,QAAQ,CAACC,SAAS,CAAC;IAC7CV,sBAAsB,CAACS,QAAQ,CAACC,SAAS,CAAC;IAC1CT,yBAAyB,CAACQ,QAAQ,CAACC,SAAS,CAAC;IAC7CR,oBAAoB,CAACO,QAAQ,CAACC,SAAS,CAAC;IACxCP,gBAAgB,CAACM,QAAQ,CAACC,SAAS,CAAC;IACpCN,sBAAsB,CAACK,QAAQ,CAACC,SAAS,CAAC;IAC1CL,kBAAkB,CAACI,QAAQ,CAACC,SAAS,CAAC;IACtCJ,yBAAyB,CAACG,QAAQ,CAACC,SAAS,CAAC;EACjD;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,14 @@
1
+ import { type UnlockEntryInput, UnlockEntryUseCase as UseCaseAbstraction, UnlockEntryUseCase } from "./abstractions.js";
2
+ import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
3
+ import type { ILockRecord } from "../../domain/index.js";
4
+ import { Result } from "@webiny/feature/api/index.js";
5
+ declare class UnlockEntryEventsDecoratorImpl implements UnlockEntryUseCase.Interface {
6
+ private readonly eventPublisher;
7
+ private readonly decoratee;
8
+ constructor(eventPublisher: EventPublisher.Interface, decoratee: UnlockEntryUseCase.Interface);
9
+ execute(input: UnlockEntryInput): Promise<Result<ILockRecord, UseCaseAbstraction.Error>>;
10
+ }
11
+ export declare const UnlockEntryEventsDecorator: typeof UnlockEntryEventsDecoratorImpl & {
12
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IUnlockEntryUseCase>;
13
+ };
14
+ export {};
@@ -0,0 +1,41 @@
1
+ import { UnlockEntryUseCase } from "./abstractions.js";
2
+ import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
3
+ import { EntryAfterUnlockEvent, EntryBeforeUnlockEvent, EntryUnlockErrorEvent } from "./events.js";
4
+ class UnlockEntryEventsDecoratorImpl {
5
+ constructor(eventPublisher, decoratee) {
6
+ this.eventPublisher = eventPublisher;
7
+ this.decoratee = decoratee;
8
+ }
9
+ async execute(input) {
10
+ // Publish before event
11
+ await this.eventPublisher.publish(new EntryBeforeUnlockEvent({
12
+ id: input.id,
13
+ type: input.type,
14
+ force: input.force
15
+ }));
16
+ const result = await this.decoratee.execute(input);
17
+ if (result.isFail()) {
18
+ const error = result.error;
19
+ await this.eventPublisher.publish(new EntryUnlockErrorEvent({
20
+ id: input.id,
21
+ type: input.type,
22
+ error
23
+ }));
24
+ return result;
25
+ }
26
+
27
+ // Publish after event
28
+ await this.eventPublisher.publish(new EntryAfterUnlockEvent({
29
+ id: input.id,
30
+ type: input.type,
31
+ record: result.value
32
+ }));
33
+ return result;
34
+ }
35
+ }
36
+ export const UnlockEntryEventsDecorator = UnlockEntryUseCase.createDecorator({
37
+ decorator: UnlockEntryEventsDecoratorImpl,
38
+ dependencies: [EventPublisher]
39
+ });
40
+
41
+ //# sourceMappingURL=UnlockEntryEventsDecorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["UnlockEntryUseCase","EventPublisher","EntryAfterUnlockEvent","EntryBeforeUnlockEvent","EntryUnlockErrorEvent","UnlockEntryEventsDecoratorImpl","constructor","eventPublisher","decoratee","execute","input","publish","id","type","force","result","isFail","error","record","value","UnlockEntryEventsDecorator","createDecorator","decorator","dependencies"],"sources":["UnlockEntryEventsDecorator.ts"],"sourcesContent":["import {\n type UnlockEntryInput,\n UnlockEntryUseCase as UseCaseAbstraction,\n UnlockEntryUseCase\n} from \"./abstractions.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { ILockRecord } from \"~/domain/index.js\";\nimport { Result } from \"@webiny/feature/api/index.js\";\nimport { EntryAfterUnlockEvent, EntryBeforeUnlockEvent, EntryUnlockErrorEvent } from \"./events.js\";\n\nclass UnlockEntryEventsDecoratorImpl implements UnlockEntryUseCase.Interface {\n constructor(\n private readonly eventPublisher: EventPublisher.Interface,\n private readonly decoratee: UnlockEntryUseCase.Interface\n ) {}\n\n async execute(input: UnlockEntryInput): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Publish before event\n await this.eventPublisher.publish(\n new EntryBeforeUnlockEvent({\n id: input.id,\n type: input.type,\n force: input.force\n })\n );\n\n const result = await this.decoratee.execute(input);\n\n if (result.isFail()) {\n const error = result.error;\n\n await this.eventPublisher.publish(\n new EntryUnlockErrorEvent({\n id: input.id,\n type: input.type,\n error\n })\n );\n\n return result;\n }\n\n // Publish after event\n await this.eventPublisher.publish(\n new EntryAfterUnlockEvent({\n id: input.id,\n type: input.type,\n record: result.value\n })\n );\n\n return result;\n }\n}\n\nexport const UnlockEntryEventsDecorator = UnlockEntryUseCase.createDecorator({\n decorator: UnlockEntryEventsDecoratorImpl,\n dependencies: [EventPublisher]\n});\n"],"mappings":"AAAA,SAGIA,kBAAkB;AAEtB,SAASC,cAAc,QAAQ,mDAAmD;AAGlF,SAASC,qBAAqB,EAAEC,sBAAsB,EAAEC,qBAAqB;AAE7E,MAAMC,8BAA8B,CAAyC;EACzEC,WAAWA,CACUC,cAAwC,EACxCC,SAAuC,EAC1D;IAAA,KAFmBD,cAAwC,GAAxCA,cAAwC;IAAA,KACxCC,SAAuC,GAAvCA,SAAuC;EACzD;EAEH,MAAMC,OAAOA,CAACC,KAAuB,EAA0D;IAC3F;IACA,MAAM,IAAI,CAACH,cAAc,CAACI,OAAO,CAC7B,IAAIR,sBAAsB,CAAC;MACvBS,EAAE,EAAEF,KAAK,CAACE,EAAE;MACZC,IAAI,EAAEH,KAAK,CAACG,IAAI;MAChBC,KAAK,EAAEJ,KAAK,CAACI;IACjB,CAAC,CACL,CAAC;IAED,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACP,SAAS,CAACC,OAAO,CAACC,KAAK,CAAC;IAElD,IAAIK,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;MACjB,MAAMC,KAAK,GAAGF,MAAM,CAACE,KAAK;MAE1B,MAAM,IAAI,CAACV,cAAc,CAACI,OAAO,CAC7B,IAAIP,qBAAqB,CAAC;QACtBQ,EAAE,EAAEF,KAAK,CAACE,EAAE;QACZC,IAAI,EAAEH,KAAK,CAACG,IAAI;QAChBI;MACJ,CAAC,CACL,CAAC;MAED,OAAOF,MAAM;IACjB;;IAEA;IACA,MAAM,IAAI,CAACR,cAAc,CAACI,OAAO,CAC7B,IAAIT,qBAAqB,CAAC;MACtBU,EAAE,EAAEF,KAAK,CAACE,EAAE;MACZC,IAAI,EAAEH,KAAK,CAACG,IAAI;MAChBK,MAAM,EAAEH,MAAM,CAACI;IACnB,CAAC,CACL,CAAC;IAED,OAAOJ,MAAM;EACjB;AACJ;AAEA,OAAO,MAAMK,0BAA0B,GAAGpB,kBAAkB,CAACqB,eAAe,CAAC;EACzEC,SAAS,EAAEjB,8BAA8B;EACzCkB,YAAY,EAAE,CAACtB,cAAc;AACjC,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,14 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { DeleteEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/DeleteEntry";
3
+ import { UnlockEntryRepository as RepositoryAbstraction } from "./abstractions.js";
4
+ import { RecordLockingModel } from "../../domain/abstractions.js";
5
+ declare class UnlockEntryRepositoryImpl implements RepositoryAbstraction.Interface {
6
+ private model;
7
+ private deleteEntry;
8
+ constructor(model: RecordLockingModel.Interface, deleteEntry: DeleteEntryUseCase.Interface);
9
+ delete(lockRecordId: string): Promise<Result<void, RepositoryAbstraction.Error>>;
10
+ }
11
+ export declare const UnlockEntryRepository: typeof UnlockEntryRepositoryImpl & {
12
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IUnlockEntryRepository>;
13
+ };
14
+ export {};
@@ -0,0 +1,40 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { DeleteEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/DeleteEntry";
3
+ import { createIdentifier } from "@webiny/utils";
4
+ import { UnlockEntryRepository as RepositoryAbstraction } from "./abstractions.js";
5
+ import { RecordLockingModel } from "../../domain/abstractions.js";
6
+ import { LockRecordNotFoundError, UnlockEntryError } from "../../domain/errors.js";
7
+ import { createLockRecordDatabaseId } from "../../utils/lockRecordDatabaseId.js";
8
+ class UnlockEntryRepositoryImpl {
9
+ constructor(model, deleteEntry) {
10
+ this.model = model;
11
+ this.deleteEntry = deleteEntry;
12
+ }
13
+ async delete(lockRecordId) {
14
+ try {
15
+ const entryId = createLockRecordDatabaseId(lockRecordId);
16
+ const id = createIdentifier({
17
+ id: entryId,
18
+ version: 1
19
+ });
20
+ const result = await this.deleteEntry.execute(this.model, id, {
21
+ permanently: true
22
+ });
23
+ if (result.isFail()) {
24
+ if (result.error.code === "Cms/Entry/NotFound") {
25
+ return Result.fail(new LockRecordNotFoundError());
26
+ }
27
+ return Result.fail(new UnlockEntryError(result.error));
28
+ }
29
+ return Result.ok();
30
+ } catch (error) {
31
+ return Result.fail(new UnlockEntryError(error));
32
+ }
33
+ }
34
+ }
35
+ export const UnlockEntryRepository = RepositoryAbstraction.createImplementation({
36
+ implementation: UnlockEntryRepositoryImpl,
37
+ dependencies: [RecordLockingModel, DeleteEntryUseCase]
38
+ });
39
+
40
+ //# sourceMappingURL=UnlockEntryRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Result","DeleteEntryUseCase","createIdentifier","UnlockEntryRepository","RepositoryAbstraction","RecordLockingModel","LockRecordNotFoundError","UnlockEntryError","createLockRecordDatabaseId","UnlockEntryRepositoryImpl","constructor","model","deleteEntry","delete","lockRecordId","entryId","id","version","result","execute","permanently","isFail","error","code","fail","ok","createImplementation","implementation","dependencies"],"sources":["UnlockEntryRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { DeleteEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/DeleteEntry\";\nimport { createIdentifier } from \"@webiny/utils\";\nimport { UnlockEntryRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { RecordLockingModel } from \"~/domain/abstractions.js\";\nimport { LockRecordNotFoundError, UnlockEntryError } from \"~/domain/errors.js\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId.js\";\n\nclass UnlockEntryRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private model: RecordLockingModel.Interface,\n private deleteEntry: DeleteEntryUseCase.Interface\n ) {}\n\n async delete(lockRecordId: string): Promise<Result<void, RepositoryAbstraction.Error>> {\n try {\n const entryId = createLockRecordDatabaseId(lockRecordId);\n const id = createIdentifier({\n id: entryId,\n version: 1\n });\n\n const result = await this.deleteEntry.execute(this.model, id, {\n permanently: true\n });\n\n if (result.isFail()) {\n if (result.error.code === \"Cms/Entry/NotFound\") {\n return Result.fail(new LockRecordNotFoundError());\n }\n return Result.fail(new UnlockEntryError(result.error));\n }\n\n return Result.ok();\n } catch (error) {\n return Result.fail(new UnlockEntryError(error as Error));\n }\n }\n}\n\nexport const UnlockEntryRepository = RepositoryAbstraction.createImplementation({\n implementation: UnlockEntryRepositoryImpl,\n dependencies: [RecordLockingModel, DeleteEntryUseCase]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,kBAAkB,QAAQ,4DAA4D;AAC/F,SAASC,gBAAgB,QAAQ,eAAe;AAChD,SAASC,qBAAqB,IAAIC,qBAAqB;AACvD,SAASC,kBAAkB;AAC3B,SAASC,uBAAuB,EAAEC,gBAAgB;AAClD,SAASC,0BAA0B;AAEnC,MAAMC,yBAAyB,CAA4C;EACvEC,WAAWA,CACCC,KAAmC,EACnCC,WAAyC,EACnD;IAAA,KAFUD,KAAmC,GAAnCA,KAAmC;IAAA,KACnCC,WAAyC,GAAzCA,WAAyC;EAClD;EAEH,MAAMC,MAAMA,CAACC,YAAoB,EAAsD;IACnF,IAAI;MACA,MAAMC,OAAO,GAAGP,0BAA0B,CAACM,YAAY,CAAC;MACxD,MAAME,EAAE,GAAGd,gBAAgB,CAAC;QACxBc,EAAE,EAAED,OAAO;QACXE,OAAO,EAAE;MACb,CAAC,CAAC;MAEF,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACN,WAAW,CAACO,OAAO,CAAC,IAAI,CAACR,KAAK,EAAEK,EAAE,EAAE;QAC1DI,WAAW,EAAE;MACjB,CAAC,CAAC;MAEF,IAAIF,MAAM,CAACG,MAAM,CAAC,CAAC,EAAE;QACjB,IAAIH,MAAM,CAACI,KAAK,CAACC,IAAI,KAAK,oBAAoB,EAAE;UAC5C,OAAOvB,MAAM,CAACwB,IAAI,CAAC,IAAIlB,uBAAuB,CAAC,CAAC,CAAC;QACrD;QACA,OAAON,MAAM,CAACwB,IAAI,CAAC,IAAIjB,gBAAgB,CAACW,MAAM,CAACI,KAAK,CAAC,CAAC;MAC1D;MAEA,OAAOtB,MAAM,CAACyB,EAAE,CAAC,CAAC;IACtB,CAAC,CAAC,OAAOH,KAAK,EAAE;MACZ,OAAOtB,MAAM,CAACwB,IAAI,CAAC,IAAIjB,gBAAgB,CAACe,KAAc,CAAC,CAAC;IAC5D;EACJ;AACJ;AAEA,OAAO,MAAMnB,qBAAqB,GAAGC,qBAAqB,CAACsB,oBAAoB,CAAC;EAC5EC,cAAc,EAAElB,yBAAyB;EACzCmB,YAAY,EAAE,CAACvB,kBAAkB,EAAEJ,kBAAkB;AACzD,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,18 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { UnlockEntryUseCase as UseCaseAbstraction, UnlockEntryRepository, UnlockEntryInput } from "./abstractions.js";
3
+ import { GetLockRecordUseCase } from "../GetLockRecord/abstractions.js";
4
+ import { KickOutCurrentUserUseCase } from "../KickOutCurrentUser/abstractions.js";
5
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
6
+ import type { ILockRecord } from "../../domain/LockRecord.js";
7
+ declare class UnlockEntryUseCaseImpl implements UseCaseAbstraction.Interface {
8
+ private getLockRecord;
9
+ private kickOutCurrentUser;
10
+ private repository;
11
+ private identityContext;
12
+ constructor(getLockRecord: GetLockRecordUseCase.Interface, kickOutCurrentUser: KickOutCurrentUserUseCase.Interface, repository: UnlockEntryRepository.Interface, identityContext: IdentityContext.Interface);
13
+ execute(input: UnlockEntryInput): Promise<Result<ILockRecord, UseCaseAbstraction.Error>>;
14
+ }
15
+ export declare const UnlockEntryUseCase: typeof UnlockEntryUseCaseImpl & {
16
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IUnlockEntryUseCase>;
17
+ };
18
+ export {};
@@ -0,0 +1,81 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { UnlockEntryUseCase as UseCaseAbstraction, UnlockEntryRepository } from "./abstractions.js";
3
+ import { GetLockRecordUseCase } from "../GetLockRecord/abstractions.js";
4
+ import { KickOutCurrentUserUseCase } from "../KickOutCurrentUser/abstractions.js";
5
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
6
+ import { LockRecordNotFoundError, IdentityMismatchError } from "../../domain/errors.js";
7
+ import { hasFullAccessPermission } from "./hasFullAccessPermission.js";
8
+ class UnlockEntryUseCaseImpl {
9
+ constructor(getLockRecord, kickOutCurrentUser, repository, identityContext) {
10
+ this.getLockRecord = getLockRecord;
11
+ this.kickOutCurrentUser = kickOutCurrentUser;
12
+ this.repository = repository;
13
+ this.identityContext = identityContext;
14
+ }
15
+ async execute(input) {
16
+ // Get the lock record
17
+ const recordResult = await this.getLockRecord.execute(input);
18
+
19
+ // If not found or expired, attempt cleanup and return error
20
+ if (recordResult.isFail()) {
21
+ if (recordResult.error instanceof LockRecordNotFoundError) {
22
+ // Try to cleanup any stale data
23
+ await this.repository.delete(input.id);
24
+ }
25
+ return Result.fail(recordResult.error);
26
+ }
27
+ const record = recordResult.value;
28
+
29
+ // If expired, cleanup and return error
30
+ if (record.isExpired()) {
31
+ await this.repository.delete(record.id);
32
+ const error = new LockRecordNotFoundError();
33
+ return Result.fail(error);
34
+ }
35
+
36
+ // Check if user is the owner
37
+ const identity = this.identityContext.getIdentity();
38
+ const isSameUser = record.lockedBy.id === identity.id;
39
+ let shouldKickOut = false;
40
+
41
+ // If not the owner, check if force unlock is allowed
42
+ if (!isSameUser) {
43
+ if (!input.force) {
44
+ const error = new IdentityMismatchError({
45
+ currentId: identity.id,
46
+ targetId: record.lockedBy.id
47
+ });
48
+ return Result.fail(error);
49
+ }
50
+
51
+ // Check if user has permission to force unlock
52
+ const hasAccess = await hasFullAccessPermission(this.identityContext);
53
+ if (!hasAccess) {
54
+ const error = new IdentityMismatchError({
55
+ currentId: identity.id,
56
+ targetId: record.lockedBy.id
57
+ });
58
+ return Result.fail(error);
59
+ }
60
+ shouldKickOut = true;
61
+ }
62
+
63
+ // Delete the lock record
64
+ const deleteResult = await this.repository.delete(record.id);
65
+ if (deleteResult.isFail()) {
66
+ return Result.fail(deleteResult.error);
67
+ }
68
+
69
+ // If forced by another user, kick out the original lock owner
70
+ if (shouldKickOut) {
71
+ await this.kickOutCurrentUser.execute(record);
72
+ }
73
+ return Result.ok(record);
74
+ }
75
+ }
76
+ export const UnlockEntryUseCase = UseCaseAbstraction.createImplementation({
77
+ implementation: UnlockEntryUseCaseImpl,
78
+ dependencies: [GetLockRecordUseCase, KickOutCurrentUserUseCase, UnlockEntryRepository, IdentityContext]
79
+ });
80
+
81
+ //# sourceMappingURL=UnlockEntryUseCase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Result","UnlockEntryUseCase","UseCaseAbstraction","UnlockEntryRepository","GetLockRecordUseCase","KickOutCurrentUserUseCase","IdentityContext","LockRecordNotFoundError","IdentityMismatchError","hasFullAccessPermission","UnlockEntryUseCaseImpl","constructor","getLockRecord","kickOutCurrentUser","repository","identityContext","execute","input","recordResult","isFail","error","delete","id","fail","record","value","isExpired","identity","getIdentity","isSameUser","lockedBy","shouldKickOut","force","currentId","targetId","hasAccess","deleteResult","ok","createImplementation","implementation","dependencies"],"sources":["UnlockEntryUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n UnlockEntryUseCase as UseCaseAbstraction,\n UnlockEntryRepository,\n UnlockEntryInput\n} from \"./abstractions.js\";\nimport { GetLockRecordUseCase } from \"../GetLockRecord/abstractions.js\";\nimport { KickOutCurrentUserUseCase } from \"../KickOutCurrentUser/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport { LockRecordNotFoundError, IdentityMismatchError } from \"~/domain/errors.js\";\nimport { hasFullAccessPermission } from \"./hasFullAccessPermission.js\";\n\nclass UnlockEntryUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getLockRecord: GetLockRecordUseCase.Interface,\n private kickOutCurrentUser: KickOutCurrentUserUseCase.Interface,\n private repository: UnlockEntryRepository.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute(input: UnlockEntryInput): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Get the lock record\n const recordResult = await this.getLockRecord.execute(input);\n\n // If not found or expired, attempt cleanup and return error\n if (recordResult.isFail()) {\n if (recordResult.error instanceof LockRecordNotFoundError) {\n // Try to cleanup any stale data\n await this.repository.delete(input.id);\n }\n\n return Result.fail(recordResult.error);\n }\n\n const record = recordResult.value;\n\n // If expired, cleanup and return error\n if (record.isExpired()) {\n await this.repository.delete(record.id);\n const error = new LockRecordNotFoundError();\n return Result.fail(error);\n }\n\n // Check if user is the owner\n const identity = this.identityContext.getIdentity();\n const isSameUser = record.lockedBy.id === identity.id;\n\n let shouldKickOut = false;\n\n // If not the owner, check if force unlock is allowed\n if (!isSameUser) {\n if (!input.force) {\n const error = new IdentityMismatchError({\n currentId: identity.id,\n targetId: record.lockedBy.id\n });\n return Result.fail(error);\n }\n\n // Check if user has permission to force unlock\n const hasAccess = await hasFullAccessPermission(this.identityContext);\n if (!hasAccess) {\n const error = new IdentityMismatchError({\n currentId: identity.id,\n targetId: record.lockedBy.id\n });\n return Result.fail(error);\n }\n\n shouldKickOut = true;\n }\n\n // Delete the lock record\n const deleteResult = await this.repository.delete(record.id);\n\n if (deleteResult.isFail()) {\n return Result.fail(deleteResult.error);\n }\n\n // If forced by another user, kick out the original lock owner\n if (shouldKickOut) {\n await this.kickOutCurrentUser.execute(record);\n }\n\n return Result.ok(record);\n }\n}\n\nexport const UnlockEntryUseCase = UseCaseAbstraction.createImplementation({\n implementation: UnlockEntryUseCaseImpl,\n dependencies: [\n GetLockRecordUseCase,\n KickOutCurrentUserUseCase,\n UnlockEntryRepository,\n IdentityContext\n ]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SACIC,kBAAkB,IAAIC,kBAAkB,EACxCC,qBAAqB;AAGzB,SAASC,oBAAoB;AAC7B,SAASC,yBAAyB;AAClC,SAASC,eAAe,QAAQ,6DAA6D;AAE7F,SAASC,uBAAuB,EAAEC,qBAAqB;AACvD,SAASC,uBAAuB;AAEhC,MAAMC,sBAAsB,CAAyC;EACjEC,WAAWA,CACCC,aAA6C,EAC7CC,kBAAuD,EACvDC,UAA2C,EAC3CC,eAA0C,EACpD;IAAA,KAJUH,aAA6C,GAA7CA,aAA6C;IAAA,KAC7CC,kBAAuD,GAAvDA,kBAAuD;IAAA,KACvDC,UAA2C,GAA3CA,UAA2C;IAAA,KAC3CC,eAA0C,GAA1CA,eAA0C;EACnD;EAEH,MAAMC,OAAOA,CAACC,KAAuB,EAA0D;IAC3F;IACA,MAAMC,YAAY,GAAG,MAAM,IAAI,CAACN,aAAa,CAACI,OAAO,CAACC,KAAK,CAAC;;IAE5D;IACA,IAAIC,YAAY,CAACC,MAAM,CAAC,CAAC,EAAE;MACvB,IAAID,YAAY,CAACE,KAAK,YAAYb,uBAAuB,EAAE;QACvD;QACA,MAAM,IAAI,CAACO,UAAU,CAACO,MAAM,CAACJ,KAAK,CAACK,EAAE,CAAC;MAC1C;MAEA,OAAOtB,MAAM,CAACuB,IAAI,CAACL,YAAY,CAACE,KAAK,CAAC;IAC1C;IAEA,MAAMI,MAAM,GAAGN,YAAY,CAACO,KAAK;;IAEjC;IACA,IAAID,MAAM,CAACE,SAAS,CAAC,CAAC,EAAE;MACpB,MAAM,IAAI,CAACZ,UAAU,CAACO,MAAM,CAACG,MAAM,CAACF,EAAE,CAAC;MACvC,MAAMF,KAAK,GAAG,IAAIb,uBAAuB,CAAC,CAAC;MAC3C,OAAOP,MAAM,CAACuB,IAAI,CAACH,KAAK,CAAC;IAC7B;;IAEA;IACA,MAAMO,QAAQ,GAAG,IAAI,CAACZ,eAAe,CAACa,WAAW,CAAC,CAAC;IACnD,MAAMC,UAAU,GAAGL,MAAM,CAACM,QAAQ,CAACR,EAAE,KAAKK,QAAQ,CAACL,EAAE;IAErD,IAAIS,aAAa,GAAG,KAAK;;IAEzB;IACA,IAAI,CAACF,UAAU,EAAE;MACb,IAAI,CAACZ,KAAK,CAACe,KAAK,EAAE;QACd,MAAMZ,KAAK,GAAG,IAAIZ,qBAAqB,CAAC;UACpCyB,SAAS,EAAEN,QAAQ,CAACL,EAAE;UACtBY,QAAQ,EAAEV,MAAM,CAACM,QAAQ,CAACR;QAC9B,CAAC,CAAC;QACF,OAAOtB,MAAM,CAACuB,IAAI,CAACH,KAAK,CAAC;MAC7B;;MAEA;MACA,MAAMe,SAAS,GAAG,MAAM1B,uBAAuB,CAAC,IAAI,CAACM,eAAe,CAAC;MACrE,IAAI,CAACoB,SAAS,EAAE;QACZ,MAAMf,KAAK,GAAG,IAAIZ,qBAAqB,CAAC;UACpCyB,SAAS,EAAEN,QAAQ,CAACL,EAAE;UACtBY,QAAQ,EAAEV,MAAM,CAACM,QAAQ,CAACR;QAC9B,CAAC,CAAC;QACF,OAAOtB,MAAM,CAACuB,IAAI,CAACH,KAAK,CAAC;MAC7B;MAEAW,aAAa,GAAG,IAAI;IACxB;;IAEA;IACA,MAAMK,YAAY,GAAG,MAAM,IAAI,CAACtB,UAAU,CAACO,MAAM,CAACG,MAAM,CAACF,EAAE,CAAC;IAE5D,IAAIc,YAAY,CAACjB,MAAM,CAAC,CAAC,EAAE;MACvB,OAAOnB,MAAM,CAACuB,IAAI,CAACa,YAAY,CAAChB,KAAK,CAAC;IAC1C;;IAEA;IACA,IAAIW,aAAa,EAAE;MACf,MAAM,IAAI,CAAClB,kBAAkB,CAACG,OAAO,CAACQ,MAAM,CAAC;IACjD;IAEA,OAAOxB,MAAM,CAACqC,EAAE,CAACb,MAAM,CAAC;EAC5B;AACJ;AAEA,OAAO,MAAMvB,kBAAkB,GAAGC,kBAAkB,CAACoC,oBAAoB,CAAC;EACtEC,cAAc,EAAE7B,sBAAsB;EACtC8B,YAAY,EAAE,CACVpC,oBAAoB,EACpBC,yBAAyB,EACzBF,qBAAqB,EACrBG,eAAe;AAEvB,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,44 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import type { ILockRecord } from "../../domain/LockRecord.js";
3
+ import type { LockRecordEntryType } from "../../domain/types.js";
4
+ import { type LockRecordNotFoundError, LockRecordPersistenceError, type IdentityMismatchError, type UnlockEntryError } from "../../domain/errors.js";
5
+ export interface UnlockEntryInput {
6
+ id: string;
7
+ type: LockRecordEntryType;
8
+ force?: boolean;
9
+ }
10
+ /**
11
+ * UnlockEntry Use Case - Unlocks an entry by deleting the lock record
12
+ */
13
+ export interface IUnlockEntryUseCase {
14
+ execute(input: UnlockEntryInput): Promise<Result<ILockRecord, UseCaseError>>;
15
+ }
16
+ export interface IUnlockEntryUseCaseErrors {
17
+ notFound: LockRecordNotFoundError;
18
+ notSameIdentity: IdentityMismatchError;
19
+ unlockError: UnlockEntryError;
20
+ persistence: LockRecordPersistenceError;
21
+ }
22
+ type UseCaseError = IUnlockEntryUseCaseErrors[keyof IUnlockEntryUseCaseErrors];
23
+ export declare const UnlockEntryUseCase: import("@webiny/di").Abstraction<IUnlockEntryUseCase>;
24
+ export declare namespace UnlockEntryUseCase {
25
+ type Interface = IUnlockEntryUseCase;
26
+ type Error = UseCaseError;
27
+ }
28
+ /**
29
+ * UnlockEntryRepository - Deletes lock record from storage
30
+ */
31
+ export interface IUnlockEntryRepository {
32
+ delete(lockRecordId: string): Promise<Result<void, RepositoryError>>;
33
+ }
34
+ export interface IUnlockEntryRepositoryErrors {
35
+ notFound: LockRecordNotFoundError;
36
+ unlockError: UnlockEntryError;
37
+ }
38
+ type RepositoryError = IUnlockEntryRepositoryErrors[keyof IUnlockEntryRepositoryErrors];
39
+ export declare const UnlockEntryRepository: import("@webiny/di").Abstraction<IUnlockEntryRepository>;
40
+ export declare namespace UnlockEntryRepository {
41
+ type Interface = IUnlockEntryRepository;
42
+ type Error = RepositoryError;
43
+ }
44
+ export {};
@@ -0,0 +1,17 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+
3
+ // Input types
4
+
5
+ /**
6
+ * UnlockEntry Use Case - Unlocks an entry by deleting the lock record
7
+ */
8
+
9
+ export const UnlockEntryUseCase = createAbstraction("UnlockEntryUseCase");
10
+
11
+ /**
12
+ * UnlockEntryRepository - Deletes lock record from storage
13
+ */
14
+
15
+ export const UnlockEntryRepository = createAbstraction("UnlockEntryRepository");
16
+
17
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createAbstraction","UnlockEntryUseCase","UnlockEntryRepository"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordEntryType } from \"~/domain/types.js\";\nimport {\n type LockRecordNotFoundError,\n LockRecordPersistenceError,\n type IdentityMismatchError,\n type UnlockEntryError\n} from \"~/domain/errors.js\";\n\n// Input types\nexport interface UnlockEntryInput {\n id: string;\n type: LockRecordEntryType;\n force?: boolean;\n}\n\n/**\n * UnlockEntry Use Case - Unlocks an entry by deleting the lock record\n */\nexport interface IUnlockEntryUseCase {\n execute(input: UnlockEntryInput): Promise<Result<ILockRecord, UseCaseError>>;\n}\n\nexport interface IUnlockEntryUseCaseErrors {\n notFound: LockRecordNotFoundError;\n notSameIdentity: IdentityMismatchError;\n unlockError: UnlockEntryError;\n persistence: LockRecordPersistenceError;\n}\n\ntype UseCaseError = IUnlockEntryUseCaseErrors[keyof IUnlockEntryUseCaseErrors];\n\nexport const UnlockEntryUseCase = createAbstraction<IUnlockEntryUseCase>(\"UnlockEntryUseCase\");\n\nexport namespace UnlockEntryUseCase {\n export type Interface = IUnlockEntryUseCase;\n export type Error = UseCaseError;\n}\n\n/**\n * UnlockEntryRepository - Deletes lock record from storage\n */\nexport interface IUnlockEntryRepository {\n delete(lockRecordId: string): Promise<Result<void, RepositoryError>>;\n}\n\nexport interface IUnlockEntryRepositoryErrors {\n notFound: LockRecordNotFoundError;\n unlockError: UnlockEntryError;\n}\n\ntype RepositoryError = IUnlockEntryRepositoryErrors[keyof IUnlockEntryRepositoryErrors];\n\nexport const UnlockEntryRepository =\n createAbstraction<IUnlockEntryRepository>(\"UnlockEntryRepository\");\n\nexport namespace UnlockEntryRepository {\n export type Interface = IUnlockEntryRepository;\n export type Error = RepositoryError;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAWvD;;AAOA;AACA;AACA;;AAcA,OAAO,MAAMC,kBAAkB,GAAGD,iBAAiB,CAAsB,oBAAoB,CAAC;;AAO9F;AACA;AACA;;AAYA,OAAO,MAAME,qBAAqB,GAC9BF,iBAAiB,CAAyB,uBAAuB,CAAC","ignoreList":[]}