@webiny/api-record-locking 0.0.0-unstable.6844005670 → 0.0.0-unstable.7be00a75a9
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/domain/LockRecord.js +63 -70
- package/domain/LockRecord.js.map +1 -1
- package/domain/RecordLockingModel.js +26 -23
- package/domain/RecordLockingModel.js.map +1 -1
- 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.js +27 -24
- 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 +1 -1
- package/features/KickOutCurrentUser/KickOutCurrentUserUseCase.js +33 -33
- 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.js +31 -31
- 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.js +31 -31
- 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.js +33 -30
- 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 +8 -8
- 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 -1
- package/features/RecordLockingFeature.js +19 -21
- package/features/RecordLockingFeature.js.map +1 -1
- 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.js +29 -27
- 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 +8 -8
- 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 +1 -1
- package/features/UnlockEntryRequest/UnlockEntryRequestRepository.js +32 -31
- 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 +8 -8
- 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 +1 -1
- package/features/UpdateEntryLock/UpdateEntryLockRepository.js +46 -49
- 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/checkPermissions.js +6 -10
- package/graphql/checkPermissions.js.map +1 -1
- package/graphql/resolve.js +15 -17
- package/graphql/resolve.js.map +1 -1
- package/graphql/schema.d.ts +2 -2
- package/graphql/schema.js +147 -168
- package/graphql/schema.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +46 -48
- package/index.js.map +1 -1
- 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/index.js
CHANGED
|
@@ -1,62 +1,60 @@
|
|
|
1
1
|
import { ContextPlugin } from "@webiny/api";
|
|
2
|
+
import { createRegisterExtensionPlugin } from "@webiny/handler";
|
|
2
3
|
import { WcpContext } from "@webiny/api-core/features/wcp/WcpContext/index.js";
|
|
3
4
|
import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels";
|
|
4
5
|
import { GetModelUseCase } from "@webiny/api-headless-cms/features/contentModel/GetModel";
|
|
5
|
-
import {
|
|
6
|
+
import { RECORD_LOCKING_MODEL_ID, RecordLockingModel } from "./domain/RecordLockingModel.js";
|
|
6
7
|
import { getTimeout } from "./utils/getTimeout.js";
|
|
7
8
|
import { RecordLockingFeature } from "./features/RecordLockingFeature.js";
|
|
8
9
|
import { createGraphQLSchema } from "./graphql/schema.js";
|
|
9
|
-
import { createFieldTypePluginRecords } from "@webiny/api-headless-cms/graphql/schema/createFieldTypePluginRecords.js";
|
|
10
10
|
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
11
11
|
import { TenantContext } from "@webiny/api-core/features/tenancy/TenantContext/index.js";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
fieldTypePlugins: createFieldTypePluginRecords(context.plugins)
|
|
46
|
-
});
|
|
47
|
-
context.plugins.register(graphQlPlugin);
|
|
48
|
-
|
|
49
|
-
// Register features
|
|
50
|
-
RecordLockingFeature.register(context.container, {
|
|
51
|
-
timeout,
|
|
52
|
-
model
|
|
12
|
+
import { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/exports/api/cms/graphql.js";
|
|
13
|
+
const createContextPlugin = (params)=>{
|
|
14
|
+
const recordLockingContextPlugin = new ContextPlugin(async (context)=>{
|
|
15
|
+
const tenantContext = context.container.resolve(TenantContext);
|
|
16
|
+
const identityContext = context.container.resolve(IdentityContext);
|
|
17
|
+
const wcp = context.container.resolve(WcpContext);
|
|
18
|
+
const getModel = context.container.resolve(GetModelUseCase);
|
|
19
|
+
const listModels = context.container.resolve(ListModelsUseCase);
|
|
20
|
+
if (!wcp.canUseRecordLocking() || !tenantContext.getTenant()) return;
|
|
21
|
+
const timeout = getTimeout(params?.timeout);
|
|
22
|
+
const [model, publicModels] = await identityContext.withoutAuthorization(async ()=>{
|
|
23
|
+
const [model, publicModels] = await Promise.all([
|
|
24
|
+
getModel.execute(RECORD_LOCKING_MODEL_ID),
|
|
25
|
+
listModels.execute({
|
|
26
|
+
includePrivate: false
|
|
27
|
+
})
|
|
28
|
+
]);
|
|
29
|
+
return [
|
|
30
|
+
model.value,
|
|
31
|
+
publicModels.value
|
|
32
|
+
];
|
|
33
|
+
});
|
|
34
|
+
const fieldRegistry = context.container.resolve(CmsModelFieldToGraphQLRegistry);
|
|
35
|
+
const graphQlPlugin = await createGraphQLSchema({
|
|
36
|
+
model,
|
|
37
|
+
models: publicModels,
|
|
38
|
+
fieldRegistry
|
|
39
|
+
});
|
|
40
|
+
context.plugins.register(graphQlPlugin);
|
|
41
|
+
RecordLockingFeature.register(context.container, {
|
|
42
|
+
timeout,
|
|
43
|
+
model
|
|
44
|
+
});
|
|
53
45
|
});
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return plugin;
|
|
46
|
+
recordLockingContextPlugin.name = "context.recordLocking";
|
|
47
|
+
return recordLockingContextPlugin;
|
|
57
48
|
};
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
const createRecordLocking = (params)=>{
|
|
50
|
+
const modelsPlugin = createRegisterExtensionPlugin((context)=>{
|
|
51
|
+
context.container.register(RecordLockingModel);
|
|
52
|
+
});
|
|
53
|
+
return [
|
|
54
|
+
createContextPlugin(params),
|
|
55
|
+
modelsPlugin
|
|
56
|
+
];
|
|
60
57
|
};
|
|
58
|
+
export { createRecordLocking };
|
|
61
59
|
|
|
62
60
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type { ApiCoreContext } from \"@webiny/api-core/types/core.js\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { createRegisterExtensionPlugin } from \"@webiny/handler\";\nimport { WcpContext } from \"@webiny/api-core/features/wcp/WcpContext/index.js\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels\";\nimport { GetModelUseCase } from \"@webiny/api-headless-cms/features/contentModel/GetModel\";\nimport { RecordLockingModel, RECORD_LOCKING_MODEL_ID } from \"~/domain/RecordLockingModel.js\";\nimport { getTimeout } from \"~/utils/getTimeout.js\";\nimport { RecordLockingFeature } from \"~/features/RecordLockingFeature.js\";\nimport { createGraphQLSchema } from \"~/graphql/schema.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\n\nexport interface ICreateContextPluginParams {\n /**\n * A number of seconds after the last activity to wait before the record is automatically unlocked.\n */\n timeout?: number;\n}\n\nconst createContextPlugin = (params?: ICreateContextPluginParams) => {\n const recordLockingContextPlugin = 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 // Determine timeout value\n const timeout = getTimeout(params?.timeout);\n\n // Fetch CMS model to use for storing record locking data\n const [model, publicModels] = await identityContext.withoutAuthorization(async () => {\n const [model, publicModels] = await Promise.all([\n // Get a record locking model\n getModel.execute(RECORD_LOCKING_MODEL_ID),\n // Get all models\n listModels.execute({ includePrivate: false })\n ]);\n\n return [model.value, publicModels.value];\n });\n\n const fieldRegistry = context.container.resolve(CmsModelFieldToGraphQLRegistry);\n\n // Register GraphQL schema plugin\n const graphQlPlugin = await createGraphQLSchema({\n model,\n models: publicModels,\n fieldRegistry\n });\n\n context.plugins.register(graphQlPlugin);\n\n // Register features\n RecordLockingFeature.register(context.container, {\n timeout,\n model\n });\n });\n recordLockingContextPlugin.name = \"context.recordLocking\";\n\n return recordLockingContextPlugin;\n};\n\nexport const createRecordLocking = (params?: ICreateContextPluginParams) => {\n const modelsPlugin = createRegisterExtensionPlugin(context => {\n context.container.register(RecordLockingModel);\n });\n\n return [createContextPlugin(params), modelsPlugin];\n};\n"],"names":["createContextPlugin","params","recordLockingContextPlugin","ContextPlugin","context","tenantContext","TenantContext","identityContext","IdentityContext","wcp","WcpContext","getModel","GetModelUseCase","listModels","ListModelsUseCase","timeout","getTimeout","model","publicModels","Promise","RECORD_LOCKING_MODEL_ID","fieldRegistry","CmsModelFieldToGraphQLRegistry","graphQlPlugin","createGraphQLSchema","RecordLockingFeature","createRecordLocking","modelsPlugin","createRegisterExtensionPlugin","RecordLockingModel"],"mappings":";;;;;;;;;;;;AAqBA,MAAMA,sBAAsB,CAACC;IACzB,MAAMC,6BAA6B,IAAIC,cAA8B,OAAMC;QACvE,MAAMC,gBAAgBD,QAAQ,SAAS,CAAC,OAAO,CAACE;QAChD,MAAMC,kBAAkBH,QAAQ,SAAS,CAAC,OAAO,CAACI;QAClD,MAAMC,MAAML,QAAQ,SAAS,CAAC,OAAO,CAACM;QACtC,MAAMC,WAAWP,QAAQ,SAAS,CAAC,OAAO,CAACQ;QAC3C,MAAMC,aAAaT,QAAQ,SAAS,CAAC,OAAO,CAACU;QAE7C,IAAI,CAACL,IAAI,mBAAmB,MAAM,CAACJ,cAAc,SAAS,IACtD;QAIJ,MAAMU,UAAUC,WAAWf,QAAQ;QAGnC,MAAM,CAACgB,OAAOC,aAAa,GAAG,MAAMX,gBAAgB,oBAAoB,CAAC;YACrE,MAAM,CAACU,OAAOC,aAAa,GAAG,MAAMC,QAAQ,GAAG,CAAC;gBAE5CR,SAAS,OAAO,CAACS;gBAEjBP,WAAW,OAAO,CAAC;oBAAE,gBAAgB;gBAAM;aAC9C;YAED,OAAO;gBAACI,MAAM,KAAK;gBAAEC,aAAa,KAAK;aAAC;QAC5C;QAEA,MAAMG,gBAAgBjB,QAAQ,SAAS,CAAC,OAAO,CAACkB;QAGhD,MAAMC,gBAAgB,MAAMC,oBAAoB;YAC5CP;YACA,QAAQC;YACRG;QACJ;QAEAjB,QAAQ,OAAO,CAAC,QAAQ,CAACmB;QAGzBE,qBAAqB,QAAQ,CAACrB,QAAQ,SAAS,EAAE;YAC7CW;YACAE;QACJ;IACJ;IACAf,2BAA2B,IAAI,GAAG;IAElC,OAAOA;AACX;AAEO,MAAMwB,sBAAsB,CAACzB;IAChC,MAAM0B,eAAeC,8BAA8BxB,CAAAA;QAC/CA,QAAQ,SAAS,CAAC,QAAQ,CAACyB;IAC/B;IAEA,OAAO;QAAC7B,oBAAoBC;QAAS0B;KAAa;AACtD"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-record-locking",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.7be00a75a9",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./index.js",
|
|
7
|
+
"./*": "./*"
|
|
8
|
+
},
|
|
6
9
|
"repository": {
|
|
7
10
|
"type": "git",
|
|
8
11
|
"url": "https://github.com/webiny/webiny-js.git"
|
|
@@ -13,30 +16,32 @@
|
|
|
13
16
|
],
|
|
14
17
|
"license": "MIT",
|
|
15
18
|
"dependencies": {
|
|
16
|
-
"@webiny/api": "0.0.0-unstable.
|
|
17
|
-
"@webiny/api-headless-cms": "0.0.0-unstable.
|
|
18
|
-
"@webiny/api-websockets": "0.0.0-unstable.
|
|
19
|
-
"@webiny/feature": "0.0.0-unstable.
|
|
20
|
-
"@webiny/handler": "0.0.0-unstable.
|
|
21
|
-
"@webiny/handler-aws": "0.0.0-unstable.
|
|
22
|
-
"@webiny/handler-graphql": "0.0.0-unstable.
|
|
23
|
-
"@webiny/plugins": "0.0.0-unstable.
|
|
24
|
-
"@webiny/utils": "0.0.0-unstable.
|
|
19
|
+
"@webiny/api": "0.0.0-unstable.7be00a75a9",
|
|
20
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.7be00a75a9",
|
|
21
|
+
"@webiny/api-websockets": "0.0.0-unstable.7be00a75a9",
|
|
22
|
+
"@webiny/feature": "0.0.0-unstable.7be00a75a9",
|
|
23
|
+
"@webiny/handler": "0.0.0-unstable.7be00a75a9",
|
|
24
|
+
"@webiny/handler-aws": "0.0.0-unstable.7be00a75a9",
|
|
25
|
+
"@webiny/handler-graphql": "0.0.0-unstable.7be00a75a9",
|
|
26
|
+
"@webiny/plugins": "0.0.0-unstable.7be00a75a9",
|
|
27
|
+
"@webiny/utils": "0.0.0-unstable.7be00a75a9"
|
|
25
28
|
},
|
|
26
29
|
"devDependencies": {
|
|
27
|
-
"@webiny/api-core": "0.0.0-unstable.
|
|
28
|
-
"@webiny/build-tools": "0.0.0-unstable.
|
|
29
|
-
"@webiny/project-utils": "0.0.0-unstable.
|
|
30
|
-
"@webiny/wcp": "0.0.0-unstable.
|
|
31
|
-
"graphql": "16.
|
|
30
|
+
"@webiny/api-core": "0.0.0-unstable.7be00a75a9",
|
|
31
|
+
"@webiny/build-tools": "0.0.0-unstable.7be00a75a9",
|
|
32
|
+
"@webiny/project-utils": "0.0.0-unstable.7be00a75a9",
|
|
33
|
+
"@webiny/wcp": "0.0.0-unstable.7be00a75a9",
|
|
34
|
+
"graphql": "16.14.0",
|
|
32
35
|
"rimraf": "6.1.3",
|
|
33
|
-
"type-fest": "5.
|
|
34
|
-
"typescript": "
|
|
35
|
-
"vitest": "4.
|
|
36
|
+
"type-fest": "5.6.0",
|
|
37
|
+
"typescript": "6.0.3",
|
|
38
|
+
"vitest": "4.1.7"
|
|
36
39
|
},
|
|
37
40
|
"publishConfig": {
|
|
38
|
-
"access": "public"
|
|
39
|
-
"directory": "dist"
|
|
41
|
+
"access": "public"
|
|
40
42
|
},
|
|
41
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "8476da73b653c89cc1474d968baf55c1b0ae0e5f",
|
|
44
|
+
"webiny": {
|
|
45
|
+
"publishFrom": "dist"
|
|
46
|
+
}
|
|
42
47
|
}
|
package/types.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var types_RecordLockingLockRecordActionType = /*#__PURE__*/ function(RecordLockingLockRecordActionType) {
|
|
2
|
+
RecordLockingLockRecordActionType["requested"] = "requested";
|
|
3
|
+
RecordLockingLockRecordActionType["approved"] = "approved";
|
|
4
|
+
RecordLockingLockRecordActionType["denied"] = "denied";
|
|
5
|
+
return RecordLockingLockRecordActionType;
|
|
6
6
|
}({});
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Do not use any special chars other than #, as we use this to create lock record IDs.
|
|
10
|
-
*/
|
|
7
|
+
export { types_RecordLockingLockRecordActionType as RecordLockingLockRecordActionType };
|
|
11
8
|
|
|
12
9
|
//# sourceMappingURL=types.js.map
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../src/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"],"names":["RecordLockingLockRecordActionType"],"mappings":"AAaO,IAAKA,0CAAiCA,WAAAA,GAAAA,SAAjCA,iCAAiC;;;;WAAjCA"}
|
|
@@ -1,38 +1,26 @@
|
|
|
1
1
|
import { createLockRecordDatabaseId } from "./lockRecordDatabaseId.js";
|
|
2
|
-
const attachPrefix = value
|
|
3
|
-
|
|
4
|
-
return value
|
|
5
|
-
}
|
|
6
|
-
return createLockRecordDatabaseId(value);
|
|
2
|
+
const attachPrefix = (value)=>{
|
|
3
|
+
if (Array.isArray(value)) return value.map(createLockRecordDatabaseId);
|
|
4
|
+
return createLockRecordDatabaseId(value);
|
|
7
5
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
const value = where[key];
|
|
26
|
-
if (!value) {
|
|
27
|
-
continue;
|
|
6
|
+
const convertWhereCondition = (where)=>{
|
|
7
|
+
if (!where) return where;
|
|
8
|
+
for(const key in where){
|
|
9
|
+
if (key.startsWith("AND") || key.startsWith("OR")) {
|
|
10
|
+
const value = where[key];
|
|
11
|
+
if (!value) continue;
|
|
12
|
+
for(const subKey in value)value[subKey] = convertWhereCondition(value[subKey]);
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
if (false === key.startsWith("id")) continue;
|
|
16
|
+
const value = where[key];
|
|
17
|
+
if (!value) continue;
|
|
18
|
+
const newKey = key.replace("id", "entryId");
|
|
19
|
+
where[newKey] = attachPrefix(where[key]);
|
|
20
|
+
delete where[key];
|
|
28
21
|
}
|
|
29
|
-
|
|
30
|
-
// @ts-expect-error
|
|
31
|
-
where[newKey] = attachPrefix(where[key]);
|
|
32
|
-
// @ts-expect-error
|
|
33
|
-
delete where[key];
|
|
34
|
-
}
|
|
35
|
-
return where;
|
|
22
|
+
return where;
|
|
36
23
|
};
|
|
24
|
+
export { convertWhereCondition };
|
|
37
25
|
|
|
38
26
|
//# sourceMappingURL=convertWhereCondition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/convertWhereCondition.js","sources":["../../src/utils/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"],"names":["attachPrefix","value","Array","createLockRecordDatabaseId","convertWhereCondition","where","key","subKey","newKey"],"mappings":";AAKA,MAAMA,eAAe,CAACC;IAClB,IAAIC,MAAM,OAAO,CAACD,QACd,OAAOA,MAAM,GAAG,CAACE;IAErB,OAAOA,2BAA2BF;AACtC;AAEO,MAAMG,wBAAwB,CAACC;IAClC,IAAI,CAACA,OACD,OAAOA;IAEX,IAAK,MAAMC,OAAOD,MAAO;QACrB,IAAIC,IAAI,UAAU,CAAC,UAAUA,IAAI,UAAU,CAAC,OAAO;YAC/C,MAAML,QAAQI,KAAK,CAACC,IAA0B;YAC9C,IAAI,CAACL,OACD;YAEJ,IAAK,MAAMM,UAAUN,MACjBA,KAAK,CAACM,OAAO,GAAGH,sBAAsBH,KAAK,CAACM,OAAO;YAEvD;QACJ;QAAO,IAAID,AAAyB,UAAzBA,IAAI,UAAU,CAAC,OACtB;QAEJ,MAAML,QAAQI,KAAK,CAACC,IAA0B;QAC9C,IAAI,CAACL,OACD;QAGJ,MAAMO,SAASF,IAAI,OAAO,CAAC,MAAM;QAEjCD,KAAK,CAACG,OAAO,GAAGR,aAAaK,KAAK,CAACC,IAAI;QAEvC,OAAOD,KAAK,CAACC,IAAI;IACrB;IACA,OAAOD;AACX"}
|
package/utils/getTimeout.js
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
const minTimeoutInSeconds = 30;
|
|
2
2
|
const defaultTimeoutInSeconds = 60;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export const getTimeout = input => {
|
|
8
|
-
if (input && input > 0) {
|
|
9
|
-
if (input < minTimeoutInSeconds) {
|
|
10
|
-
return minTimeoutInSeconds * 1000;
|
|
3
|
+
const getTimeout = (input)=>{
|
|
4
|
+
if (input && input > 0) {
|
|
5
|
+
if (input < minTimeoutInSeconds) return 1000 * minTimeoutInSeconds;
|
|
6
|
+
return 1000 * input;
|
|
11
7
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (!userDefined || isNaN(userDefined) || userDefined <= 0) {
|
|
16
|
-
return defaultTimeoutInSeconds * 1000;
|
|
17
|
-
}
|
|
18
|
-
return userDefined * 1000;
|
|
8
|
+
const userDefined = process.env.WEBINY_RECORD_LOCK_TIMEOUT ? parseInt(process.env.WEBINY_RECORD_LOCK_TIMEOUT) : void 0;
|
|
9
|
+
if (!userDefined || isNaN(userDefined) || userDefined <= 0) return 1000 * defaultTimeoutInSeconds;
|
|
10
|
+
return 1000 * userDefined;
|
|
19
11
|
};
|
|
12
|
+
export { getTimeout };
|
|
20
13
|
|
|
21
14
|
//# sourceMappingURL=getTimeout.js.map
|
package/utils/getTimeout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/getTimeout.js","sources":["../../src/utils/getTimeout.ts"],"sourcesContent":["const minTimeoutInSeconds = 30;\nconst defaultTimeoutInSeconds = 60;\n/**\n * Input is in seconds.\n * Output is milliseconds.\n */\nexport const getTimeout = (input: number | undefined) => {\n if (input && input > 0) {\n if (input < minTimeoutInSeconds) {\n return minTimeoutInSeconds * 1000;\n }\n return input * 1000;\n }\n const userDefined = process.env.WEBINY_RECORD_LOCK_TIMEOUT\n ? parseInt(process.env.WEBINY_RECORD_LOCK_TIMEOUT)\n : undefined;\n if (!userDefined || isNaN(userDefined) || userDefined <= 0) {\n return defaultTimeoutInSeconds * 1000;\n }\n return userDefined * 1000;\n};\n"],"names":["minTimeoutInSeconds","defaultTimeoutInSeconds","getTimeout","input","userDefined","process","parseInt","undefined","isNaN"],"mappings":"AAAA,MAAMA,sBAAsB;AAC5B,MAAMC,0BAA0B;AAKzB,MAAMC,aAAa,CAACC;IACvB,IAAIA,SAASA,QAAQ,GAAG;QACpB,IAAIA,QAAQH,qBACR,OAAOA,AAAsB,OAAtBA;QAEX,OAAOG,AAAQ,OAARA;IACX;IACA,MAAMC,cAAcC,QAAQ,GAAG,CAAC,0BAA0B,GACpDC,SAASD,QAAQ,GAAG,CAAC,0BAA0B,IAC/CE;IACN,IAAI,CAACH,eAAeI,MAAMJ,gBAAgBA,eAAe,GACrD,OAAOH,AAA0B,OAA1BA;IAEX,OAAOG,AAAc,OAAdA;AACX"}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { parseIdentifier } from "@webiny/utils";
|
|
2
2
|
const WBY_LM_PREFIX = "wby-lm-";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
id
|
|
6
|
-
|
|
7
|
-
if (id.startsWith(WBY_LM_PREFIX)) {
|
|
8
|
-
return id;
|
|
9
|
-
}
|
|
10
|
-
return `${WBY_LM_PREFIX}${id}`;
|
|
11
|
-
};
|
|
12
|
-
export const removeLockRecordDatabasePrefix = id => {
|
|
13
|
-
return id.replace(WBY_LM_PREFIX, "");
|
|
3
|
+
const createLockRecordDatabaseId = (input)=>{
|
|
4
|
+
const { id } = parseIdentifier(input);
|
|
5
|
+
if (id.startsWith(WBY_LM_PREFIX)) return id;
|
|
6
|
+
return `${WBY_LM_PREFIX}${id}`;
|
|
14
7
|
};
|
|
8
|
+
const removeLockRecordDatabasePrefix = (id)=>id.replace(WBY_LM_PREFIX, "");
|
|
9
|
+
export { createLockRecordDatabaseId, removeLockRecordDatabasePrefix };
|
|
15
10
|
|
|
16
11
|
//# sourceMappingURL=lockRecordDatabaseId.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils/lockRecordDatabaseId.js","sources":["../../src/utils/lockRecordDatabaseId.ts"],"sourcesContent":["import { parseIdentifier } from \"@webiny/utils\";\n\nconst WBY_LM_PREFIX = \"wby-lm-\";\n\nexport const createLockRecordDatabaseId = (input: string): string => {\n const { id } = parseIdentifier(input);\n if (id.startsWith(WBY_LM_PREFIX)) {\n return id;\n }\n return `${WBY_LM_PREFIX}${id}`;\n};\n\nexport const removeLockRecordDatabasePrefix = (id: string) => {\n return id.replace(WBY_LM_PREFIX, \"\");\n};\n"],"names":["WBY_LM_PREFIX","createLockRecordDatabaseId","input","id","parseIdentifier","removeLockRecordDatabasePrefix"],"mappings":";AAEA,MAAMA,gBAAgB;AAEf,MAAMC,6BAA6B,CAACC;IACvC,MAAM,EAAEC,EAAE,EAAE,GAAGC,gBAAgBF;IAC/B,IAAIC,GAAG,UAAU,CAACH,gBACd,OAAOG;IAEX,OAAO,GAAGH,gBAAgBG,IAAI;AAClC;AAEO,MAAME,iCAAiC,CAACF,KACpCA,GAAG,OAAO,CAACH,eAAe"}
|
package/domain/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\nexport * from \"./errors.js\";\nexport * from \"./LockRecord.js\";\nexport * from \"./types.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["GetLockRecordFeature"],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\nexport { GetLockRecordFeature } from \"./feature.js\";\n"],"mappings":"AAAA;AACA,SAASA,oBAAoB","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\nexport * from \"./feature.js\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\nexport * from \"./feature.js\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\nexport * from \"./events.js\";\nexport * from \"./feature.js\";\n"],"mappings":"AAAA;AACA;AACA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./abstractions.js\";\n"],"mappings":"AAAA","ignoreList":[]}
|