types.go 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. URL string `json:"url"`
  20. }
  21. // PageListItem is a page entry as returned by the list query.
  22. type PageListItem struct {
  23. ID int `json:"id"`
  24. Path string `json:"path"`
  25. Title string `json:"title"`
  26. Description string `json:"description"`
  27. Tags []string `json:"tags"`
  28. CreatedAt string `json:"createdAt"`
  29. UpdatedAt string `json:"updatedAt"`
  30. Locale string `json:"locale"`
  31. URL string `json:"url"`
  32. }
  33. // SearchHit is a single search result.
  34. type SearchHit struct {
  35. Title string `json:"title"`
  36. Description string `json:"description"`
  37. Path string `json:"path"`
  38. Locale string `json:"locale"`
  39. URL string `json:"url"`
  40. }
  41. // SearchResults is the result of a page search.
  42. type SearchResults struct {
  43. Results []SearchHit `json:"results"`
  44. Suggestions []string `json:"suggestions"`
  45. TotalHits int `json:"totalHits"`
  46. }
  47. // ListOptions filters the pages returned by [Client.ListPages]. Empty fields are
  48. // omitted from the GraphQL request.
  49. type ListOptions struct {
  50. Limit *int
  51. Locale string
  52. Tags []string
  53. }
  54. // CreatePageInput describes a new page.
  55. type CreatePageInput struct {
  56. Title string
  57. Content string
  58. Description string
  59. Path string
  60. Editor string
  61. IsPublished bool
  62. IsPrivate bool
  63. Locale string
  64. Tags []string
  65. }
  66. // UpdatePageInput describes an existing page and its new content.
  67. type UpdatePageInput struct {
  68. ID int
  69. Title string
  70. Content string
  71. Description string
  72. Path string
  73. Editor string
  74. IsPublished bool
  75. IsPrivate bool
  76. Locale string
  77. Tags []string
  78. }
  79. // MutationResult is the normalized WikiJS responseResult of a mutation.
  80. type MutationResult struct {
  81. Succeeded bool `json:"succeeded"`
  82. Message string `json:"message"`
  83. ErrorCode int `json:"-"`
  84. Slug string `json:"-"`
  85. }