@webiny/api-record-locking 0.0.0-unstable.6844005670 → 0.0.0-unstable.7be00a75a9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/domain/LockRecord.js +63 -70
- package/domain/LockRecord.js.map +1 -1
- package/domain/RecordLockingModel.js +26 -23
- package/domain/RecordLockingModel.js.map +1 -1
- package/domain/abstractions.js +3 -7
- package/domain/abstractions.js.map +1 -1
- package/domain/calculateExpiresOn.js +5 -6
- package/domain/calculateExpiresOn.js.map +1 -1
- package/domain/errors.js +71 -81
- package/domain/errors.js.map +1 -1
- package/domain/index.js +0 -2
- package/domain/types.js +6 -9
- package/domain/types.js.map +1 -1
- package/features/GetLockRecord/GetLockRecordRepository.js +27 -24
- package/features/GetLockRecord/GetLockRecordRepository.js.map +1 -1
- package/features/GetLockRecord/GetLockRecordUseCase.js +13 -10
- package/features/GetLockRecord/GetLockRecordUseCase.js.map +1 -1
- package/features/GetLockRecord/abstractions.js +3 -14
- package/features/GetLockRecord/abstractions.js.map +1 -1
- package/features/GetLockRecord/feature.d.ts +4 -1
- package/features/GetLockRecord/feature.js +7 -6
- package/features/GetLockRecord/feature.js.map +1 -1
- package/features/GetLockRecord/index.js +0 -2
- package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.d.ts +1 -1
- package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js +20 -29
- package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js.map +1 -1
- package/features/GetLockedEntryLockRecord/abstractions.js +2 -10
- package/features/GetLockedEntryLockRecord/abstractions.js.map +1 -1
- package/features/GetLockedEntryLockRecord/feature.d.ts +4 -1
- package/features/GetLockedEntryLockRecord/feature.js +6 -5
- package/features/GetLockedEntryLockRecord/feature.js.map +1 -1
- package/features/GetLockedEntryLockRecord/index.js +0 -2
- package/features/IsEntryLocked/IsEntryLockedUseCase.d.ts +1 -1
- package/features/IsEntryLocked/IsEntryLockedUseCase.js +23 -29
- package/features/IsEntryLocked/IsEntryLockedUseCase.js.map +1 -1
- package/features/IsEntryLocked/abstractions.js +2 -9
- package/features/IsEntryLocked/abstractions.js.map +1 -1
- package/features/IsEntryLocked/feature.d.ts +4 -1
- package/features/IsEntryLocked/feature.js +6 -5
- package/features/IsEntryLocked/feature.js.map +1 -1
- package/features/IsEntryLocked/index.js +0 -2
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.d.ts +1 -1
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js +33 -33
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js.map +1 -1
- package/features/KickOutCurrentUser/abstractions.js +2 -6
- package/features/KickOutCurrentUser/abstractions.js.map +1 -1
- package/features/KickOutCurrentUser/feature.d.ts +4 -1
- package/features/KickOutCurrentUser/feature.js +6 -5
- package/features/KickOutCurrentUser/feature.js.map +1 -1
- package/features/KickOutCurrentUser/index.js +0 -2
- package/features/ListAllLockRecords/ListAllLockRecordsRepository.js +31 -31
- package/features/ListAllLockRecords/ListAllLockRecordsRepository.js.map +1 -1
- package/features/ListAllLockRecords/ListAllLockRecordsUseCase.js +13 -10
- package/features/ListAllLockRecords/ListAllLockRecordsUseCase.js.map +1 -1
- package/features/ListAllLockRecords/abstractions.js +3 -14
- package/features/ListAllLockRecords/abstractions.js.map +1 -1
- package/features/ListAllLockRecords/feature.d.ts +4 -1
- package/features/ListAllLockRecords/feature.js +7 -6
- package/features/ListAllLockRecords/feature.js.map +1 -1
- package/features/ListAllLockRecords/index.js +0 -2
- package/features/ListLockRecords/ListLockRecordsRepository.js +31 -31
- package/features/ListLockRecords/ListLockRecordsRepository.js.map +1 -1
- package/features/ListLockRecords/ListLockRecordsUseCase.d.ts +1 -1
- package/features/ListLockRecords/ListLockRecordsUseCase.js +27 -24
- package/features/ListLockRecords/ListLockRecordsUseCase.js.map +1 -1
- package/features/ListLockRecords/abstractions.js +3 -14
- package/features/ListLockRecords/abstractions.js.map +1 -1
- package/features/ListLockRecords/feature.d.ts +4 -1
- package/features/ListLockRecords/feature.js +7 -6
- package/features/ListLockRecords/feature.js.map +1 -1
- package/features/ListLockRecords/index.js +0 -2
- package/features/LockEntry/LockEntryEventsDecorator.d.ts +1 -1
- package/features/LockEntry/LockEntryEventsDecorator.js +32 -32
- package/features/LockEntry/LockEntryEventsDecorator.js.map +1 -1
- package/features/LockEntry/LockEntryRepository.js +33 -30
- package/features/LockEntry/LockEntryRepository.js.map +1 -1
- package/features/LockEntry/LockEntryUseCase.js +21 -26
- package/features/LockEntry/LockEntryUseCase.js.map +1 -1
- package/features/LockEntry/abstractions.js +3 -14
- package/features/LockEntry/abstractions.js.map +1 -1
- package/features/LockEntry/events.d.ts +8 -8
- package/features/LockEntry/events.js +26 -34
- package/features/LockEntry/events.js.map +1 -1
- package/features/LockEntry/feature.d.ts +4 -1
- package/features/LockEntry/feature.js +8 -7
- package/features/LockEntry/feature.js.map +1 -1
- package/features/LockEntry/index.js +0 -2
- package/features/RecordLockingFeature.d.ts +4 -1
- package/features/RecordLockingFeature.js +19 -21
- package/features/RecordLockingFeature.js.map +1 -1
- package/features/UnlockEntry/UnlockEntryEventsDecorator.d.ts +1 -1
- package/features/UnlockEntry/UnlockEntryEventsDecorator.js +33 -33
- package/features/UnlockEntry/UnlockEntryEventsDecorator.js.map +1 -1
- package/features/UnlockEntry/UnlockEntryRepository.js +29 -27
- package/features/UnlockEntry/UnlockEntryRepository.js.map +1 -1
- package/features/UnlockEntry/UnlockEntryUseCase.d.ts +1 -1
- package/features/UnlockEntry/UnlockEntryUseCase.js +54 -70
- package/features/UnlockEntry/UnlockEntryUseCase.js.map +1 -1
- package/features/UnlockEntry/abstractions.js +3 -14
- package/features/UnlockEntry/abstractions.js.map +1 -1
- package/features/UnlockEntry/events.d.ts +8 -8
- package/features/UnlockEntry/events.js +26 -34
- package/features/UnlockEntry/events.js.map +1 -1
- package/features/UnlockEntry/feature.d.ts +4 -1
- package/features/UnlockEntry/feature.js +8 -7
- package/features/UnlockEntry/feature.js.map +1 -1
- package/features/UnlockEntry/hasFullAccessPermission.d.ts +1 -1
- package/features/UnlockEntry/hasFullAccessPermission.js +6 -7
- package/features/UnlockEntry/hasFullAccessPermission.js.map +1 -1
- package/features/UnlockEntry/index.js +0 -2
- package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.d.ts +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js +32 -32
- package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js.map +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.d.ts +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js +32 -31
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js.map +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.d.ts +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js +63 -80
- package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js.map +1 -1
- package/features/UnlockEntryRequest/abstractions.js +3 -14
- package/features/UnlockEntryRequest/abstractions.js.map +1 -1
- package/features/UnlockEntryRequest/events.d.ts +8 -8
- package/features/UnlockEntryRequest/events.js +26 -34
- package/features/UnlockEntryRequest/events.js.map +1 -1
- package/features/UnlockEntryRequest/feature.d.ts +4 -1
- package/features/UnlockEntryRequest/feature.js +8 -7
- package/features/UnlockEntryRequest/feature.js.map +1 -1
- package/features/UnlockEntryRequest/index.js +0 -2
- package/features/UpdateEntryLock/UpdateEntryLockRepository.d.ts +1 -1
- package/features/UpdateEntryLock/UpdateEntryLockRepository.js +46 -49
- package/features/UpdateEntryLock/UpdateEntryLockRepository.js.map +1 -1
- package/features/UpdateEntryLock/UpdateEntryLockUseCase.d.ts +1 -1
- package/features/UpdateEntryLock/UpdateEntryLockUseCase.js +41 -52
- package/features/UpdateEntryLock/UpdateEntryLockUseCase.js.map +1 -1
- package/features/UpdateEntryLock/abstractions.js +3 -14
- package/features/UpdateEntryLock/abstractions.js.map +1 -1
- package/features/UpdateEntryLock/feature.d.ts +4 -1
- package/features/UpdateEntryLock/feature.js +7 -6
- package/features/UpdateEntryLock/feature.js.map +1 -1
- package/features/UpdateEntryLock/index.js +0 -2
- package/graphql/checkPermissions.js +6 -10
- package/graphql/checkPermissions.js.map +1 -1
- package/graphql/resolve.js +15 -17
- package/graphql/resolve.js.map +1 -1
- package/graphql/schema.d.ts +2 -2
- package/graphql/schema.js +147 -168
- package/graphql/schema.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +46 -48
- package/index.js.map +1 -1
- package/package.json +27 -22
- package/types.js +6 -9
- package/types.js.map +1 -1
- package/utils/convertWhereCondition.js +20 -32
- package/utils/convertWhereCondition.js.map +1 -1
- package/utils/getTimeout.js +8 -15
- package/utils/getTimeout.js.map +1 -1
- package/utils/lockRecordDatabaseId.js +6 -11
- package/utils/lockRecordDatabaseId.js.map +1 -1
- package/domain/index.js.map +0 -1
- package/features/GetLockRecord/index.js.map +0 -1
- package/features/GetLockedEntryLockRecord/index.js.map +0 -1
- package/features/IsEntryLocked/index.js.map +0 -1
- package/features/KickOutCurrentUser/index.js.map +0 -1
- package/features/ListAllLockRecords/index.js.map +0 -1
- package/features/ListLockRecords/index.js.map +0 -1
- package/features/LockEntry/index.js.map +0 -1
- package/features/UnlockEntry/index.js.map +0 -1
- package/features/UnlockEntryRequest/index.js.map +0 -1
- package/features/UpdateEntryLock/index.js.map +0 -1
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
|
-
import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
|
|
2
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
3
3
|
import { WebsocketService } from "@webiny/api-websockets/features/WebsocketService/index.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, websocketService){
|
|
8
|
+
this.identityContext = identityContext;
|
|
9
|
+
this.websocketService = websocketService;
|
|
10
|
+
}
|
|
11
|
+
async execute(record) {
|
|
12
|
+
if (!this.websocketService) return Result.ok();
|
|
13
|
+
const { lockedBy, id } = record;
|
|
14
|
+
const { id: entryId } = parseIdentifier(id);
|
|
15
|
+
const identity = this.identityContext.getIdentity();
|
|
16
|
+
await this.websocketService.send({
|
|
17
|
+
id: lockedBy.id
|
|
18
|
+
}, {
|
|
19
|
+
action: `recordLocking.entry.kickOut.${entryId}`,
|
|
20
|
+
data: {
|
|
21
|
+
record: record.toObject(),
|
|
22
|
+
user: identity
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return Result.ok();
|
|
14
26
|
}
|
|
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
27
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
const KickOutCurrentUserUseCase_KickOutCurrentUserUseCase = KickOutCurrentUserUseCase.createImplementation({
|
|
29
|
+
implementation: KickOutCurrentUserUseCaseImpl,
|
|
30
|
+
dependencies: [
|
|
31
|
+
IdentityContext,
|
|
32
|
+
[
|
|
33
|
+
WebsocketService,
|
|
34
|
+
{
|
|
35
|
+
optional: true
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
]
|
|
40
39
|
});
|
|
40
|
+
export { KickOutCurrentUserUseCase_KickOutCurrentUserUseCase as KickOutCurrentUserUseCase };
|
|
41
41
|
|
|
42
42
|
//# 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 { WebsocketService } from \"@webiny/api-websockets/features/WebsocketService/index.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 websocketService?: WebsocketService.Interface\n ) {}\n\n async execute(record: ILockRecord): Promise<Result<void, UseCaseAbstraction.Error>> {\n if (!this.websocketService) {\n return Result.ok();\n }\n\n const { lockedBy, id } = record;\n\n const { id: entryId } = parseIdentifier(id);\n const identity = this.identityContext.getIdentity();\n\n await this.websocketService.send(\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, [WebsocketService, { optional: true }]]\n});\n"],"names":["KickOutCurrentUserUseCaseImpl","identityContext","websocketService","record","Result","lockedBy","id","entryId","parseIdentifier","identity","KickOutCurrentUserUseCase","UseCaseAbstraction","IdentityContext","WebsocketService"],"mappings":";;;;;AAOA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,gBAA6C,CACvD;aAFUD,eAAe,GAAfA;aACAC,gBAAgB,GAAhBA;IACT;IAEH,MAAM,QAAQC,MAAmB,EAAmD;QAChF,IAAI,CAAC,IAAI,CAAC,gBAAgB,EACtB,OAAOC,OAAO,EAAE;QAGpB,MAAM,EAAEC,QAAQ,EAAEC,EAAE,EAAE,GAAGH;QAEzB,MAAM,EAAE,IAAII,OAAO,EAAE,GAAGC,gBAAgBF;QACxC,MAAMG,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;QAEjD,MAAM,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAC5B;YAAE,IAAIJ,SAAS,EAAE;QAAC,GAClB;YACI,QAAQ,CAAC,4BAA4B,EAAEE,SAAS;YAChD,MAAM;gBACF,QAAQJ,OAAO,QAAQ;gBACvB,MAAMM;YACV;QACJ;QAGJ,OAAOL,OAAO,EAAE;IACpB;AACJ;AAEO,MAAMM,sDAA4BC,0BAAAA,oBAAuC,CAAC;IAC7E,gBAAgBX;IAChB,cAAc;QAACY;QAAiB;YAACC;YAAkB;gBAAE,UAAU;YAAK;SAAE;KAAC;AAC3E"}
|
|
@@ -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,43 +1,43 @@
|
|
|
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
4
|
import { RecordLockingConfig, RecordLockingModel } from "../../domain/abstractions.js";
|
|
5
5
|
import { LockRecordPersistenceError } from "../../domain/errors.js";
|
|
6
6
|
import { convertWhereCondition } from "../../utils/convertWhereCondition.js";
|
|
7
7
|
import { LockRecord } from "../../domain/LockRecord.js";
|
|
8
8
|
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
|
-
meta
|
|
32
|
-
});
|
|
33
|
-
} catch (error) {
|
|
34
|
-
return Result.fail(new LockRecordPersistenceError(error));
|
|
9
|
+
constructor(config, listEntries, model){
|
|
10
|
+
this.config = config;
|
|
11
|
+
this.listEntries = listEntries;
|
|
12
|
+
this.model = model;
|
|
13
|
+
}
|
|
14
|
+
async execute(input) {
|
|
15
|
+
try {
|
|
16
|
+
const params = {
|
|
17
|
+
...input,
|
|
18
|
+
where: convertWhereCondition(input?.where)
|
|
19
|
+
};
|
|
20
|
+
const result = await this.listEntries.execute(this.model, params);
|
|
21
|
+
if (result.isFail()) return Result.fail(new LockRecordPersistenceError(result.error));
|
|
22
|
+
const { entries, meta } = result.value;
|
|
23
|
+
const items = entries.map((entry)=>new LockRecord(entry, this.config.timeout));
|
|
24
|
+
return Result.ok({
|
|
25
|
+
items,
|
|
26
|
+
meta
|
|
27
|
+
});
|
|
28
|
+
} catch (error) {
|
|
29
|
+
return Result.fail(new LockRecordPersistenceError(error));
|
|
30
|
+
}
|
|
35
31
|
}
|
|
36
|
-
}
|
|
37
32
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
const ListAllLockRecordsRepository_ListAllLockRecordsRepository = ListAllLockRecordsRepository.createImplementation({
|
|
34
|
+
implementation: ListAllLockRecordsRepositoryImpl,
|
|
35
|
+
dependencies: [
|
|
36
|
+
RecordLockingConfig,
|
|
37
|
+
ListLatestEntriesUseCase,
|
|
38
|
+
RecordLockingModel
|
|
39
|
+
]
|
|
41
40
|
});
|
|
41
|
+
export { ListAllLockRecordsRepository_ListAllLockRecordsRepository as ListAllLockRecordsRepository };
|
|
42
42
|
|
|
43
43
|
//# 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 { RecordLockingConfig, RecordLockingModel } from \"~/domain/abstractions.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types\";\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 ) {}\n\n async execute(\n input?: ListAllLockRecordsInput\n ): Promise<Result<ListAllLockRecordsOutput, RepositoryAbstraction.Error>> {\n try {\n const params = {\n ...input,\n where: convertWhereCondition(input?.where)\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: [RecordLockingConfig, ListLatestEntriesUseCase, RecordLockingModel]\n});\n"],"names":["ListAllLockRecordsRepositoryImpl","config","listEntries","model","input","params","convertWhereCondition","result","Result","LockRecordPersistenceError","entries","meta","items","entry","LockRecord","error","ListAllLockRecordsRepository","RepositoryAbstraction","RecordLockingConfig","ListLatestEntriesUseCase","RecordLockingModel"],"mappings":";;;;;;;AAcA,MAAMA;IACF,YACYC,MAAqC,EACrCC,WAA+C,EAC/CC,KAAe,CACzB;aAHUF,MAAM,GAANA;aACAC,WAAW,GAAXA;aACAC,KAAK,GAALA;IACT;IAEH,MAAM,QACFC,KAA+B,EACuC;QACtE,IAAI;YACA,MAAMC,SAAS;gBACX,GAAGD,KAAK;gBACR,OAAOE,sBAAsBF,OAAO;YACxC;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,gBAAgBjB;IAChB,cAAc;QAACkB;QAAqBC;QAA0BC;KAAmB;AACrF"}
|
|
@@ -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"}
|
|
@@ -1,43 +1,43 @@
|
|
|
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
7
|
import { convertWhereCondition } from "../../utils/convertWhereCondition.js";
|
|
8
8
|
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
|
-
meta
|
|
32
|
-
});
|
|
33
|
-
} catch (error) {
|
|
34
|
-
return Result.fail(new LockRecordPersistenceError(error));
|
|
9
|
+
constructor(model, config, listEntries){
|
|
10
|
+
this.model = model;
|
|
11
|
+
this.config = config;
|
|
12
|
+
this.listEntries = listEntries;
|
|
13
|
+
}
|
|
14
|
+
async execute(input) {
|
|
15
|
+
try {
|
|
16
|
+
const params = {
|
|
17
|
+
...input,
|
|
18
|
+
where: convertWhereCondition(input?.where || {})
|
|
19
|
+
};
|
|
20
|
+
const result = await this.listEntries.execute(this.model, params);
|
|
21
|
+
if (result.isFail()) return Result.fail(new LockRecordPersistenceError(result.error));
|
|
22
|
+
const { entries, meta } = result.value;
|
|
23
|
+
const items = entries.map((entry)=>new LockRecord(entry, this.config.timeout));
|
|
24
|
+
return Result.ok({
|
|
25
|
+
items,
|
|
26
|
+
meta
|
|
27
|
+
});
|
|
28
|
+
} catch (error) {
|
|
29
|
+
return Result.fail(new LockRecordPersistenceError(error));
|
|
30
|
+
}
|
|
35
31
|
}
|
|
36
|
-
}
|
|
37
32
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
const ListLockRecordsRepository_ListLockRecordsRepository = ListLockRecordsRepository.createImplementation({
|
|
34
|
+
implementation: ListLockRecordsRepositoryImpl,
|
|
35
|
+
dependencies: [
|
|
36
|
+
RecordLockingModel,
|
|
37
|
+
RecordLockingConfig,
|
|
38
|
+
ListLatestEntriesUseCase
|
|
39
|
+
]
|
|
41
40
|
});
|
|
41
|
+
export { ListLockRecordsRepository_ListLockRecordsRepository as ListLockRecordsRepository };
|
|
42
42
|
|
|
43
43
|
//# 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 { 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 ) {}\n\n async execute(\n input?: ListLockRecordsInput\n ): Promise<Result<ListLockRecordsOutput, RepositoryAbstraction.Error>> {\n try {\n const params = {\n ...input,\n where: convertWhereCondition(input?.where || {})\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: [RecordLockingModel, RecordLockingConfig, ListLatestEntriesUseCase]\n});\n"],"names":["ListLockRecordsRepositoryImpl","model","config","listEntries","input","params","convertWhereCondition","result","Result","LockRecordPersistenceError","entries","meta","items","entry","LockRecord","error","ListLockRecordsRepository","RepositoryAbstraction","RecordLockingModel","RecordLockingConfig","ListLatestEntriesUseCase"],"mappings":";;;;;;;AAaA,MAAMA;IACF,YACYC,KAAmC,EACnCC,MAAqC,EACrCC,WAA+C,CACzD;aAHUF,KAAK,GAALA;aACAC,MAAM,GAANA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,QACFC,KAA4B,EACuC;QACnE,IAAI;YACA,MAAMC,SAAS;gBACX,GAAGD,KAAK;gBACR,OAAOE,sBAAsBF,OAAO,SAAS,CAAC;YAClD;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,gBAAgBjB;IAChB,cAAc;QAACkB;QAAoBC;QAAqBC;KAAyB;AACrF"}
|
|
@@ -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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/ListLockRecords/ListLockRecordsUseCase.js","sources":["../../../src/features/ListLockRecords/ListLockRecordsUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n ListLockRecordsInput,\n ListLockRecordsOutput,\n ListLockRecordsRepository,\n ListLockRecordsUseCase as UseCaseAbstraction\n} from \"./abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { RecordLockingConfig } from \"~/domain/abstractions.js\";\n\nclass ListLockRecordsUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private repository: ListLockRecordsRepository.Interface,\n private identityContext: IdentityContext.Interface,\n private config: RecordLockingConfig.Interface\n ) {}\n\n async execute(\n input?: ListLockRecordsInput\n ): Promise<Result<ListLockRecordsOutput, UseCaseAbstraction.Error>> {\n const identity = this.identityContext.getIdentity();\n\n // Filter out expired locks and exclude current user's locks\n const enhancedInput: ListLockRecordsInput = {\n ...input,\n where: {\n ...input?.where,\n createdBy_not: identity.id,\n savedOn_gte: new Date(new Date().getTime() - this.config.timeout).toISOString()\n }\n };\n\n return await this.repository.execute(enhancedInput);\n }\n}\n\nexport const ListLockRecordsUseCase = UseCaseAbstraction.createImplementation({\n implementation: ListLockRecordsUseCaseImpl,\n dependencies: [ListLockRecordsRepository, IdentityContext, RecordLockingConfig]\n});\n"],"names":["ListLockRecordsUseCaseImpl","repository","identityContext","config","input","identity","enhancedInput","Date","ListLockRecordsUseCase","UseCaseAbstraction","ListLockRecordsRepository","IdentityContext","RecordLockingConfig"],"mappings":";;;AAUA,MAAMA;IACF,YACYC,UAA+C,EAC/CC,eAA0C,EAC1CC,MAAqC,CAC/C;aAHUF,UAAU,GAAVA;aACAC,eAAe,GAAfA;aACAC,MAAM,GAANA;IACT;IAEH,MAAM,QACFC,KAA4B,EACoC;QAChE,MAAMC,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;QAGjD,MAAMC,gBAAsC;YACxC,GAAGF,KAAK;YACR,OAAO;gBACH,GAAGA,OAAO,KAAK;gBACf,eAAeC,SAAS,EAAE;gBAC1B,aAAa,IAAIE,KAAK,IAAIA,OAAO,OAAO,KAAK,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,WAAW;YACjF;QACJ;QAEA,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAACD;IACzC;AACJ;AAEO,MAAME,gDAAyBC,uBAAAA,oBAAuC,CAAC;IAC1E,gBAAgBT;IAChB,cAAc;QAACU;QAA2BC;QAAiBC;KAAoB;AACnF"}
|
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* ListLockRecords Use Case - Lists active lock records (filters out expired, excludes current user)
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
export const ListLockRecordsUseCase = createAbstraction("ListLockRecordsUseCase");
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* ListLockRecordsRepository - Fetches lock records from storage with filtering
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
export const ListLockRecordsRepository = createAbstraction("ListLockRecordsRepository");
|
|
2
|
+
const ListLockRecordsUseCase = createAbstraction("ListLockRecordsUseCase");
|
|
3
|
+
const ListLockRecordsRepository = createAbstraction("ListLockRecordsRepository");
|
|
4
|
+
export { ListLockRecordsRepository, ListLockRecordsUseCase };
|
|
16
5
|
|
|
17
6
|
//# sourceMappingURL=abstractions.js.map
|