@webiny/api-record-locking 6.0.0-alpha.5 → 6.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +1 -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 +1 -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 +1 -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 +1 -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 +1 -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 +1 -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 +1 -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 +12 -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 +1 -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 +1 -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 +1 -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 +2 -2
  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 +99 -61
  196. package/graphql/schema.js.map +1 -1
  197. package/index.d.ts +3 -3
  198. package/index.js +48 -25
  199. package/index.js.map +1 -1
  200. package/package.json +21 -25
  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
package/README.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # @webiny/api-record-locking
2
- [![](https://img.shields.io/npm/dw/@webiny/api-record-locking.svg)](https://www.npmjs.com/package/@webiny/api-record-locking)
3
- [![](https://img.shields.io/npm/v/@webiny/api-record-locking.svg)](https://www.npmjs.com/package/@webiny/api-record-locking)
4
- [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
5
- [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
6
-
7
- ## Install
8
- ```
9
- yarn add @webiny/api-record-locking
10
- ```
2
+
3
+ > [!NOTE]
4
+ > This package is part of the [Webiny](https://www.webiny.com) monorepo.
5
+ > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
6
+
7
+ 📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
8
+
9
+ ---
10
+
11
+ _This README file is automatically generated during the publish process._
@@ -0,0 +1,45 @@
1
+ import type { CmsEntry } from "@webiny/api-headless-cms/types";
2
+ import type { CmsIdentity } from "@webiny/api-headless-cms/types";
3
+ import type { LockRecordAction, LockRecordApprovedAction, LockRecordDeniedAction, LockRecordEntryType, LockRecordObject, LockRecordRequestedAction, LockRecordValues } from "./types.js";
4
+ export interface ILockRecord {
5
+ readonly id: string;
6
+ readonly targetId: string;
7
+ readonly type: LockRecordEntryType;
8
+ readonly lockedBy: CmsIdentity;
9
+ readonly lockedOn: Date;
10
+ readonly updatedOn: Date;
11
+ readonly expiresOn: Date;
12
+ readonly actions?: LockRecordAction[];
13
+ toObject(): LockRecordObject;
14
+ addAction(action: LockRecordAction): void;
15
+ getUnlockRequested(): LockRecordRequestedAction | undefined;
16
+ getUnlockApproved(): LockRecordApprovedAction | undefined;
17
+ getUnlockDenied(): LockRecordDeniedAction | undefined;
18
+ isExpired(): boolean;
19
+ }
20
+ export type LockRecordParams = Pick<CmsEntry<LockRecordValues>, "entryId" | "values" | "createdBy" | "createdOn" | "savedOn">;
21
+ export declare class LockRecord implements ILockRecord {
22
+ private readonly _id;
23
+ private readonly _targetId;
24
+ private readonly _type;
25
+ private readonly _lockedBy;
26
+ private readonly _lockedOn;
27
+ private readonly _updatedOn;
28
+ private readonly _expiresOn;
29
+ private _actions?;
30
+ get id(): string;
31
+ get targetId(): string;
32
+ get type(): LockRecordEntryType;
33
+ get lockedBy(): CmsIdentity;
34
+ get lockedOn(): Date;
35
+ get updatedOn(): Date;
36
+ get expiresOn(): Date;
37
+ get actions(): LockRecordAction[] | undefined;
38
+ constructor(input: LockRecordParams, timeout: number);
39
+ toObject(): LockRecordObject;
40
+ addAction(action: LockRecordAction): void;
41
+ getUnlockRequested(): LockRecordRequestedAction | undefined;
42
+ getUnlockApproved(): LockRecordApprovedAction | undefined;
43
+ getUnlockDenied(): LockRecordDeniedAction | undefined;
44
+ isExpired(): boolean;
45
+ }
@@ -1,17 +1,7 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.convertEntryToLockRecord = exports.HeadlessCmsLockRecord = void 0;
7
- var _types = require("../types");
8
- var _lockRecordDatabaseId = require("./lockRecordDatabaseId");
9
- var _calculateExpiresOn = require("./calculateExpiresOn");
10
- const convertEntryToLockRecord = (entry, timeout) => {
11
- return new HeadlessCmsLockRecord(entry, timeout);
12
- };
13
- exports.convertEntryToLockRecord = convertEntryToLockRecord;
14
- class HeadlessCmsLockRecord {
1
+ import { RecordLockingLockRecordActionType } from "./types.js";
2
+ import { removeLockRecordDatabasePrefix } from "../utils/lockRecordDatabaseId.js";
3
+ import { calculateExpiresOn } from "./calculateExpiresOn.js";
4
+ export class LockRecord {
15
5
  get id() {
16
6
  return this._id;
17
7
  }
@@ -37,13 +27,13 @@ class HeadlessCmsLockRecord {
37
27
  return this._actions;
38
28
  }
39
29
  constructor(input, timeout) {
40
- this._id = (0, _lockRecordDatabaseId.removeLockRecordDatabasePrefix)(input.entryId);
30
+ this._id = removeLockRecordDatabasePrefix(input.entryId);
41
31
  this._targetId = input.values.targetId;
42
32
  this._type = input.values.type;
43
33
  this._lockedBy = input.createdBy;
44
34
  this._lockedOn = new Date(input.createdOn);
45
35
  this._updatedOn = new Date(input.savedOn);
46
- this._expiresOn = (0, _calculateExpiresOn.calculateExpiresOn)(input, timeout);
36
+ this._expiresOn = calculateExpiresOn(input.savedOn, timeout);
47
37
  this._actions = input.values.actions;
48
38
  }
49
39
  toObject() {
@@ -68,24 +58,23 @@ class HeadlessCmsLockRecord {
68
58
  if (!this._actions?.length) {
69
59
  return undefined;
70
60
  }
71
- return this._actions.find(action => action.type === _types.RecordLockingLockRecordActionType.requested);
61
+ return this._actions.find(action => action.type === RecordLockingLockRecordActionType.requested);
72
62
  }
73
63
  getUnlockApproved() {
74
64
  if (!this._actions?.length) {
75
65
  return undefined;
76
66
  }
77
- return this._actions.find(action => action.type === _types.RecordLockingLockRecordActionType.approved);
67
+ return this._actions.find(action => action.type === RecordLockingLockRecordActionType.approved);
78
68
  }
79
69
  getUnlockDenied() {
80
70
  if (!this._actions?.length) {
81
71
  return undefined;
82
72
  }
83
- return this._actions.find(action => action.type === _types.RecordLockingLockRecordActionType.denied);
73
+ return this._actions.find(action => action.type === RecordLockingLockRecordActionType.denied);
84
74
  }
85
75
  isExpired() {
86
76
  return this._expiresOn.getTime() < new Date().getTime();
87
77
  }
88
78
  }
89
- exports.HeadlessCmsLockRecord = HeadlessCmsLockRecord;
90
79
 
91
- //# sourceMappingURL=convertEntryToLockRecord.js.map
80
+ //# sourceMappingURL=LockRecord.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["RecordLockingLockRecordActionType","removeLockRecordDatabasePrefix","calculateExpiresOn","LockRecord","id","_id","targetId","_targetId","type","_type","lockedBy","_lockedBy","lockedOn","_lockedOn","updatedOn","_updatedOn","expiresOn","_expiresOn","actions","_actions","constructor","input","timeout","entryId","values","createdBy","Date","createdOn","savedOn","toObject","addAction","action","push","getUnlockRequested","length","undefined","find","requested","getUnlockApproved","approved","getUnlockDenied","denied","isExpired","getTime"],"sources":["LockRecord.ts"],"sourcesContent":["import type { CmsEntry } from \"@webiny/api-headless-cms/types\";\nimport type { CmsIdentity } from \"@webiny/api-headless-cms/types\";\nimport { RecordLockingLockRecordActionType } from \"./types.js\";\nimport type {\n LockRecordAction,\n LockRecordApprovedAction,\n LockRecordDeniedAction,\n LockRecordEntryType,\n LockRecordObject,\n LockRecordRequestedAction,\n LockRecordValues\n} from \"./types.js\";\nimport { removeLockRecordDatabasePrefix } from \"~/utils/lockRecordDatabaseId.js\";\nimport { calculateExpiresOn } from \"./calculateExpiresOn.js\";\n\nexport interface ILockRecord {\n readonly id: string;\n readonly targetId: string;\n readonly type: LockRecordEntryType;\n readonly lockedBy: CmsIdentity;\n readonly lockedOn: Date;\n readonly updatedOn: Date;\n readonly expiresOn: Date;\n readonly actions?: LockRecordAction[];\n\n toObject(): LockRecordObject;\n addAction(action: LockRecordAction): void;\n getUnlockRequested(): LockRecordRequestedAction | undefined;\n getUnlockApproved(): LockRecordApprovedAction | undefined;\n getUnlockDenied(): LockRecordDeniedAction | undefined;\n isExpired(): boolean;\n}\n\nexport type LockRecordParams = Pick<\n CmsEntry<LockRecordValues>,\n \"entryId\" | \"values\" | \"createdBy\" | \"createdOn\" | \"savedOn\"\n>;\n\nexport class LockRecord implements ILockRecord {\n private readonly _id: string;\n private readonly _targetId: string;\n private readonly _type: LockRecordEntryType;\n private readonly _lockedBy: CmsIdentity;\n private readonly _lockedOn: Date;\n private readonly _updatedOn: Date;\n private readonly _expiresOn: Date;\n private _actions?: LockRecordAction[];\n\n public get id(): string {\n return this._id;\n }\n\n public get targetId(): string {\n return this._targetId;\n }\n\n public get type(): LockRecordEntryType {\n return this._type;\n }\n\n public get lockedBy(): CmsIdentity {\n return this._lockedBy;\n }\n\n public get lockedOn(): Date {\n return this._lockedOn;\n }\n\n public get updatedOn(): Date {\n return this._updatedOn;\n }\n\n public get expiresOn(): Date {\n return this._expiresOn;\n }\n\n public get actions(): LockRecordAction[] | undefined {\n return this._actions;\n }\n\n public constructor(input: LockRecordParams, timeout: number) {\n this._id = removeLockRecordDatabasePrefix(input.entryId);\n this._targetId = input.values.targetId;\n this._type = input.values.type;\n this._lockedBy = input.createdBy;\n this._lockedOn = new Date(input.createdOn);\n this._updatedOn = new Date(input.savedOn);\n this._expiresOn = calculateExpiresOn(input.savedOn, timeout);\n this._actions = input.values.actions;\n }\n\n public toObject(): LockRecordObject {\n return {\n id: this._id,\n targetId: this._targetId,\n type: this._type,\n lockedBy: this._lockedBy,\n lockedOn: this._lockedOn,\n updatedOn: this._updatedOn,\n expiresOn: this._expiresOn,\n actions: this._actions\n };\n }\n\n public addAction(action: LockRecordAction): void {\n if (!this._actions) {\n this._actions = [];\n }\n this._actions.push(action);\n }\n\n public getUnlockRequested(): LockRecordRequestedAction | undefined {\n if (!this._actions?.length) {\n return undefined;\n }\n return this._actions.find(\n (action): action is LockRecordRequestedAction =>\n action.type === RecordLockingLockRecordActionType.requested\n );\n }\n\n public getUnlockApproved(): LockRecordApprovedAction | undefined {\n if (!this._actions?.length) {\n return undefined;\n }\n return this._actions.find(\n (action): action is LockRecordApprovedAction =>\n action.type === RecordLockingLockRecordActionType.approved\n );\n }\n\n public getUnlockDenied(): LockRecordDeniedAction | undefined {\n if (!this._actions?.length) {\n return undefined;\n }\n return this._actions.find(\n (action): action is LockRecordDeniedAction =>\n action.type === RecordLockingLockRecordActionType.denied\n );\n }\n\n public isExpired(): boolean {\n return this._expiresOn.getTime() < new Date().getTime();\n }\n}\n"],"mappings":"AAEA,SAASA,iCAAiC;AAU1C,SAASC,8BAA8B;AACvC,SAASC,kBAAkB;AAyB3B,OAAO,MAAMC,UAAU,CAAwB;EAU3C,IAAWC,EAAEA,CAAA,EAAW;IACpB,OAAO,IAAI,CAACC,GAAG;EACnB;EAEA,IAAWC,QAAQA,CAAA,EAAW;IAC1B,OAAO,IAAI,CAACC,SAAS;EACzB;EAEA,IAAWC,IAAIA,CAAA,EAAwB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/index.js";
2
+ export declare const RECORD_LOCKING_MODEL_ID = "wbyRecordLock";
3
+ declare class RecordLockingPrivateModelImpl implements ModelFactory.Interface {
4
+ execute(builder: ModelFactory.Builder): Promise<import("@webiny/api-headless-cms/features/modelBuilder/index.js").PrivateModelBuilder[]>;
5
+ }
6
+ export declare const RecordLockingModel: typeof RecordLockingPrivateModelImpl & {
7
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/modelBuilder/abstractions").IModelFactory>;
8
+ };
9
+ export {};
@@ -0,0 +1,29 @@
1
+ import { ModelFactory } from "@webiny/api-headless-cms/features/modelBuilder/index.js";
2
+ export const RECORD_LOCKING_MODEL_ID = "wbyRecordLock";
3
+ class RecordLockingPrivateModelImpl {
4
+ async execute(builder) {
5
+ return [builder.private({
6
+ modelId: RECORD_LOCKING_MODEL_ID,
7
+ name: "Record Lock Tracking"
8
+ }).fields(fields => ({
9
+ targetId: fields.text().label("Target ID").required("Target ID is required."),
10
+ type: fields.text().label("Record Type").required("Record type is required."),
11
+ actions: fields.object().label("Actions").list().fields(fields => ({
12
+ type: fields.text().label("Action Type").required("Action type is required."),
13
+ message: fields.text().label("Message"),
14
+ createdBy: fields.object().label("Created By").required("Created by is required.").fields(fields => ({
15
+ id: fields.text().label("ID").required("ID is required."),
16
+ displayName: fields.text().label("Display Name").required("Display name is required."),
17
+ type: fields.text().label("Type").required("Type is required.")
18
+ })),
19
+ createdOn: fields.datetime().label("Created On").required("Created on is required.").withoutTimezone()
20
+ }))
21
+ }))];
22
+ }
23
+ }
24
+ export const RecordLockingModel = ModelFactory.createImplementation({
25
+ implementation: RecordLockingPrivateModelImpl,
26
+ dependencies: []
27
+ });
28
+
29
+ //# sourceMappingURL=RecordLockingModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ModelFactory","RECORD_LOCKING_MODEL_ID","RecordLockingPrivateModelImpl","execute","builder","private","modelId","name","fields","targetId","text","label","required","type","actions","object","list","message","createdBy","id","displayName","createdOn","datetime","withoutTimezone","RecordLockingModel","createImplementation","implementation","dependencies"],"sources":["RecordLockingModel.ts"],"sourcesContent":["import { ModelFactory } from \"@webiny/api-headless-cms/features/modelBuilder/index.js\";\n\nexport const RECORD_LOCKING_MODEL_ID = \"wbyRecordLock\";\n\nclass RecordLockingPrivateModelImpl implements ModelFactory.Interface {\n public async execute(builder: ModelFactory.Builder) {\n return [\n builder\n .private({\n modelId: RECORD_LOCKING_MODEL_ID,\n name: \"Record Lock Tracking\"\n })\n .fields(fields => ({\n targetId: fields.text().label(\"Target ID\").required(\"Target ID is required.\"),\n type: fields.text().label(\"Record Type\").required(\"Record type is required.\"),\n actions: fields\n .object()\n .label(\"Actions\")\n .list()\n .fields(fields => ({\n type: fields\n .text()\n .label(\"Action Type\")\n .required(\"Action type is required.\"),\n message: fields.text().label(\"Message\"),\n createdBy: fields\n .object()\n .label(\"Created By\")\n .required(\"Created by is required.\")\n .fields(fields => ({\n id: fields.text().label(\"ID\").required(\"ID is required.\"),\n displayName: fields\n .text()\n .label(\"Display Name\")\n .required(\"Display name is required.\"),\n type: fields.text().label(\"Type\").required(\"Type is required.\")\n })),\n createdOn: fields\n .datetime()\n .label(\"Created On\")\n .required(\"Created on is required.\")\n .withoutTimezone()\n }))\n }))\n ];\n }\n}\n\nexport const RecordLockingModel = ModelFactory.createImplementation({\n implementation: RecordLockingPrivateModelImpl,\n dependencies: []\n});\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,yDAAyD;AAEtF,OAAO,MAAMC,uBAAuB,GAAG,eAAe;AAEtD,MAAMC,6BAA6B,CAAmC;EAClE,MAAaC,OAAOA,CAACC,OAA6B,EAAE;IAChD,OAAO,CACHA,OAAO,CACFC,OAAO,CAAC;MACLC,OAAO,EAAEL,uBAAuB;MAChCM,IAAI,EAAE;IACV,CAAC,CAAC,CACDC,MAAM,CAACA,MAAM,KAAK;MACfC,QAAQ,EAAED,MAAM,CAACE,IAAI,CAAC,CAAC,CAACC,KAAK,CAAC,WAAW,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Y,CAACyB,oBAAoB,CAAC;EAChEC,cAAc,EAAExB,6BAA6B;EAC7CyB,YAAY,EAAE;AAClB,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,18 @@
1
+ import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
2
+ /**
3
+ * RecordLockingConfig - Configuration for record locking timeout
4
+ */
5
+ export interface IRecordLockingConfig {
6
+ /**
7
+ * Timeout in milliseconds after which a lock expires
8
+ */
9
+ timeout: number;
10
+ }
11
+ export declare const RecordLockingConfig: import("@webiny/di").Abstraction<IRecordLockingConfig>;
12
+ export declare namespace RecordLockingConfig {
13
+ type Interface = IRecordLockingConfig;
14
+ }
15
+ export declare const RecordLockingModel: import("@webiny/di").Abstraction<CmsModel>;
16
+ export declare namespace RecordLockingModel {
17
+ type Interface = CmsModel;
18
+ }
@@ -0,0 +1,10 @@
1
+ import { createAbstraction } from "@webiny/feature/api";
2
+
3
+ /**
4
+ * RecordLockingConfig - Configuration for record locking timeout
5
+ */
6
+
7
+ export const RecordLockingConfig = createAbstraction("RecordLockingConfig");
8
+ export const RecordLockingModel = createAbstraction("RecordLockingModel");
9
+
10
+ //# sourceMappingURL=abstractions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createAbstraction","RecordLockingConfig","RecordLockingModel"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\n/**\n * RecordLockingConfig - Configuration for record locking timeout\n */\nexport interface IRecordLockingConfig {\n /**\n * Timeout in milliseconds after which a lock expires\n */\n timeout: number;\n}\n\nexport const RecordLockingConfig = createAbstraction<IRecordLockingConfig>(\"RecordLockingConfig\");\n\nexport namespace RecordLockingConfig {\n export type Interface = IRecordLockingConfig;\n}\n\nexport const RecordLockingModel = createAbstraction<CmsModel>(\"RecordLockingModel\");\n\nexport namespace RecordLockingModel {\n export type Interface = CmsModel;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAGvD;AACA;AACA;;AAQA,OAAO,MAAMC,mBAAmB,GAAGD,iBAAiB,CAAuB,qBAAqB,CAAC;AAMjG,OAAO,MAAME,kBAAkB,GAAGF,iBAAiB,CAAW,oBAAoB,CAAC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ export declare const calculateExpiresOn: (savedOn: string | undefined, timeout: number) => Date;
@@ -0,0 +1,9 @@
1
+ export const calculateExpiresOn = (savedOn, timeout) => {
2
+ if (!savedOn) {
3
+ throw new Error("Missing savedOn property.");
4
+ }
5
+ const savedOnDate = new Date(savedOn);
6
+ return new Date(savedOnDate.getTime() + timeout);
7
+ };
8
+
9
+ //# sourceMappingURL=calculateExpiresOn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["calculateExpiresOn","savedOn","timeout","Error","savedOnDate","Date","getTime"],"sources":["calculateExpiresOn.ts"],"sourcesContent":["export const calculateExpiresOn = (savedOn: string | undefined, timeout: number): Date => {\n if (!savedOn) {\n throw new Error(\"Missing savedOn property.\");\n }\n const savedOnDate = new Date(savedOn);\n\n return new Date(savedOnDate.getTime() + timeout);\n};\n"],"mappings":"AAAA,OAAO,MAAMA,kBAAkB,GAAGA,CAACC,OAA2B,EAAEC,OAAe,KAAW;EACtF,IAAI,CAACD,OAAO,EAAE;IACV,MAAM,IAAIE,KAAK,CAAC,2BAA2B,CAAC;EAChD;EACA,MAAMC,WAAW,GAAG,IAAIC,IAAI,CAACJ,OAAO,CAAC;EAErC,OAAO,IAAII,IAAI,CAACD,WAAW,CAACE,OAAO,CAAC,CAAC,GAAGJ,OAAO,CAAC;AACpD,CAAC","ignoreList":[]}
@@ -0,0 +1,71 @@
1
+ import { BaseError } from "@webiny/feature/api";
2
+ export declare class EntryAlreadyLockedError extends BaseError<{
3
+ id: string;
4
+ type: string;
5
+ }> {
6
+ readonly code: "RecordLocking/Entry/AlreadyLockedError";
7
+ constructor(data: {
8
+ id: string;
9
+ type: string;
10
+ });
11
+ }
12
+ export declare class LockRecordNotFoundError extends BaseError {
13
+ readonly code: "RecordLocking/LockRecord/NotFoundError";
14
+ constructor();
15
+ }
16
+ export declare class LockRecordPersistenceError extends BaseError {
17
+ readonly code: "RecordLocking/LockRecord/PersistenceError";
18
+ constructor(error: Error);
19
+ }
20
+ export declare class IdentityMismatchError extends BaseError<{
21
+ currentId: string;
22
+ targetId: string;
23
+ }> {
24
+ readonly code: "RecordLocking/Identity/MismatchError";
25
+ constructor(data: {
26
+ currentId: string;
27
+ targetId: string;
28
+ });
29
+ }
30
+ export declare class UnlockEntryError extends BaseError {
31
+ readonly code: "RecordLocking/Entry/UnlockError";
32
+ constructor(error: Error);
33
+ }
34
+ export declare class LockEntryError extends BaseError {
35
+ readonly code: "RecordLocking/Entry/LockError";
36
+ constructor(error: Error);
37
+ }
38
+ export declare class UpdateEntryLockError extends BaseError {
39
+ readonly code: "RecordLocking/Entry/UpdateLockError";
40
+ constructor(error: Error);
41
+ }
42
+ export declare class IdentityMissingError extends BaseError {
43
+ readonly code: "RecordLocking/Identity/MissingError";
44
+ constructor();
45
+ }
46
+ export declare class EntryNotLockedError extends BaseError<{
47
+ id: string;
48
+ type: string;
49
+ }> {
50
+ readonly code: "RecordLocking/Entry/NotLockedError";
51
+ constructor(data: {
52
+ id: string;
53
+ type: string;
54
+ });
55
+ }
56
+ export declare class UnlockRequestAlreadySentError extends BaseError<{
57
+ id: string;
58
+ type: string;
59
+ identityId: string;
60
+ }> {
61
+ readonly code: "RecordLocking/Entry/UnlockRequestAlreadySentError";
62
+ constructor(data: {
63
+ id: string;
64
+ type: string;
65
+ identityId: string;
66
+ });
67
+ }
68
+ export declare class UnlockEntryRequestError extends BaseError {
69
+ readonly code: "RecordLocking/Entry/UnlockRequestError";
70
+ constructor(error: Error);
71
+ }
@@ -0,0 +1,95 @@
1
+ import { BaseError } from "@webiny/feature/api";
2
+ export class EntryAlreadyLockedError extends BaseError {
3
+ code = "RecordLocking/Entry/AlreadyLockedError";
4
+ constructor(data) {
5
+ super({
6
+ message: "Entry is already locked for editing.",
7
+ data
8
+ });
9
+ }
10
+ }
11
+ export class LockRecordNotFoundError extends BaseError {
12
+ code = "RecordLocking/LockRecord/NotFoundError";
13
+ constructor() {
14
+ super({
15
+ message: "Lock record not found."
16
+ });
17
+ }
18
+ }
19
+ export class LockRecordPersistenceError extends BaseError {
20
+ code = "RecordLocking/LockRecord/PersistenceError";
21
+ constructor(error) {
22
+ super({
23
+ message: error.message
24
+ });
25
+ }
26
+ }
27
+ export class IdentityMismatchError extends BaseError {
28
+ code = "RecordLocking/Identity/MismatchError";
29
+ constructor(data) {
30
+ super({
31
+ message: "Identity mismatch - cannot perform action.",
32
+ data
33
+ });
34
+ }
35
+ }
36
+ export class UnlockEntryError extends BaseError {
37
+ code = "RecordLocking/Entry/UnlockError";
38
+ constructor(error) {
39
+ super({
40
+ message: `Could not unlock entry: ${error.message}`
41
+ });
42
+ }
43
+ }
44
+ export class LockEntryError extends BaseError {
45
+ code = "RecordLocking/Entry/LockError";
46
+ constructor(error) {
47
+ super({
48
+ message: `Could not lock entry: ${error.message}`
49
+ });
50
+ }
51
+ }
52
+ export class UpdateEntryLockError extends BaseError {
53
+ code = "RecordLocking/Entry/UpdateLockError";
54
+ constructor(error) {
55
+ super({
56
+ message: `Could not update entry lock: ${error.message}`
57
+ });
58
+ }
59
+ }
60
+ export class IdentityMissingError extends BaseError {
61
+ code = "RecordLocking/Identity/MissingError";
62
+ constructor() {
63
+ super({
64
+ message: "Identity is missing."
65
+ });
66
+ }
67
+ }
68
+ export class EntryNotLockedError extends BaseError {
69
+ code = "RecordLocking/Entry/NotLockedError";
70
+ constructor(data) {
71
+ super({
72
+ message: "Entry is not locked.",
73
+ data
74
+ });
75
+ }
76
+ }
77
+ export class UnlockRequestAlreadySentError extends BaseError {
78
+ code = "RecordLocking/Entry/UnlockRequestAlreadySentError";
79
+ constructor(data) {
80
+ super({
81
+ message: "Unlock request already sent.",
82
+ data
83
+ });
84
+ }
85
+ }
86
+ export class UnlockEntryRequestError extends BaseError {
87
+ code = "RecordLocking/Entry/UnlockRequestError";
88
+ constructor(error) {
89
+ super({
90
+ message: `Could not request unlock: ${error.message}`
91
+ });
92
+ }
93
+ }
94
+
95
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["BaseError","EntryAlreadyLockedError","code","constructor","data","message","LockRecordNotFoundError","LockRecordPersistenceError","error","IdentityMismatchError","UnlockEntryError","LockEntryError","UpdateEntryLockError","IdentityMissingError","EntryNotLockedError","UnlockRequestAlreadySentError","UnlockEntryRequestError"],"sources":["errors.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\n\nexport class EntryAlreadyLockedError extends BaseError<{ id: string; type: string }> {\n override readonly code = \"RecordLocking/Entry/AlreadyLockedError\" as const;\n\n constructor(data: { id: string; type: string }) {\n super({\n message: \"Entry is already locked for editing.\",\n data\n });\n }\n}\n\nexport class LockRecordNotFoundError extends BaseError {\n override readonly code = \"RecordLocking/LockRecord/NotFoundError\" as const;\n\n constructor() {\n super({\n message: \"Lock record not found.\"\n });\n }\n}\n\nexport class LockRecordPersistenceError extends BaseError {\n override readonly code = \"RecordLocking/LockRecord/PersistenceError\" as const;\n\n constructor(error: Error) {\n super({\n message: error.message\n });\n }\n}\n\nexport class IdentityMismatchError extends BaseError<{ currentId: string; targetId: string }> {\n override readonly code = \"RecordLocking/Identity/MismatchError\" as const;\n\n constructor(data: { currentId: string; targetId: string }) {\n super({\n message: \"Identity mismatch - cannot perform action.\",\n data\n });\n }\n}\n\nexport class UnlockEntryError extends BaseError {\n override readonly code = \"RecordLocking/Entry/UnlockError\" as const;\n\n constructor(error: Error) {\n super({\n message: `Could not unlock entry: ${error.message}`\n });\n }\n}\n\nexport class LockEntryError extends BaseError {\n override readonly code = \"RecordLocking/Entry/LockError\" as const;\n\n constructor(error: Error) {\n super({\n message: `Could not lock entry: ${error.message}`\n });\n }\n}\n\nexport class UpdateEntryLockError extends BaseError {\n override readonly code = \"RecordLocking/Entry/UpdateLockError\" as const;\n\n constructor(error: Error) {\n super({\n message: `Could not update entry lock: ${error.message}`\n });\n }\n}\n\nexport class IdentityMissingError extends BaseError {\n override readonly code = \"RecordLocking/Identity/MissingError\" as const;\n\n constructor() {\n super({\n message: \"Identity is missing.\"\n });\n }\n}\n\nexport class EntryNotLockedError extends BaseError<{ id: string; type: string }> {\n override readonly code = \"RecordLocking/Entry/NotLockedError\" as const;\n\n constructor(data: { id: string; type: string }) {\n super({\n message: \"Entry is not locked.\",\n data\n });\n }\n}\n\nexport class UnlockRequestAlreadySentError extends BaseError<{\n id: string;\n type: string;\n identityId: string;\n}> {\n override readonly code = \"RecordLocking/Entry/UnlockRequestAlreadySentError\" as const;\n\n constructor(data: { id: string; type: string; identityId: string }) {\n super({\n message: \"Unlock request already sent.\",\n data\n });\n }\n}\n\nexport class UnlockEntryRequestError extends BaseError {\n override readonly code = \"RecordLocking/Entry/UnlockRequestError\" as const;\n\n constructor(error: Error) {\n super({\n message: `Could not request unlock: ${error.message}`\n });\n }\n}\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,qBAAqB;AAE/C,OAAO,MAAMC,uBAAuB,SAASD,SAAS,CAA+B;EAC/DE,IAAI,GAAG,wCAAwC;EAEjEC,WAAWA,CAACC,IAAkC,EAAE;IAC5C,KAAK,CAAC;MACFC,OAAO,EAAE,sCAAsC;MAC/CD;IACJ,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAME,uBAAuB,SAASN,SAAS,CAAC;EACjCE,IAAI,GAAG,wCAAwC;EAEjEC,WAAWA,CAAA,EAAG;IACV,KAAK,CAAC;MACFE,OAAO,EAAE;IACb,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAME,0BAA0B,SAASP,SAAS,CAAC;EACpCE,IAAI,GAAG,2CAA2C;EAEpEC,WAAWA,CAACK,KAAY,EAAE;IACtB,KAAK,CAAC;MACFH,OAAO,EAAEG,KAAK,CAACH;IACnB,CAAC,CAAC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AmD;EAE5EC,WAAWA,CAACC,IAAsD,EAAE;IAChE,KAAK,CAAC;MACFC,OAAO,EAAE,8BAA8B;MACvCD;IACJ,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMY,uBAAuB,SAAShB,SAAS,CAAC;EACjCE,IAAI,GAAG,wCAAwC;EAEjEC,WAAWA,CAACK,KAAY,EAAE;IACtB,KAAK,CAAC;MACFH,OAAO,EAAE,6BAA6BG,KAAK,CAACH,OAAO;IACvD,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ export * from "./abstractions.js";
2
+ export * from "./errors.js";
3
+ export * from "./LockRecord.js";
4
+ export * from "./types.js";
@@ -0,0 +1,6 @@
1
+ export * from "./abstractions.js";
2
+ export * from "./errors.js";
3
+ export * from "./LockRecord.js";
4
+ export * from "./types.js";
5
+
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\nexport * from \"./errors.js\";\nexport * from \"./LockRecord.js\";\nexport * from \"./types.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA","ignoreList":[]}
@@ -0,0 +1,44 @@
1
+ import type { CmsIdentity } from "@webiny/api-headless-cms/types";
2
+ /**
3
+ * Do not use any special chars other than #, as we use this to create lock record IDs.
4
+ */
5
+ export type LockRecordEntryType = string;
6
+ export declare enum RecordLockingLockRecordActionType {
7
+ requested = "requested",
8
+ approved = "approved",
9
+ denied = "denied"
10
+ }
11
+ export interface LockRecordRequestedAction {
12
+ type: RecordLockingLockRecordActionType.requested;
13
+ message?: string;
14
+ createdOn: Date;
15
+ createdBy: CmsIdentity;
16
+ }
17
+ export interface LockRecordApprovedAction {
18
+ type: RecordLockingLockRecordActionType.approved;
19
+ message?: string;
20
+ createdOn: Date;
21
+ createdBy: CmsIdentity;
22
+ }
23
+ export interface LockRecordDeniedAction {
24
+ type: RecordLockingLockRecordActionType.denied;
25
+ message?: string;
26
+ createdOn: Date;
27
+ createdBy: CmsIdentity;
28
+ }
29
+ export type LockRecordAction = LockRecordRequestedAction | LockRecordApprovedAction | LockRecordDeniedAction;
30
+ export interface LockRecordValues {
31
+ targetId: string;
32
+ type: LockRecordEntryType;
33
+ actions?: LockRecordAction[];
34
+ }
35
+ export interface LockRecordObject {
36
+ id: string;
37
+ targetId: string;
38
+ type: LockRecordEntryType;
39
+ lockedBy: CmsIdentity;
40
+ lockedOn: Date;
41
+ updatedOn: Date;
42
+ expiresOn: Date;
43
+ actions?: LockRecordAction[];
44
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Do not use any special chars other than #, as we use this to create lock record IDs.
3
+ */
4
+
5
+ export let RecordLockingLockRecordActionType = /*#__PURE__*/function (RecordLockingLockRecordActionType) {
6
+ RecordLockingLockRecordActionType["requested"] = "requested";
7
+ RecordLockingLockRecordActionType["approved"] = "approved";
8
+ RecordLockingLockRecordActionType["denied"] = "denied";
9
+ return RecordLockingLockRecordActionType;
10
+ }({});
11
+
12
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["RecordLockingLockRecordActionType"],"sources":["types.ts"],"sourcesContent":["import type { CmsIdentity } from \"@webiny/api-headless-cms/types\";\n\n/**\n * Do not use any special chars other than #, as we use this to create lock record IDs.\n */\nexport type LockRecordEntryType = string;\n\nexport enum RecordLockingLockRecordActionType {\n requested = \"requested\",\n approved = \"approved\",\n denied = \"denied\"\n}\n\nexport interface LockRecordRequestedAction {\n type: RecordLockingLockRecordActionType.requested;\n message?: string;\n createdOn: Date;\n createdBy: CmsIdentity;\n}\n\nexport interface LockRecordApprovedAction {\n type: RecordLockingLockRecordActionType.approved;\n message?: string;\n createdOn: Date;\n createdBy: CmsIdentity;\n}\n\nexport interface LockRecordDeniedAction {\n type: RecordLockingLockRecordActionType.denied;\n message?: string;\n createdOn: Date;\n createdBy: CmsIdentity;\n}\n\nexport type LockRecordAction =\n | LockRecordRequestedAction\n | LockRecordApprovedAction\n | LockRecordDeniedAction;\n\nexport interface LockRecordValues {\n targetId: string;\n type: LockRecordEntryType;\n actions?: LockRecordAction[];\n}\n\nexport interface LockRecordObject {\n id: string;\n targetId: string;\n type: LockRecordEntryType;\n lockedBy: CmsIdentity;\n lockedOn: Date;\n updatedOn: Date;\n expiresOn: Date;\n actions?: LockRecordAction[];\n}\n"],"mappings":"AAEA;AACA;AACA;;AAGA,WAAYA,iCAAiC,0BAAjCA,iCAAiC;EAAjCA,iCAAiC;EAAjCA,iCAAiC;EAAjCA,iCAAiC;EAAA,OAAjCA,iCAAiC;AAAA","ignoreList":[]}
@@ -0,0 +1,16 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById";
3
+ import { GetLockRecordRepository as RepositoryAbstraction } from "./abstractions.js";
4
+ import { RecordLockingConfig, RecordLockingModel } from "../../domain/abstractions.js";
5
+ import type { ILockRecord } from "../../domain/LockRecord.js";
6
+ declare class GetLockRecordRepositoryImpl implements RepositoryAbstraction.Interface {
7
+ private model;
8
+ private config;
9
+ private getEntryById;
10
+ constructor(model: RecordLockingModel.Interface, config: RecordLockingConfig.Interface, getEntryById: GetEntryByIdUseCase.Interface);
11
+ get(id: string): Promise<Result<ILockRecord, RepositoryAbstraction.Error>>;
12
+ }
13
+ export declare const GetLockRecordRepository: typeof GetLockRecordRepositoryImpl & {
14
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGetLockRecordRepository>;
15
+ };
16
+ export {};
@@ -0,0 +1,37 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById";
3
+ import { createIdentifier } from "@webiny/utils";
4
+ import { GetLockRecordRepository as RepositoryAbstraction } from "./abstractions.js";
5
+ import { RecordLockingConfig, RecordLockingModel } from "../../domain/abstractions.js";
6
+ import { LockRecord } from "../../domain/LockRecord.js";
7
+ import { LockRecordNotFoundError, LockRecordPersistenceError } from "../../domain/errors.js";
8
+ import { createLockRecordDatabaseId } from "../../utils/lockRecordDatabaseId.js";
9
+ class GetLockRecordRepositoryImpl {
10
+ constructor(model, config, getEntryById) {
11
+ this.model = model;
12
+ this.config = config;
13
+ this.getEntryById = getEntryById;
14
+ }
15
+ async get(id) {
16
+ const recordId = createLockRecordDatabaseId(id);
17
+ const entryId = createIdentifier({
18
+ id: recordId,
19
+ version: 1
20
+ });
21
+ const result = await this.getEntryById.execute(this.model, entryId);
22
+ if (result.isFail()) {
23
+ if (result.error.code === "Cms/Entry/NotFound") {
24
+ return Result.fail(new LockRecordNotFoundError());
25
+ }
26
+ return Result.fail(new LockRecordPersistenceError(result.error));
27
+ }
28
+ const entry = result.value;
29
+ return Result.ok(new LockRecord(entry, this.config.timeout));
30
+ }
31
+ }
32
+ export const GetLockRecordRepository = RepositoryAbstraction.createImplementation({
33
+ implementation: GetLockRecordRepositoryImpl,
34
+ dependencies: [RecordLockingModel, RecordLockingConfig, GetEntryByIdUseCase]
35
+ });
36
+
37
+ //# sourceMappingURL=GetLockRecordRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Result","GetEntryByIdUseCase","createIdentifier","GetLockRecordRepository","RepositoryAbstraction","RecordLockingConfig","RecordLockingModel","LockRecord","LockRecordNotFoundError","LockRecordPersistenceError","createLockRecordDatabaseId","GetLockRecordRepositoryImpl","constructor","model","config","getEntryById","get","id","recordId","entryId","version","result","execute","isFail","error","code","fail","entry","value","ok","timeout","createImplementation","implementation","dependencies"],"sources":["GetLockRecordRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById\";\nimport { createIdentifier } from \"@webiny/utils\";\nimport { GetLockRecordRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { RecordLockingConfig, RecordLockingModel } from \"~/domain/abstractions.js\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport { LockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordValues } from \"~/domain/types.js\";\nimport { LockRecordNotFoundError, LockRecordPersistenceError } from \"~/domain/errors.js\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId.js\";\n\nclass GetLockRecordRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private model: RecordLockingModel.Interface,\n private config: RecordLockingConfig.Interface,\n private getEntryById: GetEntryByIdUseCase.Interface\n ) {}\n\n async get(id: string): Promise<Result<ILockRecord, RepositoryAbstraction.Error>> {\n const recordId = createLockRecordDatabaseId(id);\n const entryId = createIdentifier({\n id: recordId,\n version: 1\n });\n\n const result = await this.getEntryById.execute<LockRecordValues>(this.model, entryId);\n\n if (result.isFail()) {\n if (result.error.code === \"Cms/Entry/NotFound\") {\n return Result.fail(new LockRecordNotFoundError());\n }\n\n return Result.fail(new LockRecordPersistenceError(result.error));\n }\n\n const entry = result.value;\n\n return Result.ok(new LockRecord(entry, this.config.timeout));\n }\n}\n\nexport const GetLockRecordRepository = RepositoryAbstraction.createImplementation({\n implementation: GetLockRecordRepositoryImpl,\n dependencies: [RecordLockingModel, RecordLockingConfig, GetEntryByIdUseCase]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,mBAAmB,QAAQ,6DAA6D;AACjG,SAASC,gBAAgB,QAAQ,eAAe;AAChD,SAASC,uBAAuB,IAAIC,qBAAqB;AACzD,SAASC,mBAAmB,EAAEC,kBAAkB;AAEhD,SAASC,UAAU;AAEnB,SAASC,uBAAuB,EAAEC,0BAA0B;AAC5D,SAASC,0BAA0B;AAEnC,MAAMC,2BAA2B,CAA4C;EACzEC,WAAWA,CACCC,KAAmC,EACnCC,MAAqC,EACrCC,YAA2C,EACrD;IAAA,KAHUF,KAAmC,GAAnCA,KAAmC;IAAA,KACnCC,MAAqC,GAArCA,MAAqC;IAAA,KACrCC,YAA2C,GAA3CA,YAA2C;EACpD;EAEH,MAAMC,GAAGA,CAACC,EAAU,EAA6D;IAC7E,MAAMC,QAAQ,GAAGR,0BAA0B,CAACO,EAAE,CAAC;IAC/C,MAAME,OAAO,GAAGjB,gBAAgB,CAAC;MAC7Be,EAAE,EAAEC,QAAQ;MACZE,OAAO,EAAE;IACb,CAAC,CAAC;IAEF,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACN,YAAY,CAACO,OAAO,CAAmB,IAAI,CAACT,KAAK,EAAEM,OAAO,CAAC;IAErF,IAAIE,MAAM,CAACE,MAAM,CAAC,CAAC,EAAE;MACjB,IAAIF,MAAM,CAACG,KAAK,CAACC,IAAI,KAAK,oBAAoB,EAAE;QAC5C,OAAOzB,MAAM,CAAC0B,IAAI,CAAC,IAAIlB,uBAAuB,CAAC,CAAC,CAAC;MACrD;MAEA,OAAOR,MAAM,CAAC0B,IAAI,CAAC,IAAIjB,0BAA0B,CAACY,MAAM,CAACG,KAAK,CAAC,CAAC;IACpE;IAEA,MAAMG,KAAK,GAAGN,MAAM,CAACO,KAAK;IAE1B,OAAO5B,MAAM,CAAC6B,EAAE,CAAC,IAAItB,UAAU,CAACoB,KAAK,EAAE,IAAI,CAACb,MAAM,CAACgB,OAAO,CAAC,CAAC;EAChE;AACJ;AAEA,OAAO,MAAM3B,uBAAuB,GAAGC,qBAAqB,CAAC2B,oBAAoB,CAAC;EAC9EC,cAAc,EAAErB,2BAA2B;EAC3CsB,YAAY,EAAE,CAAC3B,kBAAkB,EAAED,mBAAmB,EAAEJ,mBAAmB;AAC/E,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,12 @@
1
+ import { Result } from "@webiny/feature/api";
2
+ import { GetLockRecordUseCase as UseCaseAbstraction, GetLockRecordRepository, GetLockRecordInput } from "./abstractions.js";
3
+ import type { ILockRecord } from "../../domain/LockRecord.js";
4
+ declare class GetLockRecordUseCaseImpl implements UseCaseAbstraction.Interface {
5
+ private repository;
6
+ constructor(repository: GetLockRecordRepository.Interface);
7
+ execute(input: GetLockRecordInput): Promise<Result<ILockRecord, UseCaseAbstraction.Error>>;
8
+ }
9
+ export declare const GetLockRecordUseCase: typeof GetLockRecordUseCaseImpl & {
10
+ __abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGetLockRecordUseCase>;
11
+ };
12
+ export {};
@@ -0,0 +1,15 @@
1
+ import { GetLockRecordUseCase as UseCaseAbstraction, GetLockRecordRepository } from "./abstractions.js";
2
+ class GetLockRecordUseCaseImpl {
3
+ constructor(repository) {
4
+ this.repository = repository;
5
+ }
6
+ async execute(input) {
7
+ return await this.repository.get(input.id);
8
+ }
9
+ }
10
+ export const GetLockRecordUseCase = UseCaseAbstraction.createImplementation({
11
+ implementation: GetLockRecordUseCaseImpl,
12
+ dependencies: [GetLockRecordRepository]
13
+ });
14
+
15
+ //# sourceMappingURL=GetLockRecordUseCase.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["GetLockRecordUseCase","UseCaseAbstraction","GetLockRecordRepository","GetLockRecordUseCaseImpl","constructor","repository","execute","input","get","id","createImplementation","implementation","dependencies"],"sources":["GetLockRecordUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n GetLockRecordUseCase as UseCaseAbstraction,\n GetLockRecordRepository,\n GetLockRecordInput\n} from \"./abstractions.js\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\n\nclass GetLockRecordUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(private repository: GetLockRecordRepository.Interface) {}\n\n async execute(\n input: GetLockRecordInput\n ): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n return await this.repository.get(input.id);\n }\n}\n\nexport const GetLockRecordUseCase = UseCaseAbstraction.createImplementation({\n implementation: GetLockRecordUseCaseImpl,\n dependencies: [GetLockRecordRepository]\n});\n"],"mappings":"AACA,SACIA,oBAAoB,IAAIC,kBAAkB,EAC1CC,uBAAuB;AAK3B,MAAMC,wBAAwB,CAAyC;EACnEC,WAAWA,CAASC,UAA6C,EAAE;IAAA,KAA/CA,UAA6C,GAA7CA,UAA6C;EAAG;EAEpE,MAAMC,OAAOA,CACTC,KAAyB,EAC6B;IACtD,OAAO,MAAM,IAAI,CAACF,UAAU,CAACG,GAAG,CAACD,KAAK,CAACE,EAAE,CAAC;EAC9C;AACJ;AAEA,OAAO,MAAMT,oBAAoB,GAAGC,kBAAkB,CAACS,oBAAoB,CAAC;EACxEC,cAAc,EAAER,wBAAwB;EACxCS,YAAY,EAAE,CAACV,uBAAuB;AAC1C,CAAC,CAAC","ignoreList":[]}