@webiny/api-record-locking 0.0.0-unstable.c27f4d8a31 → 0.0.0-unstable.d0f34a8194
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/LockRecord.js +63 -70
- package/domain/LockRecord.js.map +1 -1
- package/domain/RecordLockingModel.js +27 -23
- package/domain/RecordLockingModel.js.map +1 -1
- package/domain/abstractions.d.ts +9 -3
- package/domain/abstractions.js +3 -7
- package/domain/abstractions.js.map +1 -1
- package/domain/calculateExpiresOn.js +5 -6
- package/domain/calculateExpiresOn.js.map +1 -1
- package/domain/errors.js +71 -81
- package/domain/errors.js.map +1 -1
- package/domain/index.js +0 -2
- package/domain/types.js +6 -9
- package/domain/types.js.map +1 -1
- package/features/GetLockRecord/GetLockRecordRepository.d.ts +4 -3
- package/features/GetLockRecord/GetLockRecordRepository.js +33 -25
- package/features/GetLockRecord/GetLockRecordRepository.js.map +1 -1
- package/features/GetLockRecord/GetLockRecordUseCase.js +13 -10
- package/features/GetLockRecord/GetLockRecordUseCase.js.map +1 -1
- package/features/GetLockRecord/abstractions.js +3 -14
- package/features/GetLockRecord/abstractions.js.map +1 -1
- package/features/GetLockRecord/feature.d.ts +4 -1
- package/features/GetLockRecord/feature.js +7 -6
- package/features/GetLockRecord/feature.js.map +1 -1
- package/features/GetLockRecord/index.js +0 -2
- package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.d.ts +1 -1
- package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js +20 -29
- package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js.map +1 -1
- package/features/GetLockedEntryLockRecord/abstractions.js +2 -10
- package/features/GetLockedEntryLockRecord/abstractions.js.map +1 -1
- package/features/GetLockedEntryLockRecord/feature.d.ts +4 -1
- package/features/GetLockedEntryLockRecord/feature.js +6 -5
- package/features/GetLockedEntryLockRecord/feature.js.map +1 -1
- package/features/GetLockedEntryLockRecord/index.js +0 -2
- package/features/IsEntryLocked/IsEntryLockedUseCase.d.ts +1 -1
- package/features/IsEntryLocked/IsEntryLockedUseCase.js +23 -29
- package/features/IsEntryLocked/IsEntryLockedUseCase.js.map +1 -1
- package/features/IsEntryLocked/abstractions.js +2 -9
- package/features/IsEntryLocked/abstractions.js.map +1 -1
- package/features/IsEntryLocked/feature.d.ts +4 -1
- package/features/IsEntryLocked/feature.js +6 -5
- package/features/IsEntryLocked/feature.js.map +1 -1
- package/features/IsEntryLocked/index.js +0 -2
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.d.ts +4 -4
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js +28 -34
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js.map +1 -1
- package/features/KickOutCurrentUser/abstractions.js +2 -6
- package/features/KickOutCurrentUser/abstractions.js.map +1 -1
- package/features/KickOutCurrentUser/feature.d.ts +4 -1
- package/features/KickOutCurrentUser/feature.js +6 -5
- package/features/KickOutCurrentUser/feature.js.map +1 -1
- package/features/KickOutCurrentUser/index.js +0 -2
- package/features/ListAllLockRecords/ListAllLockRecordsRepository.d.ts +5 -3
- package/features/ListAllLockRecords/ListAllLockRecordsRepository.js +39 -32
- package/features/ListAllLockRecords/ListAllLockRecordsRepository.js.map +1 -1
- package/features/ListAllLockRecords/ListAllLockRecordsUseCase.js +13 -10
- package/features/ListAllLockRecords/ListAllLockRecordsUseCase.js.map +1 -1
- package/features/ListAllLockRecords/abstractions.js +3 -14
- package/features/ListAllLockRecords/abstractions.js.map +1 -1
- package/features/ListAllLockRecords/feature.d.ts +4 -1
- package/features/ListAllLockRecords/feature.js +7 -6
- package/features/ListAllLockRecords/feature.js.map +1 -1
- package/features/ListAllLockRecords/index.js +0 -2
- package/features/ListLockRecords/ListLockRecordsRepository.d.ts +6 -3
- package/features/ListLockRecords/ListLockRecordsRepository.js +39 -32
- package/features/ListLockRecords/ListLockRecordsRepository.js.map +1 -1
- package/features/ListLockRecords/ListLockRecordsUseCase.d.ts +1 -1
- package/features/ListLockRecords/ListLockRecordsUseCase.js +27 -24
- package/features/ListLockRecords/ListLockRecordsUseCase.js.map +1 -1
- package/features/ListLockRecords/abstractions.js +3 -14
- package/features/ListLockRecords/abstractions.js.map +1 -1
- package/features/ListLockRecords/feature.d.ts +4 -1
- package/features/ListLockRecords/feature.js +7 -6
- package/features/ListLockRecords/feature.js.map +1 -1
- package/features/ListLockRecords/index.js +0 -2
- package/features/LockEntry/LockEntryEventsDecorator.d.ts +1 -1
- package/features/LockEntry/LockEntryEventsDecorator.js +32 -32
- package/features/LockEntry/LockEntryEventsDecorator.js.map +1 -1
- package/features/LockEntry/LockEntryRepository.d.ts +4 -3
- package/features/LockEntry/LockEntryRepository.js +35 -31
- package/features/LockEntry/LockEntryRepository.js.map +1 -1
- package/features/LockEntry/LockEntryUseCase.js +21 -26
- package/features/LockEntry/LockEntryUseCase.js.map +1 -1
- package/features/LockEntry/abstractions.js +3 -14
- package/features/LockEntry/abstractions.js.map +1 -1
- package/features/LockEntry/events.d.ts +2 -2
- package/features/LockEntry/events.js +26 -34
- package/features/LockEntry/events.js.map +1 -1
- package/features/LockEntry/feature.d.ts +4 -1
- package/features/LockEntry/feature.js +8 -7
- package/features/LockEntry/feature.js.map +1 -1
- package/features/LockEntry/index.js +0 -2
- package/features/RecordLockingFeature.d.ts +4 -6
- package/features/RecordLockingFeature.js +21 -22
- 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/UnlockEntryEventsDecorator.d.ts +1 -1
- package/features/UnlockEntry/UnlockEntryEventsDecorator.js +33 -33
- package/features/UnlockEntry/UnlockEntryEventsDecorator.js.map +1 -1
- package/features/UnlockEntry/UnlockEntryRepository.d.ts +3 -3
- package/features/UnlockEntry/UnlockEntryRepository.js +31 -28
- package/features/UnlockEntry/UnlockEntryRepository.js.map +1 -1
- package/features/UnlockEntry/UnlockEntryUseCase.d.ts +1 -1
- package/features/UnlockEntry/UnlockEntryUseCase.js +54 -70
- package/features/UnlockEntry/UnlockEntryUseCase.js.map +1 -1
- package/features/UnlockEntry/abstractions.js +3 -14
- package/features/UnlockEntry/abstractions.js.map +1 -1
- package/features/UnlockEntry/events.d.ts +2 -2
- package/features/UnlockEntry/events.js +26 -34
- package/features/UnlockEntry/events.js.map +1 -1
- package/features/UnlockEntry/feature.d.ts +4 -1
- package/features/UnlockEntry/feature.js +8 -7
- package/features/UnlockEntry/feature.js.map +1 -1
- package/features/UnlockEntry/hasFullAccessPermission.d.ts +1 -1
- package/features/UnlockEntry/hasFullAccessPermission.js +6 -7
- package/features/UnlockEntry/hasFullAccessPermission.js.map +1 -1
- package/features/UnlockEntry/index.js +0 -2
- package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.d.ts +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js +32 -32
- package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js.map +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.d.ts +4 -4
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js +34 -32
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js.map +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.d.ts +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js +63 -80
- package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js.map +1 -1
- package/features/UnlockEntryRequest/abstractions.js +3 -14
- package/features/UnlockEntryRequest/abstractions.js.map +1 -1
- package/features/UnlockEntryRequest/events.d.ts +2 -2
- package/features/UnlockEntryRequest/events.js +26 -34
- package/features/UnlockEntryRequest/events.js.map +1 -1
- package/features/UnlockEntryRequest/feature.d.ts +4 -1
- package/features/UnlockEntryRequest/feature.js +8 -7
- package/features/UnlockEntryRequest/feature.js.map +1 -1
- package/features/UnlockEntryRequest/index.js +0 -2
- package/features/UpdateEntryLock/UpdateEntryLockRepository.d.ts +5 -4
- package/features/UpdateEntryLock/UpdateEntryLockRepository.js +48 -50
- package/features/UpdateEntryLock/UpdateEntryLockRepository.js.map +1 -1
- package/features/UpdateEntryLock/UpdateEntryLockUseCase.d.ts +1 -1
- package/features/UpdateEntryLock/UpdateEntryLockUseCase.js +41 -52
- package/features/UpdateEntryLock/UpdateEntryLockUseCase.js.map +1 -1
- package/features/UpdateEntryLock/abstractions.js +3 -14
- package/features/UpdateEntryLock/abstractions.js.map +1 -1
- package/features/UpdateEntryLock/feature.d.ts +4 -1
- package/features/UpdateEntryLock/feature.js +7 -6
- package/features/UpdateEntryLock/feature.js.map +1 -1
- package/features/UpdateEntryLock/index.js +0 -2
- package/graphql/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 +4 -10
- package/graphql/checkPermissions.js.map +1 -1
- package/graphql/resolve.d.ts +1 -1
- package/graphql/resolve.js +16 -18
- package/graphql/resolve.js.map +1 -1
- package/index.d.ts +2 -9
- package/index.js +1 -62
- package/package.json +27 -22
- package/types.js +6 -9
- package/types.js.map +1 -1
- package/utils/convertWhereCondition.js +20 -32
- package/utils/convertWhereCondition.js.map +1 -1
- package/utils/getTimeout.js +8 -15
- package/utils/getTimeout.js.map +1 -1
- package/utils/lockRecordDatabaseId.js +6 -11
- package/utils/lockRecordDatabaseId.js.map +1 -1
- package/domain/index.js.map +0 -1
- package/features/GetLockRecord/index.js.map +0 -1
- package/features/GetLockedEntryLockRecord/index.js.map +0 -1
- package/features/IsEntryLocked/index.js.map +0 -1
- package/features/KickOutCurrentUser/index.js.map +0 -1
- package/features/ListAllLockRecords/index.js.map +0 -1
- package/features/ListLockRecords/index.js.map +0 -1
- package/features/LockEntry/index.js.map +0 -1
- package/features/UnlockEntry/index.js.map +0 -1
- package/features/UnlockEntryRequest/index.js.map +0 -1
- package/features/UpdateEntryLock/index.js.map +0 -1
- package/graphql/schema.d.ts +0 -11
- package/graphql/schema.js +0 -318
- package/graphql/schema.js.map +0 -1
- package/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/UpdateEntryLock/abstractions.js","sources":["../../../src/features/UpdateEntryLock/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { ILockRecord } from \"~/domain/LockRecord.js\";\nimport type { LockRecordEntryType } from \"~/domain/types.js\";\nimport type {\n LockRecordNotFoundError,\n LockRecordPersistenceError,\n IdentityMismatchError,\n UpdateEntryLockError\n} from \"~/domain/errors.js\";\n\n// Input types\nexport interface UpdateEntryLockInput {\n id: string;\n type: LockRecordEntryType;\n}\n\n/**\n * UpdateEntryLock Use Case - Updates lock timestamp to keep it alive\n */\nexport interface IUpdateEntryLockUseCase {\n execute(input: UpdateEntryLockInput): Promise<Result<ILockRecord, UseCaseError>>;\n}\n\nexport interface IUpdateEntryLockUseCaseErrors {\n notFound: LockRecordNotFoundError;\n notSameIdentity: IdentityMismatchError;\n persistence: LockRecordPersistenceError;\n updateError: UpdateEntryLockError;\n}\n\ntype UseCaseError = IUpdateEntryLockUseCaseErrors[keyof IUpdateEntryLockUseCaseErrors];\n\nexport const UpdateEntryLockUseCase =\n createAbstraction<IUpdateEntryLockUseCase>(\"UpdateEntryLockUseCase\");\n\nexport namespace UpdateEntryLockUseCase {\n export type Interface = IUpdateEntryLockUseCase;\n export type Error = UseCaseError;\n}\n\n/**\n * UpdateEntryLockRepository - Updates lock record in storage\n */\nexport interface IUpdateEntryLockRepository {\n update(\n lockRecordId: string,\n updateOwner: boolean\n ): Promise<Result<ILockRecord, RepositoryError>>;\n}\n\nexport interface IUpdateEntryLockRepositoryErrors {\n persistence: LockRecordPersistenceError;\n}\n\ntype RepositoryError = IUpdateEntryLockRepositoryErrors[keyof IUpdateEntryLockRepositoryErrors];\n\nexport const UpdateEntryLockRepository = createAbstraction<IUpdateEntryLockRepository>(\n \"UpdateEntryLockRepository\"\n);\n\nexport namespace UpdateEntryLockRepository {\n export type Interface = IUpdateEntryLockRepository;\n export type Error = RepositoryError;\n}\n"],"names":["UpdateEntryLockUseCase","createAbstraction","UpdateEntryLockRepository"],"mappings":";AAiCO,MAAMA,yBACTC,kBAA2C;AAuBxC,MAAMC,4BAA4BD,kBACrC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/api";
|
|
2
2
|
import { UpdateEntryLockUseCase } from "./UpdateEntryLockUseCase.js";
|
|
3
3
|
import { UpdateEntryLockRepository } from "./UpdateEntryLockRepository.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const UpdateEntryLockFeature = createFeature({
|
|
5
|
+
name: "UpdateEntryLock",
|
|
6
|
+
register (container) {
|
|
7
|
+
container.register(UpdateEntryLockUseCase);
|
|
8
|
+
container.register(UpdateEntryLockRepository).inSingletonScope();
|
|
9
|
+
}
|
|
10
10
|
});
|
|
11
|
+
export { UpdateEntryLockFeature };
|
|
11
12
|
|
|
12
13
|
//# sourceMappingURL=feature.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"features/UpdateEntryLock/feature.js","sources":["../../../src/features/UpdateEntryLock/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { UpdateEntryLockUseCase } from \"./UpdateEntryLockUseCase.js\";\nimport { UpdateEntryLockRepository } from \"./UpdateEntryLockRepository.js\";\n\nexport const UpdateEntryLockFeature = createFeature({\n name: \"UpdateEntryLock\",\n register(container) {\n container.register(UpdateEntryLockUseCase);\n container.register(UpdateEntryLockRepository).inSingletonScope();\n }\n});\n"],"names":["UpdateEntryLockFeature","createFeature","container","UpdateEntryLockUseCase","UpdateEntryLockRepository"],"mappings":";;;AAIO,MAAMA,yBAAyBC,cAAc;IAChD,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBD,UAAU,QAAQ,CAACE,2BAA2B,gBAAgB;IAClE;AACJ"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { GraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
|
+
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
3
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
4
|
+
import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels/index.js";
|
|
5
|
+
import { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/exports/api/cms/graphql.js";
|
|
6
|
+
import { RecordLockingModelProvider } from "../domain/abstractions.js";
|
|
7
|
+
/**
|
|
8
|
+
* The record locking GraphQL schema. The lock record type is rendered from the lock record model,
|
|
9
|
+
* which is loaded when the schema is composed.
|
|
10
|
+
*/
|
|
11
|
+
declare class RecordLockingGraphQLSchemaImpl implements GraphQLSchemaFactory.Interface {
|
|
12
|
+
private readonly tenantContext;
|
|
13
|
+
private readonly identityContext;
|
|
14
|
+
private readonly modelProvider;
|
|
15
|
+
private readonly listModelsUseCase;
|
|
16
|
+
private readonly fieldRegistry;
|
|
17
|
+
constructor(tenantContext: TenantContext.Interface, identityContext: IdentityContext.Interface, modelProvider: RecordLockingModelProvider.Interface, listModelsUseCase: ListModelsUseCase.Interface, fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface);
|
|
18
|
+
getSchemaKey(): Promise<string>;
|
|
19
|
+
execute(builder: GraphQLSchemaFactory.SchemaBuilder): Promise<GraphQLSchemaFactory.SchemaBuilder>;
|
|
20
|
+
private loadInputs;
|
|
21
|
+
}
|
|
22
|
+
export declare const RecordLockingGraphQLSchema: typeof RecordLockingGraphQLSchemaImpl & {
|
|
23
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-graphql/graphql/abstractions.public.js").IGraphQLSchemaFactory>;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
import { GraphQLSchemaFactory } from "@webiny/api-graphql/graphql/abstractions.js";
|
|
2
|
+
import { createModelSchemaKey } from "@webiny/api-headless-cms/utils/createModelSchemaKey.js";
|
|
3
|
+
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
4
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
5
|
+
import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels/index.js";
|
|
6
|
+
import { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/exports/api/cms/graphql.js";
|
|
7
|
+
import { renderFields } from "@webiny/api-headless-cms/utils/renderFields.js";
|
|
8
|
+
import { renderListFilterFields } from "@webiny/api-headless-cms/utils/renderListFilterFields.js";
|
|
9
|
+
import { renderSortEnum } from "@webiny/api-headless-cms/utils/renderSortEnum.js";
|
|
10
|
+
import { RecordLockingModelProvider } from "../domain/abstractions.js";
|
|
11
|
+
import { IsEntryLockedUseCase } from "../features/IsEntryLocked/abstractions.js";
|
|
12
|
+
import { GetLockRecordUseCase } from "../features/GetLockRecord/abstractions.js";
|
|
13
|
+
import { GetLockedEntryLockRecordUseCase } from "../features/GetLockedEntryLockRecord/abstractions.js";
|
|
14
|
+
import { ListLockRecordsUseCase } from "../features/ListLockRecords/abstractions.js";
|
|
15
|
+
import { ListAllLockRecordsUseCase } from "../features/ListAllLockRecords/abstractions.js";
|
|
16
|
+
import { LockEntryUseCase } from "../features/LockEntry/abstractions.js";
|
|
17
|
+
import { UpdateEntryLockUseCase } from "../features/UpdateEntryLock/abstractions.js";
|
|
18
|
+
import { UnlockEntryUseCase } from "../features/UnlockEntry/abstractions.js";
|
|
19
|
+
import { UnlockEntryRequestUseCase } from "../features/UnlockEntryRequest/abstractions.js";
|
|
20
|
+
import { resolve, resolveList } from "./resolve.js";
|
|
21
|
+
import { checkPermissions } from "./checkPermissions.js";
|
|
22
|
+
function renderTypeDefs(params) {
|
|
23
|
+
const { model, fieldRegistry } = params;
|
|
24
|
+
const models = params.models.filter((model)=>model.fields.length > 0);
|
|
25
|
+
const recordLockingFields = renderFields({
|
|
26
|
+
models,
|
|
27
|
+
model,
|
|
28
|
+
fields: model.fields,
|
|
29
|
+
type: "manage",
|
|
30
|
+
fieldRegistry
|
|
31
|
+
});
|
|
32
|
+
const listFilterFieldsRender = renderListFilterFields({
|
|
33
|
+
model,
|
|
34
|
+
fields: model.fields,
|
|
35
|
+
type: "manage",
|
|
36
|
+
fieldRegistry,
|
|
37
|
+
excludeFields: [
|
|
38
|
+
"entryId"
|
|
39
|
+
]
|
|
40
|
+
});
|
|
41
|
+
const sortEnumRender = renderSortEnum({
|
|
42
|
+
model,
|
|
43
|
+
fields: model.fields,
|
|
44
|
+
fieldRegistry,
|
|
45
|
+
sorters: []
|
|
46
|
+
});
|
|
47
|
+
return `
|
|
48
|
+
${recordLockingFields.map((f)=>f.typeDefs).join("\n")}
|
|
49
|
+
|
|
50
|
+
type RecordLockingError {
|
|
51
|
+
message: String
|
|
52
|
+
code: String
|
|
53
|
+
data: JSON
|
|
54
|
+
stack: String
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
enum RecordLockingRecordActionType {
|
|
58
|
+
requested
|
|
59
|
+
approved
|
|
60
|
+
denied
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
type RecordLockingIdentity {
|
|
64
|
+
id: String!
|
|
65
|
+
displayName: String
|
|
66
|
+
type: String
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
type RecordLockingRecordAction {
|
|
70
|
+
id: ID!
|
|
71
|
+
type: RecordLockingRecordActionType!
|
|
72
|
+
message: String
|
|
73
|
+
createdBy: RecordLockingIdentity!
|
|
74
|
+
createdOn: DateTime!
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
type RecordLockingRecord {
|
|
78
|
+
id: ID!
|
|
79
|
+
lockedBy: RecordLockingIdentity!
|
|
80
|
+
lockedOn: DateTime!
|
|
81
|
+
updatedOn: DateTime!
|
|
82
|
+
expiresOn: DateTime!
|
|
83
|
+
${recordLockingFields.map((f)=>f.fields).join("\n")}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
type RecordLockingIsEntryLockedResponse {
|
|
87
|
+
data: Boolean
|
|
88
|
+
error: RecordLockingError
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
type RecordLockingGetLockRecordResponse {
|
|
92
|
+
data: RecordLockingRecord
|
|
93
|
+
error: RecordLockingError
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
type RecordLockingGetLockedEntryLockRecordResponse {
|
|
97
|
+
data: RecordLockingRecord
|
|
98
|
+
error: RecordLockingError
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
type RecordLockingListLockRecordsResponse {
|
|
102
|
+
data: [RecordLockingRecord!]
|
|
103
|
+
error: RecordLockingError
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
type RecordLockingLockEntryResponse {
|
|
107
|
+
data: RecordLockingRecord
|
|
108
|
+
error: RecordLockingError
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
type RecordLockingUpdateLockResponse {
|
|
112
|
+
data: RecordLockingRecord
|
|
113
|
+
error: RecordLockingError
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
type RecordLockingUnlockEntryResponse {
|
|
117
|
+
data: RecordLockingRecord
|
|
118
|
+
error: RecordLockingError
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
type RecordLockingUnlockEntryRequestResponse {
|
|
122
|
+
data: RecordLockingRecord
|
|
123
|
+
error: RecordLockingError
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
input RecordLockingListWhereInput {
|
|
127
|
+
${listFilterFieldsRender.allFiltersAsString()}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
enum RecordLockingListSorter {
|
|
131
|
+
${sortEnumRender}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
type RecordLockingQuery {
|
|
135
|
+
_empty: String
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
type RecordLockingMutation {
|
|
139
|
+
_empty: String
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
extend type RecordLockingQuery {
|
|
143
|
+
isEntryLocked(id: ID!, type: String!): RecordLockingIsEntryLockedResponse!
|
|
144
|
+
getLockRecord(id: ID!, type: String!): RecordLockingGetLockRecordResponse!
|
|
145
|
+
# Returns lock record or null - if entry is locked in context of the current user, does not throw an error like getLockRecord if no record in the DB
|
|
146
|
+
getLockedEntryLockRecord(id: ID!, type: String!): RecordLockingGetLockedEntryLockRecordResponse!
|
|
147
|
+
listAllLockRecords(
|
|
148
|
+
where: RecordLockingListWhereInput
|
|
149
|
+
sort: [RecordLockingListSorter!]
|
|
150
|
+
limit: Int
|
|
151
|
+
after: String
|
|
152
|
+
): RecordLockingListLockRecordsResponse!
|
|
153
|
+
# Basically same as listAllLockRecords except this one will filter out records with expired lock.
|
|
154
|
+
listLockRecords(
|
|
155
|
+
where: RecordLockingListWhereInput
|
|
156
|
+
sort: [RecordLockingListSorter!]
|
|
157
|
+
limit: Int
|
|
158
|
+
after: String
|
|
159
|
+
): RecordLockingListLockRecordsResponse!
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
extend type RecordLockingMutation {
|
|
163
|
+
lockEntry(id: ID!, type: String!): RecordLockingLockEntryResponse!
|
|
164
|
+
updateEntryLock(id: ID!, type: String!): RecordLockingUpdateLockResponse!
|
|
165
|
+
unlockEntry(id: ID!, type: String!, force: Boolean): RecordLockingUnlockEntryResponse!
|
|
166
|
+
unlockEntryRequest(
|
|
167
|
+
id: ID!
|
|
168
|
+
type: String!
|
|
169
|
+
): RecordLockingUnlockEntryRequestResponse!
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
extend type Query {
|
|
173
|
+
recordLocking: RecordLockingQuery
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
extend type Mutation {
|
|
177
|
+
recordLocking: RecordLockingMutation
|
|
178
|
+
}
|
|
179
|
+
`;
|
|
180
|
+
}
|
|
181
|
+
function addQueryResolvers(builder) {
|
|
182
|
+
builder.addResolver({
|
|
183
|
+
path: "Query.recordLocking",
|
|
184
|
+
resolver: ()=>async ()=>({})
|
|
185
|
+
});
|
|
186
|
+
builder.addResolver({
|
|
187
|
+
path: "RecordLockingQuery.isEntryLocked",
|
|
188
|
+
dependencies: [
|
|
189
|
+
IdentityContext,
|
|
190
|
+
IsEntryLockedUseCase
|
|
191
|
+
],
|
|
192
|
+
resolver: (identityContext, useCase)=>({ args })=>resolve(async ()=>{
|
|
193
|
+
checkPermissions(identityContext);
|
|
194
|
+
const result = await useCase.execute({
|
|
195
|
+
id: args.id,
|
|
196
|
+
type: args.type
|
|
197
|
+
});
|
|
198
|
+
if (result.isFail()) throw result.error;
|
|
199
|
+
return result.value;
|
|
200
|
+
})
|
|
201
|
+
});
|
|
202
|
+
builder.addResolver({
|
|
203
|
+
path: "RecordLockingQuery.getLockRecord",
|
|
204
|
+
dependencies: [
|
|
205
|
+
IdentityContext,
|
|
206
|
+
GetLockRecordUseCase
|
|
207
|
+
],
|
|
208
|
+
resolver: (identityContext, useCase)=>({ args })=>resolve(async ()=>{
|
|
209
|
+
checkPermissions(identityContext);
|
|
210
|
+
const result = await useCase.execute({
|
|
211
|
+
id: args.id,
|
|
212
|
+
type: args.type
|
|
213
|
+
});
|
|
214
|
+
if (result.isFail()) throw result.error;
|
|
215
|
+
return result.value;
|
|
216
|
+
})
|
|
217
|
+
});
|
|
218
|
+
builder.addResolver({
|
|
219
|
+
path: "RecordLockingQuery.getLockedEntryLockRecord",
|
|
220
|
+
dependencies: [
|
|
221
|
+
IdentityContext,
|
|
222
|
+
GetLockedEntryLockRecordUseCase
|
|
223
|
+
],
|
|
224
|
+
resolver: (identityContext, useCase)=>({ args })=>resolve(async ()=>{
|
|
225
|
+
checkPermissions(identityContext);
|
|
226
|
+
const result = await useCase.execute({
|
|
227
|
+
id: args.id,
|
|
228
|
+
type: args.type
|
|
229
|
+
});
|
|
230
|
+
if (result.isFail()) return null;
|
|
231
|
+
return result.value;
|
|
232
|
+
})
|
|
233
|
+
});
|
|
234
|
+
builder.addResolver({
|
|
235
|
+
path: "RecordLockingQuery.listLockRecords",
|
|
236
|
+
dependencies: [
|
|
237
|
+
IdentityContext,
|
|
238
|
+
ListLockRecordsUseCase
|
|
239
|
+
],
|
|
240
|
+
resolver: (identityContext, useCase)=>({ args })=>resolveList(async ()=>{
|
|
241
|
+
checkPermissions(identityContext);
|
|
242
|
+
const result = await useCase.execute(args);
|
|
243
|
+
if (result.isFail()) throw result.error;
|
|
244
|
+
return result.value;
|
|
245
|
+
})
|
|
246
|
+
});
|
|
247
|
+
builder.addResolver({
|
|
248
|
+
path: "RecordLockingQuery.listAllLockRecords",
|
|
249
|
+
dependencies: [
|
|
250
|
+
IdentityContext,
|
|
251
|
+
ListAllLockRecordsUseCase
|
|
252
|
+
],
|
|
253
|
+
resolver: (identityContext, useCase)=>({ args })=>resolveList(async ()=>{
|
|
254
|
+
checkPermissions(identityContext);
|
|
255
|
+
const result = await useCase.execute(args);
|
|
256
|
+
if (result.isFail()) throw result.error;
|
|
257
|
+
return result.value;
|
|
258
|
+
})
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
function addMutationResolvers(builder) {
|
|
262
|
+
builder.addResolver({
|
|
263
|
+
path: "Mutation.recordLocking",
|
|
264
|
+
resolver: ()=>async ()=>({})
|
|
265
|
+
});
|
|
266
|
+
builder.addResolver({
|
|
267
|
+
path: "RecordLockingMutation.lockEntry",
|
|
268
|
+
dependencies: [
|
|
269
|
+
IdentityContext,
|
|
270
|
+
LockEntryUseCase
|
|
271
|
+
],
|
|
272
|
+
resolver: (identityContext, useCase)=>({ args })=>resolve(async ()=>{
|
|
273
|
+
checkPermissions(identityContext);
|
|
274
|
+
const result = await useCase.execute({
|
|
275
|
+
id: args.id,
|
|
276
|
+
type: args.type
|
|
277
|
+
});
|
|
278
|
+
if (result.isFail()) throw result.error;
|
|
279
|
+
return result.value;
|
|
280
|
+
})
|
|
281
|
+
});
|
|
282
|
+
builder.addResolver({
|
|
283
|
+
path: "RecordLockingMutation.updateEntryLock",
|
|
284
|
+
dependencies: [
|
|
285
|
+
IdentityContext,
|
|
286
|
+
UpdateEntryLockUseCase
|
|
287
|
+
],
|
|
288
|
+
resolver: (identityContext, useCase)=>({ args })=>resolve(async ()=>{
|
|
289
|
+
checkPermissions(identityContext);
|
|
290
|
+
const result = await useCase.execute({
|
|
291
|
+
id: args.id,
|
|
292
|
+
type: args.type
|
|
293
|
+
});
|
|
294
|
+
if (result.isFail()) throw result.error;
|
|
295
|
+
return result.value;
|
|
296
|
+
})
|
|
297
|
+
});
|
|
298
|
+
builder.addResolver({
|
|
299
|
+
path: "RecordLockingMutation.unlockEntry",
|
|
300
|
+
dependencies: [
|
|
301
|
+
IdentityContext,
|
|
302
|
+
UnlockEntryUseCase
|
|
303
|
+
],
|
|
304
|
+
resolver: (identityContext, useCase)=>({ args })=>resolve(async ()=>{
|
|
305
|
+
checkPermissions(identityContext);
|
|
306
|
+
const result = await useCase.execute({
|
|
307
|
+
id: args.id,
|
|
308
|
+
type: args.type,
|
|
309
|
+
force: args.force
|
|
310
|
+
});
|
|
311
|
+
if (result.isFail()) throw result.error;
|
|
312
|
+
return result.value;
|
|
313
|
+
})
|
|
314
|
+
});
|
|
315
|
+
builder.addResolver({
|
|
316
|
+
path: "RecordLockingMutation.unlockEntryRequest",
|
|
317
|
+
dependencies: [
|
|
318
|
+
IdentityContext,
|
|
319
|
+
UnlockEntryRequestUseCase
|
|
320
|
+
],
|
|
321
|
+
resolver: (identityContext, useCase)=>({ args })=>resolve(async ()=>{
|
|
322
|
+
checkPermissions(identityContext);
|
|
323
|
+
const result = await useCase.execute({
|
|
324
|
+
id: args.id,
|
|
325
|
+
type: args.type
|
|
326
|
+
});
|
|
327
|
+
if (result.isFail()) throw result.error;
|
|
328
|
+
return result.value;
|
|
329
|
+
})
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
class RecordLockingGraphQLSchemaImpl {
|
|
333
|
+
constructor(tenantContext, identityContext, modelProvider, listModelsUseCase, fieldRegistry){
|
|
334
|
+
this.tenantContext = tenantContext;
|
|
335
|
+
this.identityContext = identityContext;
|
|
336
|
+
this.modelProvider = modelProvider;
|
|
337
|
+
this.listModelsUseCase = listModelsUseCase;
|
|
338
|
+
this.fieldRegistry = fieldRegistry;
|
|
339
|
+
}
|
|
340
|
+
async getSchemaKey() {
|
|
341
|
+
const inputs = await this.loadInputs();
|
|
342
|
+
if (!inputs) return "RecordLocking:no-tenant";
|
|
343
|
+
const modelKey = createModelSchemaKey([
|
|
344
|
+
inputs.model
|
|
345
|
+
], inputs.models);
|
|
346
|
+
return `RecordLocking:${modelKey}`;
|
|
347
|
+
}
|
|
348
|
+
async execute(builder) {
|
|
349
|
+
const inputs = await this.loadInputs();
|
|
350
|
+
if (!inputs) return builder;
|
|
351
|
+
const { model, models } = inputs;
|
|
352
|
+
const typeDefs = renderTypeDefs({
|
|
353
|
+
model,
|
|
354
|
+
models,
|
|
355
|
+
fieldRegistry: this.fieldRegistry
|
|
356
|
+
});
|
|
357
|
+
builder.addTypeDefs(typeDefs);
|
|
358
|
+
addQueryResolvers(builder);
|
|
359
|
+
addMutationResolvers(builder);
|
|
360
|
+
return builder;
|
|
361
|
+
}
|
|
362
|
+
async loadInputs() {
|
|
363
|
+
if (!this.tenantContext.getTenant()) return null;
|
|
364
|
+
const model = await this.modelProvider.get();
|
|
365
|
+
const models = await this.identityContext.withoutAuthorization(async ()=>{
|
|
366
|
+
const result = await this.listModelsUseCase.execute({
|
|
367
|
+
includePrivate: false
|
|
368
|
+
});
|
|
369
|
+
if (result.isFail()) throw result.error;
|
|
370
|
+
return result.value;
|
|
371
|
+
});
|
|
372
|
+
return {
|
|
373
|
+
model,
|
|
374
|
+
models
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
const RecordLockingGraphQLSchema = GraphQLSchemaFactory.createImplementation({
|
|
379
|
+
implementation: RecordLockingGraphQLSchemaImpl,
|
|
380
|
+
dependencies: [
|
|
381
|
+
TenantContext,
|
|
382
|
+
IdentityContext,
|
|
383
|
+
RecordLockingModelProvider,
|
|
384
|
+
ListModelsUseCase,
|
|
385
|
+
CmsModelFieldToGraphQLRegistry
|
|
386
|
+
]
|
|
387
|
+
});
|
|
388
|
+
export { RecordLockingGraphQLSchema };
|
|
389
|
+
|
|
390
|
+
//# sourceMappingURL=RecordLockingGraphQLSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql/RecordLockingGraphQLSchema.js","sources":["../../src/graphql/RecordLockingGraphQLSchema.ts"],"sourcesContent":["import { GraphQLSchemaFactory } from \"@webiny/api-graphql/graphql/abstractions.js\";\nimport { createModelSchemaKey } from \"@webiny/api-headless-cms/utils/createModelSchemaKey.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels/index.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\nimport { renderFields } from \"@webiny/api-headless-cms/utils/renderFields.js\";\nimport { renderListFilterFields } from \"@webiny/api-headless-cms/utils/renderListFilterFields.js\";\nimport { renderSortEnum } from \"@webiny/api-headless-cms/utils/renderSortEnum.js\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/model.js\";\nimport { RecordLockingModelProvider } from \"~/domain/abstractions.js\";\nimport { IsEntryLockedUseCase } from \"~/features/IsEntryLocked/abstractions.js\";\nimport { GetLockRecordUseCase } from \"~/features/GetLockRecord/abstractions.js\";\nimport { GetLockedEntryLockRecordUseCase } from \"~/features/GetLockedEntryLockRecord/abstractions.js\";\nimport { ListLockRecordsUseCase } from \"~/features/ListLockRecords/abstractions.js\";\nimport type { ListLockRecordsInput } from \"~/features/ListLockRecords/abstractions.js\";\nimport { ListAllLockRecordsUseCase } from \"~/features/ListAllLockRecords/abstractions.js\";\nimport type { ListAllLockRecordsInput } from \"~/features/ListAllLockRecords/abstractions.js\";\nimport { LockEntryUseCase } from \"~/features/LockEntry/abstractions.js\";\nimport { UpdateEntryLockUseCase } from \"~/features/UpdateEntryLock/abstractions.js\";\nimport { UnlockEntryUseCase } from \"~/features/UnlockEntry/abstractions.js\";\nimport { UnlockEntryRequestUseCase } from \"~/features/UnlockEntryRequest/abstractions.js\";\nimport { resolve } from \"./resolve.js\";\nimport { resolveList } from \"./resolve.js\";\nimport { checkPermissions } from \"./checkPermissions.js\";\n\ninterface IEntryArgs {\n id: string;\n type: string;\n}\n\ninterface IUnlockEntryArgs extends IEntryArgs {\n force?: boolean;\n}\n\ninterface IResolverParams<TArgs = unknown> {\n args: TArgs;\n}\n\ninterface IRenderTypeDefsParams {\n model: CmsModel;\n models: CmsModel[];\n fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface;\n}\n\nfunction renderTypeDefs(params: IRenderTypeDefsParams): string {\n const { model, fieldRegistry } = params;\n\n const models = params.models.filter(model => {\n return model.fields.length > 0;\n });\n\n const recordLockingFields = renderFields({\n models,\n model,\n fields: model.fields,\n type: \"manage\",\n fieldRegistry\n });\n\n const listFilterFieldsRender = renderListFilterFields({\n model,\n fields: model.fields,\n type: \"manage\",\n fieldRegistry,\n excludeFields: [\"entryId\"]\n });\n\n const sortEnumRender = renderSortEnum({\n model,\n fields: model.fields,\n fieldRegistry,\n sorters: []\n });\n\n return /* GraphQL */ `\n ${recordLockingFields.map(f => f.typeDefs).join(\"\\n\")}\n\n type RecordLockingError {\n message: String\n code: String\n data: JSON\n stack: String\n }\n\n enum RecordLockingRecordActionType {\n requested\n approved\n denied\n }\n\n type RecordLockingIdentity {\n id: String!\n displayName: String\n type: String\n }\n\n type RecordLockingRecordAction {\n id: ID!\n type: RecordLockingRecordActionType!\n message: String\n createdBy: RecordLockingIdentity!\n createdOn: DateTime!\n }\n\n type RecordLockingRecord {\n id: ID!\n lockedBy: RecordLockingIdentity!\n lockedOn: DateTime!\n updatedOn: DateTime!\n expiresOn: DateTime!\n ${recordLockingFields.map(f => f.fields).join(\"\\n\")}\n }\n\n type RecordLockingIsEntryLockedResponse {\n data: Boolean\n error: RecordLockingError\n }\n\n type RecordLockingGetLockRecordResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n type RecordLockingGetLockedEntryLockRecordResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n type RecordLockingListLockRecordsResponse {\n data: [RecordLockingRecord!]\n error: RecordLockingError\n }\n\n type RecordLockingLockEntryResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n type RecordLockingUpdateLockResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n type RecordLockingUnlockEntryResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n type RecordLockingUnlockEntryRequestResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n input RecordLockingListWhereInput {\n ${listFilterFieldsRender.allFiltersAsString()}\n }\n\n enum RecordLockingListSorter {\n ${sortEnumRender}\n }\n\n type RecordLockingQuery {\n _empty: String\n }\n\n type RecordLockingMutation {\n _empty: String\n }\n\n extend type RecordLockingQuery {\n isEntryLocked(id: ID!, type: String!): RecordLockingIsEntryLockedResponse!\n getLockRecord(id: ID!, type: String!): RecordLockingGetLockRecordResponse!\n # Returns lock record or null - if entry is locked in context of the current user, does not throw an error like getLockRecord if no record in the DB\n getLockedEntryLockRecord(id: ID!, type: String!): RecordLockingGetLockedEntryLockRecordResponse!\n listAllLockRecords(\n where: RecordLockingListWhereInput\n sort: [RecordLockingListSorter!]\n limit: Int\n after: String\n ): RecordLockingListLockRecordsResponse!\n # Basically same as listAllLockRecords except this one will filter out records with expired lock.\n listLockRecords(\n where: RecordLockingListWhereInput\n sort: [RecordLockingListSorter!]\n limit: Int\n after: String\n ): RecordLockingListLockRecordsResponse!\n }\n\n extend type RecordLockingMutation {\n lockEntry(id: ID!, type: String!): RecordLockingLockEntryResponse!\n updateEntryLock(id: ID!, type: String!): RecordLockingUpdateLockResponse!\n unlockEntry(id: ID!, type: String!, force: Boolean): RecordLockingUnlockEntryResponse!\n unlockEntryRequest(\n id: ID!\n type: String!\n ): RecordLockingUnlockEntryRequestResponse!\n }\n\n extend type Query {\n recordLocking: RecordLockingQuery\n }\n\n extend type Mutation {\n recordLocking: RecordLockingMutation\n }\n `;\n}\n\nfunction addQueryResolvers(builder: GraphQLSchemaFactory.SchemaBuilder): void {\n builder.addResolver({\n path: \"Query.recordLocking\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"RecordLockingQuery.isEntryLocked\",\n dependencies: [IdentityContext, IsEntryLockedUseCase],\n resolver: (\n identityContext: IdentityContext.Interface,\n useCase: IsEntryLockedUseCase.Interface\n ) => {\n return ({ args }: IResolverParams<IEntryArgs>) => {\n return resolve(async () => {\n checkPermissions(identityContext);\n const result = await useCase.execute({\n id: args.id,\n type: args.type\n });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n };\n }\n });\n\n builder.addResolver({\n path: \"RecordLockingQuery.getLockRecord\",\n dependencies: [IdentityContext, GetLockRecordUseCase],\n resolver: (\n identityContext: IdentityContext.Interface,\n useCase: GetLockRecordUseCase.Interface\n ) => {\n return ({ args }: IResolverParams<IEntryArgs>) => {\n return resolve(async () => {\n checkPermissions(identityContext);\n const result = await useCase.execute({\n id: args.id,\n type: args.type\n });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n };\n }\n });\n\n builder.addResolver({\n path: \"RecordLockingQuery.getLockedEntryLockRecord\",\n dependencies: [IdentityContext, GetLockedEntryLockRecordUseCase],\n resolver: (\n identityContext: IdentityContext.Interface,\n useCase: GetLockedEntryLockRecordUseCase.Interface\n ) => {\n return ({ args }: IResolverParams<IEntryArgs>) => {\n return resolve(async () => {\n checkPermissions(identityContext);\n const result = await useCase.execute({\n id: args.id,\n type: args.type\n });\n // Returns null if not found/expired/locked by current user.\n if (result.isFail()) {\n return null;\n }\n return result.value;\n });\n };\n }\n });\n\n builder.addResolver({\n path: \"RecordLockingQuery.listLockRecords\",\n dependencies: [IdentityContext, ListLockRecordsUseCase],\n resolver: (\n identityContext: IdentityContext.Interface,\n useCase: ListLockRecordsUseCase.Interface\n ) => {\n return ({ args }: IResolverParams<ListLockRecordsInput>) => {\n return resolveList(async () => {\n checkPermissions(identityContext);\n const result = await useCase.execute(args);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n };\n }\n });\n\n builder.addResolver({\n path: \"RecordLockingQuery.listAllLockRecords\",\n dependencies: [IdentityContext, ListAllLockRecordsUseCase],\n resolver: (\n identityContext: IdentityContext.Interface,\n useCase: ListAllLockRecordsUseCase.Interface\n ) => {\n return ({ args }: IResolverParams<ListAllLockRecordsInput>) => {\n return resolveList(async () => {\n checkPermissions(identityContext);\n const result = await useCase.execute(args);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n };\n }\n });\n}\n\nfunction addMutationResolvers(builder: GraphQLSchemaFactory.SchemaBuilder): void {\n builder.addResolver({\n path: \"Mutation.recordLocking\",\n resolver: () => async () => ({})\n });\n\n builder.addResolver({\n path: \"RecordLockingMutation.lockEntry\",\n dependencies: [IdentityContext, LockEntryUseCase],\n resolver: (\n identityContext: IdentityContext.Interface,\n useCase: LockEntryUseCase.Interface\n ) => {\n return ({ args }: IResolverParams<IEntryArgs>) => {\n return resolve(async () => {\n checkPermissions(identityContext);\n const result = await useCase.execute({\n id: args.id,\n type: args.type\n });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n };\n }\n });\n\n builder.addResolver({\n path: \"RecordLockingMutation.updateEntryLock\",\n dependencies: [IdentityContext, UpdateEntryLockUseCase],\n resolver: (\n identityContext: IdentityContext.Interface,\n useCase: UpdateEntryLockUseCase.Interface\n ) => {\n return ({ args }: IResolverParams<IEntryArgs>) => {\n return resolve(async () => {\n checkPermissions(identityContext);\n const result = await useCase.execute({\n id: args.id,\n type: args.type\n });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n };\n }\n });\n\n builder.addResolver({\n path: \"RecordLockingMutation.unlockEntry\",\n dependencies: [IdentityContext, UnlockEntryUseCase],\n resolver: (\n identityContext: IdentityContext.Interface,\n useCase: UnlockEntryUseCase.Interface\n ) => {\n return ({ args }: IResolverParams<IUnlockEntryArgs>) => {\n return resolve(async () => {\n checkPermissions(identityContext);\n const result = await useCase.execute({\n id: args.id,\n type: args.type,\n force: args.force\n });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n };\n }\n });\n\n builder.addResolver({\n path: \"RecordLockingMutation.unlockEntryRequest\",\n dependencies: [IdentityContext, UnlockEntryRequestUseCase],\n resolver: (\n identityContext: IdentityContext.Interface,\n useCase: UnlockEntryRequestUseCase.Interface\n ) => {\n return ({ args }: IResolverParams<IEntryArgs>) => {\n return resolve(async () => {\n checkPermissions(identityContext);\n const result = await useCase.execute({\n id: args.id,\n type: args.type\n });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n };\n }\n });\n}\n\n/**\n * The record locking GraphQL schema. The lock record type is rendered from the lock record model,\n * which is loaded when the schema is composed.\n */\nclass RecordLockingGraphQLSchemaImpl implements GraphQLSchemaFactory.Interface {\n public constructor(\n private readonly tenantContext: TenantContext.Interface,\n private readonly identityContext: IdentityContext.Interface,\n private readonly modelProvider: RecordLockingModelProvider.Interface,\n private readonly listModelsUseCase: ListModelsUseCase.Interface,\n private readonly fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface\n ) {}\n\n public async getSchemaKey(): Promise<string> {\n const inputs = await this.loadInputs();\n if (!inputs) {\n return \"RecordLocking:no-tenant\";\n }\n\n const modelKey = createModelSchemaKey([inputs.model], inputs.models);\n return `RecordLocking:${modelKey}`;\n }\n\n public async execute(\n builder: GraphQLSchemaFactory.SchemaBuilder\n ): Promise<GraphQLSchemaFactory.SchemaBuilder> {\n const inputs = await this.loadInputs();\n if (!inputs) {\n return builder;\n }\n\n const { model, models } = inputs;\n const typeDefs = renderTypeDefs({\n model,\n models,\n fieldRegistry: this.fieldRegistry\n });\n\n builder.addTypeDefs(typeDefs);\n addQueryResolvers(builder);\n addMutationResolvers(builder);\n\n return builder;\n }\n\n private async loadInputs() {\n // There is no tenant until installation completes, and no model to render a schema from.\n if (!this.tenantContext.getTenant()) {\n return null;\n }\n\n const model = await this.modelProvider.get();\n\n // The model list feeds `ref` field rendering. ListModels is filtered by permission, so it\n // is read without authorization to keep the schema the same for every identity.\n const models = await this.identityContext.withoutAuthorization(async () => {\n const result = await this.listModelsUseCase.execute({ includePrivate: false });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n\n return { model, models };\n }\n}\n\nexport const RecordLockingGraphQLSchema = GraphQLSchemaFactory.createImplementation({\n implementation: RecordLockingGraphQLSchemaImpl,\n dependencies: [\n TenantContext,\n IdentityContext,\n RecordLockingModelProvider,\n ListModelsUseCase,\n CmsModelFieldToGraphQLRegistry\n ]\n});\n"],"names":["renderTypeDefs","params","model","fieldRegistry","models","recordLockingFields","renderFields","listFilterFieldsRender","renderListFilterFields","sortEnumRender","renderSortEnum","f","addQueryResolvers","builder","IdentityContext","IsEntryLockedUseCase","identityContext","useCase","args","resolve","checkPermissions","result","GetLockRecordUseCase","GetLockedEntryLockRecordUseCase","ListLockRecordsUseCase","resolveList","ListAllLockRecordsUseCase","addMutationResolvers","LockEntryUseCase","UpdateEntryLockUseCase","UnlockEntryUseCase","UnlockEntryRequestUseCase","RecordLockingGraphQLSchemaImpl","tenantContext","modelProvider","listModelsUseCase","inputs","modelKey","createModelSchemaKey","typeDefs","RecordLockingGraphQLSchema","GraphQLSchemaFactory","TenantContext","RecordLockingModelProvider","ListModelsUseCase","CmsModelFieldToGraphQLRegistry"],"mappings":"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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
2
2
|
/**
|
|
3
|
-
* Simple permission check. Only authenticated users can access the
|
|
3
|
+
* Simple permission check. Only authenticated users can access the record locking API via GraphQL.
|
|
4
4
|
*/
|
|
5
|
-
export declare const checkPermissions: (
|
|
5
|
+
export declare const checkPermissions: (identityContext: IdentityContext.Interface) => void;
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import { IdentityContext } from "@webiny/api-core/features/IdentityContext";
|
|
2
1
|
import { NotAuthorizedError } from "@webiny/api-core/features/security/shared";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export const checkPermissions = async context => {
|
|
7
|
-
const identityContext = context.container.resolve(IdentityContext);
|
|
8
|
-
const identity = identityContext.getIdentity();
|
|
9
|
-
if (identity.isAnonymous()) {
|
|
10
|
-
throw new NotAuthorizedError();
|
|
11
|
-
}
|
|
2
|
+
const checkPermissions = (identityContext)=>{
|
|
3
|
+
const identity = identityContext.getIdentity();
|
|
4
|
+
if (identity.isAnonymous()) throw new NotAuthorizedError();
|
|
12
5
|
};
|
|
6
|
+
export { checkPermissions };
|
|
13
7
|
|
|
14
8
|
//# sourceMappingURL=checkPermissions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"graphql/checkPermissions.js","sources":["../../src/graphql/checkPermissions.ts"],"sourcesContent":["import { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { NotAuthorizedError } from \"@webiny/api-core/features/security/shared\";\n\n/**\n * Simple permission check. Only authenticated users can access the record locking API via GraphQL.\n */\nexport const checkPermissions = (identityContext: IdentityContext.Interface): void => {\n const identity = identityContext.getIdentity();\n\n if (identity.isAnonymous()) {\n throw new NotAuthorizedError();\n }\n};\n"],"names":["checkPermissions","identityContext","identity","NotAuthorizedError"],"mappings":";AAMO,MAAMA,mBAAmB,CAACC;IAC7B,MAAMC,WAAWD,gBAAgB,WAAW;IAE5C,IAAIC,SAAS,WAAW,IACpB,MAAM,IAAIC;AAElB"}
|
package/graphql/resolve.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorResponse, Response } from "@webiny/
|
|
1
|
+
import { ErrorResponse, Response } from "@webiny/api-graphql";
|
|
2
2
|
import type { IRecordLockingMeta } from "../types.js";
|
|
3
3
|
export declare const resolve: <T>(cb: () => Promise<T>) => Promise<Response<T> | ErrorResponse>;
|
|
4
4
|
export interface IListResponse<T> {
|
package/graphql/resolve.js
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import { ErrorResponse, ListErrorResponse, ListResponse, Response } from "@webiny/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { ErrorResponse, ListErrorResponse, ListResponse, Response } from "@webiny/api-graphql";
|
|
2
|
+
const resolve = async (cb)=>{
|
|
3
|
+
try {
|
|
4
|
+
const result = await cb();
|
|
5
|
+
return new Response(result);
|
|
6
|
+
} catch (ex) {
|
|
7
|
+
return new ErrorResponse(ex);
|
|
8
|
+
}
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} catch (ex) {
|
|
18
|
-
return new ListErrorResponse(ex);
|
|
19
|
-
}
|
|
10
|
+
const resolveList = async (cb)=>{
|
|
11
|
+
try {
|
|
12
|
+
const { items, meta } = await cb();
|
|
13
|
+
return new ListResponse(items, meta);
|
|
14
|
+
} catch (ex) {
|
|
15
|
+
return new ListErrorResponse(ex);
|
|
16
|
+
}
|
|
20
17
|
};
|
|
18
|
+
export { resolve, resolveList };
|
|
21
19
|
|
|
22
20
|
//# sourceMappingURL=resolve.js.map
|
package/graphql/resolve.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"graphql/resolve.js","sources":["../../src/graphql/resolve.ts"],"sourcesContent":["import { ErrorResponse, ListErrorResponse, ListResponse, Response } from \"@webiny/api-graphql\";\nimport type { IRecordLockingMeta } from \"~/types.js\";\n\nexport const resolve = async <T>(cb: () => Promise<T>): Promise<Response<T> | ErrorResponse> => {\n try {\n const result = await cb();\n return new Response<T>(result);\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n};\n\nexport interface IListResponse<T> {\n items: T[];\n meta: IRecordLockingMeta;\n}\n\nexport const resolveList = async <T>(\n cb: () => Promise<IListResponse<T>>\n): Promise<Response<T[]> | ErrorResponse> => {\n try {\n const { items, meta } = await cb();\n return new ListResponse(items, meta);\n } catch (ex) {\n return new ListErrorResponse(ex);\n }\n};\n"],"names":["resolve","cb","result","Response","ex","ErrorResponse","resolveList","items","meta","ListResponse","ListErrorResponse"],"mappings":";AAGO,MAAMA,UAAU,OAAUC;IAC7B,IAAI;QACA,MAAMC,SAAS,MAAMD;QACrB,OAAO,IAAIE,SAAYD;IAC3B,EAAE,OAAOE,IAAI;QACT,OAAO,IAAIC,cAAcD;IAC7B;AACJ;AAOO,MAAME,cAAc,OACvBL;IAEA,IAAI;QACA,MAAM,EAAEM,KAAK,EAAEC,IAAI,EAAE,GAAG,MAAMP;QAC9B,OAAO,IAAIQ,aAAaF,OAAOC;IACnC,EAAE,OAAOJ,IAAI;QACT,OAAO,IAAIM,kBAAkBN;IACjC;AACJ"}
|
package/index.d.ts
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export interface ICreateContextPluginParams {
|
|
4
|
-
/**
|
|
5
|
-
* A number of seconds after the last activity to wait before the record is automatically unlocked.
|
|
6
|
-
*/
|
|
7
|
-
timeout?: number;
|
|
8
|
-
}
|
|
9
|
-
export declare const createRecordLocking: (params?: ICreateContextPluginParams) => ContextPlugin<ApiCoreContext>[];
|
|
1
|
+
export { RecordLockingAppFeature } from "./RecordLockingAppFeature.js";
|
|
2
|
+
export type { IRecordLockingAppFeatureParams } from "./RecordLockingAppFeature.js";
|