@webiny/api-record-locking 0.0.0-unstable.7be00a75a9 → 0.0.0-unstable.7c2def32a7
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/RecordLockingAppFeature.d.ts +11 -0
- package/RecordLockingAppFeature.js +20 -0
- package/RecordLockingAppFeature.js.map +1 -0
- package/domain/RecordLockingModel.js +2 -1
- package/domain/RecordLockingModel.js.map +1 -1
- package/domain/abstractions.d.ts +9 -3
- package/domain/abstractions.js +2 -2
- package/domain/abstractions.js.map +1 -1
- package/features/GetLockRecord/GetLockRecordRepository.d.ts +4 -3
- package/features/GetLockRecord/GetLockRecordRepository.js +20 -15
- package/features/GetLockRecord/GetLockRecordRepository.js.map +1 -1
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.d.ts +3 -3
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js +5 -11
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js.map +1 -1
- package/features/ListAllLockRecords/ListAllLockRecordsRepository.d.ts +5 -3
- package/features/ListAllLockRecords/ListAllLockRecordsRepository.js +13 -6
- package/features/ListAllLockRecords/ListAllLockRecordsRepository.js.map +1 -1
- package/features/ListLockRecords/ListLockRecordsRepository.d.ts +6 -3
- package/features/ListLockRecords/ListLockRecordsRepository.js +14 -7
- package/features/ListLockRecords/ListLockRecordsRepository.js.map +1 -1
- package/features/LockEntry/LockEntryRepository.d.ts +4 -3
- package/features/LockEntry/LockEntryRepository.js +6 -5
- package/features/LockEntry/LockEntryRepository.js.map +1 -1
- package/features/RecordLockingFeature.d.ts +0 -5
- package/features/RecordLockingFeature.js +3 -2
- package/features/RecordLockingFeature.js.map +1 -1
- package/features/RecordLockingModelProvider.d.ts +18 -0
- package/features/RecordLockingModelProvider.js +22 -0
- package/features/RecordLockingModelProvider.js.map +1 -0
- package/features/UnlockEntry/UnlockEntryRepository.d.ts +3 -3
- package/features/UnlockEntry/UnlockEntryRepository.js +6 -5
- package/features/UnlockEntry/UnlockEntryRepository.js.map +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.d.ts +3 -3
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js +6 -5
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js.map +1 -1
- package/features/UpdateEntryLock/UpdateEntryLockRepository.d.ts +4 -3
- package/features/UpdateEntryLock/UpdateEntryLockRepository.js +7 -6
- package/features/UpdateEntryLock/UpdateEntryLockRepository.js.map +1 -1
- package/graphql/RecordLockingGraphQLSchema.d.ts +25 -0
- package/graphql/RecordLockingGraphQLSchema.js +390 -0
- package/graphql/RecordLockingGraphQLSchema.js.map +1 -0
- package/graphql/checkPermissions.d.ts +3 -3
- package/graphql/checkPermissions.js +1 -3
- package/graphql/checkPermissions.js.map +1 -1
- package/graphql/resolve.d.ts +1 -1
- package/graphql/resolve.js +1 -1
- package/graphql/resolve.js.map +1 -1
- package/index.d.ts +2 -9
- package/index.js +1 -60
- package/package.json +18 -18
- package/graphql/schema.d.ts +0 -11
- package/graphql/schema.js +0 -297
- package/graphql/schema.js.map +0 -1
- package/index.js.map +0 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Container } from "@webiny/feature/api";
|
|
2
|
+
export interface IRecordLockingAppFeatureParams {
|
|
3
|
+
/**
|
|
4
|
+
* A number of seconds after the last activity to wait before the record is automatically unlocked.
|
|
5
|
+
*/
|
|
6
|
+
timeout?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const RecordLockingAppFeature: {
|
|
9
|
+
name: string;
|
|
10
|
+
register(container: Container, context: IRecordLockingAppFeatureParams): void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { FeatureFlags } from "@webiny/api-core/features/featureFlags/abstractions.js";
|
|
3
|
+
import { RecordLockingModel } from "./domain/RecordLockingModel.js";
|
|
4
|
+
import { RecordLockingFeature } from "./features/RecordLockingFeature.js";
|
|
5
|
+
import { RecordLockingGraphQLSchema } from "./graphql/RecordLockingGraphQLSchema.js";
|
|
6
|
+
import { getTimeout } from "./utils/getTimeout.js";
|
|
7
|
+
const RecordLockingAppFeature = createFeature({
|
|
8
|
+
name: "RecordLockingApp",
|
|
9
|
+
register (container, params) {
|
|
10
|
+
if (!container.resolve(FeatureFlags).get().isEnabled("recordLocking")) return;
|
|
11
|
+
container.register(RecordLockingModel);
|
|
12
|
+
RecordLockingFeature.register(container, {
|
|
13
|
+
timeout: getTimeout(params?.timeout)
|
|
14
|
+
});
|
|
15
|
+
container.register(RecordLockingGraphQLSchema);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
export { RecordLockingAppFeature };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=RecordLockingAppFeature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RecordLockingAppFeature.js","sources":["../src/RecordLockingAppFeature.ts"],"sourcesContent":["import { type Container, createFeature } from \"@webiny/feature/api\";\nimport { FeatureFlags } from \"@webiny/api-core/features/featureFlags/abstractions.js\";\nimport { RecordLockingModel } from \"~/domain/RecordLockingModel.js\";\nimport { RecordLockingFeature } from \"~/features/RecordLockingFeature.js\";\nimport { RecordLockingGraphQLSchema } from \"~/graphql/RecordLockingGraphQLSchema.js\";\nimport { getTimeout } from \"~/utils/getTimeout.js\";\n\nexport interface IRecordLockingAppFeatureParams {\n /**\n * A number of seconds after the last activity to wait before the record is automatically unlocked.\n */\n timeout?: number;\n}\n\nexport const RecordLockingAppFeature = createFeature<IRecordLockingAppFeatureParams>({\n name: \"RecordLockingApp\",\n register(container: Container, params: IRecordLockingAppFeatureParams) {\n // Record locking is license-gated — check at register time (license is fresh pre-register)\n // so nothing wires up without the entitlement.\n if (!container.resolve(FeatureFlags).get().isEnabled(\"recordLocking\")) {\n return;\n }\n\n container.register(RecordLockingModel);\n RecordLockingFeature.register(container, {\n timeout: getTimeout(params?.timeout)\n });\n container.register(RecordLockingGraphQLSchema);\n }\n});\n"],"names":["RecordLockingAppFeature","createFeature","container","params","FeatureFlags","RecordLockingModel","RecordLockingFeature","getTimeout","RecordLockingGraphQLSchema"],"mappings":";;;;;;AAcO,MAAMA,0BAA0BC,cAA8C;IACjF,MAAM;IACN,UAASC,SAAoB,EAAEC,MAAsC;QAGjE,IAAI,CAACD,UAAU,OAAO,CAACE,cAAc,GAAG,GAAG,SAAS,CAAC,kBACjD;QAGJF,UAAU,QAAQ,CAACG;QACnBC,qBAAqB,QAAQ,CAACJ,WAAW;YACrC,SAASK,WAAWJ,QAAQ;QAChC;QACAD,UAAU,QAAQ,CAACM;IACvB;AACJ"}
|
|
@@ -5,7 +5,8 @@ class RecordLockingPrivateModelImpl {
|
|
|
5
5
|
return [
|
|
6
6
|
builder.private({
|
|
7
7
|
modelId: RECORD_LOCKING_MODEL_ID,
|
|
8
|
-
name: "Record Lock Tracking"
|
|
8
|
+
name: "Record Lock Tracking",
|
|
9
|
+
lifecycleEvents: false
|
|
9
10
|
}).fields((fields)=>({
|
|
10
11
|
targetId: fields.text().label("Target ID").required("Target ID is required."),
|
|
11
12
|
type: fields.text().label("Record Type").required("Record type is required."),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain/RecordLockingModel.js","sources":["../../src/domain/RecordLockingModel.ts"],"sourcesContent":["import { ModelFactory } from \"@webiny/api-headless-cms/features/modelBuilder/index.js\";\n\nexport const RECORD_LOCKING_MODEL_ID = \"wbyRecordLock\";\n\nclass RecordLockingPrivateModelImpl implements ModelFactory.Interface {\n public async execute(builder: ModelFactory.Builder) {\n return [\n builder\n .private({\n modelId: RECORD_LOCKING_MODEL_ID,\n name: \"Record Lock Tracking\"\n })\n .fields(fields => ({\n targetId: fields.text().label(\"Target ID\").required(\"Target ID is required.\"),\n type: fields.text().label(\"Record Type\").required(\"Record type is required.\"),\n actions: fields\n .object()\n .label(\"Actions\")\n .list()\n .fields(fields => ({\n type: fields\n .text()\n .label(\"Action Type\")\n .required(\"Action type is required.\"),\n message: fields.text().label(\"Message\"),\n createdBy: fields\n .object()\n .label(\"Created By\")\n .required(\"Created by is required.\")\n .fields(fields => ({\n id: fields.text().label(\"ID\").required(\"ID is required.\"),\n displayName: fields\n .text()\n .label(\"Display Name\")\n .required(\"Display name is required.\"),\n type: fields.text().label(\"Type\").required(\"Type is required.\")\n })),\n createdOn: fields\n .datetime()\n .label(\"Created On\")\n .required(\"Created on is required.\")\n .withoutTimezone()\n }))\n }))\n ];\n }\n}\n\nexport const RecordLockingModel = ModelFactory.createImplementation({\n implementation: RecordLockingPrivateModelImpl,\n dependencies: []\n});\n"],"names":["RECORD_LOCKING_MODEL_ID","RecordLockingPrivateModelImpl","builder","fields","RecordLockingModel","ModelFactory"],"mappings":";AAEO,MAAMA,0BAA0B;AAEvC,MAAMC;IACF,MAAa,QAAQC,OAA6B,EAAE;QAChD,OAAO;YACHA,QACK,OAAO,CAAC;gBACL,SAASF;gBACT,MAAM;
|
|
1
|
+
{"version":3,"file":"domain/RecordLockingModel.js","sources":["../../src/domain/RecordLockingModel.ts"],"sourcesContent":["import { ModelFactory } from \"@webiny/api-headless-cms/features/modelBuilder/index.js\";\n\nexport const RECORD_LOCKING_MODEL_ID = \"wbyRecordLock\";\n\nclass RecordLockingPrivateModelImpl implements ModelFactory.Interface {\n public async execute(builder: ModelFactory.Builder) {\n return [\n builder\n .private({\n modelId: RECORD_LOCKING_MODEL_ID,\n name: \"Record Lock Tracking\",\n lifecycleEvents: false\n })\n .fields(fields => ({\n targetId: fields.text().label(\"Target ID\").required(\"Target ID is required.\"),\n type: fields.text().label(\"Record Type\").required(\"Record type is required.\"),\n actions: fields\n .object()\n .label(\"Actions\")\n .list()\n .fields(fields => ({\n type: fields\n .text()\n .label(\"Action Type\")\n .required(\"Action type is required.\"),\n message: fields.text().label(\"Message\"),\n createdBy: fields\n .object()\n .label(\"Created By\")\n .required(\"Created by is required.\")\n .fields(fields => ({\n id: fields.text().label(\"ID\").required(\"ID is required.\"),\n displayName: fields\n .text()\n .label(\"Display Name\")\n .required(\"Display name is required.\"),\n type: fields.text().label(\"Type\").required(\"Type is required.\")\n })),\n createdOn: fields\n .datetime()\n .label(\"Created On\")\n .required(\"Created on is required.\")\n .withoutTimezone()\n }))\n }))\n ];\n }\n}\n\nexport const RecordLockingModel = ModelFactory.createImplementation({\n implementation: RecordLockingPrivateModelImpl,\n dependencies: []\n});\n"],"names":["RECORD_LOCKING_MODEL_ID","RecordLockingPrivateModelImpl","builder","fields","RecordLockingModel","ModelFactory"],"mappings":";AAEO,MAAMA,0BAA0B;AAEvC,MAAMC;IACF,MAAa,QAAQC,OAA6B,EAAE;QAChD,OAAO;YACHA,QACK,OAAO,CAAC;gBACL,SAASF;gBACT,MAAM;gBACN,iBAAiB;YACrB,GACC,MAAM,CAACG,CAAAA,SAAW;oBACf,UAAUA,OAAO,IAAI,GAAG,KAAK,CAAC,aAAa,QAAQ,CAAC;oBACpD,MAAMA,OAAO,IAAI,GAAG,KAAK,CAAC,eAAe,QAAQ,CAAC;oBAClD,SAASA,OACJ,MAAM,GACN,KAAK,CAAC,WACN,IAAI,GACJ,MAAM,CAACA,CAAAA,SAAW;4BACf,MAAMA,OACD,IAAI,GACJ,KAAK,CAAC,eACN,QAAQ,CAAC;4BACd,SAASA,OAAO,IAAI,GAAG,KAAK,CAAC;4BAC7B,WAAWA,OACN,MAAM,GACN,KAAK,CAAC,cACN,QAAQ,CAAC,2BACT,MAAM,CAACA,CAAAA,SAAW;oCACf,IAAIA,OAAO,IAAI,GAAG,KAAK,CAAC,MAAM,QAAQ,CAAC;oCACvC,aAAaA,OACR,IAAI,GACJ,KAAK,CAAC,gBACN,QAAQ,CAAC;oCACd,MAAMA,OAAO,IAAI,GAAG,KAAK,CAAC,QAAQ,QAAQ,CAAC;gCAC/C;4BACJ,WAAWA,OACN,QAAQ,GACR,KAAK,CAAC,cACN,QAAQ,CAAC,2BACT,eAAe;wBACxB;gBACR;SACP;IACL;AACJ;AAEO,MAAMC,qBAAqBC,aAAa,oBAAoB,CAAC;IAChE,gBAAgBJ;IAChB,cAAc,EAAE;AACpB"}
|
package/domain/abstractions.d.ts
CHANGED
|
@@ -12,7 +12,13 @@ export declare const RecordLockingConfig: import("@webiny/di").Abstraction<IReco
|
|
|
12
12
|
export declare namespace RecordLockingConfig {
|
|
13
13
|
type Interface = IRecordLockingConfig;
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
/**
|
|
16
|
+
* RecordLockingModelProvider - Fetches the private CMS model that stores lock records.
|
|
17
|
+
*/
|
|
18
|
+
export interface IRecordLockingModelProvider {
|
|
19
|
+
get(): Promise<CmsModel>;
|
|
20
|
+
}
|
|
21
|
+
export declare const RecordLockingModelProvider: import("@webiny/di").Abstraction<IRecordLockingModelProvider>;
|
|
22
|
+
export declare namespace RecordLockingModelProvider {
|
|
23
|
+
type Interface = IRecordLockingModelProvider;
|
|
18
24
|
}
|
package/domain/abstractions.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
2
|
const RecordLockingConfig = createAbstraction("RecordLockingConfig");
|
|
3
|
-
const
|
|
4
|
-
export { RecordLockingConfig,
|
|
3
|
+
const RecordLockingModelProvider = createAbstraction("RecordLockingModelProvider");
|
|
4
|
+
export { RecordLockingConfig, RecordLockingModelProvider };
|
|
5
5
|
|
|
6
6
|
//# sourceMappingURL=abstractions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain/abstractions.js","sources":["../../src/domain/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\n/**\n * RecordLockingConfig - Configuration for record locking timeout\n */\nexport interface IRecordLockingConfig {\n /**\n * Timeout in milliseconds after which a lock expires\n */\n timeout: number;\n}\n\nexport const RecordLockingConfig = createAbstraction<IRecordLockingConfig>(\"RecordLockingConfig\");\n\nexport namespace RecordLockingConfig {\n export type Interface = IRecordLockingConfig;\n}\n\nexport const
|
|
1
|
+
{"version":3,"file":"domain/abstractions.js","sources":["../../src/domain/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\n\n/**\n * RecordLockingConfig - Configuration for record locking timeout\n */\nexport interface IRecordLockingConfig {\n /**\n * Timeout in milliseconds after which a lock expires\n */\n timeout: number;\n}\n\nexport const RecordLockingConfig = createAbstraction<IRecordLockingConfig>(\"RecordLockingConfig\");\n\nexport namespace RecordLockingConfig {\n export type Interface = IRecordLockingConfig;\n}\n\n/**\n * RecordLockingModelProvider - Fetches the private CMS model that stores lock records.\n */\nexport interface IRecordLockingModelProvider {\n get(): Promise<CmsModel>;\n}\n\nexport const RecordLockingModelProvider = createAbstraction<IRecordLockingModelProvider>(\n \"RecordLockingModelProvider\"\n);\n\nexport namespace RecordLockingModelProvider {\n export type Interface = IRecordLockingModelProvider;\n}\n"],"names":["RecordLockingConfig","createAbstraction","RecordLockingModelProvider"],"mappings":";AAaO,MAAMA,sBAAsBC,kBAAwC;AAapE,MAAMC,6BAA6BD,kBACtC"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById";
|
|
3
3
|
import { GetLockRecordRepository as RepositoryAbstraction } from "./abstractions.js";
|
|
4
|
-
import { RecordLockingConfig
|
|
4
|
+
import { RecordLockingConfig } from "../../domain/abstractions.js";
|
|
5
|
+
import { RecordLockingModelProvider } from "../../domain/abstractions.js";
|
|
5
6
|
import type { ILockRecord } from "../../domain/LockRecord.js";
|
|
6
7
|
declare class GetLockRecordRepositoryImpl implements RepositoryAbstraction.Interface {
|
|
7
|
-
private
|
|
8
|
+
private modelProvider;
|
|
8
9
|
private config;
|
|
9
10
|
private getEntryById;
|
|
10
|
-
constructor(
|
|
11
|
+
constructor(modelProvider: RecordLockingModelProvider.Interface, config: RecordLockingConfig.Interface, getEntryById: GetEntryByIdUseCase.Interface);
|
|
11
12
|
get(id: string): Promise<Result<ILockRecord, RepositoryAbstraction.Error>>;
|
|
12
13
|
}
|
|
13
14
|
export declare const GetLockRecordRepository: typeof GetLockRecordRepositoryImpl & {
|
|
@@ -2,35 +2,40 @@ import { Result } from "@webiny/feature/api";
|
|
|
2
2
|
import { GetEntryByIdUseCase } from "@webiny/api-headless-cms/features/contentEntry/GetEntryById";
|
|
3
3
|
import { createIdentifier } from "@webiny/utils";
|
|
4
4
|
import { GetLockRecordRepository } from "./abstractions.js";
|
|
5
|
-
import { RecordLockingConfig,
|
|
5
|
+
import { RecordLockingConfig, RecordLockingModelProvider } from "../../domain/abstractions.js";
|
|
6
6
|
import { LockRecord } from "../../domain/LockRecord.js";
|
|
7
7
|
import { LockRecordNotFoundError, LockRecordPersistenceError } from "../../domain/errors.js";
|
|
8
8
|
import { createLockRecordDatabaseId } from "../../utils/lockRecordDatabaseId.js";
|
|
9
9
|
class GetLockRecordRepositoryImpl {
|
|
10
|
-
constructor(
|
|
11
|
-
this.
|
|
10
|
+
constructor(modelProvider, config, getEntryById){
|
|
11
|
+
this.modelProvider = modelProvider;
|
|
12
12
|
this.config = config;
|
|
13
13
|
this.getEntryById = getEntryById;
|
|
14
14
|
}
|
|
15
15
|
async get(id) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
try {
|
|
17
|
+
const model = await this.modelProvider.get();
|
|
18
|
+
const recordId = createLockRecordDatabaseId(id);
|
|
19
|
+
const entryId = createIdentifier({
|
|
20
|
+
id: recordId,
|
|
21
|
+
version: 1
|
|
22
|
+
});
|
|
23
|
+
const result = await this.getEntryById.execute(model, entryId);
|
|
24
|
+
if (result.isFail()) {
|
|
25
|
+
if ("Cms/Entry/NotFound" === result.error.code) return Result.fail(new LockRecordNotFoundError());
|
|
26
|
+
return Result.fail(new LockRecordPersistenceError(result.error));
|
|
27
|
+
}
|
|
28
|
+
const entry = result.value;
|
|
29
|
+
return Result.ok(new LockRecord(entry, this.config.timeout));
|
|
30
|
+
} catch (error) {
|
|
31
|
+
return Result.fail(new LockRecordPersistenceError(error));
|
|
25
32
|
}
|
|
26
|
-
const entry = result.value;
|
|
27
|
-
return Result.ok(new LockRecord(entry, this.config.timeout));
|
|
28
33
|
}
|
|
29
34
|
}
|
|
30
35
|
const GetLockRecordRepository_GetLockRecordRepository = GetLockRecordRepository.createImplementation({
|
|
31
36
|
implementation: GetLockRecordRepositoryImpl,
|
|
32
37
|
dependencies: [
|
|
33
|
-
|
|
38
|
+
RecordLockingModelProvider,
|
|
34
39
|
RecordLockingConfig,
|
|
35
40
|
GetEntryByIdUseCase
|
|
36
41
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/GetLockRecord/GetLockRecordRepository.js","sources":["../../../src/features/GetLockRecord/GetLockRecordRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById\";\nimport { createIdentifier } from \"@webiny/utils\";\nimport { GetLockRecordRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { RecordLockingConfig
|
|
1
|
+
{"version":3,"file":"features/GetLockRecord/GetLockRecordRepository.js","sources":["../../../src/features/GetLockRecord/GetLockRecordRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetEntryByIdUseCase } from \"@webiny/api-headless-cms/features/contentEntry/GetEntryById\";\nimport { createIdentifier } from \"@webiny/utils\";\nimport { GetLockRecordRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { RecordLockingConfig } from \"~/domain/abstractions.js\";\nimport { RecordLockingModelProvider } 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 { LockRecordNotFoundError, LockRecordPersistenceError } from \"~/domain/errors.js\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId.js\";\n\nclass GetLockRecordRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private modelProvider: RecordLockingModelProvider.Interface,\n private config: RecordLockingConfig.Interface,\n private getEntryById: GetEntryByIdUseCase.Interface\n ) {}\n\n async get(id: string): Promise<Result<ILockRecord, RepositoryAbstraction.Error>> {\n try {\n const model = await this.modelProvider.get();\n\n const recordId = createLockRecordDatabaseId(id);\n const entryId = createIdentifier({\n id: recordId,\n version: 1\n });\n\n const result = await this.getEntryById.execute<LockRecordValues>(model, entryId);\n\n if (result.isFail()) {\n if (result.error.code === \"Cms/Entry/NotFound\") {\n return Result.fail(new LockRecordNotFoundError());\n }\n\n return Result.fail(new LockRecordPersistenceError(result.error));\n }\n\n const entry = result.value;\n\n return Result.ok(new LockRecord(entry, this.config.timeout));\n } catch (error) {\n return Result.fail(new LockRecordPersistenceError(error as Error));\n }\n }\n}\n\nexport const GetLockRecordRepository = RepositoryAbstraction.createImplementation({\n implementation: GetLockRecordRepositoryImpl,\n dependencies: [RecordLockingModelProvider, RecordLockingConfig, GetEntryByIdUseCase]\n});\n"],"names":["GetLockRecordRepositoryImpl","modelProvider","config","getEntryById","id","model","recordId","createLockRecordDatabaseId","entryId","createIdentifier","result","Result","LockRecordNotFoundError","LockRecordPersistenceError","entry","LockRecord","error","GetLockRecordRepository","RepositoryAbstraction","RecordLockingModelProvider","RecordLockingConfig","GetEntryByIdUseCase"],"mappings":";;;;;;;;AAYA,MAAMA;IACF,YACYC,aAAmD,EACnDC,MAAqC,EACrCC,YAA2C,CACrD;aAHUF,aAAa,GAAbA;aACAC,MAAM,GAANA;aACAC,YAAY,GAAZA;IACT;IAEH,MAAM,IAAIC,EAAU,EAA6D;QAC7E,IAAI;YACA,MAAMC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG;YAE1C,MAAMC,WAAWC,2BAA2BH;YAC5C,MAAMI,UAAUC,iBAAiB;gBAC7B,IAAIH;gBACJ,SAAS;YACb;YAEA,MAAMI,SAAS,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAmBL,OAAOG;YAExE,IAAIE,OAAO,MAAM,IAAI;gBACjB,IAAIA,AAAsB,yBAAtBA,OAAO,KAAK,CAAC,IAAI,EACjB,OAAOC,OAAO,IAAI,CAAC,IAAIC;gBAG3B,OAAOD,OAAO,IAAI,CAAC,IAAIE,2BAA2BH,OAAO,KAAK;YAClE;YAEA,MAAMI,QAAQJ,OAAO,KAAK;YAE1B,OAAOC,OAAO,EAAE,CAAC,IAAII,WAAWD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO;QAC9D,EAAE,OAAOE,OAAO;YACZ,OAAOL,OAAO,IAAI,CAAC,IAAIE,2BAA2BG;QACtD;IACJ;AACJ;AAEO,MAAMC,kDAA0BC,wBAAAA,oBAA0C,CAAC;IAC9E,gBAAgBlB;IAChB,cAAc;QAACmB;QAA4BC;QAAqBC;KAAoB;AACxF"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { WebsocketsSendToIdentityUseCase } from "@webiny/api-websockets/features/SendToIdentity/abstractions.js";
|
|
4
4
|
import { KickOutCurrentUserUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
5
5
|
import type { ILockRecord } from "../../domain/index.js";
|
|
6
6
|
declare class KickOutCurrentUserUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
7
7
|
private identityContext;
|
|
8
|
-
private
|
|
9
|
-
constructor(identityContext: IdentityContext.Interface,
|
|
8
|
+
private sendToIdentity;
|
|
9
|
+
constructor(identityContext: IdentityContext.Interface, sendToIdentity: WebsocketsSendToIdentityUseCase.Interface);
|
|
10
10
|
execute(record: ILockRecord): Promise<Result<void, UseCaseAbstraction.Error>>;
|
|
11
11
|
}
|
|
12
12
|
export declare const KickOutCurrentUserUseCase: typeof KickOutCurrentUserUseCaseImpl & {
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { WebsocketsSendToIdentityUseCase } from "@webiny/api-websockets/features/SendToIdentity/abstractions.js";
|
|
4
4
|
import { parseIdentifier } from "@webiny/utils";
|
|
5
5
|
import { KickOutCurrentUserUseCase } from "./abstractions.js";
|
|
6
6
|
class KickOutCurrentUserUseCaseImpl {
|
|
7
|
-
constructor(identityContext,
|
|
7
|
+
constructor(identityContext, sendToIdentity){
|
|
8
8
|
this.identityContext = identityContext;
|
|
9
|
-
this.
|
|
9
|
+
this.sendToIdentity = sendToIdentity;
|
|
10
10
|
}
|
|
11
11
|
async execute(record) {
|
|
12
|
-
if (!this.websocketService) return Result.ok();
|
|
13
12
|
const { lockedBy, id } = record;
|
|
14
13
|
const { id: entryId } = parseIdentifier(id);
|
|
15
14
|
const identity = this.identityContext.getIdentity();
|
|
16
|
-
await this.
|
|
15
|
+
await this.sendToIdentity.execute({
|
|
17
16
|
id: lockedBy.id
|
|
18
17
|
}, {
|
|
19
18
|
action: `recordLocking.entry.kickOut.${entryId}`,
|
|
@@ -29,12 +28,7 @@ const KickOutCurrentUserUseCase_KickOutCurrentUserUseCase = KickOutCurrentUserUs
|
|
|
29
28
|
implementation: KickOutCurrentUserUseCaseImpl,
|
|
30
29
|
dependencies: [
|
|
31
30
|
IdentityContext,
|
|
32
|
-
|
|
33
|
-
WebsocketService,
|
|
34
|
-
{
|
|
35
|
-
optional: true
|
|
36
|
-
}
|
|
37
|
-
]
|
|
31
|
+
WebsocketsSendToIdentityUseCase
|
|
38
32
|
]
|
|
39
33
|
});
|
|
40
34
|
export { KickOutCurrentUserUseCase_KickOutCurrentUserUseCase as KickOutCurrentUserUseCase };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/KickOutCurrentUser/KickOutCurrentUserUseCase.js","sources":["../../../src/features/KickOutCurrentUser/KickOutCurrentUserUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"features/KickOutCurrentUser/KickOutCurrentUserUseCase.js","sources":["../../../src/features/KickOutCurrentUser/KickOutCurrentUserUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { WebsocketsSendToIdentityUseCase } from \"@webiny/api-websockets/features/SendToIdentity/abstractions.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { KickOutCurrentUserUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport type { ILockRecord } from \"~/domain/index.js\";\n\nclass KickOutCurrentUserUseCaseImpl implements UseCaseAbstraction.Interface {\n constructor(\n private identityContext: IdentityContext.Interface,\n private sendToIdentity: WebsocketsSendToIdentityUseCase.Interface\n ) {}\n\n async execute(record: ILockRecord): Promise<Result<void, UseCaseAbstraction.Error>> {\n const { lockedBy, id } = record;\n\n const { id: entryId } = parseIdentifier(id);\n const identity = this.identityContext.getIdentity();\n\n await this.sendToIdentity.execute(\n { id: lockedBy.id },\n {\n action: `recordLocking.entry.kickOut.${entryId}`,\n data: {\n record: record.toObject(),\n user: identity\n }\n }\n );\n\n return Result.ok();\n }\n}\n\nexport const KickOutCurrentUserUseCase = UseCaseAbstraction.createImplementation({\n implementation: KickOutCurrentUserUseCaseImpl,\n dependencies: [IdentityContext, WebsocketsSendToIdentityUseCase]\n});\n"],"names":["KickOutCurrentUserUseCaseImpl","identityContext","sendToIdentity","record","lockedBy","id","entryId","parseIdentifier","identity","Result","KickOutCurrentUserUseCase","UseCaseAbstraction","IdentityContext","WebsocketsSendToIdentityUseCase"],"mappings":";;;;;AAOA,MAAMA;IACF,YACYC,eAA0C,EAC1CC,cAAyD,CACnE;aAFUD,eAAe,GAAfA;aACAC,cAAc,GAAdA;IACT;IAEH,MAAM,QAAQC,MAAmB,EAAmD;QAChF,MAAM,EAAEC,QAAQ,EAAEC,EAAE,EAAE,GAAGF;QAEzB,MAAM,EAAE,IAAIG,OAAO,EAAE,GAAGC,gBAAgBF;QACxC,MAAMG,WAAW,IAAI,CAAC,eAAe,CAAC,WAAW;QAEjD,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B;YAAE,IAAIJ,SAAS,EAAE;QAAC,GAClB;YACI,QAAQ,CAAC,4BAA4B,EAAEE,SAAS;YAChD,MAAM;gBACF,QAAQH,OAAO,QAAQ;gBACvB,MAAMK;YACV;QACJ;QAGJ,OAAOC,OAAO,EAAE;IACpB;AACJ;AAEO,MAAMC,sDAA4BC,0BAAAA,oBAAuC,CAAC;IAC7E,gBAAgBX;IAChB,cAAc;QAACY;QAAiBC;KAAgC;AACpE"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { ListAllLockRecordsRepository as RepositoryAbstraction, ListAllLockRecordsInput, ListAllLockRecordsOutput } from "./abstractions.js";
|
|
3
3
|
import { ListLatestEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries";
|
|
4
|
+
import { CmsWhereMapper } from "@webiny/api-headless-cms";
|
|
4
5
|
import { RecordLockingConfig } from "../../domain/abstractions.js";
|
|
5
|
-
import
|
|
6
|
+
import { RecordLockingModelProvider } from "../../domain/abstractions.js";
|
|
6
7
|
declare class ListAllLockRecordsRepositoryImpl implements RepositoryAbstraction.Interface {
|
|
7
8
|
private config;
|
|
8
9
|
private listEntries;
|
|
9
|
-
private
|
|
10
|
-
|
|
10
|
+
private modelProvider;
|
|
11
|
+
private cmsWhereMapper;
|
|
12
|
+
constructor(config: RecordLockingConfig.Interface, listEntries: ListLatestEntriesUseCase.Interface, modelProvider: RecordLockingModelProvider.Interface, cmsWhereMapper: CmsWhereMapper.Interface);
|
|
11
13
|
execute(input?: ListAllLockRecordsInput): Promise<Result<ListAllLockRecordsOutput, RepositoryAbstraction.Error>>;
|
|
12
14
|
}
|
|
13
15
|
export declare const ListAllLockRecordsRepository: typeof ListAllLockRecordsRepositoryImpl & {
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { ListAllLockRecordsRepository } from "./abstractions.js";
|
|
3
3
|
import { ListLatestEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries";
|
|
4
|
-
import {
|
|
4
|
+
import { CmsWhereMapper } from "@webiny/api-headless-cms";
|
|
5
|
+
import { RecordLockingConfig, RecordLockingModelProvider } from "../../domain/abstractions.js";
|
|
5
6
|
import { LockRecordPersistenceError } from "../../domain/errors.js";
|
|
6
7
|
import { convertWhereCondition } from "../../utils/convertWhereCondition.js";
|
|
7
8
|
import { LockRecord } from "../../domain/LockRecord.js";
|
|
8
9
|
class ListAllLockRecordsRepositoryImpl {
|
|
9
|
-
constructor(config, listEntries,
|
|
10
|
+
constructor(config, listEntries, modelProvider, cmsWhereMapper){
|
|
10
11
|
this.config = config;
|
|
11
12
|
this.listEntries = listEntries;
|
|
12
|
-
this.
|
|
13
|
+
this.modelProvider = modelProvider;
|
|
14
|
+
this.cmsWhereMapper = cmsWhereMapper;
|
|
13
15
|
}
|
|
14
16
|
async execute(input) {
|
|
15
17
|
try {
|
|
18
|
+
const model = await this.modelProvider.get();
|
|
16
19
|
const params = {
|
|
17
20
|
...input,
|
|
18
|
-
where:
|
|
21
|
+
where: this.cmsWhereMapper.map({
|
|
22
|
+
input: convertWhereCondition(input?.where),
|
|
23
|
+
fields: model.fields
|
|
24
|
+
})
|
|
19
25
|
};
|
|
20
|
-
const result = await this.listEntries.execute(
|
|
26
|
+
const result = await this.listEntries.execute(model, params);
|
|
21
27
|
if (result.isFail()) return Result.fail(new LockRecordPersistenceError(result.error));
|
|
22
28
|
const { entries, meta } = result.value;
|
|
23
29
|
const items = entries.map((entry)=>new LockRecord(entry, this.config.timeout));
|
|
@@ -35,7 +41,8 @@ const ListAllLockRecordsRepository_ListAllLockRecordsRepository = ListAllLockRec
|
|
|
35
41
|
dependencies: [
|
|
36
42
|
RecordLockingConfig,
|
|
37
43
|
ListLatestEntriesUseCase,
|
|
38
|
-
|
|
44
|
+
RecordLockingModelProvider,
|
|
45
|
+
CmsWhereMapper
|
|
39
46
|
]
|
|
40
47
|
});
|
|
41
48
|
export { ListAllLockRecordsRepository_ListAllLockRecordsRepository as ListAllLockRecordsRepository };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/ListAllLockRecords/ListAllLockRecordsRepository.js","sources":["../../../src/features/ListAllLockRecords/ListAllLockRecordsRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n ListAllLockRecordsRepository as RepositoryAbstraction,\n ListAllLockRecordsInput,\n ListAllLockRecordsOutput\n} from \"./abstractions.js\";\nimport { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries\";\nimport { RecordLockingConfig
|
|
1
|
+
{"version":3,"file":"features/ListAllLockRecords/ListAllLockRecordsRepository.js","sources":["../../../src/features/ListAllLockRecords/ListAllLockRecordsRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport {\n ListAllLockRecordsRepository as RepositoryAbstraction,\n ListAllLockRecordsInput,\n ListAllLockRecordsOutput\n} from \"./abstractions.js\";\nimport { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries\";\nimport { CmsWhereMapper } from \"@webiny/api-headless-cms\";\nimport { RecordLockingConfig } from \"~/domain/abstractions.js\";\nimport { RecordLockingModelProvider } from \"~/domain/abstractions.js\";\nimport { LockRecordPersistenceError } from \"~/domain/errors.js\";\nimport { convertWhereCondition } from \"~/utils/convertWhereCondition.js\";\nimport { LockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordValues } from \"~/domain/index.js\";\n\nclass ListAllLockRecordsRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private config: RecordLockingConfig.Interface,\n private listEntries: ListLatestEntriesUseCase.Interface,\n private modelProvider: RecordLockingModelProvider.Interface,\n private cmsWhereMapper: CmsWhereMapper.Interface\n ) {}\n\n async execute(\n input?: ListAllLockRecordsInput\n ): Promise<Result<ListAllLockRecordsOutput, RepositoryAbstraction.Error>> {\n try {\n const model = await this.modelProvider.get();\n\n const params = {\n ...input,\n where: this.cmsWhereMapper.map({\n input: convertWhereCondition(input?.where),\n fields: model.fields\n })\n };\n\n const result = await this.listEntries.execute<LockRecordValues>(model, params);\n\n if (result.isFail()) {\n return Result.fail(new LockRecordPersistenceError(result.error));\n }\n\n const { entries, meta } = result.value;\n\n const items = entries.map(entry => new LockRecord(entry, this.config.timeout));\n\n return Result.ok({\n items,\n meta\n });\n } catch (error) {\n return Result.fail(new LockRecordPersistenceError(error as Error));\n }\n }\n}\n\nexport const ListAllLockRecordsRepository = RepositoryAbstraction.createImplementation({\n implementation: ListAllLockRecordsRepositoryImpl,\n dependencies: [\n RecordLockingConfig,\n ListLatestEntriesUseCase,\n RecordLockingModelProvider,\n CmsWhereMapper\n ]\n});\n"],"names":["ListAllLockRecordsRepositoryImpl","config","listEntries","modelProvider","cmsWhereMapper","input","model","params","convertWhereCondition","result","Result","LockRecordPersistenceError","entries","meta","items","entry","LockRecord","error","ListAllLockRecordsRepository","RepositoryAbstraction","RecordLockingConfig","ListLatestEntriesUseCase","RecordLockingModelProvider","CmsWhereMapper"],"mappings":";;;;;;;;AAeA,MAAMA;IACF,YACYC,MAAqC,EACrCC,WAA+C,EAC/CC,aAAmD,EACnDC,cAAwC,CAClD;aAJUH,MAAM,GAANA;aACAC,WAAW,GAAXA;aACAC,aAAa,GAAbA;aACAC,cAAc,GAAdA;IACT;IAEH,MAAM,QACFC,KAA+B,EACuC;QACtE,IAAI;YACA,MAAMC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG;YAE1C,MAAMC,SAAS;gBACX,GAAGF,KAAK;gBACR,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC;oBAC3B,OAAOG,sBAAsBH,OAAO;oBACpC,QAAQC,MAAM,MAAM;gBACxB;YACJ;YAEA,MAAMG,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAmBH,OAAOC;YAEvE,IAAIE,OAAO,MAAM,IACb,OAAOC,OAAO,IAAI,CAAC,IAAIC,2BAA2BF,OAAO,KAAK;YAGlE,MAAM,EAAEG,OAAO,EAAEC,IAAI,EAAE,GAAGJ,OAAO,KAAK;YAEtC,MAAMK,QAAQF,QAAQ,GAAG,CAACG,CAAAA,QAAS,IAAIC,WAAWD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO;YAE5E,OAAOL,OAAO,EAAE,CAAC;gBACbI;gBACAD;YACJ;QACJ,EAAE,OAAOI,OAAO;YACZ,OAAOP,OAAO,IAAI,CAAC,IAAIC,2BAA2BM;QACtD;IACJ;AACJ;AAEO,MAAMC,4DAA+BC,6BAAAA,oBAA0C,CAAC;IACnF,gBAAgBnB;IAChB,cAAc;QACVoB;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { ListLatestEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries";
|
|
3
3
|
import { ListLockRecordsRepository as RepositoryAbstraction, ListLockRecordsInput, ListLockRecordsOutput } from "./abstractions.js";
|
|
4
|
-
import { RecordLockingConfig
|
|
4
|
+
import { RecordLockingConfig } from "../../domain/abstractions.js";
|
|
5
|
+
import { RecordLockingModelProvider } from "../../domain/abstractions.js";
|
|
6
|
+
import { CmsWhereMapper } from "@webiny/api-headless-cms";
|
|
5
7
|
declare class ListLockRecordsRepositoryImpl implements RepositoryAbstraction.Interface {
|
|
6
|
-
private
|
|
8
|
+
private modelProvider;
|
|
7
9
|
private config;
|
|
8
10
|
private listEntries;
|
|
9
|
-
|
|
11
|
+
private cmsWhereMapper;
|
|
12
|
+
constructor(modelProvider: RecordLockingModelProvider.Interface, config: RecordLockingConfig.Interface, listEntries: ListLatestEntriesUseCase.Interface, cmsWhereMapper: CmsWhereMapper.Interface);
|
|
10
13
|
execute(input?: ListLockRecordsInput): Promise<Result<ListLockRecordsOutput, RepositoryAbstraction.Error>>;
|
|
11
14
|
}
|
|
12
15
|
export declare const ListLockRecordsRepository: typeof ListLockRecordsRepositoryImpl & {
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { ListLatestEntriesUseCase } from "@webiny/api-headless-cms/features/contentEntry/ListEntries";
|
|
3
3
|
import { ListLockRecordsRepository } from "./abstractions.js";
|
|
4
|
-
import { RecordLockingConfig,
|
|
4
|
+
import { RecordLockingConfig, RecordLockingModelProvider } from "../../domain/abstractions.js";
|
|
5
5
|
import { LockRecord } from "../../domain/LockRecord.js";
|
|
6
6
|
import { LockRecordPersistenceError } from "../../domain/errors.js";
|
|
7
|
+
import { CmsWhereMapper } from "@webiny/api-headless-cms";
|
|
7
8
|
import { convertWhereCondition } from "../../utils/convertWhereCondition.js";
|
|
8
9
|
class ListLockRecordsRepositoryImpl {
|
|
9
|
-
constructor(
|
|
10
|
-
this.
|
|
10
|
+
constructor(modelProvider, config, listEntries, cmsWhereMapper){
|
|
11
|
+
this.modelProvider = modelProvider;
|
|
11
12
|
this.config = config;
|
|
12
13
|
this.listEntries = listEntries;
|
|
14
|
+
this.cmsWhereMapper = cmsWhereMapper;
|
|
13
15
|
}
|
|
14
16
|
async execute(input) {
|
|
15
17
|
try {
|
|
18
|
+
const model = await this.modelProvider.get();
|
|
16
19
|
const params = {
|
|
17
20
|
...input,
|
|
18
|
-
where:
|
|
21
|
+
where: this.cmsWhereMapper.map({
|
|
22
|
+
input: convertWhereCondition(input?.where),
|
|
23
|
+
fields: model.fields
|
|
24
|
+
})
|
|
19
25
|
};
|
|
20
|
-
const result = await this.listEntries.execute(
|
|
26
|
+
const result = await this.listEntries.execute(model, params);
|
|
21
27
|
if (result.isFail()) return Result.fail(new LockRecordPersistenceError(result.error));
|
|
22
28
|
const { entries, meta } = result.value;
|
|
23
29
|
const items = entries.map((entry)=>new LockRecord(entry, this.config.timeout));
|
|
@@ -33,9 +39,10 @@ class ListLockRecordsRepositoryImpl {
|
|
|
33
39
|
const ListLockRecordsRepository_ListLockRecordsRepository = ListLockRecordsRepository.createImplementation({
|
|
34
40
|
implementation: ListLockRecordsRepositoryImpl,
|
|
35
41
|
dependencies: [
|
|
36
|
-
|
|
42
|
+
RecordLockingModelProvider,
|
|
37
43
|
RecordLockingConfig,
|
|
38
|
-
ListLatestEntriesUseCase
|
|
44
|
+
ListLatestEntriesUseCase,
|
|
45
|
+
CmsWhereMapper
|
|
39
46
|
]
|
|
40
47
|
});
|
|
41
48
|
export { ListLockRecordsRepository_ListLockRecordsRepository as ListLockRecordsRepository };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/ListLockRecords/ListLockRecordsRepository.js","sources":["../../../src/features/ListLockRecords/ListLockRecordsRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries\";\nimport {\n ListLockRecordsRepository as RepositoryAbstraction,\n ListLockRecordsInput,\n ListLockRecordsOutput\n} from \"./abstractions.js\";\nimport { RecordLockingConfig
|
|
1
|
+
{"version":3,"file":"features/ListLockRecords/ListLockRecordsRepository.js","sources":["../../../src/features/ListLockRecords/ListLockRecordsRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { ListLatestEntriesUseCase } from \"@webiny/api-headless-cms/features/contentEntry/ListEntries\";\nimport {\n ListLockRecordsRepository as RepositoryAbstraction,\n ListLockRecordsInput,\n ListLockRecordsOutput\n} from \"./abstractions.js\";\nimport { RecordLockingConfig } from \"~/domain/abstractions.js\";\nimport { RecordLockingModelProvider } from \"~/domain/abstractions.js\";\nimport { LockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordValues } from \"~/domain/types.js\";\nimport { LockRecordPersistenceError } from \"~/domain/errors.js\";\nimport { CmsWhereMapper } from \"@webiny/api-headless-cms\";\nimport { convertWhereCondition } from \"~/utils/convertWhereCondition.js\";\n\nclass ListLockRecordsRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private modelProvider: RecordLockingModelProvider.Interface,\n private config: RecordLockingConfig.Interface,\n private listEntries: ListLatestEntriesUseCase.Interface,\n private cmsWhereMapper: CmsWhereMapper.Interface\n ) {}\n\n async execute(\n input?: ListLockRecordsInput\n ): Promise<Result<ListLockRecordsOutput, RepositoryAbstraction.Error>> {\n try {\n const model = await this.modelProvider.get();\n\n const params = {\n ...input,\n where: this.cmsWhereMapper.map({\n input: convertWhereCondition(input?.where),\n fields: model.fields\n })\n };\n\n const result = await this.listEntries.execute<LockRecordValues>(model, params);\n\n if (result.isFail()) {\n return Result.fail(new LockRecordPersistenceError(result.error));\n }\n\n const { entries, meta } = result.value;\n\n const items = entries.map(entry => new LockRecord(entry, this.config.timeout));\n\n return Result.ok({\n items,\n meta\n });\n } catch (error) {\n return Result.fail(new LockRecordPersistenceError(error as Error));\n }\n }\n}\n\nexport const ListLockRecordsRepository = RepositoryAbstraction.createImplementation({\n implementation: ListLockRecordsRepositoryImpl,\n dependencies: [\n RecordLockingModelProvider,\n RecordLockingConfig,\n ListLatestEntriesUseCase,\n CmsWhereMapper\n ]\n});\n"],"names":["ListLockRecordsRepositoryImpl","modelProvider","config","listEntries","cmsWhereMapper","input","model","params","convertWhereCondition","result","Result","LockRecordPersistenceError","entries","meta","items","entry","LockRecord","error","ListLockRecordsRepository","RepositoryAbstraction","RecordLockingModelProvider","RecordLockingConfig","ListLatestEntriesUseCase","CmsWhereMapper"],"mappings":";;;;;;;;AAeA,MAAMA;IACF,YACYC,aAAmD,EACnDC,MAAqC,EACrCC,WAA+C,EAC/CC,cAAwC,CAClD;aAJUH,aAAa,GAAbA;aACAC,MAAM,GAANA;aACAC,WAAW,GAAXA;aACAC,cAAc,GAAdA;IACT;IAEH,MAAM,QACFC,KAA4B,EACuC;QACnE,IAAI;YACA,MAAMC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG;YAE1C,MAAMC,SAAS;gBACX,GAAGF,KAAK;gBACR,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC;oBAC3B,OAAOG,sBAAsBH,OAAO;oBACpC,QAAQC,MAAM,MAAM;gBACxB;YACJ;YAEA,MAAMG,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAmBH,OAAOC;YAEvE,IAAIE,OAAO,MAAM,IACb,OAAOC,OAAO,IAAI,CAAC,IAAIC,2BAA2BF,OAAO,KAAK;YAGlE,MAAM,EAAEG,OAAO,EAAEC,IAAI,EAAE,GAAGJ,OAAO,KAAK;YAEtC,MAAMK,QAAQF,QAAQ,GAAG,CAACG,CAAAA,QAAS,IAAIC,WAAWD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO;YAE5E,OAAOL,OAAO,EAAE,CAAC;gBACbI;gBACAD;YACJ;QACJ,EAAE,OAAOI,OAAO;YACZ,OAAOP,OAAO,IAAI,CAAC,IAAIC,2BAA2BM;QACtD;IACJ;AACJ;AAEO,MAAMC,sDAA4BC,0BAAAA,oBAA0C,CAAC;IAChF,gBAAgBnB;IAChB,cAAc;QACVoB;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { CreateEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/CreateEntry";
|
|
3
3
|
import { LockEntryInput, LockEntryRepository as RepositoryAbstraction } from "./abstractions.js";
|
|
4
|
-
import { RecordLockingConfig
|
|
4
|
+
import { RecordLockingConfig } from "../../domain/abstractions.js";
|
|
5
|
+
import { RecordLockingModelProvider } from "../../domain/abstractions.js";
|
|
5
6
|
import type { ILockRecord } from "../../domain/LockRecord.js";
|
|
6
7
|
declare class LockEntryRepositoryImpl implements RepositoryAbstraction.Interface {
|
|
7
|
-
private
|
|
8
|
+
private modelProvider;
|
|
8
9
|
private config;
|
|
9
10
|
private createEntry;
|
|
10
|
-
constructor(
|
|
11
|
+
constructor(modelProvider: RecordLockingModelProvider.Interface, config: RecordLockingConfig.Interface, createEntry: CreateEntryUseCase.Interface);
|
|
11
12
|
create(input: LockEntryInput): Promise<Result<ILockRecord, RepositoryAbstraction.Error>>;
|
|
12
13
|
}
|
|
13
14
|
export declare const LockEntryRepository: typeof LockEntryRepositoryImpl & {
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { CreateEntryUseCase } from "@webiny/api-headless-cms/features/contentEntry/CreateEntry";
|
|
3
3
|
import { LockEntryRepository } from "./abstractions.js";
|
|
4
|
-
import { RecordLockingConfig,
|
|
4
|
+
import { RecordLockingConfig, RecordLockingModelProvider } from "../../domain/abstractions.js";
|
|
5
5
|
import { LockRecord } from "../../domain/LockRecord.js";
|
|
6
6
|
import { LockRecordPersistenceError } from "../../domain/errors.js";
|
|
7
7
|
import { createLockRecordDatabaseId } from "../../utils/lockRecordDatabaseId.js";
|
|
8
8
|
class LockEntryRepositoryImpl {
|
|
9
|
-
constructor(
|
|
10
|
-
this.
|
|
9
|
+
constructor(modelProvider, config, createEntry){
|
|
10
|
+
this.modelProvider = modelProvider;
|
|
11
11
|
this.config = config;
|
|
12
12
|
this.createEntry = createEntry;
|
|
13
13
|
}
|
|
14
14
|
async create(input) {
|
|
15
15
|
try {
|
|
16
|
+
const model = await this.modelProvider.get();
|
|
16
17
|
const id = createLockRecordDatabaseId(input.id);
|
|
17
18
|
const values = {
|
|
18
19
|
targetId: input.id,
|
|
19
20
|
type: input.type,
|
|
20
21
|
actions: []
|
|
21
22
|
};
|
|
22
|
-
const result = await this.createEntry.execute(
|
|
23
|
+
const result = await this.createEntry.execute(model, {
|
|
23
24
|
id,
|
|
24
25
|
values
|
|
25
26
|
});
|
|
@@ -35,7 +36,7 @@ class LockEntryRepositoryImpl {
|
|
|
35
36
|
const LockEntryRepository_LockEntryRepository = LockEntryRepository.createImplementation({
|
|
36
37
|
implementation: LockEntryRepositoryImpl,
|
|
37
38
|
dependencies: [
|
|
38
|
-
|
|
39
|
+
RecordLockingModelProvider,
|
|
39
40
|
RecordLockingConfig,
|
|
40
41
|
CreateEntryUseCase
|
|
41
42
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/LockEntry/LockEntryRepository.js","sources":["../../../src/features/LockEntry/LockEntryRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { CreateEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/CreateEntry\";\nimport type { CmsEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { LockEntryInput, LockEntryRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { RecordLockingConfig
|
|
1
|
+
{"version":3,"file":"features/LockEntry/LockEntryRepository.js","sources":["../../../src/features/LockEntry/LockEntryRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { CreateEntryUseCase } from \"@webiny/api-headless-cms/features/contentEntry/CreateEntry\";\nimport type { CmsEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { LockEntryInput, LockEntryRepository as RepositoryAbstraction } from \"./abstractions.js\";\nimport { RecordLockingConfig } from \"~/domain/abstractions.js\";\nimport { RecordLockingModelProvider } 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 LockEntryRepositoryImpl implements RepositoryAbstraction.Interface {\n constructor(\n private modelProvider: RecordLockingModelProvider.Interface,\n private config: RecordLockingConfig.Interface,\n private createEntry: CreateEntryUseCase.Interface\n ) {}\n\n async create(input: LockEntryInput): Promise<Result<ILockRecord, RepositoryAbstraction.Error>> {\n try {\n const model = await this.modelProvider.get();\n\n const id = createLockRecordDatabaseId(input.id);\n\n const values: LockRecordValues = {\n targetId: input.id,\n type: input.type,\n actions: []\n };\n\n const result = await this.createEntry.execute(model, {\n id,\n values\n });\n\n if (result.isFail()) {\n return Result.fail(new LockRecordPersistenceError(result.error));\n }\n\n const entry = result.value as CmsEntry<LockRecordValues>;\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 LockEntryRepository = RepositoryAbstraction.createImplementation({\n implementation: LockEntryRepositoryImpl,\n dependencies: [RecordLockingModelProvider, RecordLockingConfig, CreateEntryUseCase]\n});\n"],"names":["LockEntryRepositoryImpl","modelProvider","config","createEntry","input","model","id","createLockRecordDatabaseId","values","result","Result","LockRecordPersistenceError","entry","lockRecord","LockRecord","error","LockEntryRepository","RepositoryAbstraction","RecordLockingModelProvider","RecordLockingConfig","CreateEntryUseCase"],"mappings":";;;;;;;AAYA,MAAMA;IACF,YACYC,aAAmD,EACnDC,MAAqC,EACrCC,WAAyC,CACnD;aAHUF,aAAa,GAAbA;aACAC,MAAM,GAANA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,OAAOC,KAAqB,EAA6D;QAC3F,IAAI;YACA,MAAMC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG;YAE1C,MAAMC,KAAKC,2BAA2BH,MAAM,EAAE;YAE9C,MAAMI,SAA2B;gBAC7B,UAAUJ,MAAM,EAAE;gBAClB,MAAMA,MAAM,IAAI;gBAChB,SAAS,EAAE;YACf;YAEA,MAAMK,SAAS,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAACJ,OAAO;gBACjDC;gBACAE;YACJ;YAEA,IAAIC,OAAO,MAAM,IACb,OAAOC,OAAO,IAAI,CAAC,IAAIC,2BAA2BF,OAAO,KAAK;YAGlE,MAAMG,QAAQH,OAAO,KAAK;YAC1B,MAAMI,aAAa,IAAIC,WAAWF,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO;YAE5D,OAAOF,OAAO,EAAE,CAACG;QACrB,EAAE,OAAOE,OAAO;YACZ,OAAOL,OAAO,IAAI,CAAC,IAAIC,2BAA2BI;QACtD;IACJ;AACJ;AAEO,MAAMC,0CAAsBC,oBAAAA,oBAA0C,CAAC;IAC1E,gBAAgBjB;IAChB,cAAc;QAACkB;QAA4BC;QAAqBC;KAAmB;AACvF"}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import type { CmsModel } from "@webiny/api-headless-cms/types";
|
|
2
1
|
export interface RecordLockingParams {
|
|
3
2
|
/**
|
|
4
3
|
* Timeout in milliseconds after which a lock expires
|
|
5
4
|
*/
|
|
6
5
|
timeout: number;
|
|
7
|
-
/**
|
|
8
|
-
* The CMS model for storing lock records
|
|
9
|
-
*/
|
|
10
|
-
model: CmsModel;
|
|
11
6
|
}
|
|
12
7
|
export declare const RecordLockingFeature: {
|
|
13
8
|
name: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
|
-
import { RecordLockingConfig
|
|
2
|
+
import { RecordLockingConfig } from "../domain/abstractions.js";
|
|
3
|
+
import { RecordLockingModelProvider } from "./RecordLockingModelProvider.js";
|
|
3
4
|
import { GetLockRecordFeature } from "./GetLockRecord/feature.js";
|
|
4
5
|
import { GetLockedEntryLockRecordFeature } from "./GetLockedEntryLockRecord/feature.js";
|
|
5
6
|
import { KickOutCurrentUserFeature } from "./KickOutCurrentUser/feature.js";
|
|
@@ -16,7 +17,7 @@ const RecordLockingFeature = createFeature({
|
|
|
16
17
|
container.registerInstance(RecordLockingConfig, {
|
|
17
18
|
timeout: params.timeout
|
|
18
19
|
});
|
|
19
|
-
container.
|
|
20
|
+
container.register(RecordLockingModelProvider);
|
|
20
21
|
GetLockRecordFeature.register(container);
|
|
21
22
|
GetLockedEntryLockRecordFeature.register(container);
|
|
22
23
|
KickOutCurrentUserFeature.register(container);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/RecordLockingFeature.js","sources":["../../src/features/RecordLockingFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport
|
|
1
|
+
{"version":3,"file":"features/RecordLockingFeature.js","sources":["../../src/features/RecordLockingFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { RecordLockingConfig } from \"~/domain/abstractions.js\";\nimport { RecordLockingModelProvider } from \"./RecordLockingModelProvider.js\";\nimport { GetLockRecordFeature } from \"./GetLockRecord/feature.js\";\nimport { GetLockedEntryLockRecordFeature } from \"./GetLockedEntryLockRecord/feature.js\";\nimport { KickOutCurrentUserFeature } from \"./KickOutCurrentUser/feature.js\";\nimport { ListLockRecordsFeature } from \"./ListLockRecords/feature.js\";\nimport { ListAllLockRecordsFeature } from \"./ListAllLockRecords/feature.js\";\nimport { IsEntryLockedFeature } from \"./IsEntryLocked/feature.js\";\nimport { LockEntryFeature } from \"./LockEntry/feature.js\";\nimport { UpdateEntryLockFeature } from \"./UpdateEntryLock/feature.js\";\nimport { UnlockEntryFeature } from \"./UnlockEntry/feature.js\";\nimport { UnlockEntryRequestFeature } from \"./UnlockEntryRequest/feature.js\";\n\nexport interface RecordLockingParams {\n /**\n * Timeout in milliseconds after which a lock expires\n */\n timeout: number;\n}\n\nexport const RecordLockingFeature = createFeature<RecordLockingParams>({\n name: \"RecordLockingManagement\",\n register(container, params) {\n // Register domain abstractions\n container.registerInstance(RecordLockingConfig, { timeout: params.timeout });\n container.register(RecordLockingModelProvider);\n\n // Register all sub-features\n GetLockRecordFeature.register(container);\n GetLockedEntryLockRecordFeature.register(container);\n KickOutCurrentUserFeature.register(container);\n ListLockRecordsFeature.register(container);\n ListAllLockRecordsFeature.register(container);\n IsEntryLockedFeature.register(container);\n LockEntryFeature.register(container);\n UpdateEntryLockFeature.register(container);\n UnlockEntryFeature.register(container);\n UnlockEntryRequestFeature.register(container);\n }\n});\n"],"names":["RecordLockingFeature","createFeature","container","params","RecordLockingConfig","RecordLockingModelProvider","GetLockRecordFeature","GetLockedEntryLockRecordFeature","KickOutCurrentUserFeature","ListLockRecordsFeature","ListAllLockRecordsFeature","IsEntryLockedFeature","LockEntryFeature","UpdateEntryLockFeature","UnlockEntryFeature","UnlockEntryRequestFeature"],"mappings":";;;;;;;;;;;;;AAqBO,MAAMA,uBAAuBC,cAAmC;IACnE,MAAM;IACN,UAASC,SAAS,EAAEC,MAAM;QAEtBD,UAAU,gBAAgB,CAACE,qBAAqB;YAAE,SAASD,OAAO,OAAO;QAAC;QAC1ED,UAAU,QAAQ,CAACG;QAGnBC,qBAAqB,QAAQ,CAACJ;QAC9BK,gCAAgC,QAAQ,CAACL;QACzCM,0BAA0B,QAAQ,CAACN;QACnCO,uBAAuB,QAAQ,CAACP;QAChCQ,0BAA0B,QAAQ,CAACR;QACnCS,qBAAqB,QAAQ,CAACT;QAC9BU,iBAAiB,QAAQ,CAACV;QAC1BW,uBAAuB,QAAQ,CAACX;QAChCY,mBAAmB,QAAQ,CAACZ;QAC5Ba,0BAA0B,QAAQ,CAACb;IACvC;AACJ"}
|