@webiny/api-record-locking 0.0.0-unstable.06b2ede40f → 0.0.0-unstable.0d717d18dd
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/README.md +10 -9
- package/RecordLockingAppFeature.d.ts +11 -0
- package/RecordLockingAppFeature.js +18 -0
- package/RecordLockingAppFeature.js.map +1 -0
- package/domain/LockRecord.d.ts +45 -0
- package/domain/LockRecord.js +73 -0
- package/domain/LockRecord.js.map +1 -0
- package/domain/RecordLockingAppConfig.d.ts +4 -0
- package/domain/RecordLockingAppConfig.js +5 -0
- package/domain/RecordLockingAppConfig.js.map +1 -0
- package/domain/RecordLockingModel.d.ts +9 -0
- package/domain/RecordLockingModel.js +32 -0
- package/domain/RecordLockingModel.js.map +1 -0
- package/domain/abstractions.d.ts +18 -0
- package/domain/abstractions.js +6 -0
- package/domain/abstractions.js.map +1 -0
- package/domain/calculateExpiresOn.d.ts +1 -0
- package/domain/calculateExpiresOn.js +8 -0
- package/domain/calculateExpiresOn.js.map +1 -0
- package/domain/errors.d.ts +71 -0
- package/domain/errors.js +85 -0
- package/domain/errors.js.map +1 -0
- package/domain/index.d.ts +4 -0
- package/domain/index.js +4 -0
- package/domain/types.d.ts +44 -0
- package/domain/types.js +9 -0
- package/domain/types.js.map +1 -0
- package/features/GetLockRecord/GetLockRecordRepository.d.ts +16 -0
- package/features/GetLockRecord/GetLockRecordRepository.js +40 -0
- package/features/GetLockRecord/GetLockRecordRepository.js.map +1 -0
- package/features/GetLockRecord/GetLockRecordUseCase.d.ts +12 -0
- package/features/GetLockRecord/GetLockRecordUseCase.js +18 -0
- package/features/GetLockRecord/GetLockRecordUseCase.js.map +1 -0
- package/features/GetLockRecord/abstractions.d.ts +41 -0
- package/features/GetLockRecord/abstractions.js +6 -0
- package/features/GetLockRecord/abstractions.js.map +1 -0
- package/features/GetLockRecord/feature.d.ts +4 -0
- package/features/GetLockRecord/feature.js +13 -0
- package/features/GetLockRecord/feature.js.map +1 -0
- package/features/GetLockRecord/index.d.ts +2 -0
- package/features/GetLockRecord/index.js +2 -0
- package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.d.ts +15 -0
- package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js +30 -0
- package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js.map +1 -0
- package/features/GetLockedEntryLockRecord/abstractions.d.ts +26 -0
- package/features/GetLockedEntryLockRecord/abstractions.js +5 -0
- package/features/GetLockedEntryLockRecord/abstractions.js.map +1 -0
- package/features/GetLockedEntryLockRecord/feature.d.ts +4 -0
- package/features/GetLockedEntryLockRecord/feature.js +11 -0
- package/features/GetLockedEntryLockRecord/feature.js.map +1 -0
- package/features/GetLockedEntryLockRecord/index.d.ts +2 -0
- package/features/GetLockedEntryLockRecord/index.js +2 -0
- package/features/IsEntryLocked/IsEntryLockedUseCase.d.ts +14 -0
- package/features/IsEntryLocked/IsEntryLockedUseCase.js +33 -0
- package/features/IsEntryLocked/IsEntryLockedUseCase.js.map +1 -0
- package/features/IsEntryLocked/abstractions.d.ts +24 -0
- package/features/IsEntryLocked/abstractions.js +5 -0
- package/features/IsEntryLocked/abstractions.js.map +1 -0
- package/features/IsEntryLocked/feature.d.ts +4 -0
- package/features/IsEntryLocked/feature.js +11 -0
- package/features/IsEntryLocked/feature.js.map +1 -0
- package/features/IsEntryLocked/index.d.ts +1 -0
- package/features/IsEntryLocked/index.js +1 -0
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.d.ts +15 -0
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js +36 -0
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js.map +1 -0
- package/features/KickOutCurrentUser/abstractions.d.ts +17 -0
- package/features/KickOutCurrentUser/abstractions.js +5 -0
- package/features/KickOutCurrentUser/abstractions.js.map +1 -0
- package/features/KickOutCurrentUser/feature.d.ts +4 -0
- package/features/KickOutCurrentUser/feature.js +11 -0
- package/features/KickOutCurrentUser/feature.js.map +1 -0
- package/features/KickOutCurrentUser/index.d.ts +1 -0
- package/features/KickOutCurrentUser/index.js +1 -0
- package/features/ListAllLockRecords/ListAllLockRecordsRepository.d.ts +18 -0
- package/features/ListAllLockRecords/ListAllLockRecordsRepository.js +49 -0
- package/features/ListAllLockRecords/ListAllLockRecordsRepository.js.map +1 -0
- package/features/ListAllLockRecords/ListAllLockRecordsUseCase.d.ts +11 -0
- package/features/ListAllLockRecords/ListAllLockRecordsUseCase.js +18 -0
- package/features/ListAllLockRecords/ListAllLockRecordsUseCase.js.map +1 -0
- package/features/ListAllLockRecords/abstractions.d.ts +40 -0
- package/features/ListAllLockRecords/abstractions.js +6 -0
- package/features/ListAllLockRecords/abstractions.js.map +1 -0
- package/features/ListAllLockRecords/feature.d.ts +4 -0
- package/features/ListAllLockRecords/feature.js +13 -0
- package/features/ListAllLockRecords/feature.js.map +1 -0
- package/features/ListAllLockRecords/index.d.ts +2 -0
- package/features/ListAllLockRecords/index.js +2 -0
- package/features/ListLockRecords/ListLockRecordsRepository.d.ts +17 -0
- package/features/ListLockRecords/ListLockRecordsRepository.js +49 -0
- package/features/ListLockRecords/ListLockRecordsRepository.js.map +1 -0
- package/features/ListLockRecords/ListLockRecordsUseCase.d.ts +15 -0
- package/features/ListLockRecords/ListLockRecordsUseCase.js +33 -0
- package/features/ListLockRecords/ListLockRecordsUseCase.js.map +1 -0
- package/features/ListLockRecords/abstractions.d.ts +45 -0
- package/features/ListLockRecords/abstractions.js +6 -0
- package/features/ListLockRecords/abstractions.js.map +1 -0
- package/features/ListLockRecords/feature.d.ts +4 -0
- package/features/ListLockRecords/feature.js +13 -0
- package/features/ListLockRecords/feature.js.map +1 -0
- package/features/ListLockRecords/index.d.ts +1 -0
- package/features/ListLockRecords/index.js +1 -0
- package/features/LockEntry/LockEntryEventsDecorator.d.ts +14 -0
- package/features/LockEntry/LockEntryEventsDecorator.js +40 -0
- package/features/LockEntry/LockEntryEventsDecorator.js.map +1 -0
- package/features/LockEntry/LockEntryRepository.d.ts +16 -0
- package/features/LockEntry/LockEntryRepository.js +45 -0
- package/features/LockEntry/LockEntryRepository.js.map +1 -0
- package/features/LockEntry/LockEntryUseCase.d.ts +14 -0
- package/features/LockEntry/LockEntryUseCase.js +31 -0
- package/features/LockEntry/LockEntryUseCase.js.map +1 -0
- package/features/LockEntry/abstractions.d.ts +41 -0
- package/features/LockEntry/abstractions.js +6 -0
- package/features/LockEntry/abstractions.js.map +1 -0
- package/features/LockEntry/events.d.ts +45 -0
- package/features/LockEntry/events.js +32 -0
- package/features/LockEntry/events.js.map +1 -0
- package/features/LockEntry/feature.d.ts +4 -0
- package/features/LockEntry/feature.js +15 -0
- package/features/LockEntry/feature.js.map +1 -0
- package/features/LockEntry/index.d.ts +1 -0
- package/features/LockEntry/index.js +1 -0
- package/features/RecordLockingFeature.d.ts +15 -0
- package/features/RecordLockingFeature.js +34 -0
- package/features/RecordLockingFeature.js.map +1 -0
- package/features/UnlockEntry/UnlockEntryEventsDecorator.d.ts +14 -0
- package/features/UnlockEntry/UnlockEntryEventsDecorator.js +41 -0
- package/features/UnlockEntry/UnlockEntryEventsDecorator.js.map +1 -0
- package/features/UnlockEntry/UnlockEntryRepository.d.ts +14 -0
- package/features/UnlockEntry/UnlockEntryRepository.js +42 -0
- package/features/UnlockEntry/UnlockEntryRepository.js.map +1 -0
- package/features/UnlockEntry/UnlockEntryUseCase.d.ts +18 -0
- package/features/UnlockEntry/UnlockEntryUseCase.js +65 -0
- package/features/UnlockEntry/UnlockEntryUseCase.js.map +1 -0
- package/features/UnlockEntry/abstractions.d.ts +44 -0
- package/features/UnlockEntry/abstractions.js +6 -0
- package/features/UnlockEntry/abstractions.js.map +1 -0
- package/features/UnlockEntry/events.d.ts +46 -0
- package/features/UnlockEntry/events.js +32 -0
- package/features/UnlockEntry/events.js.map +1 -0
- package/features/UnlockEntry/feature.d.ts +4 -0
- package/features/UnlockEntry/feature.js +15 -0
- package/features/UnlockEntry/feature.js.map +1 -0
- package/features/UnlockEntry/hasFullAccessPermission.d.ts +2 -0
- package/features/UnlockEntry/hasFullAccessPermission.js +9 -0
- package/features/UnlockEntry/hasFullAccessPermission.js.map +1 -0
- package/features/UnlockEntry/index.d.ts +1 -0
- package/features/UnlockEntry/index.js +1 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.d.ts +14 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js +40 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js.map +1 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.d.ts +17 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js +44 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js.map +1 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.d.ts +16 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js +75 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js.map +1 -0
- package/features/UnlockEntryRequest/abstractions.d.ts +42 -0
- package/features/UnlockEntryRequest/abstractions.js +6 -0
- package/features/UnlockEntryRequest/abstractions.js.map +1 -0
- package/features/UnlockEntryRequest/events.d.ts +45 -0
- package/features/UnlockEntryRequest/events.js +32 -0
- package/features/UnlockEntryRequest/events.js.map +1 -0
- package/features/UnlockEntryRequest/feature.d.ts +4 -0
- package/features/UnlockEntryRequest/feature.js +15 -0
- package/features/UnlockEntryRequest/feature.js.map +1 -0
- package/features/UnlockEntryRequest/index.d.ts +3 -0
- package/features/UnlockEntryRequest/index.js +3 -0
- package/features/UpdateEntryLock/UpdateEntryLockRepository.d.ts +20 -0
- package/features/UpdateEntryLock/UpdateEntryLockRepository.js +60 -0
- package/features/UpdateEntryLock/UpdateEntryLockRepository.js.map +1 -0
- package/features/UpdateEntryLock/UpdateEntryLockUseCase.d.ts +18 -0
- package/features/UpdateEntryLock/UpdateEntryLockUseCase.js +51 -0
- package/features/UpdateEntryLock/UpdateEntryLockUseCase.js.map +1 -0
- package/features/UpdateEntryLock/abstractions.d.ts +42 -0
- package/features/UpdateEntryLock/abstractions.js +6 -0
- package/features/UpdateEntryLock/abstractions.js.map +1 -0
- package/features/UpdateEntryLock/feature.d.ts +4 -0
- package/features/UpdateEntryLock/feature.js +13 -0
- package/features/UpdateEntryLock/feature.js.map +1 -0
- package/features/UpdateEntryLock/index.d.ts +1 -0
- package/features/UpdateEntryLock/index.js +1 -0
- package/graphql/RecordLockingContextualSchema.d.ts +18 -0
- package/graphql/RecordLockingContextualSchema.js +77 -0
- package/graphql/RecordLockingContextualSchema.js.map +1 -0
- package/graphql/checkPermissions.d.ts +5 -0
- package/graphql/checkPermissions.js +10 -0
- package/graphql/checkPermissions.js.map +1 -0
- package/{utils → graphql}/resolve.d.ts +4 -4
- package/graphql/resolve.js +20 -0
- package/graphql/resolve.js.map +1 -0
- package/graphql/schema.d.ts +8 -4
- package/graphql/schema.js +162 -145
- package/graphql/schema.js.map +1 -1
- package/index.d.ts +2 -9
- package/index.js +1 -39
- package/package.json +32 -28
- package/types.d.ts +3 -132
- package/types.js +6 -27
- package/types.js.map +1 -1
- package/utils/convertWhereCondition.d.ts +1 -1
- package/utils/convertWhereCondition.js +21 -36
- package/utils/convertWhereCondition.js.map +1 -1
- package/utils/getTimeout.js +8 -22
- package/utils/getTimeout.js.map +1 -1
- package/utils/lockRecordDatabaseId.js +7 -20
- package/utils/lockRecordDatabaseId.js.map +1 -1
- package/abstractions/IGetLockRecordUseCase.d.ts +0 -8
- package/abstractions/IGetLockRecordUseCase.js +0 -7
- package/abstractions/IGetLockRecordUseCase.js.map +0 -1
- package/abstractions/IGetLockedEntryLockRecordUseCase.d.ts +0 -8
- package/abstractions/IGetLockedEntryLockRecordUseCase.js +0 -7
- package/abstractions/IGetLockedEntryLockRecordUseCase.js.map +0 -1
- package/abstractions/IIsEntryLocked.d.ts +0 -8
- package/abstractions/IIsEntryLocked.js +0 -7
- package/abstractions/IIsEntryLocked.js.map +0 -1
- package/abstractions/IKickOutCurrentUserUseCase.d.ts +0 -5
- package/abstractions/IKickOutCurrentUserUseCase.js +0 -7
- package/abstractions/IKickOutCurrentUserUseCase.js.map +0 -1
- package/abstractions/IListAllLockRecordsUseCase.d.ts +0 -9
- package/abstractions/IListAllLockRecordsUseCase.js +0 -7
- package/abstractions/IListAllLockRecordsUseCase.js.map +0 -1
- package/abstractions/IListLockRecordsUseCase.d.ts +0 -10
- package/abstractions/IListLockRecordsUseCase.js +0 -7
- package/abstractions/IListLockRecordsUseCase.js.map +0 -1
- package/abstractions/ILockEntryUseCase.d.ts +0 -11
- package/abstractions/ILockEntryUseCase.js +0 -7
- package/abstractions/ILockEntryUseCase.js.map +0 -1
- package/abstractions/IUnlockEntryRequestUseCase.d.ts +0 -11
- package/abstractions/IUnlockEntryRequestUseCase.js +0 -7
- package/abstractions/IUnlockEntryRequestUseCase.js.map +0 -1
- package/abstractions/IUnlockEntryUseCase.d.ts +0 -12
- package/abstractions/IUnlockEntryUseCase.js +0 -7
- package/abstractions/IUnlockEntryUseCase.js.map +0 -1
- package/abstractions/IUpdateEntryLockUseCase.d.ts +0 -11
- package/abstractions/IUpdateEntryLockUseCase.js +0 -7
- package/abstractions/IUpdateEntryLockUseCase.js.map +0 -1
- package/crud/crud.d.ts +0 -7
- package/crud/crud.js +0 -204
- package/crud/crud.js.map +0 -1
- package/crud/model.d.ts +0 -2
- package/crud/model.js +0 -127
- package/crud/model.js.map +0 -1
- package/index.js.map +0 -1
- package/useCases/GetLockRecord/GetLockRecordUseCase.d.ts +0 -16
- package/useCases/GetLockRecord/GetLockRecordUseCase.js +0 -39
- package/useCases/GetLockRecord/GetLockRecordUseCase.js.map +0 -1
- package/useCases/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.d.ts +0 -16
- package/useCases/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js +0 -29
- package/useCases/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js.map +0 -1
- package/useCases/IsEntryLocked/IsEntryLockedUseCase.d.ts +0 -13
- package/useCases/IsEntryLocked/IsEntryLockedUseCase.js +0 -31
- package/useCases/IsEntryLocked/IsEntryLockedUseCase.js.map +0 -1
- package/useCases/KickOutCurrentUser/KickOutCurrentUserUseCase.d.ts +0 -12
- package/useCases/KickOutCurrentUser/KickOutCurrentUserUseCase.js +0 -46
- package/useCases/KickOutCurrentUser/KickOutCurrentUserUseCase.js.map +0 -1
- package/useCases/ListAllLockRecordsUseCase/ListAllLockRecordsUseCase.d.ts +0 -13
- package/useCases/ListAllLockRecordsUseCase/ListAllLockRecordsUseCase.js +0 -34
- package/useCases/ListAllLockRecordsUseCase/ListAllLockRecordsUseCase.js.map +0 -1
- package/useCases/ListLockRecordsUseCase/ListLockRecordsUseCase.d.ts +0 -14
- package/useCases/ListLockRecordsUseCase/ListLockRecordsUseCase.js +0 -27
- package/useCases/ListLockRecordsUseCase/ListLockRecordsUseCase.js.map +0 -1
- package/useCases/LockEntryUseCase/LockEntryUseCase.d.ts +0 -21
- package/useCases/LockEntryUseCase/LockEntryUseCase.js +0 -64
- package/useCases/LockEntryUseCase/LockEntryUseCase.js.map +0 -1
- package/useCases/UnlockEntryUseCase/UnlockEntryUseCase.d.ts +0 -23
- package/useCases/UnlockEntryUseCase/UnlockEntryUseCase.js +0 -90
- package/useCases/UnlockEntryUseCase/UnlockEntryUseCase.js.map +0 -1
- package/useCases/UnlockRequestUseCase/UnlockEntryRequestUseCase.d.ts +0 -21
- package/useCases/UnlockRequestUseCase/UnlockEntryRequestUseCase.js +0 -82
- package/useCases/UnlockRequestUseCase/UnlockEntryRequestUseCase.js.map +0 -1
- package/useCases/UpdateEntryLock/UpdateEntryLockUseCase.d.ts +0 -26
- package/useCases/UpdateEntryLock/UpdateEntryLockUseCase.js +0 -93
- package/useCases/UpdateEntryLock/UpdateEntryLockUseCase.js.map +0 -1
- package/useCases/index.d.ts +0 -31
- package/useCases/index.js +0 -96
- package/useCases/index.js.map +0 -1
- package/useCases/types.d.ts +0 -5
- package/useCases/types.js +0 -7
- package/useCases/types.js.map +0 -1
- package/utils/calculateExpiresOn.d.ts +0 -2
- package/utils/calculateExpiresOn.js +0 -16
- package/utils/calculateExpiresOn.js.map +0 -1
- package/utils/checkPermissions.d.ts +0 -7
- package/utils/checkPermissions.js +0 -21
- package/utils/checkPermissions.js.map +0 -1
- package/utils/convertEntryToLockRecord.d.ts +0 -28
- package/utils/convertEntryToLockRecord.js +0 -91
- package/utils/convertEntryToLockRecord.js.map +0 -1
- package/utils/resolve.js +0 -30
- package/utils/resolve.js.map +0 -1
- package/utils/validateSameIdentity.d.ts +0 -6
- package/utils/validateSameIdentity.js +0 -24
- package/utils/validateSameIdentity.js.map +0 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import type { ILockRecord } from "../../domain/LockRecord.js";
|
|
3
|
+
import type { LockRecordEntryType } from "../../domain/types.js";
|
|
4
|
+
import type { LockRecordNotFoundError, LockRecordPersistenceError, IdentityMismatchError, UpdateEntryLockError } from "../../domain/errors.js";
|
|
5
|
+
export interface UpdateEntryLockInput {
|
|
6
|
+
id: string;
|
|
7
|
+
type: LockRecordEntryType;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* UpdateEntryLock Use Case - Updates lock timestamp to keep it alive
|
|
11
|
+
*/
|
|
12
|
+
export interface IUpdateEntryLockUseCase {
|
|
13
|
+
execute(input: UpdateEntryLockInput): Promise<Result<ILockRecord, UseCaseError>>;
|
|
14
|
+
}
|
|
15
|
+
export interface IUpdateEntryLockUseCaseErrors {
|
|
16
|
+
notFound: LockRecordNotFoundError;
|
|
17
|
+
notSameIdentity: IdentityMismatchError;
|
|
18
|
+
persistence: LockRecordPersistenceError;
|
|
19
|
+
updateError: UpdateEntryLockError;
|
|
20
|
+
}
|
|
21
|
+
type UseCaseError = IUpdateEntryLockUseCaseErrors[keyof IUpdateEntryLockUseCaseErrors];
|
|
22
|
+
export declare const UpdateEntryLockUseCase: import("@webiny/di").Abstraction<IUpdateEntryLockUseCase>;
|
|
23
|
+
export declare namespace UpdateEntryLockUseCase {
|
|
24
|
+
type Interface = IUpdateEntryLockUseCase;
|
|
25
|
+
type Error = UseCaseError;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* UpdateEntryLockRepository - Updates lock record in storage
|
|
29
|
+
*/
|
|
30
|
+
export interface IUpdateEntryLockRepository {
|
|
31
|
+
update(lockRecordId: string, updateOwner: boolean): Promise<Result<ILockRecord, RepositoryError>>;
|
|
32
|
+
}
|
|
33
|
+
export interface IUpdateEntryLockRepositoryErrors {
|
|
34
|
+
persistence: LockRecordPersistenceError;
|
|
35
|
+
}
|
|
36
|
+
type RepositoryError = IUpdateEntryLockRepositoryErrors[keyof IUpdateEntryLockRepositoryErrors];
|
|
37
|
+
export declare const UpdateEntryLockRepository: import("@webiny/di").Abstraction<IUpdateEntryLockRepository>;
|
|
38
|
+
export declare namespace UpdateEntryLockRepository {
|
|
39
|
+
type Interface = IUpdateEntryLockRepository;
|
|
40
|
+
type Error = RepositoryError;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
const UpdateEntryLockUseCase = createAbstraction("UpdateEntryLockUseCase");
|
|
3
|
+
const UpdateEntryLockRepository = createAbstraction("UpdateEntryLockRepository");
|
|
4
|
+
export { UpdateEntryLockRepository, UpdateEntryLockUseCase };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=abstractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { UpdateEntryLockUseCase } from "./UpdateEntryLockUseCase.js";
|
|
3
|
+
import { UpdateEntryLockRepository } from "./UpdateEntryLockRepository.js";
|
|
4
|
+
const UpdateEntryLockFeature = createFeature({
|
|
5
|
+
name: "UpdateEntryLock",
|
|
6
|
+
register (container) {
|
|
7
|
+
container.register(UpdateEntryLockUseCase);
|
|
8
|
+
container.register(UpdateEntryLockRepository).inSingletonScope();
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
export { UpdateEntryLockFeature };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./abstractions.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./abstractions.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { GraphQLSchema } from "graphql";
|
|
2
|
+
import type { IGraphQLContextualSchema } from "@webiny/api-graphql";
|
|
3
|
+
import { WcpContext } from "@webiny/api-core/features/wcp/WcpContext/index.js";
|
|
4
|
+
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
5
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
6
|
+
import { type IRecordLockingAppConfig } from "../domain/RecordLockingAppConfig.js";
|
|
7
|
+
declare class RecordLockingContextualSchemaImpl implements IGraphQLContextualSchema {
|
|
8
|
+
private wcp;
|
|
9
|
+
private tenantCtx;
|
|
10
|
+
private identityCtx;
|
|
11
|
+
private config;
|
|
12
|
+
constructor(wcp: WcpContext.Interface, tenantCtx: TenantContext.Interface, identityCtx: IdentityContext.Interface, config: IRecordLockingAppConfig);
|
|
13
|
+
build(ctx: Record<string, any>): Promise<GraphQLSchema>;
|
|
14
|
+
}
|
|
15
|
+
export declare const RecordLockingContextualSchema: typeof RecordLockingContextualSchemaImpl & {
|
|
16
|
+
__abstraction: import("@webiny/di").Abstraction<IGraphQLContextualSchema>;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { makeExecutableSchema } from "@graphql-tools/schema";
|
|
2
|
+
import { mergeResolvers } from "@graphql-tools/merge";
|
|
3
|
+
import { GraphQLContextualSchema } from "@webiny/api-graphql";
|
|
4
|
+
import { WcpContext } from "@webiny/api-core/features/wcp/WcpContext/index.js";
|
|
5
|
+
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
6
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
7
|
+
import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel";
|
|
8
|
+
import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels";
|
|
9
|
+
import { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/exports/api/cms/graphql.js";
|
|
10
|
+
import { createBaseContentSchema } from "@webiny/api-headless-cms/graphql/schema/baseContentSchema.js";
|
|
11
|
+
import { RECORD_LOCKING_MODEL_ID } from "../domain/RecordLockingModel.js";
|
|
12
|
+
import { RecordLockingAppConfig } from "../domain/RecordLockingAppConfig.js";
|
|
13
|
+
import { RecordLockingFeature } from "../features/RecordLockingFeature.js";
|
|
14
|
+
import { createGraphQLSchema } from "./schema.js";
|
|
15
|
+
class RecordLockingContextualSchemaImpl {
|
|
16
|
+
constructor(wcp, tenantCtx, identityCtx, config){
|
|
17
|
+
this.wcp = wcp;
|
|
18
|
+
this.tenantCtx = tenantCtx;
|
|
19
|
+
this.identityCtx = identityCtx;
|
|
20
|
+
this.config = config;
|
|
21
|
+
}
|
|
22
|
+
async build(ctx) {
|
|
23
|
+
if (!this.wcp.canUseRecordLocking() || !this.tenantCtx.getTenant()) return makeExecutableSchema({
|
|
24
|
+
typeDefs: "type Query\ntype Mutation",
|
|
25
|
+
assumeValidSDL: true
|
|
26
|
+
});
|
|
27
|
+
const container = ctx.container;
|
|
28
|
+
const getModel = container.resolve(GetModelUseCase);
|
|
29
|
+
const listModels = container.resolve(ListModelsUseCase);
|
|
30
|
+
const fieldRegistry = container.resolve(CmsModelFieldToGraphQLRegistry);
|
|
31
|
+
const [model, publicModels] = await this.identityCtx.withoutAuthorization(async ()=>{
|
|
32
|
+
const [modelResult, publicModelsResult] = await Promise.all([
|
|
33
|
+
getModel.execute(RECORD_LOCKING_MODEL_ID),
|
|
34
|
+
listModels.execute({
|
|
35
|
+
includePrivate: false
|
|
36
|
+
})
|
|
37
|
+
]);
|
|
38
|
+
return [
|
|
39
|
+
modelResult.value,
|
|
40
|
+
publicModelsResult.value
|
|
41
|
+
];
|
|
42
|
+
});
|
|
43
|
+
RecordLockingFeature.register(container, {
|
|
44
|
+
timeout: this.config.timeout,
|
|
45
|
+
model
|
|
46
|
+
});
|
|
47
|
+
const plugin = await createGraphQLSchema({
|
|
48
|
+
model,
|
|
49
|
+
models: publicModels,
|
|
50
|
+
fieldRegistry
|
|
51
|
+
});
|
|
52
|
+
const baseContent = createBaseContentSchema();
|
|
53
|
+
return makeExecutableSchema({
|
|
54
|
+
typeDefs: [
|
|
55
|
+
baseContent.schema.typeDefs,
|
|
56
|
+
plugin.schema.typeDefs
|
|
57
|
+
],
|
|
58
|
+
resolvers: mergeResolvers([
|
|
59
|
+
baseContent.schema.resolvers,
|
|
60
|
+
plugin.schema.resolvers
|
|
61
|
+
]),
|
|
62
|
+
inheritResolversFromInterfaces: true
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const RecordLockingContextualSchema = GraphQLContextualSchema.createImplementation({
|
|
67
|
+
implementation: RecordLockingContextualSchemaImpl,
|
|
68
|
+
dependencies: [
|
|
69
|
+
WcpContext,
|
|
70
|
+
TenantContext,
|
|
71
|
+
IdentityContext,
|
|
72
|
+
RecordLockingAppConfig
|
|
73
|
+
]
|
|
74
|
+
});
|
|
75
|
+
export { RecordLockingContextualSchema };
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=RecordLockingContextualSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql/RecordLockingContextualSchema.js","sources":["../../src/graphql/RecordLockingContextualSchema.ts"],"sourcesContent":["import type { Container } from \"@webiny/di\";\nimport type { GraphQLSchema } from \"graphql\";\nimport { makeExecutableSchema } from \"@graphql-tools/schema\";\nimport { mergeResolvers } from \"@graphql-tools/merge\";\nimport { GraphQLContextualSchema } from \"@webiny/api-graphql\";\nimport type { IGraphQLContextualSchema } from \"@webiny/api-graphql\";\nimport { WcpContext } from \"@webiny/api-core/features/wcp/WcpContext/index.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\nimport { createBaseContentSchema } from \"@webiny/api-headless-cms/graphql/schema/baseContentSchema.js\";\nimport { RECORD_LOCKING_MODEL_ID } from \"~/domain/RecordLockingModel.js\";\nimport {\n RecordLockingAppConfig,\n type IRecordLockingAppConfig\n} from \"~/domain/RecordLockingAppConfig.js\";\nimport { RecordLockingFeature } from \"~/features/RecordLockingFeature.js\";\nimport { createGraphQLSchema } from \"~/graphql/schema.js\";\n\nclass RecordLockingContextualSchemaImpl implements IGraphQLContextualSchema {\n constructor(\n private wcp: WcpContext.Interface,\n private tenantCtx: TenantContext.Interface,\n private identityCtx: IdentityContext.Interface,\n private config: IRecordLockingAppConfig\n ) {}\n\n async build(ctx: Record<string, any>): Promise<GraphQLSchema> {\n if (!this.wcp.canUseRecordLocking() || !this.tenantCtx.getTenant()) {\n return makeExecutableSchema({\n typeDefs: \"type Query\\ntype Mutation\",\n assumeValidSDL: true\n });\n }\n\n const container = ctx.container as Container;\n\n // Resolve the CMS use-cases lazily here (at build/request time) rather than as\n // constructor dependencies. They depend on AccessControl/CmsContext, which the CMS\n // initializer only registers during its own build() — so injecting them eagerly would\n // fail when the engine constructs all contextual schemas before any build() has run.\n const getModel = container.resolve(GetModelUseCase);\n const listModels = container.resolve(ListModelsUseCase);\n const fieldRegistry = container.resolve(CmsModelFieldToGraphQLRegistry);\n\n const [model, publicModels] = await this.identityCtx.withoutAuthorization(async () => {\n const [modelResult, publicModelsResult] = await Promise.all([\n getModel.execute(RECORD_LOCKING_MODEL_ID),\n listModels.execute({ includePrivate: false })\n ]);\n\n return [modelResult.value, publicModelsResult.value];\n });\n\n RecordLockingFeature.register(container, {\n timeout: this.config.timeout,\n model\n });\n\n const plugin = await createGraphQLSchema({\n model,\n models: publicModels,\n fieldRegistry\n });\n\n // The generated record-locking model schema references CMS base scalars (DateTime, JSON,\n // etc.). Include createBaseContentSchema() — which declares those scalars and their\n // resolvers — exactly as the normal CMS schema build (buildSchemaPlugins) does, so this\n // standalone schema is self-contained and valid before it is merged by the engine.\n const baseContent = createBaseContentSchema();\n\n return makeExecutableSchema({\n typeDefs: [baseContent.schema.typeDefs as string, plugin.schema.typeDefs as string],\n resolvers: mergeResolvers([\n baseContent.schema.resolvers as any,\n plugin.schema.resolvers as any\n ]),\n inheritResolversFromInterfaces: true\n });\n }\n}\n\nexport const RecordLockingContextualSchema = GraphQLContextualSchema.createImplementation({\n implementation: RecordLockingContextualSchemaImpl,\n dependencies: [WcpContext, TenantContext, IdentityContext, RecordLockingAppConfig]\n});\n"],"names":["RecordLockingContextualSchemaImpl","wcp","tenantCtx","identityCtx","config","ctx","makeExecutableSchema","container","getModel","GetModelUseCase","listModels","ListModelsUseCase","fieldRegistry","CmsModelFieldToGraphQLRegistry","model","publicModels","modelResult","publicModelsResult","Promise","RECORD_LOCKING_MODEL_ID","RecordLockingFeature","plugin","createGraphQLSchema","baseContent","createBaseContentSchema","mergeResolvers","RecordLockingContextualSchema","GraphQLContextualSchema","WcpContext","TenantContext","IdentityContext","RecordLockingAppConfig"],"mappings":";;;;;;;;;;;;;;AAqBA,MAAMA;IACF,YACYC,GAAyB,EACzBC,SAAkC,EAClCC,WAAsC,EACtCC,MAA+B,CACzC;aAJUH,GAAG,GAAHA;aACAC,SAAS,GAATA;aACAC,WAAW,GAAXA;aACAC,MAAM,GAANA;IACT;IAEH,MAAM,MAAMC,GAAwB,EAA0B;QAC1D,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,mBAAmB,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,IAC5D,OAAOC,qBAAqB;YACxB,UAAU;YACV,gBAAgB;QACpB;QAGJ,MAAMC,YAAYF,IAAI,SAAS;QAM/B,MAAMG,WAAWD,UAAU,OAAO,CAACE;QACnC,MAAMC,aAAaH,UAAU,OAAO,CAACI;QACrC,MAAMC,gBAAgBL,UAAU,OAAO,CAACM;QAExC,MAAM,CAACC,OAAOC,aAAa,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC;YACtE,MAAM,CAACC,aAAaC,mBAAmB,GAAG,MAAMC,QAAQ,GAAG,CAAC;gBACxDV,SAAS,OAAO,CAACW;gBACjBT,WAAW,OAAO,CAAC;oBAAE,gBAAgB;gBAAM;aAC9C;YAED,OAAO;gBAACM,YAAY,KAAK;gBAAEC,mBAAmB,KAAK;aAAC;QACxD;QAEAG,qBAAqB,QAAQ,CAACb,WAAW;YACrC,SAAS,IAAI,CAAC,MAAM,CAAC,OAAO;YAC5BO;QACJ;QAEA,MAAMO,SAAS,MAAMC,oBAAoB;YACrCR;YACA,QAAQC;YACRH;QACJ;QAMA,MAAMW,cAAcC;QAEpB,OAAOlB,qBAAqB;YACxB,UAAU;gBAACiB,YAAY,MAAM,CAAC,QAAQ;gBAAYF,OAAO,MAAM,CAAC,QAAQ;aAAW;YACnF,WAAWI,eAAe;gBACtBF,YAAY,MAAM,CAAC,SAAS;gBAC5BF,OAAO,MAAM,CAAC,SAAS;aAC1B;YACD,gCAAgC;QACpC;IACJ;AACJ;AAEO,MAAMK,gCAAgCC,wBAAwB,oBAAoB,CAAC;IACtF,gBAAgB3B;IAChB,cAAc;QAAC4B;QAAYC;QAAeC;QAAiBC;KAAuB;AACtF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
2
|
+
import { NotAuthorizedError } from "@webiny/api-core/features/security/shared";
|
|
3
|
+
const checkPermissions = async (context)=>{
|
|
4
|
+
const identityContext = context.container.resolve(IdentityContext);
|
|
5
|
+
const identity = identityContext.getIdentity();
|
|
6
|
+
if (identity.isAnonymous()) throw new NotAuthorizedError();
|
|
7
|
+
};
|
|
8
|
+
export { checkPermissions };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=checkPermissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql/checkPermissions.js","sources":["../../src/graphql/checkPermissions.ts"],"sourcesContent":["import { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { NotAuthorizedError } from \"@webiny/api-core/features/security/shared\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\n\n/**\n * Simple permission check. Only authenticated users can access the websockets API via GraphQL\n */\nexport const checkPermissions = async (context: ApiCoreContext): Promise<void> => {\n const identityContext = context.container.resolve(IdentityContext);\n const identity = identityContext.getIdentity();\n\n if (identity.isAnonymous()) {\n throw new NotAuthorizedError();\n }\n};\n"],"names":["checkPermissions","context","identityContext","IdentityContext","identity","NotAuthorizedError"],"mappings":";;AAOO,MAAMA,mBAAmB,OAAOC;IACnC,MAAMC,kBAAkBD,QAAQ,SAAS,CAAC,OAAO,CAACE;IAClD,MAAMC,WAAWF,gBAAgB,WAAW;IAE5C,IAAIE,SAAS,WAAW,IACpB,MAAM,IAAIC;AAElB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ErrorResponse, Response } from "@webiny/
|
|
2
|
-
import type { IRecordLockingMeta } from "../types";
|
|
3
|
-
export declare const resolve: <T>(cb: () => Promise<T>) => Promise<
|
|
1
|
+
import { ErrorResponse, Response } from "@webiny/api-graphql";
|
|
2
|
+
import type { IRecordLockingMeta } from "../types.js";
|
|
3
|
+
export declare const resolve: <T>(cb: () => Promise<T>) => Promise<Response<T> | ErrorResponse>;
|
|
4
4
|
export interface IListResponse<T> {
|
|
5
5
|
items: T[];
|
|
6
6
|
meta: IRecordLockingMeta;
|
|
7
7
|
}
|
|
8
|
-
export declare const resolveList: <T>(cb: () => Promise<IListResponse<T>>) => Promise<
|
|
8
|
+
export declare const resolveList: <T>(cb: () => Promise<IListResponse<T>>) => Promise<Response<T[]> | ErrorResponse>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ErrorResponse, ListErrorResponse, ListResponse, Response } from "@webiny/api-graphql";
|
|
2
|
+
const resolve = async (cb)=>{
|
|
3
|
+
try {
|
|
4
|
+
const result = await cb();
|
|
5
|
+
return new Response(result);
|
|
6
|
+
} catch (ex) {
|
|
7
|
+
return new ErrorResponse(ex);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
const resolveList = async (cb)=>{
|
|
11
|
+
try {
|
|
12
|
+
const { items, meta } = await cb();
|
|
13
|
+
return new ListResponse(items, meta);
|
|
14
|
+
} catch (ex) {
|
|
15
|
+
return new ListErrorResponse(ex);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
export { resolve, resolveList };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql/resolve.js","sources":["../../src/graphql/resolve.ts"],"sourcesContent":["import { ErrorResponse, ListErrorResponse, ListResponse, Response } from \"@webiny/api-graphql\";\nimport type { IRecordLockingMeta } from \"~/types.js\";\n\nexport const resolve = async <T>(cb: () => Promise<T>): Promise<Response<T> | ErrorResponse> => {\n try {\n const result = await cb();\n return new Response<T>(result);\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n};\n\nexport interface IListResponse<T> {\n items: T[];\n meta: IRecordLockingMeta;\n}\n\nexport const resolveList = async <T>(\n cb: () => Promise<IListResponse<T>>\n): Promise<Response<T[]> | ErrorResponse> => {\n try {\n const { items, meta } = await cb();\n return new ListResponse(items, meta);\n } catch (ex) {\n return new ListErrorResponse(ex);\n }\n};\n"],"names":["resolve","cb","result","Response","ex","ErrorResponse","resolveList","items","meta","ListResponse","ListErrorResponse"],"mappings":";AAGO,MAAMA,UAAU,OAAUC;IAC7B,IAAI;QACA,MAAMC,SAAS,MAAMD;QACrB,OAAO,IAAIE,SAAYD;IAC3B,EAAE,OAAOE,IAAI;QACT,OAAO,IAAIC,cAAcD;IAC7B;AACJ;AAOO,MAAME,cAAc,OACvBL;IAEA,IAAI;QACA,MAAM,EAAEM,KAAK,EAAEC,IAAI,EAAE,GAAG,MAAMP;QAC9B,OAAO,IAAIQ,aAAaF,OAAOC;IACnC,EAAE,OAAOJ,IAAI;QACT,OAAO,IAAIM,kBAAkBN;IACjC;AACJ"}
|
package/graphql/schema.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { IGraphQLSchemaPlugin } from "@webiny/api-graphql";
|
|
2
|
+
import type { ApiCoreContext } from "@webiny/api-core/types/core.js";
|
|
3
|
+
import { CmsModel } from "@webiny/api-headless-cms/types/model.js";
|
|
4
|
+
import type { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/exports/api/cms/graphql.js";
|
|
3
5
|
interface Params {
|
|
4
|
-
|
|
6
|
+
model: CmsModel;
|
|
7
|
+
models: CmsModel[];
|
|
8
|
+
fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;
|
|
5
9
|
}
|
|
6
|
-
export declare const createGraphQLSchema: (params: Params) => Promise<IGraphQLSchemaPlugin<
|
|
10
|
+
export declare const createGraphQLSchema: (params: Params) => Promise<IGraphQLSchemaPlugin<ApiCoreContext>>;
|
|
7
11
|
export {};
|
package/graphql/schema.js
CHANGED
|
@@ -1,53 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
import { resolve, resolveList } from "./resolve.js";
|
|
2
|
+
import { createGraphQLSchemaPlugin } from "@webiny/api-graphql";
|
|
3
|
+
import { renderFields } from "@webiny/api-headless-cms/utils/renderFields.js";
|
|
4
|
+
import { renderListFilterFields } from "@webiny/api-headless-cms/utils/renderListFilterFields.js";
|
|
5
|
+
import { renderSortEnum } from "@webiny/api-headless-cms/utils/renderSortEnum.js";
|
|
6
|
+
import { checkPermissions } from "./checkPermissions.js";
|
|
7
|
+
import { IsEntryLockedUseCase } from "../features/IsEntryLocked/abstractions.js";
|
|
8
|
+
import { GetLockRecordUseCase } from "../features/GetLockRecord/abstractions.js";
|
|
9
|
+
import { GetLockedEntryLockRecordUseCase } from "../features/GetLockedEntryLockRecord/abstractions.js";
|
|
10
|
+
import { ListLockRecordsUseCase } from "../features/ListLockRecords/abstractions.js";
|
|
11
|
+
import { ListAllLockRecordsUseCase } from "../features/ListAllLockRecords/abstractions.js";
|
|
12
|
+
import { LockEntryUseCase } from "../features/LockEntry/abstractions.js";
|
|
13
|
+
import { UpdateEntryLockUseCase } from "../features/UpdateEntryLock/abstractions.js";
|
|
14
|
+
import { UnlockEntryUseCase } from "../features/UnlockEntry/abstractions.js";
|
|
15
|
+
import { UnlockEntryRequestUseCase } from "../features/UnlockEntryRequest/abstractions.js";
|
|
16
|
+
const createGraphQLSchema = async (params)=>{
|
|
17
|
+
const model = params.model;
|
|
18
|
+
const models = params.models.filter((model)=>model.fields.length > 0);
|
|
19
|
+
const fieldRegistry = params.fieldRegistry;
|
|
20
|
+
const recordLockingFields = renderFields({
|
|
21
|
+
models,
|
|
22
|
+
model,
|
|
23
|
+
fields: model.fields,
|
|
24
|
+
type: "manage",
|
|
25
|
+
fieldRegistry
|
|
26
|
+
});
|
|
27
|
+
const listFilterFieldsRender = renderListFilterFields({
|
|
28
|
+
model,
|
|
29
|
+
fields: model.fields,
|
|
30
|
+
type: "manage",
|
|
31
|
+
fieldRegistry,
|
|
32
|
+
excludeFields: [
|
|
33
|
+
"entryId"
|
|
34
|
+
]
|
|
35
|
+
});
|
|
36
|
+
const sortEnumRender = renderSortEnum({
|
|
37
|
+
model,
|
|
38
|
+
fields: model.fields,
|
|
39
|
+
fieldRegistry,
|
|
40
|
+
sorters: []
|
|
25
41
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
models,
|
|
30
|
-
model,
|
|
31
|
-
fields: model.fields,
|
|
32
|
-
type: "manage",
|
|
33
|
-
fieldTypePlugins
|
|
34
|
-
});
|
|
35
|
-
const listFilterFieldsRender = (0, _renderListFilterFields.renderListFilterFields)({
|
|
36
|
-
model,
|
|
37
|
-
fields: model.fields,
|
|
38
|
-
type: "manage",
|
|
39
|
-
fieldTypePlugins,
|
|
40
|
-
excludeFields: ["entryId"]
|
|
41
|
-
});
|
|
42
|
-
const sortEnumRender = (0, _renderSortEnum.renderSortEnum)({
|
|
43
|
-
model,
|
|
44
|
-
fields: model.fields,
|
|
45
|
-
fieldTypePlugins,
|
|
46
|
-
sorterPlugins: []
|
|
47
|
-
});
|
|
48
|
-
const plugin = (0, _handlerGraphql.createGraphQLSchemaPlugin)({
|
|
49
|
-
typeDefs: /* GraphQL */`
|
|
50
|
-
${recordLockingFields.map(f => f.typeDefs).join("\n")}
|
|
42
|
+
const plugin = createGraphQLSchemaPlugin({
|
|
43
|
+
typeDefs: `
|
|
44
|
+
${recordLockingFields.map((f)=>f.typeDefs).join("\n")}
|
|
51
45
|
|
|
52
46
|
type RecordLockingError {
|
|
53
47
|
message: String
|
|
@@ -82,7 +76,7 @@ const createGraphQLSchema = async params => {
|
|
|
82
76
|
lockedOn: DateTime!
|
|
83
77
|
updatedOn: DateTime!
|
|
84
78
|
expiresOn: DateTime!
|
|
85
|
-
${recordLockingFields.map(f
|
|
79
|
+
${recordLockingFields.map((f)=>f.fields).join("\n")}
|
|
86
80
|
}
|
|
87
81
|
|
|
88
82
|
type RecordLockingIsEntryLockedResponse {
|
|
@@ -126,7 +120,7 @@ const createGraphQLSchema = async params => {
|
|
|
126
120
|
}
|
|
127
121
|
|
|
128
122
|
input RecordLockingListWhereInput {
|
|
129
|
-
${listFilterFieldsRender}
|
|
123
|
+
${listFilterFieldsRender.allFiltersAsString()}
|
|
130
124
|
}
|
|
131
125
|
|
|
132
126
|
enum RecordLockingListSorter {
|
|
@@ -179,102 +173,125 @@ const createGraphQLSchema = async params => {
|
|
|
179
173
|
recordLocking: RecordLockingMutation
|
|
180
174
|
}
|
|
181
175
|
`,
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
176
|
+
resolvers: {
|
|
177
|
+
Query: {
|
|
178
|
+
recordLocking: async ()=>({})
|
|
179
|
+
},
|
|
180
|
+
Mutation: {
|
|
181
|
+
recordLocking: async ()=>({})
|
|
182
|
+
},
|
|
183
|
+
RecordLockingQuery: {
|
|
184
|
+
async isEntryLocked (_, args, context) {
|
|
185
|
+
return resolve(async ()=>{
|
|
186
|
+
await checkPermissions(context);
|
|
187
|
+
const useCase = context.container.resolve(IsEntryLockedUseCase);
|
|
188
|
+
const result = await useCase.execute({
|
|
189
|
+
id: args.id,
|
|
190
|
+
type: args.type
|
|
191
|
+
});
|
|
192
|
+
if (result.isFail()) throw result.error;
|
|
193
|
+
return result.value;
|
|
194
|
+
});
|
|
195
|
+
},
|
|
196
|
+
async getLockRecord (_, args, context) {
|
|
197
|
+
return resolve(async ()=>{
|
|
198
|
+
await checkPermissions(context);
|
|
199
|
+
const useCase = context.container.resolve(GetLockRecordUseCase);
|
|
200
|
+
const result = await useCase.execute({
|
|
201
|
+
id: args.id,
|
|
202
|
+
type: args.type
|
|
203
|
+
});
|
|
204
|
+
if (result.isFail()) throw result.error;
|
|
205
|
+
return result.value;
|
|
206
|
+
});
|
|
207
|
+
},
|
|
208
|
+
async getLockedEntryLockRecord (_, args, context) {
|
|
209
|
+
return resolve(async ()=>{
|
|
210
|
+
await checkPermissions(context);
|
|
211
|
+
const useCase = context.container.resolve(GetLockedEntryLockRecordUseCase);
|
|
212
|
+
const result = await useCase.execute({
|
|
213
|
+
id: args.id,
|
|
214
|
+
type: args.type
|
|
215
|
+
});
|
|
216
|
+
if (result.isFail()) return null;
|
|
217
|
+
return result.value;
|
|
218
|
+
});
|
|
219
|
+
},
|
|
220
|
+
async listLockRecords (_, args, context) {
|
|
221
|
+
return resolveList(async ()=>{
|
|
222
|
+
await checkPermissions(context);
|
|
223
|
+
const useCase = context.container.resolve(ListLockRecordsUseCase);
|
|
224
|
+
const result = await useCase.execute(args);
|
|
225
|
+
if (result.isFail()) throw result.error;
|
|
226
|
+
return result.value;
|
|
227
|
+
});
|
|
228
|
+
},
|
|
229
|
+
listAllLockRecords (_, args, context) {
|
|
230
|
+
return resolveList(async ()=>{
|
|
231
|
+
await checkPermissions(context);
|
|
232
|
+
const useCase = context.container.resolve(ListAllLockRecordsUseCase);
|
|
233
|
+
const result = await useCase.execute(args);
|
|
234
|
+
if (result.isFail()) throw result.error;
|
|
235
|
+
return result.value;
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
RecordLockingMutation: {
|
|
240
|
+
async lockEntry (_, args, context) {
|
|
241
|
+
return resolve(async ()=>{
|
|
242
|
+
await checkPermissions(context);
|
|
243
|
+
const useCase = context.container.resolve(LockEntryUseCase);
|
|
244
|
+
const result = await useCase.execute({
|
|
245
|
+
id: args.id,
|
|
246
|
+
type: args.type
|
|
247
|
+
});
|
|
248
|
+
if (result.isFail()) throw result.error;
|
|
249
|
+
return result.value;
|
|
250
|
+
});
|
|
251
|
+
},
|
|
252
|
+
async updateEntryLock (_, args, context) {
|
|
253
|
+
return resolve(async ()=>{
|
|
254
|
+
await checkPermissions(context);
|
|
255
|
+
const useCase = context.container.resolve(UpdateEntryLockUseCase);
|
|
256
|
+
const result = await useCase.execute({
|
|
257
|
+
id: args.id,
|
|
258
|
+
type: args.type
|
|
259
|
+
});
|
|
260
|
+
if (result.isFail()) throw result.error;
|
|
261
|
+
return result.value;
|
|
262
|
+
});
|
|
263
|
+
},
|
|
264
|
+
async unlockEntry (_, args, context) {
|
|
265
|
+
return resolve(async ()=>{
|
|
266
|
+
await checkPermissions(context);
|
|
267
|
+
const useCase = context.container.resolve(UnlockEntryUseCase);
|
|
268
|
+
const result = await useCase.execute({
|
|
269
|
+
id: args.id,
|
|
270
|
+
type: args.type,
|
|
271
|
+
force: args.force
|
|
272
|
+
});
|
|
273
|
+
if (result.isFail()) throw result.error;
|
|
274
|
+
return result.value;
|
|
275
|
+
});
|
|
276
|
+
},
|
|
277
|
+
async unlockEntryRequest (_, args, context) {
|
|
278
|
+
return resolve(async ()=>{
|
|
279
|
+
await checkPermissions(context);
|
|
280
|
+
const useCase = context.container.resolve(UnlockEntryRequestUseCase);
|
|
281
|
+
const result = await useCase.execute({
|
|
282
|
+
id: args.id,
|
|
283
|
+
type: args.type
|
|
284
|
+
});
|
|
285
|
+
if (result.isFail()) throw result.error;
|
|
286
|
+
return result.value;
|
|
287
|
+
});
|
|
288
|
+
}
|
|
208
289
|
}
|
|
209
|
-
throw new _handlerGraphql.NotFoundError("Lock record not found.");
|
|
210
|
-
});
|
|
211
|
-
},
|
|
212
|
-
async getLockedEntryLockRecord(_, args, context) {
|
|
213
|
-
return (0, _resolve.resolve)(async () => {
|
|
214
|
-
await (0, _checkPermissions.checkPermissions)(context);
|
|
215
|
-
return await context.recordLocking.getLockedEntryLockRecord({
|
|
216
|
-
id: args.id,
|
|
217
|
-
type: args.type
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
},
|
|
221
|
-
async listLockRecords(_, args, context) {
|
|
222
|
-
return (0, _resolve.resolveList)(async () => {
|
|
223
|
-
await (0, _checkPermissions.checkPermissions)(context);
|
|
224
|
-
return await context.recordLocking.listLockRecords(args);
|
|
225
|
-
});
|
|
226
|
-
},
|
|
227
|
-
listAllLockRecords(_, args, context) {
|
|
228
|
-
return (0, _resolve.resolveList)(async () => {
|
|
229
|
-
await (0, _checkPermissions.checkPermissions)(context);
|
|
230
|
-
return await context.recordLocking.listAllLockRecords(args);
|
|
231
|
-
});
|
|
232
290
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
return (0, _resolve.resolve)(async () => {
|
|
237
|
-
await (0, _checkPermissions.checkPermissions)(context);
|
|
238
|
-
return context.recordLocking.lockEntry({
|
|
239
|
-
id: args.id,
|
|
240
|
-
type: args.type
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
},
|
|
244
|
-
async updateEntryLock(_, args, context) {
|
|
245
|
-
return (0, _resolve.resolve)(async () => {
|
|
246
|
-
await (0, _checkPermissions.checkPermissions)(context);
|
|
247
|
-
return context.recordLocking.updateEntryLock({
|
|
248
|
-
id: args.id,
|
|
249
|
-
type: args.type
|
|
250
|
-
});
|
|
251
|
-
});
|
|
252
|
-
},
|
|
253
|
-
async unlockEntry(_, args, context) {
|
|
254
|
-
return (0, _resolve.resolve)(async () => {
|
|
255
|
-
await (0, _checkPermissions.checkPermissions)(context);
|
|
256
|
-
return await context.recordLocking.unlockEntry({
|
|
257
|
-
id: args.id,
|
|
258
|
-
type: args.type,
|
|
259
|
-
force: args.force
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
},
|
|
263
|
-
async unlockEntryRequest(_, args, context) {
|
|
264
|
-
return (0, _resolve.resolve)(async () => {
|
|
265
|
-
await (0, _checkPermissions.checkPermissions)(context);
|
|
266
|
-
return await context.recordLocking.unlockEntryRequest({
|
|
267
|
-
id: args.id,
|
|
268
|
-
type: args.type
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
plugin.name = "recordLocking.graphql.schema.locking";
|
|
276
|
-
return plugin;
|
|
291
|
+
});
|
|
292
|
+
plugin.name = "recordLocking.graphql.schema.locking";
|
|
293
|
+
return plugin;
|
|
277
294
|
};
|
|
278
|
-
|
|
295
|
+
export { createGraphQLSchema };
|
|
279
296
|
|
|
280
297
|
//# sourceMappingURL=schema.js.map
|