@focus-reactive/payload-plugin-comments 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/dist/api/mutations/useAddCommentMutation.d.ts +18 -0
  2. package/dist/api/mutations/useAddCommentMutation.d.ts.map +1 -0
  3. package/dist/api/mutations/useAddCommentMutation.js +52 -0
  4. package/dist/api/mutations/useAddCommentMutation.js.map +1 -0
  5. package/dist/api/mutations/useDeleteCommentMutation.d.ts +11 -0
  6. package/dist/api/mutations/useDeleteCommentMutation.d.ts.map +1 -0
  7. package/dist/api/mutations/useDeleteCommentMutation.js +31 -0
  8. package/dist/api/mutations/useDeleteCommentMutation.js.map +1 -0
  9. package/dist/api/mutations/useResolveCommentMutation.d.ts +13 -0
  10. package/dist/api/mutations/useResolveCommentMutation.d.ts.map +1 -0
  11. package/dist/api/mutations/useResolveCommentMutation.js +41 -0
  12. package/dist/api/mutations/useResolveCommentMutation.js.map +1 -0
  13. package/dist/api/queries/useCommentsQuery.d.ts +3 -0
  14. package/dist/api/queries/useCommentsQuery.d.ts.map +1 -0
  15. package/dist/api/queries/useCommentsQuery.js +40 -0
  16. package/dist/api/queries/useCommentsQuery.js.map +1 -0
  17. package/dist/api/queries/useDocumentTitlesQuery.d.ts +3 -0
  18. package/dist/api/queries/useDocumentTitlesQuery.d.ts.map +1 -0
  19. package/dist/api/queries/useDocumentTitlesQuery.js +32 -0
  20. package/dist/api/queries/useDocumentTitlesQuery.js.map +1 -0
  21. package/dist/api/queries/useFieldLabelsQuery.d.ts +3 -0
  22. package/dist/api/queries/useFieldLabelsQuery.d.ts.map +1 -0
  23. package/dist/api/queries/useFieldLabelsQuery.js +23 -0
  24. package/dist/api/queries/useFieldLabelsQuery.js.map +1 -0
  25. package/dist/api/queries/useMentionableUsersQuery.d.ts +2 -0
  26. package/dist/api/queries/useMentionableUsersQuery.d.ts.map +1 -0
  27. package/dist/api/queries/useMentionableUsersQuery.js +25 -0
  28. package/dist/api/queries/useMentionableUsersQuery.js.map +1 -0
  29. package/dist/api/queryKeys.d.ts +23 -0
  30. package/dist/api/queryKeys.d.ts.map +1 -0
  31. package/dist/api/queryKeys.js +40 -0
  32. package/dist/api/queryKeys.js.map +1 -0
  33. package/dist/components/CommentEditor/index.d.ts.map +1 -1
  34. package/dist/components/CommentEditor/index.js +5 -3
  35. package/dist/components/CommentEditor/index.js.map +1 -1
  36. package/dist/components/CommentItem/StrikethoroughOverlay/clamp.d.ts +2 -0
  37. package/dist/components/CommentItem/StrikethoroughOverlay/clamp.d.ts.map +1 -0
  38. package/dist/components/CommentItem/StrikethoroughOverlay/clamp.js +7 -0
  39. package/dist/components/CommentItem/StrikethoroughOverlay/clamp.js.map +1 -0
  40. package/dist/components/CommentItem/StrikethoroughOverlay/index.d.ts +8 -0
  41. package/dist/components/CommentItem/StrikethoroughOverlay/index.d.ts.map +1 -0
  42. package/dist/components/CommentItem/StrikethoroughOverlay/index.js +24 -0
  43. package/dist/components/CommentItem/StrikethoroughOverlay/index.js.map +1 -0
  44. package/dist/components/CommentItem/StrikethoroughOverlay/measureLineRects.d.ts +3 -0
  45. package/dist/components/CommentItem/StrikethoroughOverlay/measureLineRects.d.ts.map +1 -0
  46. package/dist/components/CommentItem/StrikethoroughOverlay/measureLineRects.js +29 -0
  47. package/dist/components/CommentItem/StrikethoroughOverlay/measureLineRects.js.map +1 -0
  48. package/dist/components/CommentItem/StrikethoroughOverlay/useStrikethroughAnimation.d.ts +7 -0
  49. package/dist/components/CommentItem/StrikethoroughOverlay/useStrikethroughAnimation.d.ts.map +1 -0
  50. package/dist/components/CommentItem/StrikethoroughOverlay/useStrikethroughAnimation.js +114 -0
  51. package/dist/components/CommentItem/StrikethoroughOverlay/useStrikethroughAnimation.js.map +1 -0
  52. package/dist/components/CommentItem/index.d.ts.map +1 -1
  53. package/dist/components/CommentItem/index.js +37 -18
  54. package/dist/components/CommentItem/index.js.map +1 -1
  55. package/dist/components/CommentsDrawer/components/Header.d.ts.map +1 -1
  56. package/dist/components/CommentsDrawer/components/Header.js +4 -33
  57. package/dist/components/CommentsDrawer/components/Header.js.map +1 -1
  58. package/dist/components/CommentsHeaderButton/index.js +2 -2
  59. package/dist/components/CommentsHeaderButton/index.js.map +1 -1
  60. package/dist/components/CommentsPanel/components/CollapsibleGroup.d.ts +7 -2
  61. package/dist/components/CommentsPanel/components/CollapsibleGroup.d.ts.map +1 -1
  62. package/dist/components/CommentsPanel/components/CollapsibleGroup.js +7 -2
  63. package/dist/components/CommentsPanel/components/CollapsibleGroup.js.map +1 -1
  64. package/dist/components/CommentsPanel/components/DocumentView.d.ts.map +1 -1
  65. package/dist/components/CommentsPanel/components/DocumentView.js +11 -17
  66. package/dist/components/CommentsPanel/components/DocumentView.js.map +1 -1
  67. package/dist/components/CommentsPanel/components/FieldGroupSection.d.ts.map +1 -1
  68. package/dist/components/CommentsPanel/components/FieldGroupSection.js +44 -22
  69. package/dist/components/CommentsPanel/components/FieldGroupSection.js.map +1 -1
  70. package/dist/components/CommentsPanel/components/GlobalDocumentView.d.ts.map +1 -1
  71. package/dist/components/CommentsPanel/components/GlobalDocumentView.js +3 -9
  72. package/dist/components/CommentsPanel/components/GlobalDocumentView.js.map +1 -1
  73. package/dist/components/CommentsPanel/components/GlobalView.d.ts.map +1 -1
  74. package/dist/components/CommentsPanel/components/GlobalView.js +38 -41
  75. package/dist/components/CommentsPanel/components/GlobalView.js.map +1 -1
  76. package/dist/components/CommentsPanel/hooks/useCollapseState.d.ts +1 -1
  77. package/dist/components/CommentsPanel/hooks/useCollapseState.d.ts.map +1 -1
  78. package/dist/components/CommentsPanel/hooks/useCollapseState.js +4 -1
  79. package/dist/components/CommentsPanel/hooks/useCollapseState.js.map +1 -1
  80. package/dist/components/CommentsPanel/index.d.ts.map +1 -1
  81. package/dist/components/CommentsPanel/index.js +14 -11
  82. package/dist/components/CommentsPanel/index.js.map +1 -1
  83. package/dist/components/FieldCommentLabel/hooks/useFieldBreadcrumb.d.ts +2 -0
  84. package/dist/components/FieldCommentLabel/hooks/useFieldBreadcrumb.d.ts.map +1 -0
  85. package/dist/components/FieldCommentLabel/hooks/useFieldBreadcrumb.js +52 -0
  86. package/dist/components/FieldCommentLabel/hooks/useFieldBreadcrumb.js.map +1 -0
  87. package/dist/components/FieldCommentLabel/index.d.ts.map +1 -1
  88. package/dist/components/FieldCommentLabel/index.js +53 -41
  89. package/dist/components/FieldCommentLabel/index.js.map +1 -1
  90. package/dist/components/FieldCommentLabel/utils/exludeComments.js +2 -2
  91. package/dist/components/FieldCommentLabel/utils/exludeComments.js.map +1 -1
  92. package/dist/constants.d.ts +1 -0
  93. package/dist/constants.d.ts.map +1 -1
  94. package/dist/constants.js +3 -4
  95. package/dist/constants.js.map +1 -1
  96. package/dist/plugin.d.ts.map +1 -1
  97. package/dist/plugin.js +6 -2
  98. package/dist/plugin.js.map +1 -1
  99. package/dist/providers/CommentsDrawerProvider/index.d.ts +8 -0
  100. package/dist/providers/CommentsDrawerProvider/index.d.ts.map +1 -1
  101. package/dist/providers/CommentsDrawerProvider/index.js +22 -6
  102. package/dist/providers/CommentsDrawerProvider/index.js.map +1 -1
  103. package/dist/providers/CommentsProvider/index.d.ts +7 -17
  104. package/dist/providers/CommentsProvider/index.d.ts.map +1 -1
  105. package/dist/providers/CommentsProvider/index.js +105 -196
  106. package/dist/providers/CommentsProvider/index.js.map +1 -1
  107. package/dist/providers/CommentsProviderWrapper/index.d.ts +1 -1
  108. package/dist/providers/CommentsProviderWrapper/index.d.ts.map +1 -1
  109. package/dist/providers/CommentsProviderWrapper/index.js +11 -1
  110. package/dist/providers/CommentsProviderWrapper/index.js.map +1 -1
  111. package/dist/services/findAllComments.d.ts +4 -1
  112. package/dist/services/findAllComments.d.ts.map +1 -1
  113. package/dist/services/findAllComments.js +36 -10
  114. package/dist/services/findAllComments.js.map +1 -1
  115. package/dist/styles.css +1 -1
  116. package/dist/translations/en.d.ts.map +1 -1
  117. package/dist/translations/en.js +3 -7
  118. package/dist/translations/en.js.map +1 -1
  119. package/dist/translations/types.d.ts +2 -6
  120. package/dist/translations/types.d.ts.map +1 -1
  121. package/dist/types/general.d.ts +0 -2
  122. package/dist/types/general.d.ts.map +1 -1
  123. package/dist/types/index.d.ts +3 -2
  124. package/dist/types/index.d.ts.map +1 -1
  125. package/dist/types/query.d.ts +11 -0
  126. package/dist/types/query.d.ts.map +1 -0
  127. package/dist/types/query.js +1 -0
  128. package/dist/types/query.js.map +1 -0
  129. package/dist/utils/query/toQueryContext.d.ts +3 -0
  130. package/dist/utils/query/toQueryContext.d.ts.map +1 -0
  131. package/dist/utils/query/toQueryContext.js +20 -0
  132. package/dist/utils/query/toQueryContext.js.map +1 -0
  133. package/package.json +2 -5
  134. package/dist/components/CommentsPanel/constants.d.ts +0 -3
  135. package/dist/components/CommentsPanel/constants.d.ts.map +0 -1
  136. package/dist/components/CommentsPanel/constants.js +0 -9
  137. package/dist/components/CommentsPanel/constants.js.map +0 -1
  138. package/dist/components/CommentsPanel/utils/filterComments.d.ts +0 -9
  139. package/dist/components/CommentsPanel/utils/filterComments.d.ts.map +0 -1
  140. package/dist/components/CommentsPanel/utils/filterComments.js +0 -17
  141. package/dist/components/CommentsPanel/utils/filterComments.js.map +0 -1
  142. package/dist/components/FieldCommentLabel/AddCommentPopup.d.ts +0 -8
  143. package/dist/components/FieldCommentLabel/AddCommentPopup.d.ts.map +0 -1
  144. package/dist/components/FieldCommentLabel/AddCommentPopup.js +0 -50
  145. package/dist/components/FieldCommentLabel/AddCommentPopup.js.map +0 -1
  146. package/dist/providers/GlobalCommentsLoader/GlobalCommentsHydrator.d.ts +0 -13
  147. package/dist/providers/GlobalCommentsLoader/GlobalCommentsHydrator.d.ts.map +0 -1
  148. package/dist/providers/GlobalCommentsLoader/GlobalCommentsHydrator.js +0 -22
  149. package/dist/providers/GlobalCommentsLoader/GlobalCommentsHydrator.js.map +0 -1
  150. package/dist/providers/GlobalCommentsLoader/index.d.ts +0 -10
  151. package/dist/providers/GlobalCommentsLoader/index.d.ts.map +0 -1
  152. package/dist/providers/GlobalCommentsLoader/index.js +0 -31
  153. package/dist/providers/GlobalCommentsLoader/index.js.map +0 -1
  154. package/dist/services/syncAllCommentsData.d.ts +0 -12
  155. package/dist/services/syncAllCommentsData.d.ts.map +0 -1
  156. package/dist/services/syncAllCommentsData.js +0 -48
  157. package/dist/services/syncAllCommentsData.js.map +0 -1
