@webiny/api-record-locking 0.0.0-unstable.c27f4d8a31 → 0.0.0-unstable.d0f34a8194

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 (187) hide show
  1. package/RecordLockingAppFeature.d.ts +11 -0
  2. package/RecordLockingAppFeature.js +20 -0
  3. package/RecordLockingAppFeature.js.map +1 -0
  4. package/domain/LockRecord.js +63 -70
  5. package/domain/LockRecord.js.map +1 -1
  6. package/domain/RecordLockingModel.js +27 -23
  7. package/domain/RecordLockingModel.js.map +1 -1
  8. package/domain/abstractions.d.ts +9 -3
  9. package/domain/abstractions.js +3 -7
  10. package/domain/abstractions.js.map +1 -1
  11. package/domain/calculateExpiresOn.js +5 -6
  12. package/domain/calculateExpiresOn.js.map +1 -1
  13. package/domain/errors.js +71 -81
  14. package/domain/errors.js.map +1 -1
  15. package/domain/index.js +0 -2
  16. package/domain/types.js +6 -9
  17. package/domain/types.js.map +1 -1
  18. package/features/GetLockRecord/GetLockRecordRepository.d.ts +4 -3
  19. package/features/GetLockRecord/GetLockRecordRepository.js +33 -25
  20. package/features/GetLockRecord/GetLockRecordRepository.js.map +1 -1
  21. package/features/GetLockRecord/GetLockRecordUseCase.js +13 -10
  22. package/features/GetLockRecord/GetLockRecordUseCase.js.map +1 -1
  23. package/features/GetLockRecord/abstractions.js +3 -14
  24. package/features/GetLockRecord/abstractions.js.map +1 -1
  25. package/features/GetLockRecord/feature.d.ts +4 -1
  26. package/features/GetLockRecord/feature.js +7 -6
  27. package/features/GetLockRecord/feature.js.map +1 -1
  28. package/features/GetLockRecord/index.js +0 -2
  29. package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.d.ts +1 -1
  30. package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js +20 -29
  31. package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js.map +1 -1
  32. package/features/GetLockedEntryLockRecord/abstractions.js +2 -10
  33. package/features/GetLockedEntryLockRecord/abstractions.js.map +1 -1
  34. package/features/GetLockedEntryLockRecord/feature.d.ts +4 -1
  35. package/features/GetLockedEntryLockRecord/feature.js +6 -5
  36. package/features/GetLockedEntryLockRecord/feature.js.map +1 -1
  37. package/features/GetLockedEntryLockRecord/index.js +0 -2
  38. package/features/IsEntryLocked/IsEntryLockedUseCase.d.ts +1 -1
  39. package/features/IsEntryLocked/IsEntryLockedUseCase.js +23 -29
  40. package/features/IsEntryLocked/IsEntryLockedUseCase.js.map +1 -1
  41. package/features/IsEntryLocked/abstractions.js +2 -9
  42. package/features/IsEntryLocked/abstractions.js.map +1 -1
  43. package/features/IsEntryLocked/feature.d.ts +4 -1
  44. package/features/IsEntryLocked/feature.js +6 -5
  45. package/features/IsEntryLocked/feature.js.map +1 -1
  46. package/features/IsEntryLocked/index.js +0 -2
  47. package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.d.ts +4 -4
  48. package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js +28 -34
  49. package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js.map +1 -1
  50. package/features/KickOutCurrentUser/abstractions.js +2 -6
  51. package/features/KickOutCurrentUser/abstractions.js.map +1 -1
  52. package/features/KickOutCurrentUser/feature.d.ts +4 -1
  53. package/features/KickOutCurrentUser/feature.js +6 -5
  54. package/features/KickOutCurrentUser/feature.js.map +1 -1
  55. package/features/KickOutCurrentUser/index.js +0 -2
  56. package/features/ListAllLockRecords/ListAllLockRecordsRepository.d.ts +5 -3
  57. package/features/ListAllLockRecords/ListAllLockRecordsRepository.js +39 -32
  58. package/features/ListAllLockRecords/ListAllLockRecordsRepository.js.map +1 -1
  59. package/features/ListAllLockRecords/ListAllLockRecordsUseCase.js +13 -10
  60. package/features/ListAllLockRecords/ListAllLockRecordsUseCase.js.map +1 -1
  61. package/features/ListAllLockRecords/abstractions.js +3 -14
  62. package/features/ListAllLockRecords/abstractions.js.map +1 -1
  63. package/features/ListAllLockRecords/feature.d.ts +4 -1
  64. package/features/ListAllLockRecords/feature.js +7 -6
  65. package/features/ListAllLockRecords/feature.js.map +1 -1
  66. package/features/ListAllLockRecords/index.js +0 -2
  67. package/features/ListLockRecords/ListLockRecordsRepository.d.ts +6 -3
  68. package/features/ListLockRecords/ListLockRecordsRepository.js +39 -32
  69. package/features/ListLockRecords/ListLockRecordsRepository.js.map +1 -1
  70. package/features/ListLockRecords/ListLockRecordsUseCase.d.ts +1 -1
  71. package/features/ListLockRecords/ListLockRecordsUseCase.js +27 -24
  72. package/features/ListLockRecords/ListLockRecordsUseCase.js.map +1 -1
  73. package/features/ListLockRecords/abstractions.js +3 -14
  74. package/features/ListLockRecords/abstractions.js.map +1 -1
  75. package/features/ListLockRecords/feature.d.ts +4 -1
  76. package/features/ListLockRecords/feature.js +7 -6
  77. package/features/ListLockRecords/feature.js.map +1 -1
  78. package/features/ListLockRecords/index.js +0 -2
  79. package/features/LockEntry/LockEntryEventsDecorator.d.ts +1 -1
  80. package/features/LockEntry/LockEntryEventsDecorator.js +32 -32
  81. package/features/LockEntry/LockEntryEventsDecorator.js.map +1 -1
  82. package/features/LockEntry/LockEntryRepository.d.ts +4 -3
  83. package/features/LockEntry/LockEntryRepository.js +35 -31
  84. package/features/LockEntry/LockEntryRepository.js.map +1 -1
  85. package/features/LockEntry/LockEntryUseCase.js +21 -26
  86. package/features/LockEntry/LockEntryUseCase.js.map +1 -1
  87. package/features/LockEntry/abstractions.js +3 -14
  88. package/features/LockEntry/abstractions.js.map +1 -1
  89. package/features/LockEntry/events.d.ts +2 -2
  90. package/features/LockEntry/events.js +26 -34
  91. package/features/LockEntry/events.js.map +1 -1
  92. package/features/LockEntry/feature.d.ts +4 -1
  93. package/features/LockEntry/feature.js +8 -7
  94. package/features/LockEntry/feature.js.map +1 -1
  95. package/features/LockEntry/index.js +0 -2
  96. package/features/RecordLockingFeature.d.ts +4 -6
  97. package/features/RecordLockingFeature.js +21 -22
  98. package/features/RecordLockingFeature.js.map +1 -1
  99. package/features/RecordLockingModelProvider.d.ts +18 -0
  100. package/features/RecordLockingModelProvider.js +22 -0
  101. package/features/RecordLockingModelProvider.js.map +1 -0
  102. package/features/UnlockEntry/UnlockEntryEventsDecorator.d.ts +1 -1
  103. package/features/UnlockEntry/UnlockEntryEventsDecorator.js +33 -33
  104. package/features/UnlockEntry/UnlockEntryEventsDecorator.js.map +1 -1
  105. package/features/UnlockEntry/UnlockEntryRepository.d.ts +3 -3
  106. package/features/UnlockEntry/UnlockEntryRepository.js +31 -28
  107. package/features/UnlockEntry/UnlockEntryRepository.js.map +1 -1
  108. package/features/UnlockEntry/UnlockEntryUseCase.d.ts +1 -1
  109. package/features/UnlockEntry/UnlockEntryUseCase.js +54 -70
  110. package/features/UnlockEntry/UnlockEntryUseCase.js.map +1 -1
  111. package/features/UnlockEntry/abstractions.js +3 -14
  112. package/features/UnlockEntry/abstractions.js.map +1 -1
  113. package/features/UnlockEntry/events.d.ts +2 -2
  114. package/features/UnlockEntry/events.js +26 -34
  115. package/features/UnlockEntry/events.js.map +1 -1
  116. package/features/UnlockEntry/feature.d.ts +4 -1
  117. package/features/UnlockEntry/feature.js +8 -7
  118. package/features/UnlockEntry/feature.js.map +1 -1
  119. package/features/UnlockEntry/hasFullAccessPermission.d.ts +1 -1
  120. package/features/UnlockEntry/hasFullAccessPermission.js +6 -7
  121. package/features/UnlockEntry/hasFullAccessPermission.js.map +1 -1
  122. package/features/UnlockEntry/index.js +0 -2
  123. package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.d.ts +1 -1
  124. package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js +32 -32
  125. package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js.map +1 -1
  126. package/features/UnlockEntryRequest/UnlockEntryRequestRepository.d.ts +4 -4
  127. package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js +34 -32
  128. package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js.map +1 -1
  129. package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.d.ts +1 -1
  130. package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js +63 -80
  131. package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js.map +1 -1
  132. package/features/UnlockEntryRequest/abstractions.js +3 -14
  133. package/features/UnlockEntryRequest/abstractions.js.map +1 -1
  134. package/features/UnlockEntryRequest/events.d.ts +2 -2
  135. package/features/UnlockEntryRequest/events.js +26 -34
  136. package/features/UnlockEntryRequest/events.js.map +1 -1
  137. package/features/UnlockEntryRequest/feature.d.ts +4 -1
  138. package/features/UnlockEntryRequest/feature.js +8 -7
  139. package/features/UnlockEntryRequest/feature.js.map +1 -1
  140. package/features/UnlockEntryRequest/index.js +0 -2
  141. package/features/UpdateEntryLock/UpdateEntryLockRepository.d.ts +5 -4
  142. package/features/UpdateEntryLock/UpdateEntryLockRepository.js +48 -50
  143. package/features/UpdateEntryLock/UpdateEntryLockRepository.js.map +1 -1
  144. package/features/UpdateEntryLock/UpdateEntryLockUseCase.d.ts +1 -1
  145. package/features/UpdateEntryLock/UpdateEntryLockUseCase.js +41 -52
  146. package/features/UpdateEntryLock/UpdateEntryLockUseCase.js.map +1 -1
  147. package/features/UpdateEntryLock/abstractions.js +3 -14
  148. package/features/UpdateEntryLock/abstractions.js.map +1 -1
  149. package/features/UpdateEntryLock/feature.d.ts +4 -1
  150. package/features/UpdateEntryLock/feature.js +7 -6
  151. package/features/UpdateEntryLock/feature.js.map +1 -1
  152. package/features/UpdateEntryLock/index.js +0 -2
  153. package/graphql/RecordLockingGraphQLSchema.d.ts +25 -0
  154. package/graphql/RecordLockingGraphQLSchema.js +390 -0
  155. package/graphql/RecordLockingGraphQLSchema.js.map +1 -0
  156. package/graphql/checkPermissions.d.ts +3 -3
  157. package/graphql/checkPermissions.js +4 -10
  158. package/graphql/checkPermissions.js.map +1 -1
  159. package/graphql/resolve.d.ts +1 -1
  160. package/graphql/resolve.js +16 -18
  161. package/graphql/resolve.js.map +1 -1
  162. package/index.d.ts +2 -9
  163. package/index.js +1 -62
  164. package/package.json +27 -22
  165. package/types.js +6 -9
  166. package/types.js.map +1 -1
  167. package/utils/convertWhereCondition.js +20 -32
  168. package/utils/convertWhereCondition.js.map +1 -1
  169. package/utils/getTimeout.js +8 -15
  170. package/utils/getTimeout.js.map +1 -1
  171. package/utils/lockRecordDatabaseId.js +6 -11
  172. package/utils/lockRecordDatabaseId.js.map +1 -1
  173. package/domain/index.js.map +0 -1
  174. package/features/GetLockRecord/index.js.map +0 -1
  175. package/features/GetLockedEntryLockRecord/index.js.map +0 -1
  176. package/features/IsEntryLocked/index.js.map +0 -1
  177. package/features/KickOutCurrentUser/index.js.map +0 -1
  178. package/features/ListAllLockRecords/index.js.map +0 -1
  179. package/features/ListLockRecords/index.js.map +0 -1
  180. package/features/LockEntry/index.js.map +0 -1
  181. package/features/UnlockEntry/index.js.map +0 -1
  182. package/features/UnlockEntryRequest/index.js.map +0 -1
  183. package/features/UpdateEntryLock/index.js.map +0 -1
  184. package/graphql/schema.d.ts +0 -11
  185. package/graphql/schema.js +0 -318
  186. package/graphql/schema.js.map +0 -1
  187. package/index.js.map +0 -1
