@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.
Files changed (147) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -0
  3. package/components/HeadlessCmsActionsAcoCell.d.ts +2 -0
  4. package/components/HeadlessCmsActionsAcoCell.js +60 -0
  5. package/components/HeadlessCmsActionsAcoCell.js.map +1 -0
  6. package/components/HeadlessCmsContentEntry/ContentEntryGuard.d.ts +9 -0
  7. package/components/HeadlessCmsContentEntry/ContentEntryGuard.js +40 -0
  8. package/components/HeadlessCmsContentEntry/ContentEntryGuard.js.map +1 -0
  9. package/components/HeadlessCmsContentEntry/ContentEntryLocker.d.ts +18 -0
  10. package/components/HeadlessCmsContentEntry/ContentEntryLocker.js +106 -0
  11. package/components/HeadlessCmsContentEntry/ContentEntryLocker.js.map +1 -0
  12. package/components/HeadlessCmsContentEntry/HeadlessCmsContentEntry.d.ts +2 -0
  13. package/components/HeadlessCmsContentEntry/HeadlessCmsContentEntry.js +90 -0
  14. package/components/HeadlessCmsContentEntry/HeadlessCmsContentEntry.js.map +1 -0
  15. package/components/HeadlessCmsContentEntry/index.d.ts +1 -0
  16. package/components/HeadlessCmsContentEntry/index.js +3 -0
  17. package/components/HeadlessCmsContentEntry/index.js.map +1 -0
  18. package/components/LockedRecord/LockedRecord.d.ts +6 -0
  19. package/components/LockedRecord/LockedRecord.js +66 -0
  20. package/components/LockedRecord/LockedRecord.js.map +1 -0
  21. package/components/LockedRecord/LockedRecordForceUnlock.d.ts +9 -0
  22. package/components/LockedRecord/LockedRecordForceUnlock.js +75 -0
  23. package/components/LockedRecord/LockedRecordForceUnlock.js.map +1 -0
  24. package/components/LockedRecord/index.d.ts +1 -0
  25. package/components/LockedRecord/index.js +3 -0
  26. package/components/LockedRecord/index.js.map +1 -0
  27. package/components/RecordLockingProvider.d.ts +7 -0
  28. package/components/RecordLockingProvider.js +125 -0
  29. package/components/RecordLockingProvider.js.map +1 -0
  30. package/components/decorators/UseContentEntriesListHookDecorator.d.ts +2 -0
  31. package/components/decorators/UseContentEntriesListHookDecorator.js +21 -0
  32. package/components/decorators/UseContentEntriesListHookDecorator.js.map +1 -0
  33. package/components/decorators/UseRecordsDecorator.d.ts +9 -0
  34. package/components/decorators/UseRecordsDecorator.js +25 -0
  35. package/components/decorators/UseRecordsDecorator.js.map +1 -0
  36. package/components/decorators/UseSaveEntryDecorator.d.ts +2 -0
  37. package/components/decorators/UseSaveEntryDecorator.js +55 -0
  38. package/components/decorators/UseSaveEntryDecorator.js.map +1 -0
  39. package/components/permissionRenderer/RecordLockingPermissions.d.ts +7 -0
  40. package/components/permissionRenderer/RecordLockingPermissions.js +71 -0
  41. package/components/permissionRenderer/RecordLockingPermissions.js.map +1 -0
  42. package/components/permissionRenderer/index.d.ts +2 -0
  43. package/components/permissionRenderer/index.js +21 -0
  44. package/components/permissionRenderer/index.js.map +1 -0
  45. package/domain/RecordLocking.d.ts +28 -0
  46. package/domain/RecordLocking.js +320 -0
  47. package/domain/RecordLocking.js.map +1 -0
  48. package/domain/RecordLockingClient.d.ts +12 -0
  49. package/domain/RecordLockingClient.js +19 -0
  50. package/domain/RecordLockingClient.js.map +1 -0
  51. package/domain/RecordLockingGetLockRecord.d.ts +11 -0
  52. package/domain/RecordLockingGetLockRecord.js +21 -0
  53. package/domain/RecordLockingGetLockRecord.js.map +1 -0
  54. package/domain/RecordLockingGetLockedEntryLockRecord.d.ts +11 -0
  55. package/domain/RecordLockingGetLockedEntryLockRecord.js +19 -0
  56. package/domain/RecordLockingGetLockedEntryLockRecord.js.map +1 -0
  57. package/domain/RecordLockingIsEntryLocked.d.ts +11 -0
  58. package/domain/RecordLockingIsEntryLocked.js +19 -0
  59. package/domain/RecordLockingIsEntryLocked.js.map +1 -0
  60. package/domain/RecordLockingListLockRecords.d.ts +12 -0
  61. package/domain/RecordLockingListLockRecords.js +31 -0
  62. package/domain/RecordLockingListLockRecords.js.map +1 -0
  63. package/domain/RecordLockingLockEntry.d.ts +11 -0
  64. package/domain/RecordLockingLockEntry.js +15 -0
  65. package/domain/RecordLockingLockEntry.js.map +1 -0
  66. package/domain/RecordLockingUnlockEntry.d.ts +11 -0
  67. package/domain/RecordLockingUnlockEntry.js +19 -0
  68. package/domain/RecordLockingUnlockEntry.js.map +1 -0
  69. package/domain/RecordLockingUpdateEntryLock.d.ts +11 -0
  70. package/domain/RecordLockingUpdateEntryLock.js +19 -0
  71. package/domain/RecordLockingUpdateEntryLock.js.map +1 -0
  72. package/domain/abstractions/IRecordLocking.d.ts +25 -0
  73. package/domain/abstractions/IRecordLocking.js +3 -0
  74. package/domain/abstractions/IRecordLocking.js.map +1 -0
  75. package/domain/abstractions/IRecordLockingClient.d.ts +6 -0
  76. package/domain/abstractions/IRecordLockingClient.js +3 -0
  77. package/domain/abstractions/IRecordLockingClient.js.map +1 -0
  78. package/domain/abstractions/IRecordLockingGetLockRecord.d.ts +12 -0
  79. package/domain/abstractions/IRecordLockingGetLockRecord.js +3 -0
  80. package/domain/abstractions/IRecordLockingGetLockRecord.js.map +1 -0
  81. package/domain/abstractions/IRecordLockingGetLockedEntryLockRecord.d.ts +12 -0
  82. package/domain/abstractions/IRecordLockingGetLockedEntryLockRecord.js +3 -0
  83. package/domain/abstractions/IRecordLockingGetLockedEntryLockRecord.js.map +1 -0
  84. package/domain/abstractions/IRecordLockingIsEntryLocked.d.ts +8 -0
  85. package/domain/abstractions/IRecordLockingIsEntryLocked.js +3 -0
  86. package/domain/abstractions/IRecordLockingIsEntryLocked.js.map +1 -0
  87. package/domain/abstractions/IRecordLockingListLockRecords.d.ts +19 -0
  88. package/domain/abstractions/IRecordLockingListLockRecords.js +3 -0
  89. package/domain/abstractions/IRecordLockingListLockRecords.js.map +1 -0
  90. package/domain/abstractions/IRecordLockingLockEntry.d.ts +12 -0
  91. package/domain/abstractions/IRecordLockingLockEntry.js +3 -0
  92. package/domain/abstractions/IRecordLockingLockEntry.js.map +1 -0
  93. package/domain/abstractions/IRecordLockingUnlockEntry.d.ts +13 -0
  94. package/domain/abstractions/IRecordLockingUnlockEntry.js +3 -0
  95. package/domain/abstractions/IRecordLockingUnlockEntry.js.map +1 -0
  96. package/domain/abstractions/IRecordLockingUpdateEntryLock.d.ts +12 -0
  97. package/domain/abstractions/IRecordLockingUpdateEntryLock.js +3 -0
  98. package/domain/abstractions/IRecordLockingUpdateEntryLock.js.map +1 -0
  99. package/domain/graphql/fields.d.ts +2 -0
  100. package/domain/graphql/fields.js +30 -0
  101. package/domain/graphql/fields.js.map +1 -0
  102. package/domain/graphql/getLockRecord.d.ts +12 -0
  103. package/domain/graphql/getLockRecord.js +18 -0
  104. package/domain/graphql/getLockRecord.js.map +1 -0
  105. package/domain/graphql/getLockedEntryLockRecord.d.ts +12 -0
  106. package/domain/graphql/getLockedEntryLockRecord.js +18 -0
  107. package/domain/graphql/getLockedEntryLockRecord.js.map +1 -0
  108. package/domain/graphql/isEntryLocked.d.ts +12 -0
  109. package/domain/graphql/isEntryLocked.js +16 -0
  110. package/domain/graphql/isEntryLocked.js.map +1 -0
  111. package/domain/graphql/listLockRecords.d.ts +17 -0
  112. package/domain/graphql/listLockRecords.js +26 -0
  113. package/domain/graphql/listLockRecords.js.map +1 -0
  114. package/domain/graphql/lockEntry.d.ts +12 -0
  115. package/domain/graphql/lockEntry.js +20 -0
  116. package/domain/graphql/lockEntry.js.map +1 -0
  117. package/domain/graphql/unlockEntry.d.ts +12 -0
  118. package/domain/graphql/unlockEntry.js +18 -0
  119. package/domain/graphql/unlockEntry.js.map +1 -0
  120. package/domain/graphql/updateEntryLock.d.ts +12 -0
  121. package/domain/graphql/updateEntryLock.js +18 -0
  122. package/domain/graphql/updateEntryLock.js.map +1 -0
  123. package/domain/utils/createRecordLockingClient.d.ts +3 -0
  124. package/domain/utils/createRecordLockingClient.js +12 -0
  125. package/domain/utils/createRecordLockingClient.js.map +1 -0
  126. package/domain/utils/createRecordLockingError.d.ts +6 -0
  127. package/domain/utils/createRecordLockingError.js +16 -0
  128. package/domain/utils/createRecordLockingError.js.map +1 -0
  129. package/hooks/index.d.ts +2 -0
  130. package/hooks/index.js +4 -0
  131. package/hooks/index.js.map +1 -0
  132. package/hooks/usePermission.d.ts +3 -0
  133. package/hooks/usePermission.js +21 -0
  134. package/hooks/usePermission.js.map +1 -0
  135. package/hooks/useRecordLocking.d.ts +2 -0
  136. package/hooks/useRecordLocking.js +12 -0
  137. package/hooks/useRecordLocking.js.map +1 -0
  138. package/index.d.ts +7 -0
  139. package/index.js +29 -0
  140. package/index.js.map +1 -0
  141. package/package.json +52 -0
  142. package/types.d.ts +75 -0
  143. package/types.js +3 -0
  144. package/types.js.map +1 -0
  145. package/utils/createCacheKey.d.ts +3 -0
  146. package/utils/createCacheKey.js +15 -0
  147. package/utils/createCacheKey.js.map +1 -0
