@webiny/api-record-locking 6.0.0-beta.0 → 6.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -9
- package/domain/LockRecord.d.ts +45 -0
- package/{utils/convertEntryToLockRecord.js → domain/LockRecord.js} +14 -22
- package/domain/LockRecord.js.map +1 -0
- package/domain/RecordLockingModel.d.ts +9 -0
- package/domain/RecordLockingModel.js +29 -0
- package/domain/RecordLockingModel.js.map +1 -0
- package/domain/abstractions.d.ts +18 -0
- package/domain/abstractions.js +10 -0
- package/domain/abstractions.js.map +1 -0
- package/domain/calculateExpiresOn.d.ts +1 -0
- package/domain/calculateExpiresOn.js +9 -0
- package/domain/calculateExpiresOn.js.map +1 -0
- package/domain/errors.d.ts +71 -0
- package/domain/errors.js +95 -0
- package/domain/errors.js.map +1 -0
- package/domain/index.d.ts +4 -0
- package/domain/index.js +6 -0
- package/domain/index.js.map +1 -0
- package/domain/types.d.ts +44 -0
- package/domain/types.js +12 -0
- package/domain/types.js.map +1 -0
- package/features/GetLockRecord/GetLockRecordRepository.d.ts +16 -0
- package/features/GetLockRecord/GetLockRecordRepository.js +37 -0
- package/features/GetLockRecord/GetLockRecordRepository.js.map +1 -0
- package/features/GetLockRecord/GetLockRecordUseCase.d.ts +12 -0
- package/features/GetLockRecord/GetLockRecordUseCase.js +15 -0
- package/features/GetLockRecord/GetLockRecordUseCase.js.map +1 -0
- package/features/GetLockRecord/abstractions.d.ts +41 -0
- package/features/GetLockRecord/abstractions.js +17 -0
- package/features/GetLockRecord/abstractions.js.map +1 -0
- package/features/GetLockRecord/feature.d.ts +1 -0
- package/features/GetLockRecord/feature.js +12 -0
- package/features/GetLockRecord/feature.js.map +1 -0
- package/features/GetLockRecord/index.d.ts +2 -0
- package/features/GetLockRecord/index.js +4 -0
- package/features/GetLockRecord/index.js.map +1 -0
- package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.d.ts +15 -0
- package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js +39 -0
- package/features/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js.map +1 -0
- package/features/GetLockedEntryLockRecord/abstractions.d.ts +26 -0
- package/features/GetLockedEntryLockRecord/abstractions.js +13 -0
- package/features/GetLockedEntryLockRecord/abstractions.js.map +1 -0
- package/features/GetLockedEntryLockRecord/feature.d.ts +1 -0
- package/features/GetLockedEntryLockRecord/feature.js +10 -0
- package/features/GetLockedEntryLockRecord/feature.js.map +1 -0
- package/features/GetLockedEntryLockRecord/index.d.ts +2 -0
- package/features/GetLockedEntryLockRecord/index.js +4 -0
- package/features/GetLockedEntryLockRecord/index.js.map +1 -0
- package/features/IsEntryLocked/IsEntryLockedUseCase.d.ts +14 -0
- package/features/IsEntryLocked/IsEntryLockedUseCase.js +39 -0
- package/features/IsEntryLocked/IsEntryLockedUseCase.js.map +1 -0
- package/features/IsEntryLocked/abstractions.d.ts +24 -0
- package/features/IsEntryLocked/abstractions.js +12 -0
- package/features/IsEntryLocked/abstractions.js.map +1 -0
- package/features/IsEntryLocked/feature.d.ts +1 -0
- package/features/IsEntryLocked/feature.js +10 -0
- package/features/IsEntryLocked/feature.js.map +1 -0
- package/features/IsEntryLocked/index.d.ts +1 -0
- package/features/IsEntryLocked/index.js +3 -0
- package/features/IsEntryLocked/index.js.map +1 -0
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.d.ts +15 -0
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js +42 -0
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js.map +1 -0
- package/features/KickOutCurrentUser/abstractions.d.ts +17 -0
- package/features/KickOutCurrentUser/abstractions.js +9 -0
- package/features/KickOutCurrentUser/abstractions.js.map +1 -0
- package/features/KickOutCurrentUser/feature.d.ts +1 -0
- package/features/KickOutCurrentUser/feature.js +10 -0
- package/features/KickOutCurrentUser/feature.js.map +1 -0
- package/features/KickOutCurrentUser/index.d.ts +1 -0
- package/features/KickOutCurrentUser/index.js +3 -0
- package/features/KickOutCurrentUser/index.js.map +1 -0
- package/features/ListAllLockRecords/ListAllLockRecordsRepository.d.ts +16 -0
- package/features/ListAllLockRecords/ListAllLockRecordsRepository.js +43 -0
- package/features/ListAllLockRecords/ListAllLockRecordsRepository.js.map +1 -0
- package/features/ListAllLockRecords/ListAllLockRecordsUseCase.d.ts +11 -0
- package/features/ListAllLockRecords/ListAllLockRecordsUseCase.js +15 -0
- package/features/ListAllLockRecords/ListAllLockRecordsUseCase.js.map +1 -0
- package/features/ListAllLockRecords/abstractions.d.ts +40 -0
- package/features/ListAllLockRecords/abstractions.js +17 -0
- package/features/ListAllLockRecords/abstractions.js.map +1 -0
- package/features/ListAllLockRecords/feature.d.ts +1 -0
- package/features/ListAllLockRecords/feature.js +12 -0
- package/features/ListAllLockRecords/feature.js.map +1 -0
- package/features/ListAllLockRecords/index.d.ts +2 -0
- package/features/ListAllLockRecords/index.js +4 -0
- package/features/ListAllLockRecords/index.js.map +1 -0
- package/features/ListLockRecords/ListLockRecordsRepository.d.ts +15 -0
- package/features/ListLockRecords/ListLockRecordsRepository.js +43 -0
- package/features/ListLockRecords/ListLockRecordsRepository.js.map +1 -0
- package/features/ListLockRecords/ListLockRecordsUseCase.d.ts +15 -0
- package/features/ListLockRecords/ListLockRecordsUseCase.js +30 -0
- package/features/ListLockRecords/ListLockRecordsUseCase.js.map +1 -0
- package/features/ListLockRecords/abstractions.d.ts +45 -0
- package/features/ListLockRecords/abstractions.js +17 -0
- package/features/ListLockRecords/abstractions.js.map +1 -0
- package/features/ListLockRecords/feature.d.ts +1 -0
- package/features/ListLockRecords/feature.js +12 -0
- package/features/ListLockRecords/feature.js.map +1 -0
- package/features/ListLockRecords/index.d.ts +1 -0
- package/features/ListLockRecords/index.js +3 -0
- package/features/ListLockRecords/index.js.map +1 -0
- package/features/LockEntry/LockEntryEventsDecorator.d.ts +14 -0
- package/features/LockEntry/LockEntryEventsDecorator.js +40 -0
- package/features/LockEntry/LockEntryEventsDecorator.js.map +1 -0
- package/features/LockEntry/LockEntryRepository.d.ts +16 -0
- package/features/LockEntry/LockEntryRepository.js +42 -0
- package/features/LockEntry/LockEntryRepository.js.map +1 -0
- package/features/LockEntry/LockEntryUseCase.d.ts +14 -0
- package/features/LockEntry/LockEntryUseCase.js +36 -0
- package/features/LockEntry/LockEntryUseCase.js.map +1 -0
- package/features/LockEntry/abstractions.d.ts +41 -0
- package/features/LockEntry/abstractions.js +17 -0
- package/features/LockEntry/abstractions.js.map +1 -0
- package/features/LockEntry/events.d.ts +45 -0
- package/features/LockEntry/events.js +40 -0
- package/features/LockEntry/events.js.map +1 -0
- package/features/LockEntry/feature.d.ts +1 -0
- package/features/LockEntry/feature.js +14 -0
- package/features/LockEntry/feature.js.map +1 -0
- package/features/LockEntry/index.d.ts +1 -0
- package/features/LockEntry/index.js +3 -0
- package/features/LockEntry/index.js.map +1 -0
- package/features/RecordLockingFeature.d.ts +12 -0
- package/features/RecordLockingFeature.js +36 -0
- package/features/RecordLockingFeature.js.map +1 -0
- package/features/UnlockEntry/UnlockEntryEventsDecorator.d.ts +14 -0
- package/features/UnlockEntry/UnlockEntryEventsDecorator.js +41 -0
- package/features/UnlockEntry/UnlockEntryEventsDecorator.js.map +1 -0
- package/features/UnlockEntry/UnlockEntryRepository.d.ts +14 -0
- package/features/UnlockEntry/UnlockEntryRepository.js +40 -0
- package/features/UnlockEntry/UnlockEntryRepository.js.map +1 -0
- package/features/UnlockEntry/UnlockEntryUseCase.d.ts +18 -0
- package/features/UnlockEntry/UnlockEntryUseCase.js +81 -0
- package/features/UnlockEntry/UnlockEntryUseCase.js.map +1 -0
- package/features/UnlockEntry/abstractions.d.ts +44 -0
- package/features/UnlockEntry/abstractions.js +17 -0
- package/features/UnlockEntry/abstractions.js.map +1 -0
- package/features/UnlockEntry/events.d.ts +46 -0
- package/features/UnlockEntry/events.js +40 -0
- package/features/UnlockEntry/events.js.map +1 -0
- package/features/UnlockEntry/feature.d.ts +1 -0
- package/features/UnlockEntry/feature.js +14 -0
- package/features/UnlockEntry/feature.js.map +1 -0
- package/features/UnlockEntry/hasFullAccessPermission.d.ts +2 -0
- package/features/UnlockEntry/hasFullAccessPermission.js +10 -0
- package/features/UnlockEntry/hasFullAccessPermission.js.map +1 -0
- package/features/UnlockEntry/index.d.ts +1 -0
- package/features/UnlockEntry/index.js +3 -0
- package/features/UnlockEntry/index.js.map +1 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.d.ts +14 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js +40 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestEventsDecorator.js.map +1 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.d.ts +17 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js +43 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js.map +1 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.d.ts +16 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js +92 -0
- package/features/UnlockEntryRequest/UnlockEntryRequestUseCase.js.map +1 -0
- package/features/UnlockEntryRequest/abstractions.d.ts +42 -0
- package/features/UnlockEntryRequest/abstractions.js +17 -0
- package/features/UnlockEntryRequest/abstractions.js.map +1 -0
- package/features/UnlockEntryRequest/events.d.ts +45 -0
- package/features/UnlockEntryRequest/events.js +40 -0
- package/features/UnlockEntryRequest/events.js.map +1 -0
- package/features/UnlockEntryRequest/feature.d.ts +1 -0
- package/features/UnlockEntryRequest/feature.js +14 -0
- package/features/UnlockEntryRequest/feature.js.map +1 -0
- package/features/UnlockEntryRequest/index.d.ts +3 -0
- package/features/UnlockEntryRequest/index.js +5 -0
- package/features/UnlockEntryRequest/index.js.map +1 -0
- package/features/UpdateEntryLock/UpdateEntryLockRepository.d.ts +20 -0
- package/features/UpdateEntryLock/UpdateEntryLockRepository.js +63 -0
- package/features/UpdateEntryLock/UpdateEntryLockRepository.js.map +1 -0
- package/features/UpdateEntryLock/UpdateEntryLockUseCase.d.ts +18 -0
- package/features/UpdateEntryLock/UpdateEntryLockUseCase.js +62 -0
- package/features/UpdateEntryLock/UpdateEntryLockUseCase.js.map +1 -0
- package/features/UpdateEntryLock/abstractions.d.ts +42 -0
- package/features/UpdateEntryLock/abstractions.js +17 -0
- package/features/UpdateEntryLock/abstractions.js.map +1 -0
- package/features/UpdateEntryLock/feature.d.ts +1 -0
- package/features/UpdateEntryLock/feature.js +12 -0
- package/features/UpdateEntryLock/feature.js.map +1 -0
- package/features/UpdateEntryLock/index.d.ts +1 -0
- package/features/UpdateEntryLock/index.js +3 -0
- package/features/UpdateEntryLock/index.js.map +1 -0
- package/graphql/checkPermissions.d.ts +5 -0
- package/graphql/checkPermissions.js +14 -0
- package/graphql/checkPermissions.js.map +1 -0
- package/{utils → graphql}/resolve.d.ts +2 -2
- package/graphql/resolve.js +22 -0
- package/graphql/resolve.js.map +1 -0
- package/graphql/schema.d.ts +8 -4
- package/graphql/schema.js +99 -61
- package/graphql/schema.js.map +1 -1
- package/index.d.ts +8 -2
- package/index.js +50 -26
- package/index.js.map +1 -1
- package/package.json +21 -43
- package/types.d.ts +14 -133
- package/types.js +6 -24
- package/types.js.map +1 -1
- package/utils/convertWhereCondition.d.ts +2 -2
- package/utils/convertWhereCondition.js +11 -14
- package/utils/convertWhereCondition.js.map +1 -1
- package/utils/getTimeout.d.ts +3 -2
- package/utils/getTimeout.js +11 -10
- package/utils/getTimeout.js.map +1 -1
- package/utils/lockRecordDatabaseId.js +4 -12
- package/utils/lockRecordDatabaseId.js.map +1 -1
- package/abstractions/IGetLockRecordUseCase.d.ts +0 -8
- package/abstractions/IGetLockRecordUseCase.js +0 -7
- package/abstractions/IGetLockRecordUseCase.js.map +0 -1
- package/abstractions/IGetLockedEntryLockRecordUseCase.d.ts +0 -8
- package/abstractions/IGetLockedEntryLockRecordUseCase.js +0 -7
- package/abstractions/IGetLockedEntryLockRecordUseCase.js.map +0 -1
- package/abstractions/IIsEntryLocked.d.ts +0 -8
- package/abstractions/IIsEntryLocked.js +0 -7
- package/abstractions/IIsEntryLocked.js.map +0 -1
- package/abstractions/IKickOutCurrentUserUseCase.d.ts +0 -5
- package/abstractions/IKickOutCurrentUserUseCase.js +0 -7
- package/abstractions/IKickOutCurrentUserUseCase.js.map +0 -1
- package/abstractions/IListAllLockRecordsUseCase.d.ts +0 -9
- package/abstractions/IListAllLockRecordsUseCase.js +0 -7
- package/abstractions/IListAllLockRecordsUseCase.js.map +0 -1
- package/abstractions/IListLockRecordsUseCase.d.ts +0 -10
- package/abstractions/IListLockRecordsUseCase.js +0 -7
- package/abstractions/IListLockRecordsUseCase.js.map +0 -1
- package/abstractions/ILockEntryUseCase.d.ts +0 -11
- package/abstractions/ILockEntryUseCase.js +0 -7
- package/abstractions/ILockEntryUseCase.js.map +0 -1
- package/abstractions/IUnlockEntryRequestUseCase.d.ts +0 -11
- package/abstractions/IUnlockEntryRequestUseCase.js +0 -7
- package/abstractions/IUnlockEntryRequestUseCase.js.map +0 -1
- package/abstractions/IUnlockEntryUseCase.d.ts +0 -12
- package/abstractions/IUnlockEntryUseCase.js +0 -7
- package/abstractions/IUnlockEntryUseCase.js.map +0 -1
- package/abstractions/IUpdateEntryLockUseCase.d.ts +0 -11
- package/abstractions/IUpdateEntryLockUseCase.js +0 -7
- package/abstractions/IUpdateEntryLockUseCase.js.map +0 -1
- package/crud/crud.d.ts +0 -6
- package/crud/crud.js +0 -188
- package/crud/crud.js.map +0 -1
- package/crud/model.d.ts +0 -2
- package/crud/model.js +0 -127
- package/crud/model.js.map +0 -1
- package/useCases/GetLockRecord/GetLockRecordUseCase.d.ts +0 -10
- package/useCases/GetLockRecord/GetLockRecordUseCase.js +0 -35
- package/useCases/GetLockRecord/GetLockRecordUseCase.js.map +0 -1
- package/useCases/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.d.ts +0 -16
- package/useCases/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js +0 -27
- package/useCases/GetLockedEntryLockRecord/GetLockedEntryLockRecordUseCase.js.map +0 -1
- package/useCases/IsEntryLocked/IsEntryLockedUseCase.d.ts +0 -16
- package/useCases/IsEntryLocked/IsEntryLockedUseCase.js +0 -35
- package/useCases/IsEntryLocked/IsEntryLockedUseCase.js.map +0 -1
- package/useCases/KickOutCurrentUser/KickOutCurrentUserUseCase.d.ts +0 -12
- package/useCases/KickOutCurrentUser/KickOutCurrentUserUseCase.js +0 -46
- package/useCases/KickOutCurrentUser/KickOutCurrentUserUseCase.js.map +0 -1
- package/useCases/ListAllLockRecordsUseCase/ListAllLockRecordsUseCase.d.ts +0 -10
- package/useCases/ListAllLockRecordsUseCase/ListAllLockRecordsUseCase.js +0 -32
- package/useCases/ListAllLockRecordsUseCase/ListAllLockRecordsUseCase.js.map +0 -1
- package/useCases/ListLockRecordsUseCase/ListLockRecordsUseCase.d.ts +0 -14
- package/useCases/ListLockRecordsUseCase/ListLockRecordsUseCase.js +0 -27
- package/useCases/ListLockRecordsUseCase/ListLockRecordsUseCase.js.map +0 -1
- package/useCases/LockEntryUseCase/LockEntryUseCase.d.ts +0 -13
- package/useCases/LockEntryUseCase/LockEntryUseCase.js +0 -51
- package/useCases/LockEntryUseCase/LockEntryUseCase.js.map +0 -1
- package/useCases/UnlockEntryUseCase/UnlockEntryUseCase.d.ts +0 -20
- package/useCases/UnlockEntryUseCase/UnlockEntryUseCase.js +0 -67
- package/useCases/UnlockEntryUseCase/UnlockEntryUseCase.js.map +0 -1
- package/useCases/UnlockRequestUseCase/UnlockEntryRequestUseCase.d.ts +0 -15
- package/useCases/UnlockRequestUseCase/UnlockEntryRequestUseCase.js +0 -78
- package/useCases/UnlockRequestUseCase/UnlockEntryRequestUseCase.js.map +0 -1
- package/useCases/UpdateEntryLock/UpdateEntryLockUseCase.d.ts +0 -18
- package/useCases/UpdateEntryLock/UpdateEntryLockUseCase.js +0 -48
- package/useCases/UpdateEntryLock/UpdateEntryLockUseCase.js.map +0 -1
- package/useCases/index.d.ts +0 -28
- package/useCases/index.js +0 -83
- package/useCases/index.js.map +0 -1
- package/utils/calculateExpiresOn.d.ts +0 -2
- package/utils/calculateExpiresOn.js +0 -15
- package/utils/calculateExpiresOn.js.map +0 -1
- package/utils/checkPermissions.d.ts +0 -7
- package/utils/checkPermissions.js +0 -21
- package/utils/checkPermissions.js.map +0 -1
- package/utils/convertEntryToLockRecord.d.ts +0 -28
- package/utils/convertEntryToLockRecord.js.map +0 -1
- package/utils/isLockedFactory.d.ts +0 -5
- package/utils/isLockedFactory.js +0 -20
- package/utils/isLockedFactory.js.map +0 -1
- package/utils/resolve.js +0 -30
- package/utils/resolve.js.map +0 -1
- package/utils/validateSameIdentity.d.ts +0 -6
- package/utils/validateSameIdentity.js +0 -24
- package/utils/validateSameIdentity.js.map +0 -1
package/graphql/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_resolve","require","_handlerGraphql","_renderFields","_createFieldTypePluginRecords","_renderListFilterFields","_renderSortEnum","_checkPermissions","createGraphQLSchema","params","context","model","recordLocking","getModel","models","security","withoutAuthorization","cms","listModels","filter","fields","length","isPrivate","fieldTypePlugins","createFieldTypePluginRecords","plugins","recordLockingFields","renderFields","type","listFilterFieldsRender","renderListFilterFields","excludeFields","sortEnumRender","renderSortEnum","sorterPlugins","plugin","createGraphQLSchemaPlugin","typeDefs","map","f","join","resolvers","Query","Mutation","RecordLockingQuery","isEntryLocked","_","args","resolve","checkPermissions","id","getLockRecord","result","NotFoundError","getLockedEntryLockRecord","listLockRecords","resolveList","listAllLockRecords","RecordLockingMutation","lockEntry","updateEntryLock","unlockEntry","force","unlockEntryRequest","name","exports"],"sources":["schema.ts"],"sourcesContent":["import { resolve, resolveList } from \"~/utils/resolve\";\nimport { Context } from \"~/types\";\nimport {\n createGraphQLSchemaPlugin,\n IGraphQLSchemaPlugin,\n NotFoundError\n} from \"@webiny/handler-graphql\";\nimport { renderFields } from \"@webiny/api-headless-cms/utils/renderFields\";\nimport { createFieldTypePluginRecords } from \"@webiny/api-headless-cms/graphql/schema/createFieldTypePluginRecords\";\nimport { renderListFilterFields } from \"@webiny/api-headless-cms/utils/renderListFilterFields\";\nimport { renderSortEnum } from \"@webiny/api-headless-cms/utils/renderSortEnum\";\nimport { checkPermissions } from \"~/utils/checkPermissions\";\n\ninterface Params {\n context: Pick<Context, \"plugins\" | \"recordLocking\" | \"security\" | \"cms\">;\n}\nexport const createGraphQLSchema = async (\n params: Params\n): Promise<IGraphQLSchemaPlugin<Context>> => {\n const context = params.context;\n\n const model = await context.recordLocking.getModel();\n\n const models = await context.security.withoutAuthorization(async () => {\n return (await context.cms.listModels()).filter(model => {\n if (model.fields.length === 0) {\n return false;\n } else if (model.isPrivate) {\n return false;\n }\n return true;\n });\n });\n\n const fieldTypePlugins = createFieldTypePluginRecords(context.plugins);\n\n const recordLockingFields = renderFields({\n models,\n model,\n fields: model.fields,\n type: \"manage\",\n fieldTypePlugins\n });\n\n const listFilterFieldsRender = renderListFilterFields({\n model,\n fields: model.fields,\n type: \"manage\",\n fieldTypePlugins,\n excludeFields: [\"entryId\"]\n });\n\n const sortEnumRender = renderSortEnum({\n model,\n fields: model.fields,\n fieldTypePlugins,\n sorterPlugins: []\n });\n\n const plugin = createGraphQLSchemaPlugin<Context>({\n typeDefs: /* GraphQL */ `\n ${recordLockingFields.map(f => f.typeDefs).join(\"\\n\")}\n\n type RecordLockingError {\n message: String\n code: String\n data: JSON\n stack: String\n }\n\n enum RecordLockingRecordActionType {\n requested\n approved\n denied\n }\n\n type RecordLockingIdentity {\n id: String!\n displayName: String\n type: String\n }\n\n type RecordLockingRecordAction {\n id: ID!\n type: RecordLockingRecordActionType!\n message: String\n createdBy: RecordLockingIdentity!\n createdOn: DateTime!\n }\n\n type RecordLockingRecord {\n id: ID!\n lockedBy: RecordLockingIdentity!\n lockedOn: DateTime!\n updatedOn: DateTime!\n expiresOn: DateTime!\n ${recordLockingFields.map(f => f.fields).join(\"\\n\")}\n }\n\n type RecordLockingIsEntryLockedResponse {\n data: Boolean\n error: RecordLockingError\n }\n\n type RecordLockingGetLockRecordResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n type RecordLockingGetLockedEntryLockRecordResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n type RecordLockingListLockRecordsResponse {\n data: [RecordLockingRecord!]\n error: RecordLockingError\n }\n\n type RecordLockingLockEntryResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n \n type RecordLockingUpdateLockResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n type RecordLockingUnlockEntryResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n type RecordLockingUnlockEntryRequestResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n input RecordLockingListWhereInput {\n ${listFilterFieldsRender}\n }\n\n enum RecordLockingListSorter {\n ${sortEnumRender}\n }\n\n type RecordLockingQuery {\n _empty: String\n }\n\n type RecordLockingMutation {\n _empty: String\n }\n\n extend type RecordLockingQuery {\n isEntryLocked(id: ID!, type: String!): RecordLockingIsEntryLockedResponse!\n getLockRecord(id: ID!, type: String!): RecordLockingGetLockRecordResponse!\n # Returns lock record or null - if entry is locked in context of the current user, does not throw an error like getLockRecord if no record in the DB\n getLockedEntryLockRecord(id: ID!, type: String!): RecordLockingGetLockedEntryLockRecordResponse!\n listAllLockRecords(\n where: RecordLockingListWhereInput\n sort: [RecordLockingListSorter!]\n limit: Int\n after: String\n ): RecordLockingListLockRecordsResponse!\n # Basically same as listAllLockRecords except this one will filter out records with expired lock.\n listLockRecords(\n where: RecordLockingListWhereInput\n sort: [RecordLockingListSorter!]\n limit: Int\n after: String\n ): RecordLockingListLockRecordsResponse!\n }\n\n extend type RecordLockingMutation {\n lockEntry(id: ID!, type: String!): RecordLockingLockEntryResponse!\n updateEntryLock(id: ID!, type: String!): RecordLockingUpdateLockResponse!\n unlockEntry(id: ID!, type: String!, force: Boolean): RecordLockingUnlockEntryResponse!\n unlockEntryRequest(\n id: ID!\n type: String!\n ): RecordLockingUnlockEntryRequestResponse!\n }\n\n extend type Query {\n recordLocking: RecordLockingQuery\n }\n\n extend type Mutation {\n recordLocking: RecordLockingMutation\n }\n `,\n resolvers: {\n Query: {\n recordLocking: async () => ({})\n },\n Mutation: {\n recordLocking: async () => ({})\n },\n RecordLockingQuery: {\n async isEntryLocked(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n return context.recordLocking.isEntryLocked({\n id: args.id,\n type: args.type\n });\n });\n },\n async getLockRecord(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n const result = await context.recordLocking.getLockRecord({\n id: args.id,\n type: args.type\n });\n if (result) {\n return result;\n }\n throw new NotFoundError(\"Lock record not found.\");\n });\n },\n async getLockedEntryLockRecord(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n return await context.recordLocking.getLockedEntryLockRecord({\n id: args.id,\n type: args.type\n });\n });\n },\n\n async listLockRecords(_, args, context) {\n return resolveList(async () => {\n await checkPermissions(context);\n return await context.recordLocking.listLockRecords(args);\n });\n },\n listAllLockRecords(_, args, context) {\n return resolveList(async () => {\n await checkPermissions(context);\n return await context.recordLocking.listAllLockRecords(args);\n });\n }\n },\n RecordLockingMutation: {\n async lockEntry(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n return context.recordLocking.lockEntry({\n id: args.id,\n type: args.type\n });\n });\n },\n async updateEntryLock(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n return context.recordLocking.updateEntryLock({\n id: args.id,\n type: args.type\n });\n });\n },\n async unlockEntry(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n return await context.recordLocking.unlockEntry({\n id: args.id,\n type: args.type,\n force: args.force\n });\n });\n },\n async unlockEntryRequest(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n return await context.recordLocking.unlockEntryRequest({\n id: args.id,\n type: args.type\n });\n });\n }\n }\n }\n });\n\n plugin.name =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AE,CAAC,SAAS;EAC7B,CAAC,CAAC;EAEF,MAAMC,cAAc,GAAG,IAAAC,8BAAc,EAAC;IAClCtB,KAAK;IACLS,MAAM,EAAET,KAAK,CAACS,MAAM;IACpBG,gBAAgB;IAChBW,aAAa,EAAE;EACnB,CAAC,CAAC;EAEF,MAAMC,MAAM,GAAG,IAAAC,yCAAyB,EAAU;IAC9CC,QAAQ,EAAE,aAAe;AACjC,cAAcX,mBAAmB,CAACY,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACF,QAAQ,CAAC,CAACG,IAAI,CAAC,IAAI,CAAE;AAClE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkBd,mBAAmB,CAACY,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACnB,MAAM,CAAC,CAACoB,IAAI,CAAC,IAAI,CAAE;AACpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkBX,sBAAuB;AACzC;AACA;AACA;AACA,kBAAkBG,cAAe;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;IACDS,SAAS,EAAE;MACPC,KAAK,EAAE;QACH9B,aAAa,EAAE,MAAAA,CAAA,MAAa,CAAC,CAA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O,IAAAsC,gBAAO,EAAC,YAAY;YACvB,MAAM,IAAAC,kCAAgB,EAACvC,OAAO,CAAC;YAC/B,OAAO,MAAMA,OAAO,CAACE,aAAa,CAACiD,WAAW,CAAC;cAC3CX,EAAE,EAAEH,IAAI,CAACG,EAAE;cACXtB,IAAI,EAAEmB,IAAI,CAACnB,IAAI;cACfkC,KAAK,EAAEf,IAAI,CAACe;YAChB,CAAC,CAAC;UACN,CAAC,CAAC;QACN,CAAC;QACD,MAAMC,kBAAkBA,CAACjB,CAAC,EAAEC,IAAI,EAAErC,OAAO,EAAE;UACvC,OAAO,IAAAsC,gBAAO,EAAC,YAAY;YACvB,MAAM,IAAAC,kCAAgB,EAACvC,OAAO,CAAC;YAC/B,OAAO,MAAMA,OAAO,CAACE,aAAa,CAACmD,kBAAkB,CAAC;cAClDb,EAAE,EAAEH,IAAI,CAACG,EAAE;cACXtB,IAAI,EAAEmB,IAAI,CAACnB;YACf,CAAC,CAAC;UACN,CAAC,CAAC;QACN;MACJ;IACJ;EACJ,CAAC,CAAC;EAEFO,MAAM,CAAC6B,IAAI,GAAG,sCAAsC;EAEpD,OAAO7B,MAAM;AACjB,CAAC;AAAC8B,OAAA,CAAAzD,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["resolve","resolveList","createGraphQLSchemaPlugin","renderFields","renderListFilterFields","renderSortEnum","checkPermissions","IsEntryLockedUseCase","GetLockRecordUseCase","GetLockedEntryLockRecordUseCase","ListLockRecordsUseCase","ListAllLockRecordsUseCase","LockEntryUseCase","UpdateEntryLockUseCase","UnlockEntryUseCase","UnlockEntryRequestUseCase","createGraphQLSchema","params","model","models","filter","fields","length","fieldTypePlugins","recordLockingFields","type","listFilterFieldsRender","excludeFields","sortEnumRender","sorterPlugins","plugin","typeDefs","map","f","join","allFiltersAsString","resolvers","Query","recordLocking","Mutation","RecordLockingQuery","isEntryLocked","_","args","context","useCase","container","result","execute","id","isFail","error","value","getLockRecord","getLockedEntryLockRecord","listLockRecords","listAllLockRecords","RecordLockingMutation","lockEntry","updateEntryLock","unlockEntry","force","unlockEntryRequest","name"],"sources":["schema.ts"],"sourcesContent":["import { resolve, resolveList } from \"./resolve.js\";\nimport type { IGraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { createGraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { renderFields } from \"@webiny/api-headless-cms/utils/renderFields.js\";\nimport { renderListFilterFields } from \"@webiny/api-headless-cms/utils/renderListFilterFields.js\";\nimport { renderSortEnum } from \"@webiny/api-headless-cms/utils/renderSortEnum.js\";\nimport { checkPermissions } from \"./checkPermissions.js\";\nimport { IsEntryLockedUseCase } from \"~/features/IsEntryLocked/abstractions.js\";\nimport { GetLockRecordUseCase } from \"~/features/GetLockRecord/abstractions.js\";\nimport { GetLockedEntryLockRecordUseCase } from \"~/features/GetLockedEntryLockRecord/abstractions.js\";\nimport { ListLockRecordsUseCase } from \"~/features/ListLockRecords/abstractions.js\";\nimport { ListAllLockRecordsUseCase } from \"~/features/ListAllLockRecords/abstractions.js\";\nimport { LockEntryUseCase } from \"~/features/LockEntry/abstractions.js\";\nimport { UpdateEntryLockUseCase } from \"~/features/UpdateEntryLock/abstractions.js\";\nimport { UnlockEntryUseCase } from \"~/features/UnlockEntry/abstractions.js\";\nimport { UnlockEntryRequestUseCase } from \"~/features/UnlockEntryRequest/abstractions.js\";\nimport type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types/model.js\";\nimport type { CmsFieldTypePlugins } from \"@webiny/api-headless-cms/types/index.js\";\n\ninterface Params {\n // Record locking model\n model: CmsModel;\n // All public models\n models: CmsModel[];\n fieldTypePlugins: CmsFieldTypePlugins;\n}\nexport const createGraphQLSchema = async (\n params: Params\n): Promise<IGraphQLSchemaPlugin<ApiCoreContext>> => {\n // Record locking model\n const model = params.model;\n\n // Other public models that have at least one field\n const models = params.models.filter(model => {\n return model.fields.length > 0;\n });\n\n const fieldTypePlugins = params.fieldTypePlugins;\n\n const recordLockingFields = renderFields({\n models,\n model,\n fields: model.fields,\n type: \"manage\",\n fieldTypePlugins\n });\n\n const listFilterFieldsRender = renderListFilterFields({\n model,\n fields: model.fields,\n type: \"manage\",\n fieldTypePlugins,\n excludeFields: [\"entryId\"]\n });\n\n const sortEnumRender = renderSortEnum({\n model,\n fields: model.fields,\n fieldTypePlugins,\n sorterPlugins: []\n });\n\n const plugin = createGraphQLSchemaPlugin<ApiCoreContext>({\n typeDefs: /* GraphQL */ `\n ${recordLockingFields.map(f => f.typeDefs).join(\"\\n\")}\n\n type RecordLockingError {\n message: String\n code: String\n data: JSON\n stack: String\n }\n\n enum RecordLockingRecordActionType {\n requested\n approved\n denied\n }\n\n type RecordLockingIdentity {\n id: String!\n displayName: String\n type: String\n }\n\n type RecordLockingRecordAction {\n id: ID!\n type: RecordLockingRecordActionType!\n message: String\n createdBy: RecordLockingIdentity!\n createdOn: DateTime!\n }\n\n type RecordLockingRecord {\n id: ID!\n lockedBy: RecordLockingIdentity!\n lockedOn: DateTime!\n updatedOn: DateTime!\n expiresOn: DateTime!\n ${recordLockingFields.map(f => f.fields).join(\"\\n\")}\n }\n\n type RecordLockingIsEntryLockedResponse {\n data: Boolean\n error: RecordLockingError\n }\n\n type RecordLockingGetLockRecordResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n type RecordLockingGetLockedEntryLockRecordResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n type RecordLockingListLockRecordsResponse {\n data: [RecordLockingRecord!]\n error: RecordLockingError\n }\n\n type RecordLockingLockEntryResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n \n type RecordLockingUpdateLockResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n type RecordLockingUnlockEntryResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n type RecordLockingUnlockEntryRequestResponse {\n data: RecordLockingRecord\n error: RecordLockingError\n }\n\n input RecordLockingListWhereInput {\n ${listFilterFieldsRender.allFiltersAsString()}\n }\n\n enum RecordLockingListSorter {\n ${sortEnumRender}\n }\n\n type RecordLockingQuery {\n _empty: String\n }\n\n type RecordLockingMutation {\n _empty: String\n }\n\n extend type RecordLockingQuery {\n isEntryLocked(id: ID!, type: String!): RecordLockingIsEntryLockedResponse!\n getLockRecord(id: ID!, type: String!): RecordLockingGetLockRecordResponse!\n # Returns lock record or null - if entry is locked in context of the current user, does not throw an error like getLockRecord if no record in the DB\n getLockedEntryLockRecord(id: ID!, type: String!): RecordLockingGetLockedEntryLockRecordResponse!\n listAllLockRecords(\n where: RecordLockingListWhereInput\n sort: [RecordLockingListSorter!]\n limit: Int\n after: String\n ): RecordLockingListLockRecordsResponse!\n # Basically same as listAllLockRecords except this one will filter out records with expired lock.\n listLockRecords(\n where: RecordLockingListWhereInput\n sort: [RecordLockingListSorter!]\n limit: Int\n after: String\n ): RecordLockingListLockRecordsResponse!\n }\n\n extend type RecordLockingMutation {\n lockEntry(id: ID!, type: String!): RecordLockingLockEntryResponse!\n updateEntryLock(id: ID!, type: String!): RecordLockingUpdateLockResponse!\n unlockEntry(id: ID!, type: String!, force: Boolean): RecordLockingUnlockEntryResponse!\n unlockEntryRequest(\n id: ID!\n type: String!\n ): RecordLockingUnlockEntryRequestResponse!\n }\n\n extend type Query {\n recordLocking: RecordLockingQuery\n }\n\n extend type Mutation {\n recordLocking: RecordLockingMutation\n }\n `,\n resolvers: {\n Query: {\n recordLocking: async () => ({})\n },\n Mutation: {\n recordLocking: async () => ({})\n },\n RecordLockingQuery: {\n async isEntryLocked(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(IsEntryLockedUseCase);\n const result = await useCase.execute({\n id: args.id,\n type: args.type\n });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n async getLockRecord(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(GetLockRecordUseCase);\n const result = await useCase.execute({\n id: args.id,\n type: args.type\n });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n async getLockedEntryLockRecord(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(GetLockedEntryLockRecordUseCase);\n const result = await useCase.execute({\n id: args.id,\n type: args.type\n });\n // Returns null if not found/expired/locked by current user\n if (result.isFail()) {\n return null;\n }\n return result.value;\n });\n },\n\n async listLockRecords(_, args, context) {\n return resolveList(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(ListLockRecordsUseCase);\n const result = await useCase.execute(args);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n listAllLockRecords(_, args, context) {\n return resolveList(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(ListAllLockRecordsUseCase);\n const result = await useCase.execute(args);\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n }\n },\n RecordLockingMutation: {\n async lockEntry(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(LockEntryUseCase);\n const result = await useCase.execute({\n id: args.id,\n type: args.type\n });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n async updateEntryLock(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(UpdateEntryLockUseCase);\n const result = await useCase.execute({\n id: args.id,\n type: args.type\n });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n async unlockEntry(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(UnlockEntryUseCase);\n const result = await useCase.execute({\n id: args.id,\n type: args.type,\n force: args.force\n });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n },\n async unlockEntryRequest(_, args, context) {\n return resolve(async () => {\n await checkPermissions(context);\n const useCase = context.container.resolve(UnlockEntryRequestUseCase);\n const result = await useCase.execute({\n id: args.id,\n type: args.type\n });\n if (result.isFail()) {\n throw result.error;\n }\n return result.value;\n });\n }\n }\n }\n });\n\n plugin.name = \"recordLocking.graphql.schema.locking\";\n\n return plugin;\n};\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,WAAW;AAE7B,SAASC,yBAAyB,QAAQ,yBAAyB;AACnE,SAASC,YAAY,QAAQ,gDAAgD;AAC7E,SAASC,sBAAsB,QAAQ,0DAA0D;AACjG,SAASC,cAAc,QAAQ,kDAAkD;AACjF,SAASC,gBAAgB;AACzB,SAASC,oBAAoB;AAC7B,SAASC,oBAAoB;AAC7B,SAASC,+BAA+B;AACxC,SAASC,sBAAsB;AAC/B,SAASC,yBAAyB;AAClC,SAASC,gBAAgB;AACzB,SAASC,sBAAsB;AAC/B,SAASC,kBAAkB;AAC3B,SAASC,yBAAyB;AAYlC,OAAO,MAAMC,mBAAmB,GAAG,MAC/BC,MAAc,IACkC;EAChD;EACA,MAAMC,KAAK,GAAGD,MAAM,CAACC,KAAK;;EAE1B;EACA,MAAMC,MAAM,GAAGF,MAAM,CAACE,MAAM,CAACC,MAAM,CAACF,KAAK,IAAI;IACzC,OAAOA,KAAK,CAACG,MAAM,CAACC,MAAM,GAAG,CAAC;EAClC,CAAC,CAAC;EAEF,MAAMC,gBAAgB,GAAGN,MAAM,CAACM,gBAAgB;EAEhD,MAAMC,mBAAmB,GAAGrB,YAAY,CAAC;IACrCgB,MAAM;IACND,KAAK;IACLG,MAAM,EAAEH,KAAK,CAACG,MAAM;IACpBI,IAAI,EAAE,QAAQ;IACdF;EACJ,CAAC,CAAC;EAEF,MAAMG,sBAAsB,GAAGtB,sBAAsB,CAAC;IAClDc,KAAK;IACLG,MAAM,EAAEH,KAAK,CAACG,MAAM;IACpBI,IAAI,EAAE,QAAQ;IACdF,gBAAgB;IAChBI,aAAa,EAAE,CAAC,SAAS;EAC7B,CAAC,CAAC;EAEF,MAAMC,cAAc,GAAGvB,cAAc,CAAC;IAClCa,KAAK;IACLG,MAAM,EAAEH,KAAK,CAACG,MAAM;IACpBE,gBAAgB;IAChBM,aAAa,EAAE;EACnB,CAAC,CAAC;EAEF,MAAMC,MAAM,GAAG5B,yBAAyB,CAAiB;IACrD6B,QAAQ,EAAE,aAAc;AAChC,cAAcP,mBAAmB,CAACQ,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACF,QAAQ,CAAC,CAACG,IAAI,CAAC,IAAI,CAAC;AACjE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkBV,mBAAmB,CAACQ,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACZ,MAAM,CAAC,CAACa,IAAI,CAAC,IAAI,CAAC;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkBR,sBAAsB,CAACS,kBAAkB,CAAC,CAAC;AAC7D;AACA;AACA;AACA,kBAAkBP,cAAc;AAChC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS;IACDQ,SAAS,EAAE;MACPC,KAAK,EAAE;QACHC,aAAa,EAAE,MAAAA,CAAA,MAAa,CAAC,CAAC;MAClC,CAAC;MACDC,QAAQ,EAAE;QACND,aAAa,EAAE,MAAAA,CAAA,MAAa,CAAC,CAAC;MAClC,CAAC;MACDE,kBAAkB,EAAE;QAChB,MAAMC,aA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MF,OAAO,CAACG,OAAO,CAAC;cACjCC,EAAE,EAAEN,IAAI,CAACM,EAAE;cACXxB,IAAI,EAAEkB,IAAI,CAAClB,IAAI;cACfoC,KAAK,EAAElB,IAAI,CAACkB;YAChB,CAAC,CAAC;YACF,IAAId,MAAM,CAACG,MAAM,CAAC,CAAC,EAAE;cACjB,MAAMH,MAAM,CAACI,KAAK;YACtB;YACA,OAAOJ,MAAM,CAACK,KAAK;UACvB,CAAC,CAAC;QACN,CAAC;QACD,MAAMU,kBAAkBA,CAACpB,CAAC,EAAEC,IAAI,EAAEC,OAAO,EAAE;UACvC,OAAO5C,OAAO,CAAC,YAAY;YACvB,MAAMM,gBAAgB,CAACsC,OAAO,CAAC;YAC/B,MAAMC,OAAO,GAAGD,OAAO,CAACE,SAAS,CAAC9C,OAAO,CAACe,yBAAyB,CAAC;YACpE,MAAMgC,MAAM,GAAG,MAAMF,OAAO,CAACG,OAAO,CAAC;cACjCC,EAAE,EAAEN,IAAI,CAACM,EAAE;cACXxB,IAAI,EAAEkB,IAAI,CAAClB;YACf,CAAC,CAAC;YACF,IAAIsB,MAAM,CAACG,MAAM,CAAC,CAAC,EAAE;cACjB,MAAMH,MAAM,CAACI,KAAK;YACtB;YACA,OAAOJ,MAAM,CAACK,KAAK;UACvB,CAAC,CAAC;QACN;MACJ;IACJ;EACJ,CAAC,CAAC;EAEFtB,MAAM,CAACiC,IAAI,GAAG,sCAAsC;EAEpD,OAAOjC,MAAM;AACjB,CAAC","ignoreList":[]}
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import type { ApiCoreContext } from "@webiny/api-core/types/core.js";
|
|
1
2
|
import { ContextPlugin } from "@webiny/api";
|
|
2
|
-
|
|
3
|
-
|
|
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>[];
|
package/index.js
CHANGED
|
@@ -1,38 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const createContextPlugin =
|
|
13
|
-
const plugin = new
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
1
|
+
import { ContextPlugin } from "@webiny/api";
|
|
2
|
+
import { WcpContext } from "@webiny/api-core/features/wcp/WcpContext/index.js";
|
|
3
|
+
import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels";
|
|
4
|
+
import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel";
|
|
5
|
+
import { RecordLockingModel, RECORD_LOCKING_MODEL_ID } from "./domain/RecordLockingModel.js";
|
|
6
|
+
import { getTimeout } from "./utils/getTimeout.js";
|
|
7
|
+
import { RecordLockingFeature } from "./features/RecordLockingFeature.js";
|
|
8
|
+
import { createGraphQLSchema } from "./graphql/schema.js";
|
|
9
|
+
import { createFieldTypePluginRecords } from "@webiny/api-headless-cms/graphql/schema/createFieldTypePluginRecords.js";
|
|
10
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
11
|
+
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
12
|
+
const createContextPlugin = params => {
|
|
13
|
+
const plugin = new ContextPlugin(async context => {
|
|
14
|
+
const tenantContext = context.container.resolve(TenantContext);
|
|
15
|
+
const identityContext = context.container.resolve(IdentityContext);
|
|
16
|
+
const wcp = context.container.resolve(WcpContext);
|
|
17
|
+
const getModel = context.container.resolve(GetModelUseCase);
|
|
18
|
+
const listModels = context.container.resolve(ListModelsUseCase);
|
|
19
|
+
if (!wcp.canUseRecordLocking() || !tenantContext.getTenant()) {
|
|
19
20
|
return;
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
|
|
23
|
+
// Register the private model
|
|
24
|
+
context.container.register(RecordLockingModel);
|
|
25
|
+
|
|
26
|
+
// Determine timeout value
|
|
27
|
+
const timeout = getTimeout(params?.timeout);
|
|
28
|
+
|
|
29
|
+
// Fetch CMS model to use for storing record locking data
|
|
30
|
+
const [model, publicModels] = await identityContext.withoutAuthorization(async () => {
|
|
31
|
+
const [model, publicModels] = await Promise.all([
|
|
32
|
+
// Get a record locking model
|
|
33
|
+
getModel.execute(RECORD_LOCKING_MODEL_ID),
|
|
34
|
+
// Get all models
|
|
35
|
+
listModels.execute({
|
|
36
|
+
includePrivate: false
|
|
37
|
+
})]);
|
|
38
|
+
return [model.value, publicModels.value];
|
|
24
39
|
});
|
|
25
|
-
|
|
26
|
-
|
|
40
|
+
|
|
41
|
+
// Register GraphQL schema plugin
|
|
42
|
+
const graphQlPlugin = await createGraphQLSchema({
|
|
43
|
+
model,
|
|
44
|
+
models: publicModels,
|
|
45
|
+
fieldTypePlugins: createFieldTypePluginRecords(context.plugins)
|
|
27
46
|
});
|
|
28
47
|
context.plugins.register(graphQlPlugin);
|
|
48
|
+
|
|
49
|
+
// Register features
|
|
50
|
+
RecordLockingFeature.register(context.container, {
|
|
51
|
+
timeout,
|
|
52
|
+
model
|
|
53
|
+
});
|
|
29
54
|
});
|
|
30
55
|
plugin.name = "context.recordLocking";
|
|
31
56
|
return plugin;
|
|
32
57
|
};
|
|
33
|
-
const createRecordLocking =
|
|
34
|
-
return [createContextPlugin()];
|
|
58
|
+
export const createRecordLocking = params => {
|
|
59
|
+
return [createContextPlugin(params)];
|
|
35
60
|
};
|
|
36
|
-
exports.createRecordLocking = createRecordLocking;
|
|
37
61
|
|
|
38
62
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["ContextPlugin","WcpContext","ListModelsUseCase","GetModelUseCase","RecordLockingModel","RECORD_LOCKING_MODEL_ID","getTimeout","RecordLockingFeature","createGraphQLSchema","createFieldTypePluginRecords","IdentityContext","TenantContext","createContextPlugin","params","plugin","context","tenantContext","container","resolve","identityContext","wcp","getModel","listModels","canUseRecordLocking","getTenant","register","timeout","model","publicModels","withoutAuthorization","Promise","all","execute","includePrivate","value","graphQlPlugin","models","fieldTypePlugins","plugins","name","createRecordLocking"],"sources":["index.ts"],"sourcesContent":["import type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { WcpContext } from \"@webiny/api-core/features/wcp/WcpContext/index.js\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel\";\nimport { RecordLockingModel, RECORD_LOCKING_MODEL_ID } from \"~/domain/RecordLockingModel.js\";\nimport { getTimeout } from \"~/utils/getTimeout.js\";\nimport { RecordLockingFeature } from \"~/features/RecordLockingFeature.js\";\nimport { createGraphQLSchema } from \"~/graphql/schema.js\";\nimport { createFieldTypePluginRecords } from \"@webiny/api-headless-cms/graphql/schema/createFieldTypePluginRecords.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\n\nexport interface ICreateContextPluginParams {\n /**\n * A number of seconds after the last activity to wait before the record is automatically unlocked.\n */\n timeout?: number;\n}\n\nconst createContextPlugin = (params?: ICreateContextPluginParams) => {\n const plugin = new ContextPlugin<ApiCoreContext>(async context => {\n const tenantContext = context.container.resolve(TenantContext);\n const identityContext = context.container.resolve(IdentityContext);\n const wcp = context.container.resolve(WcpContext);\n const getModel = context.container.resolve(GetModelUseCase);\n const listModels = context.container.resolve(ListModelsUseCase);\n\n if (!wcp.canUseRecordLocking() || !tenantContext.getTenant()) {\n return;\n }\n\n // Register the private model\n context.container.register(RecordLockingModel);\n\n // Determine timeout value\n const timeout = getTimeout(params?.timeout);\n\n // Fetch CMS model to use for storing record locking data\n const [model, publicModels] = await identityContext.withoutAuthorization(async () => {\n const [model, publicModels] = await Promise.all([\n // Get a record locking model\n getModel.execute(RECORD_LOCKING_MODEL_ID),\n // Get all models\n listModels.execute({ includePrivate: false })\n ]);\n\n return [model.value, publicModels.value];\n });\n\n // Register GraphQL schema plugin\n const graphQlPlugin = await createGraphQLSchema({\n model,\n models: publicModels,\n fieldTypePlugins: createFieldTypePluginRecords(context.plugins)\n });\n\n context.plugins.register(graphQlPlugin);\n\n // Register features\n RecordLockingFeature.register(context.container, {\n timeout,\n model\n });\n });\n plugin.name = \"context.recordLocking\";\n\n return plugin;\n};\n\nexport const createRecordLocking = (params?: ICreateContextPluginParams) => {\n return [createContextPlugin(params)];\n};\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,aAAa;AAC3C,SAASC,UAAU,QAAQ,mDAAmD;AAC9E,SAASC,iBAAiB,QAAQ,2DAA2D;AAC7F,SAASC,eAAe,QAAQ,yDAAyD;AACzF,SAASC,kBAAkB,EAAEC,uBAAuB;AACpD,SAASC,UAAU;AACnB,SAASC,oBAAoB;AAC7B,SAASC,mBAAmB;AAC5B,SAASC,4BAA4B,QAAQ,yEAAyE;AACtH,SAASC,eAAe,QAAQ,6DAA6D;AAC7F,SAASC,aAAa,QAAQ,0DAA0D;AASxF,MAAMC,mBAAmB,GAAIC,MAAmC,IAAK;EACjE,MAAMC,MAAM,GAAG,IAAId,aAAa,CAAiB,MAAMe,OAAO,IAAI;IAC9D,MAAMC,aAAa,GAAGD,OAAO,CAACE,SAAS,CAACC,OAAO,CAACP,aAAa,CAAC;IAC9D,MAAMQ,eAAe,GAAGJ,OAAO,CAACE,SAAS,CAACC,OAAO,CAACR,eAAe,CAAC;IAClE,MAAMU,GAAG,GAAGL,OAAO,CAACE,SAAS,CAACC,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uB;EAErC,OAAOzB,MAAM;AACjB,CAAC;AAED,OAAO,MAAM0B,mBAAmB,GAAI3B,MAAmC,IAAK;EACxE,OAAO,CAACD,mBAAmB,CAACC,MAAM,CAAC,CAAC;AACxC,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-record-locking",
|
|
3
|
-
"version": "6.0.0-
|
|
3
|
+
"version": "6.0.0-rc.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"main": "index.js",
|
|
5
6
|
"repository": {
|
|
6
7
|
"type": "git",
|
|
@@ -12,53 +13,30 @@
|
|
|
12
13
|
],
|
|
13
14
|
"license": "MIT",
|
|
14
15
|
"dependencies": {
|
|
15
|
-
"@
|
|
16
|
-
"@
|
|
17
|
-
"@webiny/api": "6.0.0-
|
|
18
|
-
"@webiny/
|
|
19
|
-
"@webiny/
|
|
20
|
-
"@webiny/
|
|
21
|
-
"@webiny/handler": "6.0.0-
|
|
22
|
-
"@webiny/
|
|
23
|
-
"@webiny/
|
|
24
|
-
"@webiny/plugins": "6.0.0-beta.0",
|
|
25
|
-
"@webiny/pubsub": "6.0.0-beta.0",
|
|
26
|
-
"@webiny/utils": "6.0.0-beta.0"
|
|
16
|
+
"@webiny/api": "6.0.0-rc.0",
|
|
17
|
+
"@webiny/api-headless-cms": "6.0.0-rc.0",
|
|
18
|
+
"@webiny/api-websockets": "6.0.0-rc.0",
|
|
19
|
+
"@webiny/feature": "6.0.0-rc.0",
|
|
20
|
+
"@webiny/handler": "6.0.0-rc.0",
|
|
21
|
+
"@webiny/handler-aws": "6.0.0-rc.0",
|
|
22
|
+
"@webiny/handler-graphql": "6.0.0-rc.0",
|
|
23
|
+
"@webiny/plugins": "6.0.0-rc.0",
|
|
24
|
+
"@webiny/utils": "6.0.0-rc.0"
|
|
27
25
|
},
|
|
28
26
|
"devDependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
32
|
-
"@
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"@webiny/project-utils": "6.0.0-beta.0",
|
|
39
|
-
"graphql": "15.8.0",
|
|
40
|
-
"rimraf": "5.0.5",
|
|
41
|
-
"ttypescript": "1.5.15",
|
|
42
|
-
"type-fest": "2.19.0",
|
|
43
|
-
"typescript": "4.7.4"
|
|
27
|
+
"@webiny/api-core": "6.0.0-rc.0",
|
|
28
|
+
"@webiny/build-tools": "6.0.0-rc.0",
|
|
29
|
+
"@webiny/project-utils": "6.0.0-rc.0",
|
|
30
|
+
"@webiny/wcp": "6.0.0-rc.0",
|
|
31
|
+
"graphql": "16.12.0",
|
|
32
|
+
"rimraf": "6.1.3",
|
|
33
|
+
"type-fest": "5.4.4",
|
|
34
|
+
"typescript": "5.9.3",
|
|
35
|
+
"vitest": "4.0.18"
|
|
44
36
|
},
|
|
45
37
|
"publishConfig": {
|
|
46
38
|
"access": "public",
|
|
47
39
|
"directory": "dist"
|
|
48
40
|
},
|
|
49
|
-
"
|
|
50
|
-
"build": "yarn webiny run build",
|
|
51
|
-
"watch": "yarn webiny run watch"
|
|
52
|
-
},
|
|
53
|
-
"gitHead": "aa8dbfbbd5ad13ec271adba6f2431e02991a300f",
|
|
54
|
-
"adio": {
|
|
55
|
-
"ignore": {
|
|
56
|
-
"src": [
|
|
57
|
-
"aws-lambda"
|
|
58
|
-
],
|
|
59
|
-
"dependencies": [
|
|
60
|
-
"@types/aws-lambda"
|
|
61
|
-
]
|
|
62
|
-
}
|
|
63
|
-
}
|
|
41
|
+
"gitHead": "0f2aa699f4642e550ab62c96fcd050e8d02345c9"
|
|
64
42
|
}
|
package/types.d.ts
CHANGED
|
@@ -1,48 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export declare
|
|
7
|
-
export declare type IRecordLockingMeta = CmsEntryMeta;
|
|
8
|
-
export interface IHasFullAccessCallable {
|
|
9
|
-
(): Promise<boolean>;
|
|
10
|
-
}
|
|
11
|
-
export interface IGetWebsocketsContextCallable {
|
|
12
|
-
(): IWebsocketsContextObject;
|
|
13
|
-
}
|
|
14
|
-
export interface IGetIdentity {
|
|
15
|
-
(): IRecordLockingIdentity;
|
|
16
|
-
}
|
|
17
|
-
export interface IRecordLockingLockRecordValues {
|
|
18
|
-
targetId: string;
|
|
19
|
-
type: IRecordLockingLockRecordEntryType;
|
|
20
|
-
actions?: IRecordLockingLockRecordAction[];
|
|
21
|
-
}
|
|
22
|
-
export declare enum IRecordLockingLockRecordActionType {
|
|
1
|
+
import type { CmsEntryListParams, CmsEntryMeta, CmsIdentity } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { CmsEntry, CmsError } from "@webiny/api-headless-cms/types/index.js";
|
|
3
|
+
export type { CmsError, CmsEntry };
|
|
4
|
+
export type IRecordLockingIdentity = CmsIdentity;
|
|
5
|
+
export type IRecordLockingMeta = CmsEntryMeta;
|
|
6
|
+
export declare enum RecordLockingLockRecordActionType {
|
|
23
7
|
requested = "requested",
|
|
24
8
|
approved = "approved",
|
|
25
9
|
denied = "denied"
|
|
26
10
|
}
|
|
27
11
|
export interface IRecordLockingLockRecordRequestedAction {
|
|
28
|
-
type:
|
|
12
|
+
type: RecordLockingLockRecordActionType.requested;
|
|
29
13
|
message?: string;
|
|
30
14
|
createdOn: Date;
|
|
31
15
|
createdBy: IRecordLockingIdentity;
|
|
32
16
|
}
|
|
33
17
|
export interface IRecordLockingLockRecordApprovedAction {
|
|
34
|
-
type:
|
|
18
|
+
type: RecordLockingLockRecordActionType.approved;
|
|
35
19
|
message?: string;
|
|
36
20
|
createdOn: Date;
|
|
37
21
|
createdBy: IRecordLockingIdentity;
|
|
38
22
|
}
|
|
39
23
|
export interface IRecordLockingLockRecordDeniedAction {
|
|
40
|
-
type:
|
|
24
|
+
type: RecordLockingLockRecordActionType.denied;
|
|
41
25
|
message?: string;
|
|
42
26
|
createdOn: Date;
|
|
43
27
|
createdBy: IRecordLockingIdentity;
|
|
44
28
|
}
|
|
45
|
-
export
|
|
29
|
+
export type IRecordLockingLockRecordAction = IRecordLockingLockRecordRequestedAction | IRecordLockingLockRecordApprovedAction | IRecordLockingLockRecordDeniedAction;
|
|
46
30
|
export interface IRecordLockingLockRecordObject {
|
|
47
31
|
id: string;
|
|
48
32
|
targetId: string;
|
|
@@ -59,114 +43,11 @@ export interface IRecordLockingLockRecord extends IRecordLockingLockRecordObject
|
|
|
59
43
|
getUnlockRequested(): IRecordLockingLockRecordRequestedAction | undefined;
|
|
60
44
|
getUnlockApproved(): IRecordLockingLockRecordApprovedAction | undefined;
|
|
61
45
|
getUnlockDenied(): IRecordLockingLockRecordDeniedAction | undefined;
|
|
46
|
+
isExpired(): boolean;
|
|
62
47
|
}
|
|
63
48
|
/**
|
|
64
49
|
* Do not use any special chars other than #, as we use this to create lock record IDs.
|
|
65
50
|
*/
|
|
66
|
-
export
|
|
67
|
-
export
|
|
68
|
-
export
|
|
69
|
-
export interface IRecordLockingListAllLockRecordsResponse {
|
|
70
|
-
items: IRecordLockingLockRecord[];
|
|
71
|
-
meta: IRecordLockingMeta;
|
|
72
|
-
}
|
|
73
|
-
export declare type IRecordLockingListLockRecordsResponse = IRecordLockingListAllLockRecordsResponse;
|
|
74
|
-
export interface IRecordLockingGetLockRecordParams {
|
|
75
|
-
id: string;
|
|
76
|
-
type: IRecordLockingLockRecordEntryType;
|
|
77
|
-
}
|
|
78
|
-
export interface IRecordLockingIsLockedParams {
|
|
79
|
-
id: string;
|
|
80
|
-
type: IRecordLockingLockRecordEntryType;
|
|
81
|
-
}
|
|
82
|
-
export interface IRecordLockingGetLockedEntryLockRecordParams {
|
|
83
|
-
id: string;
|
|
84
|
-
type: IRecordLockingLockRecordEntryType;
|
|
85
|
-
}
|
|
86
|
-
export interface IRecordLockingLockEntryParams {
|
|
87
|
-
id: string;
|
|
88
|
-
type: IRecordLockingLockRecordEntryType;
|
|
89
|
-
}
|
|
90
|
-
export interface IRecordLockingUpdateEntryLockParams {
|
|
91
|
-
id: string;
|
|
92
|
-
type: IRecordLockingLockRecordEntryType;
|
|
93
|
-
}
|
|
94
|
-
export interface IRecordLockingUnlockEntryParams {
|
|
95
|
-
id: string;
|
|
96
|
-
type: IRecordLockingLockRecordEntryType;
|
|
97
|
-
force?: boolean;
|
|
98
|
-
}
|
|
99
|
-
export interface IRecordLockingUnlockEntryRequestParams {
|
|
100
|
-
id: string;
|
|
101
|
-
type: IRecordLockingLockRecordEntryType;
|
|
102
|
-
}
|
|
103
|
-
export interface OnEntryBeforeLockTopicParams {
|
|
104
|
-
id: string;
|
|
105
|
-
type: IRecordLockingLockRecordEntryType;
|
|
106
|
-
}
|
|
107
|
-
export interface OnEntryAfterLockTopicParams {
|
|
108
|
-
id: string;
|
|
109
|
-
type: IRecordLockingLockRecordEntryType;
|
|
110
|
-
record: IRecordLockingLockRecord;
|
|
111
|
-
}
|
|
112
|
-
export interface OnEntryLockErrorTopicParams {
|
|
113
|
-
id: string;
|
|
114
|
-
type: IRecordLockingLockRecordEntryType;
|
|
115
|
-
error: CmsError;
|
|
116
|
-
}
|
|
117
|
-
export interface OnEntryBeforeUnlockTopicParams {
|
|
118
|
-
id: string;
|
|
119
|
-
type: IRecordLockingLockRecordEntryType;
|
|
120
|
-
getIdentity: IGetIdentity;
|
|
121
|
-
}
|
|
122
|
-
export interface OnEntryAfterUnlockTopicParams {
|
|
123
|
-
id: string;
|
|
124
|
-
type: IRecordLockingLockRecordEntryType;
|
|
125
|
-
record: IRecordLockingLockRecord;
|
|
126
|
-
}
|
|
127
|
-
export interface OnEntryUnlockErrorTopicParams {
|
|
128
|
-
id: string;
|
|
129
|
-
type: IRecordLockingLockRecordEntryType;
|
|
130
|
-
error: CmsError;
|
|
131
|
-
}
|
|
132
|
-
export interface OnEntryBeforeUnlockRequestTopicParams {
|
|
133
|
-
id: string;
|
|
134
|
-
type: IRecordLockingLockRecordEntryType;
|
|
135
|
-
}
|
|
136
|
-
export interface OnEntryAfterUnlockRequestTopicParams {
|
|
137
|
-
id: string;
|
|
138
|
-
type: IRecordLockingLockRecordEntryType;
|
|
139
|
-
record: IRecordLockingLockRecord;
|
|
140
|
-
}
|
|
141
|
-
export interface OnEntryUnlockRequestErrorTopicParams {
|
|
142
|
-
id: string;
|
|
143
|
-
type: IRecordLockingLockRecordEntryType;
|
|
144
|
-
error: CmsError;
|
|
145
|
-
}
|
|
146
|
-
export interface IRecordLocking {
|
|
147
|
-
onEntryBeforeLock: Topic<OnEntryBeforeLockTopicParams>;
|
|
148
|
-
onEntryAfterLock: Topic<OnEntryAfterLockTopicParams>;
|
|
149
|
-
onEntryLockError: Topic<OnEntryLockErrorTopicParams>;
|
|
150
|
-
onEntryBeforeUnlock: Topic<OnEntryBeforeUnlockTopicParams>;
|
|
151
|
-
onEntryAfterUnlock: Topic<OnEntryAfterUnlockTopicParams>;
|
|
152
|
-
onEntryUnlockError: Topic<OnEntryUnlockErrorTopicParams>;
|
|
153
|
-
onEntryBeforeUnlockRequest: Topic<OnEntryBeforeUnlockRequestTopicParams>;
|
|
154
|
-
onEntryAfterUnlockRequest: Topic<OnEntryAfterUnlockRequestTopicParams>;
|
|
155
|
-
onEntryUnlockRequestError: Topic<OnEntryUnlockRequestErrorTopicParams>;
|
|
156
|
-
getModel(): Promise<CmsModel>;
|
|
157
|
-
listAllLockRecords(params?: IRecordLockingListAllLockRecordsParams): Promise<IRecordLockingListAllLockRecordsResponse>;
|
|
158
|
-
/**
|
|
159
|
-
* Same call as listAllLockRecords, except this one will filter out records with expired lock.
|
|
160
|
-
*/
|
|
161
|
-
listLockRecords(params?: IRecordLockingListLockRecordsParams): Promise<IRecordLockingListLockRecordsResponse>;
|
|
162
|
-
getLockRecord(params: IRecordLockingGetLockRecordParams): Promise<IRecordLockingLockRecord | null>;
|
|
163
|
-
isEntryLocked(params: IRecordLockingIsLockedParams): Promise<boolean>;
|
|
164
|
-
getLockedEntryLockRecord(params: IRecordLockingGetLockedEntryLockRecordParams): Promise<IRecordLockingLockRecord | null>;
|
|
165
|
-
lockEntry(params: IRecordLockingLockEntryParams): Promise<IRecordLockingLockRecord>;
|
|
166
|
-
updateEntryLock(params: IRecordLockingUpdateEntryLockParams): Promise<IRecordLockingLockRecord>;
|
|
167
|
-
unlockEntry(params: IRecordLockingUnlockEntryParams): Promise<IRecordLockingLockRecord>;
|
|
168
|
-
unlockEntryRequest(params: IRecordLockingUnlockEntryRequestParams): Promise<IRecordLockingLockRecord>;
|
|
169
|
-
}
|
|
170
|
-
export interface Context extends CmsContext, IWebsocketsContext {
|
|
171
|
-
recordLocking: IRecordLocking;
|
|
172
|
-
}
|
|
51
|
+
export type IRecordLockingLockRecordEntryType = string;
|
|
52
|
+
export type IRecordLockingListAllLockRecordsParams = Pick<CmsEntryListParams, "where" | "limit" | "sort" | "after">;
|
|
53
|
+
export type IRecordLockingListLockRecordsParams = IRecordLockingListAllLockRecordsParams;
|
package/types.js
CHANGED
|
@@ -1,28 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
Object.defineProperty(exports, "CmsEntry", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _types.CmsEntry;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "CmsError", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _types.CmsError;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
exports.IRecordLockingLockRecordActionType = void 0;
|
|
19
|
-
var _types = require("@webiny/api-headless-cms/types");
|
|
20
|
-
let IRecordLockingLockRecordActionType = exports.IRecordLockingLockRecordActionType = /*#__PURE__*/function (IRecordLockingLockRecordActionType) {
|
|
21
|
-
IRecordLockingLockRecordActionType["requested"] = "requested";
|
|
22
|
-
IRecordLockingLockRecordActionType["approved"] = "approved";
|
|
23
|
-
IRecordLockingLockRecordActionType["denied"] = "denied";
|
|
24
|
-
return IRecordLockingLockRecordActionType;
|
|
1
|
+
export let RecordLockingLockRecordActionType = /*#__PURE__*/function (RecordLockingLockRecordActionType) {
|
|
2
|
+
RecordLockingLockRecordActionType["requested"] = "requested";
|
|
3
|
+
RecordLockingLockRecordActionType["approved"] = "approved";
|
|
4
|
+
RecordLockingLockRecordActionType["denied"] = "denied";
|
|
5
|
+
return RecordLockingLockRecordActionType;
|
|
25
6
|
}({});
|
|
7
|
+
|
|
26
8
|
/**
|
|
27
9
|
* Do not use any special chars other than #, as we use this to create lock record IDs.
|
|
28
10
|
*/
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["RecordLockingLockRecordActionType"],"sources":["types.ts"],"sourcesContent":["import type {\n CmsEntryListParams,\n CmsEntryMeta,\n CmsIdentity\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { CmsEntry, CmsError } from \"@webiny/api-headless-cms/types/index.js\";\n\nexport type { CmsError, CmsEntry };\n\nexport type IRecordLockingIdentity = CmsIdentity;\n\nexport type IRecordLockingMeta = CmsEntryMeta;\n\nexport enum RecordLockingLockRecordActionType {\n requested = \"requested\",\n approved = \"approved\",\n denied = \"denied\"\n}\n\nexport interface IRecordLockingLockRecordRequestedAction {\n type: RecordLockingLockRecordActionType.requested;\n message?: string;\n createdOn: Date;\n createdBy: IRecordLockingIdentity;\n}\n\nexport interface IRecordLockingLockRecordApprovedAction {\n type: RecordLockingLockRecordActionType.approved;\n message?: string;\n createdOn: Date;\n createdBy: IRecordLockingIdentity;\n}\n\nexport interface IRecordLockingLockRecordDeniedAction {\n type: RecordLockingLockRecordActionType.denied;\n message?: string;\n createdOn: Date;\n createdBy: IRecordLockingIdentity;\n}\n\nexport type IRecordLockingLockRecordAction =\n | IRecordLockingLockRecordRequestedAction\n | IRecordLockingLockRecordApprovedAction\n | IRecordLockingLockRecordDeniedAction;\n\nexport interface IRecordLockingLockRecordObject {\n id: string;\n targetId: string;\n type: IRecordLockingLockRecordEntryType;\n lockedBy: IRecordLockingIdentity;\n lockedOn: Date;\n updatedOn: Date;\n expiresOn: Date;\n actions?: IRecordLockingLockRecordAction[];\n}\n\nexport interface IRecordLockingLockRecord extends IRecordLockingLockRecordObject {\n toObject(): IRecordLockingLockRecordObject;\n addAction(action: IRecordLockingLockRecordAction): void;\n getUnlockRequested(): IRecordLockingLockRecordRequestedAction | undefined;\n getUnlockApproved(): IRecordLockingLockRecordApprovedAction | undefined;\n getUnlockDenied(): IRecordLockingLockRecordDeniedAction | undefined;\n isExpired(): boolean;\n}\n\n/**\n * Do not use any special chars other than #, as we use this to create lock record IDs.\n */\nexport type IRecordLockingLockRecordEntryType = string;\n\nexport type IRecordLockingListAllLockRecordsParams = Pick<\n CmsEntryListParams,\n \"where\" | \"limit\" | \"sort\" | \"after\"\n>;\n\nexport type IRecordLockingListLockRecordsParams = IRecordLockingListAllLockRecordsParams;\n"],"mappings":"AAaA,WAAYA,iCAAiC,0BAAjCA,iCAAiC;EAAjCA,iCAAiC;EAAjCA,iCAAiC;EAAjCA,iCAAiC;EAAA,OAAjCA,iCAAiC;AAAA;;AAoD7C;AACA;AACA","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IRecordLockingListLockRecordsParams } from "../types";
|
|
2
|
-
|
|
1
|
+
import type { IRecordLockingListLockRecordsParams } from "../types.js";
|
|
2
|
+
type IWhere = IRecordLockingListLockRecordsParams["where"] | undefined;
|
|
3
3
|
export declare const convertWhereCondition: (where: IWhere) => IWhere;
|
|
4
4
|
export {};
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.convertWhereCondition = void 0;
|
|
7
|
-
var _lockRecordDatabaseId = require("./lockRecordDatabaseId");
|
|
1
|
+
import { createLockRecordDatabaseId } from "./lockRecordDatabaseId.js";
|
|
8
2
|
const attachPrefix = value => {
|
|
9
|
-
if (
|
|
10
|
-
return value;
|
|
11
|
-
} else if (Array.isArray(value)) {
|
|
12
|
-
return value.map(_lockRecordDatabaseId.createLockRecordDatabaseId);
|
|
3
|
+
if (Array.isArray(value)) {
|
|
4
|
+
return value.map(createLockRecordDatabaseId);
|
|
13
5
|
}
|
|
14
|
-
return
|
|
6
|
+
return createLockRecordDatabaseId(value);
|
|
15
7
|
};
|
|
16
|
-
const convertWhereCondition = where => {
|
|
8
|
+
export const convertWhereCondition = where => {
|
|
17
9
|
if (!where) {
|
|
18
10
|
return where;
|
|
19
11
|
}
|
|
@@ -30,12 +22,17 @@ const convertWhereCondition = where => {
|
|
|
30
22
|
} else if (key.startsWith("id") === false) {
|
|
31
23
|
continue;
|
|
32
24
|
}
|
|
25
|
+
const value = where[key];
|
|
26
|
+
if (!value) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
33
29
|
const newKey = key.replace("id", "entryId");
|
|
30
|
+
// @ts-expect-error
|
|
34
31
|
where[newKey] = attachPrefix(where[key]);
|
|
32
|
+
// @ts-expect-error
|
|
35
33
|
delete where[key];
|
|
36
34
|
}
|
|
37
35
|
return where;
|
|
38
36
|
};
|
|
39
|
-
exports.convertWhereCondition = convertWhereCondition;
|
|
40
37
|
|
|
41
38
|
//# sourceMappingURL=convertWhereCondition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createLockRecordDatabaseId","attachPrefix","value","Array","isArray","map","convertWhereCondition","where","key","startsWith","subKey","newKey","replace"],"sources":["convertWhereCondition.ts"],"sourcesContent":["import type { IRecordLockingListLockRecordsParams } from \"~/types.js\";\nimport { createLockRecordDatabaseId } from \"~/utils/lockRecordDatabaseId.js\";\n\ntype IWhere = IRecordLockingListLockRecordsParams[\"where\"] | undefined;\n\nconst attachPrefix = (value: string | string[]) => {\n if (Array.isArray(value)) {\n return value.map(createLockRecordDatabaseId);\n }\n return createLockRecordDatabaseId(value);\n};\n\nexport const convertWhereCondition = (where: IWhere): IWhere => {\n if (!where) {\n return where;\n }\n for (const key in where) {\n if (key.startsWith(\"AND\") || key.startsWith(\"OR\")) {\n const value = where[key as keyof typeof where] as IWhere[] | undefined;\n if (!value) {\n continue;\n }\n for (const subKey in value) {\n value[subKey] = convertWhereCondition(value[subKey]);\n }\n continue;\n } else if (key.startsWith(\"id\") === false) {\n continue;\n }\n const value = where[key as keyof typeof where];\n if (!value) {\n continue;\n }\n\n const newKey = key.replace(\"id\", \"entryId\") as keyof typeof where;\n // @ts-expect-error\n where[newKey] = attachPrefix(where[key]);\n // @ts-expect-error\n delete where[key];\n }\n return where;\n};\n"],"mappings":"AACA,SAASA,0BAA0B;AAInC,MAAMC,YAAY,GAAIC,KAAwB,IAAK;EAC/C,IAAIC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE;IACtB,OAAOA,KAAK,CAACG,GAAG,CAACL,0BAA0B,CAAC;EAChD;EACA,OAAOA,0BAA0B,CAACE,KAAK,CAAC;AAC5C,CAAC;AAED,OAAO,MAAMI,qBAAqB,GAAIC,KAAa,IAAa;EAC5D,IAAI,CAACA,KAAK,EAAE;IACR,OAAOA,KAAK;EAChB;EACA,KAAK,MAAMC,GAAG,IAAID,KAAK,EAAE;IACrB,IAAIC,GAAG,CAACC,UAAU,CAAC,KAAK,CAAC,IAAID,GAAG,CAACC,UAAU,CAAC,IAAI,CAAC,EAAE;MAC/C,MAAMP,KAAK,GAAGK,KAAK,CAACC,GAAG,CAA+C;MACtE,IAAI,CAACN,KAAK,EAAE;QACR;MACJ;MACA,KAAK,MAAMQ,MAAM,IAAIR,KAAK,EAAE;QACxBA,KAAK,CAACQ,MAAM,CAAC,GAAGJ,qBAAqB,CAACJ,KAAK,CAACQ,MAAM,CAAC,CAAC;MACxD;MACA;IACJ,CAAC,MAAM,IAAIF,GAAG,CAACC,UAAU,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE;MACvC;IACJ;IACA,MAAMP,KAAK,GAAGK,KAAK,CAACC,GAAG,CAAuB;IAC9C,IAAI,CAACN,KAAK,EAAE;MACR;IACJ;IAEA,MAAMS,MAAM,GAAGH,GAAG,CAACI,OAAO,CAAC,IAAI,EAAE,SAAS,CAAuB;IACjE;IACAL,KAAK,CAACI,MAAM,CAAC,GAAGV,YAAY,CAACM,KAAK,CAACC,GAAG,CAAC,CAAC;IACxC;IACA,OAAOD,KAAK,CAACC,GAAG,CAAC;EACrB;EACA,OAAOD,KAAK;AAChB,CAAC","ignoreList":[]}
|
package/utils/getTimeout.d.ts
CHANGED