@webiny/api-record-locking 0.0.0-unstable.6844005670 → 0.0.0-unstable.7be00a75a9

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 (170) hide show
  1. package/domain/LockRecord.js +63 -70
  2. package/domain/LockRecord.js.map +1 -1
  3. package/domain/RecordLockingModel.js +26 -23
  4. package/domain/RecordLockingModel.js.map +1 -1
  5. package/domain/abstractions.js +3 -7
  6. package/domain/abstractions.js.map +1 -1
  7. package/domain/calculateExpiresOn.js +5 -6
  8. package/domain/calculateExpiresOn.js.map +1 -1
  9. package/domain/errors.js +71 -81
  10. package/domain/errors.js.map +1 -1
  11. package/domain/index.js +0 -2
  12. package/domain/types.js +6 -9
  13. package/domain/types.js.map +1 -1
  14. package/features/GetLockRecord/GetLockRecordRepository.js +27 -24
  15. package/features/GetLockRecord/GetLockRecordRepository.js.map +1 -1
  16. package/features/GetLockRecord/GetLockRecordUseCase.js +13 -10
  17. package/features/GetLockRecord/GetLockRecordUseCase.js.map +1 -1
  18. package/features/GetLockRecord/abstractions.js +3 -14
  19. package/features/GetLockRecord/abstractions.js.map +1 -1
  20. package/features/GetLockRecord/feature.d.ts +4 -1
  21. package/features/GetLockRecord/feature.js +7 -6
  22. package/features/GetLockRecord/feature.js.map +1 -1
  23. package/features/GetLockRecord/index.js +0 -2
  24. package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.d.ts +1 -1
  25. package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js +20 -29
  26. package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js.map +1 -1
  27. package/features/GetLockedEntryLockRecord/abstractions.js +2 -10
  28. package/features/GetLockedEntryLockRecord/abstractions.js.map +1 -1
  29. package/features/GetLockedEntryLockRecord/feature.d.ts +4 -1
  30. package/features/GetLockedEntryLockRecord/feature.js +6 -5
  31. package/features/GetLockedEntryLockRecord/feature.js.map +1 -1
  32. package/features/GetLockedEntryLockRecord/index.js +0 -2
  33. package/features/IsEntryLocked/IsEntryLockedUseCase.d.ts +1 -1
  34. package/features/IsEntryLocked/IsEntryLockedUseCase.js +23 -29
  35. package/features/IsEntryLocked/IsEntryLockedUseCase.js.map +1 -1
  36. package/features/IsEntryLocked/abstractions.js +2 -9
  37. package/features/IsEntryLocked/abstractions.js.map +1 -1
  38. package/features/IsEntryLocked/feature.d.ts +4 -1
  39. package/features/IsEntryLocked/feature.js +6 -5
  40. package/features/IsEntryLocked/feature.js.map +1 -1
  41. package/features/IsEntryLocked/index.js +0 -2
  42. package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.d.ts +1 -1
  43. package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js +33 -33
  44. package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js.map +1 -1
  45. package/features/KickOutCurrentUser/abstractions.js +2 -6
  46. package/features/KickOutCurrentUser/abstractions.js.map +1 -1
  47. package/features/KickOutCurrentUser/feature.d.ts +4 -1
  48. package/features/KickOutCurrentUser/feature.js +6 -5
  49. package/features/KickOutCurrentUser/feature.js.map +1 -1
  50. package/features/KickOutCurrentUser/index.js +0 -2
  51. package/features/ListAllLockRecords/ListAllLockRecordsRepository.js +31 -31
  52. package/features/ListAllLockRecords/ListAllLockRecordsRepository.js.map +1 -1
  53. package/features/ListAllLockRecords/ListAllLockRecordsUseCase.js +13 -10
  54. package/features/ListAllLockRecords/ListAllLockRecordsUseCase.js.map +1 -1
  55. package/features/ListAllLockRecords/abstractions.js +3 -14
  56. package/features/ListAllLockRecords/abstractions.js.map +1 -1
  57. package/features/ListAllLockRecords/feature.d.ts +4 -1
  58. package/features/ListAllLockRecords/feature.js +7 -6
  59. package/features/ListAllLockRecords/feature.js.map +1 -1
  60. package/features/ListAllLockRecords/index.js +0 -2
  61. package/features/ListLockRecords/ListLockRecordsRepository.js +31 -31
  62. package/features/ListLockRecords/ListLockRecordsRepository.js.map +1 -1
  63. package/features/ListLockRecords/ListLockRecordsUseCase.d.ts +1 -1
  64. package/features/ListLockRecords/ListLockRecordsUseCase.js +27 -24
  65. package/features/ListLockRecords/ListLockRecordsUseCase.js.map +1 -1
  66. package/features/ListLockRecords/abstractions.js +3 -14
  67. package/features/ListLockRecords/abstractions.js.map +1 -1
  68. package/features/ListLockRecords/feature.d.ts +4 -1
  69. package/features/ListLockRecords/feature.js +7 -6
  70. package/features/ListLockRecords/feature.js.map +1 -1
  71. package/features/ListLockRecords/index.js +0 -2
  72. package/features/LockEntry/LockEntryEventsDecorator.d.ts +1 -1
  73. package/features/LockEntry/LockEntryEventsDecorator.js +32 -32
  74. package/features/LockEntry/LockEntryEventsDecorator.js.map +1 -1
  75. package/features/LockEntry/LockEntryRepository.js +33 -30
  76. package/features/LockEntry/LockEntryRepository.js.map +1 -1
  77. package/features/LockEntry/LockEntryUseCase.js +21 -26
  78. package/features/LockEntry/LockEntryUseCase.js.map +1 -1
  79. package/features/LockEntry/abstractions.js +3 -14
  80. package/features/LockEntry/abstractions.js.map +1 -1
  81. package/features/LockEntry/events.d.ts +8 -8
  82. package/features/LockEntry/events.js +26 -34
  83. package/features/LockEntry/events.js.map +1 -1
  84. package/features/LockEntry/feature.d.ts +4 -1
  85. package/features/LockEntry/feature.js +8 -7
  86. package/features/LockEntry/feature.js.map +1 -1
  87. package/features/LockEntry/index.js +0 -2
  88. package/features/RecordLockingFeature.d.ts +4 -1
  89. package/features/RecordLockingFeature.js +19 -21
  90. package/features/RecordLockingFeature.js.map +1 -1
  91. package/features/UnlockEntry/UnlockEntryEventsDecorator.d.ts +1 -1
  92. package/features/UnlockEntry/UnlockEntryEventsDecorator.js +33 -33
  93. package/features/UnlockEntry/UnlockEntryEventsDecorator.js.map +1 -1
  94. package/features/UnlockEntry/UnlockEntryRepository.js +29 -27
  95. package/features/UnlockEntry/UnlockEntryRepository.js.map +1 -1
  96. package/features/UnlockEntry/UnlockEntryUseCase.d.ts +1 -1
  97. package/features/UnlockEntry/UnlockEntryUseCase.js +54 -70
  98. package/features/UnlockEntry/UnlockEntryUseCase.js.map +1 -1
  99. package/features/UnlockEntry/abstractions.js +3 -14
  100. package/features/UnlockEntry/abstractions.js.map +1 -1
  101. package/features/UnlockEntry/events.d.ts +8 -8
  102. package/features/UnlockEntry/events.js +26 -34
  103. package/features/UnlockEntry/events.js.map +1 -1
  104. package/features/UnlockEntry/feature.d.ts +4 -1
  105. package/features/UnlockEntry/feature.js +8 -7
  106. package/features/UnlockEntry/feature.js.map +1 -1
  107. package/features/UnlockEntry/hasFullAccessPermission.d.ts +1 -1
  108. package/features/UnlockEntry/hasFullAccessPermission.js +6 -7
  109. package/features/UnlockEntry/hasFullAccessPermission.js.map +1 -1
  110. package/features/UnlockEntry/index.js +0 -2
  111. package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.d.ts +1 -1
  112. package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js +32 -32
  113. package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js.map +1 -1
  114. package/features/UnlockEntryRequest/UnlockEntryRequestRepository.d.ts +1 -1
  115. package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js +32 -31
  116. package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js.map +1 -1
  117. package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.d.ts +1 -1
  118. package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js +63 -80
  119. package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js.map +1 -1
  120. package/features/UnlockEntryRequest/abstractions.js +3 -14
  121. package/features/UnlockEntryRequest/abstractions.js.map +1 -1
  122. package/features/UnlockEntryRequest/events.d.ts +8 -8
  123. package/features/UnlockEntryRequest/events.js +26 -34
  124. package/features/UnlockEntryRequest/events.js.map +1 -1
  125. package/features/UnlockEntryRequest/feature.d.ts +4 -1
  126. package/features/UnlockEntryRequest/feature.js +8 -7
  127. package/features/UnlockEntryRequest/feature.js.map +1 -1
  128. package/features/UnlockEntryRequest/index.js +0 -2
  129. package/features/UpdateEntryLock/UpdateEntryLockRepository.d.ts +1 -1
  130. package/features/UpdateEntryLock/UpdateEntryLockRepository.js +46 -49
  131. package/features/UpdateEntryLock/UpdateEntryLockRepository.js.map +1 -1
  132. package/features/UpdateEntryLock/UpdateEntryLockUseCase.d.ts +1 -1
  133. package/features/UpdateEntryLock/UpdateEntryLockUseCase.js +41 -52
  134. package/features/UpdateEntryLock/UpdateEntryLockUseCase.js.map +1 -1
  135. package/features/UpdateEntryLock/abstractions.js +3 -14
  136. package/features/UpdateEntryLock/abstractions.js.map +1 -1
  137. package/features/UpdateEntryLock/feature.d.ts +4 -1
  138. package/features/UpdateEntryLock/feature.js +7 -6
  139. package/features/UpdateEntryLock/feature.js.map +1 -1
  140. package/features/UpdateEntryLock/index.js +0 -2
  141. package/graphql/checkPermissions.js +6 -10
  142. package/graphql/checkPermissions.js.map +1 -1
  143. package/graphql/resolve.js +15 -17
  144. package/graphql/resolve.js.map +1 -1
  145. package/graphql/schema.d.ts +2 -2
  146. package/graphql/schema.js +147 -168
  147. package/graphql/schema.js.map +1 -1
  148. package/index.d.ts +1 -1
  149. package/index.js +46 -48
  150. package/index.js.map +1 -1
  151. package/package.json +27 -22
  152. package/types.js +6 -9
  153. package/types.js.map +1 -1
  154. package/utils/convertWhereCondition.js +20 -32
  155. package/utils/convertWhereCondition.js.map +1 -1
  156. package/utils/getTimeout.js +8 -15
  157. package/utils/getTimeout.js.map +1 -1
  158. package/utils/lockRecordDatabaseId.js +6 -11
  159. package/utils/lockRecordDatabaseId.js.map +1 -1
  160. package/domain/index.js.map +0 -1
  161. package/features/GetLockRecord/index.js.map +0 -1
  162. package/features/GetLockedEntryLockRecord/index.js.map +0 -1
  163. package/features/IsEntryLocked/index.js.map +0 -1
  164. package/features/KickOutCurrentUser/index.js.map +0 -1
  165. package/features/ListAllLockRecords/index.js.map +0 -1
  166. package/features/ListLockRecords/index.js.map +0 -1
  167. package/features/LockEntry/index.js.map +0 -1
  168. package/features/UnlockEntry/index.js.map +0 -1
  169. package/features/UnlockEntryRequest/index.js.map +0 -1
  170. package/features/UpdateEntryLock/index.js.map +0 -1