@@ -0,0 +1,3 @@
1
+ import type { IRecordLockingClient } from "../abstractions/IRecordLockingClient";
2
+ import { ApolloClient } from "apollo-client";
3
+ export declare const createRecordLockingClient: (client: IRecordLockingClient | ApolloClient<any>) => IRecordLockingClient;
@@ -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,6 @@
1
+ import type { IRecordLockingError } from "../../types";
2
+ export interface IError extends Error {
3
+ code?: string;
4
+ data?: any;
5
+ }
6
+ export declare const createRecordLockingError: (error: IError | IRecordLockingError) => IRecordLockingError;
@@ -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":[]}
@@ -0,0 +1,2 @@
1
+ export * from "./useRecordLocking";
2
+ export * from "./usePermission";
package/hooks/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./useRecordLocking";
2
+ export * from "./usePermission";
3
+
4
+ //# sourceMappingURL=index.js.map
@@ -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,3 @@
1
+ export declare const usePermission: () => {
2
+ canForceUnlock: boolean;
3
+ };
@@ -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,2 @@
1
+ import type { IRecordLockingContext, IPossiblyRecordLockingRecord } from "../types";
2
+ export declare const useRecordLocking: <T extends IPossiblyRecordLockingRecord = IPossiblyRecordLockingRecord>() => IRecordLockingContext<T>;
@@ -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
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ export * from "./components/RecordLockingProvider";
3
+ export * from "./hooks";
4
+ export interface RecordLockingProviderProps {
5
+ children: React.ReactNode;
6
+ }
7
+ export declare const RecordLocking: () => React.JSX.Element | null;
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
@@ -0,0 +1,3 @@
1
+ export {};
2
+
3
+ //# sourceMappingURL=types.js.map
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,3 @@
1
+ import type { GenericRecord } from "@webiny/app/types";
2
+ export type ICreateCacheKeyInput = string | GenericRecord | ICreateCacheKeyInput[];
3
+ export declare const createCacheKey: (input: ICreateCacheKeyInput) => Promise<string>;
@@ -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":[]}