@webiny/api-record-locking 0.0.0-unstable.ac6ebf63c6 → 0.0.0-unstable.b6d7105cee
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 +4 -4
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js +28 -34
- 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.d.ts +4 -2
- package/features/ListAllLockRecords/ListAllLockRecordsRepository.js +37 -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.d.ts +3 -1
- package/features/ListLockRecords/ListLockRecordsRepository.js +37 -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,42 +1,36 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
|
-
import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
|
|
3
|
-
import {
|
|
2
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
3
|
+
import { WebsocketsSendToIdentityUseCase } from "@webiny/api-websockets/features/SendToIdentity/abstractions.js";
|
|
4
4
|
import { parseIdentifier } from "@webiny/utils";
|
|
5
|
-
import { KickOutCurrentUserUseCase
|
|
5
|
+
import { KickOutCurrentUserUseCase } from "./abstractions.js";
|
|
6
6
|
class KickOutCurrentUserUseCaseImpl {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
constructor(identityContext, sendToIdentity){
|
|
8
|
+
this.identityContext = identityContext;
|
|
9
|
+
this.sendToIdentity = sendToIdentity;
|
|
10
|
+
}
|
|
11
|
+
async execute(record) {
|
|
12
|
+
const { lockedBy, id } = record;
|
|
13
|
+
const { id: entryId } = parseIdentifier(id);
|
|
14
|
+
const identity = this.identityContext.getIdentity();
|
|
15
|
+
await this.sendToIdentity.execute({
|
|
16
|
+
id: lockedBy.id
|
|
17
|
+
}, {
|
|
18
|
+
action: `recordLocking.entry.kickOut.${entryId}`,
|
|
19
|
+
data: {
|
|
20
|
+
record: record.toObject(),
|
|
21
|
+
user: identity
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return Result.ok();
|
|
14
25
|
}
|
|
15
|
-
const {
|
|
16
|
-
lockedBy,
|
|
17
|
-
id
|
|
18
|
-
} = record;
|
|
19
|
-
const {
|
|
20
|
-
id: entryId
|
|
21
|
-
} = parseIdentifier(id);
|
|
22
|
-
const identity = this.identityContext.getIdentity();
|
|
23
|
-
await this.websocketService.send({
|
|
24
|
-
id: lockedBy.id
|
|
25
|
-
}, {
|
|
26
|
-
action: `recordLocking.entry.kickOut.${entryId}`,
|
|
27
|
-
data: {
|
|
28
|
-
record: record.toObject(),
|
|
29
|
-
user: identity
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
return Result.ok();
|
|
33
|
-
}
|
|
34
26
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
const KickOutCurrentUserUseCase_KickOutCurrentUserUseCase = KickOutCurrentUserUseCase.createImplementation({
|
|
28
|
+
implementation: KickOutCurrentUserUseCaseImpl,
|
|
29
|
+
dependencies: [
|
|
30
|
+
IdentityContext,
|
|
31
|
+
WebsocketsSendToIdentityUseCase
|
|
32
|
+
]
|
|
40
33
|
});
|
|
34
|
+
export { KickOutCurrentUserUseCase_KickOutCurrentUserUseCase as KickOutCurrentUserUseCase };
|
|
41
35
|
|
|
42
36
|
//# sourceMappingURL=KickOutCurrentUserUseCase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/KickOutCurrentUser/KickOutCurrentUserUseCase.js","sources":["../../../src/features/KickOutCurrentUser/KickOutCurrentUserUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { WebsocketsSendToIdentityUseCase } from \"@webiny/api-websockets/features/SendToIdentity/abstractions.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { KickOutCurrentUserUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport type { ILockRecord } from \"~/domain/index.js\";\n\nclass KickOutCurrentUserUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private sendToIdentity: WebsocketsSendToIdentityUseCase.Interface\n ) {}\n\n async execute(record: ILockRecord): Promise<Result<void, UseCaseAbstraction.Error>> {\n const { lockedBy, id } = record;\n\n const { id: entryId } = parseIdentifier(id);\n const identity = this.identityContext.getIdentity();\n\n await this.sendToIdentity.execute(\n { id: lockedBy.id },\n {\n action: `recordLocking.entry.kickOut.${entryId}`,\n data: {\n record: record.toObject(),\n user: identity\n }\n }\n );\n\n return Result.ok();\n }\n}\n\nexport const KickOutCurrentUserUseCase = UseCaseAbstraction.createImplementation({\n implementation: KickOutCurrentUserUseCaseImpl,\n dependencies: [IdentityContext, WebsocketsSendToIdentityUseCase]\n});\n"],"names":["KickOutCurrentUserUseCaseImpl","identityContext","sendToIdentity","record","lockedBy","id","entryId","parseIdentifier","identity","Result","KickOutCurrentUserUseCase","UseCaseAbstraction","IdentityContext","WebsocketsSendToIdentityUseCase"],"mappings":";;;;;AAOA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,cAAyD,CACnE;aAFUD,eAAe,GAAfA;aACAC,cAAc,GAAdA;IACT;IAEH,MAAM,QAAQC,MAAmB,EAAmD;QAChF,MAAM,EAAEC,QAAQ,EAAEC,EAAE,EAAE,GAAGF;QAEzB,MAAM,EAAE,IAAIG,OAAO,EAAE,GAAGC,gBAAgBF;QACxC,MAAMG,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;QAEjD,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B;YAAE,IAAIJ,SAAS,EAAE;QAAC,GAClB;YACI,QAAQ,CAAC,4BAA4B,EAAEE,SAAS;YAChD,MAAM;gBACF,QAAQH,OAAO,QAAQ;gBACvB,MAAMK;YACV;QACJ;QAGJ,OAAOC,OAAO,EAAE;IACpB;AACJ;AAEO,MAAMC,sDAA4BC,0BAAAA,oBAAuC,CAAC;IAC7E,gBAAgBX;IAChB,cAAc;QAACY;QAAiBC;KAAgC;AACpE"}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* KickOutCurrentUser Use Case - Sends websocket message to notify locked-out user
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export const KickOutCurrentUserUseCase = createAbstraction("KickOutCurrentUserUseCase");
|
|
2
|
+
const KickOutCurrentUserUseCase = createAbstraction("KickOutCurrentUserUseCase");
|
|
3
|
+
export { KickOutCurrentUserUseCase };
|
|
8
4
|
|
|
9
5
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/KickOutCurrentUser/abstractions.js","sources":["../../../src/features/KickOutCurrentUser/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\n\n/**\n * KickOutCurrentUser Use Case - Sends websocket message to notify locked-out user\n */\nexport interface IKickOutCurrentUserUseCase {\n execute(record: ILockRecord): Promise<Result<void, UseCaseError>>;\n}\n\nexport interface IKickOutCurrentUserUseCaseErrors {\n // This use case swallows errors and logs them, so no errors are exposed\n}\n\ntype UseCaseError = IKickOutCurrentUserUseCaseErrors[keyof IKickOutCurrentUserUseCaseErrors];\n\nexport const KickOutCurrentUserUseCase = createAbstraction<IKickOutCurrentUserUseCase>(\n \"KickOutCurrentUserUseCase\"\n);\n\nexport namespace KickOutCurrentUserUseCase {\n export type Interface = IKickOutCurrentUserUseCase;\n export type Error = UseCaseError;\n}\n"],"names":["KickOutCurrentUserUseCase","createAbstraction"],"mappings":";AAiBO,MAAMA,4BAA4BC,kBACrC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { KickOutCurrentUserUseCase } from "./KickOutCurrentUserUseCase.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const KickOutCurrentUserFeature = createFeature({
|
|
4
|
+
name: "KickOutCurrentUser",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(KickOutCurrentUserUseCase);
|
|
7
|
+
}
|
|
8
8
|
});
|
|
9
|
+
export { KickOutCurrentUserFeature };
|
|
9
10
|
|
|
10
11
|
//# sourceMappingURL=feature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/KickOutCurrentUser/feature.js","sources":["../../../src/features/KickOutCurrentUser/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { KickOutCurrentUserUseCase } from \"./KickOutCurrentUserUseCase.js\";\n\nexport const KickOutCurrentUserFeature = createFeature({\n name: \"KickOutCurrentUser\",\n register(container) {\n container.register(KickOutCurrentUserUseCase);\n }\n});\n"],"names":["KickOutCurrentUserFeature","createFeature","container","KickOutCurrentUserUseCase"],"mappings":";;AAGO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { ListAllLockRecordsRepository as RepositoryAbstraction, ListAllLockRecordsInput, ListAllLockRecordsOutput } from "./abstractions.js";
|
|
3
3
|
import { ListLatestEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries";
|
|
4
|
-
import { RecordLockingConfig } from "../../domain/abstractions.js";
|
|
5
4
|
import type { CmsModel } from "@webiny/api-headless-cms/types";
|
|
5
|
+
import { CmsWhereMapper } from "@webiny/api-headless-cms";
|
|
6
|
+
import { RecordLockingConfig } from "../../domain/abstractions.js";
|
|
6
7
|
declare class ListAllLockRecordsRepositoryImpl implements RepositoryAbstraction.Interface {
|
|
7
8
|
private config;
|
|
8
9
|
private listEntries;
|
|
9
10
|
private model;
|
|
10
|
-
|
|
11
|
+
private cmsWhereMapper;
|
|
12
|
+
constructor(config: RecordLockingConfig.Interface, listEntries: ListLatestEntriesUseCase.Interface, model: CmsModel, cmsWhereMapper: CmsWhereMapper.Interface);
|
|
11
13
|
execute(input?: ListAllLockRecordsInput): Promise<Result<ListAllLockRecordsOutput, RepositoryAbstraction.Error>>;
|
|
12
14
|
}
|
|
13
15
|
export declare const ListAllLockRecordsRepository: typeof ListAllLockRecordsRepositoryImpl & {
|
|
@@ -1,43 +1,49 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
|
-
import { ListAllLockRecordsRepository
|
|
2
|
+
import { ListAllLockRecordsRepository } from "./abstractions.js";
|
|
3
3
|
import { ListLatestEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries";
|
|
4
|
+
import { CmsWhereMapper } from "@webiny/api-headless-cms";
|
|
4
5
|
import { RecordLockingConfig, RecordLockingModel } from "../../domain/abstractions.js";
|
|
5
6
|
import { LockRecordPersistenceError } from "../../domain/errors.js";
|
|
6
7
|
import { convertWhereCondition } from "../../utils/convertWhereCondition.js";
|
|
7
8
|
import { LockRecord } from "../../domain/LockRecord.js";
|
|
8
9
|
class ListAllLockRecordsRepositoryImpl {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
10
|
+
constructor(config, listEntries, model, cmsWhereMapper){
|
|
11
|
+
this.config = config;
|
|
12
|
+
this.listEntries = listEntries;
|
|
13
|
+
this.model = model;
|
|
14
|
+
this.cmsWhereMapper = cmsWhereMapper;
|
|
15
|
+
}
|
|
16
|
+
async execute(input) {
|
|
17
|
+
try {
|
|
18
|
+
const params = {
|
|
19
|
+
...input,
|
|
20
|
+
where: this.cmsWhereMapper.map({
|
|
21
|
+
input: convertWhereCondition(input?.where),
|
|
22
|
+
fields: this.model.fields
|
|
23
|
+
})
|
|
24
|
+
};
|
|
25
|
+
const result = await this.listEntries.execute(this.model, params);
|
|
26
|
+
if (result.isFail()) return Result.fail(new LockRecordPersistenceError(result.error));
|
|
27
|
+
const { entries, meta } = result.value;
|
|
28
|
+
const items = entries.map((entry)=>new LockRecord(entry, this.config.timeout));
|
|
29
|
+
return Result.ok({
|
|
30
|
+
items,
|
|
31
|
+
meta
|
|
32
|
+
});
|
|
33
|
+
} catch (error) {
|
|
34
|
+
return Result.fail(new LockRecordPersistenceError(error));
|
|
35
|
+
}
|
|
35
36
|
}
|
|
36
|
-
}
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const ListAllLockRecordsRepository_ListAllLockRecordsRepository = ListAllLockRecordsRepository.createImplementation({
|
|
39
|
+
implementation: ListAllLockRecordsRepositoryImpl,
|
|
40
|
+
dependencies: [
|
|
41
|
+
RecordLockingConfig,
|
|
42
|
+
ListLatestEntriesUseCase,
|
|
43
|
+
RecordLockingModel,
|
|
44
|
+
CmsWhereMapper
|
|
45
|
+
]
|
|
41
46
|
});
|
|
47
|
+
export { ListAllLockRecordsRepository_ListAllLockRecordsRepository as ListAllLockRecordsRepository };
|
|
42
48
|
|
|
43
49
|
//# sourceMappingURL=ListAllLockRecordsRepository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/ListAllLockRecords/ListAllLockRecordsRepository.js","sources":["../../../src/features/ListAllLockRecords/ListAllLockRecordsRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n ListAllLockRecordsRepository as RepositoryAbstraction,\n ListAllLockRecordsInput,\n ListAllLockRecordsOutput\n} from \"./abstractions.js\";\nimport { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { CmsWhereMapper } from \"@webiny/api-headless-cms\";\nimport { RecordLockingConfig, RecordLockingModel } from \"~/domain/abstractions.js\";\nimport { LockRecordPersistenceError } from \"~/domain/errors.js\";\nimport { convertWhereCondition } from \"~/utils/convertWhereCondition.js\";\nimport { LockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordValues } from \"~/domain/index.js\";\n\nclass ListAllLockRecordsRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private config: RecordLockingConfig.Interface,\n private listEntries: ListLatestEntriesUseCase.Interface,\n private model: CmsModel,\n private cmsWhereMapper: CmsWhereMapper.Interface\n ) {}\n\n async execute(\n input?: ListAllLockRecordsInput\n ): Promise<Result<ListAllLockRecordsOutput, RepositoryAbstraction.Error>> {\n try {\n const params = {\n ...input,\n where: this.cmsWhereMapper.map({\n input: convertWhereCondition(input?.where),\n fields: this.model.fields\n })\n };\n\n const result = await this.listEntries.execute<LockRecordValues>(this.model, params);\n\n if (result.isFail()) {\n return Result.fail(new LockRecordPersistenceError(result.error));\n }\n\n const { entries, meta } = result.value;\n\n const items = entries.map(entry => new LockRecord(entry, this.config.timeout));\n\n return Result.ok({\n items,\n meta\n });\n } catch (error) {\n return Result.fail(new LockRecordPersistenceError(error as Error));\n }\n }\n}\n\nexport const ListAllLockRecordsRepository = RepositoryAbstraction.createImplementation({\n implementation: ListAllLockRecordsRepositoryImpl,\n dependencies: [\n RecordLockingConfig,\n ListLatestEntriesUseCase,\n RecordLockingModel,\n CmsWhereMapper\n ]\n});\n"],"names":["ListAllLockRecordsRepositoryImpl","config","listEntries","model","cmsWhereMapper","input","params","convertWhereCondition","result","Result","LockRecordPersistenceError","entries","meta","items","entry","LockRecord","error","ListAllLockRecordsRepository","RepositoryAbstraction","RecordLockingConfig","ListLatestEntriesUseCase","RecordLockingModel","CmsWhereMapper"],"mappings":";;;;;;;;AAeA,MAAMA;IACF,YACYC,MAAqC,EACrCC,WAA+C,EAC/CC,KAAe,EACfC,cAAwC,CAClD;aAJUH,MAAM,GAANA;aACAC,WAAW,GAAXA;aACAC,KAAK,GAALA;aACAC,cAAc,GAAdA;IACT;IAEH,MAAM,QACFC,KAA+B,EACuC;QACtE,IAAI;YACA,MAAMC,SAAS;gBACX,GAAGD,KAAK;gBACR,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC;oBAC3B,OAAOE,sBAAsBF,OAAO;oBACpC,QAAQ,IAAI,CAAC,KAAK,CAAC,MAAM;gBAC7B;YACJ;YAEA,MAAMG,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAmB,IAAI,CAAC,KAAK,EAAEF;YAE5E,IAAIE,OAAO,MAAM,IACb,OAAOC,OAAO,IAAI,CAAC,IAAIC,2BAA2BF,OAAO,KAAK;YAGlE,MAAM,EAAEG,OAAO,EAAEC,IAAI,EAAE,GAAGJ,OAAO,KAAK;YAEtC,MAAMK,QAAQF,QAAQ,GAAG,CAACG,CAAAA,QAAS,IAAIC,WAAWD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO;YAE5E,OAAOL,OAAO,EAAE,CAAC;gBACbI;gBACAD;YACJ;QACJ,EAAE,OAAOI,OAAO;YACZ,OAAOP,OAAO,IAAI,CAAC,IAAIC,2BAA2BM;QACtD;IACJ;AACJ;AAEO,MAAMC,4DAA+BC,6BAAAA,oBAA0C,CAAC;IACnF,gBAAgBlB;IAChB,cAAc;QACVmB;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ListAllLockRecordsRepository, ListAllLockRecordsUseCase } from "./abstractions.js";
|
|
2
2
|
class ListAllLockRecordsUseCaseImpl {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
constructor(repository){
|
|
4
|
+
this.repository = repository;
|
|
5
|
+
}
|
|
6
|
+
async execute(input) {
|
|
7
|
+
return await this.repository.execute(input);
|
|
8
|
+
}
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const ListAllLockRecordsUseCase_ListAllLockRecordsUseCase = ListAllLockRecordsUseCase.createImplementation({
|
|
11
|
+
implementation: ListAllLockRecordsUseCaseImpl,
|
|
12
|
+
dependencies: [
|
|
13
|
+
ListAllLockRecordsRepository
|
|
14
|
+
]
|
|
13
15
|
});
|
|
16
|
+
export { ListAllLockRecordsUseCase_ListAllLockRecordsUseCase as ListAllLockRecordsUseCase };
|
|
14
17
|
|
|
15
18
|
//# sourceMappingURL=ListAllLockRecordsUseCase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/ListAllLockRecords/ListAllLockRecordsUseCase.js","sources":["../../../src/features/ListAllLockRecords/ListAllLockRecordsUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n ListAllLockRecordsUseCase as UseCaseAbstraction,\n ListAllLockRecordsRepository,\n ListAllLockRecordsInput,\n ListAllLockRecordsOutput\n} from \"./abstractions.js\";\n\nclass ListAllLockRecordsUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(private repository: ListAllLockRecordsRepository.Interface) {}\n\n async execute(\n input?: ListAllLockRecordsInput\n ): Promise<Result<ListAllLockRecordsOutput, UseCaseAbstraction.Error>> {\n return await this.repository.execute(input);\n }\n}\n\nexport const ListAllLockRecordsUseCase = UseCaseAbstraction.createImplementation({\n implementation: ListAllLockRecordsUseCaseImpl,\n dependencies: [ListAllLockRecordsRepository]\n});\n"],"names":["ListAllLockRecordsUseCaseImpl","repository","input","ListAllLockRecordsUseCase","UseCaseAbstraction","ListAllLockRecordsRepository"],"mappings":";AAQA,MAAMA;IACF,YAAoBC,UAAkD,CAAE;aAApDA,UAAU,GAAVA;IAAqD;IAEzE,MAAM,QACFC,KAA+B,EACoC;QACnE,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAACA;IACzC;AACJ;AAEO,MAAMC,sDAA4BC,0BAAAA,oBAAuC,CAAC;IAC7E,gBAAgBJ;IAChB,cAAc;QAACK;KAA6B;AAChD"}
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* ListAllLockRecords Use Case - Lists all lock records without filtering
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
export const ListAllLockRecordsUseCase = createAbstraction("ListAllLockRecordsUseCase");
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* ListAllLockRecordsRepository - Fetches all lock records from storage
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
export const ListAllLockRecordsRepository = createAbstraction("ListAllLockRecordsRepository");
|
|
2
|
+
const ListAllLockRecordsUseCase = createAbstraction("ListAllLockRecordsUseCase");
|
|
3
|
+
const ListAllLockRecordsRepository = createAbstraction("ListAllLockRecordsRepository");
|
|
4
|
+
export { ListAllLockRecordsRepository, ListAllLockRecordsUseCase };
|
|
16
5
|
|
|
17
6
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/ListAllLockRecords/abstractions.js","sources":["../../../src/features/ListAllLockRecords/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordPersistenceError } from \"~/domain/errors.js\";\nimport type { CmsEntryListParams, CmsEntryMeta } from \"@webiny/api-headless-cms/types\";\n\n// Input/Output types\nexport type ListAllLockRecordsInput = Pick<\n CmsEntryListParams,\n \"where\" | \"limit\" | \"sort\" | \"after\"\n>;\n\nexport interface ListAllLockRecordsOutput {\n items: ILockRecord[];\n meta: CmsEntryMeta;\n}\n\n/**\n * ListAllLockRecords Use Case - Lists all lock records without filtering\n */\nexport interface IListAllLockRecordsUseCase {\n execute(\n input?: ListAllLockRecordsInput\n ): Promise<Result<ListAllLockRecordsOutput, UseCaseError>>;\n}\n\nexport interface IListAllLockRecordsUseCaseErrors {\n persistence: LockRecordPersistenceError;\n}\n\ntype UseCaseError = IListAllLockRecordsUseCaseErrors[keyof IListAllLockRecordsUseCaseErrors];\n\nexport const ListAllLockRecordsUseCase = createAbstraction<IListAllLockRecordsUseCase>(\n \"ListAllLockRecordsUseCase\"\n);\n\nexport namespace ListAllLockRecordsUseCase {\n export type Interface = IListAllLockRecordsUseCase;\n export type Error = UseCaseError;\n}\n\n/**\n * ListAllLockRecordsRepository - Fetches all lock records from storage\n */\nexport interface IListAllLockRecordsRepository {\n execute(\n input?: ListAllLockRecordsInput\n ): Promise<Result<ListAllLockRecordsOutput, RepositoryError>>;\n}\n\nexport interface IListAllLockRecordsRepositoryErrors {\n persistence: LockRecordPersistenceError;\n}\n\ntype RepositoryError =\n IListAllLockRecordsRepositoryErrors[keyof IListAllLockRecordsRepositoryErrors];\n\nexport const ListAllLockRecordsRepository = createAbstraction<IListAllLockRecordsRepository>(\n \"ListAllLockRecordsRepository\"\n);\n\nexport namespace ListAllLockRecordsRepository {\n export type Interface = IListAllLockRecordsRepository;\n export type Error = RepositoryError;\n}\n"],"names":["ListAllLockRecordsUseCase","createAbstraction","ListAllLockRecordsRepository"],"mappings":";AAgCO,MAAMA,4BAA4BC,kBACrC;AAwBG,MAAMC,+BAA+BD,kBACxC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { ListAllLockRecordsUseCase } from "./ListAllLockRecordsUseCase.js";
|
|
3
3
|
import { ListAllLockRecordsRepository } from "./ListAllLockRecordsRepository.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const ListAllLockRecordsFeature = createFeature({
|
|
5
|
+
name: "ListAllLockRecords",
|
|
6
|
+
register (container) {
|
|
7
|
+
container.register(ListAllLockRecordsUseCase);
|
|
8
|
+
container.register(ListAllLockRecordsRepository).inSingletonScope();
|
|
9
|
+
}
|
|
10
10
|
});
|
|
11
|
+
export { ListAllLockRecordsFeature };
|
|
11
12
|
|
|
12
13
|
//# sourceMappingURL=feature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/ListAllLockRecords/feature.js","sources":["../../../src/features/ListAllLockRecords/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { ListAllLockRecordsUseCase } from \"./ListAllLockRecordsUseCase.js\";\nimport { ListAllLockRecordsRepository } from \"./ListAllLockRecordsRepository.js\";\n\nexport const ListAllLockRecordsFeature = createFeature({\n name: \"ListAllLockRecords\",\n register(container) {\n container.register(ListAllLockRecordsUseCase);\n container.register(ListAllLockRecordsRepository).inSingletonScope();\n }\n});\n"],"names":["ListAllLockRecordsFeature","createFeature","container","ListAllLockRecordsUseCase","ListAllLockRecordsRepository"],"mappings":";;;AAIO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,8BAA8B,gBAAgB;IACrE;AACJ"}
|
|
@@ -2,11 +2,13 @@ import { Result } from "@webiny/feature/api";
|
|
|
2
2
|
import { ListLatestEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries";
|
|
3
3
|
import { ListLockRecordsRepository as RepositoryAbstraction, ListLockRecordsInput, ListLockRecordsOutput } from "./abstractions.js";
|
|
4
4
|
import { RecordLockingConfig, RecordLockingModel } from "../../domain/abstractions.js";
|
|
5
|
+
import { CmsWhereMapper } from "@webiny/api-headless-cms";
|
|
5
6
|
declare class ListLockRecordsRepositoryImpl implements RepositoryAbstraction.Interface {
|
|
6
7
|
private model;
|
|
7
8
|
private config;
|
|
8
9
|
private listEntries;
|
|
9
|
-
|
|
10
|
+
private cmsWhereMapper;
|
|
11
|
+
constructor(model: RecordLockingModel.Interface, config: RecordLockingConfig.Interface, listEntries: ListLatestEntriesUseCase.Interface, cmsWhereMapper: CmsWhereMapper.Interface);
|
|
10
12
|
execute(input?: ListLockRecordsInput): Promise<Result<ListLockRecordsOutput, RepositoryAbstraction.Error>>;
|
|
11
13
|
}
|
|
12
14
|
export declare const ListLockRecordsRepository: typeof ListLockRecordsRepositoryImpl & {
|
|
@@ -1,43 +1,49 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { ListLatestEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries";
|
|
3
|
-
import { ListLockRecordsRepository
|
|
3
|
+
import { ListLockRecordsRepository } from "./abstractions.js";
|
|
4
4
|
import { RecordLockingConfig, RecordLockingModel } from "../../domain/abstractions.js";
|
|
5
5
|
import { LockRecord } from "../../domain/LockRecord.js";
|
|
6
6
|
import { LockRecordPersistenceError } from "../../domain/errors.js";
|
|
7
|
+
import { CmsWhereMapper } from "@webiny/api-headless-cms";
|
|
7
8
|
import { convertWhereCondition } from "../../utils/convertWhereCondition.js";
|
|
8
9
|
class ListLockRecordsRepositoryImpl {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
10
|
+
constructor(model, config, listEntries, cmsWhereMapper){
|
|
11
|
+
this.model = model;
|
|
12
|
+
this.config = config;
|
|
13
|
+
this.listEntries = listEntries;
|
|
14
|
+
this.cmsWhereMapper = cmsWhereMapper;
|
|
15
|
+
}
|
|
16
|
+
async execute(input) {
|
|
17
|
+
try {
|
|
18
|
+
const params = {
|
|
19
|
+
...input,
|
|
20
|
+
where: this.cmsWhereMapper.map({
|
|
21
|
+
input: convertWhereCondition(input?.where),
|
|
22
|
+
fields: this.model.fields
|
|
23
|
+
})
|
|
24
|
+
};
|
|
25
|
+
const result = await this.listEntries.execute(this.model, params);
|
|
26
|
+
if (result.isFail()) return Result.fail(new LockRecordPersistenceError(result.error));
|
|
27
|
+
const { entries, meta } = result.value;
|
|
28
|
+
const items = entries.map((entry)=>new LockRecord(entry, this.config.timeout));
|
|
29
|
+
return Result.ok({
|
|
30
|
+
items,
|
|
31
|
+
meta
|
|
32
|
+
});
|
|
33
|
+
} catch (error) {
|
|
34
|
+
return Result.fail(new LockRecordPersistenceError(error));
|
|
35
|
+
}
|
|
35
36
|
}
|
|
36
|
-
}
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const ListLockRecordsRepository_ListLockRecordsRepository = ListLockRecordsRepository.createImplementation({
|
|
39
|
+
implementation: ListLockRecordsRepositoryImpl,
|
|
40
|
+
dependencies: [
|
|
41
|
+
RecordLockingModel,
|
|
42
|
+
RecordLockingConfig,
|
|
43
|
+
ListLatestEntriesUseCase,
|
|
44
|
+
CmsWhereMapper
|
|
45
|
+
]
|
|
41
46
|
});
|
|
47
|
+
export { ListLockRecordsRepository_ListLockRecordsRepository as ListLockRecordsRepository };
|
|
42
48
|
|
|
43
49
|
//# sourceMappingURL=ListLockRecordsRepository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/ListLockRecords/ListLockRecordsRepository.js","sources":["../../../src/features/ListLockRecords/ListLockRecordsRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries\";\nimport {\n ListLockRecordsRepository as RepositoryAbstraction,\n ListLockRecordsInput,\n ListLockRecordsOutput\n} from \"./abstractions.js\";\nimport { RecordLockingConfig, RecordLockingModel } from \"~/domain/abstractions.js\";\nimport { LockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordValues } from \"~/domain/types.js\";\nimport { LockRecordPersistenceError } from \"~/domain/errors.js\";\nimport { CmsWhereMapper } from \"@webiny/api-headless-cms\";\nimport { convertWhereCondition } from \"~/utils/convertWhereCondition.js\";\n\nclass ListLockRecordsRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private model: RecordLockingModel.Interface,\n private config: RecordLockingConfig.Interface,\n private listEntries: ListLatestEntriesUseCase.Interface,\n private cmsWhereMapper: CmsWhereMapper.Interface\n ) {}\n\n async execute(\n input?: ListLockRecordsInput\n ): Promise<Result<ListLockRecordsOutput, RepositoryAbstraction.Error>> {\n try {\n const params = {\n ...input,\n where: this.cmsWhereMapper.map({\n input: convertWhereCondition(input?.where),\n fields: this.model.fields\n })\n };\n\n const result = await this.listEntries.execute<LockRecordValues>(this.model, params);\n\n if (result.isFail()) {\n return Result.fail(new LockRecordPersistenceError(result.error));\n }\n\n const { entries, meta } = result.value;\n\n const items = entries.map(entry => new LockRecord(entry, this.config.timeout));\n\n return Result.ok({\n items,\n meta\n });\n } catch (error) {\n return Result.fail(new LockRecordPersistenceError(error as Error));\n }\n }\n}\n\nexport const ListLockRecordsRepository = RepositoryAbstraction.createImplementation({\n implementation: ListLockRecordsRepositoryImpl,\n dependencies: [\n RecordLockingModel,\n RecordLockingConfig,\n ListLatestEntriesUseCase,\n CmsWhereMapper\n ]\n});\n"],"names":["ListLockRecordsRepositoryImpl","model","config","listEntries","cmsWhereMapper","input","params","convertWhereCondition","result","Result","LockRecordPersistenceError","entries","meta","items","entry","LockRecord","error","ListLockRecordsRepository","RepositoryAbstraction","RecordLockingModel","RecordLockingConfig","ListLatestEntriesUseCase","CmsWhereMapper"],"mappings":";;;;;;;;AAcA,MAAMA;IACF,YACYC,KAAmC,EACnCC,MAAqC,EACrCC,WAA+C,EAC/CC,cAAwC,CAClD;aAJUH,KAAK,GAALA;aACAC,MAAM,GAANA;aACAC,WAAW,GAAXA;aACAC,cAAc,GAAdA;IACT;IAEH,MAAM,QACFC,KAA4B,EACuC;QACnE,IAAI;YACA,MAAMC,SAAS;gBACX,GAAGD,KAAK;gBACR,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC;oBAC3B,OAAOE,sBAAsBF,OAAO;oBACpC,QAAQ,IAAI,CAAC,KAAK,CAAC,MAAM;gBAC7B;YACJ;YAEA,MAAMG,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAmB,IAAI,CAAC,KAAK,EAAEF;YAE5E,IAAIE,OAAO,MAAM,IACb,OAAOC,OAAO,IAAI,CAAC,IAAIC,2BAA2BF,OAAO,KAAK;YAGlE,MAAM,EAAEG,OAAO,EAAEC,IAAI,EAAE,GAAGJ,OAAO,KAAK;YAEtC,MAAMK,QAAQF,QAAQ,GAAG,CAACG,CAAAA,QAAS,IAAIC,WAAWD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO;YAE5E,OAAOL,OAAO,EAAE,CAAC;gBACbI;gBACAD;YACJ;QACJ,EAAE,OAAOI,OAAO;YACZ,OAAOP,OAAO,IAAI,CAAC,IAAIC,2BAA2BM;QACtD;IACJ;AACJ;AAEO,MAAMC,sDAA4BC,0BAAAA,oBAA0C,CAAC;IAChF,gBAAgBlB;IAChB,cAAc;QACVmB;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { ListLockRecordsInput, ListLockRecordsOutput, ListLockRecordsRepository, ListLockRecordsUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
3
|
-
import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
|
|
3
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
4
4
|
import { RecordLockingConfig } from "../../domain/abstractions.js";
|
|
5
5
|
declare class ListLockRecordsUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
6
6
|
private repository;
|
|
@@ -1,30 +1,33 @@
|
|
|
1
|
-
import { ListLockRecordsRepository, ListLockRecordsUseCase
|
|
2
|
-
import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
|
|
1
|
+
import { ListLockRecordsRepository, ListLockRecordsUseCase } from "./abstractions.js";
|
|
2
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
3
3
|
import { RecordLockingConfig } from "../../domain/abstractions.js";
|
|
4
4
|
class ListLockRecordsUseCaseImpl {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
return await this.repository.execute(enhancedInput);
|
|
23
|
-
}
|
|
5
|
+
constructor(repository, identityContext, config){
|
|
6
|
+
this.repository = repository;
|
|
7
|
+
this.identityContext = identityContext;
|
|
8
|
+
this.config = config;
|
|
9
|
+
}
|
|
10
|
+
async execute(input) {
|
|
11
|
+
const identity = this.identityContext.getIdentity();
|
|
12
|
+
const enhancedInput = {
|
|
13
|
+
...input,
|
|
14
|
+
where: {
|
|
15
|
+
...input?.where,
|
|
16
|
+
createdBy_not: identity.id,
|
|
17
|
+
savedOn_gte: new Date(new Date().getTime() - this.config.timeout).toISOString()
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
return await this.repository.execute(enhancedInput);
|
|
21
|
+
}
|
|
24
22
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
const ListLockRecordsUseCase_ListLockRecordsUseCase = ListLockRecordsUseCase.createImplementation({
|
|
24
|
+
implementation: ListLockRecordsUseCaseImpl,
|
|
25
|
+
dependencies: [
|
|
26
|
+
ListLockRecordsRepository,
|
|
27
|
+
IdentityContext,
|
|
28
|
+
RecordLockingConfig
|
|
29
|
+
]
|
|
28
30
|
});
|
|
31
|
+
export { ListLockRecordsUseCase_ListLockRecordsUseCase as ListLockRecordsUseCase };
|
|
29
32
|
|
|
30
33
|
//# sourceMappingURL=ListLockRecordsUseCase.js.map
|