@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.
- package/domain/LockRecord.js +63 -70
- package/domain/LockRecord.js.map +1 -1
- package/domain/RecordLockingModel.js +26 -23
- package/domain/RecordLockingModel.js.map +1 -1
- package/domain/abstractions.js +3 -7
- package/domain/abstractions.js.map +1 -1
- package/domain/calculateExpiresOn.js +5 -6
- package/domain/calculateExpiresOn.js.map +1 -1
- package/domain/errors.js +71 -81
- package/domain/errors.js.map +1 -1
- package/domain/index.js +0 -2
- package/domain/types.js +6 -9
- package/domain/types.js.map +1 -1
- package/features/GetLockRecord/GetLockRecordRepository.js +27 -24
- package/features/GetLockRecord/GetLockRecordRepository.js.map +1 -1
- package/features/GetLockRecord/GetLockRecordUseCase.js +13 -10
- package/features/GetLockRecord/GetLockRecordUseCase.js.map +1 -1
- package/features/GetLockRecord/abstractions.js +3 -14
- package/features/GetLockRecord/abstractions.js.map +1 -1
- package/features/GetLockRecord/feature.d.ts +4 -1
- package/features/GetLockRecord/feature.js +7 -6
- package/features/GetLockRecord/feature.js.map +1 -1
- package/features/GetLockRecord/index.js +0 -2
- package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.d.ts +1 -1
- package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js +20 -29
- package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js.map +1 -1
- package/features/GetLockedEntryLockRecord/abstractions.js +2 -10
- package/features/GetLockedEntryLockRecord/abstractions.js.map +1 -1
- package/features/GetLockedEntryLockRecord/feature.d.ts +4 -1
- package/features/GetLockedEntryLockRecord/feature.js +6 -5
- package/features/GetLockedEntryLockRecord/feature.js.map +1 -1
- package/features/GetLockedEntryLockRecord/index.js +0 -2
- package/features/IsEntryLocked/IsEntryLockedUseCase.d.ts +1 -1
- package/features/IsEntryLocked/IsEntryLockedUseCase.js +23 -29
- package/features/IsEntryLocked/IsEntryLockedUseCase.js.map +1 -1
- package/features/IsEntryLocked/abstractions.js +2 -9
- package/features/IsEntryLocked/abstractions.js.map +1 -1
- package/features/IsEntryLocked/feature.d.ts +4 -1
- package/features/IsEntryLocked/feature.js +6 -5
- package/features/IsEntryLocked/feature.js.map +1 -1
- package/features/IsEntryLocked/index.js +0 -2
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.d.ts +1 -1
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js +33 -33
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js.map +1 -1
- package/features/KickOutCurrentUser/abstractions.js +2 -6
- package/features/KickOutCurrentUser/abstractions.js.map +1 -1
- package/features/KickOutCurrentUser/feature.d.ts +4 -1
- package/features/KickOutCurrentUser/feature.js +6 -5
- package/features/KickOutCurrentUser/feature.js.map +1 -1
- package/features/KickOutCurrentUser/index.js +0 -2
- package/features/ListAllLockRecords/ListAllLockRecordsRepository.js +31 -31
- package/features/ListAllLockRecords/ListAllLockRecordsRepository.js.map +1 -1
- package/features/ListAllLockRecords/ListAllLockRecordsUseCase.js +13 -10
- package/features/ListAllLockRecords/ListAllLockRecordsUseCase.js.map +1 -1
- package/features/ListAllLockRecords/abstractions.js +3 -14
- package/features/ListAllLockRecords/abstractions.js.map +1 -1
- package/features/ListAllLockRecords/feature.d.ts +4 -1
- package/features/ListAllLockRecords/feature.js +7 -6
- package/features/ListAllLockRecords/feature.js.map +1 -1
- package/features/ListAllLockRecords/index.js +0 -2
- package/features/ListLockRecords/ListLockRecordsRepository.js +31 -31
- package/features/ListLockRecords/ListLockRecordsRepository.js.map +1 -1
- package/features/ListLockRecords/ListLockRecordsUseCase.d.ts +1 -1
- package/features/ListLockRecords/ListLockRecordsUseCase.js +27 -24
- package/features/ListLockRecords/ListLockRecordsUseCase.js.map +1 -1
- package/features/ListLockRecords/abstractions.js +3 -14
- package/features/ListLockRecords/abstractions.js.map +1 -1
- package/features/ListLockRecords/feature.d.ts +4 -1
- package/features/ListLockRecords/feature.js +7 -6
- package/features/ListLockRecords/feature.js.map +1 -1
- package/features/ListLockRecords/index.js +0 -2
- package/features/LockEntry/LockEntryEventsDecorator.d.ts +1 -1
- package/features/LockEntry/LockEntryEventsDecorator.js +32 -32
- package/features/LockEntry/LockEntryEventsDecorator.js.map +1 -1
- package/features/LockEntry/LockEntryRepository.js +33 -30
- package/features/LockEntry/LockEntryRepository.js.map +1 -1
- package/features/LockEntry/LockEntryUseCase.js +21 -26
- package/features/LockEntry/LockEntryUseCase.js.map +1 -1
- package/features/LockEntry/abstractions.js +3 -14
- package/features/LockEntry/abstractions.js.map +1 -1
- package/features/LockEntry/events.d.ts +8 -8
- package/features/LockEntry/events.js +26 -34
- package/features/LockEntry/events.js.map +1 -1
- package/features/LockEntry/feature.d.ts +4 -1
- package/features/LockEntry/feature.js +8 -7
- package/features/LockEntry/feature.js.map +1 -1
- package/features/LockEntry/index.js +0 -2
- package/features/RecordLockingFeature.d.ts +4 -1
- package/features/RecordLockingFeature.js +19 -21
- package/features/RecordLockingFeature.js.map +1 -1
- package/features/UnlockEntry/UnlockEntryEventsDecorator.d.ts +1 -1
- package/features/UnlockEntry/UnlockEntryEventsDecorator.js +33 -33
- package/features/UnlockEntry/UnlockEntryEventsDecorator.js.map +1 -1
- package/features/UnlockEntry/UnlockEntryRepository.js +29 -27
- package/features/UnlockEntry/UnlockEntryRepository.js.map +1 -1
- package/features/UnlockEntry/UnlockEntryUseCase.d.ts +1 -1
- package/features/UnlockEntry/UnlockEntryUseCase.js +54 -70
- package/features/UnlockEntry/UnlockEntryUseCase.js.map +1 -1
- package/features/UnlockEntry/abstractions.js +3 -14
- package/features/UnlockEntry/abstractions.js.map +1 -1
- package/features/UnlockEntry/events.d.ts +8 -8
- package/features/UnlockEntry/events.js +26 -34
- package/features/UnlockEntry/events.js.map +1 -1
- package/features/UnlockEntry/feature.d.ts +4 -1
- package/features/UnlockEntry/feature.js +8 -7
- package/features/UnlockEntry/feature.js.map +1 -1
- package/features/UnlockEntry/hasFullAccessPermission.d.ts +1 -1
- package/features/UnlockEntry/hasFullAccessPermission.js +6 -7
- package/features/UnlockEntry/hasFullAccessPermission.js.map +1 -1
- package/features/UnlockEntry/index.js +0 -2
- package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.d.ts +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js +32 -32
- package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js.map +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.d.ts +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js +32 -31
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js.map +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.d.ts +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js +63 -80
- package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js.map +1 -1
- package/features/UnlockEntryRequest/abstractions.js +3 -14
- package/features/UnlockEntryRequest/abstractions.js.map +1 -1
- package/features/UnlockEntryRequest/events.d.ts +8 -8
- package/features/UnlockEntryRequest/events.js +26 -34
- package/features/UnlockEntryRequest/events.js.map +1 -1
- package/features/UnlockEntryRequest/feature.d.ts +4 -1
- package/features/UnlockEntryRequest/feature.js +8 -7
- package/features/UnlockEntryRequest/feature.js.map +1 -1
- package/features/UnlockEntryRequest/index.js +0 -2
- package/features/UpdateEntryLock/UpdateEntryLockRepository.d.ts +1 -1
- package/features/UpdateEntryLock/UpdateEntryLockRepository.js +46 -49
- package/features/UpdateEntryLock/UpdateEntryLockRepository.js.map +1 -1
- package/features/UpdateEntryLock/UpdateEntryLockUseCase.d.ts +1 -1
- package/features/UpdateEntryLock/UpdateEntryLockUseCase.js +41 -52
- package/features/UpdateEntryLock/UpdateEntryLockUseCase.js.map +1 -1
- package/features/UpdateEntryLock/abstractions.js +3 -14
- package/features/UpdateEntryLock/abstractions.js.map +1 -1
- package/features/UpdateEntryLock/feature.d.ts +4 -1
- package/features/UpdateEntryLock/feature.js +7 -6
- package/features/UpdateEntryLock/feature.js.map +1 -1
- package/features/UpdateEntryLock/index.js +0 -2
- package/graphql/checkPermissions.js +6 -10
- package/graphql/checkPermissions.js.map +1 -1
- package/graphql/resolve.js +15 -17
- package/graphql/resolve.js.map +1 -1
- package/graphql/schema.d.ts +2 -2
- package/graphql/schema.js +147 -168
- package/graphql/schema.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +46 -48
- package/index.js.map +1 -1
- package/package.json +27 -22
- package/types.js +6 -9
- package/types.js.map +1 -1
- package/utils/convertWhereCondition.js +20 -32
- package/utils/convertWhereCondition.js.map +1 -1
- package/utils/getTimeout.js +8 -15
- package/utils/getTimeout.js.map +1 -1
- package/utils/lockRecordDatabaseId.js +6 -11
- package/utils/lockRecordDatabaseId.js.map +1 -1
- package/domain/index.js.map +0 -1
- package/features/GetLockRecord/index.js.map +0 -1
- package/features/GetLockedEntryLockRecord/index.js.map +0 -1
- package/features/IsEntryLocked/index.js.map +0 -1
- package/features/KickOutCurrentUser/index.js.map +0 -1
- package/features/ListAllLockRecords/index.js.map +0 -1
- package/features/ListLockRecords/index.js.map +0 -1
- package/features/LockEntry/index.js.map +0 -1
- package/features/UnlockEntry/index.js.map +0 -1
- package/features/UnlockEntryRequest/index.js.map +0 -1
- package/features/UpdateEntryLock/index.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DomainEvent } from "@webiny/api-core/features/
|
|
2
|
-
import type { IEventHandler } from "@webiny/api-core/features/
|
|
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 EntryBeforeUnlockRequestPayload {
|
|
@@ -10,8 +10,8 @@ export declare class EntryBeforeUnlockRequestEvent extends DomainEvent<EntryBefo
|
|
|
10
10
|
eventType: "RecordLocking/Entry/BeforeUnlockRequest";
|
|
11
11
|
getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryBeforeUnlockRequestEvent>>;
|
|
12
12
|
}
|
|
13
|
-
export declare const
|
|
14
|
-
export declare namespace
|
|
13
|
+
export declare const EntryBeforeUnlockRequestEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryBeforeUnlockRequestEvent>>;
|
|
14
|
+
export declare namespace EntryBeforeUnlockRequestEventHandler {
|
|
15
15
|
type Interface = IEventHandler<EntryBeforeUnlockRequestEvent>;
|
|
16
16
|
type Event = EntryBeforeUnlockRequestEvent;
|
|
17
17
|
}
|
|
@@ -24,8 +24,8 @@ export declare class EntryAfterUnlockRequestEvent extends DomainEvent<EntryAfter
|
|
|
24
24
|
eventType: "RecordLocking/Entry/AfterUnlockRequest";
|
|
25
25
|
getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryAfterUnlockRequestEvent>>;
|
|
26
26
|
}
|
|
27
|
-
export declare const
|
|
28
|
-
export declare namespace
|
|
27
|
+
export declare const EntryAfterUnlockRequestEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryAfterUnlockRequestEvent>>;
|
|
28
|
+
export declare namespace EntryAfterUnlockRequestEventHandler {
|
|
29
29
|
type Interface = IEventHandler<EntryAfterUnlockRequestEvent>;
|
|
30
30
|
type Event = EntryAfterUnlockRequestEvent;
|
|
31
31
|
}
|
|
@@ -38,8 +38,8 @@ export declare class EntryUnlockRequestErrorEvent extends DomainEvent<EntryUnloc
|
|
|
38
38
|
eventType: "RecordLocking/Entry/UnlockRequestError";
|
|
39
39
|
getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryUnlockRequestErrorEvent>>;
|
|
40
40
|
}
|
|
41
|
-
export declare const
|
|
42
|
-
export declare namespace
|
|
41
|
+
export declare const EntryUnlockRequestErrorEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryUnlockRequestErrorEvent>>;
|
|
42
|
+
export declare namespace EntryUnlockRequestErrorEventHandler {
|
|
43
43
|
type Interface = IEventHandler<EntryUnlockRequestErrorEvent>;
|
|
44
44
|
type Event = EntryUnlockRequestErrorEvent;
|
|
45
45
|
}
|
|
@@ -1,40 +1,32 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
import { DomainEvent } from "@webiny/api-core/features/
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
getHandlerAbstraction() {
|
|
11
|
-
return EntryBeforeUnlockRequestHandler;
|
|
12
|
-
}
|
|
2
|
+
import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
|
+
class EntryBeforeUnlockRequestEvent extends DomainEvent {
|
|
4
|
+
getHandlerAbstraction() {
|
|
5
|
+
return EntryBeforeUnlockRequestEventHandler;
|
|
6
|
+
}
|
|
7
|
+
constructor(...args){
|
|
8
|
+
super(...args), this.eventType = "RecordLocking/Entry/BeforeUnlockRequest";
|
|
9
|
+
}
|
|
13
10
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
getHandlerAbstraction() {
|
|
23
|
-
return EntryAfterUnlockRequestHandler;
|
|
24
|
-
}
|
|
11
|
+
const EntryBeforeUnlockRequestEventHandler = createAbstraction("EntryBeforeUnlockRequestEventHandler");
|
|
12
|
+
class EntryAfterUnlockRequestEvent extends DomainEvent {
|
|
13
|
+
getHandlerAbstraction() {
|
|
14
|
+
return EntryAfterUnlockRequestEventHandler;
|
|
15
|
+
}
|
|
16
|
+
constructor(...args){
|
|
17
|
+
super(...args), this.eventType = "RecordLocking/Entry/AfterUnlockRequest";
|
|
18
|
+
}
|
|
25
19
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
getHandlerAbstraction() {
|
|
35
|
-
return EntryUnlockRequestErrorHandler;
|
|
36
|
-
}
|
|
20
|
+
const EntryAfterUnlockRequestEventHandler = createAbstraction("EntryAfterUnlockRequestEventHandler");
|
|
21
|
+
class EntryUnlockRequestErrorEvent extends DomainEvent {
|
|
22
|
+
getHandlerAbstraction() {
|
|
23
|
+
return EntryUnlockRequestErrorEventHandler;
|
|
24
|
+
}
|
|
25
|
+
constructor(...args){
|
|
26
|
+
super(...args), this.eventType = "RecordLocking/Entry/UnlockRequestError";
|
|
27
|
+
}
|
|
37
28
|
}
|
|
38
|
-
|
|
29
|
+
const EntryUnlockRequestErrorEventHandler = createAbstraction("EntryUnlockRequestErrorEventHandler");
|
|
30
|
+
export { EntryAfterUnlockRequestEvent, EntryAfterUnlockRequestEventHandler, EntryBeforeUnlockRequestEvent, EntryBeforeUnlockRequestEventHandler, EntryUnlockRequestErrorEvent, EntryUnlockRequestErrorEventHandler };
|
|
39
31
|
|
|
40
32
|
//# sourceMappingURL=events.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/UnlockEntryRequest/events.js","sources":["../../../src/features/UnlockEntryRequest/events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordEntryType } from \"~/domain/types.js\";\n\n// ============================================================================\n// EntryBeforeUnlockRequest Event\n// ============================================================================\n\nexport interface EntryBeforeUnlockRequestPayload {\n id: string;\n type: LockRecordEntryType;\n}\n\nexport class EntryBeforeUnlockRequestEvent extends DomainEvent<EntryBeforeUnlockRequestPayload> {\n eventType = \"RecordLocking/Entry/BeforeUnlockRequest\" as const;\n\n getHandlerAbstraction() {\n return EntryBeforeUnlockRequestEventHandler;\n }\n}\n\nexport const EntryBeforeUnlockRequestEventHandler = createAbstraction<\n IEventHandler<EntryBeforeUnlockRequestEvent>\n>(\"EntryBeforeUnlockRequestEventHandler\");\n\nexport namespace EntryBeforeUnlockRequestEventHandler {\n export type Interface = IEventHandler<EntryBeforeUnlockRequestEvent>;\n export type Event = EntryBeforeUnlockRequestEvent;\n}\n\n// ============================================================================\n// EntryAfterUnlockRequest Event\n// ============================================================================\n\nexport interface EntryAfterUnlockRequestPayload {\n id: string;\n type: LockRecordEntryType;\n record: ILockRecord;\n}\n\nexport class EntryAfterUnlockRequestEvent extends DomainEvent<EntryAfterUnlockRequestPayload> {\n eventType = \"RecordLocking/Entry/AfterUnlockRequest\" as const;\n\n getHandlerAbstraction() {\n return EntryAfterUnlockRequestEventHandler;\n }\n}\n\nexport const EntryAfterUnlockRequestEventHandler = createAbstraction<\n IEventHandler<EntryAfterUnlockRequestEvent>\n>(\"EntryAfterUnlockRequestEventHandler\");\n\nexport namespace EntryAfterUnlockRequestEventHandler {\n export type Interface = IEventHandler<EntryAfterUnlockRequestEvent>;\n export type Event = EntryAfterUnlockRequestEvent;\n}\n\n// ============================================================================\n// EntryUnlockRequestError Event\n// ============================================================================\n\nexport interface EntryUnlockRequestErrorPayload {\n id: string;\n type: LockRecordEntryType;\n error: Error;\n}\n\nexport class EntryUnlockRequestErrorEvent extends DomainEvent<EntryUnlockRequestErrorPayload> {\n eventType = \"RecordLocking/Entry/UnlockRequestError\" as const;\n\n getHandlerAbstraction() {\n return EntryUnlockRequestErrorEventHandler;\n }\n}\n\nexport const EntryUnlockRequestErrorEventHandler = createAbstraction<\n IEventHandler<EntryUnlockRequestErrorEvent>\n>(\"EntryUnlockRequestErrorEventHandler\");\n\nexport namespace EntryUnlockRequestErrorEventHandler {\n export type Interface = IEventHandler<EntryUnlockRequestErrorEvent>;\n export type Event = EntryUnlockRequestErrorEvent;\n}\n"],"names":["EntryBeforeUnlockRequestEvent","DomainEvent","EntryBeforeUnlockRequestEventHandler","createAbstraction","EntryAfterUnlockRequestEvent","EntryAfterUnlockRequestEventHandler","EntryUnlockRequestErrorEvent","EntryUnlockRequestErrorEventHandler"],"mappings":";;AAeO,MAAMA,sCAAsCC;IAG/C,wBAAwB;QACpB,OAAOC;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB;AAEO,MAAMA,uCAAuCC,kBAElD;AAiBK,MAAMC,qCAAqCH;IAG9C,wBAAwB;QACpB,OAAOI;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB;AAEO,MAAMA,sCAAsCF,kBAEjD;AAiBK,MAAMG,qCAAqCL;IAG9C,wBAAwB;QACpB,OAAOM;IACX;;QALG,qBACH,SAAS,GAAG;;AAKhB;AAEO,MAAMA,sCAAsCJ,kBAEjD"}
|
|
@@ -2,13 +2,14 @@ import { createFeature } from "@webiny/feature/api";
|
|
|
2
2
|
import { UnlockEntryRequestUseCase } from "./UnlockEntryRequestUseCase.js";
|
|
3
3
|
import { UnlockEntryRequestRepository } from "./UnlockEntryRequestRepository.js";
|
|
4
4
|
import { UnlockEntryRequestEventsDecorator } from "./UnlockEntryRequestEventsDecorator.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
const UnlockEntryRequestFeature = createFeature({
|
|
6
|
+
name: "UnlockEntryRequest",
|
|
7
|
+
register (container) {
|
|
8
|
+
container.register(UnlockEntryRequestUseCase);
|
|
9
|
+
container.register(UnlockEntryRequestRepository).inSingletonScope();
|
|
10
|
+
container.registerDecorator(UnlockEntryRequestEventsDecorator);
|
|
11
|
+
}
|
|
12
12
|
});
|
|
13
|
+
export { UnlockEntryRequestFeature };
|
|
13
14
|
|
|
14
15
|
//# sourceMappingURL=feature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/UnlockEntryRequest/feature.js","sources":["../../../src/features/UnlockEntryRequest/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { UnlockEntryRequestUseCase } from \"./UnlockEntryRequestUseCase.js\";\nimport { UnlockEntryRequestRepository } from \"./UnlockEntryRequestRepository.js\";\nimport { UnlockEntryRequestEventsDecorator } from \"./UnlockEntryRequestEventsDecorator.js\";\n\nexport const UnlockEntryRequestFeature = createFeature({\n name: \"UnlockEntryRequest\",\n register(container) {\n container.register(UnlockEntryRequestUseCase);\n container.register(UnlockEntryRequestRepository).inSingletonScope();\n container.registerDecorator(UnlockEntryRequestEventsDecorator);\n }\n});\n"],"names":["UnlockEntryRequestFeature","createFeature","container","UnlockEntryRequestUseCase","UnlockEntryRequestRepository","UnlockEntryRequestEventsDecorator"],"mappings":";;;;AAKO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,8BAA8B,gBAAgB;QACjEF,UAAU,iBAAiB,CAACG;IAChC;AACJ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
|
|
1
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
2
2
|
import { UpdateEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UpdateEntry";
|
|
3
3
|
import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById";
|
|
4
4
|
import { Result } from "@webiny/feature/api";
|
|
@@ -1,63 +1,60 @@
|
|
|
1
|
-
import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
|
|
1
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
2
2
|
import { UpdateEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UpdateEntry";
|
|
3
3
|
import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById";
|
|
4
4
|
import { Result } from "@webiny/feature/api";
|
|
5
5
|
import { createIdentifier } from "@webiny/utils";
|
|
6
|
-
import { UpdateEntryLockRepository
|
|
6
|
+
import { UpdateEntryLockRepository } from "./abstractions.js";
|
|
7
7
|
import { RecordLockingConfig, RecordLockingModel } from "../../domain/abstractions.js";
|
|
8
8
|
import { LockRecord } from "../../domain/LockRecord.js";
|
|
9
9
|
import { LockRecordPersistenceError } from "../../domain/errors.js";
|
|
10
10
|
import { createLockRecordDatabaseId } from "../../utils/lockRecordDatabaseId.js";
|
|
11
11
|
class UpdateEntryLockRepositoryImpl {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const getResult = await this.getEntryById.execute(this.model, id);
|
|
47
|
-
if (getResult.isFail()) {
|
|
48
|
-
return Result.fail(new LockRecordPersistenceError(getResult.error));
|
|
49
|
-
}
|
|
50
|
-
const entry = getResult.value;
|
|
51
|
-
const lockRecord = new LockRecord(entry, this.config.timeout);
|
|
52
|
-
return Result.ok(lockRecord);
|
|
53
|
-
} catch (error) {
|
|
54
|
-
return Result.fail(new LockRecordPersistenceError(error));
|
|
12
|
+
constructor(model, config, identityContext, updateEntry, getEntryById){
|
|
13
|
+
this.model = model;
|
|
14
|
+
this.config = config;
|
|
15
|
+
this.identityContext = identityContext;
|
|
16
|
+
this.updateEntry = updateEntry;
|
|
17
|
+
this.getEntryById = getEntryById;
|
|
18
|
+
}
|
|
19
|
+
async update(lockRecordId, updateOwner) {
|
|
20
|
+
try {
|
|
21
|
+
const entryId = createLockRecordDatabaseId(lockRecordId);
|
|
22
|
+
const id = createIdentifier({
|
|
23
|
+
id: entryId,
|
|
24
|
+
version: 1
|
|
25
|
+
});
|
|
26
|
+
const identity = this.identityContext.getIdentity();
|
|
27
|
+
const now = new Date().toISOString();
|
|
28
|
+
const updateData = {
|
|
29
|
+
savedOn: now
|
|
30
|
+
};
|
|
31
|
+
if (updateOwner) {
|
|
32
|
+
updateData.createdOn = now;
|
|
33
|
+
updateData.createdBy = identity;
|
|
34
|
+
updateData.savedBy = identity;
|
|
35
|
+
}
|
|
36
|
+
const result = await this.updateEntry.execute(this.model, id, updateData);
|
|
37
|
+
if (result.isFail()) return Result.fail(new LockRecordPersistenceError(result.error));
|
|
38
|
+
const getResult = await this.getEntryById.execute(this.model, id);
|
|
39
|
+
if (getResult.isFail()) return Result.fail(new LockRecordPersistenceError(getResult.error));
|
|
40
|
+
const entry = getResult.value;
|
|
41
|
+
const lockRecord = new LockRecord(entry, this.config.timeout);
|
|
42
|
+
return Result.ok(lockRecord);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
return Result.fail(new LockRecordPersistenceError(error));
|
|
45
|
+
}
|
|
55
46
|
}
|
|
56
|
-
}
|
|
57
47
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
48
|
+
const UpdateEntryLockRepository_UpdateEntryLockRepository = UpdateEntryLockRepository.createImplementation({
|
|
49
|
+
implementation: UpdateEntryLockRepositoryImpl,
|
|
50
|
+
dependencies: [
|
|
51
|
+
RecordLockingModel,
|
|
52
|
+
RecordLockingConfig,
|
|
53
|
+
IdentityContext,
|
|
54
|
+
UpdateEntryUseCase,
|
|
55
|
+
GetEntryByIdUseCase
|
|
56
|
+
]
|
|
61
57
|
});
|
|
58
|
+
export { UpdateEntryLockRepository_UpdateEntryLockRepository as UpdateEntryLockRepository };
|
|
62
59
|
|
|
63
60
|
//# sourceMappingURL=UpdateEntryLockRepository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/UpdateEntryLock/UpdateEntryLockRepository.js","sources":["../../../src/features/UpdateEntryLock/UpdateEntryLockRepository.ts"],"sourcesContent":["import { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { UpdateEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UpdateEntry\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById\";\nimport { Result } from \"@webiny/feature/api\";\nimport { createIdentifier } from \"@webiny/utils\";\nimport { UpdateEntryLockRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { RecordLockingConfig, RecordLockingModel } from \"~/domain/abstractions.js\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport { LockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordValues } from \"~/domain/types.js\";\nimport { LockRecordPersistenceError } from \"~/domain/errors.js\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId.js\";\n\nclass UpdateEntryLockRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private model: RecordLockingModel.Interface,\n private config: RecordLockingConfig.Interface,\n private identityContext: IdentityContext.Interface,\n private updateEntry: UpdateEntryUseCase.Interface,\n private getEntryById: GetEntryByIdUseCase.Interface\n ) {}\n\n async update(\n lockRecordId: string,\n updateOwner: boolean\n ): Promise<Result<ILockRecord, RepositoryAbstraction.Error>> {\n try {\n const entryId = createLockRecordDatabaseId(lockRecordId);\n const id = createIdentifier({\n id: entryId,\n version: 1\n });\n\n const identity = this.identityContext.getIdentity();\n const now = new Date().toISOString();\n\n // Build update data\n const updateData: any = {\n savedOn: now\n };\n\n // If updating owner (expired lock), also update created fields\n if (updateOwner) {\n updateData.createdOn = now;\n updateData.createdBy = identity;\n updateData.savedBy = identity;\n }\n\n const result = await this.updateEntry.execute(this.model, id, updateData);\n\n if (result.isFail()) {\n return Result.fail(new LockRecordPersistenceError(result.error));\n }\n\n // Fetch the updated entry to return full lock record\n const getResult = await this.getEntryById.execute<LockRecordValues>(this.model, id);\n\n if (getResult.isFail()) {\n return Result.fail(new LockRecordPersistenceError(getResult.error));\n }\n\n const entry = getResult.value;\n const lockRecord = new LockRecord(entry, this.config.timeout);\n\n return Result.ok(lockRecord);\n } catch (error) {\n return Result.fail(new LockRecordPersistenceError(error as Error));\n }\n }\n}\n\nexport const UpdateEntryLockRepository = RepositoryAbstraction.createImplementation({\n implementation: UpdateEntryLockRepositoryImpl,\n dependencies: [\n RecordLockingModel,\n RecordLockingConfig,\n IdentityContext,\n UpdateEntryUseCase,\n GetEntryByIdUseCase\n ]\n});\n"],"names":["UpdateEntryLockRepositoryImpl","model","config","identityContext","updateEntry","getEntryById","lockRecordId","updateOwner","entryId","createLockRecordDatabaseId","id","createIdentifier","identity","now","Date","updateData","result","Result","LockRecordPersistenceError","getResult","entry","lockRecord","LockRecord","error","UpdateEntryLockRepository","RepositoryAbstraction","RecordLockingModel","RecordLockingConfig","IdentityContext","UpdateEntryUseCase","GetEntryByIdUseCase"],"mappings":";;;;;;;;;;AAaA,MAAMA;IACF,YACYC,KAAmC,EACnCC,MAAqC,EACrCC,eAA0C,EAC1CC,WAAyC,EACzCC,YAA2C,CACrD;aALUJ,KAAK,GAALA;aACAC,MAAM,GAANA;aACAC,eAAe,GAAfA;aACAC,WAAW,GAAXA;aACAC,YAAY,GAAZA;IACT;IAEH,MAAM,OACFC,YAAoB,EACpBC,WAAoB,EACqC;QACzD,IAAI;YACA,MAAMC,UAAUC,2BAA2BH;YAC3C,MAAMI,KAAKC,iBAAiB;gBACxB,IAAIH;gBACJ,SAAS;YACb;YAEA,MAAMI,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;YACjD,MAAMC,MAAM,IAAIC,OAAO,WAAW;YAGlC,MAAMC,aAAkB;gBACpB,SAASF;YACb;YAGA,IAAIN,aAAa;gBACbQ,WAAW,SAAS,GAAGF;gBACvBE,WAAW,SAAS,GAAGH;gBACvBG,WAAW,OAAO,GAAGH;YACzB;YAEA,MAAMI,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAEN,IAAIK;YAE9D,IAAIC,OAAO,MAAM,IACb,OAAOC,OAAO,IAAI,CAAC,IAAIC,2BAA2BF,OAAO,KAAK;YAIlE,MAAMG,YAAY,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAmB,IAAI,CAAC,KAAK,EAAET;YAEhF,IAAIS,UAAU,MAAM,IAChB,OAAOF,OAAO,IAAI,CAAC,IAAIC,2BAA2BC,UAAU,KAAK;YAGrE,MAAMC,QAAQD,UAAU,KAAK;YAC7B,MAAME,aAAa,IAAIC,WAAWF,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO;YAE5D,OAAOH,OAAO,EAAE,CAACI;QACrB,EAAE,OAAOE,OAAO;YACZ,OAAON,OAAO,IAAI,CAAC,IAAIC,2BAA2BK;QACtD;IACJ;AACJ;AAEO,MAAMC,sDAA4BC,0BAAAA,oBAA0C,CAAC;IAChF,gBAAgBzB;IAChB,cAAc;QACV0B;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -2,7 +2,7 @@ import { Result } from "@webiny/feature/api";
|
|
|
2
2
|
import { UpdateEntryLockUseCase as UseCaseAbstraction, UpdateEntryLockRepository, UpdateEntryLockInput } from "./abstractions.js";
|
|
3
3
|
import { GetLockRecordUseCase } from "../GetLockRecord/abstractions.js";
|
|
4
4
|
import { LockEntryUseCase } from "../LockEntry/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 UpdateEntryLockUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
8
8
|
private getLockRecord;
|
|
@@ -1,62 +1,51 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
|
-
import {
|
|
2
|
+
import { UpdateEntryLockRepository, UpdateEntryLockUseCase } from "./abstractions.js";
|
|
3
3
|
import { GetLockRecordUseCase } from "../GetLockRecord/abstractions.js";
|
|
4
4
|
import { LockEntryUseCase } from "../LockEntry/abstractions.js";
|
|
5
|
-
import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
|
|
6
|
-
import {
|
|
5
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
6
|
+
import { IdentityMismatchError, LockRecordNotFoundError, UpdateEntryLockError } from "../../domain/errors.js";
|
|
7
7
|
class UpdateEntryLockUseCaseImpl {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
async execute(input) {
|
|
15
|
-
// Try to get existing lock record
|
|
16
|
-
const recordResult = await this.getLockRecord.execute(input);
|
|
17
|
-
|
|
18
|
-
// If doesn't exist, create a new lock
|
|
19
|
-
if (recordResult.isFail()) {
|
|
20
|
-
if (recordResult.error instanceof LockRecordNotFoundError) {
|
|
21
|
-
const lockResult = await this.lockEntry.execute(input);
|
|
22
|
-
if (lockResult.isFail()) {
|
|
23
|
-
return Result.fail(new UpdateEntryLockError(lockResult.error));
|
|
24
|
-
}
|
|
25
|
-
return Result.ok(lockResult.value);
|
|
26
|
-
}
|
|
27
|
-
return Result.fail(recordResult.error);
|
|
8
|
+
constructor(getLockRecord, lockEntry, repository, identityContext){
|
|
9
|
+
this.getLockRecord = getLockRecord;
|
|
10
|
+
this.lockEntry = lockEntry;
|
|
11
|
+
this.repository = repository;
|
|
12
|
+
this.identityContext = identityContext;
|
|
28
13
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
14
|
+
async execute(input) {
|
|
15
|
+
const recordResult = await this.getLockRecord.execute(input);
|
|
16
|
+
if (recordResult.isFail()) {
|
|
17
|
+
if (recordResult.error instanceof LockRecordNotFoundError) {
|
|
18
|
+
const lockResult = await this.lockEntry.execute(input);
|
|
19
|
+
if (lockResult.isFail()) return Result.fail(new UpdateEntryLockError(lockResult.error));
|
|
20
|
+
return Result.ok(lockResult.value);
|
|
21
|
+
}
|
|
22
|
+
return Result.fail(recordResult.error);
|
|
23
|
+
}
|
|
24
|
+
const record = recordResult.value;
|
|
25
|
+
if (record.isExpired()) {
|
|
26
|
+
const updateResult = await this.repository.update(record.id, true);
|
|
27
|
+
if (updateResult.isFail()) return Result.fail(new UpdateEntryLockError(updateResult.error));
|
|
28
|
+
return Result.ok(updateResult.value);
|
|
29
|
+
}
|
|
30
|
+
const identity = this.identityContext.getIdentity();
|
|
31
|
+
if (record.lockedBy.id !== identity.id) return Result.fail(new IdentityMismatchError({
|
|
32
|
+
currentId: identity.id,
|
|
33
|
+
targetId: record.lockedBy.id
|
|
34
|
+
}));
|
|
35
|
+
const updateResult = await this.repository.update(record.id, false);
|
|
36
|
+
if (updateResult.isFail()) return Result.fail(new UpdateEntryLockError(updateResult.error));
|
|
37
|
+
return Result.ok(updateResult.value);
|
|
53
38
|
}
|
|
54
|
-
return Result.ok(updateResult.value);
|
|
55
|
-
}
|
|
56
39
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
40
|
+
const UpdateEntryLockUseCase_UpdateEntryLockUseCase = UpdateEntryLockUseCase.createImplementation({
|
|
41
|
+
implementation: UpdateEntryLockUseCaseImpl,
|
|
42
|
+
dependencies: [
|
|
43
|
+
GetLockRecordUseCase,
|
|
44
|
+
LockEntryUseCase,
|
|
45
|
+
UpdateEntryLockRepository,
|
|
46
|
+
IdentityContext
|
|
47
|
+
]
|
|
60
48
|
});
|
|
49
|
+
export { UpdateEntryLockUseCase_UpdateEntryLockUseCase as UpdateEntryLockUseCase };
|
|
61
50
|
|
|
62
51
|
//# sourceMappingURL=UpdateEntryLockUseCase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/UpdateEntryLock/UpdateEntryLockUseCase.js","sources":["../../../src/features/UpdateEntryLock/UpdateEntryLockUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n UpdateEntryLockUseCase as UseCaseAbstraction,\n UpdateEntryLockRepository,\n UpdateEntryLockInput\n} from \"./abstractions.js\";\nimport { GetLockRecordUseCase } from \"../GetLockRecord/abstractions.js\";\nimport { LockEntryUseCase } from \"../LockEntry/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport {\n LockRecordNotFoundError,\n IdentityMismatchError,\n UpdateEntryLockError\n} from \"~/domain/errors.js\";\n\nclass UpdateEntryLockUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getLockRecord: GetLockRecordUseCase.Interface,\n private lockEntry: LockEntryUseCase.Interface,\n private repository: UpdateEntryLockRepository.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute(\n input: UpdateEntryLockInput\n ): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Try to get existing lock record\n const recordResult = await this.getLockRecord.execute(input);\n\n // If doesn't exist, create a new lock\n if (recordResult.isFail()) {\n if (recordResult.error instanceof LockRecordNotFoundError) {\n const lockResult = await this.lockEntry.execute(input);\n if (lockResult.isFail()) {\n return Result.fail(new UpdateEntryLockError(lockResult.error));\n }\n return Result.ok(lockResult.value);\n }\n return Result.fail(recordResult.error);\n }\n\n const record = recordResult.value;\n\n // If expired, update with current user as new owner\n if (record.isExpired()) {\n const updateResult = await this.repository.update(record.id, true);\n if (updateResult.isFail()) {\n return Result.fail(new UpdateEntryLockError(updateResult.error));\n }\n return Result.ok(updateResult.value);\n }\n\n // If not expired, validate same owner\n const identity = this.identityContext.getIdentity();\n if (record.lockedBy.id !== identity.id) {\n return Result.fail(\n new IdentityMismatchError({\n currentId: identity.id,\n targetId: record.lockedBy.id\n })\n );\n }\n\n // Update timestamp only\n const updateResult = await this.repository.update(record.id, false);\n if (updateResult.isFail()) {\n return Result.fail(new UpdateEntryLockError(updateResult.error));\n }\n\n return Result.ok(updateResult.value);\n }\n}\n\nexport const UpdateEntryLockUseCase = UseCaseAbstraction.createImplementation({\n implementation: UpdateEntryLockUseCaseImpl,\n dependencies: [\n GetLockRecordUseCase,\n LockEntryUseCase,\n UpdateEntryLockRepository,\n IdentityContext\n ]\n});\n"],"names":["UpdateEntryLockUseCaseImpl","getLockRecord","lockEntry","repository","identityContext","input","recordResult","LockRecordNotFoundError","lockResult","Result","UpdateEntryLockError","record","updateResult","identity","IdentityMismatchError","UpdateEntryLockUseCase","UseCaseAbstraction","GetLockRecordUseCase","LockEntryUseCase","UpdateEntryLockRepository","IdentityContext"],"mappings":";;;;;;AAgBA,MAAMA;IACF,YACYC,aAA6C,EAC7CC,SAAqC,EACrCC,UAA+C,EAC/CC,eAA0C,CACpD;aAJUH,aAAa,GAAbA;aACAC,SAAS,GAATA;aACAC,UAAU,GAAVA;aACAC,eAAe,GAAfA;IACT;IAEH,MAAM,QACFC,KAA2B,EAC2B;QAEtD,MAAMC,eAAe,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAACD;QAGtD,IAAIC,aAAa,MAAM,IAAI;YACvB,IAAIA,aAAa,KAAK,YAAYC,yBAAyB;gBACvD,MAAMC,aAAa,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACH;gBAChD,IAAIG,WAAW,MAAM,IACjB,OAAOC,OAAO,IAAI,CAAC,IAAIC,qBAAqBF,WAAW,KAAK;gBAEhE,OAAOC,OAAO,EAAE,CAACD,WAAW,KAAK;YACrC;YACA,OAAOC,OAAO,IAAI,CAACH,aAAa,KAAK;QACzC;QAEA,MAAMK,SAASL,aAAa,KAAK;QAGjC,IAAIK,OAAO,SAAS,IAAI;YACpB,MAAMC,eAAe,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAACD,OAAO,EAAE,EAAE;YAC7D,IAAIC,aAAa,MAAM,IACnB,OAAOH,OAAO,IAAI,CAAC,IAAIC,qBAAqBE,aAAa,KAAK;YAElE,OAAOH,OAAO,EAAE,CAACG,aAAa,KAAK;QACvC;QAGA,MAAMC,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;QACjD,IAAIF,OAAO,QAAQ,CAAC,EAAE,KAAKE,SAAS,EAAE,EAClC,OAAOJ,OAAO,IAAI,CACd,IAAIK,sBAAsB;YACtB,WAAWD,SAAS,EAAE;YACtB,UAAUF,OAAO,QAAQ,CAAC,EAAE;QAChC;QAKR,MAAMC,eAAe,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAACD,OAAO,EAAE,EAAE;QAC7D,IAAIC,aAAa,MAAM,IACnB,OAAOH,OAAO,IAAI,CAAC,IAAIC,qBAAqBE,aAAa,KAAK;QAGlE,OAAOH,OAAO,EAAE,CAACG,aAAa,KAAK;IACvC;AACJ;AAEO,MAAMG,gDAAyBC,uBAAAA,oBAAuC,CAAC;IAC1E,gBAAgBhB;IAChB,cAAc;QACViB;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* UpdateEntryLock Use Case - Updates lock timestamp to keep it alive
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
export const UpdateEntryLockUseCase = createAbstraction("UpdateEntryLockUseCase");
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* UpdateEntryLockRepository - Updates lock record in storage
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
export const UpdateEntryLockRepository = createAbstraction("UpdateEntryLockRepository");
|
|
2
|
+
const UpdateEntryLockUseCase = createAbstraction("UpdateEntryLockUseCase");
|
|
3
|
+
const UpdateEntryLockRepository = createAbstraction("UpdateEntryLockRepository");
|
|
4
|
+
export { UpdateEntryLockRepository, UpdateEntryLockUseCase };
|
|
16
5
|
|
|
17
6
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/UpdateEntryLock/abstractions.js","sources":["../../../src/features/UpdateEntryLock/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordEntryType } from \"~/domain/types.js\";\nimport type {\n LockRecordNotFoundError,\n LockRecordPersistenceError,\n IdentityMismatchError,\n UpdateEntryLockError\n} from \"~/domain/errors.js\";\n\n// Input types\nexport interface UpdateEntryLockInput {\n id: string;\n type: LockRecordEntryType;\n}\n\n/**\n * UpdateEntryLock Use Case - Updates lock timestamp to keep it alive\n */\nexport interface IUpdateEntryLockUseCase {\n execute(input: UpdateEntryLockInput): Promise<Result<ILockRecord, UseCaseError>>;\n}\n\nexport interface IUpdateEntryLockUseCaseErrors {\n notFound: LockRecordNotFoundError;\n notSameIdentity: IdentityMismatchError;\n persistence: LockRecordPersistenceError;\n updateError: UpdateEntryLockError;\n}\n\ntype UseCaseError = IUpdateEntryLockUseCaseErrors[keyof IUpdateEntryLockUseCaseErrors];\n\nexport const UpdateEntryLockUseCase =\n createAbstraction<IUpdateEntryLockUseCase>(\"UpdateEntryLockUseCase\");\n\nexport namespace UpdateEntryLockUseCase {\n export type Interface = IUpdateEntryLockUseCase;\n export type Error = UseCaseError;\n}\n\n/**\n * UpdateEntryLockRepository - Updates lock record in storage\n */\nexport interface IUpdateEntryLockRepository {\n update(\n lockRecordId: string,\n updateOwner: boolean\n ): Promise<Result<ILockRecord, RepositoryError>>;\n}\n\nexport interface IUpdateEntryLockRepositoryErrors {\n persistence: LockRecordPersistenceError;\n}\n\ntype RepositoryError = IUpdateEntryLockRepositoryErrors[keyof IUpdateEntryLockRepositoryErrors];\n\nexport const UpdateEntryLockRepository = createAbstraction<IUpdateEntryLockRepository>(\n \"UpdateEntryLockRepository\"\n);\n\nexport namespace UpdateEntryLockRepository {\n export type Interface = IUpdateEntryLockRepository;\n export type Error = RepositoryError;\n}\n"],"names":["UpdateEntryLockUseCase","createAbstraction","UpdateEntryLockRepository"],"mappings":";AAiCO,MAAMA,yBACTC,kBAA2C;AAuBxC,MAAMC,4BAA4BD,kBACrC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { UpdateEntryLockUseCase } from "./UpdateEntryLockUseCase.js";
|
|
3
3
|
import { UpdateEntryLockRepository } from "./UpdateEntryLockRepository.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const UpdateEntryLockFeature = createFeature({
|
|
5
|
+
name: "UpdateEntryLock",
|
|
6
|
+
register (container) {
|
|
7
|
+
container.register(UpdateEntryLockUseCase);
|
|
8
|
+
container.register(UpdateEntryLockRepository).inSingletonScope();
|
|
9
|
+
}
|
|
10
10
|
});
|
|
11
|
+
export { UpdateEntryLockFeature };
|
|
11
12
|
|
|
12
13
|
//# sourceMappingURL=feature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/UpdateEntryLock/feature.js","sources":["../../../src/features/UpdateEntryLock/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { UpdateEntryLockUseCase } from \"./UpdateEntryLockUseCase.js\";\nimport { UpdateEntryLockRepository } from \"./UpdateEntryLockRepository.js\";\n\nexport const UpdateEntryLockFeature = createFeature({\n name: \"UpdateEntryLock\",\n register(container) {\n container.register(UpdateEntryLockUseCase);\n container.register(UpdateEntryLockRepository).inSingletonScope();\n }\n});\n"],"names":["UpdateEntryLockFeature","createFeature","container","UpdateEntryLockUseCase","UpdateEntryLockRepository"],"mappings":";;;AAIO,MAAMA,yBAAyBC,cAAc;IAChD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,2BAA2B,gBAAgB;IAClE;AACJ"}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
|
|
1
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
2
2
|
import { NotAuthorizedError } from "@webiny/api-core/features/security/shared";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const identityContext = context.container.resolve(IdentityContext);
|
|
8
|
-
const identity = identityContext.getIdentity();
|
|
9
|
-
if (identity.isAnonymous()) {
|
|
10
|
-
throw new NotAuthorizedError();
|
|
11
|
-
}
|
|
3
|
+
const checkPermissions = async (context)=>{
|
|
4
|
+
const identityContext = context.container.resolve(IdentityContext);
|
|
5
|
+
const identity = identityContext.getIdentity();
|
|
6
|
+
if (identity.isAnonymous()) throw new NotAuthorizedError();
|
|
12
7
|
};
|
|
8
|
+
export { checkPermissions };
|
|
13
9
|
|
|
14
10
|
//# sourceMappingURL=checkPermissions.js.map
|