page.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import type {
  2. GroupType,
  3. IGrantedGroup,
  4. IPageHasId,
  5. Nullable,
  6. Origin,
  7. PageGrant,
  8. } from '@growi/core';
  9. import type { ExternalGroupProviderType } from '~/features/external-user-group/interfaces/external-user-group';
  10. import type { IPageOperationProcessData } from './page-operation';
  11. export {
  12. isIPageInfoForEntity,
  13. isIPageInfoForListing,
  14. isIPageInfoForOperation,
  15. } from '@growi/core';
  16. export type IPageForItem = Partial<
  17. IPageHasId & { processData?: IPageOperationProcessData }
  18. >;
  19. export type IPageForTreeItem = Pick<
  20. IPageHasId,
  21. | '_id'
  22. | 'path'
  23. | 'parent'
  24. | 'revision'
  25. | 'descendantCount'
  26. | 'grant'
  27. | 'isEmpty'
  28. | 'wip'
  29. > & {
  30. processData?: IPageOperationProcessData;
  31. };
  32. export const UserGroupPageGrantStatus = {
  33. isGranted: 'isGranted',
  34. notGranted: 'notGranted',
  35. cannotGrant: 'cannotGrant',
  36. };
  37. type UserGroupPageGrantStatus =
  38. (typeof UserGroupPageGrantStatus)[keyof typeof UserGroupPageGrantStatus];
  39. export type UserRelatedGroupsData = {
  40. id: string;
  41. name: string;
  42. type: GroupType;
  43. provider?: ExternalGroupProviderType;
  44. status: UserGroupPageGrantStatus;
  45. };
  46. export type GroupGrantData = {
  47. userRelatedGroups: UserRelatedGroupsData[];
  48. nonUserRelatedGrantedGroups: {
  49. id: string;
  50. name: string;
  51. type: GroupType;
  52. provider?: ExternalGroupProviderType;
  53. }[];
  54. };
  55. // current grant data of page
  56. export type IPageGrantData = {
  57. grant: PageGrant;
  58. groupGrantData?: GroupGrantData;
  59. };
  60. // grant selected by user which is not yet applied
  61. export type IPageSelectedGrant = {
  62. grant: PageGrant;
  63. userRelatedGrantedGroups?: IGrantedGroup[];
  64. };
  65. export type IDeleteSinglePageApiv1Result = {
  66. ok: boolean;
  67. path: string;
  68. isRecursively: Nullable<true>;
  69. isCompletely: Nullable<true>;
  70. };
  71. export type IDeleteManyPageApiv3Result = {
  72. paths: string[];
  73. isRecursively: Nullable<true>;
  74. isCompletely: Nullable<true>;
  75. };
  76. export type IOptionsForUpdate = {
  77. origin?: Origin;
  78. wip?: boolean;
  79. grant?: PageGrant;
  80. userRelatedGrantUserGroupIds?: IGrantedGroup[];
  81. // isSyncRevisionToHackmd?: boolean,
  82. overwriteScopesOfDescendants?: boolean;
  83. };
  84. export type IOptionsForCreate = {
  85. grant?: PageGrant;
  86. grantUserGroupIds?: IGrantedGroup[];
  87. onlyInheritUserRelatedGrantedGroups?: boolean;
  88. overwriteScopesOfDescendants?: boolean;
  89. origin?: Origin;
  90. wip?: boolean;
  91. };
  92. export type IPagePathWithDescendantCount = {
  93. path: string;
  94. descendantCount: number;
  95. };