@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,46 @@
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 EntryBeforeUnlockPayload {
6
+ id: string;
7
+ type: LockRecordEntryType;
8
+ force?: boolean;
9
+ }
10
+ export declare class EntryBeforeUnlockEvent extends DomainEvent<EntryBeforeUnlockPayload> {
11
+ eventType: "RecordLocking/Entry/BeforeUnlock";
12
+ getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryBeforeUnlockEvent>>;
13
+ }
14
+ export declare const EntryBeforeUnlockEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryBeforeUnlockEvent>>;
15
+ export declare namespace EntryBeforeUnlockEventHandler {
16
+ type Interface = IEventHandler<EntryBeforeUnlockEvent>;
17
+ type Event = EntryBeforeUnlockEvent;
18
+ }
19
+ export interface EntryAfterUnlockPayload {
20
+ id: string;
21
+ type: LockRecordEntryType;
22
+ record: ILockRecord;
23
+ }
24
+ export declare class EntryAfterUnlockEvent extends DomainEvent<EntryAfterUnlockPayload> {
25
+ eventType: "RecordLocking/Entry/AfterUnlock";
26
+ getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryAfterUnlockEvent>>;
27
+ }
28
+ export declare const EntryAfterUnlockEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryAfterUnlockEvent>>;
29
+ export declare namespace EntryAfterUnlockEventHandler {
30
+ type Interface = IEventHandler<EntryAfterUnlockEvent>;
31
+ type Event = EntryAfterUnlockEvent;
32
+ }
33
+ export interface EntryUnlockErrorPayload {
34
+ id: string;
35
+ type: LockRecordEntryType;
36
+ error: Error;
37
+ }
38
+ export declare class EntryUnlockErrorEvent extends DomainEvent<EntryUnlockErrorPayload> {
39
+ eventType: "RecordLocking/Entry/UnlockError";
40
+ getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryUnlockErrorEvent>>;
41
+ }
42
+ export declare const EntryUnlockErrorEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryUnlockErrorEvent>>;
43
+ export declare namespace EntryUnlockErrorEventHandler {
44
+ type Interface = IEventHandler<EntryUnlockErrorEvent>;
45
+ type Event = EntryUnlockErrorEvent;
46
+ }
@@ -0,0 +1,40 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+ import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
3
+
4
+ // ============================================================================
5
+ // EntryBeforeUnlock Event
6
+ // ============================================================================
7
+
8
+ export class EntryBeforeUnlockEvent extends DomainEvent {
9
+ eventType = "RecordLocking/Entry/BeforeUnlock";
10
+ getHandlerAbstraction() {
11
+ return EntryBeforeUnlockEventHandler;
12
+ }
13
+ }
14
+ export const EntryBeforeUnlockEventHandler = createAbstraction("EntryBeforeUnlockEventHandler");
15
+
16
+ // ============================================================================
17
+ // EntryAfterUnlock Event
18
+ // ============================================================================
19
+
20
+ export class EntryAfterUnlockEvent extends DomainEvent {
21
+ eventType = "RecordLocking/Entry/AfterUnlock";
22
+ getHandlerAbstraction() {
23
+ return EntryAfterUnlockEventHandler;
24
+ }
25
+ }
26
+ export const EntryAfterUnlockEventHandler = createAbstraction("EntryAfterUnlockEventHandler");
27
+
28
+ // ============================================================================
29
+ // EntryUnlockError Event
30
+ // ============================================================================
31
+
32
+ export class EntryUnlockErrorEvent extends DomainEvent {
33
+ eventType = "RecordLocking/Entry/UnlockError";
34
+ getHandlerAbstraction() {
35
+ return EntryUnlockErrorEventHandler;
36
+ }
37
+ }
38
+ export const EntryUnlockErrorEventHandler = createAbstraction("EntryUnlockErrorEventHandler");
39
+
40
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createAbstraction","DomainEvent","EntryBeforeUnlockEvent","eventType","getHandlerAbstraction","EntryBeforeUnlockEventHandler","EntryAfterUnlockEvent","EntryAfterUnlockEventHandler","EntryUnlockErrorEvent","EntryUnlockErrorEventHandler"],"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// EntryBeforeUnlock Event\n// ============================================================================\n\nexport interface EntryBeforeUnlockPayload {\n id: string;\n type: LockRecordEntryType;\n force?: boolean;\n}\n\nexport class EntryBeforeUnlockEvent extends DomainEvent<EntryBeforeUnlockPayload> {\n eventType = \"RecordLocking/Entry/BeforeUnlock\" as const;\n\n getHandlerAbstraction() {\n return EntryBeforeUnlockEventHandler;\n }\n}\n\nexport const EntryBeforeUnlockEventHandler = createAbstraction<\n IEventHandler<EntryBeforeUnlockEvent>\n>(\"EntryBeforeUnlockEventHandler\");\n\nexport namespace EntryBeforeUnlockEventHandler {\n export type Interface = IEventHandler<EntryBeforeUnlockEvent>;\n export type Event = EntryBeforeUnlockEvent;\n}\n\n// ============================================================================\n// EntryAfterUnlock Event\n// ============================================================================\n\nexport interface EntryAfterUnlockPayload {\n id: string;\n type: LockRecordEntryType;\n record: ILockRecord;\n}\n\nexport class EntryAfterUnlockEvent extends DomainEvent<EntryAfterUnlockPayload> {\n eventType = \"RecordLocking/Entry/AfterUnlock\" as const;\n\n getHandlerAbstraction() {\n return EntryAfterUnlockEventHandler;\n }\n}\n\nexport const EntryAfterUnlockEventHandler = createAbstraction<IEventHandler<EntryAfterUnlockEvent>>(\n \"EntryAfterUnlockEventHandler\"\n);\n\nexport namespace EntryAfterUnlockEventHandler {\n export type Interface = IEventHandler<EntryAfterUnlockEvent>;\n export type Event = EntryAfterUnlockEvent;\n}\n\n// ============================================================================\n// EntryUnlockError Event\n// ============================================================================\n\nexport interface EntryUnlockErrorPayload {\n id: string;\n type: LockRecordEntryType;\n error: Error;\n}\n\nexport class EntryUnlockErrorEvent extends DomainEvent<EntryUnlockErrorPayload> {\n eventType = \"RecordLocking/Entry/UnlockError\" as const;\n\n getHandlerAbstraction() {\n return EntryUnlockErrorEventHandler;\n }\n}\n\nexport const EntryUnlockErrorEventHandler = createAbstraction<IEventHandler<EntryUnlockErrorEvent>>(\n \"EntryUnlockErrorEventHandler\"\n);\n\nexport namespace EntryUnlockErrorEventHandler {\n export type Interface = IEventHandler<EntryUnlockErrorEvent>;\n export type Event = EntryUnlockErrorEvent;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW,QAAQ,mDAAmD;;AAK/E;AACA;AACA;;AAQA,OAAO,MAAMC,sBAAsB,SAASD,WAAW,CAA2B;EAC9EE,SAAS,GAAG,kCAAkC;EAE9CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,6BAA6B;EACxC;AACJ;AAEA,OAAO,MAAMA,6BAA6B,GAAGL,iBAAiB,CAE5D,+BAA+B,CAAC;;AAOlC;AACA;AACA;;AAQA,OAAO,MAAMM,qBAAqB,SAASL,WAAW,CAA0B;EAC5EE,SAAS,GAAG,iCAAiC;EAE7CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,4BAA4B;EACvC;AACJ;AAEA,OAAO,MAAMA,4BAA4B,GAAGP,iBAAiB,CACzD,8BACJ,CAAC;;AAOD;AACA;AACA;;AAQA,OAAO,MAAMQ,qBAAqB,SAASP,WAAW,CAA0B;EAC5EE,SAAS,GAAG,iCAAiC;EAE7CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOK,4BAA4B;EACvC;AACJ;AAEA,OAAO,MAAMA,4BAA4B,GAAGT,iBAAiB,CACzD,8BACJ,CAAC","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ export declare const UnlockEntryFeature: {
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 { UnlockEntryUseCase } from "./UnlockEntryUseCase.js";
3
+ import { UnlockEntryRepository } from "./UnlockEntryRepository.js";
4
+ import { UnlockEntryEventsDecorator } from "./UnlockEntryEventsDecorator.js";
5
+ export const UnlockEntryFeature = createFeature({
6
+ name: "UnlockEntry",
7
+ register(container) {
8
+ container.register(UnlockEntryUseCase);
9
+ container.register(UnlockEntryRepository).inSingletonScope();
10
+ container.registerDecorator(UnlockEntryEventsDecorator);
11
+ }
12
+ });
13
+
14
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createFeature","UnlockEntryUseCase","UnlockEntryRepository","UnlockEntryEventsDecorator","UnlockEntryFeature","name","register","container","inSingletonScope","registerDecorator"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { UnlockEntryUseCase } from \"./UnlockEntryUseCase.js\";\nimport { UnlockEntryRepository } from \"./UnlockEntryRepository.js\";\nimport { UnlockEntryEventsDecorator } from \"./UnlockEntryEventsDecorator.js\";\n\nexport const UnlockEntryFeature = createFeature({\n name: \"UnlockEntry\",\n register(container) {\n container.register(UnlockEntryUseCase);\n container.register(UnlockEntryRepository).inSingletonScope();\n container.registerDecorator(UnlockEntryEventsDecorator);\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,kBAAkB;AAC3B,SAASC,qBAAqB;AAC9B,SAASC,0BAA0B;AAEnC,OAAO,MAAMC,kBAAkB,GAAGJ,aAAa,CAAC;EAC5CK,IAAI,EAAE,aAAa;EACnBC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACL,kBAAkB,CAAC;IACtCM,SAAS,CAACD,QAAQ,CAACJ,qBAAqB,CAAC,CAACM,gBAAgB,CAAC,CAAC;IAC5DD,SAAS,CAACE,iBAAiB,CAACN,0BAA0B,CAAC;EAC3D;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import type { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
2
+ export declare const hasFullAccessPermission: (identityContext: IdentityContext.Interface) => Promise<boolean>;
@@ -0,0 +1,10 @@
1
+ export const hasFullAccessPermission = async identityContext => {
2
+ const hasFullAccess = await identityContext.hasFullAccess();
3
+ if (hasFullAccess) {
4
+ return true;
5
+ }
6
+ const permission = await identityContext.getPermission("recordLocking");
7
+ return permission?.canForceUnlock === true;
8
+ };
9
+
10
+ //# sourceMappingURL=hasFullAccessPermission.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["hasFullAccessPermission","identityContext","hasFullAccess","permission","getPermission","canForceUnlock"],"sources":["hasFullAccessPermission.ts"],"sourcesContent":["import type { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type { SecurityPermission } from \"@webiny/api-core/types/security.js\";\n\ninterface RecordLockingSecurityPermission extends SecurityPermission {\n canForceUnlock?: boolean;\n}\n\nexport const hasFullAccessPermission = async (\n identityContext: IdentityContext.Interface\n): Promise<boolean> => {\n const hasFullAccess = await identityContext.hasFullAccess();\n if (hasFullAccess) {\n return true;\n }\n\n const permission =\n await identityContext.getPermission<RecordLockingSecurityPermission>(\"recordLocking\");\n return permission?.canForceUnlock === true;\n};\n"],"mappings":"AAOA,OAAO,MAAMA,uBAAuB,GAAG,MACnCC,eAA0C,IACvB;EACnB,MAAMC,aAAa,GAAG,MAAMD,eAAe,CAACC,aAAa,CAAC,CAAC;EAC3D,IAAIA,aAAa,EAAE;IACf,OAAO,IAAI;EACf;EAEA,MAAMC,UAAU,GACZ,MAAMF,eAAe,CAACG,aAAa,CAAkC,eAAe,CAAC;EACzF,OAAOD,UAAU,EAAEE,cAAc,KAAK,IAAI;AAC9C,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,14 @@
1
+ import { type UnlockEntryRequestInput, UnlockEntryRequestUseCase as UseCaseAbstraction, UnlockEntryRequestUseCase } 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 UnlockEntryRequestEventsDecoratorImpl implements UnlockEntryRequestUseCase.Interface {
6
+ private readonly eventPublisher;
7
+ private readonly decoratee;
8
+ constructor(eventPublisher: EventPublisher.Interface, decoratee: UnlockEntryRequestUseCase.Interface);
9
+ execute(input: UnlockEntryRequestInput): Promise<Result<ILockRecord, UseCaseAbstraction.Error>>;
10
+ }
11
+ export declare const UnlockEntryRequestEventsDecorator: typeof UnlockEntryRequestEventsDecoratorImpl & {
12
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IUnlockEntryRequestUseCase>;
13
+ };
14
+ export {};
@@ -0,0 +1,40 @@
1
+ import { UnlockEntryRequestUseCase } from "./abstractions.js";
2
+ import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
3
+ import { EntryAfterUnlockRequestEvent, EntryBeforeUnlockRequestEvent, EntryUnlockRequestErrorEvent } from "./events.js";
4
+ class UnlockEntryRequestEventsDecoratorImpl {
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 EntryBeforeUnlockRequestEvent({
12
+ id: input.id,
13
+ type: input.type
14
+ }));
15
+ const result = await this.decoratee.execute(input);
16
+ if (result.isFail()) {
17
+ const error = result.error;
18
+ await this.eventPublisher.publish(new EntryUnlockRequestErrorEvent({
19
+ id: input.id,
20
+ type: input.type,
21
+ error
22
+ }));
23
+ return result;
24
+ }
25
+
26
+ // Publish after event
27
+ await this.eventPublisher.publish(new EntryAfterUnlockRequestEvent({
28
+ id: input.id,
29
+ type: input.type,
30
+ record: result.value
31
+ }));
32
+ return result;
33
+ }
34
+ }
35
+ export const UnlockEntryRequestEventsDecorator = UnlockEntryRequestUseCase.createDecorator({
36
+ decorator: UnlockEntryRequestEventsDecoratorImpl,
37
+ dependencies: [EventPublisher]
38
+ });
39
+
40
+ //# sourceMappingURL=UnlockEntryRequestEventsDecorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["UnlockEntryRequestUseCase","EventPublisher","EntryAfterUnlockRequestEvent","EntryBeforeUnlockRequestEvent","EntryUnlockRequestErrorEvent","UnlockEntryRequestEventsDecoratorImpl","constructor","eventPublisher","decoratee","execute","input","publish","id","type","result","isFail","error","record","value","UnlockEntryRequestEventsDecorator","createDecorator","decorator","dependencies"],"sources":["UnlockEntryRequestEventsDecorator.ts"],"sourcesContent":["import {\n type UnlockEntryRequestInput,\n UnlockEntryRequestUseCase as UseCaseAbstraction,\n UnlockEntryRequestUseCase\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 {\n EntryAfterUnlockRequestEvent,\n EntryBeforeUnlockRequestEvent,\n EntryUnlockRequestErrorEvent\n} from \"./events.js\";\n\nclass UnlockEntryRequestEventsDecoratorImpl implements UnlockEntryRequestUseCase.Interface {\n constructor(\n private readonly eventPublisher: EventPublisher.Interface,\n private readonly decoratee: UnlockEntryRequestUseCase.Interface\n ) {}\n\n async execute(\n input: UnlockEntryRequestInput\n ): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Publish before event\n await this.eventPublisher.publish(\n new EntryBeforeUnlockRequestEvent({\n id: input.id,\n type: input.type\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 EntryUnlockRequestErrorEvent({\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 EntryAfterUnlockRequestEvent({\n id: input.id,\n type: input.type,\n record: result.value\n })\n );\n\n return result;\n }\n}\n\nexport const UnlockEntryRequestEventsDecorator = UnlockEntryRequestUseCase.createDecorator({\n decorator: UnlockEntryRequestEventsDecoratorImpl,\n dependencies: [EventPublisher]\n});\n"],"mappings":"AAAA,SAGIA,yBAAyB;AAE7B,SAASC,cAAc,QAAQ,mDAAmD;AAGlF,SACIC,4BAA4B,EAC5BC,6BAA6B,EAC7BC,4BAA4B;AAGhC,MAAMC,qCAAqC,CAAgD;EACvFC,WAAWA,CACUC,cAAwC,EACxCC,SAA8C,EACjE;IAAA,KAFmBD,cAAwC,GAAxCA,cAAwC;IAAA,KACxCC,SAA8C,GAA9CA,SAA8C;EAChE;EAEH,MAAMC,OAAOA,CACTC,KAA8B,EACwB;IACtD;IACA,MAAM,IAAI,CAACH,cAAc,CAACI,OAAO,CAC7B,IAAIR,6BAA6B,CAAC;MAC9BS,EAAE,EAAEF,KAAK,CAACE,EAAE;MACZC,IAAI,EAAEH,KAAK,CAACG;IAChB,CAAC,CACL,CAAC;IAED,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACN,SAAS,CAACC,OAAO,CAACC,KAAK,CAAC;IAElD,IAAII,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;MACjB,MAAMC,KAAK,GAAGF,MAAM,CAACE,KAAK;MAE1B,MAAM,IAAI,CAACT,cAAc,CAACI,OAAO,CAC7B,IAAIP,4BAA4B,CAAC;QAC7BQ,EAAE,EAAEF,KAAK,CAACE,EAAE;QACZC,IAAI,EAAEH,KAAK,CAACG,IAAI;QAChBG;MACJ,CAAC,CACL,CAAC;MAED,OAAOF,MAAM;IACjB;;IAEA;IACA,MAAM,IAAI,CAACP,cAAc,CAACI,OAAO,CAC7B,IAAIT,4BAA4B,CAAC;MAC7BU,EAAE,EAAEF,KAAK,CAACE,EAAE;MACZC,IAAI,EAAEH,KAAK,CAACG,IAAI;MAChBI,MAAM,EAAEH,MAAM,CAACI;IACnB,CAAC,CACL,CAAC;IAED,OAAOJ,MAAM;EACjB;AACJ;AAEA,OAAO,MAAMK,iCAAiC,GAAGnB,yBAAyB,CAACoB,eAAe,CAAC;EACvFC,SAAS,EAAEhB,qCAAqC;EAChDiB,YAAY,EAAE,CAACrB,cAAc;AACjC,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,17 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { UnlockEntryRequestRepository as RepositoryAbstraction } from "./abstractions.js";
3
+ import { UpdateEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UpdateEntry";
4
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
5
+ import type { ILockRecord } from "../../domain/LockRecord.js";
6
+ import type { CmsModel } from "@webiny/api-headless-cms/types";
7
+ declare class UnlockEntryRequestRepositoryImpl implements RepositoryAbstraction.Interface {
8
+ private updateEntry;
9
+ private identityContext;
10
+ private model;
11
+ constructor(updateEntry: UpdateEntryUseCase.Interface, identityContext: IdentityContext.Interface, model: CmsModel);
12
+ update(record: ILockRecord): Promise<Result<ILockRecord, RepositoryAbstraction.Error>>;
13
+ }
14
+ export declare const UnlockEntryRequestRepository: typeof UnlockEntryRequestRepositoryImpl & {
15
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IUnlockEntryRequestRepository>;
16
+ };
17
+ export {};
@@ -0,0 +1,43 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { UnlockEntryRequestRepository as RepositoryAbstraction } from "./abstractions.js";
3
+ import { UpdateEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UpdateEntry";
4
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
5
+ import { RecordLockingModel } from "../../domain/abstractions.js";
6
+ import { UnlockEntryRequestError } from "../../domain/errors.js";
7
+ import { createLockRecordDatabaseId } from "../../utils/lockRecordDatabaseId.js";
8
+ import { createIdentifier } from "@webiny/utils";
9
+ class UnlockEntryRequestRepositoryImpl {
10
+ constructor(updateEntry, identityContext, model) {
11
+ this.updateEntry = updateEntry;
12
+ this.identityContext = identityContext;
13
+ this.model = model;
14
+ }
15
+ async update(record) {
16
+ try {
17
+ const entryId = createLockRecordDatabaseId(record.id);
18
+ const id = createIdentifier({
19
+ id: entryId,
20
+ version: 1
21
+ });
22
+ const recordValues = record.toObject();
23
+ const result = await this.identityContext.withoutAuthorization(async () => {
24
+ return await this.updateEntry.execute(this.model, id, {
25
+ ...recordValues,
26
+ values: recordValues
27
+ });
28
+ });
29
+ if (result.isFail()) {
30
+ return Result.fail(new UnlockEntryRequestError(result.error));
31
+ }
32
+ return Result.ok(record);
33
+ } catch (error) {
34
+ return Result.fail(new UnlockEntryRequestError(error));
35
+ }
36
+ }
37
+ }
38
+ export const UnlockEntryRequestRepository = RepositoryAbstraction.createImplementation({
39
+ implementation: UnlockEntryRequestRepositoryImpl,
40
+ dependencies: [UpdateEntryUseCase, IdentityContext, RecordLockingModel]
41
+ });
42
+
43
+ //# sourceMappingURL=UnlockEntryRequestRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Result","UnlockEntryRequestRepository","RepositoryAbstraction","UpdateEntryUseCase","IdentityContext","RecordLockingModel","UnlockEntryRequestError","createLockRecordDatabaseId","createIdentifier","UnlockEntryRequestRepositoryImpl","constructor","updateEntry","identityContext","model","update","record","entryId","id","version","recordValues","toObject","result","withoutAuthorization","execute","values","isFail","fail","error","ok","createImplementation","implementation","dependencies"],"sources":["UnlockEntryRequestRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UnlockEntryRequestRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { UpdateEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UpdateEntry\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { RecordLockingModel } from \"~/domain/abstractions.js\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { UnlockEntryRequestError } from \"~/domain/errors.js\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId.js\";\nimport { createIdentifier } from \"@webiny/utils\";\n\nclass UnlockEntryRequestRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private updateEntry: UpdateEntryUseCase.Interface,\n private identityContext: IdentityContext.Interface,\n private model: CmsModel\n ) {}\n\n async update(record: ILockRecord): Promise<Result<ILockRecord, RepositoryAbstraction.Error>> {\n try {\n const entryId = createLockRecordDatabaseId(record.id);\n const id = createIdentifier({\n id: entryId,\n version: 1\n });\n\n const recordValues = record.toObject();\n const result = await this.identityContext.withoutAuthorization(async () => {\n return await this.updateEntry.execute(this.model, id, {\n ...recordValues,\n values: recordValues\n });\n });\n\n if (result.isFail()) {\n return Result.fail(new UnlockEntryRequestError(result.error));\n }\n\n return Result.ok(record);\n } catch (error) {\n return Result.fail(new UnlockEntryRequestError(error as Error));\n }\n }\n}\n\nexport const UnlockEntryRequestRepository = RepositoryAbstraction.createImplementation({\n implementation: UnlockEntryRequestRepositoryImpl,\n dependencies: [UpdateEntryUseCase, IdentityContext, RecordLockingModel]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,4BAA4B,IAAIC,qBAAqB;AAC9D,SAASC,kBAAkB,QAAQ,4DAA4D;AAC/F,SAASC,eAAe,QAAQ,6DAA6D;AAC7F,SAASC,kBAAkB;AAG3B,SAASC,uBAAuB;AAChC,SAASC,0BAA0B;AACnC,SAASC,gBAAgB,QAAQ,eAAe;AAEhD,MAAMC,gCAAgC,CAA4C;EAC9EC,WAAWA,CACCC,WAAyC,EACzCC,eAA0C,EAC1CC,KAAe,EACzB;IAAA,KAHUF,WAAyC,GAAzCA,WAAyC;IAAA,KACzCC,eAA0C,GAA1CA,eAA0C;IAAA,KAC1CC,KAAe,GAAfA,KAAe;EACxB;EAEH,MAAMC,MAAMA,CAACC,MAAmB,EAA6D;IACzF,IAAI;MACA,MAAMC,OAAO,GAAGT,0BAA0B,CAACQ,MAAM,CAACE,EAAE,CAAC;MACrD,MAAMA,EAAE,GAAGT,gBAAgB,CAAC;QACxBS,EAAE,EAAED,OAAO;QACXE,OAAO,EAAE;MACb,CAAC,CAAC;MAEF,MAAMC,YAAY,GAAGJ,MAAM,CAACK,QAAQ,CAAC,CAAC;MACtC,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACT,eAAe,CAACU,oBAAoB,CAAC,YAAY;QACvE,OAAO,MAAM,IAAI,CAACX,WAAW,CAACY,OAAO,CAAC,IAAI,CAACV,KAAK,EAAEI,EAAE,EAAE;UAClD,GAAGE,YAAY;UACfK,MAAM,EAAEL;QACZ,CAAC,CAAC;MACN,CAAC,CAAC;MAEF,IAAIE,MAAM,CAACI,MAAM,CAAC,CAAC,EAAE;QACjB,OAAOzB,MAAM,CAAC0B,IAAI,CAAC,IAAIpB,uBAAuB,CAACe,MAAM,CAACM,KAAK,CAAC,CAAC;MACjE;MAEA,OAAO3B,MAAM,CAAC4B,EAAE,CAACb,MAAM,CAAC;IAC5B,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,OAAO3B,MAAM,CAAC0B,IAAI,CAAC,IAAIpB,uBAAuB,CAACqB,KAAc,CAAC,CAAC;IACnE;EACJ;AACJ;AAEA,OAAO,MAAM1B,4BAA4B,GAAGC,qBAAqB,CAAC2B,oBAAoB,CAAC;EACnFC,cAAc,EAAErB,gCAAgC;EAChDsB,YAAY,EAAE,CAAC5B,kBAAkB,EAAEC,eAAe,EAAEC,kBAAkB;AAC1E,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,16 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { UnlockEntryRequestUseCase as UseCaseAbstraction, UnlockEntryRequestRepository, UnlockEntryRequestInput } from "./abstractions.js";
3
+ import { GetLockRecordUseCase } from "../GetLockRecord/abstractions.js";
4
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
5
+ import type { ILockRecord } from "../../domain/LockRecord.js";
6
+ declare class UnlockEntryRequestUseCaseImpl implements UseCaseAbstraction.Interface {
7
+ private getLockRecord;
8
+ private repository;
9
+ private identityContext;
10
+ constructor(getLockRecord: GetLockRecordUseCase.Interface, repository: UnlockEntryRequestRepository.Interface, identityContext: IdentityContext.Interface);
11
+ execute(input: UnlockEntryRequestInput): Promise<Result<ILockRecord, UseCaseAbstraction.Error>>;
12
+ }
13
+ export declare const UnlockEntryRequestUseCase: typeof UnlockEntryRequestUseCaseImpl & {
14
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IUnlockEntryRequestUseCase>;
15
+ };
16
+ export {};
@@ -0,0 +1,92 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { UnlockEntryRequestUseCase as UseCaseAbstraction, UnlockEntryRequestRepository } from "./abstractions.js";
3
+ import { GetLockRecordUseCase } from "../GetLockRecord/abstractions.js";
4
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
5
+ import { EntryNotLockedError, UnlockRequestAlreadySentError, LockRecordNotFoundError, LockRecordPersistenceError } from "../../domain/errors.js";
6
+ import { RecordLockingLockRecordActionType } from "../../domain/types.js";
7
+ class UnlockEntryRequestUseCaseImpl {
8
+ constructor(getLockRecord, repository, identityContext) {
9
+ this.getLockRecord = getLockRecord;
10
+ this.repository = repository;
11
+ this.identityContext = identityContext;
12
+ }
13
+ async execute(input) {
14
+ // Get the lock record
15
+ const recordResult = await this.getLockRecord.execute(input);
16
+
17
+ // If not found, it means entry is not locked
18
+ if (recordResult.isFail()) {
19
+ if (recordResult.error instanceof LockRecordNotFoundError) {
20
+ const error = new EntryNotLockedError({
21
+ id: input.id,
22
+ type: input.type
23
+ });
24
+ return Result.fail(error);
25
+ }
26
+ // Other errors
27
+ return Result.fail(new LockRecordPersistenceError(recordResult.error));
28
+ }
29
+ const record = recordResult.value;
30
+
31
+ // If expired, entry is not locked
32
+ if (record.isExpired()) {
33
+ const error = new EntryNotLockedError({
34
+ id: input.id,
35
+ type: input.type
36
+ });
37
+ return Result.fail(error);
38
+ }
39
+
40
+ // Check if unlock request already exists
41
+ const unlockRequested = record.getUnlockRequested();
42
+ if (unlockRequested) {
43
+ const currentIdentity = this.identityContext.getIdentity();
44
+
45
+ // If a different user already requested unlock, deny
46
+ if (unlockRequested.createdBy.id !== currentIdentity.id) {
47
+ const error = new UnlockRequestAlreadySentError({
48
+ id: input.id,
49
+ type: input.type,
50
+ identityId: unlockRequested.createdBy.id
51
+ });
52
+ return Result.fail(error);
53
+ }
54
+
55
+ // If same user but already approved or denied, return the record
56
+ const approved = record.getUnlockApproved();
57
+ const denied = record.getUnlockDenied();
58
+ if (approved || denied) {
59
+ return Result.ok(record);
60
+ }
61
+
62
+ // If same user and pending, treat as duplicate
63
+ const error = new UnlockRequestAlreadySentError({
64
+ id: input.id,
65
+ type: input.type,
66
+ identityId: unlockRequested.createdBy.id
67
+ });
68
+ return Result.fail(error);
69
+ }
70
+
71
+ // Add unlock request action
72
+ const identity = this.identityContext.getIdentity();
73
+ record.addAction({
74
+ type: RecordLockingLockRecordActionType.requested,
75
+ createdOn: new Date(),
76
+ createdBy: identity
77
+ });
78
+
79
+ // Update the record
80
+ const updateResult = await this.repository.update(record);
81
+ if (updateResult.isFail()) {
82
+ return Result.fail(updateResult.error);
83
+ }
84
+ return Result.ok(record);
85
+ }
86
+ }
87
+ export const UnlockEntryRequestUseCase = UseCaseAbstraction.createImplementation({
88
+ implementation: UnlockEntryRequestUseCaseImpl,
89
+ dependencies: [GetLockRecordUseCase, UnlockEntryRequestRepository, IdentityContext]
90
+ });
91
+
92
+ //# sourceMappingURL=UnlockEntryRequestUseCase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Result","UnlockEntryRequestUseCase","UseCaseAbstraction","UnlockEntryRequestRepository","GetLockRecordUseCase","IdentityContext","EntryNotLockedError","UnlockRequestAlreadySentError","LockRecordNotFoundError","LockRecordPersistenceError","RecordLockingLockRecordActionType","UnlockEntryRequestUseCaseImpl","constructor","getLockRecord","repository","identityContext","execute","input","recordResult","isFail","error","id","type","fail","record","value","isExpired","unlockRequested","getUnlockRequested","currentIdentity","getIdentity","createdBy","identityId","approved","getUnlockApproved","denied","getUnlockDenied","ok","identity","addAction","requested","createdOn","Date","updateResult","update","createImplementation","implementation","dependencies"],"sources":["UnlockEntryRequestUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n UnlockEntryRequestUseCase as UseCaseAbstraction,\n UnlockEntryRequestRepository,\n UnlockEntryRequestInput\n} from \"./abstractions.js\";\nimport { GetLockRecordUseCase } from \"../GetLockRecord/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport {\n EntryNotLockedError,\n UnlockRequestAlreadySentError,\n LockRecordNotFoundError,\n LockRecordPersistenceError\n} from \"~/domain/errors.js\";\nimport { RecordLockingLockRecordActionType } from \"~/domain/types.js\";\n\nclass UnlockEntryRequestUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getLockRecord: GetLockRecordUseCase.Interface,\n private repository: UnlockEntryRequestRepository.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute(\n input: UnlockEntryRequestInput\n ): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Get the lock record\n const recordResult = await this.getLockRecord.execute(input);\n\n // If not found, it means entry is not locked\n if (recordResult.isFail()) {\n if (recordResult.error instanceof LockRecordNotFoundError) {\n const error = new EntryNotLockedError({ id: input.id, type: input.type });\n return Result.fail(error);\n }\n // Other errors\n return Result.fail(new LockRecordPersistenceError(recordResult.error));\n }\n\n const record = recordResult.value;\n\n // If expired, entry is not locked\n if (record.isExpired()) {\n const error = new EntryNotLockedError({ id: input.id, type: input.type });\n return Result.fail(error);\n }\n\n // Check if unlock request already exists\n const unlockRequested = record.getUnlockRequested();\n if (unlockRequested) {\n const currentIdentity = this.identityContext.getIdentity();\n\n // If a different user already requested unlock, deny\n if (unlockRequested.createdBy.id !== currentIdentity.id) {\n const error = new UnlockRequestAlreadySentError({\n id: input.id,\n type: input.type,\n identityId: unlockRequested.createdBy.id\n });\n return Result.fail(error);\n }\n\n // If same user but already approved or denied, return the record\n const approved = record.getUnlockApproved();\n const denied = record.getUnlockDenied();\n if (approved || denied) {\n return Result.ok(record);\n }\n\n // If same user and pending, treat as duplicate\n const error = new UnlockRequestAlreadySentError({\n id: input.id,\n type: input.type,\n identityId: unlockRequested.createdBy.id\n });\n return Result.fail(error);\n }\n\n // Add unlock request action\n const identity = this.identityContext.getIdentity();\n record.addAction({\n type: RecordLockingLockRecordActionType.requested,\n createdOn: new Date(),\n createdBy: identity\n });\n\n // Update the record\n const updateResult = await this.repository.update(record);\n\n if (updateResult.isFail()) {\n return Result.fail(updateResult.error);\n }\n\n return Result.ok(record);\n }\n}\n\nexport const UnlockEntryRequestUseCase = UseCaseAbstraction.createImplementation({\n implementation: UnlockEntryRequestUseCaseImpl,\n dependencies: [GetLockRecordUseCase, UnlockEntryRequestRepository, IdentityContext]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SACIC,yBAAyB,IAAIC,kBAAkB,EAC/CC,4BAA4B;AAGhC,SAASC,oBAAoB;AAC7B,SAASC,eAAe,QAAQ,6DAA6D;AAE7F,SACIC,mBAAmB,EACnBC,6BAA6B,EAC7BC,uBAAuB,EACvBC,0BAA0B;AAE9B,SAASC,iCAAiC;AAE1C,MAAMC,6BAA6B,CAAyC;EACxEC,WAAWA,CACCC,aAA6C,EAC7CC,UAAkD,EAClDC,eAA0C,EACpD;IAAA,KAHUF,aAA6C,GAA7CA,aAA6C;IAAA,KAC7CC,UAAkD,GAAlDA,UAAkD;IAAA,KAClDC,eAA0C,GAA1CA,eAA0C;EACnD;EAEH,MAAMC,OAAOA,CACTC,KAA8B,EACwB;IACtD;IACA,MAAMC,YAAY,GAAG,MAAM,IAAI,CAACL,aAAa,CAACG,OAAO,CAACC,KAAK,CAAC;;IAE5D;IACA,IAAIC,YAAY,CAACC,MAAM,CAAC,CAAC,EAAE;MACvB,IAAID,YAAY,CAACE,KAAK,YAAYZ,uBAAuB,EAAE;QACvD,MAAMY,KAAK,GAAG,IAAId,mBAAmB,CAAC;UAAEe,EAAE,EAAEJ,KAAK,CAACI,EAAE;UAAEC,IAAI,EAAEL,KAAK,CAACK;QAAK,CAAC,CAAC;QACzE,OAAOtB,MAAM,CAACuB,IAAI,CAACH,KAAK,CAAC;MAC7B;MACA;MACA,OAAOpB,MAAM,CAACuB,IAAI,CAAC,IAAId,0BAA0B,CAACS,YAAY,CAACE,KAAK,CAAC,CAAC;IAC1E;IAEA,MAAMI,MAAM,GAAGN,YAAY,CAACO,KAAK;;IAEjC;IACA,IAAID,MAAM,CAACE,SAAS,CAAC,CAAC,EAAE;MACpB,MAAMN,KAAK,GAAG,IAAId,mBAAmB,CAAC;QAAEe,EAAE,EAAEJ,KAAK,CAACI,EAAE;QAAEC,IAAI,EAAEL,KAAK,CAACK;MAAK,CAAC,CAAC;MACzE,OAAOtB,MAAM,CAACuB,IAAI,CAACH,KAAK,CAAC;IAC7B;;IAEA;IACA,MAAMO,eAAe,GAAGH,MAAM,CAACI,kBAAkB,CAAC,CAAC;IACnD,IAAID,eAAe,EAAE;MACjB,MAAME,eAAe,GAAG,IAAI,CAACd,eAAe,CAACe,WAAW,CAAC,CAAC;;MAE1D;MACA,IAAIH,eAAe,CAACI,SAAS,CAACV,EAAE,KAAKQ,eAAe,CAACR,EAAE,EAAE;QACrD,MAAMD,KAAK,GAAG,IAAIb,6BAA6B,CAAC;UAC5Cc,EAAE,EAAEJ,KAAK,CAACI,EAAE;UACZC,IAAI,EAAEL,KAAK,CAACK,IAAI;UAChBU,UAAU,EAAEL,eAAe,CAACI,SAAS,CAACV;QAC1C,CAAC,CAAC;QACF,OAAOrB,MAAM,CAACuB,IAAI,CAACH,KAAK,CAAC;MAC7B;;MAEA;MACA,MAAMa,QAAQ,GAAGT,MAAM,CAACU,iBAAiB,CAAC,CAAC;MAC3C,MAAMC,MAAM,GAAGX,MAAM,CAACY,eAAe,CAAC,CAAC;MACvC,IAAIH,QAAQ,IAAIE,MAAM,EAAE;QACpB,OAAOnC,MAAM,CAACqC,EAAE,CAACb,MAAM,CAAC;MAC5B;;MAEA;MACA,MAAMJ,KAAK,GAAG,IAAIb,6BAA6B,CAAC;QAC5Cc,EAAE,EAAEJ,KAAK,CAACI,EAAE;QACZC,IAAI,EAAEL,KAAK,CAACK,IAAI;QAChBU,UAAU,EAAEL,eAAe,CAACI,SAAS,CAACV;MAC1C,CAAC,CAAC;MACF,OAAOrB,MAAM,CAACuB,IAAI,CAACH,KAAK,CAAC;IAC7B;;IAEA;IACA,MAAMkB,QAAQ,GAAG,IAAI,CAACvB,eAAe,CAACe,WAAW,CAAC,CAAC;IACnDN,MAAM,CAACe,SAAS,CAAC;MACbjB,IAAI,EAAEZ,iCAAiC,CAAC8B,SAAS;MACjDC,SAAS,EAAE,IAAIC,IAAI,CAAC,CAAC;MACrBX,SAAS,EAAEO;IACf,CAAC,CAAC;;IAEF;IACA,MAAMK,YAAY,GAAG,MAAM,IAAI,CAAC7B,UAAU,CAAC8B,MAAM,CAACpB,MAAM,CAAC;IAEzD,IAAImB,YAAY,CAACxB,MAAM,CAAC,CAAC,EAAE;MACvB,OAAOnB,MAAM,CAACuB,IAAI,CAACoB,YAAY,CAACvB,KAAK,CAAC;IAC1C;IAEA,OAAOpB,MAAM,CAACqC,EAAE,CAACb,MAAM,CAAC;EAC5B;AACJ;AAEA,OAAO,MAAMvB,yBAAyB,GAAGC,kBAAkB,CAAC2C,oBAAoB,CAAC;EAC7EC,cAAc,EAAEnC,6BAA6B;EAC7CoC,YAAY,EAAE,CAAC3C,oBAAoB,EAAED,4BAA4B,EAAEE,eAAe;AACtF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,42 @@
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 { EntryNotLockedError, UnlockRequestAlreadySentError, UnlockEntryRequestError, LockRecordPersistenceError } from "../../domain/errors.js";
5
+ export interface UnlockEntryRequestInput {
6
+ id: string;
7
+ type: LockRecordEntryType;
8
+ }
9
+ /**
10
+ * UnlockEntryRequest Use Case - Adds unlock request to lock record
11
+ */
12
+ export interface IUnlockEntryRequestUseCase {
13
+ execute(input: UnlockEntryRequestInput): Promise<Result<ILockRecord, UseCaseError>>;
14
+ }
15
+ export interface IUnlockEntryRequestUseCaseErrors {
16
+ notLocked: EntryNotLockedError;
17
+ alreadySent: UnlockRequestAlreadySentError;
18
+ persistence: LockRecordPersistenceError;
19
+ requestError: UnlockEntryRequestError;
20
+ }
21
+ type UseCaseError = IUnlockEntryRequestUseCaseErrors[keyof IUnlockEntryRequestUseCaseErrors];
22
+ export declare const UnlockEntryRequestUseCase: import("@webiny/di").Abstraction<IUnlockEntryRequestUseCase>;
23
+ export declare namespace UnlockEntryRequestUseCase {
24
+ type Interface = IUnlockEntryRequestUseCase;
25
+ type Error = UseCaseError;
26
+ }
27
+ /**
28
+ * UnlockEntryRequestRepository - Updates lock record with unlock request
29
+ */
30
+ export interface IUnlockEntryRequestRepository {
31
+ update(record: ILockRecord): Promise<Result<ILockRecord, RepositoryError>>;
32
+ }
33
+ export interface IUnlockEntryRequestRepositoryErrors {
34
+ persistence: UnlockEntryRequestError;
35
+ }
36
+ type RepositoryError = IUnlockEntryRequestRepositoryErrors[keyof IUnlockEntryRequestRepositoryErrors];
37
+ export declare const UnlockEntryRequestRepository: import("@webiny/di").Abstraction<IUnlockEntryRequestRepository>;
38
+ export declare namespace UnlockEntryRequestRepository {
39
+ type Interface = IUnlockEntryRequestRepository;
40
+ type Error = RepositoryError;
41
+ }
42
+ export {};
@@ -0,0 +1,17 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+
3
+ // Input type
4
+
5
+ /**
6
+ * UnlockEntryRequest Use Case - Adds unlock request to lock record
7
+ */
8
+
9
+ export const UnlockEntryRequestUseCase = createAbstraction("UnlockEntryRequestUseCase");
10
+
11
+ /**
12
+ * UnlockEntryRequestRepository - Updates lock record with unlock request
13
+ */
14
+
15
+ export const UnlockEntryRequestRepository = createAbstraction("UnlockEntryRequestRepository");
16
+
17
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createAbstraction","UnlockEntryRequestUseCase","UnlockEntryRequestRepository"],"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 EntryNotLockedError,\n UnlockRequestAlreadySentError,\n UnlockEntryRequestError,\n LockRecordPersistenceError\n} from \"~/domain/errors.js\";\n\n// Input type\nexport interface UnlockEntryRequestInput {\n id: string;\n type: LockRecordEntryType;\n}\n\n/**\n * UnlockEntryRequest Use Case - Adds unlock request to lock record\n */\nexport interface IUnlockEntryRequestUseCase {\n execute(input: UnlockEntryRequestInput): Promise<Result<ILockRecord, UseCaseError>>;\n}\n\nexport interface IUnlockEntryRequestUseCaseErrors {\n notLocked: EntryNotLockedError;\n alreadySent: UnlockRequestAlreadySentError;\n persistence: LockRecordPersistenceError;\n requestError: UnlockEntryRequestError;\n}\n\ntype UseCaseError = IUnlockEntryRequestUseCaseErrors[keyof IUnlockEntryRequestUseCaseErrors];\n\nexport const UnlockEntryRequestUseCase = createAbstraction<IUnlockEntryRequestUseCase>(\n \"UnlockEntryRequestUseCase\"\n);\n\nexport namespace UnlockEntryRequestUseCase {\n export type Interface = IUnlockEntryRequestUseCase;\n export type Error = UseCaseError;\n}\n\n/**\n * UnlockEntryRequestRepository - Updates lock record with unlock request\n */\nexport interface IUnlockEntryRequestRepository {\n update(record: ILockRecord): Promise<Result<ILockRecord, RepositoryError>>;\n}\n\nexport interface IUnlockEntryRequestRepositoryErrors {\n persistence: UnlockEntryRequestError;\n}\n\ntype RepositoryError =\n IUnlockEntryRequestRepositoryErrors[keyof IUnlockEntryRequestRepositoryErrors];\n\nexport const UnlockEntryRequestRepository = createAbstraction<IUnlockEntryRequestRepository>(\n \"UnlockEntryRequestRepository\"\n);\n\nexport namespace UnlockEntryRequestRepository {\n export type Interface = IUnlockEntryRequestRepository;\n export type Error = RepositoryError;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAWvD;;AAMA;AACA;AACA;;AAcA,OAAO,MAAMC,yBAAyB,GAAGD,iBAAiB,CACtD,2BACJ,CAAC;;AAOD;AACA;AACA;;AAYA,OAAO,MAAME,4BAA4B,GAAGF,iBAAiB,CACzD,8BACJ,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 EntryBeforeUnlockRequestPayload {
6
+ id: string;
7
+ type: LockRecordEntryType;
8
+ }
9
+ export declare class EntryBeforeUnlockRequestEvent extends DomainEvent<EntryBeforeUnlockRequestPayload> {
10
+ eventType: "RecordLocking/Entry/BeforeUnlockRequest";
11
+ getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryBeforeUnlockRequestEvent>>;
12
+ }
13
+ export declare const EntryBeforeUnlockRequestEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryBeforeUnlockRequestEvent>>;
14
+ export declare namespace EntryBeforeUnlockRequestEventHandler {
15
+ type Interface = IEventHandler<EntryBeforeUnlockRequestEvent>;
16
+ type Event = EntryBeforeUnlockRequestEvent;
17
+ }
18
+ export interface EntryAfterUnlockRequestPayload {
19
+ id: string;
20
+ type: LockRecordEntryType;
21
+ record: ILockRecord;
22
+ }
23
+ export declare class EntryAfterUnlockRequestEvent extends DomainEvent<EntryAfterUnlockRequestPayload> {
24
+ eventType: "RecordLocking/Entry/AfterUnlockRequest";
25
+ getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryAfterUnlockRequestEvent>>;
26
+ }
27
+ export declare const EntryAfterUnlockRequestEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryAfterUnlockRequestEvent>>;
28
+ export declare namespace EntryAfterUnlockRequestEventHandler {
29
+ type Interface = IEventHandler<EntryAfterUnlockRequestEvent>;
30
+ type Event = EntryAfterUnlockRequestEvent;
31
+ }
32
+ export interface EntryUnlockRequestErrorPayload {
33
+ id: string;
34
+ type: LockRecordEntryType;
35
+ error: Error;
36
+ }
37
+ export declare class EntryUnlockRequestErrorEvent extends DomainEvent<EntryUnlockRequestErrorPayload> {
38
+ eventType: "RecordLocking/Entry/UnlockRequestError";
39
+ getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryUnlockRequestErrorEvent>>;
40
+ }
41
+ export declare const EntryUnlockRequestErrorEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryUnlockRequestErrorEvent>>;
42
+ export declare namespace EntryUnlockRequestErrorEventHandler {
43
+ type Interface = IEventHandler<EntryUnlockRequestErrorEvent>;
44
+ type Event = EntryUnlockRequestErrorEvent;
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
+ // EntryBeforeUnlockRequest Event
6
+ // ============================================================================
7
+
8
+ export class EntryBeforeUnlockRequestEvent extends DomainEvent {
9
+ eventType = "RecordLocking/Entry/BeforeUnlockRequest";
10
+ getHandlerAbstraction() {
11
+ return EntryBeforeUnlockRequestEventHandler;
12
+ }
13
+ }
14
+ export const EntryBeforeUnlockRequestEventHandler = createAbstraction("EntryBeforeUnlockRequestEventHandler");
15
+
16
+ // ============================================================================
17
+ // EntryAfterUnlockRequest Event
18
+ // ============================================================================
19
+
20
+ export class EntryAfterUnlockRequestEvent extends DomainEvent {
21
+ eventType = "RecordLocking/Entry/AfterUnlockRequest";
22
+ getHandlerAbstraction() {
23
+ return EntryAfterUnlockRequestEventHandler;
24
+ }
25
+ }
26
+ export const EntryAfterUnlockRequestEventHandler = createAbstraction("EntryAfterUnlockRequestEventHandler");
27
+
28
+ // ============================================================================
29
+ // EntryUnlockRequestError Event
30
+ // ============================================================================
31
+
32
+ export class EntryUnlockRequestErrorEvent extends DomainEvent {
33
+ eventType = "RecordLocking/Entry/UnlockRequestError";
34
+ getHandlerAbstraction() {
35
+ return EntryUnlockRequestErrorEventHandler;
36
+ }
37
+ }
38
+ export const EntryUnlockRequestErrorEventHandler = createAbstraction("EntryUnlockRequestErrorEventHandler");
39
+
40
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createAbstraction","DomainEvent","EntryBeforeUnlockRequestEvent","eventType","getHandlerAbstraction","EntryBeforeUnlockRequestEventHandler","EntryAfterUnlockRequestEvent","EntryAfterUnlockRequestEventHandler","EntryUnlockRequestErrorEvent","EntryUnlockRequestErrorEventHandler"],"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// EntryBeforeUnlockRequest Event\n// ============================================================================\n\nexport interface EntryBeforeUnlockRequestPayload {\n id: string;\n type: LockRecordEntryType;\n}\n\nexport class EntryBeforeUnlockRequestEvent extends DomainEvent<EntryBeforeUnlockRequestPayload> {\n eventType = \"RecordLocking/Entry/BeforeUnlockRequest\" as const;\n\n getHandlerAbstraction() {\n return EntryBeforeUnlockRequestEventHandler;\n }\n}\n\nexport const EntryBeforeUnlockRequestEventHandler = createAbstraction<\n IEventHandler<EntryBeforeUnlockRequestEvent>\n>(\"EntryBeforeUnlockRequestEventHandler\");\n\nexport namespace EntryBeforeUnlockRequestEventHandler {\n export type Interface = IEventHandler<EntryBeforeUnlockRequestEvent>;\n export type Event = EntryBeforeUnlockRequestEvent;\n}\n\n// ============================================================================\n// EntryAfterUnlockRequest Event\n// ============================================================================\n\nexport interface EntryAfterUnlockRequestPayload {\n id: string;\n type: LockRecordEntryType;\n record: ILockRecord;\n}\n\nexport class EntryAfterUnlockRequestEvent extends DomainEvent<EntryAfterUnlockRequestPayload> {\n eventType = \"RecordLocking/Entry/AfterUnlockRequest\" as const;\n\n getHandlerAbstraction() {\n return EntryAfterUnlockRequestEventHandler;\n }\n}\n\nexport const EntryAfterUnlockRequestEventHandler = createAbstraction<\n IEventHandler<EntryAfterUnlockRequestEvent>\n>(\"EntryAfterUnlockRequestEventHandler\");\n\nexport namespace EntryAfterUnlockRequestEventHandler {\n export type Interface = IEventHandler<EntryAfterUnlockRequestEvent>;\n export type Event = EntryAfterUnlockRequestEvent;\n}\n\n// ============================================================================\n// EntryUnlockRequestError Event\n// ============================================================================\n\nexport interface EntryUnlockRequestErrorPayload {\n id: string;\n type: LockRecordEntryType;\n error: Error;\n}\n\nexport class EntryUnlockRequestErrorEvent extends DomainEvent<EntryUnlockRequestErrorPayload> {\n eventType = \"RecordLocking/Entry/UnlockRequestError\" as const;\n\n getHandlerAbstraction() {\n return EntryUnlockRequestErrorEventHandler;\n }\n}\n\nexport const EntryUnlockRequestErrorEventHandler = createAbstraction<\n IEventHandler<EntryUnlockRequestErrorEvent>\n>(\"EntryUnlockRequestErrorEventHandler\");\n\nexport namespace EntryUnlockRequestErrorEventHandler {\n export type Interface = IEventHandler<EntryUnlockRequestErrorEvent>;\n export type Event = EntryUnlockRequestErrorEvent;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW,QAAQ,mDAAmD;;AAK/E;AACA;AACA;;AAOA,OAAO,MAAMC,6BAA6B,SAASD,WAAW,CAAkC;EAC5FE,SAAS,GAAG,yCAAyC;EAErDC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,oCAAoC;EAC/C;AACJ;AAEA,OAAO,MAAMA,oCAAoC,GAAGL,iBAAiB,CAEnE,sCAAsC,CAAC;;AAOzC;AACA;AACA;;AAQA,OAAO,MAAMM,4BAA4B,SAASL,WAAW,CAAiC;EAC1FE,SAAS,GAAG,wCAAwC;EAEpDC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,mCAAmC;EAC9C;AACJ;AAEA,OAAO,MAAMA,mCAAmC,GAAGP,iBAAiB,CAElE,qCAAqC,CAAC;;AAOxC;AACA;AACA;;AAQA,OAAO,MAAMQ,4BAA4B,SAASP,WAAW,CAAiC;EAC1FE,SAAS,GAAG,wCAAwC;EAEpDC,qBAAqBA,CAAA,EAAG;IACpB,OAAOK,mCAAmC;EAC9C;AACJ;AAEA,OAAO,MAAMA,mCAAmC,GAAGT,iBAAiB,CAElE,qCAAqC,CAAC","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ export declare const UnlockEntryRequestFeature: {
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 { UnlockEntryRequestUseCase } from "./UnlockEntryRequestUseCase.js";
3
+ import { UnlockEntryRequestRepository } from "./UnlockEntryRequestRepository.js";
4
+ import { UnlockEntryRequestEventsDecorator } from "./UnlockEntryRequestEventsDecorator.js";
5
+ export const UnlockEntryRequestFeature = createFeature({
6
+ name: "UnlockEntryRequest",
7
+ register(container) {
8
+ container.register(UnlockEntryRequestUseCase);
9
+ container.register(UnlockEntryRequestRepository).inSingletonScope();
10
+ container.registerDecorator(UnlockEntryRequestEventsDecorator);
11
+ }
12
+ });
13
+
14
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createFeature","UnlockEntryRequestUseCase","UnlockEntryRequestRepository","UnlockEntryRequestEventsDecorator","UnlockEntryRequestFeature","name","register","container","inSingletonScope","registerDecorator"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { UnlockEntryRequestUseCase } from \"./UnlockEntryRequestUseCase.js\";\nimport { UnlockEntryRequestRepository } from \"./UnlockEntryRequestRepository.js\";\nimport { UnlockEntryRequestEventsDecorator } from \"./UnlockEntryRequestEventsDecorator.js\";\n\nexport const UnlockEntryRequestFeature = createFeature({\n name: \"UnlockEntryRequest\",\n register(container) {\n container.register(UnlockEntryRequestUseCase);\n container.register(UnlockEntryRequestRepository).inSingletonScope();\n container.registerDecorator(UnlockEntryRequestEventsDecorator);\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,yBAAyB;AAClC,SAASC,4BAA4B;AACrC,SAASC,iCAAiC;AAE1C,OAAO,MAAMC,yBAAyB,GAAGJ,aAAa,CAAC;EACnDK,IAAI,EAAE,oBAAoB;EAC1BC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACL,yBAAyB,CAAC;IAC7CM,SAAS,CAACD,QAAQ,CAACJ,4BAA4B,CAAC,CAACM,gBAAgB,CAAC,CAAC;IACnED,SAAS,CAACE,iBAAiB,CAACN,iCAAiC,CAAC;EAClE;AACJ,CAAC,CAAC","ignoreList":[]}