@@ -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 {
@@ -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 EntryBeforeUnlockEventHandler;
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 EntryBeforeUnlockEventHandler = createAbstraction("EntryBeforeUnlockEventHandler");
15
-
16
- // ============================================================================
17
- // EntryAfterUnlock Event
18
- // ============================================================================
19
-
20
- export class EntryAfterUnlockEvent extends DomainEvent {
21
- eventType = "RecordLocking/Entry/AfterUnlock";
22
- getHandlerAbstraction() {
23
- return EntryAfterUnlockEventHandler;
24
- }
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 EntryAfterUnlockEventHandler = createAbstraction("EntryAfterUnlockEventHandler");
27
-
28
- // ============================================================================
29
- // EntryUnlockError Event
30
- // ============================================================================
31
-
32
- export class EntryUnlockErrorEvent extends DomainEvent {
33
- eventType = "RecordLocking/Entry/UnlockError";
34
- getHandlerAbstraction() {
35
- return EntryUnlockErrorEventHandler;
36
- }
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 EntryUnlockErrorEventHandler = createAbstraction("EntryUnlockErrorEventHandler");
29
+ const EntryUnlockErrorEventHandler = createAbstraction("EntryUnlockErrorEventHandler");
30
+ export { EntryAfterUnlockEvent, EntryAfterUnlockEventHandler, EntryBeforeUnlockEvent, EntryBeforeUnlockEventHandler, EntryUnlockErrorEvent, EntryUnlockErrorEventHandler };
39
31
 
40
32
  //# sourceMappingURL=events.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","DomainEvent","EntryBeforeUnlockEvent","eventType","getHandlerAbstraction","EntryBeforeUnlockEventHandler","EntryAfterUnlockEvent","EntryAfterUnlockEventHandler","EntryUnlockErrorEvent","EntryUnlockErrorEventHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"@webiny/api-core/features/EventPublisher\";\nimport type { IEventHandler } from \"@webiny/api-core/features/EventPublisher\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordEntryType } from \"~/domain/types.js\";\n\n// ============================================================================\n// EntryBeforeUnlock Event\n// ============================================================================\n\nexport interface EntryBeforeUnlockPayload {\n id: string;\n type: LockRecordEntryType;\n force?: boolean;\n}\n\nexport class EntryBeforeUnlockEvent extends DomainEvent<EntryBeforeUnlockPayload> {\n eventType = \"RecordLocking/Entry/BeforeUnlock\" as const;\n\n getHandlerAbstraction() {\n return EntryBeforeUnlockEventHandler;\n }\n}\n\nexport const EntryBeforeUnlockEventHandler = createAbstraction<\n IEventHandler<EntryBeforeUnlockEvent>\n>(\"EntryBeforeUnlockEventHandler\");\n\nexport namespace EntryBeforeUnlockEventHandler {\n export type Interface = IEventHandler<EntryBeforeUnlockEvent>;\n export type Event = EntryBeforeUnlockEvent;\n}\n\n// ============================================================================\n// EntryAfterUnlock Event\n// ============================================================================\n\nexport interface EntryAfterUnlockPayload {\n id: string;\n type: LockRecordEntryType;\n record: ILockRecord;\n}\n\nexport class EntryAfterUnlockEvent extends DomainEvent<EntryAfterUnlockPayload> {\n eventType = \"RecordLocking/Entry/AfterUnlock\" as const;\n\n getHandlerAbstraction() {\n return EntryAfterUnlockEventHandler;\n }\n}\n\nexport const EntryAfterUnlockEventHandler = createAbstraction<IEventHandler<EntryAfterUnlockEvent>>(\n \"EntryAfterUnlockEventHandler\"\n);\n\nexport namespace EntryAfterUnlockEventHandler {\n export type Interface = IEventHandler<EntryAfterUnlockEvent>;\n export type Event = EntryAfterUnlockEvent;\n}\n\n// ============================================================================\n// EntryUnlockError Event\n// ============================================================================\n\nexport interface EntryUnlockErrorPayload {\n id: string;\n type: LockRecordEntryType;\n error: Error;\n}\n\nexport class EntryUnlockErrorEvent extends DomainEvent<EntryUnlockErrorPayload> {\n eventType = \"RecordLocking/Entry/UnlockError\" as const;\n\n getHandlerAbstraction() {\n return EntryUnlockErrorEventHandler;\n }\n}\n\nexport const EntryUnlockErrorEventHandler = createAbstraction<IEventHandler<EntryUnlockErrorEvent>>(\n \"EntryUnlockErrorEventHandler\"\n);\n\nexport namespace EntryUnlockErrorEventHandler {\n export type Interface = IEventHandler<EntryUnlockErrorEvent>;\n export type Event = EntryUnlockErrorEvent;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW,QAAQ,0CAA0C;;AAKtE;AACA;AACA;;AAQA,OAAO,MAAMC,sBAAsB,SAASD,WAAW,CAA2B;EAC9EE,SAAS,GAAG,kCAAkC;EAE9CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,6BAA6B;EACxC;AACJ;AAEA,OAAO,MAAMA,6BAA6B,GAAGL,iBAAiB,CAE5D,+BAA+B,CAAC;;AAOlC;AACA;AACA;;AAQA,OAAO,MAAMM,qBAAqB,SAASL,WAAW,CAA0B;EAC5EE,SAAS,GAAG,iCAAiC;EAE7CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,4BAA4B;EACvC;AACJ;AAEA,OAAO,MAAMA,4BAA4B,GAAGP,iBAAiB,CACzD,8BACJ,CAAC;;AAOD;AACA;AACA;;AAQA,OAAO,MAAMQ,qBAAqB,SAASP,WAAW,CAA0B;EAC5EE,SAAS,GAAG,iCAAiC;EAE7CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOK,4BAA4B;EACvC;AACJ;AAEA,OAAO,MAAMA,4BAA4B,GAAGT,iBAAiB,CACzD,8BACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/UnlockEntry/events.js","sources":["../../../src/features/UnlockEntry/events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordEntryType } from \"~/domain/types.js\";\n\n// ============================================================================\n// EntryBeforeUnlock Event\n// ============================================================================\n\nexport interface EntryBeforeUnlockPayload {\n id: string;\n type: LockRecordEntryType;\n force?: boolean;\n}\n\nexport class EntryBeforeUnlockEvent extends DomainEvent<EntryBeforeUnlockPayload> {\n eventType = \"RecordLocking/Entry/BeforeUnlock\" as const;\n\n getHandlerAbstraction() {\n return EntryBeforeUnlockEventHandler;\n }\n}\n\nexport const EntryBeforeUnlockEventHandler = createAbstraction<\n IEventHandler<EntryBeforeUnlockEvent>\n>(\"EntryBeforeUnlockEventHandler\");\n\nexport namespace EntryBeforeUnlockEventHandler {\n export type Interface = IEventHandler<EntryBeforeUnlockEvent>;\n export type Event = EntryBeforeUnlockEvent;\n}\n\n// ============================================================================\n// EntryAfterUnlock Event\n// ============================================================================\n\nexport interface EntryAfterUnlockPayload {\n id: string;\n type: LockRecordEntryType;\n record: ILockRecord;\n}\n\nexport class EntryAfterUnlockEvent extends DomainEvent<EntryAfterUnlockPayload> {\n eventType = \"RecordLocking/Entry/AfterUnlock\" as const;\n\n getHandlerAbstraction() {\n return EntryAfterUnlockEventHandler;\n }\n}\n\nexport const EntryAfterUnlockEventHandler = createAbstraction<IEventHandler<EntryAfterUnlockEvent>>(\n \"EntryAfterUnlockEventHandler\"\n);\n\nexport namespace EntryAfterUnlockEventHandler {\n export type Interface = IEventHandler<EntryAfterUnlockEvent>;\n export type Event = EntryAfterUnlockEvent;\n}\n\n// ============================================================================\n// EntryUnlockError Event\n// ============================================================================\n\nexport interface EntryUnlockErrorPayload {\n id: string;\n type: LockRecordEntryType;\n error: Error;\n}\n\nexport class EntryUnlockErrorEvent extends DomainEvent<EntryUnlockErrorPayload> {\n eventType = \"RecordLocking/Entry/UnlockError\" as const;\n\n getHandlerAbstraction() {\n return EntryUnlockErrorEventHandler;\n }\n}\n\nexport const EntryUnlockErrorEventHandler = createAbstraction<IEventHandler<EntryUnlockErrorEvent>>(\n \"EntryUnlockErrorEventHandler\"\n);\n\nexport namespace EntryUnlockErrorEventHandler {\n export type Interface = IEventHandler<EntryUnlockErrorEvent>;\n export type Event = EntryUnlockErrorEvent;\n}\n"],"names":["EntryBeforeUnlockEvent","DomainEvent","EntryBeforeUnlockEventHandler","createAbstraction","EntryAfterUnlockEvent","EntryAfterUnlockEventHandler","EntryUnlockErrorEvent","EntryUnlockErrorEventHandler"],"mappings":";;AAgBO,MAAMA,+BAA+BC;IAGxC,wBAAwB;QACpB,OAAOC;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB;AAEO,MAAMA,gCAAgCC,kBAE3C;AAiBK,MAAMC,8BAA8BH;IAGvC,wBAAwB;QACpB,OAAOI;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB;AAEO,MAAMA,+BAA+BF,kBACxC;AAkBG,MAAMG,8BAA8BL;IAGvC,wBAAwB;QACpB,OAAOM;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB;AAEO,MAAMA,+BAA+BJ,kBACxC"}
@@ -1 +1,4 @@
1
- export declare const UnlockEntryFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
1
+ export declare const UnlockEntryFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -2,13 +2,14 @@ import { createFeature } from "@webiny/feature/api";
2
2
  import { UnlockEntryUseCase } from "./UnlockEntryUseCase.js";
3
3
  import { UnlockEntryRepository } from "./UnlockEntryRepository.js";
4
4
  import { UnlockEntryEventsDecorator } from "./UnlockEntryEventsDecorator.js";
5
- export const UnlockEntryFeature = createFeature({
6
- name: "UnlockEntry",
7
- register(container) {
8
- container.register(UnlockEntryUseCase);
9
- container.register(UnlockEntryRepository).inSingletonScope();
10
- container.registerDecorator(UnlockEntryEventsDecorator);
11
- }
5
+ const UnlockEntryFeature = createFeature({
6
+ name: "UnlockEntry",
7
+ register (container) {
8
+ container.register(UnlockEntryUseCase);
9
+ container.register(UnlockEntryRepository).inSingletonScope();
10
+ container.registerDecorator(UnlockEntryEventsDecorator);
11
+ }
12
12
  });
13
+ export { UnlockEntryFeature };
13
14
 
14
15
  //# sourceMappingURL=feature.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createFeature","UnlockEntryUseCase","UnlockEntryRepository","UnlockEntryEventsDecorator","UnlockEntryFeature","name","register","container","inSingletonScope","registerDecorator"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { UnlockEntryUseCase } from \"./UnlockEntryUseCase.js\";\nimport { UnlockEntryRepository } from \"./UnlockEntryRepository.js\";\nimport { UnlockEntryEventsDecorator } from \"./UnlockEntryEventsDecorator.js\";\n\nexport const UnlockEntryFeature = createFeature({\n name: \"UnlockEntry\",\n register(container) {\n container.register(UnlockEntryUseCase);\n container.register(UnlockEntryRepository).inSingletonScope();\n container.registerDecorator(UnlockEntryEventsDecorator);\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,kBAAkB;AAC3B,SAASC,qBAAqB;AAC9B,SAASC,0BAA0B;AAEnC,OAAO,MAAMC,kBAAkB,GAAGJ,aAAa,CAAC;EAC5CK,IAAI,EAAE,aAAa;EACnBC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACL,kBAAkB,CAAC;IACtCM,SAAS,CAACD,QAAQ,CAACJ,qBAAqB,CAAC,CAACM,gBAAgB,CAAC,CAAC;IAC5DD,SAAS,CAACE,iBAAiB,CAACN,0BAA0B,CAAC;EAC3D;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/UnlockEntry/feature.js","sources":["../../../src/features/UnlockEntry/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { UnlockEntryUseCase } from \"./UnlockEntryUseCase.js\";\nimport { UnlockEntryRepository } from \"./UnlockEntryRepository.js\";\nimport { UnlockEntryEventsDecorator } from \"./UnlockEntryEventsDecorator.js\";\n\nexport const UnlockEntryFeature = createFeature({\n name: \"UnlockEntry\",\n register(container) {\n container.register(UnlockEntryUseCase);\n container.register(UnlockEntryRepository).inSingletonScope();\n container.registerDecorator(UnlockEntryEventsDecorator);\n }\n});\n"],"names":["UnlockEntryFeature","createFeature","container","UnlockEntryUseCase","UnlockEntryRepository","UnlockEntryEventsDecorator"],"mappings":";;;;AAKO,MAAMA,qBAAqBC,cAAc;IAC5C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,uBAAuB,gBAAgB;QAC1DF,UAAU,iBAAiB,CAACG;IAChC;AACJ"}
@@ -1,2 +1,2 @@
1
- import type { IdentityContext } from "@webiny/api-core/features/IdentityContext";
1
+ import type { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
2
2
  export declare const hasFullAccessPermission: (identityContext: IdentityContext.Interface) => Promise<boolean>;
@@ -1,10 +1,9 @@
1
- export const hasFullAccessPermission = async identityContext => {
2
- const hasFullAccess = await identityContext.hasFullAccess();
3
- if (hasFullAccess) {
4
- return true;
5
- }
6
- const permission = await identityContext.getPermission("recordLocking");
7
- return permission?.canForceUnlock === true;
1
+ const hasFullAccessPermission = async (identityContext)=>{
2
+ const hasFullAccess = await identityContext.hasFullAccess();
3
+ if (hasFullAccess) return true;
4
+ const permission = await identityContext.getPermission("recordLocking");
5
+ return permission?.canForceUnlock === true;
8
6
  };
7
+ export { hasFullAccessPermission };
9
8
 
10
9
  //# sourceMappingURL=hasFullAccessPermission.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["hasFullAccessPermission","identityContext","hasFullAccess","permission","getPermission","canForceUnlock"],"sources":["hasFullAccessPermission.ts"],"sourcesContent":["import type { IdentityContext } from \"@webiny/api-core/features/IdentityContext\";\nimport type { SecurityPermission } from \"@webiny/api-core/types/security.js\";\n\ninterface RecordLockingSecurityPermission extends SecurityPermission {\n canForceUnlock?: boolean;\n}\n\nexport const hasFullAccessPermission = async (\n identityContext: IdentityContext.Interface\n): Promise<boolean> => {\n const hasFullAccess = await identityContext.hasFullAccess();\n if (hasFullAccess) {\n return true;\n }\n\n const permission =\n await identityContext.getPermission<RecordLockingSecurityPermission>(\"recordLocking\");\n return permission?.canForceUnlock === true;\n};\n"],"mappings":"AAOA,OAAO,MAAMA,uBAAuB,GAAG,MACnCC,eAA0C,IACvB;EACnB,MAAMC,aAAa,GAAG,MAAMD,eAAe,CAACC,aAAa,CAAC,CAAC;EAC3D,IAAIA,aAAa,EAAE;IACf,OAAO,IAAI;EACf;EAEA,MAAMC,UAAU,GACZ,MAAMF,eAAe,CAACG,aAAa,CAAkC,eAAe,CAAC;EACzF,OAAOD,UAAU,EAAEE,cAAc,KAAK,IAAI;AAC9C,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/UnlockEntry/hasFullAccessPermission.js","sources":["../../../src/features/UnlockEntry/hasFullAccessPermission.ts"],"sourcesContent":["import type { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type { SecurityPermission } from \"@webiny/api-core/types/security.js\";\n\ninterface RecordLockingSecurityPermission extends SecurityPermission {\n canForceUnlock?: boolean;\n}\n\nexport const hasFullAccessPermission = async (\n identityContext: IdentityContext.Interface\n): Promise<boolean> => {\n const hasFullAccess = await identityContext.hasFullAccess();\n if (hasFullAccess) {\n return true;\n }\n\n const permission =\n await identityContext.getPermission<RecordLockingSecurityPermission>(\"recordLocking\");\n return permission?.canForceUnlock === true;\n};\n"],"names":["hasFullAccessPermission","identityContext","hasFullAccess","permission"],"mappings":"AAOO,MAAMA,0BAA0B,OACnCC;IAEA,MAAMC,gBAAgB,MAAMD,gBAAgB,aAAa;IACzD,IAAIC,eACA,OAAO;IAGX,MAAMC,aACF,MAAMF,gBAAgB,aAAa,CAAkC;IACzE,OAAOE,YAAY,mBAAmB;AAC1C"}
@@ -1,3 +1 @@
1
1
  export * from "./abstractions.js";
2
-
3
- //# sourceMappingURL=index.js.map
@@ -1,5 +1,5 @@
1
1
  import { type UnlockEntryRequestInput, UnlockEntryRequestUseCase as UseCaseAbstraction, UnlockEntryRequestUseCase } 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 UnlockEntryRequestEventsDecoratorImpl implements UnlockEntryRequestUseCase.Interface {
@@ -1,40 +1,40 @@
1
1
  import { UnlockEntryRequestUseCase } 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 { EntryAfterUnlockRequestEvent, EntryBeforeUnlockRequestEvent, EntryUnlockRequestErrorEvent } from "./events.js";
4
4
  class UnlockEntryRequestEventsDecoratorImpl {
5
- constructor(eventPublisher, decoratee) {
6
- this.eventPublisher = eventPublisher;
7
- this.decoratee = decoratee;
8
- }
9
- async execute(input) {
10
- // Publish before event
11
- await this.eventPublisher.publish(new EntryBeforeUnlockRequestEvent({
12
- id: input.id,
13
- type: input.type
14
- }));
15
- const result = await this.decoratee.execute(input);
16
- if (result.isFail()) {
17
- const error = result.error;
18
- await this.eventPublisher.publish(new EntryUnlockRequestErrorEvent({
19
- id: input.id,
20
- type: input.type,
21
- error
22
- }));
23
- return result;
5
+ constructor(eventPublisher, decoratee){
6
+ this.eventPublisher = eventPublisher;
7
+ this.decoratee = decoratee;
8
+ }
9
+ async execute(input) {
10
+ await this.eventPublisher.publish(new EntryBeforeUnlockRequestEvent({
11
+ id: input.id,
12
+ type: input.type
13
+ }));
14
+ const result = await this.decoratee.execute(input);
15
+ if (result.isFail()) {
16
+ const error = result.error;
17
+ await this.eventPublisher.publish(new EntryUnlockRequestErrorEvent({
18
+ id: input.id,
19
+ type: input.type,
20
+ error
21
+ }));
22
+ return result;
23
+ }
24
+ await this.eventPublisher.publish(new EntryAfterUnlockRequestEvent({
25
+ id: input.id,
26
+ type: input.type,
27
+ record: result.value
28
+ }));
29
+ return result;
24
30
  }
25
-
26
- // Publish after event
27
- await this.eventPublisher.publish(new EntryAfterUnlockRequestEvent({
28
- id: input.id,
29
- type: input.type,
30
- record: result.value
31
- }));
32
- return result;
33
- }
34
31
  }
35
- export const UnlockEntryRequestEventsDecorator = UnlockEntryRequestUseCase.createDecorator({
36
- decorator: UnlockEntryRequestEventsDecoratorImpl,
37
- dependencies: [EventPublisher]
32
+ const UnlockEntryRequestEventsDecorator = UnlockEntryRequestUseCase.createDecorator({
33
+ decorator: UnlockEntryRequestEventsDecoratorImpl,
34
+ dependencies: [
35
+ EventPublisher
36
+ ]
38
37
  });
38
+ export { UnlockEntryRequestEventsDecorator };
39
39
 
40
40
  //# sourceMappingURL=UnlockEntryRequestEventsDecorator.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["UnlockEntryRequestUseCase","EventPublisher","EntryAfterUnlockRequestEvent","EntryBeforeUnlockRequestEvent","EntryUnlockRequestErrorEvent","UnlockEntryRequestEventsDecoratorImpl","constructor","eventPublisher","decoratee","execute","input","publish","id","type","result","isFail","error","record","value","UnlockEntryRequestEventsDecorator","createDecorator","decorator","dependencies"],"sources":["UnlockEntryRequestEventsDecorator.ts"],"sourcesContent":["import {\n type UnlockEntryRequestInput,\n UnlockEntryRequestUseCase as UseCaseAbstraction,\n UnlockEntryRequestUseCase\n} from \"./abstractions.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/EventPublisher\";\nimport type { ILockRecord } from \"~/domain/index.js\";\nimport { Result } from \"@webiny/feature/api/index.js\";\nimport {\n EntryAfterUnlockRequestEvent,\n EntryBeforeUnlockRequestEvent,\n EntryUnlockRequestErrorEvent\n} from \"./events.js\";\n\nclass UnlockEntryRequestEventsDecoratorImpl implements UnlockEntryRequestUseCase.Interface {\n constructor(\n private readonly eventPublisher: EventPublisher.Interface,\n private readonly decoratee: UnlockEntryRequestUseCase.Interface\n ) {}\n\n async execute(\n input: UnlockEntryRequestInput\n ): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Publish before event\n await this.eventPublisher.publish(\n new EntryBeforeUnlockRequestEvent({\n id: input.id,\n type: input.type\n })\n );\n\n const result = await this.decoratee.execute(input);\n\n if (result.isFail()) {\n const error = result.error;\n\n await this.eventPublisher.publish(\n new EntryUnlockRequestErrorEvent({\n id: input.id,\n type: input.type,\n error\n })\n );\n\n return result;\n }\n\n // Publish after event\n await this.eventPublisher.publish(\n new EntryAfterUnlockRequestEvent({\n id: input.id,\n type: input.type,\n record: result.value\n })\n );\n\n return result;\n }\n}\n\nexport const UnlockEntryRequestEventsDecorator = UnlockEntryRequestUseCase.createDecorator({\n decorator: UnlockEntryRequestEventsDecoratorImpl,\n dependencies: [EventPublisher]\n});\n"],"mappings":"AAAA,SAGIA,yBAAyB;AAE7B,SAASC,cAAc,QAAQ,0CAA0C;AAGzE,SACIC,4BAA4B,EAC5BC,6BAA6B,EAC7BC,4BAA4B;AAGhC,MAAMC,qCAAqC,CAAgD;EACvFC,WAAWA,CACUC,cAAwC,EACxCC,SAA8C,EACjE;IAAA,KAFmBD,cAAwC,GAAxCA,cAAwC;IAAA,KACxCC,SAA8C,GAA9CA,SAA8C;EAChE;EAEH,MAAMC,OAAOA,CACTC,KAA8B,EACwB;IACtD;IACA,MAAM,IAAI,CAACH,cAAc,CAACI,OAAO,CAC7B,IAAIR,6BAA6B,CAAC;MAC9BS,EAAE,EAAEF,KAAK,CAACE,EAAE;MACZC,IAAI,EAAEH,KAAK,CAACG;IAChB,CAAC,CACL,CAAC;IAED,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACN,SAAS,CAACC,OAAO,CAACC,KAAK,CAAC;IAElD,IAAII,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;MACjB,MAAMC,KAAK,GAAGF,MAAM,CAACE,KAAK;MAE1B,MAAM,IAAI,CAACT,cAAc,CAACI,OAAO,CAC7B,IAAIP,4BAA4B,CAAC;QAC7BQ,EAAE,EAAEF,KAAK,CAACE,EAAE;QACZC,IAAI,EAAEH,KAAK,CAACG,IAAI;QAChBG;MACJ,CAAC,CACL,CAAC;MAED,OAAOF,MAAM;IACjB;;IAEA;IACA,MAAM,IAAI,CAACP,cAAc,CAACI,OAAO,CAC7B,IAAIT,4BAA4B,CAAC;MAC7BU,EAAE,EAAEF,KAAK,CAACE,EAAE;MACZC,IAAI,EAAEH,KAAK,CAACG,IAAI;MAChBI,MAAM,EAAEH,MAAM,CAACI;IACnB,CAAC,CACL,CAAC;IAED,OAAOJ,MAAM;EACjB;AACJ;AAEA,OAAO,MAAMK,iCAAiC,GAAGnB,yBAAyB,CAACoB,eAAe,CAAC;EACvFC,SAAS,EAAEhB,qCAAqC;EAChDiB,YAAY,EAAE,CAACrB,cAAc;AACjC,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js","sources":["../../../src/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.ts"],"sourcesContent":["import {\n type UnlockEntryRequestInput,\n UnlockEntryRequestUseCase as UseCaseAbstraction,\n UnlockEntryRequestUseCase\n} from \"./abstractions.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { ILockRecord } from \"~/domain/index.js\";\nimport { Result } from \"@webiny/feature/api/index.js\";\nimport {\n EntryAfterUnlockRequestEvent,\n EntryBeforeUnlockRequestEvent,\n EntryUnlockRequestErrorEvent\n} from \"./events.js\";\n\nclass UnlockEntryRequestEventsDecoratorImpl implements UnlockEntryRequestUseCase.Interface {\n constructor(\n private readonly eventPublisher: EventPublisher.Interface,\n private readonly decoratee: UnlockEntryRequestUseCase.Interface\n ) {}\n\n async execute(\n input: UnlockEntryRequestInput\n ): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Publish before event\n await this.eventPublisher.publish(\n new EntryBeforeUnlockRequestEvent({\n id: input.id,\n type: input.type\n })\n );\n\n const result = await this.decoratee.execute(input);\n\n if (result.isFail()) {\n const error = result.error;\n\n await this.eventPublisher.publish(\n new EntryUnlockRequestErrorEvent({\n id: input.id,\n type: input.type,\n error\n })\n );\n\n return result;\n }\n\n // Publish after event\n await this.eventPublisher.publish(\n new EntryAfterUnlockRequestEvent({\n id: input.id,\n type: input.type,\n record: result.value\n })\n );\n\n return result;\n }\n}\n\nexport const UnlockEntryRequestEventsDecorator = UnlockEntryRequestUseCase.createDecorator({\n decorator: UnlockEntryRequestEventsDecoratorImpl,\n dependencies: [EventPublisher]\n});\n"],"names":["UnlockEntryRequestEventsDecoratorImpl","eventPublisher","decoratee","input","EntryBeforeUnlockRequestEvent","result","error","EntryUnlockRequestErrorEvent","EntryAfterUnlockRequestEvent","UnlockEntryRequestEventsDecorator","UnlockEntryRequestUseCase","EventPublisher"],"mappings":";;;AAcA,MAAMA;IACF,YACqBC,cAAwC,EACxCC,SAA8C,CACjE;aAFmBD,cAAc,GAAdA;aACAC,SAAS,GAATA;IAClB;IAEH,MAAM,QACFC,KAA8B,EACwB;QAEtD,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIC,8BAA8B;YAC9B,IAAID,MAAM,EAAE;YACZ,MAAMA,MAAM,IAAI;QACpB;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,6BAA6B;gBAC7B,IAAIJ,MAAM,EAAE;gBACZ,MAAMA,MAAM,IAAI;gBAChBG;YACJ;YAGJ,OAAOD;QACX;QAGA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIG,6BAA6B;YAC7B,IAAIL,MAAM,EAAE;YACZ,MAAMA,MAAM,IAAI;YAChB,QAAQE,OAAO,KAAK;QACxB;QAGJ,OAAOA;IACX;AACJ;AAEO,MAAMI,oCAAoCC,0BAA0B,eAAe,CAAC;IACvF,WAAWV;IACX,cAAc;QAACW;KAAe;AAClC"}
@@ -1,14 +1,14 @@
1
1
  import { Result } from "@webiny/feature/api";
2
2
  import { UnlockEntryRequestRepository as RepositoryAbstraction } from "./abstractions.js";
3
3
  import { UpdateEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UpdateEntry";
4
- import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
4
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
5
+ import { RecordLockingModelProvider } from "../../domain/abstractions.js";
5
6
  import type { ILockRecord } from "../../domain/LockRecord.js";
6
- import type { CmsModel } from "@webiny/api-headless-cms/types";
7
7
  declare class UnlockEntryRequestRepositoryImpl implements RepositoryAbstraction.Interface {
8
8
  private updateEntry;
9
9
  private identityContext;
10
- private model;
11
- constructor(updateEntry: UpdateEntryUseCase.Interface, identityContext: IdentityContext.Interface, model: CmsModel);
10
+ private modelProvider;
11
+ constructor(updateEntry: UpdateEntryUseCase.Interface, identityContext: IdentityContext.Interface, modelProvider: RecordLockingModelProvider.Interface);
12
12
  update(record: ILockRecord): Promise<Result<ILockRecord, RepositoryAbstraction.Error>>;
13
13
  }
14
14
  export declare const UnlockEntryRequestRepository: typeof UnlockEntryRequestRepositoryImpl & {
@@ -1,43 +1,45 @@
1
1
  import { Result } from "@webiny/feature/api";
2
- import { UnlockEntryRequestRepository as RepositoryAbstraction } from "./abstractions.js";
2
+ import { UnlockEntryRequestRepository } from "./abstractions.js";
3
3
  import { UpdateEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UpdateEntry";
4
- import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
5
- import { RecordLockingModel } from "../../domain/abstractions.js";
4
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
5
+ import { RecordLockingModelProvider } from "../../domain/abstractions.js";
6
6
  import { UnlockEntryRequestError } from "../../domain/errors.js";
7
7
  import { createLockRecordDatabaseId } from "../../utils/lockRecordDatabaseId.js";
8
8
  import { createIdentifier } from "@webiny/utils";
9
9
  class UnlockEntryRequestRepositoryImpl {
10
- constructor(updateEntry, identityContext, model) {
11
- this.updateEntry = updateEntry;
12
- this.identityContext = identityContext;
13
- this.model = model;
14
- }
15
- async update(record) {
16
- try {
17
- const entryId = createLockRecordDatabaseId(record.id);
18
- const id = createIdentifier({
19
- id: entryId,
20
- version: 1
21
- });
22
- const recordValues = record.toObject();
23
- const result = await this.identityContext.withoutAuthorization(async () => {
24
- return await this.updateEntry.execute(this.model, id, {
25
- ...recordValues,
26
- values: recordValues
27
- });
28
- });
29
- if (result.isFail()) {
30
- return Result.fail(new UnlockEntryRequestError(result.error));
31
- }
32
- return Result.ok(record);
33
- } catch (error) {
34
- return Result.fail(new UnlockEntryRequestError(error));
10
+ constructor(updateEntry, identityContext, modelProvider){
11
+ this.updateEntry = updateEntry;
12
+ this.identityContext = identityContext;
13
+ this.modelProvider = modelProvider;
14
+ }
15
+ async update(record) {
16
+ try {
17
+ const model = await this.modelProvider.get();
18
+ const entryId = createLockRecordDatabaseId(record.id);
19
+ const id = createIdentifier({
20
+ id: entryId,
21
+ version: 1
22
+ });
23
+ const recordValues = record.toObject();
24
+ const result = await this.identityContext.withoutAuthorization(async ()=>await this.updateEntry.execute(model, id, {
25
+ ...recordValues,
26
+ values: recordValues
27
+ }));
28
+ if (result.isFail()) return Result.fail(new UnlockEntryRequestError(result.error));
29
+ return Result.ok(record);
30
+ } catch (error) {
31
+ return Result.fail(new UnlockEntryRequestError(error));
32
+ }
35
33
  }
36
- }
37
34
  }
38
- export const UnlockEntryRequestRepository = RepositoryAbstraction.createImplementation({
39
- implementation: UnlockEntryRequestRepositoryImpl,
40
- dependencies: [UpdateEntryUseCase, IdentityContext, RecordLockingModel]
35
+ const UnlockEntryRequestRepository_UnlockEntryRequestRepository = UnlockEntryRequestRepository.createImplementation({
36
+ implementation: UnlockEntryRequestRepositoryImpl,
37
+ dependencies: [
38
+ UpdateEntryUseCase,
39
+ IdentityContext,
40
+ RecordLockingModelProvider
41
+ ]
41
42
  });
43
+ export { UnlockEntryRequestRepository_UnlockEntryRequestRepository as UnlockEntryRequestRepository };
42
44
 
43
45
  //# sourceMappingURL=UnlockEntryRequestRepository.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Result","UnlockEntryRequestRepository","RepositoryAbstraction","UpdateEntryUseCase","IdentityContext","RecordLockingModel","UnlockEntryRequestError","createLockRecordDatabaseId","createIdentifier","UnlockEntryRequestRepositoryImpl","constructor","updateEntry","identityContext","model","update","record","entryId","id","version","recordValues","toObject","result","withoutAuthorization","execute","values","isFail","fail","error","ok","createImplementation","implementation","dependencies"],"sources":["UnlockEntryRequestRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UnlockEntryRequestRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { UpdateEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UpdateEntry\";\nimport { IdentityContext } from \"@webiny/api-core/features/IdentityContext\";\nimport { RecordLockingModel } from \"~/domain/abstractions.js\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { UnlockEntryRequestError } from \"~/domain/errors.js\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId.js\";\nimport { createIdentifier } from \"@webiny/utils\";\n\nclass UnlockEntryRequestRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private updateEntry: UpdateEntryUseCase.Interface,\n private identityContext: IdentityContext.Interface,\n private model: CmsModel\n ) {}\n\n async update(record: ILockRecord): Promise<Result<ILockRecord, RepositoryAbstraction.Error>> {\n try {\n const entryId = createLockRecordDatabaseId(record.id);\n const id = createIdentifier({\n id: entryId,\n version: 1\n });\n\n const recordValues = record.toObject();\n const result = await this.identityContext.withoutAuthorization(async () => {\n return await this.updateEntry.execute(this.model, id, {\n ...recordValues,\n values: recordValues\n });\n });\n\n if (result.isFail()) {\n return Result.fail(new UnlockEntryRequestError(result.error));\n }\n\n return Result.ok(record);\n } catch (error) {\n return Result.fail(new UnlockEntryRequestError(error as Error));\n }\n }\n}\n\nexport const UnlockEntryRequestRepository = RepositoryAbstraction.createImplementation({\n implementation: UnlockEntryRequestRepositoryImpl,\n dependencies: [UpdateEntryUseCase, IdentityContext, RecordLockingModel]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,4BAA4B,IAAIC,qBAAqB;AAC9D,SAASC,kBAAkB,QAAQ,4DAA4D;AAC/F,SAASC,eAAe,QAAQ,2CAA2C;AAC3E,SAASC,kBAAkB;AAG3B,SAASC,uBAAuB;AAChC,SAASC,0BAA0B;AACnC,SAASC,gBAAgB,QAAQ,eAAe;AAEhD,MAAMC,gCAAgC,CAA4C;EAC9EC,WAAWA,CACCC,WAAyC,EACzCC,eAA0C,EAC1CC,KAAe,EACzB;IAAA,KAHUF,WAAyC,GAAzCA,WAAyC;IAAA,KACzCC,eAA0C,GAA1CA,eAA0C;IAAA,KAC1CC,KAAe,GAAfA,KAAe;EACxB;EAEH,MAAMC,MAAMA,CAACC,MAAmB,EAA6D;IACzF,IAAI;MACA,MAAMC,OAAO,GAAGT,0BAA0B,CAACQ,MAAM,CAACE,EAAE,CAAC;MACrD,MAAMA,EAAE,GAAGT,gBAAgB,CAAC;QACxBS,EAAE,EAAED,OAAO;QACXE,OAAO,EAAE;MACb,CAAC,CAAC;MAEF,MAAMC,YAAY,GAAGJ,MAAM,CAACK,QAAQ,CAAC,CAAC;MACtC,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACT,eAAe,CAACU,oBAAoB,CAAC,YAAY;QACvE,OAAO,MAAM,IAAI,CAACX,WAAW,CAACY,OAAO,CAAC,IAAI,CAACV,KAAK,EAAEI,EAAE,EAAE;UAClD,GAAGE,YAAY;UACfK,MAAM,EAAEL;QACZ,CAAC,CAAC;MACN,CAAC,CAAC;MAEF,IAAIE,MAAM,CAACI,MAAM,CAAC,CAAC,EAAE;QACjB,OAAOzB,MAAM,CAAC0B,IAAI,CAAC,IAAIpB,uBAAuB,CAACe,MAAM,CAACM,KAAK,CAAC,CAAC;MACjE;MAEA,OAAO3B,MAAM,CAAC4B,EAAE,CAACb,MAAM,CAAC;IAC5B,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,OAAO3B,MAAM,CAAC0B,IAAI,CAAC,IAAIpB,uBAAuB,CAACqB,KAAc,CAAC,CAAC;IACnE;EACJ;AACJ;AAEA,OAAO,MAAM1B,4BAA4B,GAAGC,qBAAqB,CAAC2B,oBAAoB,CAAC;EACnFC,cAAc,EAAErB,gCAAgC;EAChDsB,YAAY,EAAE,CAAC5B,kBAAkB,EAAEC,eAAe,EAAEC,kBAAkB;AAC1E,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"features/UnlockEntryRequest/UnlockEntryRequestRepository.js","sources":["../../../src/features/UnlockEntryRequest/UnlockEntryRequestRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UnlockEntryRequestRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { UpdateEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UpdateEntry\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { RecordLockingModelProvider } from \"~/domain/abstractions.js\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport { UnlockEntryRequestError } from \"~/domain/errors.js\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId.js\";\nimport { createIdentifier } from \"@webiny/utils\";\n\nclass UnlockEntryRequestRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private updateEntry: UpdateEntryUseCase.Interface,\n private identityContext: IdentityContext.Interface,\n private modelProvider: RecordLockingModelProvider.Interface\n ) {}\n\n async update(record: ILockRecord): Promise<Result<ILockRecord, RepositoryAbstraction.Error>> {\n try {\n const model = await this.modelProvider.get();\n\n const entryId = createLockRecordDatabaseId(record.id);\n const id = createIdentifier({\n id: entryId,\n version: 1\n });\n\n const recordValues = record.toObject();\n const result = await this.identityContext.withoutAuthorization(async () => {\n return await this.updateEntry.execute(model, id, {\n ...recordValues,\n values: recordValues\n });\n });\n\n if (result.isFail()) {\n return Result.fail(new UnlockEntryRequestError(result.error));\n }\n\n return Result.ok(record);\n } catch (error) {\n return Result.fail(new UnlockEntryRequestError(error as Error));\n }\n }\n}\n\nexport const UnlockEntryRequestRepository = RepositoryAbstraction.createImplementation({\n implementation: UnlockEntryRequestRepositoryImpl,\n dependencies: [UpdateEntryUseCase, IdentityContext, RecordLockingModelProvider]\n});\n"],"names":["UnlockEntryRequestRepositoryImpl","updateEntry","identityContext","modelProvider","record","model","entryId","createLockRecordDatabaseId","id","createIdentifier","recordValues","result","Result","UnlockEntryRequestError","error","UnlockEntryRequestRepository","RepositoryAbstraction","UpdateEntryUseCase","IdentityContext","RecordLockingModelProvider"],"mappings":";;;;;;;;AAUA,MAAMA;IACF,YACYC,WAAyC,EACzCC,eAA0C,EAC1CC,aAAmD,CAC7D;aAHUF,WAAW,GAAXA;aACAC,eAAe,GAAfA;aACAC,aAAa,GAAbA;IACT;IAEH,MAAM,OAAOC,MAAmB,EAA6D;QACzF,IAAI;YACA,MAAMC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG;YAE1C,MAAMC,UAAUC,2BAA2BH,OAAO,EAAE;YACpD,MAAMI,KAAKC,iBAAiB;gBACxB,IAAIH;gBACJ,SAAS;YACb;YAEA,MAAMI,eAAeN,OAAO,QAAQ;YACpC,MAAMO,SAAS,MAAM,IAAI,CAAC,eAAe,CAAC,oBAAoB,CAAC,UACpD,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAACN,OAAOG,IAAI;oBAC7C,GAAGE,YAAY;oBACf,QAAQA;gBACZ;YAGJ,IAAIC,OAAO,MAAM,IACb,OAAOC,OAAO,IAAI,CAAC,IAAIC,wBAAwBF,OAAO,KAAK;YAG/D,OAAOC,OAAO,EAAE,CAACR;QACrB,EAAE,OAAOU,OAAO;YACZ,OAAOF,OAAO,IAAI,CAAC,IAAIC,wBAAwBC;QACnD;IACJ;AACJ;AAEO,MAAMC,4DAA+BC,6BAAAA,oBAA0C,CAAC;IACnF,gBAAgBhB;IAChB,cAAc;QAACiB;QAAoBC;QAAiBC;KAA2B;AACnF"}
@@ -1,7 +1,7 @@
1
1
  import { Result } from "@webiny/feature/api";
2
2
  import { UnlockEntryRequestUseCase as UseCaseAbstraction, UnlockEntryRequestRepository, UnlockEntryRequestInput } from "./abstractions.js";
3
3
  import { GetLockRecordUseCase } from "../GetLockRecord/abstractions.js";
4
- import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
4
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
5
5
  import type { ILockRecord } from "../../domain/LockRecord.js";
6
6
  declare class UnlockEntryRequestUseCaseImpl implements UseCaseAbstraction.Interface {
7
7
  private getLockRecord;
@@ -1,92 +1,75 @@
1
1
  import { Result } from "@webiny/feature/api";
2
- import { UnlockEntryRequestUseCase as UseCaseAbstraction, UnlockEntryRequestRepository } from "./abstractions.js";
2
+ import { UnlockEntryRequestRepository, UnlockEntryRequestUseCase } from "./abstractions.js";
3
3
  import { GetLockRecordUseCase } from "../GetLockRecord/abstractions.js";
4
- import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
5
- import { EntryNotLockedError, UnlockRequestAlreadySentError, LockRecordNotFoundError, LockRecordPersistenceError } from "../../domain/errors.js";
4
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
5
+ import { EntryNotLockedError, LockRecordNotFoundError, LockRecordPersistenceError, UnlockRequestAlreadySentError } from "../../domain/errors.js";
6
6
  import { RecordLockingLockRecordActionType } from "../../domain/types.js";
7
7
  class UnlockEntryRequestUseCaseImpl {
8
- constructor(getLockRecord, repository, identityContext) {
9
- this.getLockRecord = getLockRecord;
10
- this.repository = repository;
11
- this.identityContext = identityContext;
12
- }
13
- async execute(input) {
14
- // Get the lock record
15
- const recordResult = await this.getLockRecord.execute(input);
16
-
17
- // If not found, it means entry is not locked
18
- if (recordResult.isFail()) {
19
- if (recordResult.error instanceof LockRecordNotFoundError) {
20
- const error = new EntryNotLockedError({
21
- id: input.id,
22
- type: input.type
23
- });
24
- return Result.fail(error);
25
- }
26
- // Other errors
27
- return Result.fail(new LockRecordPersistenceError(recordResult.error));
28
- }
29
- const record = recordResult.value;
30
-
31
- // If expired, entry is not locked
32
- if (record.isExpired()) {
33
- const error = new EntryNotLockedError({
34
- id: input.id,
35
- type: input.type
36
- });
37
- return Result.fail(error);
8
+ constructor(getLockRecord, repository, identityContext){
9
+ this.getLockRecord = getLockRecord;
10
+ this.repository = repository;
11
+ this.identityContext = identityContext;
38
12
  }
39
-
40
- // Check if unlock request already exists
41
- const unlockRequested = record.getUnlockRequested();
42
- if (unlockRequested) {
43
- const currentIdentity = this.identityContext.getIdentity();
44
-
45
- // If a different user already requested unlock, deny
46
- if (unlockRequested.createdBy.id !== currentIdentity.id) {
47
- const error = new UnlockRequestAlreadySentError({
48
- id: input.id,
49
- type: input.type,
50
- identityId: unlockRequested.createdBy.id
13
+ async execute(input) {
14
+ const recordResult = await this.getLockRecord.execute(input);
15
+ if (recordResult.isFail()) {
16
+ if (recordResult.error instanceof LockRecordNotFoundError) {
17
+ const error = new EntryNotLockedError({
18
+ id: input.id,
19
+ type: input.type
20
+ });
21
+ return Result.fail(error);
22
+ }
23
+ return Result.fail(new LockRecordPersistenceError(recordResult.error));
24
+ }
25
+ const record = recordResult.value;
26
+ if (record.isExpired()) {
27
+ const error = new EntryNotLockedError({
28
+ id: input.id,
29
+ type: input.type
30
+ });
31
+ return Result.fail(error);
32
+ }
33
+ const unlockRequested = record.getUnlockRequested();
34
+ if (unlockRequested) {
35
+ const currentIdentity = this.identityContext.getIdentity();
36
+ if (unlockRequested.createdBy.id !== currentIdentity.id) {
37
+ const error = new UnlockRequestAlreadySentError({
38
+ id: input.id,
39
+ type: input.type,
40
+ identityId: unlockRequested.createdBy.id
41
+ });
42
+ return Result.fail(error);
43
+ }
44
+ const approved = record.getUnlockApproved();
45
+ const denied = record.getUnlockDenied();
46
+ if (approved || denied) return Result.ok(record);
47
+ const error = new UnlockRequestAlreadySentError({
48
+ id: input.id,
49
+ type: input.type,
50
+ identityId: unlockRequested.createdBy.id
51
+ });
52
+ return Result.fail(error);
53
+ }
54
+ const identity = this.identityContext.getIdentity();
55
+ record.addAction({
56
+ type: RecordLockingLockRecordActionType.requested,
57
+ createdOn: new Date(),
58
+ createdBy: identity
51
59
  });
52
- return Result.fail(error);
53
- }
54
-
55
- // If same user but already approved or denied, return the record
56
- const approved = record.getUnlockApproved();
57
- const denied = record.getUnlockDenied();
58
- if (approved || denied) {
60
+ const updateResult = await this.repository.update(record);
61
+ if (updateResult.isFail()) return Result.fail(updateResult.error);
59
62
  return Result.ok(record);
60
- }
61
-
62
- // If same user and pending, treat as duplicate
63
- const error = new UnlockRequestAlreadySentError({
64
- id: input.id,
65
- type: input.type,
66
- identityId: unlockRequested.createdBy.id
67
- });
68
- return Result.fail(error);
69
- }
70
-
71
- // Add unlock request action
72
- const identity = this.identityContext.getIdentity();
73
- record.addAction({
74
- type: RecordLockingLockRecordActionType.requested,
75
- createdOn: new Date(),
76
- createdBy: identity
77
- });
78
-
79
- // Update the record
80
- const updateResult = await this.repository.update(record);
81
- if (updateResult.isFail()) {
82
- return Result.fail(updateResult.error);
83
63
  }
84
- return Result.ok(record);
85
- }
86
64
  }
87
- export const UnlockEntryRequestUseCase = UseCaseAbstraction.createImplementation({
88
- implementation: UnlockEntryRequestUseCaseImpl,
89
- dependencies: [GetLockRecordUseCase, UnlockEntryRequestRepository, IdentityContext]
65
+ const UnlockEntryRequestUseCase_UnlockEntryRequestUseCase = UnlockEntryRequestUseCase.createImplementation({
66
+ implementation: UnlockEntryRequestUseCaseImpl,
67
+ dependencies: [
68
+ GetLockRecordUseCase,
69
+ UnlockEntryRequestRepository,
70
+ IdentityContext
71
+ ]
90
72
  });
73
+ export { UnlockEntryRequestUseCase_UnlockEntryRequestUseCase as UnlockEntryRequestUseCase };
91
74
 
92
75
  //# sourceMappingURL=UnlockEntryRequestUseCase.js.map