@webiny/api-record-locking 6.1.0 → 6.2.0

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.
Files changed (55) hide show
  1. package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.d.ts +1 -1
  2. package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js +1 -1
  3. package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js.map +1 -1
  4. package/features/IsEntryLocked/IsEntryLockedUseCase.d.ts +1 -1
  5. package/features/IsEntryLocked/IsEntryLockedUseCase.js +1 -1
  6. package/features/IsEntryLocked/IsEntryLockedUseCase.js.map +1 -1
  7. package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.d.ts +1 -1
  8. package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js +1 -1
  9. package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js.map +1 -1
  10. package/features/ListLockRecords/ListLockRecordsUseCase.d.ts +1 -1
  11. package/features/ListLockRecords/ListLockRecordsUseCase.js +1 -1
  12. package/features/ListLockRecords/ListLockRecordsUseCase.js.map +1 -1
  13. package/features/LockEntry/LockEntryEventsDecorator.d.ts +1 -1
  14. package/features/LockEntry/LockEntryEventsDecorator.js +1 -1
  15. package/features/LockEntry/LockEntryEventsDecorator.js.map +1 -1
  16. package/features/LockEntry/events.d.ts +2 -2
  17. package/features/LockEntry/events.js +1 -1
  18. package/features/LockEntry/events.js.map +1 -1
  19. package/features/UnlockEntry/UnlockEntryEventsDecorator.d.ts +1 -1
  20. package/features/UnlockEntry/UnlockEntryEventsDecorator.js +1 -1
  21. package/features/UnlockEntry/UnlockEntryEventsDecorator.js.map +1 -1
  22. package/features/UnlockEntry/UnlockEntryUseCase.d.ts +1 -1
  23. package/features/UnlockEntry/UnlockEntryUseCase.js +1 -1
  24. package/features/UnlockEntry/UnlockEntryUseCase.js.map +1 -1
  25. package/features/UnlockEntry/events.d.ts +2 -2
  26. package/features/UnlockEntry/events.js +1 -1
  27. package/features/UnlockEntry/events.js.map +1 -1
  28. package/features/UnlockEntry/hasFullAccessPermission.d.ts +1 -1
  29. package/features/UnlockEntry/hasFullAccessPermission.js.map +1 -1
  30. package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.d.ts +1 -1
  31. package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js +1 -1
  32. package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js.map +1 -1
  33. package/features/UnlockEntryRequest/UnlockEntryRequestRepository.d.ts +1 -1
  34. package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js +1 -1
  35. package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js.map +1 -1
  36. package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.d.ts +1 -1
  37. package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js +1 -1
  38. package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js.map +1 -1
  39. package/features/UnlockEntryRequest/events.d.ts +2 -2
  40. package/features/UnlockEntryRequest/events.js +1 -1
  41. package/features/UnlockEntryRequest/events.js.map +1 -1
  42. package/features/UpdateEntryLock/UpdateEntryLockRepository.d.ts +1 -1
  43. package/features/UpdateEntryLock/UpdateEntryLockRepository.js +1 -1
  44. package/features/UpdateEntryLock/UpdateEntryLockRepository.js.map +1 -1
  45. package/features/UpdateEntryLock/UpdateEntryLockUseCase.d.ts +1 -1
  46. package/features/UpdateEntryLock/UpdateEntryLockUseCase.js +1 -1
  47. package/features/UpdateEntryLock/UpdateEntryLockUseCase.js.map +1 -1
  48. package/graphql/checkPermissions.js +1 -1
  49. package/graphql/checkPermissions.js.map +1 -1
  50. package/graphql/schema.d.ts +2 -2
  51. package/graphql/schema.js +5 -8
  52. package/graphql/schema.js.map +1 -1
  53. package/index.js +3 -2
  54. package/index.js.map +1 -1
  55. package/package.json +16 -16
