types.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. // AssetFolder is a folder in the WikiJS asset store. Path is the full folder
  80. // path (for example images/vacation), filled in by the client.
  81. type AssetFolder struct {
  82. ID int `json:"id"`
  83. Slug string `json:"slug"`
  84. Name string `json:"name"`
  85. Path string `json:"path"`
  86. }
  87. // Asset is a file in the WikiJS asset store.
  88. type Asset struct {
  89. ID int `json:"id"`
  90. FileName string `json:"filename"`
  91. Ext string `json:"ext"`
  92. Kind string `json:"kind"`
  93. MimeType string `json:"mime"`
  94. FileSize int `json:"fileSize"`
  95. CreatedAt string `json:"createdAt"`
  96. UpdatedAt string `json:"updatedAt"`
  97. Folder *AssetFolder `json:"folder"`
  98. URL string `json:"url"`
  99. }
  100. // UploadedAsset describes the result of a successful asset upload.
  101. type UploadedAsset struct {
  102. Filename string `json:"filename"`
  103. URL string `json:"url"`
  104. }
  105. // MutationResult is the normalized WikiJS responseResult of a mutation.
  106. type MutationResult struct {
  107. Succeeded bool `json:"succeeded"`
  108. Message string `json:"message"`
  109. ErrorCode int `json:"-"`
  110. Slug string `json:"-"`
  111. }