{"version":3,"file":"page.cjs","sources":["../../src/interfaces/page.ts"],"sourcesContent":["import type { Ref } from './common';\nimport type { HasObjectId } from './has-object-id';\nimport type {\n  HasRevisionShortbody,\n  IRevision,\n  IRevisionHasId,\n} from './revision';\nimport type { SubscriptionStatusType } from './subscription';\nimport type { ITag } from './tag';\nimport type { IUser, IUserGroup, IUserGroupHasId, IUserHasId } from './user';\n\nexport const GroupType = {\n  userGroup: 'UserGroup',\n  externalUserGroup: 'ExternalUserGroup',\n} as const;\nexport type GroupType = (typeof GroupType)[keyof typeof GroupType];\n\nexport type IGrantedGroup = {\n  type: GroupType;\n  item: Ref<IUserGroup>;\n};\n\nexport type IPage = {\n  path: string;\n  status: string;\n  revision?: Ref<IRevision>;\n  tags: Ref<ITag>[];\n  creator?: Ref<IUser>;\n  createdAt: Date;\n  updatedAt: Date;\n  seenUsers: Ref<IUser>[];\n  parent: Ref<IPage> | null;\n  descendantCount: number;\n  isEmpty: boolean;\n  grant: PageGrant;\n  grantedUsers: Ref<IUser>[];\n  grantedGroups: IGrantedGroup[];\n  lastUpdateUser?: Ref<IUser>;\n  liker: Ref<IUser>[];\n  commentCount: number;\n  slackChannels: string;\n  deleteUser: Ref<IUser>;\n  deletedAt: Date;\n  latestRevision?: Ref<IRevision>;\n  latestRevisionBodyLength?: number;\n  expandContentWidth?: boolean;\n  wip?: boolean;\n  ttlTimestamp?: Date;\n};\n\nexport type IPagePopulatedToShowRevision = Omit<\n  IPageHasId,\n  | 'lastUpdateUser'\n  | 'creator'\n  | 'deleteUser'\n  | 'grantedGroups'\n  | 'revision'\n  | 'author'\n> & {\n  lastUpdateUser?: IUserHasId;\n  creator?: IUserHasId;\n  deleteUser: IUserHasId;\n  grantedGroups: { type: GroupType; item: IUserGroupHasId }[];\n  revision?: IRevisionHasId;\n  author: IUserHasId;\n};\n\nexport const PageGrant = {\n  GRANT_PUBLIC: 1,\n  GRANT_RESTRICTED: 2,\n  GRANT_SPECIFIED: 3, // DEPRECATED\n  GRANT_OWNER: 4,\n  GRANT_USER_GROUP: 5,\n} as const;\ntype UnionPageGrantKeys = keyof typeof PageGrant;\nexport type PageGrant = (typeof PageGrant)[UnionPageGrantKeys];\n\nexport const PageStatus = {\n  STATUS_PUBLISHED: 'published',\n  STATUS_DELETED: 'deleted',\n} as const;\nexport type PageStatus = (typeof PageStatus)[keyof typeof PageStatus];\n\nexport type IPageHasId = IPage & HasObjectId;\n\n// Special type to represent page is an empty page or not found or forbidden status\nexport type IPageNotFoundInfo = {\n  isNotFound: true;\n  isForbidden: boolean;\n};\n\nexport type IPageInfo = {\n  isNotFound: boolean;\n  isV5Compatible: boolean;\n  isEmpty: boolean;\n  isMovable: boolean;\n  isDeletable: boolean;\n  isAbleToDeleteCompletely: boolean;\n  isRevertible: boolean;\n  bookmarkCount: number;\n};\n\nexport type IPageInfoForEmpty = Omit<IPageInfo, 'isNotFound' | 'isEmpty'> & {\n  emptyPageId: string;\n  isNotFound: false;\n  isEmpty: true;\n  isBookmarked?: boolean;\n};\n\nexport type IPageInfoForEntity = Omit<IPageInfo, 'isNotFound' | 'isEmpty'> & {\n  isNotFound: false;\n  isEmpty: false;\n  sumOfLikers: number;\n  likerIds: string[];\n  sumOfSeenUsers: number;\n  seenUserIds: string[];\n  contentAge: number;\n  descendantCount: number;\n  commentCount: number;\n  latestRevisionId: Ref<IRevision>;\n};\n\nexport type IPageInfoForOperation = IPageInfoForEntity & {\n  isBookmarked?: boolean;\n  isLiked?: boolean;\n  subscriptionStatus?: SubscriptionStatusType;\n};\n\nexport type IPageInfoForListing = IPageInfoForEntity & HasRevisionShortbody;\n\nexport type IPageInfoExt =\n  | IPageInfo\n  | IPageInfoForEmpty\n  | IPageInfoForEntity\n  | IPageInfoForOperation\n  | IPageInfoForListing;\n\nexport const isIPageNotFoundInfo = (\n  // biome-ignore lint/suspicious/noExplicitAny: ignore\n  pageInfo: any | undefined,\n): pageInfo is IPageNotFoundInfo => {\n  return (\n    pageInfo != null &&\n    pageInfo instanceof Object &&\n    pageInfo.isNotFound === true &&\n    'isForbidden' in pageInfo\n  );\n};\n\nexport const isIPageInfo = (\n  // biome-ignore lint/suspicious/noExplicitAny: ignore\n  pageInfo: any | undefined,\n): pageInfo is IPageInfo => {\n  return (\n    pageInfo != null && pageInfo instanceof Object && 'isEmpty' in pageInfo\n  );\n};\n\nexport const isIPageInfoForEmpty = (\n  // biome-ignore lint/suspicious/noExplicitAny: ignore\n  pageInfo: any | undefined,\n): pageInfo is IPageInfoForEmpty => {\n  return isIPageInfo(pageInfo) && pageInfo.isEmpty === true;\n};\n\nexport const isIPageInfoForEntity = (\n  // biome-ignore lint/suspicious/noExplicitAny: ignore\n  pageInfo: any | undefined,\n): pageInfo is IPageInfoForEntity => {\n  return isIPageInfo(pageInfo) && pageInfo.isEmpty === false;\n};\n\nexport type IPageInfoBasicForEmpty = Omit<\n  IPageInfoForEmpty,\n  'bookmarkCount' | 'isDeletable' | 'isAbleToDeleteCompletely' | 'isBookmarked'\n>;\n\nexport type IPageInfoBasicForEntity = Omit<\n  IPageInfoForEntity,\n  'bookmarkCount' | 'isDeletable' | 'isAbleToDeleteCompletely'\n>;\n\nexport type IPageInfoBasic = IPageInfoBasicForEmpty | IPageInfoBasicForEntity;\n\nexport const isIPageInfoForOperation = (\n  // biome-ignore lint/suspicious/noExplicitAny: ignore\n  pageInfo: any | undefined,\n): pageInfo is IPageInfoForOperation => {\n  return (\n    isIPageInfoForEntity(pageInfo) &&\n    ('isBookmarked' in pageInfo ||\n      'isLiked' in pageInfo ||\n      'subscriptionStatus' in pageInfo)\n  );\n};\n\nexport const isIPageInfoForListing = (\n  // biome-ignore lint/suspicious/noExplicitAny: ignore\n  pageInfo: any | undefined,\n): pageInfo is IPageInfoForListing => {\n  return isIPageInfoForEntity(pageInfo) && 'revisionShortBody' in pageInfo;\n};\n\nexport type IDataWithMeta<D = unknown, M = unknown> = {\n  data: D;\n  meta?: M;\n};\nexport type IDataWithRequiredMeta<D = unknown, M = unknown> = IDataWithMeta<\n  D,\n  M\n> & { meta: M };\n\nexport type IPageWithMeta<M = IPageInfoExt> = IDataWithMeta<IPageHasId, M>;\n\nexport type IPageToDeleteWithMeta<T = IPageInfoForEntity | unknown> =\n  IDataWithMeta<\n    HasObjectId & (IPage | { path: string; revision: string | null }),\n    T\n  >;\nexport type IPageToRenameWithMeta<T = IPageInfoForEntity | unknown> =\n  IPageToDeleteWithMeta<T>;\n"],"names":["GroupType","PageGrant","PageStatus","isIPageNotFoundInfo","pageInfo","isIPageInfo","isIPageInfoForEmpty","isIPageInfoForEntity","isIPageInfoForOperation","isIPageInfoForListing"],"mappings":"gFAWO,MAAMA,EAAY,CACvB,UAAW,YACX,kBAAmB,mBACrB,EAqDaC,EAAY,CACvB,aAAc,EACd,iBAAkB,EAClB,gBAAiB,EACjB,YAAa,EACb,iBAAkB,CACpB,EAIaC,EAAa,CACxB,iBAAkB,YAClB,eAAgB,SAClB,EAyDaC,EAEXC,GAGEA,GAAY,MACZA,aAAoB,QACpBA,EAAS,aAAe,IACxB,gBAAiBA,EAIRC,EAEXD,GAGEA,GAAY,MAAQA,aAAoB,QAAU,YAAaA,EAItDE,EAEXF,GAEOC,EAAYD,CAAQ,GAAKA,EAAS,UAAY,GAG1CG,EAEXH,GAEOC,EAAYD,CAAQ,GAAKA,EAAS,UAAY,GAe1CI,EAEXJ,GAGEG,EAAqBH,CAAQ,IAC5B,iBAAkBA,GACjB,YAAaA,GACb,uBAAwBA,GAIjBK,EAEXL,GAEOG,EAAqBH,CAAQ,GAAK,sBAAuBA"}