@@ -1,13 +0,0 @@
1
- import type { EntityLabelsMap, Comment, DocumentTitles, GlobalFieldLabelRegistry, User } from "../../types";
2
- interface Props {
3
- comments: Comment[];
4
- documentTitles: DocumentTitles;
5
- mentionUsers: User[];
6
- fieldLabels: GlobalFieldLabelRegistry;
7
- collectionLabels: EntityLabelsMap;
8
- globalLabels: EntityLabelsMap;
9
- loadError: boolean;
10
- }
11
- export declare function GlobalCommentsHydrator({ comments, documentTitles, mentionUsers, fieldLabels, collectionLabels, globalLabels, loadError, }: Props): null;
12
- export {};
13
- //# sourceMappingURL=GlobalCommentsHydrator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GlobalCommentsHydrator.d.ts","sourceRoot":"","sources":["../../../src/providers/GlobalCommentsLoader/GlobalCommentsHydrator.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAE5G,UAAU,KAAK;IACb,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,cAAc,EAAE,cAAc,CAAC;IAC/B,YAAY,EAAE,IAAI,EAAE,CAAC;IACrB,WAAW,EAAE,wBAAwB,CAAC;IACtC,gBAAgB,EAAE,eAAe,CAAC;IAClC,YAAY,EAAE,eAAe,CAAC;IAC9B,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,sBAAsB,CAAC,EACrC,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,SAAS,GACV,EAAE,KAAK,QAQP"}
@@ -1,22 +0,0 @@
1
- "use client";
2
- import { useEffect } from "react";
3
- import { useComments } from "../CommentsProvider";
4
- function GlobalCommentsHydrator({
5
- comments,
6
- documentTitles,
7
- mentionUsers,
8
- fieldLabels,
9
- collectionLabels,
10
- globalLabels,
11
- loadError
12
- }) {
13
- const { hydrateComments } = useComments();
14
- useEffect(() => {
15
- hydrateComments(comments, documentTitles, mentionUsers, fieldLabels, collectionLabels, loadError, globalLabels);
16
- }, [comments, documentTitles, mentionUsers, fieldLabels, collectionLabels, loadError, globalLabels, hydrateComments]);
17
- return null;
18
- }
19
- export {
20
- GlobalCommentsHydrator
21
- };
22
- //# sourceMappingURL=GlobalCommentsHydrator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/providers/GlobalCommentsLoader/GlobalCommentsHydrator.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect } from \"react\";\nimport { useComments } from \"../CommentsProvider\";\nimport type { EntityLabelsMap, Comment, DocumentTitles, GlobalFieldLabelRegistry, User } from \"../../types\";\n\ninterface Props {\n comments: Comment[];\n documentTitles: DocumentTitles;\n mentionUsers: User[];\n fieldLabels: GlobalFieldLabelRegistry;\n collectionLabels: EntityLabelsMap;\n globalLabels: EntityLabelsMap;\n loadError: boolean;\n}\n\nexport function GlobalCommentsHydrator({\n comments,\n documentTitles,\n mentionUsers,\n fieldLabels,\n collectionLabels,\n globalLabels,\n loadError,\n}: Props) {\n const { hydrateComments } = useComments();\n\n useEffect(() => {\n hydrateComments(comments, documentTitles, mentionUsers, fieldLabels, collectionLabels, loadError, globalLabels);\n }, [comments, documentTitles, mentionUsers, fieldLabels, collectionLabels, loadError, globalLabels, hydrateComments]);\n\n return null;\n}\n"],"mappings":";AAEA,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAarB,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAU;AACR,QAAM,EAAE,gBAAgB,IAAI,YAAY;AAExC,YAAU,MAAM;AACd,oBAAgB,UAAU,gBAAgB,cAAc,aAAa,kBAAkB,WAAW,YAAY;AAAA,EAChH,GAAG,CAAC,UAAU,gBAAgB,cAAc,aAAa,kBAAkB,WAAW,cAAc,eAAe,CAAC;AAEpH,SAAO;AACT;","names":[]}
@@ -1,10 +0,0 @@
1
- import type { Payload } from "payload";
2
- import type { ReactNode } from "react";
3
- interface Props {
4
- children: ReactNode;
5
- payload: Payload;
6
- locale?: string;
7
- }
8
- export declare function GlobalCommentsLoader({ children, payload, locale }: Props): Promise<string | number | bigint | boolean | Iterable<ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined>;
9
- export {};
10
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/GlobalCommentsLoader/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,UAAU,KAAK;IACb,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAsB,oBAAoB,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,kIA0B9E"}
@@ -1,31 +0,0 @@
1
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import { setPayloadConfig } from "../../config";
3
- import { GlobalCommentsHydrator } from "./GlobalCommentsHydrator";
4
- import { syncAllCommentsData } from "../../services/syncAllCommentsData";
5
- async function GlobalCommentsLoader({ children, payload, locale }) {
6
- setPayloadConfig(payload.config);
7
- const res = await syncAllCommentsData({ payload, locale });
8
- if (res.success) {
9
- const { comments, documentTitles, mentionUsers, fieldLabels, collectionLabels, globalLabels } = res.data;
10
- return /* @__PURE__ */ jsxs(Fragment, { children: [
11
- /* @__PURE__ */ jsx(
12
- GlobalCommentsHydrator,
13
- {
14
- comments,
15
- documentTitles,
16
- mentionUsers,
17
- fieldLabels,
18
- collectionLabels,
19
- globalLabels,
20
- loadError: false
21
- }
22
- ),
23
- children
24
- ] });
25
- }
26
- return children;
27
- }
28
- export {
29
- GlobalCommentsLoader
30
- };
31
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/providers/GlobalCommentsLoader/index.tsx"],"sourcesContent":["import { setPayloadConfig } from \"../../config\";\nimport { GlobalCommentsHydrator } from \"./GlobalCommentsHydrator\";\nimport type { Payload } from \"payload\";\nimport type { ReactNode } from \"react\";\nimport { syncAllCommentsData } from \"../../services/syncAllCommentsData\";\n\ninterface Props {\n children: ReactNode;\n payload: Payload;\n locale?: string;\n}\n\nexport async function GlobalCommentsLoader({ children, payload, locale }: Props) {\n setPayloadConfig(payload.config);\n\n const res = await syncAllCommentsData({ payload, locale });\n\n if (res.success) {\n const { comments, documentTitles, mentionUsers, fieldLabels, collectionLabels, globalLabels } = res.data;\n\n return (\n <>\n <GlobalCommentsHydrator\n comments={comments}\n documentTitles={documentTitles}\n mentionUsers={mentionUsers}\n fieldLabels={fieldLabels}\n collectionLabels={collectionLabels}\n globalLabels={globalLabels}\n loadError={false}\n />\n\n {children}\n </>\n );\n }\n\n return children;\n}\n"],"mappings":"AAqBM,mBACE,KADF;AArBN,SAAS,wBAAwB;AACjC,SAAS,8BAA8B;AAGvC,SAAS,2BAA2B;AAQpC,eAAsB,qBAAqB,EAAE,UAAU,SAAS,OAAO,GAAU;AAC/E,mBAAiB,QAAQ,MAAM;AAE/B,QAAM,MAAM,MAAM,oBAAoB,EAAE,SAAS,OAAO,CAAC;AAEzD,MAAI,IAAI,SAAS;AACf,UAAM,EAAE,UAAU,gBAAgB,cAAc,aAAa,kBAAkB,aAAa,IAAI,IAAI;AAEpG,WACE,iCACE;AAAA;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,WAAW;AAAA;AAAA,MACb;AAAA,MAEC;AAAA,OACH;AAAA,EAEJ;AAEA,SAAO;AACT;","names":[]}
@@ -1,12 +0,0 @@
1
- import type { BaseServiceOptions, EntityLabelsMap, Comment, DocumentTitles, GlobalFieldLabelRegistry, Response, User } from "../types";
2
- interface SyncResult {
3
- comments: Comment[];
4
- documentTitles: DocumentTitles;
5
- mentionUsers: User[];
6
- fieldLabels: GlobalFieldLabelRegistry;
7
- collectionLabels: EntityLabelsMap;
8
- globalLabels: EntityLabelsMap;
9
- }
10
- export declare function syncAllCommentsData(options?: BaseServiceOptions): Promise<Response<SyncResult>>;
11
- export {};
12
- //# sourceMappingURL=syncAllCommentsData.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"syncAllCommentsData.d.ts","sourceRoot":"","sources":["../../src/services/syncAllCommentsData.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,kBAAkB,EAClB,eAAe,EACf,OAAO,EAEP,cAAc,EACd,wBAAwB,EACxB,QAAQ,EACR,IAAI,EACL,MAAM,UAAU,CAAC;AAGlB,UAAU,UAAU;IAClB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,cAAc,EAAE,cAAc,CAAC;IAC/B,YAAY,EAAE,IAAI,EAAE,CAAC;IACrB,WAAW,EAAE,wBAAwB,CAAC;IACtC,gBAAgB,EAAE,eAAe,CAAC;IAClC,YAAY,EAAE,eAAe,CAAC;CAC/B;AAOD,wBAAsB,mBAAmB,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAwCrG"}
@@ -1,48 +0,0 @@
1
- "use server";
2
- import { findAllComments } from "./findAllComments";
3
- import { getDocumentTitles } from "./getDocumentTitles";
4
- import { fetchMentionableUsers } from "./fetchMentionableUsers";
5
- import { fetchFieldLabels } from "./fieldLabels/fetchFieldLabels";
6
- import { getEntitiesLabels } from "./getEntitiesLabels";
7
- import { extractPayload } from "../utils/payload/extractPayload";
8
- const errorResult = {
9
- success: false,
10
- error: "Failed to sync all comments data"
11
- };
12
- async function syncAllCommentsData(options) {
13
- const payload = await extractPayload(options?.payload);
14
- const pluginConfig = payload.config.admin?.custom?.commentsPlugin;
15
- const commentsResult = await findAllComments({
16
- enabledCollections: pluginConfig?.collections,
17
- enabledGlobals: pluginConfig?.globals,
18
- options: {
19
- payload
20
- }
21
- });
22
- if (!commentsResult.success) return errorResult;
23
- const comments = commentsResult.data;
24
- const [titlesResult, mentionUsersResult, fieldLabels] = await Promise.all([
25
- getDocumentTitles(comments, pluginConfig?.documentTitleFields ?? {}, { payload, locale: options?.locale }),
26
- fetchMentionableUsers({ payload }),
27
- fetchFieldLabels(comments)
28
- ]);
29
- const success = titlesResult.success && mentionUsersResult.success;
30
- if (!success) return errorResult;
31
- const collectionLabels = getEntitiesLabels(payload.config.collections, pluginConfig?.collections ?? []);
32
- const globalLabels = getEntitiesLabels(payload.config.globals, pluginConfig?.globals ?? []);
33
- return {
34
- success: true,
35
- data: {
36
- comments,
37
- documentTitles: titlesResult.data,
38
- mentionUsers: mentionUsersResult.data,
39
- fieldLabels,
40
- collectionLabels,
41
- globalLabels
42
- }
43
- };
44
- }
45
- export {
46
- syncAllCommentsData
47
- };
48
- //# sourceMappingURL=syncAllCommentsData.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/services/syncAllCommentsData.ts"],"sourcesContent":["\"use server\";\n\nimport { findAllComments } from \"./findAllComments\";\nimport { getDocumentTitles } from \"./getDocumentTitles\";\nimport { fetchMentionableUsers } from \"./fetchMentionableUsers\";\nimport { fetchFieldLabels } from \"./fieldLabels/fetchFieldLabels\";\nimport { getEntitiesLabels } from \"./getEntitiesLabels\";\nimport type {\n BaseServiceOptions,\n EntityLabelsMap,\n Comment,\n CommentsPluginConfigStorage,\n DocumentTitles,\n GlobalFieldLabelRegistry,\n Response,\n User,\n} from \"../types\";\nimport { extractPayload } from \"../utils/payload/extractPayload\";\n\ninterface SyncResult {\n comments: Comment[];\n documentTitles: DocumentTitles;\n mentionUsers: User[];\n fieldLabels: GlobalFieldLabelRegistry;\n collectionLabels: EntityLabelsMap;\n globalLabels: EntityLabelsMap;\n}\n\nconst errorResult: Response<SyncResult> = {\n success: false,\n error: \"Failed to sync all comments data\",\n};\n\nexport async function syncAllCommentsData(options?: BaseServiceOptions): Promise<Response<SyncResult>> {\n const payload = await extractPayload(options?.payload);\n const pluginConfig = payload.config.admin?.custom?.commentsPlugin as CommentsPluginConfigStorage | undefined;\n\n const commentsResult = await findAllComments({\n enabledCollections: pluginConfig?.collections,\n enabledGlobals: pluginConfig?.globals,\n options: {\n payload,\n },\n });\n\n if (!commentsResult.success) return errorResult;\n\n const comments = commentsResult.data;\n\n const [titlesResult, mentionUsersResult, fieldLabels] = await Promise.all([\n getDocumentTitles(comments, pluginConfig?.documentTitleFields ?? {}, { payload, locale: options?.locale }),\n fetchMentionableUsers({ payload }),\n fetchFieldLabels(comments),\n ]);\n\n const success = titlesResult.success && mentionUsersResult.success;\n\n if (!success) return errorResult;\n\n const collectionLabels = getEntitiesLabels(payload.config.collections, pluginConfig?.collections ?? []);\n const globalLabels = getEntitiesLabels(payload.config.globals, pluginConfig?.globals ?? []);\n\n return {\n success: true,\n data: {\n comments,\n documentTitles: titlesResult.data,\n mentionUsers: mentionUsersResult.data,\n fieldLabels,\n collectionLabels,\n globalLabels,\n },\n };\n}\n"],"mappings":";AAEA,SAAS,uBAAuB;AAChC,SAAS,yBAAyB;AAClC,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAWlC,SAAS,sBAAsB;AAW/B,MAAM,cAAoC;AAAA,EACxC,SAAS;AAAA,EACT,OAAO;AACT;AAEA,eAAsB,oBAAoB,SAA6D;AACrG,QAAM,UAAU,MAAM,eAAe,SAAS,OAAO;AACrD,QAAM,eAAe,QAAQ,OAAO,OAAO,QAAQ;AAEnD,QAAM,iBAAiB,MAAM,gBAAgB;AAAA,IAC3C,oBAAoB,cAAc;AAAA,IAClC,gBAAgB,cAAc;AAAA,IAC9B,SAAS;AAAA,MACP;AAAA,IACF;AAAA,EACF,CAAC;AAED,MAAI,CAAC,eAAe,QAAS,QAAO;AAEpC,QAAM,WAAW,eAAe;AAEhC,QAAM,CAAC,cAAc,oBAAoB,WAAW,IAAI,MAAM,QAAQ,IAAI;AAAA,IACxE,kBAAkB,UAAU,cAAc,uBAAuB,CAAC,GAAG,EAAE,SAAS,QAAQ,SAAS,OAAO,CAAC;AAAA,IACzG,sBAAsB,EAAE,QAAQ,CAAC;AAAA,IACjC,iBAAiB,QAAQ;AAAA,EAC3B,CAAC;AAED,QAAM,UAAU,aAAa,WAAW,mBAAmB;AAE3D,MAAI,CAAC,QAAS,QAAO;AAErB,QAAM,mBAAmB,kBAAkB,QAAQ,OAAO,aAAa,cAAc,eAAe,CAAC,CAAC;AACtG,QAAM,eAAe,kBAAkB,QAAQ,OAAO,SAAS,cAAc,WAAW,CAAC,CAAC;AAE1F,SAAO;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,MACJ;AAAA,MACA,gBAAgB,aAAa;AAAA,MAC7B,cAAc,mBAAmB;AAAA,MACjC;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;","names":[]}