@webiny/api-record-locking 5.42.1-beta.0 → 5.42.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/crud/crud.d.ts +2 -1
- package/crud/crud.js +20 -8
- package/crud/crud.js.map +1 -1
- package/index.d.ts +4 -1
- package/index.js +5 -4
- package/index.js.map +1 -1
- package/package.json +18 -18
- package/types.d.ts +13 -5
- package/types.js +6 -6
- package/types.js.map +1 -1
- package/useCases/GetLockRecord/GetLockRecordUseCase.d.ts +5 -2
- package/useCases/GetLockRecord/GetLockRecordUseCase.js +2 -2
- package/useCases/GetLockRecord/GetLockRecordUseCase.js.map +1 -1
- package/useCases/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.d.ts +4 -4
- package/useCases/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js.map +1 -1
- package/useCases/IsEntryLocked/IsEntryLockedUseCase.d.ts +4 -4
- package/useCases/IsEntryLocked/IsEntryLockedUseCase.js.map +1 -1
- package/useCases/KickOutCurrentUser/KickOutCurrentUserUseCase.d.ts +2 -2
- package/useCases/KickOutCurrentUser/KickOutCurrentUserUseCase.js.map +1 -1
- package/useCases/ListAllLockRecordsUseCase/ListAllLockRecordsUseCase.d.ts +5 -2
- package/useCases/ListAllLockRecordsUseCase/ListAllLockRecordsUseCase.js +4 -2
- package/useCases/ListAllLockRecordsUseCase/ListAllLockRecordsUseCase.js.map +1 -1
- package/useCases/ListLockRecordsUseCase/ListLockRecordsUseCase.d.ts +2 -2
- package/useCases/ListLockRecordsUseCase/ListLockRecordsUseCase.js.map +1 -1
- package/useCases/LockEntryUseCase/LockEntryUseCase.d.ts +6 -3
- package/useCases/LockEntryUseCase/LockEntryUseCase.js +2 -2
- package/useCases/LockEntryUseCase/LockEntryUseCase.js.map +1 -1
- package/useCases/UnlockEntryUseCase/UnlockEntryUseCase.d.ts +6 -6
- package/useCases/UnlockEntryUseCase/UnlockEntryUseCase.js +20 -4
- package/useCases/UnlockEntryUseCase/UnlockEntryUseCase.js.map +1 -1
- package/useCases/UnlockRequestUseCase/UnlockEntryRequestUseCase.d.ts +6 -3
- package/useCases/UnlockRequestUseCase/UnlockEntryRequestUseCase.js +3 -3
- package/useCases/UnlockRequestUseCase/UnlockEntryRequestUseCase.js.map +1 -1
- package/useCases/UpdateEntryLock/UpdateEntryLockUseCase.d.ts +7 -4
- package/useCases/UpdateEntryLock/UpdateEntryLockUseCase.js +2 -2
- package/useCases/UpdateEntryLock/UpdateEntryLockUseCase.js.map +1 -1
- package/useCases/index.d.ts +12 -11
- package/useCases/index.js +19 -8
- package/useCases/index.js.map +1 -1
- package/useCases/types.d.ts +5 -0
- package/useCases/types.js +7 -0
- package/useCases/types.js.map +1 -0
- package/utils/calculateExpiresOn.d.ts +1 -1
- package/utils/calculateExpiresOn.js +1 -3
- package/utils/calculateExpiresOn.js.map +1 -1
- package/utils/convertEntryToLockRecord.d.ts +3 -4
- package/utils/convertEntryToLockRecord.js +7 -7
- package/utils/convertEntryToLockRecord.js.map +1 -1
- package/utils/getTimeout.d.ts +3 -2
- package/utils/getTimeout.js +6 -2
- package/utils/getTimeout.js.map +1 -1
- package/utils/isLockedFactory.d.ts +1 -1
- package/utils/isLockedFactory.js +1 -2
- package/utils/isLockedFactory.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ListLockRecordsUseCase","constructor","params","listAllLockRecordsUseCase","timeout","getIdentity","execute","input","identity","where","createdBy_not","id","savedOn_gte","Date","getTime","exports"],"sources":["ListLockRecordsUseCase.ts"],"sourcesContent":["import {\n IListLockRecordsUseCase,\n IListLockRecordsUseCaseExecuteParams,\n IListLockRecordsUseCaseExecuteResponse\n} from \"~/abstractions/IListLockRecordsUseCase\";\nimport { IGetIdentity } from \"~/types\";\n\nexport interface IListLockRecordsUseCaseParams {\n listAllLockRecordsUseCase: IListLockRecordsUseCase;\n timeout: number;\n getIdentity: IGetIdentity;\n}\n\nexport class ListLockRecordsUseCase implements IListLockRecordsUseCase {\n private readonly listAllLockRecordsUseCase: IListLockRecordsUseCase;\n private readonly timeout: number;\n private readonly getIdentity: IGetIdentity;\n\n public constructor(params: IListLockRecordsUseCaseParams) {\n this.listAllLockRecordsUseCase = params.listAllLockRecordsUseCase;\n this.timeout = params.timeout;\n this.getIdentity = params.getIdentity;\n }\n public async execute(\n input: IListLockRecordsUseCaseExecuteParams\n ): Promise<IListLockRecordsUseCaseExecuteResponse> {\n const identity = this.getIdentity();\n return this.listAllLockRecordsUseCase.execute({\n ...input,\n where: {\n ...input.where,\n createdBy_not: identity.id,\n savedOn_gte: new Date(new Date().getTime() - this.timeout)\n }\n });\n }\n}\n"],"mappings":";;;;;;AAaO,MAAMA,sBAAsB,CAAoC;EAK5DC,WAAWA,CAACC,MAAqC,EAAE;IACtD,IAAI,CAACC,yBAAyB,GAAGD,MAAM,CAACC,yBAAyB;IACjE,IAAI,CAACC,OAAO,GAAGF,MAAM,CAACE,OAAO;IAC7B,IAAI,CAACC,WAAW,GAAGH,MAAM,CAACG,WAAW;EACzC;EACA,MAAaC,OAAOA,CAChBC,KAA2C,EACI;IAC/C,MAAMC,QAAQ,GAAG,IAAI,CAACH,WAAW,CAAC,CAAC;IACnC,OAAO,IAAI,CAACF,yBAAyB,CAACG,OAAO,CAAC;MAC1C,GAAGC,KAAK;MACRE,KAAK,EAAE;QACH,GAAGF,KAAK,CAACE,KAAK;QACdC,aAAa,EAAEF,QAAQ,CAACG,EAAE;QAC1BC,WAAW,EAAE,IAAIC,IAAI,CAAC,IAAIA,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC,GAAG,IAAI,CAACV,OAAO;MAC7D;IACJ,CAAC,CAAC;EACN;AACJ;AAACW,OAAA,CAAAf,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["ListLockRecordsUseCase","constructor","params","listAllLockRecordsUseCase","timeout","getIdentity","execute","input","identity","where","createdBy_not","id","savedOn_gte","Date","getTime","exports"],"sources":["ListLockRecordsUseCase.ts"],"sourcesContent":["import type {\n IListLockRecordsUseCase,\n IListLockRecordsUseCaseExecuteParams,\n IListLockRecordsUseCaseExecuteResponse\n} from \"~/abstractions/IListLockRecordsUseCase\";\nimport type { IGetIdentity } from \"~/types\";\n\nexport interface IListLockRecordsUseCaseParams {\n listAllLockRecordsUseCase: IListLockRecordsUseCase;\n timeout: number;\n getIdentity: IGetIdentity;\n}\n\nexport class ListLockRecordsUseCase implements IListLockRecordsUseCase {\n private readonly listAllLockRecordsUseCase: IListLockRecordsUseCase;\n private readonly timeout: number;\n private readonly getIdentity: IGetIdentity;\n\n public constructor(params: IListLockRecordsUseCaseParams) {\n this.listAllLockRecordsUseCase = params.listAllLockRecordsUseCase;\n this.timeout = params.timeout;\n this.getIdentity = params.getIdentity;\n }\n public async execute(\n input: IListLockRecordsUseCaseExecuteParams\n ): Promise<IListLockRecordsUseCaseExecuteResponse> {\n const identity = this.getIdentity();\n return this.listAllLockRecordsUseCase.execute({\n ...input,\n where: {\n ...input.where,\n createdBy_not: identity.id,\n savedOn_gte: new Date(new Date().getTime() - this.timeout)\n }\n });\n }\n}\n"],"mappings":";;;;;;AAaO,MAAMA,sBAAsB,CAAoC;EAK5DC,WAAWA,CAACC,MAAqC,EAAE;IACtD,IAAI,CAACC,yBAAyB,GAAGD,MAAM,CAACC,yBAAyB;IACjE,IAAI,CAACC,OAAO,GAAGF,MAAM,CAACE,OAAO;IAC7B,IAAI,CAACC,WAAW,GAAGH,MAAM,CAACG,WAAW;EACzC;EACA,MAAaC,OAAOA,CAChBC,KAA2C,EACI;IAC/C,MAAMC,QAAQ,GAAG,IAAI,CAACH,WAAW,CAAC,CAAC;IACnC,OAAO,IAAI,CAACF,yBAAyB,CAACG,OAAO,CAAC;MAC1C,GAAGC,KAAK;MACRE,KAAK,EAAE;QACH,GAAGF,KAAK,CAACE,KAAK;QACdC,aAAa,EAAEF,QAAQ,CAACG,EAAE;QAC1BC,WAAW,EAAE,IAAIC,IAAI,CAAC,IAAIA,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,CAAC,GAAG,IAAI,CAACV,OAAO;MAC7D;IACJ,CAAC,CAAC;EACN;AACJ;AAACW,OAAA,CAAAf,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { ILockEntryUseCase, ILockEntryUseCaseExecuteParams } from "../../abstractions/ILockEntryUseCase";
|
|
2
|
-
import { IRecordLockingLockRecord, IRecordLockingModelManager } from "../../types";
|
|
3
|
-
import { IIsEntryLockedUseCase } from "../../abstractions/IIsEntryLocked";
|
|
1
|
+
import type { ILockEntryUseCase, ILockEntryUseCaseExecuteParams } from "../../abstractions/ILockEntryUseCase";
|
|
2
|
+
import type { IRecordLockingLockRecord, IRecordLockingModelManager } from "../../types";
|
|
3
|
+
import type { IIsEntryLockedUseCase } from "../../abstractions/IIsEntryLocked";
|
|
4
|
+
import type { ConvertEntryToLockRecordCb } from "../types";
|
|
4
5
|
export interface ILockEntryUseCaseParams {
|
|
5
6
|
isEntryLockedUseCase: IIsEntryLockedUseCase;
|
|
6
7
|
getManager(): Promise<IRecordLockingModelManager>;
|
|
8
|
+
convert: ConvertEntryToLockRecordCb;
|
|
7
9
|
}
|
|
8
10
|
export declare class LockEntryUseCase implements ILockEntryUseCase {
|
|
9
11
|
private readonly isEntryLockedUseCase;
|
|
10
12
|
private readonly getManager;
|
|
13
|
+
private readonly convert;
|
|
11
14
|
constructor(params: ILockEntryUseCaseParams);
|
|
12
15
|
execute(params: ILockEntryUseCaseExecuteParams): Promise<IRecordLockingLockRecord>;
|
|
13
16
|
}
|
|
@@ -6,13 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.LockEntryUseCase = void 0;
|
|
8
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
var _convertEntryToLockRecord = require("../../utils/convertEntryToLockRecord");
|
|
10
9
|
var _lockRecordDatabaseId = require("../../utils/lockRecordDatabaseId");
|
|
11
10
|
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
12
11
|
class LockEntryUseCase {
|
|
13
12
|
constructor(params) {
|
|
14
13
|
this.isEntryLockedUseCase = params.isEntryLockedUseCase;
|
|
15
14
|
this.getManager = params.getManager;
|
|
15
|
+
this.convert = params.convert;
|
|
16
16
|
}
|
|
17
17
|
async execute(params) {
|
|
18
18
|
let locked = false;
|
|
@@ -38,7 +38,7 @@ class LockEntryUseCase {
|
|
|
38
38
|
type: params.type,
|
|
39
39
|
actions: []
|
|
40
40
|
});
|
|
41
|
-
return
|
|
41
|
+
return this.convert(entry);
|
|
42
42
|
} catch (ex) {
|
|
43
43
|
throw new _error.default(`Could not lock entry: ${ex.message}`, ex.code || "LOCK_ENTRY_ERROR", {
|
|
44
44
|
...ex.data
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_lockRecordDatabaseId","_handlerGraphql","LockEntryUseCase","constructor","params","isEntryLockedUseCase","getManager","convert","execute","locked","ex","NotFoundError","WebinyError","manager","id","createLockRecordDatabaseId","entry","create","targetId","type","actions","message","code","data","exports"],"sources":["LockEntryUseCase.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n ILockEntryUseCase,\n ILockEntryUseCaseExecuteParams\n} from \"~/abstractions/ILockEntryUseCase\";\nimport type {\n IRecordLockingLockRecord,\n IRecordLockingLockRecordValues,\n IRecordLockingModelManager\n} from \"~/types\";\nimport type { IIsEntryLockedUseCase } from \"~/abstractions/IIsEntryLocked\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\nimport type { ConvertEntryToLockRecordCb } from \"~/useCases/types\";\n\nexport interface ILockEntryUseCaseParams {\n isEntryLockedUseCase: IIsEntryLockedUseCase;\n getManager(): Promise<IRecordLockingModelManager>;\n convert: ConvertEntryToLockRecordCb;\n}\n\nexport class LockEntryUseCase implements ILockEntryUseCase {\n private readonly isEntryLockedUseCase: IIsEntryLockedUseCase;\n private readonly getManager: () => Promise<IRecordLockingModelManager>;\n private readonly convert: ConvertEntryToLockRecordCb;\n\n public constructor(params: ILockEntryUseCaseParams) {\n this.isEntryLockedUseCase = params.isEntryLockedUseCase;\n this.getManager = params.getManager;\n this.convert = params.convert;\n }\n\n public async execute(\n params: ILockEntryUseCaseExecuteParams\n ): Promise<IRecordLockingLockRecord> {\n let locked = false;\n try {\n locked = await this.isEntryLockedUseCase.execute(params);\n } catch (ex) {\n if (ex instanceof NotFoundError === false) {\n throw ex;\n }\n locked = false;\n }\n if (locked) {\n throw new WebinyError(\"Entry is already locked for editing.\", \"ENTRY_ALREADY_LOCKED\", {\n ...params\n });\n }\n try {\n const manager = await this.getManager();\n\n const id = createLockRecordDatabaseId(params.id);\n const entry = await manager.create<IRecordLockingLockRecordValues>({\n id,\n targetId: params.id,\n type: params.type,\n actions: []\n });\n return this.convert(entry);\n } catch (ex) {\n throw new WebinyError(\n `Could not lock entry: ${ex.message}`,\n ex.code || \"LOCK_ENTRY_ERROR\",\n {\n ...ex.data\n }\n );\n }\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAWA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AASO,MAAMG,gBAAgB,CAA8B;EAKhDC,WAAWA,CAACC,MAA+B,EAAE;IAChD,IAAI,CAACC,oBAAoB,GAAGD,MAAM,CAACC,oBAAoB;IACvD,IAAI,CAACC,UAAU,GAAGF,MAAM,CAACE,UAAU;IACnC,IAAI,CAACC,OAAO,GAAGH,MAAM,CAACG,OAAO;EACjC;EAEA,MAAaC,OAAOA,CAChBJ,MAAsC,EACL;IACjC,IAAIK,MAAM,GAAG,KAAK;IAClB,IAAI;MACAA,MAAM,GAAG,MAAM,IAAI,CAACJ,oBAAoB,CAACG,OAAO,CAACJ,MAAM,CAAC;IAC5D,CAAC,CAAC,OAAOM,EAAE,EAAE;MACT,IAAIA,EAAE,YAAYC,6BAAa,KAAK,KAAK,EAAE;QACvC,MAAMD,EAAE;MACZ;MACAD,MAAM,GAAG,KAAK;IAClB;IACA,IAAIA,MAAM,EAAE;MACR,MAAM,IAAIG,cAAW,CAAC,sCAAsC,EAAE,sBAAsB,EAAE;QAClF,GAAGR;MACP,CAAC,CAAC;IACN;IACA,IAAI;MACA,MAAMS,OAAO,GAAG,MAAM,IAAI,CAACP,UAAU,CAAC,CAAC;MAEvC,MAAMQ,EAAE,GAAG,IAAAC,gDAA0B,EAACX,MAAM,CAACU,EAAE,CAAC;MAChD,MAAME,KAAK,GAAG,MAAMH,OAAO,CAACI,MAAM,CAAiC;QAC/DH,EAAE;QACFI,QAAQ,EAAEd,MAAM,CAACU,EAAE;QACnBK,IAAI,EAAEf,MAAM,CAACe,IAAI;QACjBC,OAAO,EAAE;MACb,CAAC,CAAC;MACF,OAAO,IAAI,CAACb,OAAO,CAACS,KAAK,CAAC;IAC9B,CAAC,CAAC,OAAON,EAAE,EAAE;MACT,MAAM,IAAIE,cAAW,CACjB,yBAAyBF,EAAE,CAACW,OAAO,EAAE,EACrCX,EAAE,CAACY,IAAI,IAAI,kBAAkB,EAC7B;QACI,GAAGZ,EAAE,CAACa;MACV,CACJ,CAAC;IACL;EACJ;AACJ;AAACC,OAAA,CAAAtB,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { IUnlockEntryUseCase, IUnlockEntryUseCaseExecuteParams } from "../../abstractions/IUnlockEntryUseCase";
|
|
2
|
-
import { IGetIdentity,
|
|
3
|
-
import { IGetLockRecordUseCase } from "../../abstractions/IGetLockRecordUseCase";
|
|
4
|
-
import { IKickOutCurrentUserUseCase } from "../../abstractions/IKickOutCurrentUserUseCase";
|
|
1
|
+
import type { IUnlockEntryUseCase, IUnlockEntryUseCaseExecuteParams } from "../../abstractions/IUnlockEntryUseCase";
|
|
2
|
+
import type { IGetIdentity, IHasRecordLockingAccessCallable, IRecordLockingLockRecord, IRecordLockingModelManager } from "../../types";
|
|
3
|
+
import type { IGetLockRecordUseCase } from "../../abstractions/IGetLockRecordUseCase";
|
|
4
|
+
import type { IKickOutCurrentUserUseCase } from "../../abstractions/IKickOutCurrentUserUseCase";
|
|
5
5
|
export interface IUnlockEntryUseCaseParams {
|
|
6
6
|
readonly getLockRecordUseCase: IGetLockRecordUseCase;
|
|
7
7
|
readonly kickOutCurrentUserUseCase: IKickOutCurrentUserUseCase;
|
|
8
8
|
getManager(): Promise<IRecordLockingModelManager>;
|
|
9
9
|
getIdentity: IGetIdentity;
|
|
10
|
-
|
|
10
|
+
hasRecordLockingAccess: IHasRecordLockingAccessCallable;
|
|
11
11
|
}
|
|
12
12
|
export declare class UnlockEntryUseCase implements IUnlockEntryUseCase {
|
|
13
13
|
private readonly getLockRecordUseCase;
|
|
14
14
|
private readonly kickOutCurrentUserUseCase;
|
|
15
15
|
private readonly getManager;
|
|
16
16
|
private readonly getIdentity;
|
|
17
|
-
private readonly
|
|
17
|
+
private readonly hasRecordLockingAccess;
|
|
18
18
|
constructor(params: IUnlockEntryUseCaseParams);
|
|
19
19
|
execute(params: IUnlockEntryUseCaseExecuteParams): Promise<IRecordLockingLockRecord>;
|
|
20
20
|
}
|
|
@@ -9,17 +9,30 @@ var _error = _interopRequireDefault(require("@webiny/error"));
|
|
|
9
9
|
var _lockRecordDatabaseId = require("../../utils/lockRecordDatabaseId");
|
|
10
10
|
var _validateSameIdentity = require("../../utils/validateSameIdentity");
|
|
11
11
|
var _apiSecurity = require("@webiny/api-security");
|
|
12
|
+
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
12
13
|
class UnlockEntryUseCase {
|
|
13
14
|
constructor(params) {
|
|
14
15
|
this.getLockRecordUseCase = params.getLockRecordUseCase;
|
|
15
16
|
this.kickOutCurrentUserUseCase = params.kickOutCurrentUserUseCase;
|
|
16
17
|
this.getManager = params.getManager;
|
|
17
18
|
this.getIdentity = params.getIdentity;
|
|
18
|
-
this.
|
|
19
|
+
this.hasRecordLockingAccess = params.hasRecordLockingAccess;
|
|
19
20
|
}
|
|
20
21
|
async execute(params) {
|
|
21
22
|
const record = await this.getLockRecordUseCase.execute(params);
|
|
22
23
|
if (!record) {
|
|
24
|
+
try {
|
|
25
|
+
const manager = await this.getManager();
|
|
26
|
+
await manager.delete((0, _lockRecordDatabaseId.createLockRecordDatabaseId)(params.id), {
|
|
27
|
+
force: true,
|
|
28
|
+
permanently: true
|
|
29
|
+
});
|
|
30
|
+
} catch (ex) {
|
|
31
|
+
if (ex instanceof _handlerGraphql.NotFoundError === false) {
|
|
32
|
+
console.log("Could not forcefully delete lock record.");
|
|
33
|
+
console.error(ex);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
23
36
|
throw new _error.default("Lock Record not found.", "LOCK_RECORD_NOT_FOUND", {
|
|
24
37
|
...params
|
|
25
38
|
});
|
|
@@ -41,15 +54,18 @@ class UnlockEntryUseCase {
|
|
|
41
54
|
if (!params.force) {
|
|
42
55
|
throw ex;
|
|
43
56
|
}
|
|
44
|
-
const
|
|
45
|
-
if (ex instanceof _apiSecurity.NotAuthorizedError === false || !
|
|
57
|
+
const hasAccess = await this.hasRecordLockingAccess();
|
|
58
|
+
if (ex instanceof _apiSecurity.NotAuthorizedError === false || !hasAccess) {
|
|
46
59
|
throw ex;
|
|
47
60
|
}
|
|
48
61
|
kickOutCurrentUser = true;
|
|
49
62
|
}
|
|
50
63
|
try {
|
|
51
64
|
const manager = await this.getManager();
|
|
52
|
-
await manager.delete((0, _lockRecordDatabaseId.createLockRecordDatabaseId)(params.id)
|
|
65
|
+
await manager.delete((0, _lockRecordDatabaseId.createLockRecordDatabaseId)(params.id), {
|
|
66
|
+
force: true,
|
|
67
|
+
permanently: true
|
|
68
|
+
});
|
|
53
69
|
if (!kickOutCurrentUser) {
|
|
54
70
|
return record;
|
|
55
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_lockRecordDatabaseId","_validateSameIdentity","_apiSecurity","UnlockEntryUseCase","constructor","params","getLockRecordUseCase","kickOutCurrentUserUseCase","getManager","getIdentity","
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_lockRecordDatabaseId","_validateSameIdentity","_apiSecurity","_handlerGraphql","UnlockEntryUseCase","constructor","params","getLockRecordUseCase","kickOutCurrentUserUseCase","getManager","getIdentity","hasRecordLockingAccess","execute","record","manager","delete","createLockRecordDatabaseId","id","force","permanently","ex","NotFoundError","console","log","error","WebinyError","kickOutCurrentUser","validateSameIdentity","target","lockedBy","hasAccess","NotAuthorizedError","message","code","data","exports"],"sources":["UnlockEntryUseCase.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n IUnlockEntryUseCase,\n IUnlockEntryUseCaseExecuteParams\n} from \"~/abstractions/IUnlockEntryUseCase\";\nimport type {\n IGetIdentity,\n IHasRecordLockingAccessCallable,\n IRecordLockingLockRecord,\n IRecordLockingModelManager\n} from \"~/types\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId\";\nimport type { IGetLockRecordUseCase } from \"~/abstractions/IGetLockRecordUseCase\";\nimport { validateSameIdentity } from \"~/utils/validateSameIdentity\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\nimport type { IKickOutCurrentUserUseCase } from \"~/abstractions/IKickOutCurrentUserUseCase\";\nimport { NotFoundError } from \"@webiny/handler-graphql\";\n\nexport interface IUnlockEntryUseCaseParams {\n readonly getLockRecordUseCase: IGetLockRecordUseCase;\n readonly kickOutCurrentUserUseCase: IKickOutCurrentUserUseCase;\n getManager(): Promise<IRecordLockingModelManager>;\n getIdentity: IGetIdentity;\n hasRecordLockingAccess: IHasRecordLockingAccessCallable;\n}\n\nexport class UnlockEntryUseCase implements IUnlockEntryUseCase {\n private readonly getLockRecordUseCase: IGetLockRecordUseCase;\n private readonly kickOutCurrentUserUseCase: IKickOutCurrentUserUseCase;\n private readonly getManager: () => Promise<IRecordLockingModelManager>;\n private readonly getIdentity: IGetIdentity;\n private readonly hasRecordLockingAccess: IHasRecordLockingAccessCallable;\n\n public constructor(params: IUnlockEntryUseCaseParams) {\n this.getLockRecordUseCase = params.getLockRecordUseCase;\n this.kickOutCurrentUserUseCase = params.kickOutCurrentUserUseCase;\n this.getManager = params.getManager;\n this.getIdentity = params.getIdentity;\n this.hasRecordLockingAccess = params.hasRecordLockingAccess;\n }\n\n public async execute(\n params: IUnlockEntryUseCaseExecuteParams\n ): Promise<IRecordLockingLockRecord> {\n const record = await this.getLockRecordUseCase.execute(params);\n if (!record) {\n try {\n const manager = await this.getManager();\n await manager.delete(createLockRecordDatabaseId(params.id), {\n force: true,\n permanently: true\n });\n } catch (ex) {\n if (ex instanceof NotFoundError === false) {\n console.log(\"Could not forcefully delete lock record.\");\n console.error(ex);\n }\n }\n\n throw new WebinyError(\"Lock Record not found.\", \"LOCK_RECORD_NOT_FOUND\", {\n ...params\n });\n }\n\n /**\n * We need to validate that the user executing unlock is the same user that locked the entry.\n * In case it is not the same user, there is a possibility that it is a user which has full access,\n * and at that point, we allow unlocking, but we also need to message the user who locked the entry.\n *\n */\n let kickOutCurrentUser = false;\n try {\n validateSameIdentity({\n getIdentity: this.getIdentity,\n target: record.lockedBy\n });\n } catch (ex) {\n if (!params.force) {\n throw ex;\n }\n const hasAccess = await this.hasRecordLockingAccess();\n if (ex instanceof NotAuthorizedError === false || !hasAccess) {\n throw ex;\n }\n\n kickOutCurrentUser = true;\n }\n\n try {\n const manager = await this.getManager();\n await manager.delete(createLockRecordDatabaseId(params.id), {\n force: true,\n permanently: true\n });\n\n if (!kickOutCurrentUser) {\n return record;\n }\n await this.kickOutCurrentUserUseCase.execute(record);\n return record;\n } catch (ex) {\n throw new WebinyError(\n `Could not unlock entry: ${ex.message}`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"../../abstractions/IUnlockEntryRequestUseCase";
|
|
2
|
-
import { IGetIdentity, IRecordLockingLockRecord, IRecordLockingModelManager } from "../../types";
|
|
3
|
-
import { IGetLockRecordUseCase } from "../../abstractions/IGetLockRecordUseCase";
|
|
1
|
+
import type { IUnlockEntryRequestUseCase, IUnlockEntryRequestUseCaseExecuteParams } from "../../abstractions/IUnlockEntryRequestUseCase";
|
|
2
|
+
import type { IGetIdentity, IRecordLockingLockRecord, IRecordLockingModelManager } from "../../types";
|
|
3
|
+
import type { IGetLockRecordUseCase } from "../../abstractions/IGetLockRecordUseCase";
|
|
4
|
+
import type { ConvertEntryToLockRecordCb } from "../types";
|
|
4
5
|
export interface IUnlockEntryRequestUseCaseParams {
|
|
5
6
|
getLockRecordUseCase: IGetLockRecordUseCase;
|
|
6
7
|
getManager: () => Promise<IRecordLockingModelManager>;
|
|
7
8
|
getIdentity: IGetIdentity;
|
|
9
|
+
convert: ConvertEntryToLockRecordCb;
|
|
8
10
|
}
|
|
9
11
|
export declare class UnlockEntryRequestUseCase implements IUnlockEntryRequestUseCase {
|
|
10
12
|
private readonly getLockRecordUseCase;
|
|
11
13
|
private readonly getManager;
|
|
12
14
|
private readonly getIdentity;
|
|
15
|
+
private readonly convert;
|
|
13
16
|
constructor(params: IUnlockEntryRequestUseCaseParams);
|
|
14
17
|
execute(params: IUnlockEntryRequestUseCaseExecuteParams): Promise<IRecordLockingLockRecord>;
|
|
15
18
|
}
|
|
@@ -9,12 +9,12 @@ var _error = _interopRequireDefault(require("@webiny/error"));
|
|
|
9
9
|
var _types = require("../../types");
|
|
10
10
|
var _lockRecordDatabaseId = require("../../utils/lockRecordDatabaseId");
|
|
11
11
|
var _utils = require("@webiny/utils");
|
|
12
|
-
var _convertEntryToLockRecord = require("../../utils/convertEntryToLockRecord");
|
|
13
12
|
class UnlockEntryRequestUseCase {
|
|
14
13
|
constructor(params) {
|
|
15
14
|
this.getLockRecordUseCase = params.getLockRecordUseCase;
|
|
16
15
|
this.getManager = params.getManager;
|
|
17
16
|
this.getIdentity = params.getIdentity;
|
|
17
|
+
this.convert = params.convert;
|
|
18
18
|
}
|
|
19
19
|
async execute(params) {
|
|
20
20
|
const record = await this.getLockRecordUseCase.execute(params);
|
|
@@ -46,7 +46,7 @@ class UnlockEntryRequestUseCase {
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
record.addAction({
|
|
49
|
-
type: _types.
|
|
49
|
+
type: _types.RecordLockingLockRecordActionType.requested,
|
|
50
50
|
createdOn: new Date(),
|
|
51
51
|
createdBy: this.getIdentity()
|
|
52
52
|
});
|
|
@@ -58,7 +58,7 @@ class UnlockEntryRequestUseCase {
|
|
|
58
58
|
version: 1
|
|
59
59
|
});
|
|
60
60
|
const result = await manager.update(id, record.toObject());
|
|
61
|
-
return
|
|
61
|
+
return this.convert(result);
|
|
62
62
|
} catch (ex) {
|
|
63
63
|
throw new _error.default("Could not update record with a unlock request.", "UNLOCK_REQUEST_ERROR", {
|
|
64
64
|
...ex.data,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_types","_lockRecordDatabaseId","_utils","
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_types","_lockRecordDatabaseId","_utils","UnlockEntryRequestUseCase","constructor","params","getLockRecordUseCase","getManager","getIdentity","convert","execute","record","WebinyError","unlockRequested","getUnlockRequested","currentIdentity","createdBy","id","identity","approved","getUnlockApproved","denied","getUnlockDenied","addAction","type","RecordLockingLockRecordActionType","requested","createdOn","Date","manager","entryId","createLockRecordDatabaseId","createIdentifier","version","result","update","toObject","ex","data","error","message","code","recordId","exports"],"sources":["UnlockEntryRequestUseCase.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n IUnlockEntryRequestUseCase,\n IUnlockEntryRequestUseCaseExecuteParams\n} from \"~/abstractions/IUnlockEntryRequestUseCase\";\nimport type { IGetIdentity, IRecordLockingLockRecord, IRecordLockingModelManager } from \"~/types\";\nimport { RecordLockingLockRecordActionType } from \"~/types\";\nimport type { IGetLockRecordUseCase } from \"~/abstractions/IGetLockRecordUseCase\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId\";\nimport { createIdentifier } from \"@webiny/utils\";\nimport type { ConvertEntryToLockRecordCb } from \"~/useCases/types\";\n\nexport interface IUnlockEntryRequestUseCaseParams {\n getLockRecordUseCase: IGetLockRecordUseCase;\n getManager: () => Promise<IRecordLockingModelManager>;\n getIdentity: IGetIdentity;\n convert: ConvertEntryToLockRecordCb;\n}\n\nexport class UnlockEntryRequestUseCase implements IUnlockEntryRequestUseCase {\n private readonly getLockRecordUseCase: IGetLockRecordUseCase;\n private readonly getManager: () => Promise<IRecordLockingModelManager>;\n private readonly getIdentity: IGetIdentity;\n private readonly convert: ConvertEntryToLockRecordCb;\n\n public constructor(params: IUnlockEntryRequestUseCaseParams) {\n this.getLockRecordUseCase = params.getLockRecordUseCase;\n this.getManager = params.getManager;\n this.getIdentity = params.getIdentity;\n this.convert = params.convert;\n }\n\n public async execute(\n params: IUnlockEntryRequestUseCaseExecuteParams\n ): Promise<IRecordLockingLockRecord> {\n const record = await this.getLockRecordUseCase.execute(params);\n if (!record) {\n throw new WebinyError(\"Entry is not locked.\", \"ENTRY_NOT_LOCKED\", {\n ...params\n });\n }\n const unlockRequested = record.getUnlockRequested();\n if (unlockRequested) {\n const currentIdentity = this.getIdentity();\n /**\n * If a current identity did not request unlock, we will not allow that user to continue.\n */\n if (unlockRequested.createdBy.id !== currentIdentity.id) {\n throw new WebinyError(\n \"Unlock request already sent.\",\n \"UNLOCK_REQUEST_ALREADY_SENT\",\n {\n ...params,\n identity: unlockRequested.createdBy\n }\n );\n }\n const approved = record.getUnlockApproved();\n const denied = record.getUnlockDenied();\n if (approved || denied) {\n return record;\n }\n throw new WebinyError(\"Unlock request already sent.\", \"UNLOCK_REQUEST_ALREADY_SENT\", {\n ...params,\n identity: unlockRequested.createdBy\n });\n }\n\n record.addAction({\n type: RecordLockingLockRecordActionType.requested,\n createdOn: new Date(),\n createdBy: this.getIdentity()\n });\n\n try {\n const manager = await this.getManager();\n\n const entryId = createLockRecordDatabaseId(record.id);\n const id = createIdentifier({\n id: entryId,\n version: 1\n });\n const result = await manager.update(id, record.toObject());\n return this.convert(result);\n } catch (ex) {\n throw new WebinyError(\n \"Could not update record with a unlock request.\",\n \"UNLOCK_REQUEST_ERROR\",\n {\n ...ex.data,\n error: {\n message: ex.message,\n code: ex.code\n },\n id: params.id,\n type: params.type,\n recordId: record.id\n }\n );\n }\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAMA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,qBAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAUO,MAAMI,yBAAyB,CAAuC;EAMlEC,WAAWA,CAACC,MAAwC,EAAE;IACzD,IAAI,CAACC,oBAAoB,GAAGD,MAAM,CAACC,oBAAoB;IACvD,IAAI,CAACC,UAAU,GAAGF,MAAM,CAACE,UAAU;IACnC,IAAI,CAACC,WAAW,GAAGH,MAAM,CAACG,WAAW;IACrC,IAAI,CAACC,OAAO,GAAGJ,MAAM,CAACI,OAAO;EACjC;EAEA,MAAaC,OAAOA,CAChBL,MAA+C,EACd;IACjC,MAAMM,MAAM,GAAG,MAAM,IAAI,CAACL,oBAAoB,CAACI,OAAO,CAACL,MAAM,CAAC;IAC9D,IAAI,CAACM,MAAM,EAAE;MACT,MAAM,IAAIC,cAAW,CAAC,sBAAsB,EAAE,kBAAkB,EAAE;QAC9D,GAAGP;MACP,CAAC,CAAC;IACN;IACA,MAAMQ,eAAe,GAAGF,MAAM,CAACG,kBAAkB,CAAC,CAAC;IACnD,IAAID,eAAe,EAAE;MACjB,MAAME,eAAe,GAAG,IAAI,CAACP,WAAW,CAAC,CAAC;MAC1C;AACZ;AACA;MACY,IAAIK,eAAe,CAACG,SAAS,CAACC,EAAE,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C,OAAO,EAAEH,EAAE,CAACG,OAAO;UACnBC,IAAI,EAAEJ,EAAE,CAACI;QACb,CAAC;QACDxB,EAAE,EAAEZ,MAAM,CAACY,EAAE;QACbO,IAAI,EAAEnB,MAAM,CAACmB,IAAI;QACjBkB,QAAQ,EAAE/B,MAAM,CAACM;MACrB,CACJ,CAAC;IACL;EACJ;AACJ;AAAC0B,OAAA,CAAAxC,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import { IUpdateEntryLockUseCase, IUpdateEntryLockUseCaseExecuteParams } from "../../abstractions/IUpdateEntryLockUseCase";
|
|
2
|
-
import { IGetIdentity, IRecordLockingLockRecord, IRecordLockingModelManager } from "../../types";
|
|
3
|
-
import { IGetLockRecordUseCase } from "../../abstractions/IGetLockRecordUseCase";
|
|
4
|
-
import { ILockEntryUseCase } from "../../abstractions/ILockEntryUseCase";
|
|
1
|
+
import type { IUpdateEntryLockUseCase, IUpdateEntryLockUseCaseExecuteParams } from "../../abstractions/IUpdateEntryLockUseCase";
|
|
2
|
+
import type { IGetIdentity, IRecordLockingLockRecord, IRecordLockingModelManager } from "../../types";
|
|
3
|
+
import type { IGetLockRecordUseCase } from "../../abstractions/IGetLockRecordUseCase";
|
|
4
|
+
import type { ILockEntryUseCase } from "../../abstractions/ILockEntryUseCase";
|
|
5
|
+
import type { ConvertEntryToLockRecordCb } from "../types";
|
|
5
6
|
export interface IUpdateEntryLockUseCaseParams {
|
|
6
7
|
readonly getLockRecordUseCase: IGetLockRecordUseCase;
|
|
7
8
|
readonly lockEntryUseCase: ILockEntryUseCase;
|
|
8
9
|
getManager(): Promise<IRecordLockingModelManager>;
|
|
9
10
|
getIdentity: IGetIdentity;
|
|
11
|
+
convert: ConvertEntryToLockRecordCb;
|
|
10
12
|
}
|
|
11
13
|
export declare class UpdateEntryLockUseCase implements IUpdateEntryLockUseCase {
|
|
12
14
|
private readonly getLockRecordUseCase;
|
|
13
15
|
private readonly lockEntryUseCase;
|
|
14
16
|
private readonly getManager;
|
|
15
17
|
private readonly getIdentity;
|
|
18
|
+
private readonly convert;
|
|
16
19
|
constructor(params: IUpdateEntryLockUseCaseParams);
|
|
17
20
|
execute(params: IUpdateEntryLockUseCaseExecuteParams): Promise<IRecordLockingLockRecord>;
|
|
18
21
|
}
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.UpdateEntryLockUseCase = void 0;
|
|
7
7
|
var _error = require("@webiny/error");
|
|
8
|
-
var _convertEntryToLockRecord = require("../../utils/convertEntryToLockRecord");
|
|
9
8
|
var _lockRecordDatabaseId = require("../../utils/lockRecordDatabaseId");
|
|
10
9
|
var _utils = require("@webiny/utils");
|
|
11
10
|
var _validateSameIdentity = require("../../utils/validateSameIdentity");
|
|
@@ -15,6 +14,7 @@ class UpdateEntryLockUseCase {
|
|
|
15
14
|
this.lockEntryUseCase = params.lockEntryUseCase;
|
|
16
15
|
this.getManager = params.getManager;
|
|
17
16
|
this.getIdentity = params.getIdentity;
|
|
17
|
+
this.convert = params.convert;
|
|
18
18
|
}
|
|
19
19
|
async execute(params) {
|
|
20
20
|
const record = await this.getLockRecordUseCase.execute(params);
|
|
@@ -35,7 +35,7 @@ class UpdateEntryLockUseCase {
|
|
|
35
35
|
const result = await manager.update(id, {
|
|
36
36
|
savedOn: new Date().toISOString()
|
|
37
37
|
});
|
|
38
|
-
return
|
|
38
|
+
return this.convert(result);
|
|
39
39
|
} catch (ex) {
|
|
40
40
|
throw new _error.WebinyError(`Could not update lock entry: ${ex.message}`, ex.code || "UPDATE_LOCK_ENTRY_ERROR", {
|
|
41
41
|
...ex.data
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","require","
|
|
1
|
+
{"version":3,"names":["_error","require","_lockRecordDatabaseId","_utils","_validateSameIdentity","UpdateEntryLockUseCase","constructor","params","getLockRecordUseCase","lockEntryUseCase","getManager","getIdentity","convert","execute","record","validateSameIdentity","target","lockedBy","manager","entryId","createLockRecordDatabaseId","id","createIdentifier","version","result","update","savedOn","Date","toISOString","ex","WebinyError","message","code","data","exports"],"sources":["UpdateEntryLockUseCase.ts"],"sourcesContent":["import type {\n IUpdateEntryLockUseCase,\n IUpdateEntryLockUseCaseExecuteParams\n} from \"~/abstractions/IUpdateEntryLockUseCase\";\nimport type { IGetIdentity, IRecordLockingLockRecord, IRecordLockingModelManager } from \"~/types\";\nimport type { IGetLockRecordUseCase } from \"~/abstractions/IGetLockRecordUseCase\";\nimport { WebinyError } from \"@webiny/error\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId\";\nimport { createIdentifier } from \"@webiny/utils\";\nimport { validateSameIdentity } from \"~/utils/validateSameIdentity\";\nimport type { ILockEntryUseCase } from \"~/abstractions/ILockEntryUseCase\";\nimport type { ConvertEntryToLockRecordCb } from \"~/useCases/types\";\n\nexport interface IUpdateEntryLockUseCaseParams {\n readonly getLockRecordUseCase: IGetLockRecordUseCase;\n readonly lockEntryUseCase: ILockEntryUseCase;\n getManager(): Promise<IRecordLockingModelManager>;\n getIdentity: IGetIdentity;\n convert: ConvertEntryToLockRecordCb;\n}\n\nexport class UpdateEntryLockUseCase implements IUpdateEntryLockUseCase {\n private readonly getLockRecordUseCase: IGetLockRecordUseCase;\n private readonly lockEntryUseCase: ILockEntryUseCase;\n private readonly getManager: () => Promise<IRecordLockingModelManager>;\n private readonly getIdentity: IGetIdentity;\n private readonly convert: ConvertEntryToLockRecordCb;\n\n public constructor(params: IUpdateEntryLockUseCaseParams) {\n this.getLockRecordUseCase = params.getLockRecordUseCase;\n this.lockEntryUseCase = params.lockEntryUseCase;\n this.getManager = params.getManager;\n this.getIdentity = params.getIdentity;\n this.convert = params.convert;\n }\n\n public async execute(\n params: IUpdateEntryLockUseCaseExecuteParams\n ): Promise<IRecordLockingLockRecord> {\n const record = await this.getLockRecordUseCase.execute(params);\n if (!record) {\n return this.lockEntryUseCase.execute(params);\n }\n\n validateSameIdentity({\n getIdentity: this.getIdentity,\n target: record.lockedBy\n });\n\n try {\n const manager = await this.getManager();\n\n const entryId = createLockRecordDatabaseId(record.id);\n const id = createIdentifier({\n id: entryId,\n version: 1\n });\n const result = await manager.update(id, {\n savedOn: new Date().toISOString()\n });\n return this.convert(result);\n } catch (ex) {\n throw new WebinyError(\n `Could not update lock entry: ${ex.message}`,\n ex.code || \"UPDATE_LOCK_ENTRY_ERROR\",\n {\n ...ex.data\n }\n );\n }\n }\n}\n"],"mappings":";;;;;;AAMA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,qBAAA,GAAAH,OAAA;AAYO,MAAMI,sBAAsB,CAAoC;EAO5DC,WAAWA,CAACC,MAAqC,EAAE;IACtD,IAAI,CAACC,oBAAoB,GAAGD,MAAM,CAACC,oBAAoB;IACvD,IAAI,CAACC,gBAAgB,GAAGF,MAAM,CAACE,gBAAgB;IAC/C,IAAI,CAACC,UAAU,GAAGH,MAAM,CAACG,UAAU;IACnC,IAAI,CAACC,WAAW,GAAGJ,MAAM,CAACI,WAAW;IACrC,IAAI,CAACC,OAAO,GAAGL,MAAM,CAACK,OAAO;EACjC;EAEA,MAAaC,OAAOA,CAChBN,MAA4C,EACX;IACjC,MAAMO,MAAM,GAAG,MAAM,IAAI,CAACN,oBAAoB,CAACK,OAAO,CAACN,MAAM,CAAC;IAC9D,IAAI,CAACO,MAAM,EAAE;MACT,OAAO,IAAI,CAACL,gBAAgB,CAACI,OAAO,CAACN,MAAM,CAAC;IAChD;IAEA,IAAAQ,0CAAoB,EAAC;MACjBJ,WAAW,EAAE,IAAI,CAACA,WAAW;MAC7BK,MAAM,EAAEF,MAAM,CAACG;IACnB,CAAC,CAAC;IAEF,IAAI;MACA,MAAMC,OAAO,GAAG,MAAM,IAAI,CAACR,UAAU,CAAC,CAAC;MAEvC,MAAMS,OAAO,GAAG,IAAAC,gDAA0B,EAACN,MAAM,CAACO,EAAE,CAAC;MACrD,MAAMA,EAAE,GAAG,IAAAC,uBAAgB,EAAC;QACxBD,EAAE,EAAEF,OAAO;QACXI,OAAO,EAAE;MACb,CAAC,CAAC;MACF,MAAMC,MAAM,GAAG,MAAMN,OAAO,CAACO,MAAM,CAACJ,EAAE,EAAE;QACpCK,OAAO,EAAE,IAAIC,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC;MACpC,CAAC,CAAC;MACF,OAAO,IAAI,CAAChB,OAAO,CAACY,MAAM,CAAC;IAC/B,CAAC,CAAC,OAAOK,EAAE,EAAE;MACT,MAAM,IAAIC,kBAAW,CACjB,gCAAgCD,EAAE,CAACE,OAAO,EAAE,EAC5CF,EAAE,CAACG,IAAI,IAAI,yBAAyB,EACpC;QACI,GAAGH,EAAE,CAACI;MACV,CACJ,CAAC;IACL;EACJ;AACJ;AAACC,OAAA,CAAA7B,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
package/useCases/index.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { IGetIdentity, IGetWebsocketsContextCallable,
|
|
2
|
-
import { IListAllLockRecordsUseCase } from "../abstractions/IListAllLockRecordsUseCase";
|
|
3
|
-
import { IListLockRecordsUseCase } from "../abstractions/IListLockRecordsUseCase";
|
|
4
|
-
import { IGetLockRecordUseCase } from "../abstractions/IGetLockRecordUseCase";
|
|
5
|
-
import { IIsEntryLockedUseCase } from "../abstractions/IIsEntryLocked";
|
|
6
|
-
import { IGetLockedEntryLockRecordUseCase } from "../abstractions/IGetLockedEntryLockRecordUseCase";
|
|
7
|
-
import { ILockEntryUseCase } from "../abstractions/ILockEntryUseCase";
|
|
8
|
-
import { IUpdateEntryLockUseCase } from "../abstractions/IUpdateEntryLockUseCase";
|
|
9
|
-
import { IUnlockEntryUseCase } from "../abstractions/IUnlockEntryUseCase";
|
|
10
|
-
import { IUnlockEntryRequestUseCase } from "../abstractions/IUnlockEntryRequestUseCase";
|
|
1
|
+
import type { IGetIdentity, IGetWebsocketsContextCallable, IHasRecordLockingAccessCallable, IRecordLockingModelManager } from "../types";
|
|
2
|
+
import type { IListAllLockRecordsUseCase } from "../abstractions/IListAllLockRecordsUseCase";
|
|
3
|
+
import type { IListLockRecordsUseCase } from "../abstractions/IListLockRecordsUseCase";
|
|
4
|
+
import type { IGetLockRecordUseCase } from "../abstractions/IGetLockRecordUseCase";
|
|
5
|
+
import type { IIsEntryLockedUseCase } from "../abstractions/IIsEntryLocked";
|
|
6
|
+
import type { IGetLockedEntryLockRecordUseCase } from "../abstractions/IGetLockedEntryLockRecordUseCase";
|
|
7
|
+
import type { ILockEntryUseCase } from "../abstractions/ILockEntryUseCase";
|
|
8
|
+
import type { IUpdateEntryLockUseCase } from "../abstractions/IUpdateEntryLockUseCase";
|
|
9
|
+
import type { IUnlockEntryUseCase } from "../abstractions/IUnlockEntryUseCase";
|
|
10
|
+
import type { IUnlockEntryRequestUseCase } from "../abstractions/IUnlockEntryRequestUseCase";
|
|
11
11
|
export interface ICreateUseCasesParams {
|
|
12
|
+
getTimeout: () => number;
|
|
12
13
|
getIdentity: IGetIdentity;
|
|
13
14
|
getManager(): Promise<IRecordLockingModelManager>;
|
|
14
|
-
|
|
15
|
+
hasRecordLockingAccess: IHasRecordLockingAccessCallable;
|
|
15
16
|
getWebsockets: IGetWebsocketsContextCallable;
|
|
16
17
|
}
|
|
17
18
|
export interface ICreateUseCasesResponse {
|
package/useCases/index.js
CHANGED
|
@@ -13,14 +13,21 @@ var _ListAllLockRecordsUseCase = require("./ListAllLockRecordsUseCase/ListAllLoc
|
|
|
13
13
|
var _ListLockRecordsUseCase = require("./ListLockRecordsUseCase/ListLockRecordsUseCase");
|
|
14
14
|
var _isLockedFactory = require("../utils/isLockedFactory");
|
|
15
15
|
var _UpdateEntryLockUseCase = require("./UpdateEntryLock/UpdateEntryLockUseCase");
|
|
16
|
-
var _getTimeout = require("../utils/getTimeout");
|
|
17
16
|
var _KickOutCurrentUserUseCase = require("./KickOutCurrentUser/KickOutCurrentUserUseCase");
|
|
18
17
|
var _GetLockedEntryLockRecordUseCase = require("./GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase");
|
|
18
|
+
var _convertEntryToLockRecord = require("../utils/convertEntryToLockRecord");
|
|
19
19
|
const createUseCases = params => {
|
|
20
|
-
const
|
|
20
|
+
const {
|
|
21
|
+
getTimeout
|
|
22
|
+
} = params;
|
|
23
|
+
const timeout = getTimeout();
|
|
21
24
|
const isLocked = (0, _isLockedFactory.isLockedFactory)(timeout);
|
|
25
|
+
const convertEntryToLockRecord = entry => {
|
|
26
|
+
return (0, _convertEntryToLockRecord.convertEntryToLockRecord)(entry, timeout);
|
|
27
|
+
};
|
|
22
28
|
const listAllLockRecordsUseCase = new _ListAllLockRecordsUseCase.ListAllLockRecordsUseCase({
|
|
23
|
-
getManager: params.getManager
|
|
29
|
+
getManager: params.getManager,
|
|
30
|
+
convert: convertEntryToLockRecord
|
|
24
31
|
});
|
|
25
32
|
const listLockRecordsUseCase = new _ListLockRecordsUseCase.ListLockRecordsUseCase({
|
|
26
33
|
listAllLockRecordsUseCase,
|
|
@@ -28,7 +35,8 @@ const createUseCases = params => {
|
|
|
28
35
|
getIdentity: params.getIdentity
|
|
29
36
|
});
|
|
30
37
|
const getLockRecordUseCase = new _GetLockRecordUseCase.GetLockRecordUseCase({
|
|
31
|
-
getManager: params.getManager
|
|
38
|
+
getManager: params.getManager,
|
|
39
|
+
convert: convertEntryToLockRecord
|
|
32
40
|
});
|
|
33
41
|
const isEntryLockedUseCase = new _IsEntryLockedUseCase.IsEntryLockedUseCase({
|
|
34
42
|
getLockRecordUseCase,
|
|
@@ -42,13 +50,15 @@ const createUseCases = params => {
|
|
|
42
50
|
});
|
|
43
51
|
const lockEntryUseCase = new _LockEntryUseCase.LockEntryUseCase({
|
|
44
52
|
isEntryLockedUseCase,
|
|
45
|
-
getManager: params.getManager
|
|
53
|
+
getManager: params.getManager,
|
|
54
|
+
convert: convertEntryToLockRecord
|
|
46
55
|
});
|
|
47
56
|
const updateEntryLockUseCase = new _UpdateEntryLockUseCase.UpdateEntryLockUseCase({
|
|
48
57
|
getLockRecordUseCase,
|
|
49
58
|
lockEntryUseCase,
|
|
50
59
|
getManager: params.getManager,
|
|
51
|
-
getIdentity: params.getIdentity
|
|
60
|
+
getIdentity: params.getIdentity,
|
|
61
|
+
convert: convertEntryToLockRecord
|
|
52
62
|
});
|
|
53
63
|
const kickOutCurrentUserUseCase = new _KickOutCurrentUserUseCase.KickOutCurrentUserUseCase({
|
|
54
64
|
getWebsockets: params.getWebsockets,
|
|
@@ -59,12 +69,13 @@ const createUseCases = params => {
|
|
|
59
69
|
kickOutCurrentUserUseCase,
|
|
60
70
|
getManager: params.getManager,
|
|
61
71
|
getIdentity: params.getIdentity,
|
|
62
|
-
|
|
72
|
+
hasRecordLockingAccess: params.hasRecordLockingAccess
|
|
63
73
|
});
|
|
64
74
|
const unlockEntryRequestUseCase = new _UnlockEntryRequestUseCase.UnlockEntryRequestUseCase({
|
|
65
75
|
getLockRecordUseCase,
|
|
66
76
|
getIdentity: params.getIdentity,
|
|
67
|
-
getManager: params.getManager
|
|
77
|
+
getManager: params.getManager,
|
|
78
|
+
convert: convertEntryToLockRecord
|
|
68
79
|
});
|
|
69
80
|
return {
|
|
70
81
|
listAllLockRecordsUseCase,
|
package/useCases/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_GetLockRecordUseCase","require","_IsEntryLockedUseCase","_LockEntryUseCase","_UnlockEntryUseCase","_UnlockEntryRequestUseCase","_ListAllLockRecordsUseCase","_ListLockRecordsUseCase","_isLockedFactory","_UpdateEntryLockUseCase","
|
|
1
|
+
{"version":3,"names":["_GetLockRecordUseCase","require","_IsEntryLockedUseCase","_LockEntryUseCase","_UnlockEntryUseCase","_UnlockEntryRequestUseCase","_ListAllLockRecordsUseCase","_ListLockRecordsUseCase","_isLockedFactory","_UpdateEntryLockUseCase","_KickOutCurrentUserUseCase","_GetLockedEntryLockRecordUseCase","_convertEntryToLockRecord","createUseCases","params","getTimeout","timeout","isLocked","isLockedFactory","convertEntryToLockRecord","entry","baseConvertEntryToLockRecord","listAllLockRecordsUseCase","ListAllLockRecordsUseCase","getManager","convert","listLockRecordsUseCase","ListLockRecordsUseCase","getIdentity","getLockRecordUseCase","GetLockRecordUseCase","isEntryLockedUseCase","IsEntryLockedUseCase","getLockedEntryLockRecordUseCase","GetLockedEntryLockRecordUseCase","lockEntryUseCase","LockEntryUseCase","updateEntryLockUseCase","UpdateEntryLockUseCase","kickOutCurrentUserUseCase","KickOutCurrentUserUseCase","getWebsockets","unlockEntryUseCase","UnlockEntryUseCase","hasRecordLockingAccess","unlockEntryRequestUseCase","UnlockEntryRequestUseCase","exports"],"sources":["index.ts"],"sourcesContent":["import type {\n IGetIdentity,\n IGetWebsocketsContextCallable,\n IHasRecordLockingAccessCallable,\n IRecordLockingModelManager\n} from \"~/types\";\nimport { GetLockRecordUseCase } from \"./GetLockRecord/GetLockRecordUseCase\";\nimport { IsEntryLockedUseCase } from \"./IsEntryLocked/IsEntryLockedUseCase\";\nimport { LockEntryUseCase } from \"./LockEntryUseCase/LockEntryUseCase\";\nimport { UnlockEntryUseCase } from \"./UnlockEntryUseCase/UnlockEntryUseCase\";\nimport { UnlockEntryRequestUseCase } from \"./UnlockRequestUseCase/UnlockEntryRequestUseCase\";\nimport { ListAllLockRecordsUseCase } from \"./ListAllLockRecordsUseCase/ListAllLockRecordsUseCase\";\nimport { ListLockRecordsUseCase } from \"./ListLockRecordsUseCase/ListLockRecordsUseCase\";\nimport { isLockedFactory } from \"~/utils/isLockedFactory\";\nimport { UpdateEntryLockUseCase } from \"~/useCases/UpdateEntryLock/UpdateEntryLockUseCase\";\nimport { KickOutCurrentUserUseCase } from \"./KickOutCurrentUser/KickOutCurrentUserUseCase\";\nimport { GetLockedEntryLockRecordUseCase } from \"~/useCases/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase\";\nimport type { IListAllLockRecordsUseCase } from \"~/abstractions/IListAllLockRecordsUseCase\";\nimport type { IListLockRecordsUseCase } from \"~/abstractions/IListLockRecordsUseCase\";\nimport type { IGetLockRecordUseCase } from \"~/abstractions/IGetLockRecordUseCase\";\nimport type { IIsEntryLockedUseCase } from \"~/abstractions/IIsEntryLocked\";\nimport type { IGetLockedEntryLockRecordUseCase } from \"~/abstractions/IGetLockedEntryLockRecordUseCase\";\nimport type { ILockEntryUseCase } from \"~/abstractions/ILockEntryUseCase\";\nimport type { IUpdateEntryLockUseCase } from \"~/abstractions/IUpdateEntryLockUseCase\";\nimport type { IUnlockEntryUseCase } from \"~/abstractions/IUnlockEntryUseCase\";\nimport type { IUnlockEntryRequestUseCase } from \"~/abstractions/IUnlockEntryRequestUseCase\";\nimport { convertEntryToLockRecord as baseConvertEntryToLockRecord } from \"~/utils/convertEntryToLockRecord\";\nimport { ConvertEntryToLockRecordCb } from \"~/useCases/types\";\n\nexport interface ICreateUseCasesParams {\n getTimeout: () => number;\n getIdentity: IGetIdentity;\n getManager(): Promise<IRecordLockingModelManager>;\n hasRecordLockingAccess: IHasRecordLockingAccessCallable;\n getWebsockets: IGetWebsocketsContextCallable;\n}\n\nexport interface ICreateUseCasesResponse {\n listAllLockRecordsUseCase: IListAllLockRecordsUseCase;\n listLockRecordsUseCase: IListLockRecordsUseCase;\n getLockRecordUseCase: IGetLockRecordUseCase;\n isEntryLockedUseCase: IIsEntryLockedUseCase;\n getLockedEntryLockRecordUseCase: IGetLockedEntryLockRecordUseCase;\n lockEntryUseCase: ILockEntryUseCase;\n updateEntryLockUseCase: IUpdateEntryLockUseCase;\n unlockEntryUseCase: IUnlockEntryUseCase;\n unlockEntryRequestUseCase: IUnlockEntryRequestUseCase;\n}\n\nexport const createUseCases = (params: ICreateUseCasesParams): ICreateUseCasesResponse => {\n const { getTimeout } = params;\n const timeout = getTimeout();\n const isLocked = isLockedFactory(timeout);\n\n const convertEntryToLockRecord: ConvertEntryToLockRecordCb = entry => {\n return baseConvertEntryToLockRecord(entry, timeout);\n };\n\n const listAllLockRecordsUseCase = new ListAllLockRecordsUseCase({\n getManager: params.getManager,\n convert: convertEntryToLockRecord\n });\n\n const listLockRecordsUseCase = new ListLockRecordsUseCase({\n listAllLockRecordsUseCase,\n timeout,\n getIdentity: params.getIdentity\n });\n\n const getLockRecordUseCase = new GetLockRecordUseCase({\n getManager: params.getManager,\n convert: convertEntryToLockRecord\n });\n\n const isEntryLockedUseCase = new IsEntryLockedUseCase({\n getLockRecordUseCase,\n isLocked,\n getIdentity: params.getIdentity\n });\n\n const getLockedEntryLockRecordUseCase = new GetLockedEntryLockRecordUseCase({\n getLockRecordUseCase,\n isLocked,\n getIdentity: params.getIdentity\n });\n\n const lockEntryUseCase = new LockEntryUseCase({\n isEntryLockedUseCase,\n getManager: params.getManager,\n convert: convertEntryToLockRecord\n });\n\n const updateEntryLockUseCase = new UpdateEntryLockUseCase({\n getLockRecordUseCase,\n lockEntryUseCase,\n getManager: params.getManager,\n getIdentity: params.getIdentity,\n convert: convertEntryToLockRecord\n });\n\n const kickOutCurrentUserUseCase = new KickOutCurrentUserUseCase({\n getWebsockets: params.getWebsockets,\n getIdentity: params.getIdentity\n });\n\n const unlockEntryUseCase = new UnlockEntryUseCase({\n getLockRecordUseCase,\n kickOutCurrentUserUseCase,\n getManager: params.getManager,\n getIdentity: params.getIdentity,\n hasRecordLockingAccess: params.hasRecordLockingAccess\n });\n\n const unlockEntryRequestUseCase = new UnlockEntryRequestUseCase({\n getLockRecordUseCase,\n getIdentity: params.getIdentity,\n getManager: params.getManager,\n convert: convertEntryToLockRecord\n });\n\n return {\n listAllLockRecordsUseCase,\n listLockRecordsUseCase,\n getLockRecordUseCase,\n isEntryLockedUseCase,\n getLockedEntryLockRecordUseCase,\n lockEntryUseCase,\n updateEntryLockUseCase,\n unlockEntryUseCase,\n unlockEntryRequestUseCase\n };\n};\n"],"mappings":";;;;;;AAMA,IAAAA,qBAAA,G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+
import type { CmsEntry } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import type { IRecordLockingLockRecord, IRecordLockingLockRecordValues } from "../types";
|
|
3
|
+
export interface ConvertEntryToLockRecordCb {
|
|
4
|
+
(entry: CmsEntry<IRecordLockingLockRecordValues>): IRecordLockingLockRecord;
|
|
5
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { CmsEntry } from \"@webiny/api-headless-cms/types\";\nimport type { IRecordLockingLockRecord, IRecordLockingLockRecordValues } from \"~/types\";\n\nexport interface ConvertEntryToLockRecordCb {\n (entry: CmsEntry<IRecordLockingLockRecordValues>): IRecordLockingLockRecord;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { IHeadlessCmsLockRecordParams } from "./convertEntryToLockRecord";
|
|
2
|
-
export declare const calculateExpiresOn: (input: Pick<IHeadlessCmsLockRecordParams, "savedOn"
|
|
2
|
+
export declare const calculateExpiresOn: (input: Pick<IHeadlessCmsLockRecordParams, "savedOn">, timeout: number) => Date;
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.calculateExpiresOn = void 0;
|
|
7
|
-
|
|
8
|
-
const calculateExpiresOn = input => {
|
|
9
|
-
const timeout = (0, _getTimeout.getTimeout)();
|
|
7
|
+
const calculateExpiresOn = (input, timeout) => {
|
|
10
8
|
const savedOn = new Date(input.savedOn);
|
|
11
9
|
return new Date(savedOn.getTime() + timeout);
|
|
12
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["calculateExpiresOn","input","timeout","savedOn","Date","getTime","exports"],"sources":["calculateExpiresOn.ts"],"sourcesContent":["import { IHeadlessCmsLockRecordParams } from \"./convertEntryToLockRecord\";\n\nexport const calculateExpiresOn = (\n input: Pick<IHeadlessCmsLockRecordParams, \"savedOn\">,\n timeout: number\n): Date => {\n const savedOn = new Date(input.savedOn);\n\n return new Date(savedOn.getTime() + timeout);\n};\n"],"mappings":";;;;;;AAEO,MAAMA,kBAAkB,GAAGA,CAC9BC,KAAoD,EACpDC,OAAe,KACR;EACP,MAAMC,OAAO,GAAG,IAAIC,IAAI,CAACH,KAAK,CAACE,OAAO,CAAC;EAEvC,OAAO,IAAIC,IAAI,CAACD,OAAO,CAACE,OAAO,CAAC,CAAC,GAAGH,OAAO,CAAC;AAChD,CAAC;AAACI,OAAA,CAAAN,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { CmsEntry, IRecordLockingIdentity } from "../types";
|
|
2
|
-
|
|
3
|
-
export declare const convertEntryToLockRecord: (entry: CmsEntry<IRecordLockingLockRecordValues>) => IRecordLockingLockRecord;
|
|
1
|
+
import type { CmsEntry, IRecordLockingIdentity, IRecordLockingLockRecord, IRecordLockingLockRecordAction, IRecordLockingLockRecordApprovedAction, IRecordLockingLockRecordDeniedAction, IRecordLockingLockRecordEntryType, IRecordLockingLockRecordObject, IRecordLockingLockRecordRequestedAction, IRecordLockingLockRecordValues } from "../types";
|
|
2
|
+
export declare const convertEntryToLockRecord: (entry: CmsEntry<IRecordLockingLockRecordValues>, timeout: number) => IRecordLockingLockRecord;
|
|
4
3
|
export type IHeadlessCmsLockRecordParams = Pick<CmsEntry<IRecordLockingLockRecordValues>, "entryId" | "values" | "createdBy" | "createdOn" | "savedOn">;
|
|
5
4
|
export declare class HeadlessCmsLockRecord implements IRecordLockingLockRecord {
|
|
6
5
|
private readonly _id;
|
|
@@ -19,7 +18,7 @@ export declare class HeadlessCmsLockRecord implements IRecordLockingLockRecord {
|
|
|
19
18
|
get updatedOn(): Date;
|
|
20
19
|
get expiresOn(): Date;
|
|
21
20
|
get actions(): IRecordLockingLockRecordAction[] | undefined;
|
|
22
|
-
constructor(input: IHeadlessCmsLockRecordParams);
|
|
21
|
+
constructor(input: IHeadlessCmsLockRecordParams, timeout: number);
|
|
23
22
|
toObject(): IRecordLockingLockRecordObject;
|
|
24
23
|
addAction(action: IRecordLockingLockRecordAction): void;
|
|
25
24
|
getUnlockRequested(): IRecordLockingLockRecordRequestedAction | undefined;
|