@webiny/api-record-locking 0.0.0-unstable.e622468070 → 0.0.0-unstable.e6f0dc8ca7
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/features/GetLockRecord/feature.d.ts +4 -1
- package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.d.ts +1 -1
- package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js +1 -1
- package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js.map +1 -1
- package/features/GetLockedEntryLockRecord/feature.d.ts +4 -1
- package/features/IsEntryLocked/IsEntryLockedUseCase.d.ts +1 -1
- package/features/IsEntryLocked/IsEntryLockedUseCase.js +1 -1
- package/features/IsEntryLocked/IsEntryLockedUseCase.js.map +1 -1
- package/features/IsEntryLocked/feature.d.ts +4 -1
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.d.ts +1 -1
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js +1 -1
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js.map +1 -1
- package/features/KickOutCurrentUser/feature.d.ts +4 -1
- package/features/ListAllLockRecords/feature.d.ts +4 -1
- package/features/ListLockRecords/ListLockRecordsUseCase.d.ts +1 -1
- package/features/ListLockRecords/ListLockRecordsUseCase.js +1 -1
- package/features/ListLockRecords/ListLockRecordsUseCase.js.map +1 -1
- package/features/ListLockRecords/abstractions.js.map +1 -1
- package/features/ListLockRecords/feature.d.ts +4 -1
- package/features/LockEntry/LockEntryEventsDecorator.d.ts +1 -1
- package/features/LockEntry/LockEntryEventsDecorator.js +1 -1
- package/features/LockEntry/LockEntryEventsDecorator.js.map +1 -1
- package/features/LockEntry/events.d.ts +8 -8
- package/features/LockEntry/events.js +7 -7
- package/features/LockEntry/events.js.map +1 -1
- package/features/LockEntry/feature.d.ts +4 -1
- package/features/RecordLockingFeature.d.ts +4 -1
- package/features/RecordLockingFeature.js.map +1 -1
- package/features/UnlockEntry/UnlockEntryEventsDecorator.d.ts +1 -1
- package/features/UnlockEntry/UnlockEntryEventsDecorator.js +1 -1
- package/features/UnlockEntry/UnlockEntryEventsDecorator.js.map +1 -1
- package/features/UnlockEntry/UnlockEntryUseCase.d.ts +1 -1
- package/features/UnlockEntry/UnlockEntryUseCase.js +1 -1
- package/features/UnlockEntry/UnlockEntryUseCase.js.map +1 -1
- package/features/UnlockEntry/events.d.ts +8 -8
- package/features/UnlockEntry/events.js +7 -7
- package/features/UnlockEntry/events.js.map +1 -1
- package/features/UnlockEntry/feature.d.ts +4 -1
- package/features/UnlockEntry/hasFullAccessPermission.d.ts +1 -1
- package/features/UnlockEntry/hasFullAccessPermission.js +1 -1
- package/features/UnlockEntry/hasFullAccessPermission.js.map +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.d.ts +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js.map +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.d.ts +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js.map +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.d.ts +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js.map +1 -1
- package/features/UnlockEntryRequest/events.d.ts +8 -8
- package/features/UnlockEntryRequest/events.js +7 -7
- package/features/UnlockEntryRequest/events.js.map +1 -1
- package/features/UnlockEntryRequest/feature.d.ts +4 -1
- package/features/UpdateEntryLock/UpdateEntryLockRepository.d.ts +1 -1
- package/features/UpdateEntryLock/UpdateEntryLockRepository.js +1 -1
- package/features/UpdateEntryLock/UpdateEntryLockRepository.js.map +1 -1
- package/features/UpdateEntryLock/UpdateEntryLockUseCase.d.ts +1 -1
- package/features/UpdateEntryLock/UpdateEntryLockUseCase.js +1 -1
- package/features/UpdateEntryLock/UpdateEntryLockUseCase.js.map +1 -1
- package/features/UpdateEntryLock/feature.d.ts +4 -1
- package/graphql/checkPermissions.js +1 -1
- package/graphql/checkPermissions.js.map +1 -1
- package/graphql/schema.d.ts +2 -2
- package/graphql/schema.js +5 -8
- package/graphql/schema.js.map +1 -1
- package/index.js +3 -2
- package/index.js.map +1 -1
- package/package.json +24 -21
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { GetLockedEntryLockRecordUseCase as UseCaseAbstraction, GetLockedEntryLockRecordInput } from "./abstractions.js";
|
|
3
3
|
import { GetLockRecordUseCase } from "../GetLockRecord/abstractions.js";
|
|
4
|
-
import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
|
|
4
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
5
5
|
import type { ILockRecord } from "../../domain/LockRecord.js";
|
|
6
6
|
declare class GetLockedEntryLockRecordUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
7
7
|
private getLockRecord;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { GetLockedEntryLockRecordUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
3
3
|
import { GetLockRecordUseCase } from "../GetLockRecord/abstractions.js";
|
|
4
|
-
import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
|
|
4
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
5
5
|
import { LockRecordNotFoundError } from "../../domain/errors.js";
|
|
6
6
|
class GetLockedEntryLockRecordUseCaseImpl {
|
|
7
7
|
constructor(getLockRecord, identityContext) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Result","GetLockedEntryLockRecordUseCase","UseCaseAbstraction","GetLockRecordUseCase","IdentityContext","LockRecordNotFoundError","GetLockedEntryLockRecordUseCaseImpl","constructor","getLockRecord","identityContext","execute","input","result","isFail","fail","record","value","identity","getIdentity","lockedByCurrentUser","lockedBy","id","isExpired","ok","createImplementation","implementation","dependencies"],"sources":["GetLockedEntryLockRecordUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n GetLockedEntryLockRecordUseCase as UseCaseAbstraction,\n GetLockedEntryLockRecordInput\n} from \"./abstractions.js\";\nimport { GetLockRecordUseCase } from \"../GetLockRecord/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/IdentityContext\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport { LockRecordNotFoundError } from \"~/domain/errors.js\";\n\nclass GetLockedEntryLockRecordUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getLockRecord: GetLockRecordUseCase.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute(\n input: GetLockedEntryLockRecordInput\n ): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Get the lock record\n const result = await this.getLockRecord.execute(input);\n\n // If not found or error, return not found error\n if (result.isFail()) {\n return Result.fail(new LockRecordNotFoundError());\n }\n\n const record = result.value;\n const identity = this.identityContext.getIdentity();\n\n // Record is treated as \"not found\":\n // - If locked by current user\n // - If expired\n const lockedByCurrentUser = record.lockedBy.id === identity.id;\n\n if (record.isExpired() || lockedByCurrentUser) {\n return Result.fail(new LockRecordNotFoundError());\n }\n\n // Locked by another user, return the record\n return Result.ok(record);\n }\n}\n\nexport const GetLockedEntryLockRecordUseCase = UseCaseAbstraction.createImplementation({\n implementation: GetLockedEntryLockRecordUseCaseImpl,\n dependencies: [GetLockRecordUseCase, IdentityContext]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SACIC,+BAA+B,IAAIC,kBAAkB;AAGzD,SAASC,oBAAoB;AAC7B,SAASC,eAAe,QAAQ,
|
|
1
|
+
{"version":3,"names":["Result","GetLockedEntryLockRecordUseCase","UseCaseAbstraction","GetLockRecordUseCase","IdentityContext","LockRecordNotFoundError","GetLockedEntryLockRecordUseCaseImpl","constructor","getLockRecord","identityContext","execute","input","result","isFail","fail","record","value","identity","getIdentity","lockedByCurrentUser","lockedBy","id","isExpired","ok","createImplementation","implementation","dependencies"],"sources":["GetLockedEntryLockRecordUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n GetLockedEntryLockRecordUseCase as UseCaseAbstraction,\n GetLockedEntryLockRecordInput\n} from \"./abstractions.js\";\nimport { GetLockRecordUseCase } from \"../GetLockRecord/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport { LockRecordNotFoundError } from \"~/domain/errors.js\";\n\nclass GetLockedEntryLockRecordUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getLockRecord: GetLockRecordUseCase.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute(\n input: GetLockedEntryLockRecordInput\n ): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Get the lock record\n const result = await this.getLockRecord.execute(input);\n\n // If not found or error, return not found error\n if (result.isFail()) {\n return Result.fail(new LockRecordNotFoundError());\n }\n\n const record = result.value;\n const identity = this.identityContext.getIdentity();\n\n // Record is treated as \"not found\":\n // - If locked by current user\n // - If expired\n const lockedByCurrentUser = record.lockedBy.id === identity.id;\n\n if (record.isExpired() || lockedByCurrentUser) {\n return Result.fail(new LockRecordNotFoundError());\n }\n\n // Locked by another user, return the record\n return Result.ok(record);\n }\n}\n\nexport const GetLockedEntryLockRecordUseCase = UseCaseAbstraction.createImplementation({\n implementation: GetLockedEntryLockRecordUseCaseImpl,\n dependencies: [GetLockRecordUseCase, IdentityContext]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SACIC,+BAA+B,IAAIC,kBAAkB;AAGzD,SAASC,oBAAoB;AAC7B,SAASC,eAAe,QAAQ,6DAA6D;AAE7F,SAASC,uBAAuB;AAEhC,MAAMC,mCAAmC,CAAyC;EAC9EC,WAAWA,CACCC,aAA6C,EAC7CC,eAA0C,EACpD;IAAA,KAFUD,aAA6C,GAA7CA,aAA6C;IAAA,KAC7CC,eAA0C,GAA1CA,eAA0C;EACnD;EAEH,MAAMC,OAAOA,CACTC,KAAoC,EACkB;IACtD;IACA,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACJ,aAAa,CAACE,OAAO,CAACC,KAAK,CAAC;;IAEtD;IACA,IAAIC,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;MACjB,OAAOb,MAAM,CAACc,IAAI,CAAC,IAAIT,uBAAuB,CAAC,CAAC,CAAC;IACrD;IAEA,MAAMU,MAAM,GAAGH,MAAM,CAACI,KAAK;IAC3B,MAAMC,QAAQ,GAAG,IAAI,CAACR,eAAe,CAACS,WAAW,CAAC,CAAC;;IAEnD;IACA;IACA;IACA,MAAMC,mBAAmB,GAAGJ,MAAM,CAACK,QAAQ,CAACC,EAAE,KAAKJ,QAAQ,CAACI,EAAE;IAE9D,IAAIN,MAAM,CAACO,SAAS,CAAC,CAAC,IAAIH,mBAAmB,EAAE;MAC3C,OAAOnB,MAAM,CAACc,IAAI,CAAC,IAAIT,uBAAuB,CAAC,CAAC,CAAC;IACrD;;IAEA;IACA,OAAOL,MAAM,CAACuB,EAAE,CAACR,MAAM,CAAC;EAC5B;AACJ;AAEA,OAAO,MAAMd,+BAA+B,GAAGC,kBAAkB,CAACsB,oBAAoB,CAAC;EACnFC,cAAc,EAAEnB,mCAAmC;EACnDoB,YAAY,EAAE,CAACvB,oBAAoB,EAAEC,eAAe;AACxD,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { IsEntryLockedUseCase as UseCaseAbstraction, IsEntryLockedInput } from "./abstractions.js";
|
|
3
3
|
import { GetLockRecordUseCase } from "../GetLockRecord/abstractions.js";
|
|
4
|
-
import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
|
|
4
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
5
5
|
declare class IsEntryLockedUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
6
6
|
private getLockRecord;
|
|
7
7
|
private identityContext;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { IsEntryLockedUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
3
3
|
import { GetLockRecordUseCase } from "../GetLockRecord/abstractions.js";
|
|
4
|
-
import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
|
|
4
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
5
5
|
import { LockRecordNotFoundError } from "../../domain/errors.js";
|
|
6
6
|
class IsEntryLockedUseCaseImpl {
|
|
7
7
|
constructor(getLockRecord, identityContext) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Result","IsEntryLockedUseCase","UseCaseAbstraction","GetLockRecordUseCase","IdentityContext","LockRecordNotFoundError","IsEntryLockedUseCaseImpl","constructor","getLockRecord","identityContext","execute","input","result","isFail","error","ok","fail","record","value","isExpired","identity","getIdentity","isLockedByOther","lockedBy","id","createImplementation","implementation","dependencies"],"sources":["IsEntryLockedUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { IsEntryLockedUseCase as UseCaseAbstraction, IsEntryLockedInput } from \"./abstractions.js\";\nimport { GetLockRecordUseCase } from \"../GetLockRecord/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/IdentityContext\";\nimport { LockRecordNotFoundError } from \"~/domain/errors.js\";\n\nclass IsEntryLockedUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getLockRecord: GetLockRecordUseCase.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute(input: IsEntryLockedInput): Promise<Result<boolean, UseCaseAbstraction.Error>> {\n const result = await this.getLockRecord.execute(input);\n\n if (result.isFail()) {\n // If not found, entry is not locked\n if (result.error instanceof LockRecordNotFoundError) {\n return Result.ok(false);\n }\n // Propagate other errors\n return Result.fail(result.error);\n }\n\n const record = result.value;\n\n // If expired, entry is not locked\n if (record.isExpired()) {\n return Result.ok(false);\n }\n\n // Check if locked by someone else\n const identity = this.identityContext.getIdentity();\n const isLockedByOther = record.lockedBy.id !== identity.id;\n\n return Result.ok(isLockedByOther);\n }\n}\n\nexport const IsEntryLockedUseCase = UseCaseAbstraction.createImplementation({\n implementation: IsEntryLockedUseCaseImpl,\n dependencies: [GetLockRecordUseCase, IdentityContext]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,oBAAoB,IAAIC,kBAAkB;AACnD,SAASC,oBAAoB;AAC7B,SAASC,eAAe,QAAQ,
|
|
1
|
+
{"version":3,"names":["Result","IsEntryLockedUseCase","UseCaseAbstraction","GetLockRecordUseCase","IdentityContext","LockRecordNotFoundError","IsEntryLockedUseCaseImpl","constructor","getLockRecord","identityContext","execute","input","result","isFail","error","ok","fail","record","value","isExpired","identity","getIdentity","isLockedByOther","lockedBy","id","createImplementation","implementation","dependencies"],"sources":["IsEntryLockedUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { IsEntryLockedUseCase as UseCaseAbstraction, IsEntryLockedInput } from \"./abstractions.js\";\nimport { GetLockRecordUseCase } from \"../GetLockRecord/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { LockRecordNotFoundError } from \"~/domain/errors.js\";\n\nclass IsEntryLockedUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getLockRecord: GetLockRecordUseCase.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute(input: IsEntryLockedInput): Promise<Result<boolean, UseCaseAbstraction.Error>> {\n const result = await this.getLockRecord.execute(input);\n\n if (result.isFail()) {\n // If not found, entry is not locked\n if (result.error instanceof LockRecordNotFoundError) {\n return Result.ok(false);\n }\n // Propagate other errors\n return Result.fail(result.error);\n }\n\n const record = result.value;\n\n // If expired, entry is not locked\n if (record.isExpired()) {\n return Result.ok(false);\n }\n\n // Check if locked by someone else\n const identity = this.identityContext.getIdentity();\n const isLockedByOther = record.lockedBy.id !== identity.id;\n\n return Result.ok(isLockedByOther);\n }\n}\n\nexport const IsEntryLockedUseCase = UseCaseAbstraction.createImplementation({\n implementation: IsEntryLockedUseCaseImpl,\n dependencies: [GetLockRecordUseCase, IdentityContext]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,oBAAoB,IAAIC,kBAAkB;AACnD,SAASC,oBAAoB;AAC7B,SAASC,eAAe,QAAQ,6DAA6D;AAC7F,SAASC,uBAAuB;AAEhC,MAAMC,wBAAwB,CAAyC;EACnEC,WAAWA,CACCC,aAA6C,EAC7CC,eAA0C,EACpD;IAAA,KAFUD,aAA6C,GAA7CA,aAA6C;IAAA,KAC7CC,eAA0C,GAA1CA,eAA0C;EACnD;EAEH,MAAMC,OAAOA,CAACC,KAAyB,EAAsD;IACzF,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACJ,aAAa,CAACE,OAAO,CAACC,KAAK,CAAC;IAEtD,IAAIC,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;MACjB;MACA,IAAID,MAAM,CAACE,KAAK,YAAYT,uBAAuB,EAAE;QACjD,OAAOL,MAAM,CAACe,EAAE,CAAC,KAAK,CAAC;MAC3B;MACA;MACA,OAAOf,MAAM,CAACgB,IAAI,CAACJ,MAAM,CAACE,KAAK,CAAC;IACpC;IAEA,MAAMG,MAAM,GAAGL,MAAM,CAACM,KAAK;;IAE3B;IACA,IAAID,MAAM,CAACE,SAAS,CAAC,CAAC,EAAE;MACpB,OAAOnB,MAAM,CAACe,EAAE,CAAC,KAAK,CAAC;IAC3B;;IAEA;IACA,MAAMK,QAAQ,GAAG,IAAI,CAACX,eAAe,CAACY,WAAW,CAAC,CAAC;IACnD,MAAMC,eAAe,GAAGL,MAAM,CAACM,QAAQ,CAACC,EAAE,KAAKJ,QAAQ,CAACI,EAAE;IAE1D,OAAOxB,MAAM,CAACe,EAAE,CAACO,eAAe,CAAC;EACrC;AACJ;AAEA,OAAO,MAAMrB,oBAAoB,GAAGC,kBAAkB,CAACuB,oBAAoB,CAAC;EACxEC,cAAc,EAAEpB,wBAAwB;EACxCqB,YAAY,EAAE,CAACxB,oBAAoB,EAAEC,eAAe;AACxD,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
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 { KickOutCurrentUserUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
5
5
|
import type { ILockRecord } from "../../domain/index.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
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
5
|
import { KickOutCurrentUserUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Result","IdentityContext","WebsocketService","parseIdentifier","KickOutCurrentUserUseCase","UseCaseAbstraction","KickOutCurrentUserUseCaseImpl","constructor","identityContext","websocketService","execute","record","ok","lockedBy","id","entryId","identity","getIdentity","send","action","data","toObject","user","createImplementation","implementation","dependencies","optional"],"sources":["KickOutCurrentUserUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { IdentityContext } from \"@webiny/api-core/features/IdentityContext\";\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"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,eAAe,QAAQ,
|
|
1
|
+
{"version":3,"names":["Result","IdentityContext","WebsocketService","parseIdentifier","KickOutCurrentUserUseCase","UseCaseAbstraction","KickOutCurrentUserUseCaseImpl","constructor","identityContext","websocketService","execute","record","ok","lockedBy","id","entryId","identity","getIdentity","send","action","data","toObject","user","createImplementation","implementation","dependencies","optional"],"sources":["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"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,eAAe,QAAQ,6DAA6D;AAC7F,SAASC,gBAAgB,QAAQ,2DAA2D;AAC5F,SAASC,eAAe,QAAQ,eAAe;AAC/C,SAASC,yBAAyB,IAAIC,kBAAkB;AAGxD,MAAMC,6BAA6B,CAAyC;EACxEC,WAAWA,CACCC,eAA0C,EAC1CC,gBAA6C,EACvD;IAAA,KAFUD,eAA0C,GAA1CA,eAA0C;IAAA,KAC1CC,gBAA6C,GAA7CA,gBAA6C;EACtD;EAEH,MAAMC,OAAOA,CAACC,MAAmB,EAAmD;IAChF,IAAI,CAAC,IAAI,CAACF,gBAAgB,EAAE;MACxB,OAAOT,MAAM,CAACY,EAAE,CAAC,CAAC;IACtB;IAEA,MAAM;MAAEC,QAAQ;MAAEC;IAAG,CAAC,GAAGH,MAAM;IAE/B,MAAM;MAAEG,EAAE,EAAEC;IAAQ,CAAC,GAAGZ,eAAe,CAACW,EAAE,CAAC;IAC3C,MAAME,QAAQ,GAAG,IAAI,CAACR,eAAe,CAACS,WAAW,CAAC,CAAC;IAEnD,MAAM,IAAI,CAACR,gBAAgB,CAACS,IAAI,CAC5B;MAAEJ,EAAE,EAAED,QAAQ,CAACC;IAAG,CAAC,EACnB;MACIK,MAAM,EAAE,+BAA+BJ,OAAO,EAAE;MAChDK,IAAI,EAAE;QACFT,MAAM,EAAEA,MAAM,CAACU,QAAQ,CAAC,CAAC;QACzBC,IAAI,EAAEN;MACV;IACJ,CACJ,CAAC;IAED,OAAOhB,MAAM,CAACY,EAAE,CAAC,CAAC;EACtB;AACJ;AAEA,OAAO,MAAMR,yBAAyB,GAAGC,kBAAkB,CAACkB,oBAAoB,CAAC;EAC7EC,cAAc,EAAElB,6BAA6B;EAC7CmB,YAAY,EAAE,CAACxB,eAAe,EAAE,CAACC,gBAAgB,EAAE;IAAEwB,QAAQ,EAAE;EAAK,CAAC,CAAC;AAC1E,CAAC,CAAC","ignoreList":[]}
|
|
@@ -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,5 +1,5 @@
|
|
|
1
1
|
import { ListLockRecordsRepository, ListLockRecordsUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
2
|
-
import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
|
|
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
5
|
constructor(repository, identityContext, config) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ListLockRecordsRepository","ListLockRecordsUseCase","UseCaseAbstraction","IdentityContext","RecordLockingConfig","ListLockRecordsUseCaseImpl","constructor","repository","identityContext","config","execute","input","identity","getIdentity","enhancedInput","where","createdBy_not","id","savedOn_gte","Date","getTime","timeout","toISOString","createImplementation","implementation","dependencies"],"sources":["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/IdentityContext\";\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"],"mappings":"AACA,SAGIA,yBAAyB,EACzBC,sBAAsB,IAAIC,kBAAkB;AAEhD,SAASC,eAAe,QAAQ,
|
|
1
|
+
{"version":3,"names":["ListLockRecordsRepository","ListLockRecordsUseCase","UseCaseAbstraction","IdentityContext","RecordLockingConfig","ListLockRecordsUseCaseImpl","constructor","repository","identityContext","config","execute","input","identity","getIdentity","enhancedInput","where","createdBy_not","id","savedOn_gte","Date","getTime","timeout","toISOString","createImplementation","implementation","dependencies"],"sources":["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"],"mappings":"AACA,SAGIA,yBAAyB,EACzBC,sBAAsB,IAAIC,kBAAkB;AAEhD,SAASC,eAAe,QAAQ,6DAA6D;AAC7F,SAASC,mBAAmB;AAE5B,MAAMC,0BAA0B,CAAyC;EACrEC,WAAWA,CACCC,UAA+C,EAC/CC,eAA0C,EAC1CC,MAAqC,EAC/C;IAAA,KAHUF,UAA+C,GAA/CA,UAA+C;IAAA,KAC/CC,eAA0C,GAA1CA,eAA0C;IAAA,KAC1CC,MAAqC,GAArCA,MAAqC;EAC9C;EAEH,MAAMC,OAAOA,CACTC,KAA4B,EACoC;IAChE,MAAMC,QAAQ,GAAG,IAAI,CAACJ,eAAe,CAACK,WAAW,CAAC,CAAC;;IAEnD;IACA,MAAMC,aAAmC,GAAG;MACxC,GAAGH,KAAK;MACRI,KAAK,EAAE;QACH,GAAGJ,KAAK,EAAEI,KAAK;QACfC,aAAa,EAAEJ,QAAQ,CAACK,EAAE;QAC1BC,WAAW,EAAE,IAAIC,IAAI,CAAC,IAAIA,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC,GAAG,IAAI,CAACX,MAAM,CAACY,OAAO,CAAC,CAACC,WAAW,CAAC;MAClF;IACJ,CAAC;IAED,OAAO,MAAM,IAAI,CAACf,UAAU,CAACG,OAAO,CAACI,aAAa,CAAC;EACvD;AACJ;AAEA,OAAO,MAAMb,sBAAsB,GAAGC,kBAAkB,CAACqB,oBAAoB,CAAC;EAC1EC,cAAc,EAAEnB,0BAA0B;EAC1CoB,YAAY,EAAE,CAACzB,yBAAyB,EAAEG,eAAe,EAAEC,mBAAmB;AAClF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createAbstraction","ListLockRecordsUseCase","ListLockRecordsRepository"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction, 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\";\nimport type {\n DateStringInterfaceGenerator,\n IdentityInterfaceGenerator,\n IdInterfaceGenerator\n} from \"@webiny/api\";\n\n// Input/Output types\nexport interface IListLockRecordsWhere\n extends
|
|
1
|
+
{"version":3,"names":["createAbstraction","ListLockRecordsUseCase","ListLockRecordsRepository"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction, 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\";\nimport type {\n DateStringInterfaceGenerator,\n IdentityInterfaceGenerator,\n IdInterfaceGenerator\n} from \"@webiny/api\";\n\n// Input/Output types\nexport interface IListLockRecordsWhere\n extends\n IdInterfaceGenerator<\"id\">,\n IdentityInterfaceGenerator<\"lockedBy\">,\n IdentityInterfaceGenerator<\"createdBy\">,\n DateStringInterfaceGenerator<\"lockedOn\">,\n DateStringInterfaceGenerator<\"updatedOn\">,\n DateStringInterfaceGenerator<\"savedOn\">,\n DateStringInterfaceGenerator<\"expiresOn\"> {}\n\nexport interface ListLockRecordsInput extends Pick<CmsEntryListParams, \"limit\" | \"sort\" | \"after\"> {\n where?: IListLockRecordsWhere;\n}\n\nexport interface ListLockRecordsOutput {\n items: ILockRecord[];\n meta: CmsEntryMeta;\n}\n\n/**\n * ListLockRecords Use Case - Lists active lock records (filters out expired, excludes current user)\n */\nexport interface IListLockRecordsUseCase {\n execute(input?: ListLockRecordsInput): Promise<Result<ListLockRecordsOutput, UseCaseError>>;\n}\n\nexport interface IListLockRecordsUseCaseErrors {\n persistence: LockRecordPersistenceError;\n}\n\ntype UseCaseError = IListLockRecordsUseCaseErrors[keyof IListLockRecordsUseCaseErrors];\n\nexport const ListLockRecordsUseCase =\n createAbstraction<IListLockRecordsUseCase>(\"ListLockRecordsUseCase\");\n\nexport namespace ListLockRecordsUseCase {\n export type Interface = IListLockRecordsUseCase;\n export type Error = UseCaseError;\n}\n\n/**\n * ListLockRecordsRepository - Fetches lock records from storage with filtering\n */\nexport interface IListLockRecordsRepository {\n execute(input?: ListLockRecordsInput): Promise<Result<ListLockRecordsOutput, RepositoryError>>;\n}\n\nexport interface IListLockRecordsRepositoryErrors {\n persistence: LockRecordPersistenceError;\n}\n\ntype RepositoryError = IListLockRecordsRepositoryErrors[keyof IListLockRecordsRepositoryErrors];\n\nexport const ListLockRecordsRepository = createAbstraction<IListLockRecordsRepository>(\n \"ListLockRecordsRepository\"\n);\n\nexport namespace ListLockRecordsRepository {\n export type Interface = IListLockRecordsRepository;\n export type Error = RepositoryError;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAgB,qBAAqB;;AAU/D;;AAoBA;AACA;AACA;;AAWA,OAAO,MAAMC,sBAAsB,GAC/BD,iBAAiB,CAA0B,wBAAwB,CAAC;;AAOxE;AACA;AACA;;AAWA,OAAO,MAAME,yBAAyB,GAAGF,iBAAiB,CACtD,2BACJ,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type LockEntryInput, LockEntryUseCase as UseCaseAbstraction, LockEntryUseCase } from "./abstractions.js";
|
|
2
|
-
import { EventPublisher } from "@webiny/api-core/features/
|
|
2
|
+
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
3
|
import type { ILockRecord } from "../../domain/index.js";
|
|
4
4
|
import { Result } from "@webiny/feature/api/index.js";
|
|
5
5
|
declare class LockEntryErrorDecoratorImpl implements LockEntryUseCase.Interface {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LockEntryUseCase } from "./abstractions.js";
|
|
2
|
-
import { EventPublisher } from "@webiny/api-core/features/
|
|
2
|
+
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
3
|
import { EntryAfterLockEvent, EntryBeforeLockEvent, EntryLockErrorEvent } from "./events.js";
|
|
4
4
|
class LockEntryErrorDecoratorImpl {
|
|
5
5
|
constructor(eventPublisher, decoratee) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LockEntryUseCase","EventPublisher","EntryAfterLockEvent","EntryBeforeLockEvent","EntryLockErrorEvent","LockEntryErrorDecoratorImpl","constructor","eventPublisher","decoratee","execute","input","publish","id","type","result","isFail","error","record","value","LockEntryEventsDecorator","createDecorator","decorator","dependencies"],"sources":["LockEntryEventsDecorator.ts"],"sourcesContent":["import {\n type LockEntryInput,\n LockEntryUseCase as UseCaseAbstraction,\n LockEntryUseCase\n} from \"./abstractions.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/
|
|
1
|
+
{"version":3,"names":["LockEntryUseCase","EventPublisher","EntryAfterLockEvent","EntryBeforeLockEvent","EntryLockErrorEvent","LockEntryErrorDecoratorImpl","constructor","eventPublisher","decoratee","execute","input","publish","id","type","result","isFail","error","record","value","LockEntryEventsDecorator","createDecorator","decorator","dependencies"],"sources":["LockEntryEventsDecorator.ts"],"sourcesContent":["import {\n type LockEntryInput,\n LockEntryUseCase as UseCaseAbstraction,\n LockEntryUseCase\n} from \"./abstractions.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { ILockRecord } from \"~/domain/index.js\";\nimport { Result } from \"@webiny/feature/api/index.js\";\nimport { EntryAfterLockEvent, EntryBeforeLockEvent, EntryLockErrorEvent } from \"./events.js\";\n\nclass LockEntryErrorDecoratorImpl implements LockEntryUseCase.Interface {\n constructor(\n private readonly eventPublisher: EventPublisher.Interface,\n private readonly decoratee: LockEntryUseCase.Interface\n ) {}\n async execute(input: LockEntryInput): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Publish before event\n await this.eventPublisher.publish(\n new EntryBeforeLockEvent({\n id: input.id,\n type: input.type\n })\n );\n\n const result = await this.decoratee.execute(input);\n\n if (result.isFail()) {\n const error = result.error;\n\n await this.eventPublisher.publish(\n new EntryLockErrorEvent({\n id: input.id,\n type: input.type,\n error\n })\n );\n\n return result;\n }\n\n // Publish after event\n await this.eventPublisher.publish(\n new EntryAfterLockEvent({\n id: input.id,\n type: input.type,\n record: result.value\n })\n );\n\n return result;\n }\n}\n\nexport const LockEntryEventsDecorator = LockEntryUseCase.createDecorator({\n decorator: LockEntryErrorDecoratorImpl,\n dependencies: [EventPublisher]\n});\n"],"mappings":"AAAA,SAGIA,gBAAgB;AAEpB,SAASC,cAAc,QAAQ,mDAAmD;AAGlF,SAASC,mBAAmB,EAAEC,oBAAoB,EAAEC,mBAAmB;AAEvE,MAAMC,2BAA2B,CAAuC;EACpEC,WAAWA,CACUC,cAAwC,EACxCC,SAAqC,EACxD;IAAA,KAFmBD,cAAwC,GAAxCA,cAAwC;IAAA,KACxCC,SAAqC,GAArCA,SAAqC;EACvD;EACH,MAAMC,OAAOA,CAACC,KAAqB,EAA0D;IACzF;IACA,MAAM,IAAI,CAACH,cAAc,CAACI,OAAO,CAC7B,IAAIR,oBAAoB,CAAC;MACrBS,EAAE,EAAEF,KAAK,CAACE,EAAE;MACZC,IAAI,EAAEH,KAAK,CAACG;IAChB,CAAC,CACL,CAAC;IAED,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACN,SAAS,CAACC,OAAO,CAACC,KAAK,CAAC;IAElD,IAAII,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;MACjB,MAAMC,KAAK,GAAGF,MAAM,CAACE,KAAK;MAE1B,MAAM,IAAI,CAACT,cAAc,CAACI,OAAO,CAC7B,IAAIP,mBAAmB,CAAC;QACpBQ,EAAE,EAAEF,KAAK,CAACE,EAAE;QACZC,IAAI,EAAEH,KAAK,CAACG,IAAI;QAChBG;MACJ,CAAC,CACL,CAAC;MAED,OAAOF,MAAM;IACjB;;IAEA;IACA,MAAM,IAAI,CAACP,cAAc,CAACI,OAAO,CAC7B,IAAIT,mBAAmB,CAAC;MACpBU,EAAE,EAAEF,KAAK,CAACE,EAAE;MACZC,IAAI,EAAEH,KAAK,CAACG,IAAI;MAChBI,MAAM,EAAEH,MAAM,CAACI;IACnB,CAAC,CACL,CAAC;IAED,OAAOJ,MAAM;EACjB;AACJ;AAEA,OAAO,MAAMK,wBAAwB,GAAGnB,gBAAgB,CAACoB,eAAe,CAAC;EACrEC,SAAS,EAAEhB,2BAA2B;EACtCiB,YAAY,EAAE,CAACrB,cAAc;AACjC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DomainEvent } from "@webiny/api-core/features/
|
|
2
|
-
import type { IEventHandler } from "@webiny/api-core/features/
|
|
1
|
+
import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
2
|
+
import type { IEventHandler } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
3
|
import type { ILockRecord } from "../../domain/LockRecord.js";
|
|
4
4
|
import type { LockRecordEntryType } from "../../domain/types.js";
|
|
5
5
|
export interface EntryBeforeLockPayload {
|
|
@@ -10,8 +10,8 @@ export declare class EntryBeforeLockEvent extends DomainEvent<EntryBeforeLockPay
|
|
|
10
10
|
eventType: "RecordLocking/Entry/BeforeLock";
|
|
11
11
|
getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryBeforeLockEvent>>;
|
|
12
12
|
}
|
|
13
|
-
export declare const
|
|
14
|
-
export declare namespace
|
|
13
|
+
export declare const EntryBeforeLockEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryBeforeLockEvent>>;
|
|
14
|
+
export declare namespace EntryBeforeLockEventHandler {
|
|
15
15
|
type Interface = IEventHandler<EntryBeforeLockEvent>;
|
|
16
16
|
type Event = EntryBeforeLockEvent;
|
|
17
17
|
}
|
|
@@ -24,8 +24,8 @@ export declare class EntryAfterLockEvent extends DomainEvent<EntryAfterLockPaylo
|
|
|
24
24
|
eventType: "RecordLocking/Entry/AfterLock";
|
|
25
25
|
getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryAfterLockEvent>>;
|
|
26
26
|
}
|
|
27
|
-
export declare const
|
|
28
|
-
export declare namespace
|
|
27
|
+
export declare const EntryAfterLockEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryAfterLockEvent>>;
|
|
28
|
+
export declare namespace EntryAfterLockEventHandler {
|
|
29
29
|
type Interface = IEventHandler<EntryAfterLockEvent>;
|
|
30
30
|
type Event = EntryAfterLockEvent;
|
|
31
31
|
}
|
|
@@ -38,8 +38,8 @@ export declare class EntryLockErrorEvent extends DomainEvent<EntryLockErrorPaylo
|
|
|
38
38
|
eventType: "RecordLocking/Entry/LockError";
|
|
39
39
|
getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryLockErrorEvent>>;
|
|
40
40
|
}
|
|
41
|
-
export declare const
|
|
42
|
-
export declare namespace
|
|
41
|
+
export declare const EntryLockErrorEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryLockErrorEvent>>;
|
|
42
|
+
export declare namespace EntryLockErrorEventHandler {
|
|
43
43
|
type Interface = IEventHandler<EntryLockErrorEvent>;
|
|
44
44
|
type Event = EntryLockErrorEvent;
|
|
45
45
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
import { DomainEvent } from "@webiny/api-core/features/
|
|
2
|
+
import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
3
|
|
|
4
4
|
// ============================================================================
|
|
5
5
|
// EntryBeforeLock Event
|
|
@@ -8,10 +8,10 @@ import { DomainEvent } from "@webiny/api-core/features/EventPublisher";
|
|
|
8
8
|
export class EntryBeforeLockEvent extends DomainEvent {
|
|
9
9
|
eventType = "RecordLocking/Entry/BeforeLock";
|
|
10
10
|
getHandlerAbstraction() {
|
|
11
|
-
return
|
|
11
|
+
return EntryBeforeLockEventHandler;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
export const
|
|
14
|
+
export const EntryBeforeLockEventHandler = createAbstraction("EntryBeforeLockEventHandler");
|
|
15
15
|
|
|
16
16
|
// ============================================================================
|
|
17
17
|
// EntryAfterLock Event
|
|
@@ -20,10 +20,10 @@ export const EntryBeforeLockHandler = createAbstraction("EntryBeforeLockHandler"
|
|
|
20
20
|
export class EntryAfterLockEvent extends DomainEvent {
|
|
21
21
|
eventType = "RecordLocking/Entry/AfterLock";
|
|
22
22
|
getHandlerAbstraction() {
|
|
23
|
-
return
|
|
23
|
+
return EntryAfterLockEventHandler;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
export const
|
|
26
|
+
export const EntryAfterLockEventHandler = createAbstraction("EntryAfterLockEventHandler");
|
|
27
27
|
|
|
28
28
|
// ============================================================================
|
|
29
29
|
// EntryLockError Event
|
|
@@ -32,9 +32,9 @@ export const EntryAfterLockHandler = createAbstraction("EntryAfterLockHandler");
|
|
|
32
32
|
export class EntryLockErrorEvent extends DomainEvent {
|
|
33
33
|
eventType = "RecordLocking/Entry/LockError";
|
|
34
34
|
getHandlerAbstraction() {
|
|
35
|
-
return
|
|
35
|
+
return EntryLockErrorEventHandler;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
export const
|
|
38
|
+
export const EntryLockErrorEventHandler = createAbstraction("EntryLockErrorEventHandler");
|
|
39
39
|
|
|
40
40
|
//# sourceMappingURL=events.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createAbstraction","DomainEvent","EntryBeforeLockEvent","eventType","getHandlerAbstraction","
|
|
1
|
+
{"version":3,"names":["createAbstraction","DomainEvent","EntryBeforeLockEvent","eventType","getHandlerAbstraction","EntryBeforeLockEventHandler","EntryAfterLockEvent","EntryAfterLockEventHandler","EntryLockErrorEvent","EntryLockErrorEventHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { IEventHandler } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordEntryType } from \"~/domain/types.js\";\n\n// ============================================================================\n// EntryBeforeLock Event\n// ============================================================================\n\nexport interface EntryBeforeLockPayload {\n id: string;\n type: LockRecordEntryType;\n}\n\nexport class EntryBeforeLockEvent extends DomainEvent<EntryBeforeLockPayload> {\n eventType = \"RecordLocking/Entry/BeforeLock\" as const;\n\n getHandlerAbstraction() {\n return EntryBeforeLockEventHandler;\n }\n}\n\nexport const EntryBeforeLockEventHandler = createAbstraction<IEventHandler<EntryBeforeLockEvent>>(\n \"EntryBeforeLockEventHandler\"\n);\n\nexport namespace EntryBeforeLockEventHandler {\n export type Interface = IEventHandler<EntryBeforeLockEvent>;\n export type Event = EntryBeforeLockEvent;\n}\n\n// ============================================================================\n// EntryAfterLock Event\n// ============================================================================\n\nexport interface EntryAfterLockPayload {\n id: string;\n type: LockRecordEntryType;\n record: ILockRecord;\n}\n\nexport class EntryAfterLockEvent extends DomainEvent<EntryAfterLockPayload> {\n eventType = \"RecordLocking/Entry/AfterLock\" as const;\n\n getHandlerAbstraction() {\n return EntryAfterLockEventHandler;\n }\n}\n\nexport const EntryAfterLockEventHandler = createAbstraction<IEventHandler<EntryAfterLockEvent>>(\n \"EntryAfterLockEventHandler\"\n);\n\nexport namespace EntryAfterLockEventHandler {\n export type Interface = IEventHandler<EntryAfterLockEvent>;\n export type Event = EntryAfterLockEvent;\n}\n\n// ============================================================================\n// EntryLockError Event\n// ============================================================================\n\nexport interface EntryLockErrorPayload {\n id: string;\n type: LockRecordEntryType;\n error: Error;\n}\n\nexport class EntryLockErrorEvent extends DomainEvent<EntryLockErrorPayload> {\n eventType = \"RecordLocking/Entry/LockError\" as const;\n\n getHandlerAbstraction() {\n return EntryLockErrorEventHandler;\n }\n}\n\nexport const EntryLockErrorEventHandler = createAbstraction<IEventHandler<EntryLockErrorEvent>>(\n \"EntryLockErrorEventHandler\"\n);\n\nexport namespace EntryLockErrorEventHandler {\n export type Interface = IEventHandler<EntryLockErrorEvent>;\n export type Event = EntryLockErrorEvent;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW,QAAQ,mDAAmD;;AAK/E;AACA;AACA;;AAOA,OAAO,MAAMC,oBAAoB,SAASD,WAAW,CAAyB;EAC1EE,SAAS,GAAG,gCAAgC;EAE5CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,2BAA2B;EACtC;AACJ;AAEA,OAAO,MAAMA,2BAA2B,GAAGL,iBAAiB,CACxD,6BACJ,CAAC;;AAOD;AACA;AACA;;AAQA,OAAO,MAAMM,mBAAmB,SAASL,WAAW,CAAwB;EACxEE,SAAS,GAAG,+BAA+B;EAE3CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,0BAA0B;EACrC;AACJ;AAEA,OAAO,MAAMA,0BAA0B,GAAGP,iBAAiB,CACvD,4BACJ,CAAC;;AAOD;AACA;AACA;;AAQA,OAAO,MAAMQ,mBAAmB,SAASP,WAAW,CAAwB;EACxEE,SAAS,GAAG,+BAA+B;EAE3CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOK,0BAA0B;EACrC;AACJ;AAEA,OAAO,MAAMA,0BAA0B,GAAGT,iBAAiB,CACvD,4BACJ,CAAC","ignoreList":[]}
|
|
@@ -9,4 +9,7 @@ export interface RecordLockingParams {
|
|
|
9
9
|
*/
|
|
10
10
|
model: CmsModel;
|
|
11
11
|
}
|
|
12
|
-
export declare const RecordLockingFeature:
|
|
12
|
+
export declare const RecordLockingFeature: {
|
|
13
|
+
name: string;
|
|
14
|
+
register(container: import("@webiny/di").Container, context: RecordLockingParams): void;
|
|
15
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createFeature","RecordLockingConfig","RecordLockingModel","GetLockRecordFeature","GetLockedEntryLockRecordFeature","KickOutCurrentUserFeature","ListLockRecordsFeature","ListAllLockRecordsFeature","IsEntryLockedFeature","LockEntryFeature","UpdateEntryLockFeature","UnlockEntryFeature","UnlockEntryRequestFeature","RecordLockingFeature","name","register","container","params","registerInstance","timeout","model"],"sources":["RecordLockingFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { RecordLockingConfig, RecordLockingModel } from \"~/domain/abstractions.js\";\nimport { GetLockRecordFeature } from \"./GetLockRecord/feature.js\";\nimport { GetLockedEntryLockRecordFeature } from \"./GetLockedEntryLockRecord/feature.js\";\nimport { KickOutCurrentUserFeature } from \"./KickOutCurrentUser/feature.js\";\nimport { ListLockRecordsFeature } from \"./ListLockRecords/feature.js\";\nimport { ListAllLockRecordsFeature } from \"./ListAllLockRecords/feature.js\";\nimport { IsEntryLockedFeature } from \"./IsEntryLocked/feature.js\";\nimport { LockEntryFeature } from \"./LockEntry/feature.js\";\nimport { UpdateEntryLockFeature } from \"./UpdateEntryLock/feature.js\";\nimport { UnlockEntryFeature } from \"./UnlockEntry/feature.js\";\nimport { UnlockEntryRequestFeature } from \"./UnlockEntryRequest/feature.js\";\n\nexport interface RecordLockingParams {\n /**\n * Timeout in milliseconds after which a lock expires\n */\n timeout: number;\n /**\n * The CMS model for storing lock records\n */\n model: CmsModel;\n}\n\nexport const RecordLockingFeature = createFeature({\n name: \"RecordLockingManagement\",\n register(container, params
|
|
1
|
+
{"version":3,"names":["createFeature","RecordLockingConfig","RecordLockingModel","GetLockRecordFeature","GetLockedEntryLockRecordFeature","KickOutCurrentUserFeature","ListLockRecordsFeature","ListAllLockRecordsFeature","IsEntryLockedFeature","LockEntryFeature","UpdateEntryLockFeature","UnlockEntryFeature","UnlockEntryRequestFeature","RecordLockingFeature","name","register","container","params","registerInstance","timeout","model"],"sources":["RecordLockingFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { RecordLockingConfig, RecordLockingModel } from \"~/domain/abstractions.js\";\nimport { GetLockRecordFeature } from \"./GetLockRecord/feature.js\";\nimport { GetLockedEntryLockRecordFeature } from \"./GetLockedEntryLockRecord/feature.js\";\nimport { KickOutCurrentUserFeature } from \"./KickOutCurrentUser/feature.js\";\nimport { ListLockRecordsFeature } from \"./ListLockRecords/feature.js\";\nimport { ListAllLockRecordsFeature } from \"./ListAllLockRecords/feature.js\";\nimport { IsEntryLockedFeature } from \"./IsEntryLocked/feature.js\";\nimport { LockEntryFeature } from \"./LockEntry/feature.js\";\nimport { UpdateEntryLockFeature } from \"./UpdateEntryLock/feature.js\";\nimport { UnlockEntryFeature } from \"./UnlockEntry/feature.js\";\nimport { UnlockEntryRequestFeature } from \"./UnlockEntryRequest/feature.js\";\n\nexport interface RecordLockingParams {\n /**\n * Timeout in milliseconds after which a lock expires\n */\n timeout: number;\n /**\n * The CMS model for storing lock records\n */\n model: CmsModel;\n}\n\nexport const RecordLockingFeature = createFeature<RecordLockingParams>({\n name: \"RecordLockingManagement\",\n register(container, params) {\n // Register domain abstractions\n container.registerInstance(RecordLockingConfig, { timeout: params.timeout });\n container.registerInstance(RecordLockingModel, params.model);\n\n // Register all sub-features\n GetLockRecordFeature.register(container);\n GetLockedEntryLockRecordFeature.register(container);\n KickOutCurrentUserFeature.register(container);\n ListLockRecordsFeature.register(container);\n ListAllLockRecordsFeature.register(container);\n IsEntryLockedFeature.register(container);\n LockEntryFeature.register(container);\n UpdateEntryLockFeature.register(container);\n UnlockEntryFeature.register(container);\n UnlockEntryRequestFeature.register(container);\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AAEnD,SAASC,mBAAmB,EAAEC,kBAAkB;AAChD,SAASC,oBAAoB;AAC7B,SAASC,+BAA+B;AACxC,SAASC,yBAAyB;AAClC,SAASC,sBAAsB;AAC/B,SAASC,yBAAyB;AAClC,SAASC,oBAAoB;AAC7B,SAASC,gBAAgB;AACzB,SAASC,sBAAsB;AAC/B,SAASC,kBAAkB;AAC3B,SAASC,yBAAyB;AAalC,OAAO,MAAMC,oBAAoB,GAAGb,aAAa,CAAsB;EACnEc,IAAI,EAAE,yBAAyB;EAC/BC,QAAQA,CAACC,SAAS,EAAEC,MAAM,EAAE;IACxB;IACAD,SAAS,CAACE,gBAAgB,CAACjB,mBAAmB,EAAE;MAAEkB,OAAO,EAAEF,MAAM,CAACE;IAAQ,CAAC,CAAC;IAC5EH,SAAS,CAACE,gBAAgB,CAAChB,kBAAkB,EAAEe,MAAM,CAACG,KAAK,CAAC;;IAE5D;IACAjB,oBAAoB,CAACY,QAAQ,CAACC,SAAS,CAAC;IACxCZ,+BAA+B,CAACW,QAAQ,CAACC,SAAS,CAAC;IACnDX,yBAAyB,CAACU,QAAQ,CAACC,SAAS,CAAC;IAC7CV,sBAAsB,CAACS,QAAQ,CAACC,SAAS,CAAC;IAC1CT,yBAAyB,CAACQ,QAAQ,CAACC,SAAS,CAAC;IAC7CR,oBAAoB,CAACO,QAAQ,CAACC,SAAS,CAAC;IACxCP,gBAAgB,CAACM,QAAQ,CAACC,SAAS,CAAC;IACpCN,sBAAsB,CAACK,QAAQ,CAACC,SAAS,CAAC;IAC1CL,kBAAkB,CAACI,QAAQ,CAACC,SAAS,CAAC;IACtCJ,yBAAyB,CAACG,QAAQ,CAACC,SAAS,CAAC;EACjD;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type UnlockEntryInput, UnlockEntryUseCase as UseCaseAbstraction, UnlockEntryUseCase } from "./abstractions.js";
|
|
2
|
-
import { EventPublisher } from "@webiny/api-core/features/
|
|
2
|
+
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
3
|
import type { ILockRecord } from "../../domain/index.js";
|
|
4
4
|
import { Result } from "@webiny/feature/api/index.js";
|
|
5
5
|
declare class UnlockEntryEventsDecoratorImpl implements UnlockEntryUseCase.Interface {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UnlockEntryUseCase } from "./abstractions.js";
|
|
2
|
-
import { EventPublisher } from "@webiny/api-core/features/
|
|
2
|
+
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
3
|
import { EntryAfterUnlockEvent, EntryBeforeUnlockEvent, EntryUnlockErrorEvent } from "./events.js";
|
|
4
4
|
class UnlockEntryEventsDecoratorImpl {
|
|
5
5
|
constructor(eventPublisher, decoratee) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["UnlockEntryUseCase","EventPublisher","EntryAfterUnlockEvent","EntryBeforeUnlockEvent","EntryUnlockErrorEvent","UnlockEntryEventsDecoratorImpl","constructor","eventPublisher","decoratee","execute","input","publish","id","type","force","result","isFail","error","record","value","UnlockEntryEventsDecorator","createDecorator","decorator","dependencies"],"sources":["UnlockEntryEventsDecorator.ts"],"sourcesContent":["import {\n type UnlockEntryInput,\n UnlockEntryUseCase as UseCaseAbstraction,\n UnlockEntryUseCase\n} from \"./abstractions.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/
|
|
1
|
+
{"version":3,"names":["UnlockEntryUseCase","EventPublisher","EntryAfterUnlockEvent","EntryBeforeUnlockEvent","EntryUnlockErrorEvent","UnlockEntryEventsDecoratorImpl","constructor","eventPublisher","decoratee","execute","input","publish","id","type","force","result","isFail","error","record","value","UnlockEntryEventsDecorator","createDecorator","decorator","dependencies"],"sources":["UnlockEntryEventsDecorator.ts"],"sourcesContent":["import {\n type UnlockEntryInput,\n UnlockEntryUseCase as UseCaseAbstraction,\n UnlockEntryUseCase\n} from \"./abstractions.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/eventPublisher/index.js\";\nimport type { ILockRecord } from \"~/domain/index.js\";\nimport { Result } from \"@webiny/feature/api/index.js\";\nimport { EntryAfterUnlockEvent, EntryBeforeUnlockEvent, EntryUnlockErrorEvent } from \"./events.js\";\n\nclass UnlockEntryEventsDecoratorImpl implements UnlockEntryUseCase.Interface {\n constructor(\n private readonly eventPublisher: EventPublisher.Interface,\n private readonly decoratee: UnlockEntryUseCase.Interface\n ) {}\n\n async execute(input: UnlockEntryInput): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Publish before event\n await this.eventPublisher.publish(\n new EntryBeforeUnlockEvent({\n id: input.id,\n type: input.type,\n force: input.force\n })\n );\n\n const result = await this.decoratee.execute(input);\n\n if (result.isFail()) {\n const error = result.error;\n\n await this.eventPublisher.publish(\n new EntryUnlockErrorEvent({\n id: input.id,\n type: input.type,\n error\n })\n );\n\n return result;\n }\n\n // Publish after event\n await this.eventPublisher.publish(\n new EntryAfterUnlockEvent({\n id: input.id,\n type: input.type,\n record: result.value\n })\n );\n\n return result;\n }\n}\n\nexport const UnlockEntryEventsDecorator = UnlockEntryUseCase.createDecorator({\n decorator: UnlockEntryEventsDecoratorImpl,\n dependencies: [EventPublisher]\n});\n"],"mappings":"AAAA,SAGIA,kBAAkB;AAEtB,SAASC,cAAc,QAAQ,mDAAmD;AAGlF,SAASC,qBAAqB,EAAEC,sBAAsB,EAAEC,qBAAqB;AAE7E,MAAMC,8BAA8B,CAAyC;EACzEC,WAAWA,CACUC,cAAwC,EACxCC,SAAuC,EAC1D;IAAA,KAFmBD,cAAwC,GAAxCA,cAAwC;IAAA,KACxCC,SAAuC,GAAvCA,SAAuC;EACzD;EAEH,MAAMC,OAAOA,CAACC,KAAuB,EAA0D;IAC3F;IACA,MAAM,IAAI,CAACH,cAAc,CAACI,OAAO,CAC7B,IAAIR,sBAAsB,CAAC;MACvBS,EAAE,EAAEF,KAAK,CAACE,EAAE;MACZC,IAAI,EAAEH,KAAK,CAACG,IAAI;MAChBC,KAAK,EAAEJ,KAAK,CAACI;IACjB,CAAC,CACL,CAAC;IAED,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACP,SAAS,CAACC,OAAO,CAACC,KAAK,CAAC;IAElD,IAAIK,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;MACjB,MAAMC,KAAK,GAAGF,MAAM,CAACE,KAAK;MAE1B,MAAM,IAAI,CAACV,cAAc,CAACI,OAAO,CAC7B,IAAIP,qBAAqB,CAAC;QACtBQ,EAAE,EAAEF,KAAK,CAACE,EAAE;QACZC,IAAI,EAAEH,KAAK,CAACG,IAAI;QAChBI;MACJ,CAAC,CACL,CAAC;MAED,OAAOF,MAAM;IACjB;;IAEA;IACA,MAAM,IAAI,CAACR,cAAc,CAACI,OAAO,CAC7B,IAAIT,qBAAqB,CAAC;MACtBU,EAAE,EAAEF,KAAK,CAACE,EAAE;MACZC,IAAI,EAAEH,KAAK,CAACG,IAAI;MAChBK,MAAM,EAAEH,MAAM,CAACI;IACnB,CAAC,CACL,CAAC;IAED,OAAOJ,MAAM;EACjB;AACJ;AAEA,OAAO,MAAMK,0BAA0B,GAAGpB,kBAAkB,CAACqB,eAAe,CAAC;EACzEC,SAAS,EAAEjB,8BAA8B;EACzCkB,YAAY,EAAE,CAACtB,cAAc;AACjC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@ import { Result } from "@webiny/feature/api";
|
|
|
2
2
|
import { UnlockEntryUseCase as UseCaseAbstraction, UnlockEntryRepository, UnlockEntryInput } from "./abstractions.js";
|
|
3
3
|
import { GetLockRecordUseCase } from "../GetLockRecord/abstractions.js";
|
|
4
4
|
import { KickOutCurrentUserUseCase } from "../KickOutCurrentUser/abstractions.js";
|
|
5
|
-
import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
|
|
5
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
6
6
|
import type { ILockRecord } from "../../domain/LockRecord.js";
|
|
7
7
|
declare class UnlockEntryUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
8
8
|
private getLockRecord;
|
|
@@ -2,7 +2,7 @@ import { Result } from "@webiny/feature/api";
|
|
|
2
2
|
import { UnlockEntryUseCase as UseCaseAbstraction, UnlockEntryRepository } from "./abstractions.js";
|
|
3
3
|
import { GetLockRecordUseCase } from "../GetLockRecord/abstractions.js";
|
|
4
4
|
import { KickOutCurrentUserUseCase } from "../KickOutCurrentUser/abstractions.js";
|
|
5
|
-
import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
|
|
5
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
6
6
|
import { LockRecordNotFoundError, IdentityMismatchError } from "../../domain/errors.js";
|
|
7
7
|
import { hasFullAccessPermission } from "./hasFullAccessPermission.js";
|
|
8
8
|
class UnlockEntryUseCaseImpl {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Result","UnlockEntryUseCase","UseCaseAbstraction","UnlockEntryRepository","GetLockRecordUseCase","KickOutCurrentUserUseCase","IdentityContext","LockRecordNotFoundError","IdentityMismatchError","hasFullAccessPermission","UnlockEntryUseCaseImpl","constructor","getLockRecord","kickOutCurrentUser","repository","identityContext","execute","input","recordResult","isFail","error","delete","id","fail","record","value","isExpired","identity","getIdentity","isSameUser","lockedBy","shouldKickOut","force","currentId","targetId","hasAccess","deleteResult","ok","createImplementation","implementation","dependencies"],"sources":["UnlockEntryUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n UnlockEntryUseCase as UseCaseAbstraction,\n UnlockEntryRepository,\n UnlockEntryInput\n} from \"./abstractions.js\";\nimport { GetLockRecordUseCase } from \"../GetLockRecord/abstractions.js\";\nimport { KickOutCurrentUserUseCase } from \"../KickOutCurrentUser/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/IdentityContext\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport { LockRecordNotFoundError, IdentityMismatchError } from \"~/domain/errors.js\";\nimport { hasFullAccessPermission } from \"./hasFullAccessPermission.js\";\n\nclass UnlockEntryUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getLockRecord: GetLockRecordUseCase.Interface,\n private kickOutCurrentUser: KickOutCurrentUserUseCase.Interface,\n private repository: UnlockEntryRepository.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute(input: UnlockEntryInput): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Get the lock record\n const recordResult = await this.getLockRecord.execute(input);\n\n // If not found or expired, attempt cleanup and return error\n if (recordResult.isFail()) {\n if (recordResult.error instanceof LockRecordNotFoundError) {\n // Try to cleanup any stale data\n await this.repository.delete(input.id);\n }\n\n return Result.fail(recordResult.error);\n }\n\n const record = recordResult.value;\n\n // If expired, cleanup and return error\n if (record.isExpired()) {\n await this.repository.delete(record.id);\n const error = new LockRecordNotFoundError();\n return Result.fail(error);\n }\n\n // Check if user is the owner\n const identity = this.identityContext.getIdentity();\n const isSameUser = record.lockedBy.id === identity.id;\n\n let shouldKickOut = false;\n\n // If not the owner, check if force unlock is allowed\n if (!isSameUser) {\n if (!input.force) {\n const error = new IdentityMismatchError({\n currentId: identity.id,\n targetId: record.lockedBy.id\n });\n return Result.fail(error);\n }\n\n // Check if user has permission to force unlock\n const hasAccess = await hasFullAccessPermission(this.identityContext);\n if (!hasAccess) {\n const error = new IdentityMismatchError({\n currentId: identity.id,\n targetId: record.lockedBy.id\n });\n return Result.fail(error);\n }\n\n shouldKickOut = true;\n }\n\n // Delete the lock record\n const deleteResult = await this.repository.delete(record.id);\n\n if (deleteResult.isFail()) {\n return Result.fail(deleteResult.error);\n }\n\n // If forced by another user, kick out the original lock owner\n if (shouldKickOut) {\n await this.kickOutCurrentUser.execute(record);\n }\n\n return Result.ok(record);\n }\n}\n\nexport const UnlockEntryUseCase = UseCaseAbstraction.createImplementation({\n implementation: UnlockEntryUseCaseImpl,\n dependencies: [\n GetLockRecordUseCase,\n KickOutCurrentUserUseCase,\n UnlockEntryRepository,\n IdentityContext\n ]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SACIC,kBAAkB,IAAIC,kBAAkB,EACxCC,qBAAqB;AAGzB,SAASC,oBAAoB;AAC7B,SAASC,yBAAyB;AAClC,SAASC,eAAe,QAAQ,
|
|
1
|
+
{"version":3,"names":["Result","UnlockEntryUseCase","UseCaseAbstraction","UnlockEntryRepository","GetLockRecordUseCase","KickOutCurrentUserUseCase","IdentityContext","LockRecordNotFoundError","IdentityMismatchError","hasFullAccessPermission","UnlockEntryUseCaseImpl","constructor","getLockRecord","kickOutCurrentUser","repository","identityContext","execute","input","recordResult","isFail","error","delete","id","fail","record","value","isExpired","identity","getIdentity","isSameUser","lockedBy","shouldKickOut","force","currentId","targetId","hasAccess","deleteResult","ok","createImplementation","implementation","dependencies"],"sources":["UnlockEntryUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n UnlockEntryUseCase as UseCaseAbstraction,\n UnlockEntryRepository,\n UnlockEntryInput\n} from \"./abstractions.js\";\nimport { GetLockRecordUseCase } from \"../GetLockRecord/abstractions.js\";\nimport { KickOutCurrentUserUseCase } from \"../KickOutCurrentUser/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport { LockRecordNotFoundError, IdentityMismatchError } from \"~/domain/errors.js\";\nimport { hasFullAccessPermission } from \"./hasFullAccessPermission.js\";\n\nclass UnlockEntryUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getLockRecord: GetLockRecordUseCase.Interface,\n private kickOutCurrentUser: KickOutCurrentUserUseCase.Interface,\n private repository: UnlockEntryRepository.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute(input: UnlockEntryInput): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Get the lock record\n const recordResult = await this.getLockRecord.execute(input);\n\n // If not found or expired, attempt cleanup and return error\n if (recordResult.isFail()) {\n if (recordResult.error instanceof LockRecordNotFoundError) {\n // Try to cleanup any stale data\n await this.repository.delete(input.id);\n }\n\n return Result.fail(recordResult.error);\n }\n\n const record = recordResult.value;\n\n // If expired, cleanup and return error\n if (record.isExpired()) {\n await this.repository.delete(record.id);\n const error = new LockRecordNotFoundError();\n return Result.fail(error);\n }\n\n // Check if user is the owner\n const identity = this.identityContext.getIdentity();\n const isSameUser = record.lockedBy.id === identity.id;\n\n let shouldKickOut = false;\n\n // If not the owner, check if force unlock is allowed\n if (!isSameUser) {\n if (!input.force) {\n const error = new IdentityMismatchError({\n currentId: identity.id,\n targetId: record.lockedBy.id\n });\n return Result.fail(error);\n }\n\n // Check if user has permission to force unlock\n const hasAccess = await hasFullAccessPermission(this.identityContext);\n if (!hasAccess) {\n const error = new IdentityMismatchError({\n currentId: identity.id,\n targetId: record.lockedBy.id\n });\n return Result.fail(error);\n }\n\n shouldKickOut = true;\n }\n\n // Delete the lock record\n const deleteResult = await this.repository.delete(record.id);\n\n if (deleteResult.isFail()) {\n return Result.fail(deleteResult.error);\n }\n\n // If forced by another user, kick out the original lock owner\n if (shouldKickOut) {\n await this.kickOutCurrentUser.execute(record);\n }\n\n return Result.ok(record);\n }\n}\n\nexport const UnlockEntryUseCase = UseCaseAbstraction.createImplementation({\n implementation: UnlockEntryUseCaseImpl,\n dependencies: [\n GetLockRecordUseCase,\n KickOutCurrentUserUseCase,\n UnlockEntryRepository,\n IdentityContext\n ]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SACIC,kBAAkB,IAAIC,kBAAkB,EACxCC,qBAAqB;AAGzB,SAASC,oBAAoB;AAC7B,SAASC,yBAAyB;AAClC,SAASC,eAAe,QAAQ,6DAA6D;AAE7F,SAASC,uBAAuB,EAAEC,qBAAqB;AACvD,SAASC,uBAAuB;AAEhC,MAAMC,sBAAsB,CAAyC;EACjEC,WAAWA,CACCC,aAA6C,EAC7CC,kBAAuD,EACvDC,UAA2C,EAC3CC,eAA0C,EACpD;IAAA,KAJUH,aAA6C,GAA7CA,aAA6C;IAAA,KAC7CC,kBAAuD,GAAvDA,kBAAuD;IAAA,KACvDC,UAA2C,GAA3CA,UAA2C;IAAA,KAC3CC,eAA0C,GAA1CA,eAA0C;EACnD;EAEH,MAAMC,OAAOA,CAACC,KAAuB,EAA0D;IAC3F;IACA,MAAMC,YAAY,GAAG,MAAM,IAAI,CAACN,aAAa,CAACI,OAAO,CAACC,KAAK,CAAC;;IAE5D;IACA,IAAIC,YAAY,CAACC,MAAM,CAAC,CAAC,EAAE;MACvB,IAAID,YAAY,CAACE,KAAK,YAAYb,uBAAuB,EAAE;QACvD;QACA,MAAM,IAAI,CAACO,UAAU,CAACO,MAAM,CAACJ,KAAK,CAACK,EAAE,CAAC;MAC1C;MAEA,OAAOtB,MAAM,CAACuB,IAAI,CAACL,YAAY,CAACE,KAAK,CAAC;IAC1C;IAEA,MAAMI,MAAM,GAAGN,YAAY,CAACO,KAAK;;IAEjC;IACA,IAAID,MAAM,CAACE,SAAS,CAAC,CAAC,EAAE;MACpB,MAAM,IAAI,CAACZ,UAAU,CAACO,MAAM,CAACG,MAAM,CAACF,EAAE,CAAC;MACvC,MAAMF,KAAK,GAAG,IAAIb,uBAAuB,CAAC,CAAC;MAC3C,OAAOP,MAAM,CAACuB,IAAI,CAACH,KAAK,CAAC;IAC7B;;IAEA;IACA,MAAMO,QAAQ,GAAG,IAAI,CAACZ,eAAe,CAACa,WAAW,CAAC,CAAC;IACnD,MAAMC,UAAU,GAAGL,MAAM,CAACM,QAAQ,CAACR,EAAE,KAAKK,QAAQ,CAACL,EAAE;IAErD,IAAIS,aAAa,GAAG,KAAK;;IAEzB;IACA,IAAI,CAACF,UAAU,EAAE;MACb,IAAI,CAACZ,KAAK,CAACe,KAAK,EAAE;QACd,MAAMZ,KAAK,GAAG,IAAIZ,qBAAqB,CAAC;UACpCyB,SAAS,EAAEN,QAAQ,CAACL,EAAE;UACtBY,QAAQ,EAAEV,MAAM,CAACM,QAAQ,CAACR;QAC9B,CAAC,CAAC;QACF,OAAOtB,MAAM,CAACuB,IAAI,CAACH,KAAK,CAAC;MAC7B;;MAEA;MACA,MAAMe,SAAS,GAAG,MAAM1B,uBAAuB,CAAC,IAAI,CAACM,eAAe,CAAC;MACrE,IAAI,CAACoB,SAAS,EAAE;QACZ,MAAMf,KAAK,GAAG,IAAIZ,qBAAqB,CAAC;UACpCyB,SAAS,EAAEN,QAAQ,CAACL,EAAE;UACtBY,QAAQ,EAAEV,MAAM,CAACM,QAAQ,CAACR;QAC9B,CAAC,CAAC;QACF,OAAOtB,MAAM,CAACuB,IAAI,CAACH,KAAK,CAAC;MAC7B;MAEAW,aAAa,GAAG,IAAI;IACxB;;IAEA;IACA,MAAMK,YAAY,GAAG,MAAM,IAAI,CAACtB,UAAU,CAACO,MAAM,CAACG,MAAM,CAACF,EAAE,CAAC;IAE5D,IAAIc,YAAY,CAACjB,MAAM,CAAC,CAAC,EAAE;MACvB,OAAOnB,MAAM,CAACuB,IAAI,CAACa,YAAY,CAAChB,KAAK,CAAC;IAC1C;;IAEA;IACA,IAAIW,aAAa,EAAE;MACf,MAAM,IAAI,CAAClB,kBAAkB,CAACG,OAAO,CAACQ,MAAM,CAAC;IACjD;IAEA,OAAOxB,MAAM,CAACqC,EAAE,CAACb,MAAM,CAAC;EAC5B;AACJ;AAEA,OAAO,MAAMvB,kBAAkB,GAAGC,kBAAkB,CAACoC,oBAAoB,CAAC;EACtEC,cAAc,EAAE7B,sBAAsB;EACtC8B,YAAY,EAAE,CACVpC,oBAAoB,EACpBC,yBAAyB,EACzBF,qBAAqB,EACrBG,eAAe;AAEvB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DomainEvent } from "@webiny/api-core/features/
|
|
2
|
-
import type { IEventHandler } from "@webiny/api-core/features/
|
|
1
|
+
import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
2
|
+
import type { IEventHandler } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
3
|
import type { ILockRecord } from "../../domain/LockRecord.js";
|
|
4
4
|
import type { LockRecordEntryType } from "../../domain/types.js";
|
|
5
5
|
export interface EntryBeforeUnlockPayload {
|
|
@@ -11,8 +11,8 @@ export declare class EntryBeforeUnlockEvent extends DomainEvent<EntryBeforeUnloc
|
|
|
11
11
|
eventType: "RecordLocking/Entry/BeforeUnlock";
|
|
12
12
|
getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryBeforeUnlockEvent>>;
|
|
13
13
|
}
|
|
14
|
-
export declare const
|
|
15
|
-
export declare namespace
|
|
14
|
+
export declare const EntryBeforeUnlockEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryBeforeUnlockEvent>>;
|
|
15
|
+
export declare namespace EntryBeforeUnlockEventHandler {
|
|
16
16
|
type Interface = IEventHandler<EntryBeforeUnlockEvent>;
|
|
17
17
|
type Event = EntryBeforeUnlockEvent;
|
|
18
18
|
}
|
|
@@ -25,8 +25,8 @@ export declare class EntryAfterUnlockEvent extends DomainEvent<EntryAfterUnlockP
|
|
|
25
25
|
eventType: "RecordLocking/Entry/AfterUnlock";
|
|
26
26
|
getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryAfterUnlockEvent>>;
|
|
27
27
|
}
|
|
28
|
-
export declare const
|
|
29
|
-
export declare namespace
|
|
28
|
+
export declare const EntryAfterUnlockEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryAfterUnlockEvent>>;
|
|
29
|
+
export declare namespace EntryAfterUnlockEventHandler {
|
|
30
30
|
type Interface = IEventHandler<EntryAfterUnlockEvent>;
|
|
31
31
|
type Event = EntryAfterUnlockEvent;
|
|
32
32
|
}
|
|
@@ -39,8 +39,8 @@ export declare class EntryUnlockErrorEvent extends DomainEvent<EntryUnlockErrorP
|
|
|
39
39
|
eventType: "RecordLocking/Entry/UnlockError";
|
|
40
40
|
getHandlerAbstraction(): import("@webiny/di").Abstraction<IEventHandler<EntryUnlockErrorEvent>>;
|
|
41
41
|
}
|
|
42
|
-
export declare const
|
|
43
|
-
export declare namespace
|
|
42
|
+
export declare const EntryUnlockErrorEventHandler: import("@webiny/di").Abstraction<IEventHandler<EntryUnlockErrorEvent>>;
|
|
43
|
+
export declare namespace EntryUnlockErrorEventHandler {
|
|
44
44
|
type Interface = IEventHandler<EntryUnlockErrorEvent>;
|
|
45
45
|
type Event = EntryUnlockErrorEvent;
|
|
46
46
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
import { DomainEvent } from "@webiny/api-core/features/
|
|
2
|
+
import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
3
3
|
|
|
4
4
|
// ============================================================================
|
|
5
5
|
// EntryBeforeUnlock Event
|
|
@@ -8,10 +8,10 @@ import { DomainEvent } from "@webiny/api-core/features/EventPublisher";
|
|
|
8
8
|
export class EntryBeforeUnlockEvent extends DomainEvent {
|
|
9
9
|
eventType = "RecordLocking/Entry/BeforeUnlock";
|
|
10
10
|
getHandlerAbstraction() {
|
|
11
|
-
return
|
|
11
|
+
return EntryBeforeUnlockEventHandler;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
export const
|
|
14
|
+
export const EntryBeforeUnlockEventHandler = createAbstraction("EntryBeforeUnlockEventHandler");
|
|
15
15
|
|
|
16
16
|
// ============================================================================
|
|
17
17
|
// EntryAfterUnlock Event
|
|
@@ -20,10 +20,10 @@ export const EntryBeforeUnlockHandler = createAbstraction("EntryBeforeUnlockHand
|
|
|
20
20
|
export class EntryAfterUnlockEvent extends DomainEvent {
|
|
21
21
|
eventType = "RecordLocking/Entry/AfterUnlock";
|
|
22
22
|
getHandlerAbstraction() {
|
|
23
|
-
return
|
|
23
|
+
return EntryAfterUnlockEventHandler;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
export const
|
|
26
|
+
export const EntryAfterUnlockEventHandler = createAbstraction("EntryAfterUnlockEventHandler");
|
|
27
27
|
|
|
28
28
|
// ============================================================================
|
|
29
29
|
// EntryUnlockError Event
|
|
@@ -32,9 +32,9 @@ export const EntryAfterUnlockHandler = createAbstraction("EntryAfterUnlockHandle
|
|
|
32
32
|
export class EntryUnlockErrorEvent extends DomainEvent {
|
|
33
33
|
eventType = "RecordLocking/Entry/UnlockError";
|
|
34
34
|
getHandlerAbstraction() {
|
|
35
|
-
return
|
|
35
|
+
return EntryUnlockErrorEventHandler;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
export const
|
|
38
|
+
export const EntryUnlockErrorEventHandler = createAbstraction("EntryUnlockErrorEventHandler");
|
|
39
39
|
|
|
40
40
|
//# sourceMappingURL=events.js.map
|