types.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // Package wikijs is a small typed client for the WikiJS GraphQL API.
  2. package wikijs
  3. // Tag is a tag attached to a single page.
  4. type Tag struct {
  5. Tag string `json:"tag"`
  6. Title string `json:"title"`
  7. }
  8. // Page is a full page as returned by the single and singleByPath queries.
  9. type Page struct {
  10. ID int `json:"id"`
  11. Path string `json:"path"`
  12. Title string `json:"title"`
  13. Description string `json:"description"`
  14. Tags []Tag `json:"tags"`
  15. Content string `json:"content"`
  16. CreatedAt string `json:"createdAt"`
  17. UpdatedAt string `json:"updatedAt"`
  18. Locale string `json:"locale"`
  19. IsPublished bool `json:"isPublished"`
  20. IsPrivate bool `json:"isPrivate"`
  21. URL string `json:"url"`
  22. }
  23. // PageListItem is a page entry as returned by the list query.
  24. type PageListItem struct {
  25. ID int `json:"id"`
  26. Path string `json:"path"`
  27. Title string `json:"title"`
  28. Description string `json:"description"`
  29. Tags []string `json:"tags"`
  30. CreatedAt string `json:"createdAt"`
  31. UpdatedAt string `json:"updatedAt"`
  32. Locale string `json:"locale"`
  33. URL string `json:"url"`
  34. }
  35. // SearchHit is a single search result.
  36. type SearchHit struct {
  37. Title string `json:"title"`
  38. Description string `json:"description"`
  39. Path string `json:"path"`
  40. Locale string `json:"locale"`
  41. URL string `json:"url"`
  42. }
  43. // SearchResults is the result of a page search.
  44. type SearchResults struct {
  45. Results []SearchHit `json:"results"`
  46. Suggestions []string `json:"suggestions"`
  47. TotalHits int `json:"totalHits"`
  48. }
  49. // ListOptions filters the pages returned by [Client.ListPages]. Empty fields are
  50. // omitted from the GraphQL request.
  51. type ListOptions struct {
  52. Limit *int
  53. Locale string
  54. Tags []string
  55. }
  56. // CreatePageInput describes a new page.
  57. type CreatePageInput struct {
  58. Title string
  59. Content string
  60. Description string
  61. Path string
  62. Editor string
  63. IsPublished bool
  64. IsPrivate bool
  65. Locale string
  66. Tags []string
  67. }
  68. // UpdatePageInput describes an existing page and its new content.
  69. type UpdatePageInput struct {
  70. ID int
  71. Title string
  72. Content string
  73. Description string
  74. Path string
  75. Editor string
  76. IsPublished bool
  77. IsPrivate bool
  78. Locale string
  79. Tags []string
  80. }
  81. // AssetFolder is a folder in the WikiJS asset store. Path is the full folder
  82. // path (for example images/vacation), filled in by the client.
  83. type AssetFolder struct {
  84. ID int `json:"id"`
  85. Slug string `json:"slug"`
  86. Name string `json:"name"`
  87. Path string `json:"path"`
  88. }
  89. // Asset is a file in the WikiJS asset store.
  90. type Asset struct {
  91. ID int `json:"id"`
  92. FileName string `json:"filename"`
  93. Ext string `json:"ext"`
  94. Kind string `json:"kind"`
  95. MimeType string `json:"mime"`
  96. FileSize int `json:"fileSize"`
  97. CreatedAt string `json:"createdAt"`
  98. UpdatedAt string `json:"updatedAt"`
  99. Folder *AssetFolder `json:"folder"`
  100. URL string `json:"url"`
  101. }
  102. // UploadedAsset describes the result of a successful asset upload.
  103. type UploadedAsset struct {
  104. Filename string `json:"filename"`
  105. URL string `json:"url"`
  106. }
  107. // MutationResult is the normalized WikiJS responseResult of a mutation.
  108. type MutationResult struct {
  109. Succeeded bool `json:"succeeded"`
  110. Message string `json:"message"`
  111. ErrorCode int `json:"-"`
  112. Slug string `json:"-"`
  113. }