@@ -10,27 +10,25 @@ import { LockEntryFeature } from "./LockEntry/feature.js";
10
10
  import { UpdateEntryLockFeature } from "./UpdateEntryLock/feature.js";
11
11
  import { UnlockEntryFeature } from "./UnlockEntry/feature.js";
12
12
  import { UnlockEntryRequestFeature } from "./UnlockEntryRequest/feature.js";
13
- export const RecordLockingFeature = createFeature({
14
- name: "RecordLockingManagement",
15
- register(container, params) {
16
- // Register domain abstractions
17
- container.registerInstance(RecordLockingConfig, {
18
- timeout: params.timeout
19
- });
20
- container.registerInstance(RecordLockingModel, params.model);
21
-
22
- // Register all sub-features
23
- GetLockRecordFeature.register(container);
24
- GetLockedEntryLockRecordFeature.register(container);
25
- KickOutCurrentUserFeature.register(container);
26
- ListLockRecordsFeature.register(container);
27
- ListAllLockRecordsFeature.register(container);
28
- IsEntryLockedFeature.register(container);
29
- LockEntryFeature.register(container);
30
- UpdateEntryLockFeature.register(container);
31
- UnlockEntryFeature.register(container);
32
- UnlockEntryRequestFeature.register(container);
33
- }
13
+ const RecordLockingFeature = createFeature({
14
+ name: "RecordLockingManagement",
15
+ register (container, params) {
16
+ container.registerInstance(RecordLockingConfig, {
17
+ timeout: params.timeout
18
+ });
19
+ container.registerInstance(RecordLockingModel, params.model);
20
+ GetLockRecordFeature.register(container);
21
+ GetLockedEntryLockRecordFeature.register(container);
22
+ KickOutCurrentUserFeature.register(container);
23
+ ListLockRecordsFeature.register(container);
24
+ ListAllLockRecordsFeature.register(container);
25
+ IsEntryLockedFeature.register(container);
26
+ LockEntryFeature.register(container);
27
+ UpdateEntryLockFeature.register(container);
28
+ UnlockEntryFeature.register(container);
29
+ UnlockEntryRequestFeature.register(container);
30
+ }
34
31
  });
32
+ export { RecordLockingFeature };
35
33
 
36
34
  //# sourceMappingURL=RecordLockingFeature.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createFeature","RecordLockingConfig","RecordLockingModel","GetLockRecordFeature","GetLockedEntryLockRecordFeature","KickOutCurrentUserFeature","ListLockRecordsFeature","ListAllLockRecordsFeature","IsEntryLockedFeature","LockEntryFeature","UpdateEntryLockFeature","UnlockEntryFeature","UnlockEntryRequestFeature","RecordLockingFeature","name","register","container","params","registerInstance","timeout","model"],"sources":["RecordLockingFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { RecordLockingConfig, RecordLockingModel } from \"~/domain/abstractions.js\";\nimport { GetLockRecordFeature } from \"./GetLockRecord/feature.js\";\nimport { GetLockedEntryLockRecordFeature } from \"./GetLockedEntryLockRecord/feature.js\";\nimport { KickOutCurrentUserFeature } from \"./KickOutCurrentUser/feature.js\";\nimport { ListLockRecordsFeature } from \"./ListLockRecords/feature.js\";\nimport { ListAllLockRecordsFeature } from \"./ListAllLockRecords/feature.js\";\nimport { IsEntryLockedFeature } from \"./IsEntryLocked/feature.js\";\nimport { LockEntryFeature } from \"./LockEntry/feature.js\";\nimport { UpdateEntryLockFeature } from \"./UpdateEntryLock/feature.js\";\nimport { UnlockEntryFeature } from \"./UnlockEntry/feature.js\";\nimport { UnlockEntryRequestFeature } from \"./UnlockEntryRequest/feature.js\";\n\nexport interface RecordLockingParams {\n /**\n * Timeout in milliseconds after which a lock expires\n */\n timeout: number;\n /**\n * The CMS model for storing lock records\n */\n model: CmsModel;\n}\n\nexport const RecordLockingFeature = createFeature({\n name: \"RecordLockingManagement\",\n register(container, params: RecordLockingParams) {\n // Register domain abstractions\n container.registerInstance(RecordLockingConfig, { timeout: params.timeout });\n container.registerInstance(RecordLockingModel, params.model);\n\n // Register all sub-features\n GetLockRecordFeature.register(container);\n GetLockedEntryLockRecordFeature.register(container);\n KickOutCurrentUserFeature.register(container);\n ListLockRecordsFeature.register(container);\n ListAllLockRecordsFeature.register(container);\n IsEntryLockedFeature.register(container);\n LockEntryFeature.register(container);\n UpdateEntryLockFeature.register(container);\n UnlockEntryFeature.register(container);\n UnlockEntryRequestFeature.register(container);\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AAEnD,SAASC,mBAAmB,EAAEC,kBAAkB;AAChD,SAASC,oBAAoB;AAC7B,SAASC,+BAA+B;AACxC,SAASC,yBAAyB;AAClC,SAASC,sBAAsB;AAC/B,SAASC,yBAAyB;AAClC,SAASC,oBAAoB;AAC7B,SAASC,gBAAgB;AACzB,SAASC,sBAAsB;AAC/B,SAASC,kBAAkB;AAC3B,SAASC,yBAAyB;AAalC,OAAO,MAAMC,oBAAoB,GAAGb,aAAa,CAAC;EAC9Cc,IAAI,EAAE,yBAAyB;EAC/BC,QAAQA,CAACC,SAAS,EAAEC,MAA2B,EAAE;IAC7C;IACAD,SAAS,CAACE,gBAAgB,CAACjB,mBAAmB,EAAE;MAAEkB,OAAO,EAAEF,MAAM,CAACE;IAAQ,CAAC,CAAC;IAC5EH,SAAS,CAACE,gBAAgB,CAAChB,kBAAkB,EAAEe,MAAM,CAACG,KAAK,CAAC;;IAE5D;IACAjB,oBAAoB,CAACY,QAAQ,CAACC,SAAS,CAAC;IACxCZ,+BAA+B,CAACW,QAAQ,CAACC,SAAS,CAAC;IACnDX,yBAAyB,CAACU,QAAQ,CAACC,SAAS,CAAC;IAC7CV,sBAAsB,CAACS,QAAQ,CAACC,SAAS,CAAC;IAC1CT,yBAAyB,CAACQ,QAAQ,CAACC,SAAS,CAAC;IAC7CR,oBAAoB,CAACO,QAAQ,CAACC,SAAS,CAAC;IACxCP,gBAAgB,CAACM,QAAQ,CAACC,SAAS,CAAC;IACpCN,sBAAsB,CAACK,QAAQ,CAACC,SAAS,CAAC;IAC1CL,kBAAkB,CAACI,QAAQ,CAACC,SAAS,CAAC;IACtCJ,yBAAyB,CAACG,QAAQ,CAACC,SAAS,CAAC;EACjD;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/RecordLockingFeature.js","sources":["../../src/features/RecordLockingFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { RecordLockingConfig, RecordLockingModel } from \"~/domain/abstractions.js\";\nimport { GetLockRecordFeature } from \"./GetLockRecord/feature.js\";\nimport { GetLockedEntryLockRecordFeature } from \"./GetLockedEntryLockRecord/feature.js\";\nimport { KickOutCurrentUserFeature } from \"./KickOutCurrentUser/feature.js\";\nimport { ListLockRecordsFeature } from \"./ListLockRecords/feature.js\";\nimport { ListAllLockRecordsFeature } from \"./ListAllLockRecords/feature.js\";\nimport { IsEntryLockedFeature } from \"./IsEntryLocked/feature.js\";\nimport { LockEntryFeature } from \"./LockEntry/feature.js\";\nimport { UpdateEntryLockFeature } from \"./UpdateEntryLock/feature.js\";\nimport { UnlockEntryFeature } from \"./UnlockEntry/feature.js\";\nimport { UnlockEntryRequestFeature } from \"./UnlockEntryRequest/feature.js\";\n\nexport interface RecordLockingParams {\n /**\n * Timeout in milliseconds after which a lock expires\n */\n timeout: number;\n /**\n * The CMS model for storing lock records\n */\n model: CmsModel;\n}\n\nexport const RecordLockingFeature = createFeature<RecordLockingParams>({\n name: \"RecordLockingManagement\",\n register(container, params) {\n // Register domain abstractions\n container.registerInstance(RecordLockingConfig, { timeout: params.timeout });\n container.registerInstance(RecordLockingModel, params.model);\n\n // Register all sub-features\n GetLockRecordFeature.register(container);\n GetLockedEntryLockRecordFeature.register(container);\n KickOutCurrentUserFeature.register(container);\n ListLockRecordsFeature.register(container);\n ListAllLockRecordsFeature.register(container);\n IsEntryLockedFeature.register(container);\n LockEntryFeature.register(container);\n UpdateEntryLockFeature.register(container);\n UnlockEntryFeature.register(container);\n UnlockEntryRequestFeature.register(container);\n }\n});\n"],"names":["RecordLockingFeature","createFeature","container","params","RecordLockingConfig","RecordLockingModel","GetLockRecordFeature","GetLockedEntryLockRecordFeature","KickOutCurrentUserFeature","ListLockRecordsFeature","ListAllLockRecordsFeature","IsEntryLockedFeature","LockEntryFeature","UpdateEntryLockFeature","UnlockEntryFeature","UnlockEntryRequestFeature"],"mappings":";;;;;;;;;;;;AAyBO,MAAMA,uBAAuBC,cAAmC;IACnE,MAAM;IACN,UAASC,SAAS,EAAEC,MAAM;QAEtBD,UAAU,gBAAgB,CAACE,qBAAqB;YAAE,SAASD,OAAO,OAAO;QAAC;QAC1ED,UAAU,gBAAgB,CAACG,oBAAoBF,OAAO,KAAK;QAG3DG,qBAAqB,QAAQ,CAACJ;QAC9BK,gCAAgC,QAAQ,CAACL;QACzCM,0BAA0B,QAAQ,CAACN;QACnCO,uBAAuB,QAAQ,CAACP;QAChCQ,0BAA0B,QAAQ,CAACR;QACnCS,qBAAqB,QAAQ,CAACT;QAC9BU,iBAAiB,QAAQ,CAACV;QAC1BW,uBAAuB,QAAQ,CAACX;QAChCY,mBAAmB,QAAQ,CAACZ;QAC5Ba,0BAA0B,QAAQ,CAACb;IACvC;AACJ"}
@@ -1,5 +1,5 @@
1
1
  import { type UnlockEntryInput, UnlockEntryUseCase as UseCaseAbstraction, UnlockEntryUseCase } from "./abstractions.js";
2
- import { EventPublisher } from "@webiny/api-core/features/EventPublisher";
2
+ import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
3
3
  import type { ILockRecord } from "../../domain/index.js";
4
4
  import { Result } from "@webiny/feature/api/index.js";
5
5
  declare class UnlockEntryEventsDecoratorImpl implements UnlockEntryUseCase.Interface {
@@ -1,41 +1,41 @@
1
1
  import { UnlockEntryUseCase } from "./abstractions.js";
2
- import { EventPublisher } from "@webiny/api-core/features/EventPublisher";
2
+ import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
3
3
  import { EntryAfterUnlockEvent, EntryBeforeUnlockEvent, EntryUnlockErrorEvent } from "./events.js";
4
4
  class UnlockEntryEventsDecoratorImpl {
5
- constructor(eventPublisher, decoratee) {
6
- this.eventPublisher = eventPublisher;
7
- this.decoratee = decoratee;
8
- }
9
- async execute(input) {
10
- // Publish before event
11
- await this.eventPublisher.publish(new EntryBeforeUnlockEvent({
12
- id: input.id,
13
- type: input.type,
14
- force: input.force
15
- }));
16
- const result = await this.decoratee.execute(input);
17
- if (result.isFail()) {
18
- const error = result.error;
19
- await this.eventPublisher.publish(new EntryUnlockErrorEvent({
20
- id: input.id,
21
- type: input.type,
22
- error
23
- }));
24
- return result;
5
+ constructor(eventPublisher, decoratee){
6
+ this.eventPublisher = eventPublisher;
7
+ this.decoratee = decoratee;
8
+ }
9
+ async execute(input) {
10
+ await this.eventPublisher.publish(new EntryBeforeUnlockEvent({
11
+ id: input.id,
12
+ type: input.type,
13
+ force: input.force
14
+ }));
15
+ const result = await this.decoratee.execute(input);
16
+ if (result.isFail()) {
17
+ const error = result.error;
18
+ await this.eventPublisher.publish(new EntryUnlockErrorEvent({
19
+ id: input.id,
20
+ type: input.type,
21
+ error
22
+ }));
23
+ return result;
24
+ }
25
+ await this.eventPublisher.publish(new EntryAfterUnlockEvent({
26
+ id: input.id,
27
+ type: input.type,
28
+ record: result.value
29
+ }));
30
+ return result;
25
31
  }
26
-
27
- // Publish after event
28
- await this.eventPublisher.publish(new EntryAfterUnlockEvent({
29
- id: input.id,
30
- type: input.type,
31
- record: result.value
32
- }));
33
- return result;
34
- }
35
32
  }
36
- export const UnlockEntryEventsDecorator = UnlockEntryUseCase.createDecorator({
37
- decorator: UnlockEntryEventsDecoratorImpl,
38
- dependencies: [EventPublisher]
33
+ const UnlockEntryEventsDecorator = UnlockEntryUseCase.createDecorator({
34
+ decorator: UnlockEntryEventsDecoratorImpl,
35
+ dependencies: [
36
+ EventPublisher
37
+ ]
39
38
  });
39
+ export { UnlockEntryEventsDecorator };
40
40
 
41
41
  //# sourceMappingURL=UnlockEntryEventsDecorator.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["UnlockEntryUseCase","EventPublisher","EntryAfterUnlockEvent","EntryBeforeUnlockEvent","EntryUnlockErrorEvent","UnlockEntryEventsDecoratorImpl","constructor","eventPublisher","decoratee","execute","input","publish","id","type","force","result","isFail","error","record","value","UnlockEntryEventsDecorator","createDecorator","decorator","dependencies"],"sources":["UnlockEntryEventsDecorator.ts"],"sourcesContent":["import {\n type UnlockEntryInput,\n UnlockEntryUseCase as UseCaseAbstraction,\n UnlockEntryUseCase\n} from \"./abstractions.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/EventPublisher\";\nimport type { ILockRecord } from \"~/domain/index.js\";\nimport { Result } from \"@webiny/feature/api/index.js\";\nimport { EntryAfterUnlockEvent, EntryBeforeUnlockEvent, EntryUnlockErrorEvent } from \"./events.js\";\n\nclass UnlockEntryEventsDecoratorImpl implements UnlockEntryUseCase.Interface {\n constructor(\n private readonly eventPublisher: EventPublisher.Interface,\n private readonly decoratee: UnlockEntryUseCase.Interface\n ) {}\n\n async execute(input: UnlockEntryInput): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Publish before event\n await this.eventPublisher.publish(\n new EntryBeforeUnlockEvent({\n id: input.id,\n type: input.type,\n force: input.force\n })\n );\n\n const result = await this.decoratee.execute(input);\n\n if (result.isFail()) {\n const error = result.error;\n\n await this.eventPublisher.publish(\n new EntryUnlockErrorEvent({\n id: input.id,\n type: input.type,\n error\n })\n );\n\n return result;\n }\n\n // Publish after event\n await this.eventPublisher.publish(\n new EntryAfterUnlockEvent({\n id: input.id,\n type: input.type,\n record: result.value\n })\n );\n\n return result;\n }\n}\n\nexport const UnlockEntryEventsDecorator = UnlockEntryUseCase.createDecorator({\n decorator: UnlockEntryEventsDecoratorImpl,\n dependencies: [EventPublisher]\n});\n"],"mappings":"AAAA,SAGIA,kBAAkB;AAEtB,SAASC,cAAc,QAAQ,0CAA0C;AAGzE,SAASC,qBAAqB,EAAEC,sBAAsB,EAAEC,qBAAqB;AAE7E,MAAMC,8BAA8B,CAAyC;EACzEC,WAAWA,CACUC,cAAwC,EACxCC,SAAuC,EAC1D;IAAA,KAFmBD,cAAwC,GAAxCA,cAAwC;IAAA,KACxCC,SAAuC,GAAvCA,SAAuC;EACzD;EAEH,MAAMC,OAAOA,CAACC,KAAuB,EAA0D;IAC3F;IACA,MAAM,IAAI,CAACH,cAAc,CAACI,OAAO,CAC7B,IAAIR,sBAAsB,CAAC;MACvBS,EAAE,EAAEF,KAAK,CAACE,EAAE;MACZC,IAAI,EAAEH,KAAK,CAACG,IAAI;MAChBC,KAAK,EAAEJ,KAAK,CAACI;IACjB,CAAC,CACL,CAAC;IAED,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACP,SAAS,CAACC,OAAO,CAACC,KAAK,CAAC;IAElD,IAAIK,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;MACjB,MAAMC,KAAK,GAAGF,MAAM,CAACE,KAAK;MAE1B,MAAM,IAAI,CAACV,cAAc,CAACI,OAAO,CAC7B,IAAIP,qBAAqB,CAAC;QACtBQ,EAAE,EAAEF,KAAK,CAACE,EAAE;QACZC,IAAI,EAAEH,KAAK,CAACG,IAAI;QAChBI;MACJ,CAAC,CACL,CAAC;MAED,OAAOF,MAAM;IACjB;;IAEA;IACA,MAAM,IAAI,CAACR,cAAc,CAACI,OAAO,CAC7B,IAAIT,qBAAqB,CAAC;MACtBU,EAAE,EAAEF,KAAK,CAACE,EAAE;MACZC,IAAI,EAAEH,KAAK,CAACG,IAAI;MAChBK,MAAM,EAAEH,MAAM,CAACI;IACnB,CAAC,CACL,CAAC;IAED,OAAOJ,MAAM;EACjB;AACJ;AAEA,OAAO,MAAMK,0BAA0B,GAAGpB,kBAAkB,CAACqB,eAAe,CAAC;EACzEC,SAAS,EAAEjB,8BAA8B;EACzCkB,YAAY,EAAE,CAACtB,cAAc;AACjC,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/UnlockEntry/UnlockEntryEventsDecorator.js","sources":["../../../src/features/UnlockEntry/UnlockEntryEventsDecorator.ts"],"sourcesContent":["import {\n type UnlockEntryInput,\n UnlockEntryUseCase as UseCaseAbstraction,\n UnlockEntryUseCase\n} from \"./abstractions.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { ILockRecord } from \"~/domain/index.js\";\nimport { Result } from \"@webiny/feature/api/index.js\";\nimport { EntryAfterUnlockEvent, EntryBeforeUnlockEvent, EntryUnlockErrorEvent } from \"./events.js\";\n\nclass UnlockEntryEventsDecoratorImpl implements UnlockEntryUseCase.Interface {\n constructor(\n private readonly eventPublisher: EventPublisher.Interface,\n private readonly decoratee: UnlockEntryUseCase.Interface\n ) {}\n\n async execute(input: UnlockEntryInput): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Publish before event\n await this.eventPublisher.publish(\n new EntryBeforeUnlockEvent({\n id: input.id,\n type: input.type,\n force: input.force\n })\n );\n\n const result = await this.decoratee.execute(input);\n\n if (result.isFail()) {\n const error = result.error;\n\n await this.eventPublisher.publish(\n new EntryUnlockErrorEvent({\n id: input.id,\n type: input.type,\n error\n })\n );\n\n return result;\n }\n\n // Publish after event\n await this.eventPublisher.publish(\n new EntryAfterUnlockEvent({\n id: input.id,\n type: input.type,\n record: result.value\n })\n );\n\n return result;\n }\n}\n\nexport const UnlockEntryEventsDecorator = UnlockEntryUseCase.createDecorator({\n decorator: UnlockEntryEventsDecoratorImpl,\n dependencies: [EventPublisher]\n});\n"],"names":["UnlockEntryEventsDecoratorImpl","eventPublisher","decoratee","input","EntryBeforeUnlockEvent","result","error","EntryUnlockErrorEvent","EntryAfterUnlockEvent","UnlockEntryEventsDecorator","UnlockEntryUseCase","EventPublisher"],"mappings":";;;AAUA,MAAMA;IACF,YACqBC,cAAwC,EACxCC,SAAuC,CAC1D;aAFmBD,cAAc,GAAdA;aACAC,SAAS,GAATA;IAClB;IAEH,MAAM,QAAQC,KAAuB,EAA0D;QAE3F,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIC,uBAAuB;YACvB,IAAID,MAAM,EAAE;YACZ,MAAMA,MAAM,IAAI;YAChB,OAAOA,MAAM,KAAK;QACtB;QAGJ,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACF;QAE5C,IAAIE,OAAO,MAAM,IAAI;YACjB,MAAMC,QAAQD,OAAO,KAAK;YAE1B,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIE,sBAAsB;gBACtB,IAAIJ,MAAM,EAAE;gBACZ,MAAMA,MAAM,IAAI;gBAChBG;YACJ;YAGJ,OAAOD;QACX;QAGA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIG,sBAAsB;YACtB,IAAIL,MAAM,EAAE;YACZ,MAAMA,MAAM,IAAI;YAChB,QAAQE,OAAO,KAAK;QACxB;QAGJ,OAAOA;IACX;AACJ;AAEO,MAAMI,6BAA6BC,mBAAmB,eAAe,CAAC;IACzE,WAAWV;IACX,cAAc;QAACW;KAAe;AAClC"}
@@ -1,40 +1,42 @@
1
1
  import { Result } from "@webiny/feature/api";
2
2
  import { DeleteEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/DeleteEntry";
3
3
  import { createIdentifier } from "@webiny/utils";
4
- import { UnlockEntryRepository as RepositoryAbstraction } from "./abstractions.js";
4
+ import { UnlockEntryRepository } from "./abstractions.js";
5
5
  import { RecordLockingModel } from "../../domain/abstractions.js";
6
6
  import { LockRecordNotFoundError, UnlockEntryError } from "../../domain/errors.js";
7
7
  import { createLockRecordDatabaseId } from "../../utils/lockRecordDatabaseId.js";
8
8
  class UnlockEntryRepositoryImpl {
9
- constructor(model, deleteEntry) {
10
- this.model = model;
11
- this.deleteEntry = deleteEntry;
12
- }
13
- async delete(lockRecordId) {
14
- try {
15
- const entryId = createLockRecordDatabaseId(lockRecordId);
16
- const id = createIdentifier({
17
- id: entryId,
18
- version: 1
19
- });
20
- const result = await this.deleteEntry.execute(this.model, id, {
21
- permanently: true
22
- });
23
- if (result.isFail()) {
24
- if (result.error.code === "Cms/Entry/NotFound") {
25
- return Result.fail(new LockRecordNotFoundError());
9
+ constructor(model, deleteEntry){
10
+ this.model = model;
11
+ this.deleteEntry = deleteEntry;
12
+ }
13
+ async delete(lockRecordId) {
14
+ try {
15
+ const entryId = createLockRecordDatabaseId(lockRecordId);
16
+ const id = createIdentifier({
17
+ id: entryId,
18
+ version: 1
19
+ });
20
+ const result = await this.deleteEntry.execute(this.model, id, {
21
+ permanently: true
22
+ });
23
+ if (result.isFail()) {
24
+ if ("Cms/Entry/NotFound" === result.error.code) return Result.fail(new LockRecordNotFoundError());
25
+ return Result.fail(new UnlockEntryError(result.error));
26
+ }
27
+ return Result.ok();
28
+ } catch (error) {
29
+ return Result.fail(new UnlockEntryError(error));
26
30
  }
27
- return Result.fail(new UnlockEntryError(result.error));
28
- }
29
- return Result.ok();
30
- } catch (error) {
31
- return Result.fail(new UnlockEntryError(error));
32
31
  }
33
- }
34
32
  }
35
- export const UnlockEntryRepository = RepositoryAbstraction.createImplementation({
36
- implementation: UnlockEntryRepositoryImpl,
37
- dependencies: [RecordLockingModel, DeleteEntryUseCase]
33
+ const UnlockEntryRepository_UnlockEntryRepository = UnlockEntryRepository.createImplementation({
34
+ implementation: UnlockEntryRepositoryImpl,
35
+ dependencies: [
36
+ RecordLockingModel,
37
+ DeleteEntryUseCase
38
+ ]
38
39
  });
40
+ export { UnlockEntryRepository_UnlockEntryRepository as UnlockEntryRepository };
39
41
 
40
42
  //# sourceMappingURL=UnlockEntryRepository.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Result","DeleteEntryUseCase","createIdentifier","UnlockEntryRepository","RepositoryAbstraction","RecordLockingModel","LockRecordNotFoundError","UnlockEntryError","createLockRecordDatabaseId","UnlockEntryRepositoryImpl","constructor","model","deleteEntry","delete","lockRecordId","entryId","id","version","result","execute","permanently","isFail","error","code","fail","ok","createImplementation","implementation","dependencies"],"sources":["UnlockEntryRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { DeleteEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/DeleteEntry\";\nimport { createIdentifier } from \"@webiny/utils\";\nimport { UnlockEntryRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { RecordLockingModel } from \"~/domain/abstractions.js\";\nimport { LockRecordNotFoundError, UnlockEntryError } from \"~/domain/errors.js\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId.js\";\n\nclass UnlockEntryRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private model: RecordLockingModel.Interface,\n private deleteEntry: DeleteEntryUseCase.Interface\n ) {}\n\n async delete(lockRecordId: string): Promise<Result<void, RepositoryAbstraction.Error>> {\n try {\n const entryId = createLockRecordDatabaseId(lockRecordId);\n const id = createIdentifier({\n id: entryId,\n version: 1\n });\n\n const result = await this.deleteEntry.execute(this.model, id, {\n permanently: true\n });\n\n if (result.isFail()) {\n if (result.error.code === \"Cms/Entry/NotFound\") {\n return Result.fail(new LockRecordNotFoundError());\n }\n return Result.fail(new UnlockEntryError(result.error));\n }\n\n return Result.ok();\n } catch (error) {\n return Result.fail(new UnlockEntryError(error as Error));\n }\n }\n}\n\nexport const UnlockEntryRepository = RepositoryAbstraction.createImplementation({\n implementation: UnlockEntryRepositoryImpl,\n dependencies: [RecordLockingModel, DeleteEntryUseCase]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,kBAAkB,QAAQ,4DAA4D;AAC/F,SAASC,gBAAgB,QAAQ,eAAe;AAChD,SAASC,qBAAqB,IAAIC,qBAAqB;AACvD,SAASC,kBAAkB;AAC3B,SAASC,uBAAuB,EAAEC,gBAAgB;AAClD,SAASC,0BAA0B;AAEnC,MAAMC,yBAAyB,CAA4C;EACvEC,WAAWA,CACCC,KAAmC,EACnCC,WAAyC,EACnD;IAAA,KAFUD,KAAmC,GAAnCA,KAAmC;IAAA,KACnCC,WAAyC,GAAzCA,WAAyC;EAClD;EAEH,MAAMC,MAAMA,CAACC,YAAoB,EAAsD;IACnF,IAAI;MACA,MAAMC,OAAO,GAAGP,0BAA0B,CAACM,YAAY,CAAC;MACxD,MAAME,EAAE,GAAGd,gBAAgB,CAAC;QACxBc,EAAE,EAAED,OAAO;QACXE,OAAO,EAAE;MACb,CAAC,CAAC;MAEF,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACN,WAAW,CAACO,OAAO,CAAC,IAAI,CAACR,KAAK,EAAEK,EAAE,EAAE;QAC1DI,WAAW,EAAE;MACjB,CAAC,CAAC;MAEF,IAAIF,MAAM,CAACG,MAAM,CAAC,CAAC,EAAE;QACjB,IAAIH,MAAM,CAACI,KAAK,CAACC,IAAI,KAAK,oBAAoB,EAAE;UAC5C,OAAOvB,MAAM,CAACwB,IAAI,CAAC,IAAIlB,uBAAuB,CAAC,CAAC,CAAC;QACrD;QACA,OAAON,MAAM,CAACwB,IAAI,CAAC,IAAIjB,gBAAgB,CAACW,MAAM,CAACI,KAAK,CAAC,CAAC;MAC1D;MAEA,OAAOtB,MAAM,CAACyB,EAAE,CAAC,CAAC;IACtB,CAAC,CAAC,OAAOH,KAAK,EAAE;MACZ,OAAOtB,MAAM,CAACwB,IAAI,CAAC,IAAIjB,gBAAgB,CAACe,KAAc,CAAC,CAAC;IAC5D;EACJ;AACJ;AAEA,OAAO,MAAMnB,qBAAqB,GAAGC,qBAAqB,CAACsB,oBAAoB,CAAC;EAC5EC,cAAc,EAAElB,yBAAyB;EACzCmB,YAAY,EAAE,CAACvB,kBAAkB,EAAEJ,kBAAkB;AACzD,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/UnlockEntry/UnlockEntryRepository.js","sources":["../../../src/features/UnlockEntry/UnlockEntryRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { DeleteEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/DeleteEntry\";\nimport { createIdentifier } from \"@webiny/utils\";\nimport { UnlockEntryRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { RecordLockingModel } from \"~/domain/abstractions.js\";\nimport { LockRecordNotFoundError, UnlockEntryError } from \"~/domain/errors.js\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId.js\";\n\nclass UnlockEntryRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private model: RecordLockingModel.Interface,\n private deleteEntry: DeleteEntryUseCase.Interface\n ) {}\n\n async delete(lockRecordId: string): Promise<Result<void, RepositoryAbstraction.Error>> {\n try {\n const entryId = createLockRecordDatabaseId(lockRecordId);\n const id = createIdentifier({\n id: entryId,\n version: 1\n });\n\n const result = await this.deleteEntry.execute(this.model, id, {\n permanently: true\n });\n\n if (result.isFail()) {\n if (result.error.code === \"Cms/Entry/NotFound\") {\n return Result.fail(new LockRecordNotFoundError());\n }\n return Result.fail(new UnlockEntryError(result.error));\n }\n\n return Result.ok();\n } catch (error) {\n return Result.fail(new UnlockEntryError(error as Error));\n }\n }\n}\n\nexport const UnlockEntryRepository = RepositoryAbstraction.createImplementation({\n implementation: UnlockEntryRepositoryImpl,\n dependencies: [RecordLockingModel, DeleteEntryUseCase]\n});\n"],"names":["UnlockEntryRepositoryImpl","model","deleteEntry","lockRecordId","entryId","createLockRecordDatabaseId","id","createIdentifier","result","Result","LockRecordNotFoundError","UnlockEntryError","error","UnlockEntryRepository","RepositoryAbstraction","RecordLockingModel","DeleteEntryUseCase"],"mappings":";;;;;;;AAQA,MAAMA;IACF,YACYC,KAAmC,EACnCC,WAAyC,CACnD;aAFUD,KAAK,GAALA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,OAAOC,YAAoB,EAAsD;QACnF,IAAI;YACA,MAAMC,UAAUC,2BAA2BF;YAC3C,MAAMG,KAAKC,iBAAiB;gBACxB,IAAIH;gBACJ,SAAS;YACb;YAEA,MAAMI,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAEF,IAAI;gBAC1D,aAAa;YACjB;YAEA,IAAIE,OAAO,MAAM,IAAI;gBACjB,IAAIA,AAAsB,yBAAtBA,OAAO,KAAK,CAAC,IAAI,EACjB,OAAOC,OAAO,IAAI,CAAC,IAAIC;gBAE3B,OAAOD,OAAO,IAAI,CAAC,IAAIE,iBAAiBH,OAAO,KAAK;YACxD;YAEA,OAAOC,OAAO,EAAE;QACpB,EAAE,OAAOG,OAAO;YACZ,OAAOH,OAAO,IAAI,CAAC,IAAIE,iBAAiBC;QAC5C;IACJ;AACJ;AAEO,MAAMC,8CAAwBC,sBAAAA,oBAA0C,CAAC;IAC5E,gBAAgBd;IAChB,cAAc;QAACe;QAAoBC;KAAmB;AAC1D"}
@@ -2,7 +2,7 @@ import { Result } from "@webiny/feature/api";
2
2
  import { UnlockEntryUseCase as UseCaseAbstraction, UnlockEntryRepository, UnlockEntryInput } from "./abstractions.js";
3
3
  import { GetLockRecordUseCase } from "../GetLockRecord/abstractions.js";
4
4
  import { KickOutCurrentUserUseCase } from "../KickOutCurrentUser/abstractions.js";
5
- import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
5
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
6
6
  import type { ILockRecord } from "../../domain/LockRecord.js";
7
7
  declare class UnlockEntryUseCaseImpl implements UseCaseAbstraction.Interface {
8
8
  private getLockRecord;
@@ -1,81 +1,65 @@
1
1
  import { Result } from "@webiny/feature/api";
2
- import { UnlockEntryUseCase as UseCaseAbstraction, UnlockEntryRepository } from "./abstractions.js";
2
+ import { UnlockEntryRepository, UnlockEntryUseCase } from "./abstractions.js";
3
3
  import { GetLockRecordUseCase } from "../GetLockRecord/abstractions.js";
4
4
  import { KickOutCurrentUserUseCase } from "../KickOutCurrentUser/abstractions.js";
5
- import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
6
- import { LockRecordNotFoundError, IdentityMismatchError } from "../../domain/errors.js";
5
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
6
+ import { IdentityMismatchError, LockRecordNotFoundError } from "../../domain/errors.js";
7
7
  import { hasFullAccessPermission } from "./hasFullAccessPermission.js";
8
8
  class UnlockEntryUseCaseImpl {
9
- constructor(getLockRecord, kickOutCurrentUser, repository, identityContext) {
10
- this.getLockRecord = getLockRecord;
11
- this.kickOutCurrentUser = kickOutCurrentUser;
12
- this.repository = repository;
13
- this.identityContext = identityContext;
14
- }
15
- async execute(input) {
16
- // Get the lock record
17
- const recordResult = await this.getLockRecord.execute(input);
18
-
19
- // If not found or expired, attempt cleanup and return error
20
- if (recordResult.isFail()) {
21
- if (recordResult.error instanceof LockRecordNotFoundError) {
22
- // Try to cleanup any stale data
23
- await this.repository.delete(input.id);
24
- }
25
- return Result.fail(recordResult.error);
26
- }
27
- const record = recordResult.value;
28
-
29
- // If expired, cleanup and return error
30
- if (record.isExpired()) {
31
- await this.repository.delete(record.id);
32
- const error = new LockRecordNotFoundError();
33
- return Result.fail(error);
34
- }
35
-
36
- // Check if user is the owner
37
- const identity = this.identityContext.getIdentity();
38
- const isSameUser = record.lockedBy.id === identity.id;
39
- let shouldKickOut = false;
40
-
41
- // If not the owner, check if force unlock is allowed
42
- if (!isSameUser) {
43
- if (!input.force) {
44
- const error = new IdentityMismatchError({
45
- currentId: identity.id,
46
- targetId: record.lockedBy.id
47
- });
48
- return Result.fail(error);
49
- }
50
-
51
- // Check if user has permission to force unlock
52
- const hasAccess = await hasFullAccessPermission(this.identityContext);
53
- if (!hasAccess) {
54
- const error = new IdentityMismatchError({
55
- currentId: identity.id,
56
- targetId: record.lockedBy.id
57
- });
58
- return Result.fail(error);
59
- }
60
- shouldKickOut = true;
9
+ constructor(getLockRecord, kickOutCurrentUser, repository, identityContext){
10
+ this.getLockRecord = getLockRecord;
11
+ this.kickOutCurrentUser = kickOutCurrentUser;
12
+ this.repository = repository;
13
+ this.identityContext = identityContext;
61
14
  }
62
-
63
- // Delete the lock record
64
- const deleteResult = await this.repository.delete(record.id);
65
- if (deleteResult.isFail()) {
66
- return Result.fail(deleteResult.error);
67
- }
68
-
69
- // If forced by another user, kick out the original lock owner
70
- if (shouldKickOut) {
71
- await this.kickOutCurrentUser.execute(record);
15
+ async execute(input) {
16
+ const recordResult = await this.getLockRecord.execute(input);
17
+ if (recordResult.isFail()) {
18
+ if (recordResult.error instanceof LockRecordNotFoundError) await this.repository.delete(input.id);
19
+ return Result.fail(recordResult.error);
20
+ }
21
+ const record = recordResult.value;
22
+ if (record.isExpired()) {
23
+ await this.repository.delete(record.id);
24
+ const error = new LockRecordNotFoundError();
25
+ return Result.fail(error);
26
+ }
27
+ const identity = this.identityContext.getIdentity();
28
+ const isSameUser = record.lockedBy.id === identity.id;
29
+ let shouldKickOut = false;
30
+ if (!isSameUser) {
31
+ if (!input.force) {
32
+ const error = new IdentityMismatchError({
33
+ currentId: identity.id,
34
+ targetId: record.lockedBy.id
35
+ });
36
+ return Result.fail(error);
37
+ }
38
+ const hasAccess = await hasFullAccessPermission(this.identityContext);
39
+ if (!hasAccess) {
40
+ const error = new IdentityMismatchError({
41
+ currentId: identity.id,
42
+ targetId: record.lockedBy.id
43
+ });
44
+ return Result.fail(error);
45
+ }
46
+ shouldKickOut = true;
47
+ }
48
+ const deleteResult = await this.repository.delete(record.id);
49
+ if (deleteResult.isFail()) return Result.fail(deleteResult.error);
50
+ if (shouldKickOut) await this.kickOutCurrentUser.execute(record);
51
+ return Result.ok(record);
72
52
  }
73
- return Result.ok(record);
74
- }
75
53
  }
76
- export const UnlockEntryUseCase = UseCaseAbstraction.createImplementation({
77
- implementation: UnlockEntryUseCaseImpl,
78
- dependencies: [GetLockRecordUseCase, KickOutCurrentUserUseCase, UnlockEntryRepository, IdentityContext]
54
+ const UnlockEntryUseCase_UnlockEntryUseCase = UnlockEntryUseCase.createImplementation({
55
+ implementation: UnlockEntryUseCaseImpl,
56
+ dependencies: [
57
+ GetLockRecordUseCase,
58
+ KickOutCurrentUserUseCase,
59
+ UnlockEntryRepository,
60
+ IdentityContext
61
+ ]
79
62
  });
63
+ export { UnlockEntryUseCase_UnlockEntryUseCase as UnlockEntryUseCase };
80
64
 
81
65
  //# sourceMappingURL=UnlockEntryUseCase.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Result","UnlockEntryUseCase","UseCaseAbstraction","UnlockEntryRepository","GetLockRecordUseCase","KickOutCurrentUserUseCase","IdentityContext","LockRecordNotFoundError","IdentityMismatchError","hasFullAccessPermission","UnlockEntryUseCaseImpl","constructor","getLockRecord","kickOutCurrentUser","repository","identityContext","execute","input","recordResult","isFail","error","delete","id","fail","record","value","isExpired","identity","getIdentity","isSameUser","lockedBy","shouldKickOut","force","currentId","targetId","hasAccess","deleteResult","ok","createImplementation","implementation","dependencies"],"sources":["UnlockEntryUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n UnlockEntryUseCase as UseCaseAbstraction,\n UnlockEntryRepository,\n UnlockEntryInput\n} from \"./abstractions.js\";\nimport { GetLockRecordUseCase } from \"../GetLockRecord/abstractions.js\";\nimport { KickOutCurrentUserUseCase } from \"../KickOutCurrentUser/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/IdentityContext\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport { LockRecordNotFoundError, IdentityMismatchError } from \"~/domain/errors.js\";\nimport { hasFullAccessPermission } from \"./hasFullAccessPermission.js\";\n\nclass UnlockEntryUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getLockRecord: GetLockRecordUseCase.Interface,\n private kickOutCurrentUser: KickOutCurrentUserUseCase.Interface,\n private repository: UnlockEntryRepository.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute(input: UnlockEntryInput): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Get the lock record\n const recordResult = await this.getLockRecord.execute(input);\n\n // If not found or expired, attempt cleanup and return error\n if (recordResult.isFail()) {\n if (recordResult.error instanceof LockRecordNotFoundError) {\n // Try to cleanup any stale data\n await this.repository.delete(input.id);\n }\n\n return Result.fail(recordResult.error);\n }\n\n const record = recordResult.value;\n\n // If expired, cleanup and return error\n if (record.isExpired()) {\n await this.repository.delete(record.id);\n const error = new LockRecordNotFoundError();\n return Result.fail(error);\n }\n\n // Check if user is the owner\n const identity = this.identityContext.getIdentity();\n const isSameUser = record.lockedBy.id === identity.id;\n\n let shouldKickOut = false;\n\n // If not the owner, check if force unlock is allowed\n if (!isSameUser) {\n if (!input.force) {\n const error = new IdentityMismatchError({\n currentId: identity.id,\n targetId: record.lockedBy.id\n });\n return Result.fail(error);\n }\n\n // Check if user has permission to force unlock\n const hasAccess = await hasFullAccessPermission(this.identityContext);\n if (!hasAccess) {\n const error = new IdentityMismatchError({\n currentId: identity.id,\n targetId: record.lockedBy.id\n });\n return Result.fail(error);\n }\n\n shouldKickOut = true;\n }\n\n // Delete the lock record\n const deleteResult = await this.repository.delete(record.id);\n\n if (deleteResult.isFail()) {\n return Result.fail(deleteResult.error);\n }\n\n // If forced by another user, kick out the original lock owner\n if (shouldKickOut) {\n await this.kickOutCurrentUser.execute(record);\n }\n\n return Result.ok(record);\n }\n}\n\nexport const UnlockEntryUseCase = UseCaseAbstraction.createImplementation({\n implementation: UnlockEntryUseCaseImpl,\n dependencies: [\n GetLockRecordUseCase,\n KickOutCurrentUserUseCase,\n UnlockEntryRepository,\n IdentityContext\n ]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SACIC,kBAAkB,IAAIC,kBAAkB,EACxCC,qBAAqB;AAGzB,SAASC,oBAAoB;AAC7B,SAASC,yBAAyB;AAClC,SAASC,eAAe,QAAQ,2CAA2C;AAE3E,SAASC,uBAAuB,EAAEC,qBAAqB;AACvD,SAASC,uBAAuB;AAEhC,MAAMC,sBAAsB,CAAyC;EACjEC,WAAWA,CACCC,aAA6C,EAC7CC,kBAAuD,EACvDC,UAA2C,EAC3CC,eAA0C,EACpD;IAAA,KAJUH,aAA6C,GAA7CA,aAA6C;IAAA,KAC7CC,kBAAuD,GAAvDA,kBAAuD;IAAA,KACvDC,UAA2C,GAA3CA,UAA2C;IAAA,KAC3CC,eAA0C,GAA1CA,eAA0C;EACnD;EAEH,MAAMC,OAAOA,CAACC,KAAuB,EAA0D;IAC3F;IACA,MAAMC,YAAY,GAAG,MAAM,IAAI,CAACN,aAAa,CAACI,OAAO,CAACC,KAAK,CAAC;;IAE5D;IACA,IAAIC,YAAY,CAACC,MAAM,CAAC,CAAC,EAAE;MACvB,IAAID,YAAY,CAACE,KAAK,YAAYb,uBAAuB,EAAE;QACvD;QACA,MAAM,IAAI,CAACO,UAAU,CAACO,MAAM,CAACJ,KAAK,CAACK,EAAE,CAAC;MAC1C;MAEA,OAAOtB,MAAM,CAACuB,IAAI,CAACL,YAAY,CAACE,KAAK,CAAC;IAC1C;IAEA,MAAMI,MAAM,GAAGN,YAAY,CAACO,KAAK;;IAEjC;IACA,IAAID,MAAM,CAACE,SAAS,CAAC,CAAC,EAAE;MACpB,MAAM,IAAI,CAACZ,UAAU,CAACO,MAAM,CAACG,MAAM,CAACF,EAAE,CAAC;MACvC,MAAMF,KAAK,GAAG,IAAIb,uBAAuB,CAAC,CAAC;MAC3C,OAAOP,MAAM,CAACuB,IAAI,CAACH,KAAK,CAAC;IAC7B;;IAEA;IACA,MAAMO,QAAQ,GAAG,IAAI,CAACZ,eAAe,CAACa,WAAW,CAAC,CAAC;IACnD,MAAMC,UAAU,GAAGL,MAAM,CAACM,QAAQ,CAACR,EAAE,KAAKK,QAAQ,CAACL,EAAE;IAErD,IAAIS,aAAa,GAAG,KAAK;;IAEzB;IACA,IAAI,CAACF,UAAU,EAAE;MACb,IAAI,CAACZ,KAAK,CAACe,KAAK,EAAE;QACd,MAAMZ,KAAK,GAAG,IAAIZ,qBAAqB,CAAC;UACpCyB,SAAS,EAAEN,QAAQ,CAACL,EAAE;UACtBY,QAAQ,EAAEV,MAAM,CAACM,QAAQ,CAACR;QAC9B,CAAC,CAAC;QACF,OAAOtB,MAAM,CAACuB,IAAI,CAACH,KAAK,CAAC;MAC7B;;MAEA;MACA,MAAMe,SAAS,GAAG,MAAM1B,uBAAuB,CAAC,IAAI,CAACM,eAAe,CAAC;MACrE,IAAI,CAACoB,SAAS,EAAE;QACZ,MAAMf,KAAK,GAAG,IAAIZ,qBAAqB,CAAC;UACpCyB,SAAS,EAAEN,QAAQ,CAACL,EAAE;UACtBY,QAAQ,EAAEV,MAAM,CAACM,QAAQ,CAACR;QAC9B,CAAC,CAAC;QACF,OAAOtB,MAAM,CAACuB,IAAI,CAACH,KAAK,CAAC;MAC7B;MAEAW,aAAa,GAAG,IAAI;IACxB;;IAEA;IACA,MAAMK,YAAY,GAAG,MAAM,IAAI,CAACtB,UAAU,CAACO,MAAM,CAACG,MAAM,CAACF,EAAE,CAAC;IAE5D,IAAIc,YAAY,CAACjB,MAAM,CAAC,CAAC,EAAE;MACvB,OAAOnB,MAAM,CAACuB,IAAI,CAACa,YAAY,CAAChB,KAAK,CAAC;IAC1C;;IAEA;IACA,IAAIW,aAAa,EAAE;MACf,MAAM,IAAI,CAAClB,kBAAkB,CAACG,OAAO,CAACQ,MAAM,CAAC;IACjD;IAEA,OAAOxB,MAAM,CAACqC,EAAE,CAACb,MAAM,CAAC;EAC5B;AACJ;AAEA,OAAO,MAAMvB,kBAAkB,GAAGC,kBAAkB,CAACoC,oBAAoB,CAAC;EACtEC,cAAc,EAAE7B,sBAAsB;EACtC8B,YAAY,EAAE,CACVpC,oBAAoB,EACpBC,yBAAyB,EACzBF,qBAAqB,EACrBG,eAAe;AAEvB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/UnlockEntry/UnlockEntryUseCase.js","sources":["../../../src/features/UnlockEntry/UnlockEntryUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n UnlockEntryUseCase as UseCaseAbstraction,\n UnlockEntryRepository,\n UnlockEntryInput\n} from \"./abstractions.js\";\nimport { GetLockRecordUseCase } from \"../GetLockRecord/abstractions.js\";\nimport { KickOutCurrentUserUseCase } from \"../KickOutCurrentUser/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport { LockRecordNotFoundError, IdentityMismatchError } from \"~/domain/errors.js\";\nimport { hasFullAccessPermission } from \"./hasFullAccessPermission.js\";\n\nclass UnlockEntryUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getLockRecord: GetLockRecordUseCase.Interface,\n private kickOutCurrentUser: KickOutCurrentUserUseCase.Interface,\n private repository: UnlockEntryRepository.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute(input: UnlockEntryInput): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Get the lock record\n const recordResult = await this.getLockRecord.execute(input);\n\n // If not found or expired, attempt cleanup and return error\n if (recordResult.isFail()) {\n if (recordResult.error instanceof LockRecordNotFoundError) {\n // Try to cleanup any stale data\n await this.repository.delete(input.id);\n }\n\n return Result.fail(recordResult.error);\n }\n\n const record = recordResult.value;\n\n // If expired, cleanup and return error\n if (record.isExpired()) {\n await this.repository.delete(record.id);\n const error = new LockRecordNotFoundError();\n return Result.fail(error);\n }\n\n // Check if user is the owner\n const identity = this.identityContext.getIdentity();\n const isSameUser = record.lockedBy.id === identity.id;\n\n let shouldKickOut = false;\n\n // If not the owner, check if force unlock is allowed\n if (!isSameUser) {\n if (!input.force) {\n const error = new IdentityMismatchError({\n currentId: identity.id,\n targetId: record.lockedBy.id\n });\n return Result.fail(error);\n }\n\n // Check if user has permission to force unlock\n const hasAccess = await hasFullAccessPermission(this.identityContext);\n if (!hasAccess) {\n const error = new IdentityMismatchError({\n currentId: identity.id,\n targetId: record.lockedBy.id\n });\n return Result.fail(error);\n }\n\n shouldKickOut = true;\n }\n\n // Delete the lock record\n const deleteResult = await this.repository.delete(record.id);\n\n if (deleteResult.isFail()) {\n return Result.fail(deleteResult.error);\n }\n\n // If forced by another user, kick out the original lock owner\n if (shouldKickOut) {\n await this.kickOutCurrentUser.execute(record);\n }\n\n return Result.ok(record);\n }\n}\n\nexport const UnlockEntryUseCase = UseCaseAbstraction.createImplementation({\n implementation: UnlockEntryUseCaseImpl,\n dependencies: [\n GetLockRecordUseCase,\n KickOutCurrentUserUseCase,\n UnlockEntryRepository,\n IdentityContext\n ]\n});\n"],"names":["UnlockEntryUseCaseImpl","getLockRecord","kickOutCurrentUser","repository","identityContext","input","recordResult","LockRecordNotFoundError","Result","record","error","identity","isSameUser","shouldKickOut","IdentityMismatchError","hasAccess","hasFullAccessPermission","deleteResult","UnlockEntryUseCase","UseCaseAbstraction","GetLockRecordUseCase","KickOutCurrentUserUseCase","UnlockEntryRepository","IdentityContext"],"mappings":";;;;;;;AAaA,MAAMA;IACF,YACYC,aAA6C,EAC7CC,kBAAuD,EACvDC,UAA2C,EAC3CC,eAA0C,CACpD;aAJUH,aAAa,GAAbA;aACAC,kBAAkB,GAAlBA;aACAC,UAAU,GAAVA;aACAC,eAAe,GAAfA;IACT;IAEH,MAAM,QAAQC,KAAuB,EAA0D;QAE3F,MAAMC,eAAe,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAACD;QAGtD,IAAIC,aAAa,MAAM,IAAI;YACvB,IAAIA,aAAa,KAAK,YAAYC,yBAE9B,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAACF,MAAM,EAAE;YAGzC,OAAOG,OAAO,IAAI,CAACF,aAAa,KAAK;QACzC;QAEA,MAAMG,SAASH,aAAa,KAAK;QAGjC,IAAIG,OAAO,SAAS,IAAI;YACpB,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAACA,OAAO,EAAE;YACtC,MAAMC,QAAQ,IAAIH;YAClB,OAAOC,OAAO,IAAI,CAACE;QACvB;QAGA,MAAMC,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;QACjD,MAAMC,aAAaH,OAAO,QAAQ,CAAC,EAAE,KAAKE,SAAS,EAAE;QAErD,IAAIE,gBAAgB;QAGpB,IAAI,CAACD,YAAY;YACb,IAAI,CAACP,MAAM,KAAK,EAAE;gBACd,MAAMK,QAAQ,IAAII,sBAAsB;oBACpC,WAAWH,SAAS,EAAE;oBACtB,UAAUF,OAAO,QAAQ,CAAC,EAAE;gBAChC;gBACA,OAAOD,OAAO,IAAI,CAACE;YACvB;YAGA,MAAMK,YAAY,MAAMC,wBAAwB,IAAI,CAAC,eAAe;YACpE,IAAI,CAACD,WAAW;gBACZ,MAAML,QAAQ,IAAII,sBAAsB;oBACpC,WAAWH,SAAS,EAAE;oBACtB,UAAUF,OAAO,QAAQ,CAAC,EAAE;gBAChC;gBACA,OAAOD,OAAO,IAAI,CAACE;YACvB;YAEAG,gBAAgB;QACpB;QAGA,MAAMI,eAAe,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAACR,OAAO,EAAE;QAE3D,IAAIQ,aAAa,MAAM,IACnB,OAAOT,OAAO,IAAI,CAACS,aAAa,KAAK;QAIzC,IAAIJ,eACA,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAACJ;QAG1C,OAAOD,OAAO,EAAE,CAACC;IACrB;AACJ;AAEO,MAAMS,wCAAqBC,mBAAAA,oBAAuC,CAAC;IACtE,gBAAgBnB;IAChB,cAAc;QACVoB;QACAC;QACAC;QACAC;KACH;AACL"}
@@ -1,17 +1,6 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
-
3
- // Input types
4
-
5
- /**
6
- * UnlockEntry Use Case - Unlocks an entry by deleting the lock record
7
- */
8
-
9
- export const UnlockEntryUseCase = createAbstraction("UnlockEntryUseCase");
10
-
11
- /**
12
- * UnlockEntryRepository - Deletes lock record from storage
13
- */
14
-
15
- export const UnlockEntryRepository = createAbstraction("UnlockEntryRepository");
2
+ const UnlockEntryUseCase = createAbstraction("UnlockEntryUseCase");
3
+ const UnlockEntryRepository = createAbstraction("UnlockEntryRepository");
4
+ export { UnlockEntryRepository, UnlockEntryUseCase };
16
5
 
17
6
  //# sourceMappingURL=abstractions.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","UnlockEntryUseCase","UnlockEntryRepository"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordEntryType } from \"~/domain/types.js\";\nimport {\n type LockRecordNotFoundError,\n LockRecordPersistenceError,\n type IdentityMismatchError,\n type UnlockEntryError\n} from \"~/domain/errors.js\";\n\n// Input types\nexport interface UnlockEntryInput {\n id: string;\n type: LockRecordEntryType;\n force?: boolean;\n}\n\n/**\n * UnlockEntry Use Case - Unlocks an entry by deleting the lock record\n */\nexport interface IUnlockEntryUseCase {\n execute(input: UnlockEntryInput): Promise<Result<ILockRecord, UseCaseError>>;\n}\n\nexport interface IUnlockEntryUseCaseErrors {\n notFound: LockRecordNotFoundError;\n notSameIdentity: IdentityMismatchError;\n unlockError: UnlockEntryError;\n persistence: LockRecordPersistenceError;\n}\n\ntype UseCaseError = IUnlockEntryUseCaseErrors[keyof IUnlockEntryUseCaseErrors];\n\nexport const UnlockEntryUseCase = createAbstraction<IUnlockEntryUseCase>(\"UnlockEntryUseCase\");\n\nexport namespace UnlockEntryUseCase {\n export type Interface = IUnlockEntryUseCase;\n export type Error = UseCaseError;\n}\n\n/**\n * UnlockEntryRepository - Deletes lock record from storage\n */\nexport interface IUnlockEntryRepository {\n delete(lockRecordId: string): Promise<Result<void, RepositoryError>>;\n}\n\nexport interface IUnlockEntryRepositoryErrors {\n notFound: LockRecordNotFoundError;\n unlockError: UnlockEntryError;\n}\n\ntype RepositoryError = IUnlockEntryRepositoryErrors[keyof IUnlockEntryRepositoryErrors];\n\nexport const UnlockEntryRepository =\n createAbstraction<IUnlockEntryRepository>(\"UnlockEntryRepository\");\n\nexport namespace UnlockEntryRepository {\n export type Interface = IUnlockEntryRepository;\n export type Error = RepositoryError;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAWvD;;AAOA;AACA;AACA;;AAcA,OAAO,MAAMC,kBAAkB,GAAGD,iBAAiB,CAAsB,oBAAoB,CAAC;;AAO9F;AACA;AACA;;AAYA,OAAO,MAAME,qBAAqB,GAC9BF,iBAAiB,CAAyB,uBAAuB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/UnlockEntry/abstractions.js","sources":["../../../src/features/UnlockEntry/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordEntryType } from \"~/domain/types.js\";\nimport {\n type LockRecordNotFoundError,\n LockRecordPersistenceError,\n type IdentityMismatchError,\n type UnlockEntryError\n} from \"~/domain/errors.js\";\n\n// Input types\nexport interface UnlockEntryInput {\n id: string;\n type: LockRecordEntryType;\n force?: boolean;\n}\n\n/**\n * UnlockEntry Use Case - Unlocks an entry by deleting the lock record\n */\nexport interface IUnlockEntryUseCase {\n execute(input: UnlockEntryInput): Promise<Result<ILockRecord, UseCaseError>>;\n}\n\nexport interface IUnlockEntryUseCaseErrors {\n notFound: LockRecordNotFoundError;\n notSameIdentity: IdentityMismatchError;\n unlockError: UnlockEntryError;\n persistence: LockRecordPersistenceError;\n}\n\ntype UseCaseError = IUnlockEntryUseCaseErrors[keyof IUnlockEntryUseCaseErrors];\n\nexport const UnlockEntryUseCase = createAbstraction<IUnlockEntryUseCase>(\"UnlockEntryUseCase\");\n\nexport namespace UnlockEntryUseCase {\n export type Interface = IUnlockEntryUseCase;\n export type Error = UseCaseError;\n}\n\n/**\n * UnlockEntryRepository - Deletes lock record from storage\n */\nexport interface IUnlockEntryRepository {\n delete(lockRecordId: string): Promise<Result<void, RepositoryError>>;\n}\n\nexport interface IUnlockEntryRepositoryErrors {\n notFound: LockRecordNotFoundError;\n unlockError: UnlockEntryError;\n}\n\ntype RepositoryError = IUnlockEntryRepositoryErrors[keyof IUnlockEntryRepositoryErrors];\n\nexport const UnlockEntryRepository =\n createAbstraction<IUnlockEntryRepository>(\"UnlockEntryRepository\");\n\nexport namespace UnlockEntryRepository {\n export type Interface = IUnlockEntryRepository;\n export type Error = RepositoryError;\n}\n"],"names":["UnlockEntryUseCase","createAbstraction","UnlockEntryRepository"],"mappings":";AAkCO,MAAMA,qBAAqBC,kBAAuC;AAqBlE,MAAMC,wBACTD,kBAA0C"}
@@ -1,5 +1,5 @@
1
- import { DomainEvent } from "@webiny/api-core/features/EventPublisher";
2
- import type { IEventHandler } from "@webiny/api-core/features/EventPublisher";
1
+ import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
2
+ import type { IEventHandler } from "@webiny/api-core/features/eventPublisher/index.js";
3
3
  import type { ILockRecord } from "../../domain/LockRecord.js";
4
4
  import type { LockRecordEntryType } from "../../domain/types.js";
5
5
  export interface EntryBeforeUnlockPayload {
@@ -11,8 +11,8 @@ export declare class EntryBeforeUnlockEvent extends DomainEvent<EntryBeforeUnloc
11
11
  eventType: "RecordLocking/Entry/BeforeUnlock";
12
12
  getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryBeforeUnlockEvent>>;
13
13
  }
14
- export declare const EntryBeforeUnlockHandler: import("@webiny/di").Abstraction<IEventHandler<EntryBeforeUnlockEvent>>;
15
- export declare namespace EntryBeforeUnlockHandler {
14
+ export declare const EntryBeforeUnlockEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryBeforeUnlockEvent>>;
15
+ export declare namespace EntryBeforeUnlockEventHandler {
16
16
  type Interface = IEventHandler<EntryBeforeUnlockEvent>;
17
17
  type Event = EntryBeforeUnlockEvent;
18
18
  }
@@ -25,8 +25,8 @@ export declare class EntryAfterUnlockEvent extends DomainEvent<EntryAfterUnlockP
25
25
  eventType: "RecordLocking/Entry/AfterUnlock";
26
26
  getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryAfterUnlockEvent>>;
27
27
  }
28
- export declare const EntryAfterUnlockHandler: import("@webiny/di").Abstraction<IEventHandler<EntryAfterUnlockEvent>>;
29
- export declare namespace EntryAfterUnlockHandler {
28
+ export declare const EntryAfterUnlockEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryAfterUnlockEvent>>;
29
+ export declare namespace EntryAfterUnlockEventHandler {
30
30
  type Interface = IEventHandler<EntryAfterUnlockEvent>;
31
31
  type Event = EntryAfterUnlockEvent;
32
32
  }
@@ -39,8 +39,8 @@ export declare class EntryUnlockErrorEvent extends DomainEvent<EntryUnlockErrorP
39
39
  eventType: "RecordLocking/Entry/UnlockError";
40
40
  getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryUnlockErrorEvent>>;
41
41
  }
42
- export declare const EntryUnlockErrorHandler: import("@webiny/di").Abstraction<IEventHandler<EntryUnlockErrorEvent>>;
43
- export declare namespace EntryUnlockErrorHandler {
42
+ export declare const EntryUnlockErrorEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryUnlockErrorEvent>>;
43
+ export declare namespace EntryUnlockErrorEventHandler {
44
44
  type Interface = IEventHandler<EntryUnlockErrorEvent>;
45
45
  type Event = EntryUnlockErrorEvent;
46
46
  }
@@ -1,40 +1,32 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
- import { DomainEvent } from "@webiny/api-core/features/EventPublisher";
3
-
4
- // ============================================================================
5
- // EntryBeforeUnlock Event
6
- // ============================================================================
7
-
8
- export class EntryBeforeUnlockEvent extends DomainEvent {
9
- eventType = "RecordLocking/Entry/BeforeUnlock";
10
- getHandlerAbstraction() {
11
- return EntryBeforeUnlockHandler;
12
- }
2
+ import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
3
+ class EntryBeforeUnlockEvent extends DomainEvent {
4
+ getHandlerAbstraction() {
5
+ return EntryBeforeUnlockEventHandler;
6
+ }
7
+ constructor(...args){
8
+ super(...args), this.eventType = "RecordLocking/Entry/BeforeUnlock";
9
+ }
13
10
  }
14
- export const EntryBeforeUnlockHandler = createAbstraction("EntryBeforeUnlockHandler");
15
-
16
- // ============================================================================
17
- // EntryAfterUnlock Event
18
- // ============================================================================
19
-
20
- export class EntryAfterUnlockEvent extends DomainEvent {
21
- eventType = "RecordLocking/Entry/AfterUnlock";
22
- getHandlerAbstraction() {
23
- return EntryAfterUnlockHandler;
24
- }
11
+ const EntryBeforeUnlockEventHandler = createAbstraction("EntryBeforeUnlockEventHandler");
12
+ class EntryAfterUnlockEvent extends DomainEvent {
13
+ getHandlerAbstraction() {
14
+ return EntryAfterUnlockEventHandler;
15
+ }
16
+ constructor(...args){
17
+ super(...args), this.eventType = "RecordLocking/Entry/AfterUnlock";
18
+ }
25
19
  }
26
- export const EntryAfterUnlockHandler = createAbstraction("EntryAfterUnlockHandler");
27
-
28
- // ============================================================================
29
- // EntryUnlockError Event
30
- // ============================================================================
31
-
32
- export class EntryUnlockErrorEvent extends DomainEvent {
33
- eventType = "RecordLocking/Entry/UnlockError";
34
- getHandlerAbstraction() {
35
- return EntryUnlockErrorHandler;
36
- }
20
+ const EntryAfterUnlockEventHandler = createAbstraction("EntryAfterUnlockEventHandler");
21
+ class EntryUnlockErrorEvent extends DomainEvent {
22
+ getHandlerAbstraction() {
23
+ return EntryUnlockErrorEventHandler;
24
+ }
25
+ constructor(...args){
26
+ super(...args), this.eventType = "RecordLocking/Entry/UnlockError";
27
+ }
37
28
  }
38
- export const EntryUnlockErrorHandler = createAbstraction("EntryUnlockErrorHandler");
29
+ const EntryUnlockErrorEventHandler = createAbstraction("EntryUnlockErrorEventHandler");
30
+ export { EntryAfterUnlockEvent, EntryAfterUnlockEventHandler, EntryBeforeUnlockEvent, EntryBeforeUnlockEventHandler, EntryUnlockErrorEvent, EntryUnlockErrorEventHandler };
39
31
 
40
32
  //# sourceMappingURL=events.js.map