@@ -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,2CAA2C;AAE3E,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
+ {"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,2CAA2C;AAC3E,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
+ {"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,2CAA2C;AAC3E,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
+ {"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,2CAA2C;AAC3E,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
+ {"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,5 +1,5 @@
1
1
  import { type LockEntryInput, LockEntryUseCase as UseCaseAbstraction, LockEntryUseCase } from "./abstractions.js";
2
- import { EventPublisher } from "@webiny/api-core/features/EventPublisher";
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/EventPublisher";
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/EventPublisher\";\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,0CAA0C;AAGzE,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
+ {"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/EventPublisher";
2
- import type { IEventHandler } from "@webiny/api-core/features/EventPublisher";
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 {
@@ -1,5 +1,5 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
- import { DomainEvent } from "@webiny/api-core/features/EventPublisher";
2
+ import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
3
3
 
4
4
  // ============================================================================
5
5
  // EntryBeforeLock Event
@@ -1 +1 @@
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\";\nimport type { IEventHandler } from \"@webiny/api-core/features/EventPublisher\";\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,0CAA0C;;AAKtE;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":[]}
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":[]}
@@ -1,5 +1,5 @@
1
1
  import { type UnlockEntryInput, UnlockEntryUseCase as UseCaseAbstraction, UnlockEntryUseCase } from "./abstractions.js";
2
- import { EventPublisher } from "@webiny/api-core/features/EventPublisher";
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/EventPublisher";
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/EventPublisher\";\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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BAAkB,CAACqB,eAAe,CAAC;EACzEC,SAAS,EAAEjB,8BAA8B;EACzCkB,YAAY,EAAE,CAACtB,cAAc;AACjC,CAAC,CAAC","ignoreList":[]}
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"],"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;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,2CAA2C;AAE3E,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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ACG,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
+ {"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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,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/EventPublisher";
2
- import type { IEventHandler } from "@webiny/api-core/features/EventPublisher";
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 {
@@ -1,5 +1,5 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
- import { DomainEvent } from "@webiny/api-core/features/EventPublisher";
2
+ import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
3
3
 
4
4
  // ============================================================================
5
5
  // EntryBeforeUnlock Event
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","DomainEvent","EntryBeforeUnlockEvent","eventType","getHandlerAbstraction","EntryBeforeUnlockEventHandler","EntryAfterUnlockEvent","EntryAfterUnlockEventHandler","EntryUnlockErrorEvent","EntryUnlockErrorEventHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"@webiny/api-core/features/EventPublisher\";\nimport type { IEventHandler } from \"@webiny/api-core/features/EventPublisher\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordEntryType } from \"~/domain/types.js\";\n\n// ============================================================================\n// EntryBeforeUnlock Event\n// ============================================================================\n\nexport interface EntryBeforeUnlockPayload {\n id: string;\n type: LockRecordEntryType;\n force?: boolean;\n}\n\nexport class EntryBeforeUnlockEvent extends DomainEvent<EntryBeforeUnlockPayload> {\n eventType = \"RecordLocking/Entry/BeforeUnlock\" as const;\n\n getHandlerAbstraction() {\n return EntryBeforeUnlockEventHandler;\n }\n}\n\nexport const EntryBeforeUnlockEventHandler = createAbstraction<\n IEventHandler<EntryBeforeUnlockEvent>\n>(\"EntryBeforeUnlockEventHandler\");\n\nexport namespace EntryBeforeUnlockEventHandler {\n export type Interface = IEventHandler<EntryBeforeUnlockEvent>;\n export type Event = EntryBeforeUnlockEvent;\n}\n\n// ============================================================================\n// EntryAfterUnlock Event\n// ============================================================================\n\nexport interface EntryAfterUnlockPayload {\n id: string;\n type: LockRecordEntryType;\n record: ILockRecord;\n}\n\nexport class EntryAfterUnlockEvent extends DomainEvent<EntryAfterUnlockPayload> {\n eventType = \"RecordLocking/Entry/AfterUnlock\" as const;\n\n getHandlerAbstraction() {\n return EntryAfterUnlockEventHandler;\n }\n}\n\nexport const EntryAfterUnlockEventHandler = createAbstraction<IEventHandler<EntryAfterUnlockEvent>>(\n \"EntryAfterUnlockEventHandler\"\n);\n\nexport namespace EntryAfterUnlockEventHandler {\n export type Interface = IEventHandler<EntryAfterUnlockEvent>;\n export type Event = EntryAfterUnlockEvent;\n}\n\n// ============================================================================\n// EntryUnlockError Event\n// ============================================================================\n\nexport interface EntryUnlockErrorPayload {\n id: string;\n type: LockRecordEntryType;\n error: Error;\n}\n\nexport class EntryUnlockErrorEvent extends DomainEvent<EntryUnlockErrorPayload> {\n eventType = \"RecordLocking/Entry/UnlockError\" as const;\n\n getHandlerAbstraction() {\n return EntryUnlockErrorEventHandler;\n }\n}\n\nexport const EntryUnlockErrorEventHandler = createAbstraction<IEventHandler<EntryUnlockErrorEvent>>(\n \"EntryUnlockErrorEventHandler\"\n);\n\nexport namespace EntryUnlockErrorEventHandler {\n export type Interface = IEventHandler<EntryUnlockErrorEvent>;\n export type Event = EntryUnlockErrorEvent;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW,QAAQ,0CAA0C;;AAKtE;AACA;AACA;;AAQA,OAAO,MAAMC,sBAAsB,SAASD,WAAW,CAA2B;EAC9EE,SAAS,GAAG,kCAAkC;EAE9CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,6BAA6B;EACxC;AACJ;AAEA,OAAO,MAAMA,6BAA6B,GAAGL,iBAAiB,CAE5D,+BAA+B,CAAC;;AAOlC;AACA;AACA;;AAQA,OAAO,MAAMM,qBAAqB,SAASL,WAAW,CAA0B;EAC5EE,SAAS,GAAG,iCAAiC;EAE7CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,4BAA4B;EACvC;AACJ;AAEA,OAAO,MAAMA,4BAA4B,GAAGP,iBAAiB,CACzD,8BACJ,CAAC;;AAOD;AACA;AACA;;AAQA,OAAO,MAAMQ,qBAAqB,SAASP,WAAW,CAA0B;EAC5EE,SAAS,GAAG,iCAAiC;EAE7CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOK,4BAA4B;EACvC;AACJ;AAEA,OAAO,MAAMA,4BAA4B,GAAGT,iBAAiB,CACzD,8BACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["createAbstraction","DomainEvent","EntryBeforeUnlockEvent","eventType","getHandlerAbstraction","EntryBeforeUnlockEventHandler","EntryAfterUnlockEvent","EntryAfterUnlockEventHandler","EntryUnlockErrorEvent","EntryUnlockErrorEventHandler"],"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// EntryBeforeUnlock Event\n// ============================================================================\n\nexport interface EntryBeforeUnlockPayload {\n id: string;\n type: LockRecordEntryType;\n force?: boolean;\n}\n\nexport class EntryBeforeUnlockEvent extends DomainEvent<EntryBeforeUnlockPayload> {\n eventType = \"RecordLocking/Entry/BeforeUnlock\" as const;\n\n getHandlerAbstraction() {\n return EntryBeforeUnlockEventHandler;\n }\n}\n\nexport const EntryBeforeUnlockEventHandler = createAbstraction<\n IEventHandler<EntryBeforeUnlockEvent>\n>(\"EntryBeforeUnlockEventHandler\");\n\nexport namespace EntryBeforeUnlockEventHandler {\n export type Interface = IEventHandler<EntryBeforeUnlockEvent>;\n export type Event = EntryBeforeUnlockEvent;\n}\n\n// ============================================================================\n// EntryAfterUnlock Event\n// ============================================================================\n\nexport interface EntryAfterUnlockPayload {\n id: string;\n type: LockRecordEntryType;\n record: ILockRecord;\n}\n\nexport class EntryAfterUnlockEvent extends DomainEvent<EntryAfterUnlockPayload> {\n eventType = \"RecordLocking/Entry/AfterUnlock\" as const;\n\n getHandlerAbstraction() {\n return EntryAfterUnlockEventHandler;\n }\n}\n\nexport const EntryAfterUnlockEventHandler = createAbstraction<IEventHandler<EntryAfterUnlockEvent>>(\n \"EntryAfterUnlockEventHandler\"\n);\n\nexport namespace EntryAfterUnlockEventHandler {\n export type Interface = IEventHandler<EntryAfterUnlockEvent>;\n export type Event = EntryAfterUnlockEvent;\n}\n\n// ============================================================================\n// EntryUnlockError Event\n// ============================================================================\n\nexport interface EntryUnlockErrorPayload {\n id: string;\n type: LockRecordEntryType;\n error: Error;\n}\n\nexport class EntryUnlockErrorEvent extends DomainEvent<EntryUnlockErrorPayload> {\n eventType = \"RecordLocking/Entry/UnlockError\" as const;\n\n getHandlerAbstraction() {\n return EntryUnlockErrorEventHandler;\n }\n}\n\nexport const EntryUnlockErrorEventHandler = createAbstraction<IEventHandler<EntryUnlockErrorEvent>>(\n \"EntryUnlockErrorEventHandler\"\n);\n\nexport namespace EntryUnlockErrorEventHandler {\n export type Interface = IEventHandler<EntryUnlockErrorEvent>;\n export type Event = EntryUnlockErrorEvent;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW,QAAQ,mDAAmD;;AAK/E;AACA;AACA;;AAQA,OAAO,MAAMC,sBAAsB,SAASD,WAAW,CAA2B;EAC9EE,SAAS,GAAG,kCAAkC;EAE9CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,6BAA6B;EACxC;AACJ;AAEA,OAAO,MAAMA,6BAA6B,GAAGL,iBAAiB,CAE5D,+BAA+B,CAAC;;AAOlC;AACA;AACA;;AAQA,OAAO,MAAMM,qBAAqB,SAASL,WAAW,CAA0B;EAC5EE,SAAS,GAAG,iCAAiC;EAE7CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,4BAA4B;EACvC;AACJ;AAEA,OAAO,MAAMA,4BAA4B,GAAGP,iBAAiB,CACzD,8BACJ,CAAC;;AAOD;AACA;AACA;;AAQA,OAAO,MAAMQ,qBAAqB,SAASP,WAAW,CAA0B;EAC5EE,SAAS,GAAG,iCAAiC;EAE7CC,qBAAqBA,CAAA,EAAG;IACpB,OAAOK,4BAA4B;EACvC;AACJ;AAEA,OAAO,MAAMA,4BAA4B,GAAGT,iBAAiB,CACzD,8BACJ,CAAC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import type { IdentityContext } from "@webiny/api-core/features/IdentityContext";
1
+ import type { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
2
2
  export declare const hasFullAccessPermission: (identityContext: IdentityContext.Interface) => Promise<boolean>;
@@ -1 +1 @@
1
- {"version":3,"names":["hasFullAccessPermission","identityContext","hasFullAccess","permission","getPermission","canForceUnlock"],"sources":["hasFullAccessPermission.ts"],"sourcesContent":["import type { IdentityContext } from \"@webiny/api-core/features/IdentityContext\";\nimport type { SecurityPermission } from \"@webiny/api-core/types/security.js\";\n\ninterface RecordLockingSecurityPermission extends SecurityPermission {\n canForceUnlock?: boolean;\n}\n\nexport const hasFullAccessPermission = async (\n identityContext: IdentityContext.Interface\n): Promise<boolean> => {\n const hasFullAccess = await identityContext.hasFullAccess();\n if (hasFullAccess) {\n return true;\n }\n\n const permission =\n await identityContext.getPermission<RecordLockingSecurityPermission>(\"recordLocking\");\n return permission?.canForceUnlock === true;\n};\n"],"mappings":"AAOA,OAAO,MAAMA,uBAAuB,GAAG,MACnCC,eAA0C,IACvB;EACnB,MAAMC,aAAa,GAAG,MAAMD,eAAe,CAACC,aAAa,CAAC,CAAC;EAC3D,IAAIA,aAAa,EAAE;IACf,OAAO,IAAI;EACf;EAEA,MAAMC,UAAU,GACZ,MAAMF,eAAe,CAACG,aAAa,CAAkC,eAAe,CAAC;EACzF,OAAOD,UAAU,EAAEE,cAAc,KAAK,IAAI;AAC9C,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["hasFullAccessPermission","identityContext","hasFullAccess","permission","getPermission","canForceUnlock"],"sources":["hasFullAccessPermission.ts"],"sourcesContent":["import type { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type { SecurityPermission } from \"@webiny/api-core/types/security.js\";\n\ninterface RecordLockingSecurityPermission extends SecurityPermission {\n canForceUnlock?: boolean;\n}\n\nexport const hasFullAccessPermission = async (\n identityContext: IdentityContext.Interface\n): Promise<boolean> => {\n const hasFullAccess = await identityContext.hasFullAccess();\n if (hasFullAccess) {\n return true;\n }\n\n const permission =\n await identityContext.getPermission<RecordLockingSecurityPermission>(\"recordLocking\");\n return permission?.canForceUnlock === true;\n};\n"],"mappings":"AAOA,OAAO,MAAMA,uBAAuB,GAAG,MACnCC,eAA0C,IACvB;EACnB,MAAMC,aAAa,GAAG,MAAMD,eAAe,CAACC,aAAa,CAAC,CAAC;EAC3D,IAAIA,aAAa,EAAE;IACf,OAAO,IAAI;EACf;EAEA,MAAMC,UAAU,GACZ,MAAMF,eAAe,CAACG,aAAa,CAAkC,eAAe,CAAC;EACzF,OAAOD,UAAU,EAAEE,cAAc,KAAK,IAAI;AAC9C,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import { type UnlockEntryRequestInput, UnlockEntryRequestUseCase as UseCaseAbstraction, UnlockEntryRequestUseCase } from "./abstractions.js";
2
- import { EventPublisher } from "@webiny/api-core/features/EventPublisher";
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 UnlockEntryRequestEventsDecoratorImpl implements UnlockEntryRequestUseCase.Interface {
@@ -1,5 +1,5 @@
1
1
  import { UnlockEntryRequestUseCase } from "./abstractions.js";
2
- import { EventPublisher } from "@webiny/api-core/features/EventPublisher";
2
+ import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
3
3
  import { EntryAfterUnlockRequestEvent, EntryBeforeUnlockRequestEvent, EntryUnlockRequestErrorEvent } from "./events.js";
4
4
  class UnlockEntryRequestEventsDecoratorImpl {
5
5
  constructor(eventPublisher, decoratee) {
@@ -1 +1 @@
1
- {"version":3,"names":["UnlockEntryRequestUseCase","EventPublisher","EntryAfterUnlockRequestEvent","EntryBeforeUnlockRequestEvent","EntryUnlockRequestErrorEvent","UnlockEntryRequestEventsDecoratorImpl","constructor","eventPublisher","decoratee","execute","input","publish","id","type","result","isFail","error","record","value","UnlockEntryRequestEventsDecorator","createDecorator","decorator","dependencies"],"sources":["UnlockEntryRequestEventsDecorator.ts"],"sourcesContent":["import {\n type UnlockEntryRequestInput,\n UnlockEntryRequestUseCase as UseCaseAbstraction,\n UnlockEntryRequestUseCase\n} from \"./abstractions.js\";\nimport { EventPublisher } from \"@webiny/api-core/features/EventPublisher\";\nimport type { ILockRecord } from \"~/domain/index.js\";\nimport { Result } from \"@webiny/feature/api/index.js\";\nimport {\n EntryAfterUnlockRequestEvent,\n EntryBeforeUnlockRequestEvent,\n EntryUnlockRequestErrorEvent\n} from \"./events.js\";\n\nclass UnlockEntryRequestEventsDecoratorImpl implements UnlockEntryRequestUseCase.Interface {\n constructor(\n private readonly eventPublisher: EventPublisher.Interface,\n private readonly decoratee: UnlockEntryRequestUseCase.Interface\n ) {}\n\n async execute(\n input: UnlockEntryRequestInput\n ): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Publish before event\n await this.eventPublisher.publish(\n new EntryBeforeUnlockRequestEvent({\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 EntryUnlockRequestErrorEvent({\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 EntryAfterUnlockRequestEvent({\n id: input.id,\n type: input.type,\n record: result.value\n })\n );\n\n return result;\n }\n}\n\nexport const UnlockEntryRequestEventsDecorator = UnlockEntryRequestUseCase.createDecorator({\n decorator: UnlockEntryRequestEventsDecoratorImpl,\n dependencies: [EventPublisher]\n});\n"],"mappings":"AAAA,SAGIA,yBAAyB;AAE7B,SAASC,cAAc,QAAQ,0CAA0C;AAGzE,SACIC,4BAA4B,EAC5BC,6BAA6B,EAC7BC,4BAA4B;AAGhC,MAAMC,qCAAqC,CAAgD;EACvFC,WAAWA,CACUC,cAAwC,EACxCC,SAA8C,EACjE;IAAA,KAFmBD,cAAwC,GAAxCA,cAAwC;IAAA,KACxCC,SAA8C,GAA9CA,SAA8C;EAChE;EAEH,MAAMC,OAAOA,CACTC,KAA8B,EACwB;IACtD;IACA,MAAM,IAAI,CAACH,cAAc,CAACI,OAAO,CAC7B,IAAIR,6BAA6B,CAAC;MAC9BS,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,4BAA4B,CAAC;QAC7BQ,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,4BAA4B,CAAC;MAC7BU,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,iCAAiC,GAAGnB,yBAAyB,CAACoB,eAAe,CAAC;EACvFC,SAAS,EAAEhB,qCAAqC;EAChDiB,YAAY,EAAE,CAACrB,cAAc;AACjC,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["UnlockEntryRequestUseCase","EventPublisher","EntryAfterUnlockRequestEvent","EntryBeforeUnlockRequestEvent","EntryUnlockRequestErrorEvent","UnlockEntryRequestEventsDecoratorImpl","constructor","eventPublisher","decoratee","execute","input","publish","id","type","result","isFail","error","record","value","UnlockEntryRequestEventsDecorator","createDecorator","decorator","dependencies"],"sources":["UnlockEntryRequestEventsDecorator.ts"],"sourcesContent":["import {\n type UnlockEntryRequestInput,\n UnlockEntryRequestUseCase as UseCaseAbstraction,\n UnlockEntryRequestUseCase\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 {\n EntryAfterUnlockRequestEvent,\n EntryBeforeUnlockRequestEvent,\n EntryUnlockRequestErrorEvent\n} from \"./events.js\";\n\nclass UnlockEntryRequestEventsDecoratorImpl implements UnlockEntryRequestUseCase.Interface {\n constructor(\n private readonly eventPublisher: EventPublisher.Interface,\n private readonly decoratee: UnlockEntryRequestUseCase.Interface\n ) {}\n\n async execute(\n input: UnlockEntryRequestInput\n ): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Publish before event\n await this.eventPublisher.publish(\n new EntryBeforeUnlockRequestEvent({\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 EntryUnlockRequestErrorEvent({\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 EntryAfterUnlockRequestEvent({\n id: input.id,\n type: input.type,\n record: result.value\n })\n );\n\n return result;\n }\n}\n\nexport const UnlockEntryRequestEventsDecorator = UnlockEntryRequestUseCase.createDecorator({\n decorator: UnlockEntryRequestEventsDecoratorImpl,\n dependencies: [EventPublisher]\n});\n"],"mappings":"AAAA,SAGIA,yBAAyB;AAE7B,SAASC,cAAc,QAAQ,mDAAmD;AAGlF,SACIC,4BAA4B,EAC5BC,6BAA6B,EAC7BC,4BAA4B;AAGhC,MAAMC,qCAAqC,CAAgD;EACvFC,WAAWA,CACUC,cAAwC,EACxCC,SAA8C,EACjE;IAAA,KAFmBD,cAAwC,GAAxCA,cAAwC;IAAA,KACxCC,SAA8C,GAA9CA,SAA8C;EAChE;EAEH,MAAMC,OAAOA,CACTC,KAA8B,EACwB;IACtD;IACA,MAAM,IAAI,CAACH,cAAc,CAACI,OAAO,CAC7B,IAAIR,6BAA6B,CAAC;MAC9BS,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,4BAA4B,CAAC;QAC7BQ,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,4BAA4B,CAAC;MAC7BU,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,iCAAiC,GAAGnB,yBAAyB,CAACoB,eAAe,CAAC;EACvFC,SAAS,EAAEhB,qCAAqC;EAChDiB,YAAY,EAAE,CAACrB,cAAc;AACjC,CAAC,CAAC","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import { Result } from "@webiny/feature/api";
2
2
  import { UnlockEntryRequestRepository as RepositoryAbstraction } from "./abstractions.js";
3
3
  import { UpdateEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UpdateEntry";
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
  import type { CmsModel } from "@webiny/api-headless-cms/types";
7
7
  declare class UnlockEntryRequestRepositoryImpl implements RepositoryAbstraction.Interface {
@@ -1,7 +1,7 @@
1
1
  import { Result } from "@webiny/feature/api";
2
2
  import { UnlockEntryRequestRepository as RepositoryAbstraction } from "./abstractions.js";
3
3
  import { UpdateEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UpdateEntry";
4
- import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
4
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
5
5
  import { RecordLockingModel } from "../../domain/abstractions.js";
6
6
  import { UnlockEntryRequestError } from "../../domain/errors.js";
7
7
  import { createLockRecordDatabaseId } from "../../utils/lockRecordDatabaseId.js";
@@ -1 +1 @@
1
- {"version":3,"names":["Result","UnlockEntryRequestRepository","RepositoryAbstraction","UpdateEntryUseCase","IdentityContext","RecordLockingModel","UnlockEntryRequestError","createLockRecordDatabaseId","createIdentifier","UnlockEntryRequestRepositoryImpl","constructor","updateEntry","identityContext","model","update","record","entryId","id","version","recordValues","toObject","result","withoutAuthorization","execute","values","isFail","fail","error","ok","createImplementation","implementation","dependencies"],"sources":["UnlockEntryRequestRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UnlockEntryRequestRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { UpdateEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UpdateEntry\";\nimport { IdentityContext } from \"@webiny/api-core/features/IdentityContext\";\nimport { RecordLockingModel } from \"~/domain/abstractions.js\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { UnlockEntryRequestError } from \"~/domain/errors.js\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId.js\";\nimport { createIdentifier } from \"@webiny/utils\";\n\nclass UnlockEntryRequestRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private updateEntry: UpdateEntryUseCase.Interface,\n private identityContext: IdentityContext.Interface,\n private model: CmsModel\n ) {}\n\n async update(record: ILockRecord): Promise<Result<ILockRecord, RepositoryAbstraction.Error>> {\n try {\n const entryId = createLockRecordDatabaseId(record.id);\n const id = createIdentifier({\n id: entryId,\n version: 1\n });\n\n const recordValues = record.toObject();\n const result = await this.identityContext.withoutAuthorization(async () => {\n return await this.updateEntry.execute(this.model, id, {\n ...recordValues,\n values: recordValues\n });\n });\n\n if (result.isFail()) {\n return Result.fail(new UnlockEntryRequestError(result.error));\n }\n\n return Result.ok(record);\n } catch (error) {\n return Result.fail(new UnlockEntryRequestError(error as Error));\n }\n }\n}\n\nexport const UnlockEntryRequestRepository = RepositoryAbstraction.createImplementation({\n implementation: UnlockEntryRequestRepositoryImpl,\n dependencies: [UpdateEntryUseCase,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K,EAAE;MACZ,OAAO3B,MAAM,CAAC0B,IAAI,CAAC,IAAIpB,uBAAuB,CAACqB,KAAc,CAAC,CAAC;IACnE;EACJ;AACJ;AAEA,OAAO,MAAM1B,4BAA4B,GAAGC,qBAAqB,CAAC2B,oBAAoB,CAAC;EACnFC,cAAc,EAAErB,gCAAgC;EAChDsB,YAAY,EAAE,CAAC5B,kBAAkB,EAAEC,eAAe,EAAEC,kBAAkB;AAC1E,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["Result","UnlockEntryRequestRepository","RepositoryAbstraction","UpdateEntryUseCase","IdentityContext","RecordLockingModel","UnlockEntryRequestError","createLockRecordDatabaseId","createIdentifier","UnlockEntryRequestRepositoryImpl","constructor","updateEntry","identityContext","model","update","record","entryId","id","version","recordValues","toObject","result","withoutAuthorization","execute","values","isFail","fail","error","ok","createImplementation","implementation","dependencies"],"sources":["UnlockEntryRequestRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { UnlockEntryRequestRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { UpdateEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UpdateEntry\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { RecordLockingModel } from \"~/domain/abstractions.js\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { UnlockEntryRequestError } from \"~/domain/errors.js\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId.js\";\nimport { createIdentifier } from \"@webiny/utils\";\n\nclass UnlockEntryRequestRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private updateEntry: UpdateEntryUseCase.Interface,\n private identityContext: IdentityContext.Interface,\n private model: CmsModel\n ) {}\n\n async update(record: ILockRecord): Promise<Result<ILockRecord, RepositoryAbstraction.Error>> {\n try {\n const entryId = createLockRecordDatabaseId(record.id);\n const id = createIdentifier({\n id: entryId,\n version: 1\n });\n\n const recordValues = record.toObject();\n const result = await this.identityContext.withoutAuthorization(async () => {\n return await this.updateEntry.execute(this.model, id, {\n ...recordValues,\n values: recordValues\n });\n });\n\n if (result.isFail()) {\n return Result.fail(new UnlockEntryRequestError(result.error));\n }\n\n return Result.ok(record);\n } catch (error) {\n return Result.fail(new UnlockEntryRequestError(error as Error));\n }\n }\n}\n\nexport const UnlockEntryRequestRepository = RepositoryAbstraction.createImplementation({\n implementation: UnlockEntryRequestRepositoryImpl,\n dependencies: [UpdateEntryUseCase, IdentityContext, RecordLockingModel]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,4BAA4B,IAAIC,qBAAqB;AAC9D,SAASC,kBAAkB,QAAQ,4DAA4D;AAC/F,SAASC,eAAe,QAAQ,6DAA6D;AAC7F,SAASC,kBAAkB;AAG3B,SAASC,uBAAuB;AAChC,SAASC,0BAA0B;AACnC,SAASC,gBAAgB,QAAQ,eAAe;AAEhD,MAAMC,gCAAgC,CAA4C;EAC9EC,WAAWA,CACCC,WAAyC,EACzCC,eAA0C,EAC1CC,KAAe,EACzB;IAAA,KAHUF,WAAyC,GAAzCA,WAAyC;IAAA,KACzCC,eAA0C,GAA1CA,eAA0C;IAAA,KAC1CC,KAAe,GAAfA,KAAe;EACxB;EAEH,MAAMC,MAAMA,CAACC,MAAmB,EAA6D;IACzF,IAAI;MACA,MAAMC,OAAO,GAAGT,0BAA0B,CAACQ,MAAM,CAACE,EAAE,CAAC;MACrD,MAAMA,EAAE,GAAGT,gBAAgB,CAAC;QACxBS,EAAE,EAAED,OAAO;QACXE,OAAO,EAAE;MACb,CAAC,CAAC;MAEF,MAAMC,YAAY,GAAGJ,MAAM,CAACK,QAAQ,CAAC,CAAC;MACtC,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACT,eAAe,CAACU,oBAAoB,CAAC,YAAY;QACvE,OAAO,MAAM,IAAI,CAACX,WAAW,CAACY,OAAO,CAAC,IAAI,CAACV,KAAK,EAAEI,EAAE,EAAE;UAClD,GAAGE,YAAY;UACfK,MAAM,EAAEL;QACZ,CAAC,CAAC;MACN,CAAC,CAAC;MAEF,IAAIE,MAAM,CAACI,MAAM,CAAC,CAAC,EAAE;QACjB,OAAOzB,MAAM,CAAC0B,IAAI,CAAC,IAAIpB,uBAAuB,CAACe,MAAM,CAACM,KAAK,CAAC,CAAC;MACjE;MAEA,OAAO3B,MAAM,CAAC4B,EAAE,CAACb,MAAM,CAAC;IAC5B,CAAC,CAAC,OAAOY,KAAK,EAAE;MACZ,OAAO3B,MAAM,CAAC0B,IAAI,CAAC,IAAIpB,uBAAuB,CAACqB,KAAc,CAAC,CAAC;IACnE;EACJ;AACJ;AAEA,OAAO,MAAM1B,4BAA4B,GAAGC,qBAAqB,CAAC2B,oBAAoB,CAAC;EACnFC,cAAc,EAAErB,gCAAgC;EAChDsB,YAAY,EAAE,CAAC5B,kBAAkB,EAAEC,eAAe,EAAEC,kBAAkB;AAC1E,CAAC,CAAC","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import { Result } from "@webiny/feature/api";
2
2
  import { UnlockEntryRequestUseCase as UseCaseAbstraction, UnlockEntryRequestRepository, UnlockEntryRequestInput } 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 UnlockEntryRequestUseCaseImpl implements UseCaseAbstraction.Interface {
7
7
  private getLockRecord;
@@ -1,7 +1,7 @@
1
1
  import { Result } from "@webiny/feature/api";
2
2
  import { UnlockEntryRequestUseCase as UseCaseAbstraction, UnlockEntryRequestRepository } 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 { EntryNotLockedError, UnlockRequestAlreadySentError, LockRecordNotFoundError, LockRecordPersistenceError } from "../../domain/errors.js";
6
6
  import { RecordLockingLockRecordActionType } from "../../domain/types.js";
7
7
  class UnlockEntryRequestUseCaseImpl {
@@ -1 +1 @@
1
- {"version":3,"names":["Result","UnlockEntryRequestUseCase","UseCaseAbstraction","UnlockEntryRequestRepository","GetLockRecordUseCase","IdentityContext","EntryNotLockedError","UnlockRequestAlreadySentError","LockRecordNotFoundError","LockRecordPersistenceError","RecordLockingLockRecordActionType","UnlockEntryRequestUseCaseImpl","constructor","getLockRecord","repository","identityContext","execute","input","recordResult","isFail","error","id","type","fail","record","value","isExpired","unlockRequested","getUnlockRequested","currentIdentity","getIdentity","createdBy","identityId","approved","getUnlockApproved","denied","getUnlockDenied","ok","identity","addAction","requested","createdOn","Date","updateResult","update","createImplementation","implementation","dependencies"],"sources":["UnlockEntryRequestUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n UnlockEntryRequestUseCase as UseCaseAbstraction,\n UnlockEntryRequestRepository,\n UnlockEntryRequestInput\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 {\n EntryNotLockedError,\n UnlockRequestAlreadySentError,\n LockRecordNotFoundError,\n LockRecordPersistenceError\n} from \"~/domain/errors.js\";\nimport { RecordLockingLockRecordActionType } from \"~/domain/types.js\";\n\nclass UnlockEntryRequestUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getLockRecord: GetLockRecordUseCase.Interface,\n private repository: UnlockEntryRequestRepository.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute(\n input: UnlockEntryRequestInput\n ): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Get the lock record\n const recordResult = await this.getLockRecord.execute(input);\n\n // If not found, it means entry is not locked\n if (recordResult.isFail()) {\n if (recordResult.error instanceof LockRecordNotFoundError) {\n const error = new EntryNotLockedError({ id: input.id, type: input.type });\n return Result.fail(error);\n }\n // Other errors\n return Result.fail(new LockRecordPersistenceError(recordResult.error));\n }\n\n const record = recordResult.value;\n\n // If expired, entry is not locked\n if (record.isExpired()) {\n const error = new EntryNotLockedError({ id: input.id, type: input.type });\n return Result.fail(error);\n }\n\n // Check if unlock request already exists\n const unlockRequested = record.getUnlockRequested();\n if (unlockRequested) {\n const currentIdentity = this.identityContext.getIdentity();\n\n // If a different user already requested unlock, deny\n if (unlockRequested.createdBy.id !== currentIdentity.id) {\n const error = new UnlockRequestAlreadySentError({\n id: input.id,\n type: input.type,\n identityId: unlockRequested.createdBy.id\n });\n return Result.fail(error);\n }\n\n // If same user but already approved or denied, return the record\n const approved = record.getUnlockApproved();\n const denied = record.getUnlockDenied();\n if (approved || denied) {\n return Result.ok(record);\n }\n\n // If same user and pending, treat as duplicate\n const error = new UnlockRequestAlreadySentError({\n id: input.id,\n type: input.type,\n identityId: unlockRequested.createdBy.id\n });\n return Result.fail(error);\n }\n\n // Add unlock request action\n const identity = this.identityContext.getIdentity();\n record.addAction({\n type: RecordLockingLockRecordActionType.requested,\n createdOn: new Date(),\n createdBy: identity\n });\n\n // Update the record\n const updateResult = await this.repository.update(record);\n\n if (updateResult.isFail()) {\n return Result.fail(updateResult.error);\n }\n\n return Result.ok(record);\n }\n}\n\nexport const UnlockEntryRequestUseCase = UseCaseAbstraction.createImplementation({\n implementation: UnlockEntryRequestUseCaseImpl,\n dependencies: [GetLockRecordUseCase, UnlockEntryRequestRepository, IdentityContext]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SACIC,yBAAyB,IAAIC,kBAAkB,EAC/CC,4BAA4B;AAGhC,SAASC,oBAAoB;AAC7B,SAASC,eAAe,QAAQ,2CAA2C;AAE3E,SACIC,mBAAmB,E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CAACuB,IAAI,CAACoB,YAAY,CAACvB,KAAK,CAAC;IAC1C;IAEA,OAAOpB,MAAM,CAACqC,EAAE,CAACb,MAAM,CAAC;EAC5B;AACJ;AAEA,OAAO,MAAMvB,yBAAyB,GAAGC,kBAAkB,CAAC2C,oBAAoB,CAAC;EAC7EC,cAAc,EAAEnC,6BAA6B;EAC7CoC,YAAY,EAAE,CAAC3C,oBAAoB,EAAED,4BAA4B,EAAEE,eAAe;AACtF,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["Result","UnlockEntryRequestUseCase","UseCaseAbstraction","UnlockEntryRequestRepository","GetLockRecordUseCase","IdentityContext","EntryNotLockedError","UnlockRequestAlreadySentError","LockRecordNotFoundError","LockRecordPersistenceError","RecordLockingLockRecordActionType","UnlockEntryRequestUseCaseImpl","constructor","getLockRecord","repository","identityContext","execute","input","recordResult","isFail","error","id","type","fail","record","value","isExpired","unlockRequested","getUnlockRequested","currentIdentity","getIdentity","createdBy","identityId","approved","getUnlockApproved","denied","getUnlockDenied","ok","identity","addAction","requested","createdOn","Date","updateResult","update","createImplementation","implementation","dependencies"],"sources":["UnlockEntryRequestUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n UnlockEntryRequestUseCase as UseCaseAbstraction,\n UnlockEntryRequestRepository,\n UnlockEntryRequestInput\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 {\n EntryNotLockedError,\n UnlockRequestAlreadySentError,\n LockRecordNotFoundError,\n LockRecordPersistenceError\n} from \"~/domain/errors.js\";\nimport { RecordLockingLockRecordActionType } from \"~/domain/types.js\";\n\nclass UnlockEntryRequestUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getLockRecord: GetLockRecordUseCase.Interface,\n private repository: UnlockEntryRequestRepository.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute(\n input: UnlockEntryRequestInput\n ): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Get the lock record\n const recordResult = await this.getLockRecord.execute(input);\n\n // If not found, it means entry is not locked\n if (recordResult.isFail()) {\n if (recordResult.error instanceof LockRecordNotFoundError) {\n const error = new EntryNotLockedError({ id: input.id, type: input.type });\n return Result.fail(error);\n }\n // Other errors\n return Result.fail(new LockRecordPersistenceError(recordResult.error));\n }\n\n const record = recordResult.value;\n\n // If expired, entry is not locked\n if (record.isExpired()) {\n const error = new EntryNotLockedError({ id: input.id, type: input.type });\n return Result.fail(error);\n }\n\n // Check if unlock request already exists\n const unlockRequested = record.getUnlockRequested();\n if (unlockRequested) {\n const currentIdentity = this.identityContext.getIdentity();\n\n // If a different user already requested unlock, deny\n if (unlockRequested.createdBy.id !== currentIdentity.id) {\n const error = new UnlockRequestAlreadySentError({\n id: input.id,\n type: input.type,\n identityId: unlockRequested.createdBy.id\n });\n return Result.fail(error);\n }\n\n // If same user but already approved or denied, return the record\n const approved = record.getUnlockApproved();\n const denied = record.getUnlockDenied();\n if (approved || denied) {\n return Result.ok(record);\n }\n\n // If same user and pending, treat as duplicate\n const error = new UnlockRequestAlreadySentError({\n id: input.id,\n type: input.type,\n identityId: unlockRequested.createdBy.id\n });\n return Result.fail(error);\n }\n\n // Add unlock request action\n const identity = this.identityContext.getIdentity();\n record.addAction({\n type: RecordLockingLockRecordActionType.requested,\n createdOn: new Date(),\n createdBy: identity\n });\n\n // Update the record\n const updateResult = await this.repository.update(record);\n\n if (updateResult.isFail()) {\n return Result.fail(updateResult.error);\n }\n\n return Result.ok(record);\n }\n}\n\nexport const UnlockEntryRequestUseCase = UseCaseAbstraction.createImplementation({\n implementation: UnlockEntryRequestUseCaseImpl,\n dependencies: [GetLockRecordUseCase, UnlockEntryRequestRepository, IdentityContext]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SACIC,yB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AC7B,UAAU,CAAC8B,MAAM,CAACpB,MAAM,CAAC;IAEzD,IAAImB,YAAY,CAACxB,MAAM,CAAC,CAAC,EAAE;MACvB,OAAOnB,MAAM,CAACuB,IAAI,CAACoB,YAAY,CAACvB,KAAK,CAAC;IAC1C;IAEA,OAAOpB,MAAM,CAACqC,EAAE,CAACb,MAAM,CAAC;EAC5B;AACJ;AAEA,OAAO,MAAMvB,yBAAyB,GAAGC,kBAAkB,CAAC2C,oBAAoB,CAAC;EAC7EC,cAAc,EAAEnC,6BAA6B;EAC7CoC,YAAY,EAAE,CAAC3C,oBAAoB,EAAED,4BAA4B,EAAEE,eAAe;AACtF,CAAC,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import { DomainEvent } from "@webiny/api-core/features/EventPublisher";
2
- import type { IEventHandler } from "@webiny/api-core/features/EventPublisher";
1
+ import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
2
+ import type { IEventHandler } from "@webiny/api-core/features/eventPublisher/index.js";
3
3
  import type { ILockRecord } from "../../domain/LockRecord.js";
4
4
  import type { LockRecordEntryType } from "../../domain/types.js";
5
5
  export interface EntryBeforeUnlockRequestPayload {
@@ -1,5 +1,5 @@
1
1
  import { createAbstraction } from "@webiny/feature/api";
2
- import { DomainEvent } from "@webiny/api-core/features/EventPublisher";
2
+ import { DomainEvent } from "@webiny/api-core/features/eventPublisher/index.js";
3
3
 
4
4
  // ============================================================================
5
5
  // EntryBeforeUnlockRequest Event
@@ -1 +1 @@
1
- {"version":3,"names":["createAbstraction","DomainEvent","EntryBeforeUnlockRequestEvent","eventType","getHandlerAbstraction","EntryBeforeUnlockRequestEventHandler","EntryAfterUnlockRequestEvent","EntryAfterUnlockRequestEventHandler","EntryUnlockRequestErrorEvent","EntryUnlockRequestErrorEventHandler"],"sources":["events.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { DomainEvent } from \"@webiny/api-core/features/EventPublisher\";\nimport type { IEventHandler } from \"@webiny/api-core/features/EventPublisher\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordEntryType } from \"~/domain/types.js\";\n\n// ============================================================================\n// EntryBeforeUnlockRequest Event\n// ============================================================================\n\nexport interface EntryBeforeUnlockRequestPayload {\n id: string;\n type: LockRecordEntryType;\n}\n\nexport class EntryBeforeUnlockRequestEvent extends DomainEvent<EntryBeforeUnlockRequestPayload> {\n eventType = \"RecordLocking/Entry/BeforeUnlockRequest\" as const;\n\n getHandlerAbstraction() {\n return EntryBeforeUnlockRequestEventHandler;\n }\n}\n\nexport const EntryBeforeUnlockRequestEventHandler = createAbstraction<\n IEventHandler<EntryBeforeUnlockRequestEvent>\n>(\"EntryBeforeUnlockRequestEventHandler\");\n\nexport namespace EntryBeforeUnlockRequestEventHandler {\n export type Interface = IEventHandler<EntryBeforeUnlockRequestEvent>;\n export type Event = EntryBeforeUnlockRequestEvent;\n}\n\n// ============================================================================\n// EntryAfterUnlockRequest Event\n// ============================================================================\n\nexport interface EntryAfterUnlockRequestPayload {\n id: string;\n type: LockRecordEntryType;\n record: ILockRecord;\n}\n\nexport class EntryAfterUnlockRequestEvent extends DomainEvent<EntryAfterUnlockRequestPayload> {\n eventType = \"RecordLocking/Entry/AfterUnlockRequest\" as const;\n\n getHandlerAbstraction() {\n return EntryAfterUnlockRequestEventHandler;\n }\n}\n\nexport const EntryAfterUnlockRequestEventHandler = createAbstraction<\n IEventHandler<EntryAfterUnlockRequestEvent>\n>(\"EntryAfterUnlockRequestEventHandler\");\n\nexport namespace EntryAfterUnlockRequestEventHandler {\n export type Interface = IEventHandler<EntryAfterUnlockRequestEvent>;\n export type Event = EntryAfterUnlockRequestEvent;\n}\n\n// ============================================================================\n// EntryUnlockRequestError Event\n// ============================================================================\n\nexport interface EntryUnlockRequestErrorPayload {\n id: string;\n type: LockRecordEntryType;\n error: Error;\n}\n\nexport class EntryUnlockRequestErrorEvent extends DomainEvent<EntryUnlockRequestErrorPayload> {\n eventType = \"RecordLocking/Entry/UnlockRequestError\" as const;\n\n getHandlerAbstraction() {\n return EntryUnlockRequestErrorEventHandler;\n }\n}\n\nexport const EntryUnlockRequestErrorEventHandler = createAbstraction<\n IEventHandler<EntryUnlockRequestErrorEvent>\n>(\"EntryUnlockRequestErrorEventHandler\");\n\nexport namespace EntryUnlockRequestErrorEventHandler {\n export type Interface = IEventHandler<EntryUnlockRequestErrorEvent>;\n export type Event = EntryUnlockRequestErrorEvent;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW,QAAQ,0CAA0C;;AAKtE;AACA;AACA;;AAOA,OAAO,MAAMC,6BAA6B,SAASD,WAAW,CAAkC;EAC5FE,SAAS,GAAG,yCAAyC;EAErDC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,oCAAoC;EAC/C;AACJ;AAEA,OAAO,MAAMA,oCAAoC,GAAGL,iBAAiB,CAEnE,sCAAsC,CAAC;;AAOzC;AACA;AACA;;AAQA,OAAO,MAAMM,4BAA4B,SAASL,WAAW,CAAiC;EAC1FE,SAAS,GAAG,wCAAwC;EAEpDC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,mCAAmC;EAC9C;AACJ;AAEA,OAAO,MAAMA,mCAAmC,GAAGP,iBAAiB,CAElE,qCAAqC,CAAC;;AAOxC;AACA;AACA;;AAQA,OAAO,MAAMQ,4BAA4B,SAASP,WAAW,CAAiC;EAC1FE,SAAS,GAAG,wCAAwC;EAEpDC,qBAAqBA,CAAA,EAAG;IACpB,OAAOK,mCAAmC;EAC9C;AACJ;AAEA,OAAO,MAAMA,mCAAmC,GAAGT,iBAAiB,CAElE,qCAAqC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["createAbstraction","DomainEvent","EntryBeforeUnlockRequestEvent","eventType","getHandlerAbstraction","EntryBeforeUnlockRequestEventHandler","EntryAfterUnlockRequestEvent","EntryAfterUnlockRequestEventHandler","EntryUnlockRequestErrorEvent","EntryUnlockRequestErrorEventHandler"],"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// EntryBeforeUnlockRequest Event\n// ============================================================================\n\nexport interface EntryBeforeUnlockRequestPayload {\n id: string;\n type: LockRecordEntryType;\n}\n\nexport class EntryBeforeUnlockRequestEvent extends DomainEvent<EntryBeforeUnlockRequestPayload> {\n eventType = \"RecordLocking/Entry/BeforeUnlockRequest\" as const;\n\n getHandlerAbstraction() {\n return EntryBeforeUnlockRequestEventHandler;\n }\n}\n\nexport const EntryBeforeUnlockRequestEventHandler = createAbstraction<\n IEventHandler<EntryBeforeUnlockRequestEvent>\n>(\"EntryBeforeUnlockRequestEventHandler\");\n\nexport namespace EntryBeforeUnlockRequestEventHandler {\n export type Interface = IEventHandler<EntryBeforeUnlockRequestEvent>;\n export type Event = EntryBeforeUnlockRequestEvent;\n}\n\n// ============================================================================\n// EntryAfterUnlockRequest Event\n// ============================================================================\n\nexport interface EntryAfterUnlockRequestPayload {\n id: string;\n type: LockRecordEntryType;\n record: ILockRecord;\n}\n\nexport class EntryAfterUnlockRequestEvent extends DomainEvent<EntryAfterUnlockRequestPayload> {\n eventType = \"RecordLocking/Entry/AfterUnlockRequest\" as const;\n\n getHandlerAbstraction() {\n return EntryAfterUnlockRequestEventHandler;\n }\n}\n\nexport const EntryAfterUnlockRequestEventHandler = createAbstraction<\n IEventHandler<EntryAfterUnlockRequestEvent>\n>(\"EntryAfterUnlockRequestEventHandler\");\n\nexport namespace EntryAfterUnlockRequestEventHandler {\n export type Interface = IEventHandler<EntryAfterUnlockRequestEvent>;\n export type Event = EntryAfterUnlockRequestEvent;\n}\n\n// ============================================================================\n// EntryUnlockRequestError Event\n// ============================================================================\n\nexport interface EntryUnlockRequestErrorPayload {\n id: string;\n type: LockRecordEntryType;\n error: Error;\n}\n\nexport class EntryUnlockRequestErrorEvent extends DomainEvent<EntryUnlockRequestErrorPayload> {\n eventType = \"RecordLocking/Entry/UnlockRequestError\" as const;\n\n getHandlerAbstraction() {\n return EntryUnlockRequestErrorEventHandler;\n }\n}\n\nexport const EntryUnlockRequestErrorEventHandler = createAbstraction<\n IEventHandler<EntryUnlockRequestErrorEvent>\n>(\"EntryUnlockRequestErrorEventHandler\");\n\nexport namespace EntryUnlockRequestErrorEventHandler {\n export type Interface = IEventHandler<EntryUnlockRequestErrorEvent>;\n export type Event = EntryUnlockRequestErrorEvent;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,WAAW,QAAQ,mDAAmD;;AAK/E;AACA;AACA;;AAOA,OAAO,MAAMC,6BAA6B,SAASD,WAAW,CAAkC;EAC5FE,SAAS,GAAG,yCAAyC;EAErDC,qBAAqBA,CAAA,EAAG;IACpB,OAAOC,oCAAoC;EAC/C;AACJ;AAEA,OAAO,MAAMA,oCAAoC,GAAGL,iBAAiB,CAEnE,sCAAsC,CAAC;;AAOzC;AACA;AACA;;AAQA,OAAO,MAAMM,4BAA4B,SAASL,WAAW,CAAiC;EAC1FE,SAAS,GAAG,wCAAwC;EAEpDC,qBAAqBA,CAAA,EAAG;IACpB,OAAOG,mCAAmC;EAC9C;AACJ;AAEA,OAAO,MAAMA,mCAAmC,GAAGP,iBAAiB,CAElE,qCAAqC,CAAC;;AAOxC;AACA;AACA;;AAQA,OAAO,MAAMQ,4BAA4B,SAASP,WAAW,CAAiC;EAC1FE,SAAS,GAAG,wCAAwC;EAEpDC,qBAAqBA,CAAA,EAAG;IACpB,OAAOK,mCAAmC;EAC9C;AACJ;AAEA,OAAO,MAAMA,mCAAmC,GAAGT,iBAAiB,CAElE,qCAAqC,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
1
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
2
2
  import { UpdateEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UpdateEntry";
3
3
  import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById";
4
4
  import { Result } from "@webiny/feature/api";
@@ -1,4 +1,4 @@
1
- import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
1
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
2
2
  import { UpdateEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/UpdateEntry";
3
3
  import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById";
4
4
  import { Result } from "@webiny/feature/api";
@@ -1 +1 @@
1
- {"version":3,"names":["IdentityContext","UpdateEntryUseCase","GetEntryByIdUseCase","Result","createIdentifier","UpdateEntryLockRepository","RepositoryAbstraction","RecordLockingConfig","RecordLockingModel","LockRecord","LockRecordPersistenceError","createLockRecordDatabaseId","UpdateEntryLockRepositoryImpl","constructor","model","config","identityContext","updateEntry","getEntryById","update","lockRecordId","updateOwner","entryId","id","version","identity","getIdentity","now","Date","toISOString","updateData","savedOn","createdOn","createdBy","savedBy","result","execute","isFail","fail","error","getResult","entry","value","lockRecord","timeout","ok","createImplementation","implementation","dependencies"],"sources":["UpdateEntryLockRepository.ts"],"sourcesContent":["import { IdentityContext } from \"@webiny/api-core/features/IdentityContext\";\nimport { UpdateEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UpdateEntry\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById\";\nimport { Result } from \"@webiny/feature/api\";\nimport { createIdentifier } from \"@webiny/utils\";\nimport { UpdateEntryLockRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { RecordLockingConfig, RecordLockingModel } from \"~/domain/abstractions.js\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport { LockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordValues } from \"~/domain/types.js\";\nimport { LockRecordPersistenceError } from \"~/domain/errors.js\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId.js\";\n\nclass UpdateEntryLockRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private model: RecordLockingModel.Interface,\n private config: RecordLockingConfig.Interface,\n private identityContext: IdentityContext.Interface,\n private updateEntry: UpdateEntryUseCase.Interface,\n private getEntryById: GetEntryByIdUseCase.Interface\n ) {}\n\n async update(\n lockRecordId: string,\n updateOwner: boolean\n ): Promise<Result<ILockRecord, RepositoryAbstraction.Error>> {\n try {\n const entryId = createLockRecordDatabaseId(lockRecordId);\n const id = createIdentifier({\n id: entryId,\n version: 1\n });\n\n const identity = this.identityContext.getIdentity();\n const now = new Date().toISOString();\n\n // Build update data\n const updateData: any = {\n savedOn: now\n };\n\n // If updating owner (expired lock), also update created fields\n if (updateOwner) {\n updateData.createdOn = now;\n updateData.createdBy = identity;\n updateData.savedBy = identity;\n }\n\n const result = await this.updateEntry.execute(this.model, id, updateData);\n\n if (result.isFail()) {\n return Result.fail(new LockRecordPersistenceError(result.error));\n }\n\n // Fetch the updated entry to return full lock record\n const getResult = await this.getEntryById.execute<LockRecordValues>(this.model, id);\n\n if (getResult.isFail()) {\n return Result.fail(new LockRecordPersistenceError(getResult.error));\n }\n\n const entry = getResult.value;\n const lockRecord = new LockRecord(entry, this.config.timeout);\n\n return Result.ok(lockRecord);\n } catch (error) {\n return Result.fail(new LockRecordPersistenceError(error as Error));\n }\n }\n}\n\nexport const UpdateEntryLockRepository = RepositoryAbstraction.createImplementation({\n implementation: UpdateEntryLockRepositoryImpl,\n dependencies: [\n RecordLockingModel,\n RecordLockingConfig,\n IdentityContext,\n UpdateEntryUseCase,\n GetEntryByIdUseCase\n ]\n});\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,2CAA2C;AAC3E,SAASC,kBAAkB,QAAQ,4DAA4D;AAC/F,SAASC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UAAU,CAAC;MAEzE,IAAIK,MAAM,CAACE,MAAM,CAAC,CAAC,EAAE;QACjB,OAAOlC,MAAM,CAACmC,IAAI,CAAC,IAAI5B,0BAA0B,CAACyB,MAAM,CAACI,KAAK,CAAC,CAAC;MACpE;;MAEA;MACA,MAAMC,SAAS,GAAG,MAAM,IAAI,CAACtB,YAAY,CAACkB,OAAO,CAAmB,IAAI,CAACtB,KAAK,EAAES,EAAE,CAAC;MAEnF,IAAIiB,SAAS,CAACH,MAAM,CAAC,CAAC,EAAE;QACpB,OAAOlC,MAAM,CAACmC,IAAI,CAAC,IAAI5B,0BAA0B,CAAC8B,SAAS,CAACD,KAAK,CAAC,CAAC;MACvE;MAEA,MAAME,KAAK,GAAGD,SAAS,CAACE,KAAK;MAC7B,MAAMC,UAAU,GAAG,IAAIlC,UAAU,CAACgC,KAAK,EAAE,IAAI,CAAC1B,MAAM,CAAC6B,OAAO,CAAC;MAE7D,OAAOzC,MAAM,CAAC0C,EAAE,CAACF,UAAU,CAAC;IAChC,CAAC,CAAC,OAAOJ,KAAK,EAAE;MACZ,OAAOpC,MAAM,CAACmC,IAAI,CAAC,IAAI5B,0BAA0B,CAAC6B,KAAc,CAAC,CAAC;IACtE;EACJ;AACJ;AAEA,OAAO,MAAMlC,yBAAyB,GAAGC,qBAAqB,CAACwC,oBAAoB,CAAC;EAChFC,cAAc,EAAEnC,6BAA6B;EAC7CoC,YAAY,EAAE,CACVxC,kBAAkB,EAClBD,mBAAmB,EACnBP,eAAe,EACfC,kBAAkB,EAClBC,mBAAmB;AAE3B,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["IdentityContext","UpdateEntryUseCase","GetEntryByIdUseCase","Result","createIdentifier","UpdateEntryLockRepository","RepositoryAbstraction","RecordLockingConfig","RecordLockingModel","LockRecord","LockRecordPersistenceError","createLockRecordDatabaseId","UpdateEntryLockRepositoryImpl","constructor","model","config","identityContext","updateEntry","getEntryById","update","lockRecordId","updateOwner","entryId","id","version","identity","getIdentity","now","Date","toISOString","updateData","savedOn","createdOn","createdBy","savedBy","result","execute","isFail","fail","error","getResult","entry","value","lockRecord","timeout","ok","createImplementation","implementation","dependencies"],"sources":["UpdateEntryLockRepository.ts"],"sourcesContent":["import { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { UpdateEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/UpdateEntry\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById\";\nimport { Result } from \"@webiny/feature/api\";\nimport { createIdentifier } from \"@webiny/utils\";\nimport { UpdateEntryLockRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { RecordLockingConfig, RecordLockingModel } from \"~/domain/abstractions.js\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport { LockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordValues } from \"~/domain/types.js\";\nimport { LockRecordPersistenceError } from \"~/domain/errors.js\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId.js\";\n\nclass UpdateEntryLockRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private model: RecordLockingModel.Interface,\n private config: RecordLockingConfig.Interface,\n private identityContext: IdentityContext.Interface,\n private updateEntry: UpdateEntryUseCase.Interface,\n private getEntryById: GetEntryByIdUseCase.Interface\n ) {}\n\n async update(\n lockRecordId: string,\n updateOwner: boolean\n ): Promise<Result<ILockRecord, RepositoryAbstraction.Error>> {\n try {\n const entryId = createLockRecordDatabaseId(lockRecordId);\n const id = createIdentifier({\n id: entryId,\n version: 1\n });\n\n const identity = this.identityContext.getIdentity();\n const now = new Date().toISOString();\n\n // Build update data\n const updateData: any = {\n savedOn: now\n };\n\n // If updating owner (expired lock), also update created fields\n if (updateOwner) {\n updateData.createdOn = now;\n updateData.createdBy = identity;\n updateData.savedBy = identity;\n }\n\n const result = await this.updateEntry.execute(this.model, id, updateData);\n\n if (result.isFail()) {\n return Result.fail(new LockRecordPersistenceError(result.error));\n }\n\n // Fetch the updated entry to return full lock record\n const getResult = await this.getEntryById.execute<LockRecordValues>(this.model, id);\n\n if (getResult.isFail()) {\n return Result.fail(new LockRecordPersistenceError(getResult.error));\n }\n\n const entry = getResult.value;\n const lockRecord = new LockRecord(entry, this.config.timeout);\n\n return Result.ok(lockRecord);\n } catch (error) {\n return Result.fail(new LockRecordPersistenceError(error as Error));\n }\n }\n}\n\nexport const UpdateEntryLockRepository = RepositoryAbstraction.createImplementation({\n implementation: UpdateEntryLockRepositoryImpl,\n dependencies: [\n RecordLockingModel,\n RecordLockingConfig,\n IdentityContext,\n UpdateEntryUseCase,\n GetEntryByIdUseCase\n ]\n});\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,6DAA6D;AAC7F,SAASC,kBAAkB,QAAQ,4DAA4D;AAC/F,SAASC,mBAAmB,QAAQ,6DAA6D;AACjG,SAASC,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,gBAAgB,QAAQ,eAAe;AAChD,SAASC,yBAAyB,IAAIC,qBAAqB;AAC3D,SAASC,mBAAmB,EAAEC,kBAAkB;AAEhD,SAASC,UAAU;AAEnB,SAASC,0BAA0B;AACnC,SAASC,0BAA0B;AAEnC,MAAMC,6BAA6B,CAA4C;EAC3EC,WAAWA,CACCC,KAAmC,EACnCC,MAAqC,EACrCC,eAA0C,EAC1CC,WAAyC,EACzCC,YAA2C,EACrD;IAAA,KALUJ,KAAmC,GAAnCA,KAAmC;IAAA,KACnCC,MAAqC,GAArCA,MAAqC;IAAA,KACrCC,eAA0C,GAA1CA,eAA0C;IAAA,KAC1CC,WAAyC,GAAzCA,WAAyC;IAAA,KACzCC,YAA2C,GAA3CA,YAA2C;EACpD;EAEH,MAAMC,MAAMA,CACRC,YAAoB,EACpBC,WAAoB,EACqC;IACzD,IAAI;MACA,MAAMC,OAAO,GAAGX,0BAA0B,CAACS,YAAY,CAAC;MACxD,MAAMG,EAAE,GAAGnB,gBAAgB,CAAC;QACxBmB,EAAE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B,0BAA0B,CAAC6B,KAAc,CAAC,CAAC;IACtE;EACJ;AACJ;AAEA,OAAO,MAAMlC,yBAAyB,GAAGC,qBAAqB,CAACwC,oBAAoB,CAAC;EAChFC,cAAc,EAAEnC,6BAA6B;EAC7CoC,YAAY,EAAE,CACVxC,kBAAkB,EAClBD,mBAAmB,EACnBP,eAAe,EACfC,kBAAkB,EAClBC,mBAAmB;AAE3B,CAAC,CAAC","ignoreList":[]}
@@ -2,7 +2,7 @@ import { Result } from "@webiny/feature/api";
2
2
  import { UpdateEntryLockUseCase as UseCaseAbstraction, UpdateEntryLockRepository, UpdateEntryLockInput } from "./abstractions.js";
3
3
  import { GetLockRecordUseCase } from "../GetLockRecord/abstractions.js";
4
4
  import { LockEntryUseCase } from "../LockEntry/abstractions.js";
5
- import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
5
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
6
6
  import type { ILockRecord } from "../../domain/LockRecord.js";
7
7
  declare class UpdateEntryLockUseCaseImpl implements UseCaseAbstraction.Interface {
8
8
  private getLockRecord;
@@ -2,7 +2,7 @@ import { Result } from "@webiny/feature/api";
2
2
  import { UpdateEntryLockUseCase as UseCaseAbstraction, UpdateEntryLockRepository } from "./abstractions.js";
3
3
  import { GetLockRecordUseCase } from "../GetLockRecord/abstractions.js";
4
4
  import { LockEntryUseCase } from "../LockEntry/abstractions.js";
5
- import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
5
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
6
6
  import { LockRecordNotFoundError, IdentityMismatchError, UpdateEntryLockError } from "../../domain/errors.js";
7
7
  class UpdateEntryLockUseCaseImpl {
8
8
  constructor(getLockRecord, lockEntry, repository, identityContext) {
@@ -1 +1 @@
1
- {"version":3,"names":["Result","UpdateEntryLockUseCase","UseCaseAbstraction","UpdateEntryLockRepository","GetLockRecordUseCase","LockEntryUseCase","IdentityContext","LockRecordNotFoundError","IdentityMismatchError","UpdateEntryLockError","UpdateEntryLockUseCaseImpl","constructor","getLockRecord","lockEntry","repository","identityContext","execute","input","recordResult","isFail","error","lockResult","fail","ok","value","record","isExpired","updateResult","update","id","identity","getIdentity","lockedBy","currentId","targetId","createImplementation","implementation","dependencies"],"sources":["UpdateEntryLockUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n UpdateEntryLockUseCase as UseCaseAbstraction,\n UpdateEntryLockRepository,\n UpdateEntryLockInput\n} from \"./abstractions.js\";\nimport { GetLockRecordUseCase } from \"../GetLockRecord/abstractions.js\";\nimport { LockEntryUseCase } from \"../LockEntry/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/IdentityContext\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport {\n LockRecordNotFoundError,\n IdentityMismatchError,\n UpdateEntryLockError\n} from \"~/domain/errors.js\";\n\nclass UpdateEntryLockUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getLockRecord: GetLockRecordUseCase.Interface,\n private lockEntry: LockEntryUseCase.Interface,\n private repository: UpdateEntryLockRepository.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute(\n input: UpdateEntryLockInput\n ): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Try to get existing lock record\n const recordResult = await this.getLockRecord.execute(input);\n\n // If doesn't exist, create a new lock\n if (recordResult.isFail()) {\n if (recordResult.error instanceof LockRecordNotFoundError) {\n const lockResult = await this.lockEntry.execute(input);\n if (lockResult.isFail()) {\n return Result.fail(new UpdateEntryLockError(lockResult.error));\n }\n return Result.ok(lockResult.value);\n }\n return Result.fail(recordResult.error);\n }\n\n const record = recordResult.value;\n\n // If expired, update with current user as new owner\n if (record.isExpired()) {\n const updateResult = await this.repository.update(record.id, true);\n if (updateResult.isFail()) {\n return Result.fail(new UpdateEntryLockError(updateResult.error));\n }\n return Result.ok(updateResult.value);\n }\n\n // If not expired, validate same owner\n const identity = this.identityContext.getIdentity();\n if (record.lockedBy.id !== identity.id) {\n return Result.fail(\n new IdentityMismatchError({\n currentId: identity.id,\n targetId: record.lockedBy.id\n })\n );\n }\n\n // Update timestamp only\n const updateResult = await this.repository.update(record.id, false);\n if (updateResult.isFail()) {\n return Result.fail(new UpdateEntryLockError(updateResult.error));\n }\n\n return Result.ok(updateResult.value);\n }\n}\n\nexport const UpdateEntryLockUseCase = UseCaseAbstraction.createImplementation({\n implementation: UpdateEntryLockUseCaseImpl,\n dependencies: [\n GetLockRecordUseCase,\n LockEntryUseCase,\n UpdateEntryLockRepository,\n IdentityContext\n ]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SACIC,sBAAsB,IAAIC,kBAAkB,EAC5CC,yBAAyB;AAG7B,SAASC,oBAAoB;AAC7B,SAASC,gBAAgB;AACzB,SAASC,eAAe,QAAQ,2CAA2C;AAE3E,SACIC,uBAAuB,EACvBC,qBAAqB,EACrBC,oBAAoB;AAGxB,MAAMC,0BAA0B,CAAyC;EACrEC,WAAWA,CACCC,aAA6C,EAC7CC,SAAqC,EACrCC,UAA+C,EAC/CC,eAA0C,EACpD;IAAA,KAJUH,aAA6C,GAA7CA,aAA6C;IAAA,KAC7CC,SAAqC,GAArCA,SAAqC;IAAA,KACrCC,UAA+C,GAA/CA,UAA+C;IAAA,KAC/CC,eAA0C,GAA1CA,eAA0C;EACnD;EAEH,MAAMC,OAAOA,CACTC,KAA2B,EAC2B;IACtD;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,MAAMc,UAAU,GAAG,MAAM,IAAI,CAACR,SAAS,CAACG,OAAO,CAACC,KAAK,CAAC;QACtD,IAAII,UAAU,CAACF,MAAM,CAAC,CAAC,EAAE;UACrB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ACpE;IAEA,OAAOpB,MAAM,CAACuB,EAAE,CAACI,YAAY,CAACH,KAAK,CAAC;EACxC;AACJ;AAEA,OAAO,MAAMvB,sBAAsB,GAAGC,kBAAkB,CAACiC,oBAAoB,CAAC;EAC1EC,cAAc,EAAE1B,0BAA0B;EAC1C2B,YAAY,EAAE,CACVjC,oBAAoB,EACpBC,gBAAgB,EAChBF,yBAAyB,EACzBG,eAAe;AAEvB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["Result","UpdateEntryLockUseCase","UseCaseAbstraction","UpdateEntryLockRepository","GetLockRecordUseCase","LockEntryUseCase","IdentityContext","LockRecordNotFoundError","IdentityMismatchError","UpdateEntryLockError","UpdateEntryLockUseCaseImpl","constructor","getLockRecord","lockEntry","repository","identityContext","execute","input","recordResult","isFail","error","lockResult","fail","ok","value","record","isExpired","updateResult","update","id","identity","getIdentity","lockedBy","currentId","targetId","createImplementation","implementation","dependencies"],"sources":["UpdateEntryLockUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n UpdateEntryLockUseCase as UseCaseAbstraction,\n UpdateEntryLockRepository,\n UpdateEntryLockInput\n} from \"./abstractions.js\";\nimport { GetLockRecordUseCase } from \"../GetLockRecord/abstractions.js\";\nimport { LockEntryUseCase } from \"../LockEntry/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport {\n LockRecordNotFoundError,\n IdentityMismatchError,\n UpdateEntryLockError\n} from \"~/domain/errors.js\";\n\nclass UpdateEntryLockUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private getLockRecord: GetLockRecordUseCase.Interface,\n private lockEntry: LockEntryUseCase.Interface,\n private repository: UpdateEntryLockRepository.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n async execute(\n input: UpdateEntryLockInput\n ): Promise<Result<ILockRecord, UseCaseAbstraction.Error>> {\n // Try to get existing lock record\n const recordResult = await this.getLockRecord.execute(input);\n\n // If doesn't exist, create a new lock\n if (recordResult.isFail()) {\n if (recordResult.error instanceof LockRecordNotFoundError) {\n const lockResult = await this.lockEntry.execute(input);\n if (lockResult.isFail()) {\n return Result.fail(new UpdateEntryLockError(lockResult.error));\n }\n return Result.ok(lockResult.value);\n }\n return Result.fail(recordResult.error);\n }\n\n const record = recordResult.value;\n\n // If expired, update with current user as new owner\n if (record.isExpired()) {\n const updateResult = await this.repository.update(record.id, true);\n if (updateResult.isFail()) {\n return Result.fail(new UpdateEntryLockError(updateResult.error));\n }\n return Result.ok(updateResult.value);\n }\n\n // If not expired, validate same owner\n const identity = this.identityContext.getIdentity();\n if (record.lockedBy.id !== identity.id) {\n return Result.fail(\n new IdentityMismatchError({\n currentId: identity.id,\n targetId: record.lockedBy.id\n })\n );\n }\n\n // Update timestamp only\n const updateResult = await this.repository.update(record.id, false);\n if (updateResult.isFail()) {\n return Result.fail(new UpdateEntryLockError(updateResult.error));\n }\n\n return Result.ok(updateResult.value);\n }\n}\n\nexport const UpdateEntryLockUseCase = UseCaseAbstraction.createImplementation({\n implementation: UpdateEntryLockUseCaseImpl,\n dependencies: [\n GetLockRecordUseCase,\n LockEntryUseCase,\n UpdateEntryLockRepository,\n IdentityContext\n ]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SACIC,sBAAsB,IAAIC,kBAAkB,EAC5CC,yBAAyB;AAG7B,SAASC,oBAAoB;AAC7B,SAASC,gBAAgB;AACzB,SAASC,eAAe,QAAQ,6DAA6D;AAE7F,SACIC,uBAAuB,EACvBC,qBAAqB,EACrBC,oBAAoB;AAGxB,MAAMC,0BAA0B,CAAyC;EACrEC,WAAWA,CACCC,aAA6C,EAC7CC,SAAqC,EACrCC,UAA+C,EAC/CC,eAA0C,EACpD;IAAA,KAJUH,aAA6C,GAA7CA,aAA6C;IAAA,KAC7CC,SAAqC,GAArCA,SAAqC;IAAA,KACrCC,UAA+C,GAA/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OAAO7B,MAAM,CAACsB,IAAI,CACd,IAAId,qBAAqB,CAAC;QACtByB,SAAS,EAAEH,QAAQ,CAACD,EAAE;QACtBK,QAAQ,EAAET,MAAM,CAACO,QAAQ,CAACH;MAC9B,CAAC,CACL,CAAC;IACL;;IAEA;IACA,MAAMF,YAAY,GAAG,MAAM,IAAI,CAACb,UAAU,CAACc,MAAM,CAACH,MAAM,CAACI,EAAE,EAAE,KAAK,CAAC;IACnE,IAAIF,YAAY,CAACR,MAAM,CAAC,CAAC,EAAE;MACvB,OAAOnB,MAAM,CAACsB,IAAI,CAAC,IAAIb,oBAAoB,CAACkB,YAAY,CAACP,KAAK,CAAC,CAAC;IACpE;IAEA,OAAOpB,MAAM,CAACuB,EAAE,CAACI,YAAY,CAACH,KAAK,CAAC;EACxC;AACJ;AAEA,OAAO,MAAMvB,sBAAsB,GAAGC,kBAAkB,CAACiC,oBAAoB,CAAC;EAC1EC,cAAc,EAAE1B,0BAA0B;EAC1C2B,YAAY,EAAE,CACVjC,oBAAoB,EACpBC,gBAAgB,EAChBF,yBAAyB,EACzBG,eAAe;AAEvB,CAAC,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
1
+ import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
2
2
  import { NotAuthorizedError } from "@webiny/api-core/features/security/shared";
3
3
  /**
4
4
  * Simple permission check. Only authenticated users can access the websockets API via GraphQL
@@ -1 +1 @@
1
- {"version":3,"names":["IdentityContext","NotAuthorizedError","checkPermissions","context","identityContext","container","resolve","identity","getIdentity","isAnonymous"],"sources":["checkPermissions.ts"],"sourcesContent":["import { IdentityContext } from \"@webiny/api-core/features/IdentityContext\";\nimport { NotAuthorizedError } from \"@webiny/api-core/features/security/shared\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\n\n/**\n * Simple permission check. Only authenticated users can access the websockets API via GraphQL\n */\nexport const checkPermissions = async (context: ApiCoreContext): Promise<void> => {\n const identityContext = context.container.resolve(IdentityContext);\n const identity = identityContext.getIdentity();\n\n if (identity.isAnonymous()) {\n throw new NotAuthorizedError();\n }\n};\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,2CAA2C;AAC3E,SAASC,kBAAkB,QAAQ,2CAA2C;AAG9E;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAG,MAAOC,OAAuB,IAAoB;EAC9E,MAAMC,eAAe,GAAGD,OAAO,CAACE,SAAS,CAACC,OAAO,CAACN,eAAe,CAAC;EAClE,MAAMO,QAAQ,GAAGH,eAAe,CAACI,WAAW,CAAC,CAAC;EAE9C,IAAID,QAAQ,CAACE,WAAW,CAAC,CAAC,EAAE;IACxB,MAAM,IAAIR,kBAAkB,CAAC,CAAC;EAClC;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["IdentityContext","NotAuthorizedError","checkPermissions","context","identityContext","container","resolve","identity","getIdentity","isAnonymous"],"sources":["checkPermissions.ts"],"sourcesContent":["import { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { NotAuthorizedError } from \"@webiny/api-core/features/security/shared\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\n\n/**\n * Simple permission check. Only authenticated users can access the websockets API via GraphQL\n */\nexport const checkPermissions = async (context: ApiCoreContext): Promise<void> => {\n const identityContext = context.container.resolve(IdentityContext);\n const identity = identityContext.getIdentity();\n\n if (identity.isAnonymous()) {\n throw new NotAuthorizedError();\n }\n};\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,6DAA6D;AAC7F,SAASC,kBAAkB,QAAQ,2CAA2C;AAG9E;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAG,MAAOC,OAAuB,IAAoB;EAC9E,MAAMC,eAAe,GAAGD,OAAO,CAACE,SAAS,CAACC,OAAO,CAACN,eAAe,CAAC;EAClE,MAAMO,QAAQ,GAAGH,eAAe,CAACI,WAAW,CAAC,CAAC;EAE9C,IAAID,QAAQ,CAACE,WAAW,CAAC,CAAC,EAAE;IACxB,MAAM,IAAIR,kBAAkB,CAAC,CAAC;EAClC;AACJ,CAAC","ignoreList":[]}
@@ -1,11 +1,11 @@
1
1
  import type { IGraphQLSchemaPlugin } from "@webiny/handler-graphql";
2
2
  import type { ApiCoreContext } from "@webiny/api-core/types/core.js";
3
3
  import { CmsModel } from "@webiny/api-headless-cms/types/model.js";
4
- import type { CmsFieldTypePlugins } from "@webiny/api-headless-cms/types/index.js";
4
+ import type { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/exports/api/cms/graphql.js";
5
5
  interface Params {
6
6
  model: CmsModel;
7
7
  models: CmsModel[];
8
- fieldTypePlugins: CmsFieldTypePlugins;
8
+ fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;
9
9
  }
10
10
  export declare const createGraphQLSchema: (params: Params) => Promise<IGraphQLSchemaPlugin<ApiCoreContext>>;
11
11
  export {};
package/graphql/schema.js CHANGED
@@ -14,33 +14,30 @@ import { UpdateEntryLockUseCase } from "../features/UpdateEntryLock/abstractions
14
14
  import { UnlockEntryUseCase } from "../features/UnlockEntry/abstractions.js";
15
15
  import { UnlockEntryRequestUseCase } from "../features/UnlockEntryRequest/abstractions.js";
16
16
  export const createGraphQLSchema = async params => {
17
- // Record locking model
18
17
  const model = params.model;
19
-
20
- // Other public models that have at least one field
21
18
  const models = params.models.filter(model => {
22
19
  return model.fields.length > 0;
23
20
  });
24
- const fieldTypePlugins = params.fieldTypePlugins;
21
+ const fieldRegistry = params.fieldRegistry;
25
22
  const recordLockingFields = renderFields({
26
23
  models,
27
24
  model,
28
25
  fields: model.fields,
29
26
  type: "manage",
30
- fieldTypePlugins
27
+ fieldRegistry
31
28
  });
32
29
  const listFilterFieldsRender = renderListFilterFields({
33
30
  model,
34
31
  fields: model.fields,
35
32
  type: "manage",
36
- fieldTypePlugins,
33
+ fieldRegistry,
37
34
  excludeFields: ["entryId"]
38
35
  });
39
36
  const sortEnumRender = renderSortEnum({
40
37
  model,
41
38
  fields: model.fields,
42
- fieldTypePlugins,
43
- sorterPlugins: []
39
+ fieldRegistry,
40
+ sorters: []
44
41
  });
45
42
  const plugin = createGraphQLSchemaPlugin({
46
43
  typeDefs: /* GraphQL */`
@@ -1 +1 @@
1
- {"version":3,"names":["resolve","resolveList","createGraphQLSchemaPlugin","renderFields","renderListFilterFields","renderSortEnum","checkPermissions","IsEntryLockedUseCase","GetLockRecordUseCase","GetLockedEntryLockRecordUseCase","ListLockRecordsUseCase","ListAllLockRecordsUseCase","LockEntryUseCase","UpdateEntryLockUseCase","UnlockEntryUseCase","UnlockEntryRequestUseCase","createGraphQLSchema","params","model","models","filter","fields","length","fieldTypePlugins","recordLockingFields","type","listFilterFieldsRender","excludeFields","sortEnumRender","sorterPlugins","plugin","typeDefs","map","f","join","allFiltersAsString","resolvers","Query","recordLocking","Mutation","RecordLockingQuery","isEntryLocked","_","args","context","useCase","container","result","execute","id","isFail","error","value","getLockRecord","getLockedEntryLockRecord","listLockRecords","listAllLockRecords","RecordLockingMutation","lockEntry","updateEntryLock","unlockEntry","force","unlockEntryRequest","name"],"sources":["schema.ts"],"sourcesContent":["import { resolve, resolveList } from \"./resolve.js\";\nimport type { IGraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { createGraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { renderFields } from \"@webiny/api-headless-cms/utils/renderFields.js\";\nimport { renderListFilterFields } from \"@webiny/api-headless-cms/utils/renderListFilterFields.js\";\nimport { renderSortEnum } from \"@webiny/api-headless-cms/utils/renderSortEnum.js\";\nimport { checkPermissions } from \"./checkPermissions.js\";\nimport { IsEntryLockedUseCase } from \"~/features/IsEntryLocked/abstractions.js\";\nimport { GetLockRecordUseCase } from \"~/features/GetLockRecord/abstractions.js\";\nimport { GetLockedEntryLockRecordUseCase } from \"~/features/GetLockedEntryLockRecord/abstractions.js\";\nimport { ListLockRecordsUseCase } from \"~/features/ListLockRecords/abstractions.js\";\nimport { ListAllLockRecordsUseCase } from \"~/features/ListAllLockRecords/abstractions.js\";\nimport { LockEntryUseCase } from \"~/features/LockEntry/abstractions.js\";\nimport { UpdateEntryLockUseCase } from \"~/features/UpdateEntryLock/abstractions.js\";\nimport { UnlockEntryUseCase } from \"~/features/UnlockEntry/abstractions.js\";\nimport { UnlockEntryRequestUseCase } from \"~/features/UnlockEntryRequest/abstractions.js\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types/model.js\";\nimport type { CmsFieldTypePlugins } from \"@webiny/api-headless-cms/types/index.js\";\n\ninterface Params {\n // Record locking model\n model: CmsModel;\n // All public models\n models: CmsModel[];\n fieldTypePlugins: CmsFieldTypePlugins;\n}\nexport const createGraphQLSchema = async (\n params: Params\n): Promise<IGraphQLSchemaPlugin<ApiCoreContext>> => {\n // Record locking model\n const model = params.model;\n\n // Other public models that have at least one field\n const models = params.models.filter(model => {\n return model.fields.length > 0;\n });\n\n const fieldTypePlugins = params.fieldTypePlugins;\n\n const recordLockingFields = renderFields({\n models,\n model,\n fields: model.fields,\n type: \"manage\",\n fieldTypePlugins\n });\n\n const listFilterFieldsRender = renderListFilterFields({\n model,\n fields: model.fields,\n type: \"manage\",\n fieldTypePlugins,\n excludeFields: [\"entryId\"]\n });\n\n const sortEnumRender = renderSortEnum({\n model,\n fields: model.fields,\n fieldTypePlugins,\n sorterPlugins: []\n });\n\n const plugin = createGraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n ${recordLockingFields.map(f => f.typeDefs).join(\"\\n\")}\n\n type RecordLockingError {\n message: String\n code: String\n data: JSON\n stack: String\n }\n\n enum RecordLockingRecordActionType {\n requested\n approved\n denied\n }\n\n type RecordLockingIdentity {\n id: String!\n displayName: String\n type: String\n }\n\n type RecordLockingRecordAction {\n id: ID!\n type: RecordLockingRecordActionType!\n message: String\n createdBy: RecordLockingIdentity!\n createdOn: DateTime!\n }\n\n type RecordLockingRecord {\n id: ID!\n lockedBy: RecordLockingIdentity!\n lockedOn: DateTime!\n updatedOn: DateTime!\n expiresOn: DateTime!\n ${recordLockingFields.map(f => f.fields).join(\"\\n\")}\n }\n\n type RecordLockingIsEntryLockedResponse {\n data: Boolean\n error: RecordLockingError\n }\n\n type RecordLockingGetLockRecordResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n type RecordLockingGetLockedEntryLockRecordResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n type RecordLockingListLockRecordsResponse {\n data: [RecordLockingRecord!]\n error: RecordLockingError\n }\n\n type RecordLockingLockEntryResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n \n type RecordLockingUpdateLockResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n type RecordLockingUnlockEntryResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n type RecordLockingUnlockEntryRequestResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n input RecordLockingListWhereInput {\n ${listFilterFieldsRender.allFiltersAsString()}\n }\n\n enum RecordLockingListSorter {\n ${sortEnumRender}\n }\n\n type RecordLockingQuery {\n _empty: String\n }\n\n type RecordLockingMutation {\n _empty: String\n }\n\n extend type RecordLockingQuery {\n isEntryLocked(id: ID!, type: String!): RecordLockingIsEntryLockedResponse!\n getLockRecord(id: ID!, type: String!): RecordLockingGetLockRecordResponse!\n # Returns lock record or null - if entry is locked in context of the current user, does not throw an error like getLockRecord if no record in the DB\n getLockedEntryLockRecord(id: ID!, type: String!): RecordLockingGetLockedEntryLockRecordResponse!\n listAllLockRecords(\n where: RecordLockingListWhereInput\n sort: [RecordLockingListSorter!]\n limit: Int\n after: String\n ): RecordLockingListLockRecordsResponse!\n # Basically same as listAllLockRecords except this one will filter out records with expired lock.\n listLockRecords(\n where: RecordLockingListWhereInput\n sort: [RecordLockingListSorter!]\n limit: Int\n after: String\n ): RecordLockingListLockRecordsResponse!\n }\n\n extend type RecordLockingMutation {\n lockEntry(id: ID!, type: String!): RecordLockingLockEntryResponse!\n updateEntryLock(id: ID!, type: String!): RecordLockingUpdateLockResponse!\n unlockEntry(id: ID!, type: String!, force: Boolean): RecordLockingUnlockEntryResponse!\n unlockEntryRequest(\n id: ID!\n type: String!\n ): RecordLockingUnlockEntryRequestResponse!\n }\n\n extend type Query {\n recordLocking: RecordLockingQuery\n }\n\n extend type Mutation {\n recordLocking: RecordLockingMutation\n }\n `,\n resolvers: {\n Query: {\n recordLocking: async () => ({})\n },\n Mutation: {\n recordLocking: async () => ({})\n },\n RecordLockingQuery: {\n async isEntryLocked(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(IsEntryLockedUseCase);\n const result = await useCase.execute({\n id: args.id,\n type: args.type\n });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n async getLockRecord(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(GetLockRecordUseCase);\n const result = await useCase.execute({\n id: args.id,\n type: args.type\n });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n async getLockedEntryLockRecord(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(GetLockedEntryLockRecordUseCase);\n const result = await useCase.execute({\n id: args.id,\n type: args.type\n });\n // Returns null if not found/expired/locked by current user\n if (result.isFail()) {\n return null;\n }\n return result.value;\n });\n },\n\n async listLockRecords(_, args, context) {\n return resolveList(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(ListLockRecordsUseCase);\n const result = await useCase.execute(args);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n listAllLockRecords(_, args, context) {\n return resolveList(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(ListAllLockRecordsUseCase);\n const result = await useCase.execute(args);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n }\n },\n RecordLockingMutation: {\n async lockEntry(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(LockEntryUseCase);\n const result = await useCase.execute({\n id: args.id,\n type: args.type\n });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n async updateEntryLock(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(UpdateEntryLockUseCase);\n const result = await useCase.execute({\n id: args.id,\n type: args.type\n });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n async unlockEntry(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(UnlockEntryUseCase);\n const result = await useCase.execute({\n id: args.id,\n type: args.type,\n force: args.force\n });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n async unlockEntryRequest(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(UnlockEntryRequestUseCase);\n const result = await useCase.execute({\n id: args.id,\n type: args.type\n });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n }\n }\n }\n });\n\n plugin.name = \"recordLocking.graphql.schema.locking\";\n\n return plugin;\n};\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,WAAW;AAE7B,SAASC,yBAAyB,QAAQ,yBAAyB;AACnE,SAASC,YAAY,QAAQ,gDAAgD;AAC7E,SAASC,sBAAsB,QAAQ,0DAA0D;AACjG,SAASC,cAAc,QAAQ,kDAAkD;AACjF,SAASC,gBAAgB;AACzB,SAASC,oBAAoB;AAC7B,SAASC,oBAAoB;AAC7B,SAASC,+BAA+B;AACxC,SAASC,sBAAsB;AAC/B,SAASC,yBAAyB;AAClC,SAASC,gBAAgB;AACzB,SAASC,sBAAsB;AAC/B,SAASC,kBAAkB;AAC3B,SAASC,yBAAyB;AAYlC,OAAO,MAAMC,mBAAmB,GAAG,MAC/BC,MAAc,IACkC;EAChD;EACA,MAAMC,KAAK,GAAGD,MAAM,CAACC,KAAK;;EAE1B;EACA,MAAMC,MAAM,GAAGF,MAAM,CAAC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,EAAE;cACXxB,IAAI,EAAEkB,IAAI,CAAClB;YACf,CAAC,CAAC;YACF,IAAIsB,MAAM,CAACG,MAAM,CAAC,CAAC,EAAE;cACjB,MAAMH,MAAM,CAACI,KAAK;YACtB;YACA,OAAOJ,MAAM,CAACK,KAAK;UACvB,CAAC,CAAC;QACN;MACJ;IACJ;EACJ,CAAC,CAAC;EAEFtB,MAAM,CAACiC,IAAI,GAAG,sCAAsC;EAEpD,OAAOjC,MAAM;AACjB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["resolve","resolveList","createGraphQLSchemaPlugin","renderFields","renderListFilterFields","renderSortEnum","checkPermissions","IsEntryLockedUseCase","GetLockRecordUseCase","GetLockedEntryLockRecordUseCase","ListLockRecordsUseCase","ListAllLockRecordsUseCase","LockEntryUseCase","UpdateEntryLockUseCase","UnlockEntryUseCase","UnlockEntryRequestUseCase","createGraphQLSchema","params","model","models","filter","fields","length","fieldRegistry","recordLockingFields","type","listFilterFieldsRender","excludeFields","sortEnumRender","sorters","plugin","typeDefs","map","f","join","allFiltersAsString","resolvers","Query","recordLocking","Mutation","RecordLockingQuery","isEntryLocked","_","args","context","useCase","container","result","execute","id","isFail","error","value","getLockRecord","getLockedEntryLockRecord","listLockRecords","listAllLockRecords","RecordLockingMutation","lockEntry","updateEntryLock","unlockEntry","force","unlockEntryRequest","name"],"sources":["schema.ts"],"sourcesContent":["import { resolve, resolveList } from \"./resolve.js\";\nimport type { IGraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { createGraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { renderFields } from \"@webiny/api-headless-cms/utils/renderFields.js\";\nimport { renderListFilterFields } from \"@webiny/api-headless-cms/utils/renderListFilterFields.js\";\nimport { renderSortEnum } from \"@webiny/api-headless-cms/utils/renderSortEnum.js\";\nimport { checkPermissions } from \"./checkPermissions.js\";\nimport { IsEntryLockedUseCase } from \"~/features/IsEntryLocked/abstractions.js\";\nimport { GetLockRecordUseCase } from \"~/features/GetLockRecord/abstractions.js\";\nimport { GetLockedEntryLockRecordUseCase } from \"~/features/GetLockedEntryLockRecord/abstractions.js\";\nimport { ListLockRecordsUseCase } from \"~/features/ListLockRecords/abstractions.js\";\nimport { ListAllLockRecordsUseCase } from \"~/features/ListAllLockRecords/abstractions.js\";\nimport { LockEntryUseCase } from \"~/features/LockEntry/abstractions.js\";\nimport { UpdateEntryLockUseCase } from \"~/features/UpdateEntryLock/abstractions.js\";\nimport { UnlockEntryUseCase } from \"~/features/UnlockEntry/abstractions.js\";\nimport { UnlockEntryRequestUseCase } from \"~/features/UnlockEntryRequest/abstractions.js\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types/model.js\";\nimport type { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\n\ninterface Params {\n model: CmsModel;\n models: CmsModel[];\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n}\nexport const createGraphQLSchema = async (\n params: Params\n): Promise<IGraphQLSchemaPlugin<ApiCoreContext>> => {\n const model = params.model;\n\n const models = params.models.filter(model => {\n return model.fields.length > 0;\n });\n\n const fieldRegistry = params.fieldRegistry;\n\n const recordLockingFields = renderFields({\n models,\n model,\n fields: model.fields,\n type: \"manage\",\n fieldRegistry\n });\n\n const listFilterFieldsRender = renderListFilterFields({\n model,\n fields: model.fields,\n type: \"manage\",\n fieldRegistry,\n excludeFields: [\"entryId\"]\n });\n\n const sortEnumRender = renderSortEnum({\n model,\n fields: model.fields,\n fieldRegistry,\n sorters: []\n });\n\n const plugin = createGraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n ${recordLockingFields.map(f => f.typeDefs).join(\"\\n\")}\n\n type RecordLockingError {\n message: String\n code: String\n data: JSON\n stack: String\n }\n\n enum RecordLockingRecordActionType {\n requested\n approved\n denied\n }\n\n type RecordLockingIdentity {\n id: String!\n displayName: String\n type: String\n }\n\n type RecordLockingRecordAction {\n id: ID!\n type: RecordLockingRecordActionType!\n message: String\n createdBy: RecordLockingIdentity!\n createdOn: DateTime!\n }\n\n type RecordLockingRecord {\n id: ID!\n lockedBy: RecordLockingIdentity!\n lockedOn: DateTime!\n updatedOn: DateTime!\n expiresOn: DateTime!\n ${recordLockingFields.map(f => f.fields).join(\"\\n\")}\n }\n\n type RecordLockingIsEntryLockedResponse {\n data: Boolean\n error: RecordLockingError\n }\n\n type RecordLockingGetLockRecordResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n type RecordLockingGetLockedEntryLockRecordResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n type RecordLockingListLockRecordsResponse {\n data: [RecordLockingRecord!]\n error: RecordLockingError\n }\n\n type RecordLockingLockEntryResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n \n type RecordLockingUpdateLockResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n type RecordLockingUnlockEntryResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n type RecordLockingUnlockEntryRequestResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n input RecordLockingListWhereInput {\n ${listFilterFieldsRender.allFiltersAsString()}\n }\n\n enum RecordLockingListSorter {\n ${sortEnumRender}\n }\n\n type RecordLockingQuery {\n _empty: String\n }\n\n type RecordLockingMutation {\n _empty: String\n }\n\n extend type RecordLockingQuery {\n isEntryLocked(id: ID!, type: String!): RecordLockingIsEntryLockedResponse!\n getLockRecord(id: ID!, type: String!): RecordLockingGetLockRecordResponse!\n # Returns lock record or null - if entry is locked in context of the current user, does not throw an error like getLockRecord if no record in the DB\n getLockedEntryLockRecord(id: ID!, type: String!): RecordLockingGetLockedEntryLockRecordResponse!\n listAllLockRecords(\n where: RecordLockingListWhereInput\n sort: [RecordLockingListSorter!]\n limit: Int\n after: String\n ): RecordLockingListLockRecordsResponse!\n # Basically same as listAllLockRecords except this one will filter out records with expired lock.\n listLockRecords(\n where: RecordLockingListWhereInput\n sort: [RecordLockingListSorter!]\n limit: Int\n after: String\n ): RecordLockingListLockRecordsResponse!\n }\n\n extend type RecordLockingMutation {\n lockEntry(id: ID!, type: String!): RecordLockingLockEntryResponse!\n updateEntryLock(id: ID!, type: String!): RecordLockingUpdateLockResponse!\n unlockEntry(id: ID!, type: String!, force: Boolean): RecordLockingUnlockEntryResponse!\n unlockEntryRequest(\n id: ID!\n type: String!\n ): RecordLockingUnlockEntryRequestResponse!\n }\n\n extend type Query {\n recordLocking: RecordLockingQuery\n }\n\n extend type Mutation {\n recordLocking: RecordLockingMutation\n }\n `,\n resolvers: {\n Query: {\n recordLocking: async () => ({})\n },\n Mutation: {\n recordLocking: async () => ({})\n },\n RecordLockingQuery: {\n async isEntryLocked(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(IsEntryLockedUseCase);\n const result = await useCase.execute({\n id: args.id,\n type: args.type\n });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n async getLockRecord(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(GetLockRecordUseCase);\n const result = await useCase.execute({\n id: args.id,\n type: args.type\n });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n async getLockedEntryLockRecord(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(GetLockedEntryLockRecordUseCase);\n const result = await useCase.execute({\n id: args.id,\n type: args.type\n });\n // Returns null if not found/expired/locked by current user\n if (result.isFail()) {\n return null;\n }\n return result.value;\n });\n },\n\n async listLockRecords(_, args, context) {\n return resolveList(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(ListLockRecordsUseCase);\n const result = await useCase.execute(args);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n listAllLockRecords(_, args, context) {\n return resolveList(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(ListAllLockRecordsUseCase);\n const result = await useCase.execute(args);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n }\n },\n RecordLockingMutation: {\n async lockEntry(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(LockEntryUseCase);\n const result = await useCase.execute({\n id: args.id,\n type: args.type\n });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n async updateEntryLock(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(UpdateEntryLockUseCase);\n const result = await useCase.execute({\n id: args.id,\n type: args.type\n });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n async unlockEntry(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(UnlockEntryUseCase);\n const result = await useCase.execute({\n id: args.id,\n type: args.type,\n force: args.force\n });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n async unlockEntryRequest(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(UnlockEntryRequestUseCase);\n const result = await useCase.execute({\n id: args.id,\n type: args.type\n });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n }\n }\n }\n });\n\n plugin.name = \"recordLocking.graphql.schema.locking\";\n\n return plugin;\n};\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,WAAW;AAE7B,SAASC,yBAAyB,QAAQ,yBAAyB;AACnE,SAASC,YAAY,QAAQ,gDAAgD;AAC7E,SAASC,sBAAsB,QAAQ,0DAA0D;AACjG,SAASC,cAAc,QAAQ,kDAAkD;AACjF,SAASC,gBAAgB;AACzB,SAASC,oBAAoB;AAC7B,SAASC,oBAAoB;AAC7B,SAASC,+BAA+B;AACxC,SAASC,sBAAsB;AAC/B,SAASC,yBAAyB;AAClC,SAASC,gBAAgB;AACzB,SAASC,sBAAsB;AAC/B,SAASC,kBAAkB;AAC3B,SAASC,yBAAyB;AAUlC,OAAO,MAAMC,mBAAmB,GAAG,MAC/BC,MA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ACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkBR,sBAAsB,CAACS,kBAAkB,CAAC,CAAC;AAC7D;AACA;AACA;AACA,kBAAkBP,cAAc;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;IACDQ,SAAS,EAAE;MACPC,KAAK,EAAE;QACHC,aAAa,EAAE,MAAAA,CAAA,MAAa,CAAC,CAAC;MAClC,CAAC;MACDC,QAAQ,EAAE;QACND,aAAa,EAAE,MAAAA,CAAA,MAAa,CAAC,CAAC;MAClC,CAAC;MACDE,kBAAkB,EAAE;QAChB,MAAMC,aAAaA,CAACC,CAAC,EAAEC,IAAI,EAAEC,OAAO,EAAE;UAClC,OAAO5C,OAAO,CAAC,YAAY;YACvB,MAAMM,gBAAgB,CAACsC,OAAO,CAAC;YAC/B,MAAMC,OAAO,GAAGD,OAAO,CAACE,SAAS,CAAC9C,OAAO,CAACO,oBAAoB,CAAC;YAC/D,MAAMwC,MAAM,GAAG,MAAMF,OAAO,CAACG,OAAO,CAAC;cACjCC,EAAE,EAAEN,IAAI,CAACM,EAAE;cACXxB,IAAI,EAAEkB,IAAI,CAAClB;YACf,CAAC,CAAC;YACF,IAAIsB,MAAM,CAACG,MAAM,CAAC,CAAC,EAAE;cACjB,MAAMH,MAAM,CAACI,KAAK;YACtB;YACA,OAAOJ,MAAM,CAACK,KAAK;UACvB,CAAC,CAAC;QACN,CAAC;QACD,MAAMC,aAAaA,CAACX,CAAC,EAAE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gC,MAAM,GAAG,MAAMF,OAAO,CAACG,OAAO,CAAC;cACjCC,EAAE,EAAEN,IAAI,CAACM,EAAE;cACXxB,IAAI,EAAEkB,IAAI,CAAClB;YACf,CAAC,CAAC;YACF,IAAIsB,MAAM,CAACG,MAAM,CAAC,CAAC,EAAE;cACjB,MAAMH,MAAM,CAACI,KAAK;YACtB;YACA,OAAOJ,MAAM,CAACK,KAAK;UACvB,CAAC,CAAC;QACN;MACJ;IACJ;EACJ,CAAC,CAAC;EAEFtB,MAAM,CAACiC,IAAI,GAAG,sCAAsC;EAEpD,OAAOjC,MAAM;AACjB,CAAC","ignoreList":[]}
package/index.js CHANGED
@@ -6,9 +6,9 @@ import { RecordLockingModel, RECORD_LOCKING_MODEL_ID } from "./domain/RecordLock
6
6
  import { getTimeout } from "./utils/getTimeout.js";
7
7
  import { RecordLockingFeature } from "./features/RecordLockingFeature.js";
8
8
  import { createGraphQLSchema } from "./graphql/schema.js";
9
- import { createFieldTypePluginRecords } from "@webiny/api-headless-cms/graphql/schema/createFieldTypePluginRecords.js";
10
9
  import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
11
10
  import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
11
+ import { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/exports/api/cms/graphql.js";
12
12
  const createContextPlugin = params => {
13
13
  const plugin = new ContextPlugin(async context => {
14
14
  const tenantContext = context.container.resolve(TenantContext);
@@ -37,12 +37,13 @@ const createContextPlugin = params => {
37
37
  })]);
38
38
  return [model.value, publicModels.value];
39
39
  });
40
+ const fieldRegistry = context.container.resolve(CmsModelFieldToGraphQLRegistry);
40
41
 
41
42
  // Register GraphQL schema plugin
42
43
  const graphQlPlugin = await createGraphQLSchema({
43
44
  model,
44
45
  models: publicModels,
45
- fieldTypePlugins: createFieldTypePluginRecords(context.plugins)
46
+ fieldRegistry
46
47
  });
47
48
  context.plugins.register(graphQlPlugin);
48
49
 
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["ContextPlugin","WcpContext","ListModelsUseCase","GetModelUseCase","RecordLockingModel","RECORD_LOCKING_MODEL_ID","getTimeout","RecordLockingFeature","createGraphQLSchema","createFieldTypePluginRecords","IdentityContext","TenantContext","createContextPlugin","params","plugin","context","tenantContext","container","resolve","identityContext","wcp","getModel","listModels","canUseRecordLocking","getTenant","register","timeout","model","publicModels","withoutAuthorization","Promise","all","execute","includePrivate","value","graphQlPlugin","models","fieldTypePlugins","plugins","name","createRecordLocking"],"sources":["index.ts"],"sourcesContent":["import type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { WcpContext } from \"@webiny/api-core/features/wcp/WcpContext/index.js\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel\";\nimport { RecordLockingModel, RECORD_LOCKING_MODEL_ID } from \"~/domain/RecordLockingModel.js\";\nimport { getTimeout } from \"~/utils/getTimeout.js\";\nimport { RecordLockingFeature } from \"~/features/RecordLockingFeature.js\";\nimport { createGraphQLSchema } from \"~/graphql/schema.js\";\nimport { createFieldTypePluginRecords } from \"@webiny/api-headless-cms/graphql/schema/createFieldTypePluginRecords.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\n\nexport interface ICreateContextPluginParams {\n /**\n * A number of seconds after the last activity to wait before the record is automatically unlocked.\n */\n timeout?: number;\n}\n\nconst createContextPlugin = (params?: ICreateContextPluginParams) => {\n const plugin = new ContextPlugin<ApiCoreContext>(async context => {\n const tenantContext = context.container.resolve(TenantContext);\n const identityContext = context.container.resolve(IdentityContext);\n const wcp = context.container.resolve(WcpContext);\n const getModel = context.container.resolve(GetModelUseCase);\n const listModels = context.container.resolve(ListModelsUseCase);\n\n if (!wcp.canUseRecordLocking() || !tenantContext.getTenant()) {\n return;\n }\n\n // Register the private model\n context.container.register(RecordLockingModel);\n\n // Determine timeout value\n const timeout = getTimeout(params?.timeout);\n\n // Fetch CMS model to use for storing record locking data\n const [model, publicModels] = await identityContext.withoutAuthorization(async () => {\n const [model, publicModels] = await Promise.all([\n // Get a record locking model\n getModel.execute(RECORD_LOCKING_MODEL_ID),\n // Get all models\n listModels.execute({ includePrivate: false })\n ]);\n\n return [model.value, publicModels.value];\n });\n\n // Register GraphQL schema plugin\n const graphQlPlugin = await createGraphQLSchema({\n model,\n models: publicModels,\n fieldTypePlugins: createFieldTypePluginRecords(context.plugins)\n });\n\n context.plugins.register(graphQlPlugin);\n\n // Register features\n RecordLockingFeature.register(context.container, {\n timeout,\n model\n });\n });\n plugin.name = \"context.recordLocking\";\n\n return plugin;\n};\n\nexport const createRecordLocking = (params?: ICreateContextPluginParams) => {\n return [createContextPlugin(params)];\n};\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,aAAa;AAC3C,SAASC,UAAU,QAAQ,mDAAmD;AAC9E,SAASC,iBAAiB,QAAQ,2DAA2D;AAC7F,SAASC,eAAe,QAAQ,yDAAyD;AACzF,SAASC,kBAAkB,EAAEC,uBAAuB;AACpD,SAASC,UAAU;AACnB,SAASC,oBAAoB;AAC7B,SAASC,mBAAmB;AAC5B,SAASC,4BAA4B,QAAQ,yEAAyE;AACtH,SAASC,eAAe,QAAQ,6DAA6D;AAC7F,SAASC,aAAa,QAAQ,0DAA0D;AASxF,MAAMC,mBAAmB,GAAIC,MAAmC,IAAK;EACjE,MAAMC,MAAM,GAAG,IAAId,aAAa,CAAiB,MAAMe,OAAO,IAAI;IAC9D,MAAMC,aAAa,GAAGD,OAAO,CAACE,SAAS,CAACC,OAAO,CAACP,aAAa,CAAC;IAC9D,MAAMQ,eAAe,GAAGJ,OAAO,CAACE,SAAS,CAACC,OAAO,CAACR,eAAe,CAAC;IAClE,MAAMU,GAAG,GAAGL,OAAO,CAACE,SAAS,CA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BAAuB;EAErC,OAAOzB,MAAM;AACjB,CAAC;AAED,OAAO,MAAM0B,mBAAmB,GAAI3B,MAAmC,IAAK;EACxE,OAAO,CAACD,mBAAmB,CAACC,MAAM,CAAC,CAAC;AACxC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["ContextPlugin","WcpContext","ListModelsUseCase","GetModelUseCase","RecordLockingModel","RECORD_LOCKING_MODEL_ID","getTimeout","RecordLockingFeature","createGraphQLSchema","IdentityContext","TenantContext","CmsModelFieldToGraphQLRegistry","createContextPlugin","params","plugin","context","tenantContext","container","resolve","identityContext","wcp","getModel","listModels","canUseRecordLocking","getTenant","register","timeout","model","publicModels","withoutAuthorization","Promise","all","execute","includePrivate","value","fieldRegistry","graphQlPlugin","models","plugins","name","createRecordLocking"],"sources":["index.ts"],"sourcesContent":["import type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { WcpContext } from \"@webiny/api-core/features/wcp/WcpContext/index.js\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel\";\nimport { RecordLockingModel, RECORD_LOCKING_MODEL_ID } from \"~/domain/RecordLockingModel.js\";\nimport { getTimeout } from \"~/utils/getTimeout.js\";\nimport { RecordLockingFeature } from \"~/features/RecordLockingFeature.js\";\nimport { createGraphQLSchema } from \"~/graphql/schema.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\n\nexport interface ICreateContextPluginParams {\n /**\n * A number of seconds after the last activity to wait before the record is automatically unlocked.\n */\n timeout?: number;\n}\n\nconst createContextPlugin = (params?: ICreateContextPluginParams) => {\n const plugin = new ContextPlugin<ApiCoreContext>(async context => {\n const tenantContext = context.container.resolve(TenantContext);\n const identityContext = context.container.resolve(IdentityContext);\n const wcp = context.container.resolve(WcpContext);\n const getModel = context.container.resolve(GetModelUseCase);\n const listModels = context.container.resolve(ListModelsUseCase);\n\n if (!wcp.canUseRecordLocking() || !tenantContext.getTenant()) {\n return;\n }\n\n // Register the private model\n context.container.register(RecordLockingModel);\n\n // Determine timeout value\n const timeout = getTimeout(params?.timeout);\n\n // Fetch CMS model to use for storing record locking data\n const [model, publicModels] = await identityContext.withoutAuthorization(async () => {\n const [model, publicModels] = await Promise.all([\n // Get a record locking model\n getModel.execute(RECORD_LOCKING_MODEL_ID),\n // Get all models\n listModels.execute({ includePrivate: false })\n ]);\n\n return [model.value, publicModels.value];\n });\n\n const fieldRegistry = context.container.resolve(CmsModelFieldToGraphQLRegistry);\n\n // Register GraphQL schema plugin\n const graphQlPlugin = await createGraphQLSchema({\n model,\n models: publicModels,\n fieldRegistry\n });\n\n context.plugins.register(graphQlPlugin);\n\n // Register features\n RecordLockingFeature.register(context.container, {\n timeout,\n model\n });\n });\n plugin.name = \"context.recordLocking\";\n\n return plugin;\n};\n\nexport const createRecordLocking = (params?: ICreateContextPluginParams) => {\n return [createContextPlugin(params)];\n};\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,aAAa;AAC3C,SAASC,UAAU,QAAQ,mDAAmD;AAC9E,SAASC,iBAAiB,QAAQ,2DAA2D;AAC7F,SAASC,eAAe,QAAQ,yDAAyD;AACzF,SAASC,kBAAkB,EAAEC,uBAAuB;AACpD,SAASC,UAAU;AACnB,SAASC,oBAAoB;AAC7B,SAASC,mBAAmB;AAC5B,SAASC,eAAe,QAAQ,6DAA6D;AAC7F,SAASC,aAAa,QAAQ,0DAA0D;AACxF,SAASC,8BAA8B,QAAQ,qDAAqD;AASpG,MAAMC,mBAAmB,GAAIC,MAAmC,IAAK;EACjE,MAAMC,MAAM,GAAG,IAAId,aAAa,CAAiB,MAAMe,OAAO,IAAI;IAC9D,MAAMC,aAAa,GAAGD,O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CAACuB,OAAO,CAACb,QAAQ,CAACW,aAAa,CAAC;;IAEvC;IACA7B,oBAAoB,CAACkB,QAAQ,CAACV,OAAO,CAACE,SAAS,EAAE;MAC7CS,OAAO;MACPC;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;EACFb,MAAM,CAACyB,IAAI,GAAG,uBAAuB;EAErC,OAAOzB,MAAM;AACjB,CAAC;AAED,OAAO,MAAM0B,mBAAmB,GAAI3B,MAAmC,IAAK;EACxE,OAAO,CAACD,mBAAmB,CAACC,MAAM,CAAC,CAAC;AACxC,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-record-locking",
3
- "version": "6.1.0",
3
+ "version": "6.2.0",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -13,30 +13,30 @@
13
13
  ],
14
14
  "license": "MIT",
15
15
  "dependencies": {
16
- "@webiny/api": "6.1.0",
17
- "@webiny/api-headless-cms": "6.1.0",
18
- "@webiny/api-websockets": "6.1.0",
19
- "@webiny/feature": "6.1.0",
20
- "@webiny/handler": "6.1.0",
21
- "@webiny/handler-aws": "6.1.0",
22
- "@webiny/handler-graphql": "6.1.0",
23
- "@webiny/plugins": "6.1.0",
24
- "@webiny/utils": "6.1.0"
16
+ "@webiny/api": "6.2.0",
17
+ "@webiny/api-headless-cms": "6.2.0",
18
+ "@webiny/api-websockets": "6.2.0",
19
+ "@webiny/feature": "6.2.0",
20
+ "@webiny/handler": "6.2.0",
21
+ "@webiny/handler-aws": "6.2.0",
22
+ "@webiny/handler-graphql": "6.2.0",
23
+ "@webiny/plugins": "6.2.0",
24
+ "@webiny/utils": "6.2.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@webiny/api-core": "6.1.0",
28
- "@webiny/build-tools": "6.1.0",
29
- "@webiny/project-utils": "6.1.0",
30
- "@webiny/wcp": "6.1.0",
27
+ "@webiny/api-core": "6.2.0",
28
+ "@webiny/build-tools": "6.2.0",
29
+ "@webiny/project-utils": "6.2.0",
30
+ "@webiny/wcp": "6.2.0",
31
31
  "graphql": "16.13.2",
32
32
  "rimraf": "6.1.3",
33
33
  "type-fest": "5.5.0",
34
34
  "typescript": "5.9.3",
35
- "vitest": "4.1.2"
35
+ "vitest": "4.1.4"
36
36
  },
37
37
  "publishConfig": {
38
38
  "access": "public",
39
39
  "directory": "dist"
40
40
  },
41
- "gitHead": "65e0ac1889b3392c99b8cac6cde508e1e831c715"
41
+ "gitHead": "3d3148358b6febbc857371930871743bec3b3939"
42
42
  }