@webiny/app-record-locking 0.0.0-unstable.06b2ede40f
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/LICENSE +21 -0
- package/README.md +12 -0
- package/components/HeadlessCmsActionsAcoCell.d.ts +2 -0
- package/components/HeadlessCmsActionsAcoCell.js +60 -0
- package/components/HeadlessCmsActionsAcoCell.js.map +1 -0
- package/components/HeadlessCmsContentEntry/ContentEntryGuard.d.ts +9 -0
- package/components/HeadlessCmsContentEntry/ContentEntryGuard.js +40 -0
- package/components/HeadlessCmsContentEntry/ContentEntryGuard.js.map +1 -0
- package/components/HeadlessCmsContentEntry/ContentEntryLocker.d.ts +18 -0
- package/components/HeadlessCmsContentEntry/ContentEntryLocker.js +106 -0
- package/components/HeadlessCmsContentEntry/ContentEntryLocker.js.map +1 -0
- package/components/HeadlessCmsContentEntry/HeadlessCmsContentEntry.d.ts +2 -0
- package/components/HeadlessCmsContentEntry/HeadlessCmsContentEntry.js +90 -0
- package/components/HeadlessCmsContentEntry/HeadlessCmsContentEntry.js.map +1 -0
- package/components/HeadlessCmsContentEntry/index.d.ts +1 -0
- package/components/HeadlessCmsContentEntry/index.js +3 -0
- package/components/HeadlessCmsContentEntry/index.js.map +1 -0
- package/components/LockedRecord/LockedRecord.d.ts +6 -0
- package/components/LockedRecord/LockedRecord.js +66 -0
- package/components/LockedRecord/LockedRecord.js.map +1 -0
- package/components/LockedRecord/LockedRecordForceUnlock.d.ts +9 -0
- package/components/LockedRecord/LockedRecordForceUnlock.js +75 -0
- package/components/LockedRecord/LockedRecordForceUnlock.js.map +1 -0
- package/components/LockedRecord/index.d.ts +1 -0
- package/components/LockedRecord/index.js +3 -0
- package/components/LockedRecord/index.js.map +1 -0
- package/components/RecordLockingProvider.d.ts +7 -0
- package/components/RecordLockingProvider.js +125 -0
- package/components/RecordLockingProvider.js.map +1 -0
- package/components/decorators/UseContentEntriesListHookDecorator.d.ts +2 -0
- package/components/decorators/UseContentEntriesListHookDecorator.js +21 -0
- package/components/decorators/UseContentEntriesListHookDecorator.js.map +1 -0
- package/components/decorators/UseRecordsDecorator.d.ts +9 -0
- package/components/decorators/UseRecordsDecorator.js +25 -0
- package/components/decorators/UseRecordsDecorator.js.map +1 -0
- package/components/decorators/UseSaveEntryDecorator.d.ts +2 -0
- package/components/decorators/UseSaveEntryDecorator.js +55 -0
- package/components/decorators/UseSaveEntryDecorator.js.map +1 -0
- package/components/permissionRenderer/RecordLockingPermissions.d.ts +7 -0
- package/components/permissionRenderer/RecordLockingPermissions.js +71 -0
- package/components/permissionRenderer/RecordLockingPermissions.js.map +1 -0
- package/components/permissionRenderer/index.d.ts +2 -0
- package/components/permissionRenderer/index.js +21 -0
- package/components/permissionRenderer/index.js.map +1 -0
- package/domain/RecordLocking.d.ts +28 -0
- package/domain/RecordLocking.js +320 -0
- package/domain/RecordLocking.js.map +1 -0
- package/domain/RecordLockingClient.d.ts +12 -0
- package/domain/RecordLockingClient.js +19 -0
- package/domain/RecordLockingClient.js.map +1 -0
- package/domain/RecordLockingGetLockRecord.d.ts +11 -0
- package/domain/RecordLockingGetLockRecord.js +21 -0
- package/domain/RecordLockingGetLockRecord.js.map +1 -0
- package/domain/RecordLockingGetLockedEntryLockRecord.d.ts +11 -0
- package/domain/RecordLockingGetLockedEntryLockRecord.js +19 -0
- package/domain/RecordLockingGetLockedEntryLockRecord.js.map +1 -0
- package/domain/RecordLockingIsEntryLocked.d.ts +11 -0
- package/domain/RecordLockingIsEntryLocked.js +19 -0
- package/domain/RecordLockingIsEntryLocked.js.map +1 -0
- package/domain/RecordLockingListLockRecords.d.ts +12 -0
- package/domain/RecordLockingListLockRecords.js +31 -0
- package/domain/RecordLockingListLockRecords.js.map +1 -0
- package/domain/RecordLockingLockEntry.d.ts +11 -0
- package/domain/RecordLockingLockEntry.js +15 -0
- package/domain/RecordLockingLockEntry.js.map +1 -0
- package/domain/RecordLockingUnlockEntry.d.ts +11 -0
- package/domain/RecordLockingUnlockEntry.js +19 -0
- package/domain/RecordLockingUnlockEntry.js.map +1 -0
- package/domain/RecordLockingUpdateEntryLock.d.ts +11 -0
- package/domain/RecordLockingUpdateEntryLock.js +19 -0
- package/domain/RecordLockingUpdateEntryLock.js.map +1 -0
- package/domain/abstractions/IRecordLocking.d.ts +25 -0
- package/domain/abstractions/IRecordLocking.js +3 -0
- package/domain/abstractions/IRecordLocking.js.map +1 -0
- package/domain/abstractions/IRecordLockingClient.d.ts +6 -0
- package/domain/abstractions/IRecordLockingClient.js +3 -0
- package/domain/abstractions/IRecordLockingClient.js.map +1 -0
- package/domain/abstractions/IRecordLockingGetLockRecord.d.ts +12 -0
- package/domain/abstractions/IRecordLockingGetLockRecord.js +3 -0
- package/domain/abstractions/IRecordLockingGetLockRecord.js.map +1 -0
- package/domain/abstractions/IRecordLockingGetLockedEntryLockRecord.d.ts +12 -0
- package/domain/abstractions/IRecordLockingGetLockedEntryLockRecord.js +3 -0
- package/domain/abstractions/IRecordLockingGetLockedEntryLockRecord.js.map +1 -0
- package/domain/abstractions/IRecordLockingIsEntryLocked.d.ts +8 -0
- package/domain/abstractions/IRecordLockingIsEntryLocked.js +3 -0
- package/domain/abstractions/IRecordLockingIsEntryLocked.js.map +1 -0
- package/domain/abstractions/IRecordLockingListLockRecords.d.ts +19 -0
- package/domain/abstractions/IRecordLockingListLockRecords.js +3 -0
- package/domain/abstractions/IRecordLockingListLockRecords.js.map +1 -0
- package/domain/abstractions/IRecordLockingLockEntry.d.ts +12 -0
- package/domain/abstractions/IRecordLockingLockEntry.js +3 -0
- package/domain/abstractions/IRecordLockingLockEntry.js.map +1 -0
- package/domain/abstractions/IRecordLockingUnlockEntry.d.ts +13 -0
- package/domain/abstractions/IRecordLockingUnlockEntry.js +3 -0
- package/domain/abstractions/IRecordLockingUnlockEntry.js.map +1 -0
- package/domain/abstractions/IRecordLockingUpdateEntryLock.d.ts +12 -0
- package/domain/abstractions/IRecordLockingUpdateEntryLock.js +3 -0
- package/domain/abstractions/IRecordLockingUpdateEntryLock.js.map +1 -0
- package/domain/graphql/fields.d.ts +2 -0
- package/domain/graphql/fields.js +30 -0
- package/domain/graphql/fields.js.map +1 -0
- package/domain/graphql/getLockRecord.d.ts +12 -0
- package/domain/graphql/getLockRecord.js +18 -0
- package/domain/graphql/getLockRecord.js.map +1 -0
- package/domain/graphql/getLockedEntryLockRecord.d.ts +12 -0
- package/domain/graphql/getLockedEntryLockRecord.js +18 -0
- package/domain/graphql/getLockedEntryLockRecord.js.map +1 -0
- package/domain/graphql/isEntryLocked.d.ts +12 -0
- package/domain/graphql/isEntryLocked.js +16 -0
- package/domain/graphql/isEntryLocked.js.map +1 -0
- package/domain/graphql/listLockRecords.d.ts +17 -0
- package/domain/graphql/listLockRecords.js +26 -0
- package/domain/graphql/listLockRecords.js.map +1 -0
- package/domain/graphql/lockEntry.d.ts +12 -0
- package/domain/graphql/lockEntry.js +20 -0
- package/domain/graphql/lockEntry.js.map +1 -0
- package/domain/graphql/unlockEntry.d.ts +12 -0
- package/domain/graphql/unlockEntry.js +18 -0
- package/domain/graphql/unlockEntry.js.map +1 -0
- package/domain/graphql/updateEntryLock.d.ts +12 -0
- package/domain/graphql/updateEntryLock.js +18 -0
- package/domain/graphql/updateEntryLock.js.map +1 -0
- package/domain/utils/createRecordLockingClient.d.ts +3 -0
- package/domain/utils/createRecordLockingClient.js +12 -0
- package/domain/utils/createRecordLockingClient.js.map +1 -0
- package/domain/utils/createRecordLockingError.d.ts +6 -0
- package/domain/utils/createRecordLockingError.js +16 -0
- package/domain/utils/createRecordLockingError.js.map +1 -0
- package/hooks/index.d.ts +2 -0
- package/hooks/index.js +4 -0
- package/hooks/index.js.map +1 -0
- package/hooks/usePermission.d.ts +3 -0
- package/hooks/usePermission.js +21 -0
- package/hooks/usePermission.js.map +1 -0
- package/hooks/useRecordLocking.d.ts +2 -0
- package/hooks/useRecordLocking.js +12 -0
- package/hooks/useRecordLocking.js.map +1 -0
- package/index.d.ts +7 -0
- package/index.js +29 -0
- package/index.js.map +1 -0
- package/package.json +52 -0
- package/types.d.ts +75 -0
- package/types.js +3 -0
- package/types.js.map +1 -0
- package/utils/createCacheKey.d.ts +3 -0
- package/utils/createCacheKey.js +15 -0
- package/utils/createCacheKey.js.map +1 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RecordLockingClient } from "../RecordLockingClient";
|
|
2
|
+
import { ApolloClient } from "apollo-client";
|
|
3
|
+
export const createRecordLockingClient = client => {
|
|
4
|
+
if (client instanceof ApolloClient) {
|
|
5
|
+
return new RecordLockingClient({
|
|
6
|
+
client
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
return client;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=createRecordLockingClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["RecordLockingClient","ApolloClient","createRecordLockingClient","client"],"sources":["createRecordLockingClient.ts"],"sourcesContent":["import type { IRecordLockingClient } from \"~/domain/abstractions/IRecordLockingClient\";\nimport { RecordLockingClient } from \"~/domain/RecordLockingClient\";\nimport { ApolloClient } from \"apollo-client\";\n\nexport const createRecordLockingClient = (client: IRecordLockingClient | ApolloClient<any>) => {\n if (client instanceof ApolloClient) {\n return new RecordLockingClient({ client });\n }\n return client;\n};\n"],"mappings":"AACA,SAASA,mBAAmB;AAC5B,SAASC,YAAY,QAAQ,eAAe;AAE5C,OAAO,MAAMC,yBAAyB,GAAIC,MAAgD,IAAK;EAC3F,IAAIA,MAAM,YAAYF,YAAY,EAAE;IAChC,OAAO,IAAID,mBAAmB,CAAC;MAAEG;IAAO,CAAC,CAAC;EAC9C;EACA,OAAOA,MAAM;AACjB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const createRecordLockingError = error => {
|
|
2
|
+
if (error instanceof Error) {
|
|
3
|
+
return {
|
|
4
|
+
message: error.message,
|
|
5
|
+
code: error.code || "UNKNOWN_ERROR",
|
|
6
|
+
data: error.data
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
message: error.message,
|
|
11
|
+
code: error.code,
|
|
12
|
+
data: error.data
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=createRecordLockingError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createRecordLockingError","error","Error","message","code","data"],"sources":["createRecordLockingError.ts"],"sourcesContent":["import type { IRecordLockingError } from \"~/types\";\n\nexport interface IError extends Error {\n code?: string;\n data?: any;\n}\n\nexport const createRecordLockingError = (\n error: IError | IRecordLockingError\n): IRecordLockingError => {\n if (error instanceof Error) {\n return {\n message: error.message,\n code: error.code || \"UNKNOWN_ERROR\",\n data: error.data\n };\n }\n return {\n message: error.message,\n code: error.code,\n data: error.data\n };\n};\n"],"mappings":"AAOA,OAAO,MAAMA,wBAAwB,GACjCC,KAAmC,IACb;EACtB,IAAIA,KAAK,YAAYC,KAAK,EAAE;IACxB,OAAO;MACHC,OAAO,EAAEF,KAAK,CAACE,OAAO;MACtBC,IAAI,EAAEH,KAAK,CAACG,IAAI,IAAI,eAAe;MACnCC,IAAI,EAAEJ,KAAK,CAACI;IAChB,CAAC;EACL;EACA,OAAO;IACHF,OAAO,EAAEF,KAAK,CAACE,OAAO;IACtBC,IAAI,EAAEH,KAAK,CAACG,IAAI;IAChBC,IAAI,EAAEJ,KAAK,CAACI;EAChB,CAAC;AACL,CAAC","ignoreList":[]}
|
package/hooks/index.d.ts
ADDED
package/hooks/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./useRecordLocking\";\nexport * from \"./usePermission\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useSecurity } from "@webiny/app-security";
|
|
3
|
+
export const usePermission = () => {
|
|
4
|
+
const {
|
|
5
|
+
identity,
|
|
6
|
+
getPermission
|
|
7
|
+
} = useSecurity();
|
|
8
|
+
const canForceUnlock = useMemo(() => {
|
|
9
|
+
const hasFullAccess = !!getPermission("recordLocking.*");
|
|
10
|
+
if (hasFullAccess) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
const permission = getPermission("recordLocking");
|
|
14
|
+
return permission?.canForceUnlock === "yes";
|
|
15
|
+
}, [identity?.permissions]);
|
|
16
|
+
return {
|
|
17
|
+
canForceUnlock
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=usePermission.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useMemo","useSecurity","usePermission","identity","getPermission","canForceUnlock","hasFullAccess","permission","permissions"],"sources":["usePermission.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport { useSecurity } from \"@webiny/app-security\";\n\nexport const usePermission = () => {\n const { identity, getPermission } = useSecurity();\n\n const canForceUnlock = useMemo(() => {\n const hasFullAccess = !!getPermission(\"recordLocking.*\");\n if (hasFullAccess) {\n return true;\n }\n const permission = getPermission(\"recordLocking\");\n return permission?.canForceUnlock === \"yes\";\n }, [identity?.permissions]);\n\n return {\n canForceUnlock\n };\n};\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,WAAW,QAAQ,sBAAsB;AAElD,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAM;EAC/B,MAAM;IAAEC,QAAQ;IAAEC;EAAc,CAAC,GAAGH,WAAW,CAAC,CAAC;EAEjD,MAAMI,cAAc,GAAGL,OAAO,CAAC,MAAM;IACjC,MAAMM,aAAa,GAAG,CAAC,CAACF,aAAa,CAAC,iBAAiB,CAAC;IACxD,IAAIE,aAAa,EAAE;MACf,OAAO,IAAI;IACf;IACA,MAAMC,UAAU,GAAGH,aAAa,CAAC,eAAe,CAAC;IACjD,OAAOG,UAAU,EAAEF,cAAc,KAAK,KAAK;EAC/C,CAAC,EAAE,CAACF,QAAQ,EAAEK,WAAW,CAAC,CAAC;EAE3B,OAAO;IACHH;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { WebinyError } from "@webiny/error";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
import { RecordLockingContext } from "../components/RecordLockingProvider";
|
|
4
|
+
export const useRecordLocking = () => {
|
|
5
|
+
const context = useContext(RecordLockingContext);
|
|
6
|
+
if (!context) {
|
|
7
|
+
throw new WebinyError("useRecordLocking must be used within a RecordLockingProvider.");
|
|
8
|
+
}
|
|
9
|
+
return context;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=useRecordLocking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["WebinyError","useContext","RecordLockingContext","useRecordLocking","context"],"sources":["useRecordLocking.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport { useContext } from \"react\";\nimport { RecordLockingContext } from \"~/components/RecordLockingProvider\";\nimport type { IRecordLockingContext, IPossiblyRecordLockingRecord } from \"~/types\";\n\nexport const useRecordLocking = <\n T extends IPossiblyRecordLockingRecord = IPossiblyRecordLockingRecord\n>() => {\n const context = useContext(RecordLockingContext);\n if (!context) {\n throw new WebinyError(\"useRecordLocking must be used within a RecordLockingProvider.\");\n }\n return context as IRecordLockingContext<T>;\n};\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,eAAe;AAC3C,SAASC,UAAU,QAAQ,OAAO;AAClC,SAASC,oBAAoB;AAG7B,OAAO,MAAMC,gBAAgB,GAAGA,CAAA,KAEzB;EACH,MAAMC,OAAO,GAAGH,UAAU,CAACC,oBAAoB,CAAC;EAChD,IAAI,CAACE,OAAO,EAAE;IACV,MAAM,IAAIJ,WAAW,CAAC,+DAA+D,CAAC;EAC1F;EACA,OAAOI,OAAO;AAClB,CAAC","ignoreList":[]}
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Provider } from "@webiny/app";
|
|
3
|
+
import { RecordLockingProvider as RecordLockingProviderComponent } from "./components/RecordLockingProvider";
|
|
4
|
+
import { HeadlessCmsActionsAcoCell } from "./components/HeadlessCmsActionsAcoCell";
|
|
5
|
+
import { HeadlessCmsContentEntry } from "./components/HeadlessCmsContentEntry";
|
|
6
|
+
import { useWcp } from "@webiny/app-wcp";
|
|
7
|
+
import { plugins } from "@webiny/plugins";
|
|
8
|
+
import { recordLockingPermissionRenderer } from "./components/permissionRenderer";
|
|
9
|
+
export * from "./components/RecordLockingProvider";
|
|
10
|
+
export * from "./hooks";
|
|
11
|
+
const RecordLockingHoc = Component => {
|
|
12
|
+
return function RecordLockingProvider({
|
|
13
|
+
children
|
|
14
|
+
}) {
|
|
15
|
+
return /*#__PURE__*/React.createElement(Component, null, /*#__PURE__*/React.createElement(RecordLockingProviderComponent, null, children));
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export const RecordLocking = () => {
|
|
19
|
+
const wcp = useWcp();
|
|
20
|
+
if (!wcp.canUseRecordLocking()) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
plugins.register(recordLockingPermissionRenderer);
|
|
24
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Provider, {
|
|
25
|
+
hoc: RecordLockingHoc
|
|
26
|
+
}), /*#__PURE__*/React.createElement(HeadlessCmsActionsAcoCell, null), /*#__PURE__*/React.createElement(HeadlessCmsContentEntry, null));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","Provider","RecordLockingProvider","RecordLockingProviderComponent","HeadlessCmsActionsAcoCell","HeadlessCmsContentEntry","useWcp","plugins","recordLockingPermissionRenderer","RecordLockingHoc","Component","children","createElement","RecordLocking","wcp","canUseRecordLocking","register","Fragment","hoc"],"sources":["index.tsx"],"sourcesContent":["import React from \"react\";\nimport { Provider } from \"@webiny/app\";\nimport { RecordLockingProvider as RecordLockingProviderComponent } from \"~/components/RecordLockingProvider\";\nimport { HeadlessCmsActionsAcoCell } from \"~/components/HeadlessCmsActionsAcoCell\";\nimport { HeadlessCmsContentEntry } from \"~/components/HeadlessCmsContentEntry\";\nimport { useWcp } from \"@webiny/app-wcp\";\nimport { plugins } from \"@webiny/plugins\";\nimport { recordLockingPermissionRenderer } from \"~/components/permissionRenderer\";\n\nexport * from \"~/components/RecordLockingProvider\";\nexport * from \"~/hooks\";\n\nexport interface RecordLockingProviderProps {\n children: React.ReactNode;\n}\n\nconst RecordLockingHoc = (Component: React.ComponentType<RecordLockingProviderProps>) => {\n return function RecordLockingProvider({ children }: RecordLockingProviderProps) {\n return (\n <Component>\n <RecordLockingProviderComponent>{children}</RecordLockingProviderComponent>\n </Component>\n );\n };\n};\n\nexport const RecordLocking = () => {\n const wcp = useWcp();\n\n if (!wcp.canUseRecordLocking()) {\n return null;\n }\n plugins.register(recordLockingPermissionRenderer);\n\n return (\n <>\n <Provider hoc={RecordLockingHoc} />\n <HeadlessCmsActionsAcoCell />\n <HeadlessCmsContentEntry />\n </>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,QAAQ,aAAa;AACtC,SAASC,qBAAqB,IAAIC,8BAA8B;AAChE,SAASC,yBAAyB;AAClC,SAASC,uBAAuB;AAChC,SAASC,MAAM,QAAQ,iBAAiB;AACxC,SAASC,OAAO,QAAQ,iBAAiB;AACzC,SAASC,+BAA+B;AAExC;AACA;AAMA,MAAMC,gBAAgB,GAAIC,SAA0D,IAAK;EACrF,OAAO,SAASR,qBAAqBA,CAAC;IAAES;EAAqC,CAAC,EAAE;IAC5E,oBACIX,KAAA,CAAAY,aAAA,CAACF,SAAS,qBACNV,KAAA,CAAAY,aAAA,CAACT,8BAA8B,QAAEQ,QAAyC,CACnE,CAAC;EAEpB,CAAC;AACL,CAAC;AAED,OAAO,MAAME,aAAa,GAAGA,CAAA,KAAM;EAC/B,MAAMC,GAAG,GAAGR,MAAM,CAAC,CAAC;EAEpB,IAAI,CAACQ,GAAG,CAACC,mBAAmB,CAAC,CAAC,EAAE;IAC5B,OAAO,IAAI;EACf;EACAR,OAAO,CAACS,QAAQ,CAACR,+BAA+B,CAAC;EAEjD,oBACIR,KAAA,CAAAY,aAAA,CAAAZ,KAAA,CAAAiB,QAAA,qBACIjB,KAAA,CAAAY,aAAA,CAACX,QAAQ;IAACiB,GAAG,EAAET;EAAiB,CAAE,CAAC,eACnCT,KAAA,CAAAY,aAAA,CAACR,yBAAyB,MAAE,CAAC,eAC7BJ,KAAA,CAAAY,aAAA,CAACP,uBAAuB,MAAE,CAC5B,CAAC;AAEX,CAAC","ignoreList":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webiny/app-record-locking",
|
|
3
|
+
"version": "0.0.0-unstable.06b2ede40f",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/webiny/webiny-js.git"
|
|
8
|
+
},
|
|
9
|
+
"contributors": [
|
|
10
|
+
"Pavel Denisjuk <pavel@webiny.com>",
|
|
11
|
+
"Sven Al Hamad <sven@webiny.com>",
|
|
12
|
+
"Adrian Smijulj <adrian@webiny.com>"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@apollo/react-hooks": "3.1.5",
|
|
17
|
+
"@webiny/admin-ui": "0.0.0-unstable.06b2ede40f",
|
|
18
|
+
"@webiny/app": "0.0.0-unstable.06b2ede40f",
|
|
19
|
+
"@webiny/app-aco": "0.0.0-unstable.06b2ede40f",
|
|
20
|
+
"@webiny/app-admin": "0.0.0-unstable.06b2ede40f",
|
|
21
|
+
"@webiny/app-headless-cms": "0.0.0-unstable.06b2ede40f",
|
|
22
|
+
"@webiny/app-security": "0.0.0-unstable.06b2ede40f",
|
|
23
|
+
"@webiny/app-wcp": "0.0.0-unstable.06b2ede40f",
|
|
24
|
+
"@webiny/app-websockets": "0.0.0-unstable.06b2ede40f",
|
|
25
|
+
"@webiny/error": "0.0.0-unstable.06b2ede40f",
|
|
26
|
+
"@webiny/form": "0.0.0-unstable.06b2ede40f",
|
|
27
|
+
"@webiny/icons": "0.0.0-unstable.06b2ede40f",
|
|
28
|
+
"@webiny/plugins": "0.0.0-unstable.06b2ede40f",
|
|
29
|
+
"@webiny/react-router": "0.0.0-unstable.06b2ede40f",
|
|
30
|
+
"@webiny/utils": "0.0.0-unstable.06b2ede40f",
|
|
31
|
+
"apollo-client": "2.6.10",
|
|
32
|
+
"apollo-link": "1.2.14",
|
|
33
|
+
"crypto-hash": "3.0.0",
|
|
34
|
+
"graphql-tag": "2.12.6",
|
|
35
|
+
"react": "18.2.0",
|
|
36
|
+
"react-dom": "18.2.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@webiny/project-utils": "0.0.0-unstable.06b2ede40f",
|
|
40
|
+
"rimraf": "6.0.1",
|
|
41
|
+
"typescript": "5.3.3"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public",
|
|
45
|
+
"directory": "dist"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "node ../cli/bin.js run build",
|
|
49
|
+
"watch": "node ../cli/bin.js run watch"
|
|
50
|
+
},
|
|
51
|
+
"gitHead": "06b2ede40fc2212a70eeafd74afd50b56fb0ce82"
|
|
52
|
+
}
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { CmsContentEntry } from "@webiny/app-headless-cms/types";
|
|
2
|
+
import type { GenericRecord } from "@webiny/app/types";
|
|
3
|
+
import type { IRecordLockingUnlockEntryResult } from "./domain/abstractions/IRecordLockingUnlockEntry";
|
|
4
|
+
import type { SecurityPermission } from "@webiny/app-security/types";
|
|
5
|
+
import type { IRecordLockingUpdateEntryLockResult } from "./domain/abstractions/IRecordLocking.js";
|
|
6
|
+
export interface IRecordLockingIdentity {
|
|
7
|
+
id: string;
|
|
8
|
+
displayName: string;
|
|
9
|
+
type: string;
|
|
10
|
+
}
|
|
11
|
+
export interface IRecordLockingRecordLocked {
|
|
12
|
+
lockedBy: IRecordLockingIdentity;
|
|
13
|
+
lockedOn: string;
|
|
14
|
+
expiresOn: string;
|
|
15
|
+
actions: IRecordLockingLockRecordAction[];
|
|
16
|
+
}
|
|
17
|
+
export interface IPossiblyRecordLockingRecord extends CmsContentEntry {
|
|
18
|
+
$lockingType?: string;
|
|
19
|
+
$locked?: IRecordLockingRecordLocked | null;
|
|
20
|
+
}
|
|
21
|
+
export interface IRecordLockingRecord extends IPossiblyRecordLockingRecord {
|
|
22
|
+
$lockingType: string;
|
|
23
|
+
}
|
|
24
|
+
export type IIsRecordLockedParams = Pick<IRecordLockingRecord, "id" | "$lockingType">;
|
|
25
|
+
export type IUpdateEntryLockParams = Pick<IRecordLockingRecord, "id" | "$lockingType">;
|
|
26
|
+
export type IUnlockEntryParams = Pick<IRecordLockingRecord, "id" | "$lockingType">;
|
|
27
|
+
export type IFetchLockRecordParams = Pick<IRecordLockingRecord, "id" | "$lockingType">;
|
|
28
|
+
export type IFetchLockedEntryLockRecordParams = Pick<IRecordLockingRecord, "id" | "$lockingType">;
|
|
29
|
+
export interface IFetchLockRecordResult {
|
|
30
|
+
data: IRecordLockingLockRecord | null;
|
|
31
|
+
error: IRecordLockingError | null;
|
|
32
|
+
}
|
|
33
|
+
export interface IRecordLockingContext<T extends IPossiblyRecordLockingRecord = IPossiblyRecordLockingRecord> {
|
|
34
|
+
readonly loading: boolean;
|
|
35
|
+
readonly records: IPossiblyRecordLockingRecord[];
|
|
36
|
+
readonly error?: IRecordLockingError | null;
|
|
37
|
+
setRecords(folderId: string, type: string, records: T[]): Promise<void>;
|
|
38
|
+
updateEntryLock(params: IUpdateEntryLockParams): Promise<IRecordLockingUpdateEntryLockResult>;
|
|
39
|
+
isRecordLocked(params?: IIsRecordLockedParams): boolean;
|
|
40
|
+
getLockRecordEntry(id: string): IRecordLockingRecord | undefined;
|
|
41
|
+
fetchLockRecord(params: IFetchLockRecordParams): Promise<IFetchLockRecordResult>;
|
|
42
|
+
fetchLockedEntryLockRecord(params: IFetchLockedEntryLockRecordParams): Promise<IRecordLockingLockRecord | null>;
|
|
43
|
+
unlockEntry(params: IUnlockEntryParams): Promise<IRecordLockingUnlockEntryResult>;
|
|
44
|
+
removeEntryLock(params: IUnlockEntryParams): void;
|
|
45
|
+
unlockEntryForce(params: IUnlockEntryParams): Promise<IRecordLockingUnlockEntryResult>;
|
|
46
|
+
isLockExpired(input: Date | string): boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface IRecordLockingLockRecordAction {
|
|
49
|
+
type: string;
|
|
50
|
+
message: string;
|
|
51
|
+
createdBy: IRecordLockingIdentity;
|
|
52
|
+
createdOn: string;
|
|
53
|
+
}
|
|
54
|
+
export interface IRecordLockingLockRecord {
|
|
55
|
+
id: string;
|
|
56
|
+
lockedOn: string;
|
|
57
|
+
expiresOn: string;
|
|
58
|
+
lockedBy: IRecordLockingIdentity;
|
|
59
|
+
targetId: string;
|
|
60
|
+
type: string;
|
|
61
|
+
actions: IRecordLockingLockRecordAction[];
|
|
62
|
+
}
|
|
63
|
+
export interface IRecordLockingMeta {
|
|
64
|
+
totalCount: number;
|
|
65
|
+
cursor: string | null;
|
|
66
|
+
hasMoreItems: boolean;
|
|
67
|
+
}
|
|
68
|
+
export interface IRecordLockingError<T = GenericRecord> {
|
|
69
|
+
message: string;
|
|
70
|
+
code: string;
|
|
71
|
+
data?: T;
|
|
72
|
+
}
|
|
73
|
+
export interface RecordLockingSecurityPermission extends SecurityPermission {
|
|
74
|
+
canForceUnlock?: string;
|
|
75
|
+
}
|
package/types.js
ADDED
package/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { CmsContentEntry } from \"@webiny/app-headless-cms/types\";\nimport type { GenericRecord } from \"@webiny/app/types\";\nimport type { IRecordLockingUnlockEntryResult } from \"~/domain/abstractions/IRecordLockingUnlockEntry\";\nimport type { SecurityPermission } from \"@webiny/app-security/types\";\nimport type { IRecordLockingUpdateEntryLockResult } from \"~/domain/abstractions/IRecordLocking.js\";\n\nexport interface IRecordLockingIdentity {\n id: string;\n displayName: string;\n type: string;\n}\n\nexport interface IRecordLockingRecordLocked {\n lockedBy: IRecordLockingIdentity;\n lockedOn: string;\n expiresOn: string;\n actions: IRecordLockingLockRecordAction[];\n}\n\nexport interface IPossiblyRecordLockingRecord extends CmsContentEntry {\n $lockingType?: string;\n $locked?: IRecordLockingRecordLocked | null;\n}\n\nexport interface IRecordLockingRecord extends IPossiblyRecordLockingRecord {\n $lockingType: string;\n}\n\nexport type IIsRecordLockedParams = Pick<IRecordLockingRecord, \"id\" | \"$lockingType\">;\n\nexport type IUpdateEntryLockParams = Pick<IRecordLockingRecord, \"id\" | \"$lockingType\">;\n\nexport type IUnlockEntryParams = Pick<IRecordLockingRecord, \"id\" | \"$lockingType\">;\n\nexport type IFetchLockRecordParams = Pick<IRecordLockingRecord, \"id\" | \"$lockingType\">;\n\nexport type IFetchLockedEntryLockRecordParams = Pick<IRecordLockingRecord, \"id\" | \"$lockingType\">;\n\nexport interface IFetchLockRecordResult {\n data: IRecordLockingLockRecord | null;\n error: IRecordLockingError | null;\n}\n\nexport interface IRecordLockingContext<\n T extends IPossiblyRecordLockingRecord = IPossiblyRecordLockingRecord\n> {\n readonly loading: boolean;\n readonly records: IPossiblyRecordLockingRecord[];\n readonly error?: IRecordLockingError | null;\n setRecords(folderId: string, type: string, records: T[]): Promise<void>;\n updateEntryLock(params: IUpdateEntryLockParams): Promise<IRecordLockingUpdateEntryLockResult>;\n isRecordLocked(params?: IIsRecordLockedParams): boolean;\n getLockRecordEntry(id: string): IRecordLockingRecord | undefined;\n fetchLockRecord(params: IFetchLockRecordParams): Promise<IFetchLockRecordResult>;\n fetchLockedEntryLockRecord(\n params: IFetchLockedEntryLockRecordParams\n ): Promise<IRecordLockingLockRecord | null>;\n unlockEntry(params: IUnlockEntryParams): Promise<IRecordLockingUnlockEntryResult>;\n removeEntryLock(params: IUnlockEntryParams): void;\n unlockEntryForce(params: IUnlockEntryParams): Promise<IRecordLockingUnlockEntryResult>;\n isLockExpired(input: Date | string): boolean;\n}\n\nexport interface IRecordLockingLockRecordAction {\n type: string;\n message: string;\n createdBy: IRecordLockingIdentity;\n createdOn: string;\n}\n\nexport interface IRecordLockingLockRecord {\n id: string;\n lockedOn: string;\n expiresOn: string;\n lockedBy: IRecordLockingIdentity;\n targetId: string;\n type: string;\n actions: IRecordLockingLockRecordAction[];\n}\n\nexport interface IRecordLockingMeta {\n totalCount: number;\n cursor: string | null;\n hasMoreItems: boolean;\n}\n\nexport interface IRecordLockingError<T = GenericRecord> {\n message: string;\n code: string;\n data?: T;\n}\n\nexport interface RecordLockingSecurityPermission extends SecurityPermission {\n canForceUnlock?: string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { sha1 } from "crypto-hash";
|
|
2
|
+
const createKey = input => {
|
|
3
|
+
if (typeof input === "string") {
|
|
4
|
+
return input;
|
|
5
|
+
}
|
|
6
|
+
return JSON.stringify(input);
|
|
7
|
+
};
|
|
8
|
+
export const createCacheKey = input => {
|
|
9
|
+
const key = createKey(input);
|
|
10
|
+
return sha1(key, {
|
|
11
|
+
outputFormat: "hex"
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=createCacheKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["sha1","createKey","input","JSON","stringify","createCacheKey","key","outputFormat"],"sources":["createCacheKey.ts"],"sourcesContent":["import type { GenericRecord } from \"@webiny/app/types\";\nimport { sha1 } from \"crypto-hash\";\n\nexport type ICreateCacheKeyInput = string | GenericRecord | ICreateCacheKeyInput[];\n\nconst createKey = (input: ICreateCacheKeyInput): string => {\n if (typeof input === \"string\") {\n return input;\n }\n return JSON.stringify(input);\n};\n\nexport const createCacheKey = (input: ICreateCacheKeyInput): Promise<string> => {\n const key = createKey(input);\n\n return sha1(key, {\n outputFormat: \"hex\"\n });\n};\n"],"mappings":"AACA,SAASA,IAAI,QAAQ,aAAa;AAIlC,MAAMC,SAAS,GAAIC,KAA2B,IAAa;EACvD,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB;EACA,OAAOC,IAAI,CAACC,SAAS,CAACF,KAAK,CAAC;AAChC,CAAC;AAED,OAAO,MAAMG,cAAc,GAAIH,KAA2B,IAAsB;EAC5E,MAAMI,GAAG,GAAGL,SAAS,CAACC,KAAK,CAAC;EAE5B,OAAOF,IAAI,CAACM,GAAG,EAAE;IACbC,YAAY,EAAE;EAClB,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|