@rynt/sdk 0.9.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (332) hide show
  1. package/README.md +122 -0
  2. package/REGISTRIES.md +189 -0
  3. package/env.d.ts +11 -0
  4. package/host-shims.d.ts +30 -0
  5. package/package.json +88 -0
  6. package/src/extension-marketplace/api-types.ts +141 -0
  7. package/src/extension-marketplace/client.ts +296 -0
  8. package/src/extension-marketplace/index.ts +22 -0
  9. package/src/extension-marketplace/schemas.ts +178 -0
  10. package/src/extensions/ExtensionRoutePage.vue +17 -0
  11. package/src/extensions/context.ts +37 -0
  12. package/src/extensions/disabled-folder.ts +21 -0
  13. package/src/extensions/extension-expose-map.ts +5 -0
  14. package/src/extensions/extension-expose.ts +48 -0
  15. package/src/extensions/graph.ts +67 -0
  16. package/src/extensions/index.ts +251 -0
  17. package/src/extensions/invite-handler/types.ts +20 -0
  18. package/src/extensions/launcher-entities/create-launcher-entity.ts +25 -0
  19. package/src/extensions/launcher-entities/keys.ts +46 -0
  20. package/src/extensions/launcher-entities/launcher-entity-components.ts +177 -0
  21. package/src/extensions/launcher-entities/props-map.ts +69 -0
  22. package/src/extensions/launcher-entities/registry.ts +32 -0
  23. package/src/extensions/launcher-models/apis/accounts-contracts.ts +102 -0
  24. package/src/extensions/launcher-models/apis/launcher-model-apis.ts +553 -0
  25. package/src/extensions/launcher-models/keys.ts +23 -0
  26. package/src/extensions/launcher-models/public.ts +9 -0
  27. package/src/extensions/launcher-models/registry-core.ts +34 -0
  28. package/src/extensions/manifest-types.ts +22 -0
  29. package/src/extensions/manifest.ts +46 -0
  30. package/src/extensions/marketplace-open-key.ts +26 -0
  31. package/src/extensions/plugin-types.ts +44 -0
  32. package/src/extensions/plugin.ts +62 -0
  33. package/src/extensions/registries/bootstrap.ts +11 -0
  34. package/src/extensions/registries/builtins/account-provider.ts +6 -0
  35. package/src/extensions/registries/builtins/app-topbar-left-widgets.ts +6 -0
  36. package/src/extensions/registries/builtins/app-topbar-right-widgets.ts +6 -0
  37. package/src/extensions/registries/builtins/app-topbar-status-widgets.ts +6 -0
  38. package/src/extensions/registries/builtins/build-card-actions.ts +6 -0
  39. package/src/extensions/registries/builtins/build-card-after-meta.ts +6 -0
  40. package/src/extensions/registries/builtins/build-card-before-media.ts +6 -0
  41. package/src/extensions/registries/builtins/build-card-before-meta.ts +6 -0
  42. package/src/extensions/registries/builtins/build-card-footer-actions.ts +6 -0
  43. package/src/extensions/registries/builtins/build-detail-after-content.ts +6 -0
  44. package/src/extensions/registries/builtins/build-detail-before-content.ts +6 -0
  45. package/src/extensions/registries/builtins/build-detail-before-hero.ts +6 -0
  46. package/src/extensions/registries/builtins/build-detail-header-actions.ts +6 -0
  47. package/src/extensions/registries/builtins/build-detail-mod-row-actions.ts +6 -0
  48. package/src/extensions/registries/builtins/build-detail-resourcepack-row-actions.ts +6 -0
  49. package/src/extensions/registries/builtins/build-detail-right-column-bottom.ts +6 -0
  50. package/src/extensions/registries/builtins/build-detail-right-column-top.ts +6 -0
  51. package/src/extensions/registries/builtins/dialog-footer-actions.ts +6 -0
  52. package/src/extensions/registries/builtins/feed-after-content.ts +6 -0
  53. package/src/extensions/registries/builtins/feed-before-content.ts +6 -0
  54. package/src/extensions/registries/builtins/file-editor.ts +19 -0
  55. package/src/extensions/registries/builtins/friends-after-list.ts +6 -0
  56. package/src/extensions/registries/builtins/friends-before-list.ts +6 -0
  57. package/src/extensions/registries/builtins/index.ts +141 -0
  58. package/src/extensions/registries/builtins/invite-handler.ts +7 -0
  59. package/src/extensions/registries/builtins/library-after-content.ts +6 -0
  60. package/src/extensions/registries/builtins/library-before-content.ts +6 -0
  61. package/src/extensions/registries/builtins/loader.ts +8 -0
  62. package/src/extensions/registries/builtins/map-card-actions.ts +6 -0
  63. package/src/extensions/registries/builtins/map-card-after-meta.ts +6 -0
  64. package/src/extensions/registries/builtins/map-card-before-meta.ts +6 -0
  65. package/src/extensions/registries/builtins/map-card-footer-actions.ts +6 -0
  66. package/src/extensions/registries/builtins/map-detail-after-content.ts +6 -0
  67. package/src/extensions/registries/builtins/map-detail-before-content.ts +6 -0
  68. package/src/extensions/registries/builtins/map-detail-header-actions.ts +6 -0
  69. package/src/extensions/registries/builtins/markdown-editor-tiptap-extensions.ts +7 -0
  70. package/src/extensions/registries/builtins/markdown-editor-toolbar-actions.ts +6 -0
  71. package/src/extensions/registries/builtins/markdown-renderer-after-content.ts +6 -0
  72. package/src/extensions/registries/builtins/markdown-renderer-before-content.ts +6 -0
  73. package/src/extensions/registries/builtins/mod-details-footer-actions.ts +6 -0
  74. package/src/extensions/registries/builtins/mod-manage-actions.ts +6 -0
  75. package/src/extensions/registries/builtins/mod-provider.ts +5 -0
  76. package/src/extensions/registries/builtins/nav.ts +7 -0
  77. package/src/extensions/registries/builtins/page.ts +13 -0
  78. package/src/extensions/registries/builtins/projects-after-content.ts +6 -0
  79. package/src/extensions/registries/builtins/projects-before-content.ts +6 -0
  80. package/src/extensions/registries/builtins/resourcepack-manage-actions.ts +7 -0
  81. package/src/extensions/registries/builtins/server-card-actions.ts +6 -0
  82. package/src/extensions/registries/builtins/server-card-after-meta.ts +6 -0
  83. package/src/extensions/registries/builtins/server-card-before-meta.ts +6 -0
  84. package/src/extensions/registries/builtins/server-card-footer-actions.ts +6 -0
  85. package/src/extensions/registries/builtins/server-detail-after-content.ts +6 -0
  86. package/src/extensions/registries/builtins/server-detail-before-content.ts +6 -0
  87. package/src/extensions/registries/builtins/server-detail-header-actions.ts +6 -0
  88. package/src/extensions/registries/builtins/settings-after-sections.ts +6 -0
  89. package/src/extensions/registries/builtins/settings-before-sections.ts +6 -0
  90. package/src/extensions/registries/builtins/settings-section-widgets.ts +6 -0
  91. package/src/extensions/registries/builtins/shaderpack-manage-actions.ts +7 -0
  92. package/src/extensions/registries/builtins/shell.ts +5 -0
  93. package/src/extensions/registries/builtins/sidebar-after-content.ts +6 -0
  94. package/src/extensions/registries/builtins/sidebar-before-content.ts +6 -0
  95. package/src/extensions/registries/builtins/sidebar-footer-widgets.ts +6 -0
  96. package/src/extensions/registries/builtins/sidebar-header-widgets.ts +6 -0
  97. package/src/extensions/registries/builtins/sidebar.ts +11 -0
  98. package/src/extensions/registries/builtins/theme.ts +5 -0
  99. package/src/extensions/registries/builtins/user-card-after-meta.ts +6 -0
  100. package/src/extensions/registries/builtins/user-card-before-meta.ts +6 -0
  101. package/src/extensions/registries/builtins/user-menu-actions.ts +6 -0
  102. package/src/extensions/registries/builtins/user-menu-after-actions.ts +6 -0
  103. package/src/extensions/registries/builtins/user-menu-before-actions.ts +6 -0
  104. package/src/extensions/registries/builtins/user-strip.ts +5 -0
  105. package/src/extensions/registries/clear-extension-ui-registries.ts +15 -0
  106. package/src/extensions/registries/define-extension-registry.ts +58 -0
  107. package/src/extensions/registries/extension-host-api.ts +41 -0
  108. package/src/extensions/registries/extension-registry-api.ts +103 -0
  109. package/src/extensions/registries/extension-registry-payload-map.ts +9 -0
  110. package/src/extensions/registries/extension-scope.ts +41 -0
  111. package/src/extensions/registries/get-registry.ts +23 -0
  112. package/src/extensions/registries/index.ts +58 -0
  113. package/src/extensions/registries/manifest-rynt.ts +193 -0
  114. package/src/extensions/registries/registry-slot.ts +40 -0
  115. package/src/extensions/registries/registry-value-map.ts +89 -0
  116. package/src/extensions/registries/store.ts +206 -0
  117. package/src/extensions/resolve-extensions.ts +245 -0
  118. package/src/extensions/router-bridge.ts +103 -0
  119. package/src/extensions/session.ts +6 -0
  120. package/src/extensions/slug.ts +23 -0
  121. package/src/extensions/version.ts +147 -0
  122. package/src/host/extensions-composables.ts +33 -0
  123. package/src/host/extensions-init.ts +194 -0
  124. package/src/host/index.ts +11 -0
  125. package/src/host/launcher-models/index.ts +4 -0
  126. package/src/index.ts +229 -0
  127. package/src/minecraft-loader/base-loader.ts +102 -0
  128. package/src/minecraft-loader/index.ts +11 -0
  129. package/src/minecraft-loader/loader-registry.ts +72 -0
  130. package/src/shared/api/assets.ts +112 -0
  131. package/src/shared/api/auth.ts +283 -0
  132. package/src/shared/api/builds.ts +647 -0
  133. package/src/shared/api/config.ts +19 -0
  134. package/src/shared/api/download-stats.ts +103 -0
  135. package/src/shared/api/downloads.ts +36 -0
  136. package/src/shared/api/entity-authorship.ts +60 -0
  137. package/src/shared/api/events.ts +393 -0
  138. package/src/shared/api/friends.ts +140 -0
  139. package/src/shared/api/graphql.ts +87 -0
  140. package/src/shared/api/index.ts +23 -0
  141. package/src/shared/api/invites.ts +262 -0
  142. package/src/shared/api/library.ts +44 -0
  143. package/src/shared/api/maps.ts +385 -0
  144. package/src/shared/api/notify-websocket.ts +140 -0
  145. package/src/shared/api/posts.ts +357 -0
  146. package/src/shared/api/projectServers.ts +379 -0
  147. package/src/shared/api/serverMembers.ts +173 -0
  148. package/src/shared/api/users.ts +294 -0
  149. package/src/shared/composables/buildEditor/useBuildEditor.ts +66 -0
  150. package/src/shared/composables/buildManifest/buildManifest.ts +447 -0
  151. package/src/shared/composables/filesEditor/filesEditor.ts +346 -0
  152. package/src/shared/composables/index.ts +10 -0
  153. package/src/shared/composables/modsEditor/modsEditor.ts +1678 -0
  154. package/src/shared/composables/registrySlot/registry-slot-utils.ts +25 -0
  155. package/src/shared/composables/registrySlot/useRegistrySlotMissing.ts +35 -0
  156. package/src/shared/composables/resourcePacksEditor/resourcePacksEditor.ts +448 -0
  157. package/src/shared/composables/shaderPacksEditor/shaderPacksEditor.ts +395 -0
  158. package/src/shared/composables/useSkinRender.ts +70 -0
  159. package/src/shared/composables/useZlDeepLink.ts +178 -0
  160. package/src/shared/definitions/defineGraphCache.ts +216 -0
  161. package/src/shared/definitions/defineStore.ts +32 -0
  162. package/src/shared/definitions/index.ts +2 -0
  163. package/src/shared/minecraft-types/build-manifest.ts +611 -0
  164. package/src/shared/minecraft-types/index.ts +3 -0
  165. package/src/shared/minecraft-types/launcher-versions.ts +32 -0
  166. package/src/shared/minecraft-types/minecraft-launcher-types.ts +276 -0
  167. package/src/shared/mocks/index.ts +1 -0
  168. package/src/shared/mocks/navigation.ts +17 -0
  169. package/src/shared/mods/http.ts +45 -0
  170. package/src/shared/mods/index.ts +5 -0
  171. package/src/shared/mods/marketplace-editor-search.ts +266 -0
  172. package/src/shared/mods/marketplace-search-utils.ts +42 -0
  173. package/src/shared/mods/mod-marketplace-registry.ts +66 -0
  174. package/src/shared/mods/mod-marketplace-types.ts +28 -0
  175. package/src/shared/mods/providers/curseforge.ts +464 -0
  176. package/src/shared/mods/providers/index.ts +8 -0
  177. package/src/shared/mods/providers/modrinth.ts +402 -0
  178. package/src/shared/mods/resolve-mods-provider-loader-ids.ts +77 -0
  179. package/src/shared/mods/types.ts +76 -0
  180. package/src/shared/styles/index.css +713 -0
  181. package/src/shared/themes/index.ts +23 -0
  182. package/src/shared/themes/theme-tokens-black.json +126 -0
  183. package/src/shared/themes/theme-tokens-classic.json +126 -0
  184. package/src/shared/themes/theme-tokens-pink.json +126 -0
  185. package/src/shared/themes/theme-tokens.json +126 -0
  186. package/src/shared/themes/types.ts +85 -0
  187. package/src/shared/types/API_DOCUMENTATION.md +422 -0
  188. package/src/shared/types/account.ts +40 -0
  189. package/src/shared/types/build.ts +8 -0
  190. package/src/shared/types/entities.ts +181 -0
  191. package/src/shared/types/index.ts +6 -0
  192. package/src/shared/types/invite-payloads.ts +60 -0
  193. package/src/shared/types/navigation.ts +16 -0
  194. package/src/shared/types/running-build.ts +51 -0
  195. package/src/shared/types/serverMember.ts +17 -0
  196. package/src/shared/types/user.ts +55 -0
  197. package/src/shared/ui/base/Avatar.vue +262 -0
  198. package/src/shared/ui/base/Badge.vue +47 -0
  199. package/src/shared/ui/base/Button.vue +78 -0
  200. package/src/shared/ui/base/Divider.vue +42 -0
  201. package/src/shared/ui/base/Icon.vue +597 -0
  202. package/src/shared/ui/base/StatusIndicator.vue +44 -0
  203. package/src/shared/ui/base/index.ts +7 -0
  204. package/src/shared/ui/cards/InviteCard.vue +47 -0
  205. package/src/shared/ui/cards/index.ts +2 -0
  206. package/src/shared/ui/dialog/Dialog.vue +71 -0
  207. package/src/shared/ui/dialog/DialogContent.vue +31 -0
  208. package/src/shared/ui/dialog/DialogFooter.vue +14 -0
  209. package/src/shared/ui/dialog/DialogHeader.vue +41 -0
  210. package/src/shared/ui/dialog/index.ts +5 -0
  211. package/src/shared/ui/editors/AttachmentImagesEditor.vue +133 -0
  212. package/src/shared/ui/editors/ContentAttachmentsDisplay.vue +76 -0
  213. package/src/shared/ui/editors/MarkdownEditor.vue +956 -0
  214. package/src/shared/ui/editors/MarkdownRenderer.vue +299 -0
  215. package/src/shared/ui/editors/RichContentImageViewer.vue +85 -0
  216. package/src/shared/ui/editors/SocialPostMediaZone.vue +320 -0
  217. package/src/shared/ui/editors/index.ts +6 -0
  218. package/src/shared/ui/editors/markdown-editor-gallery.ts +234 -0
  219. package/src/shared/ui/editors/markdown-editor-image.ts +178 -0
  220. package/src/shared/ui/form/Checkbox.vue +38 -0
  221. package/src/shared/ui/form/FormField.vue +30 -0
  222. package/src/shared/ui/form/FormGrid.vue +38 -0
  223. package/src/shared/ui/form/ImageEditor.vue +598 -0
  224. package/src/shared/ui/form/Input.vue +72 -0
  225. package/src/shared/ui/form/Range.vue +65 -0
  226. package/src/shared/ui/form/Select.vue +76 -0
  227. package/src/shared/ui/form/Switch.vue +38 -0
  228. package/src/shared/ui/form/Textarea.vue +144 -0
  229. package/src/shared/ui/form/index.ts +9 -0
  230. package/src/shared/ui/index.ts +9 -0
  231. package/src/shared/ui/layout/BusyOverlay.vue +31 -0
  232. package/src/shared/ui/layout/Callout.vue +44 -0
  233. package/src/shared/ui/layout/Card.vue +38 -0
  234. package/src/shared/ui/layout/Container.vue +36 -0
  235. package/src/shared/ui/layout/EmptyState.vue +99 -0
  236. package/src/shared/ui/layout/EntityMediaRow.vue +54 -0
  237. package/src/shared/ui/layout/FilterResultsLayout.vue +22 -0
  238. package/src/shared/ui/layout/FloatingPanel.vue +37 -0
  239. package/src/shared/ui/layout/FullscreenDimmer.vue +11 -0
  240. package/src/shared/ui/layout/Grid.vue +40 -0
  241. package/src/shared/ui/layout/Inline.vue +59 -0
  242. package/src/shared/ui/layout/LoadingState.vue +39 -0
  243. package/src/shared/ui/layout/MediaBox.vue +47 -0
  244. package/src/shared/ui/layout/OverlayPanel.vue +28 -0
  245. package/src/shared/ui/layout/OverlayWaitPanel.vue +22 -0
  246. package/src/shared/ui/layout/PageSection.vue +43 -0
  247. package/src/shared/ui/layout/PageToolbar.vue +29 -0
  248. package/src/shared/ui/layout/Panel.vue +39 -0
  249. package/src/shared/ui/layout/ProgressBar.vue +49 -0
  250. package/src/shared/ui/layout/Section.vue +30 -0
  251. package/src/shared/ui/layout/SegmentedControl.vue +43 -0
  252. package/src/shared/ui/layout/SelectableCard.vue +46 -0
  253. package/src/shared/ui/layout/SelectableRow.vue +41 -0
  254. package/src/shared/ui/layout/Skeleton.vue +25 -0
  255. package/src/shared/ui/layout/SkeletonAvatar.vue +30 -0
  256. package/src/shared/ui/layout/SkeletonEntityCard.vue +20 -0
  257. package/src/shared/ui/layout/SkeletonFeedPost.vue +22 -0
  258. package/src/shared/ui/layout/SkeletonGrid.vue +18 -0
  259. package/src/shared/ui/layout/SkeletonListRow.vue +31 -0
  260. package/src/shared/ui/layout/SkeletonText.vue +25 -0
  261. package/src/shared/ui/layout/Stack.vue +42 -0
  262. package/src/shared/ui/layout/StateBlock.vue +44 -0
  263. package/src/shared/ui/layout/TwoPaneLayout.vue +35 -0
  264. package/src/shared/ui/layout/VirtualList.vue +160 -0
  265. package/src/shared/ui/layout/index.ts +35 -0
  266. package/src/shared/ui/layout/skeletonSurfaceStyles.ts +24 -0
  267. package/src/shared/ui/navigation/NavItem.vue +139 -0
  268. package/src/shared/ui/navigation/Tab.vue +61 -0
  269. package/src/shared/ui/navigation/Tabs.vue +37 -0
  270. package/src/shared/ui/navigation/index.ts +4 -0
  271. package/src/shared/ui/primitives/Action.vue +19 -0
  272. package/src/shared/ui/primitives/Block.vue +28 -0
  273. package/src/shared/ui/primitives/CanvasView.vue +19 -0
  274. package/src/shared/ui/primitives/Control.vue +24 -0
  275. package/src/shared/ui/primitives/ControlSelect.vue +19 -0
  276. package/src/shared/ui/primitives/ControlTextarea.vue +17 -0
  277. package/src/shared/ui/primitives/FieldLabel.vue +19 -0
  278. package/src/shared/ui/primitives/Form.vue +19 -0
  279. package/src/shared/ui/primitives/Heading.vue +29 -0
  280. package/src/shared/ui/primitives/Image.vue +17 -0
  281. package/src/shared/ui/primitives/LineBreak.vue +3 -0
  282. package/src/shared/ui/primitives/Link.vue +19 -0
  283. package/src/shared/ui/primitives/List.vue +28 -0
  284. package/src/shared/ui/primitives/ListItem.vue +19 -0
  285. package/src/shared/ui/primitives/OptionItem.vue +19 -0
  286. package/src/shared/ui/primitives/Text.vue +28 -0
  287. package/src/shared/ui/primitives/VideoView.vue +19 -0
  288. package/src/shared/ui/primitives/index.ts +19 -0
  289. package/src/shared/ui/primitives/resolveElement.ts +25 -0
  290. package/src/shared/ui/special/AngularAccent.vue +106 -0
  291. package/src/shared/ui/special/ExtensionRegistrySlotButton.vue +143 -0
  292. package/src/shared/ui/special/InfoRow.vue +39 -0
  293. package/src/shared/ui/special/LogViewer.vue +53 -0
  294. package/src/shared/ui/special/PageHeader.vue +23 -0
  295. package/src/shared/ui/special/RegistrySlotMissingCallout.vue +48 -0
  296. package/src/shared/ui/special/WelcomeCard.vue +32 -0
  297. package/src/shared/ui/special/index.ts +9 -0
  298. package/src/shared/utils/app-paths.ts +50 -0
  299. package/src/shared/utils/attachments.ts +16 -0
  300. package/src/shared/utils/autostart.ts +213 -0
  301. package/src/shared/utils/build-files.ts +439 -0
  302. package/src/shared/utils/build-manifest-init.ts +176 -0
  303. package/src/shared/utils/cloudinary.ts +67 -0
  304. package/src/shared/utils/cn.ts +7 -0
  305. package/src/shared/utils/download-stats-week.ts +165 -0
  306. package/src/shared/utils/entity-api-to-cache.ts +84 -0
  307. package/src/shared/utils/entity-build-from-api.ts +1 -0
  308. package/src/shared/utils/entity-display.ts +27 -0
  309. package/src/shared/utils/entity-map-from-api.ts +1 -0
  310. package/src/shared/utils/file-hash.ts +65 -0
  311. package/src/shared/utils/formatSize.ts +5 -0
  312. package/src/shared/utils/formatTime.ts +157 -0
  313. package/src/shared/utils/getAccountSkinRender.ts +32 -0
  314. package/src/shared/utils/index.ts +34 -0
  315. package/src/shared/utils/local-mods.ts +678 -0
  316. package/src/shared/utils/local-settings.ts +217 -0
  317. package/src/shared/utils/member-join-stats.ts +35 -0
  318. package/src/shared/utils/platform.ts +86 -0
  319. package/src/shared/utils/play-host-slug.ts +92 -0
  320. package/src/shared/utils/rich-content.ts +294 -0
  321. package/src/shared/utils/safeRequest.ts +23 -0
  322. package/src/shared/utils/semver.ts +81 -0
  323. package/src/shared/utils/serverPermissions.ts +155 -0
  324. package/src/shared/utils/skin-render-cache.ts +372 -0
  325. package/src/shared/utils/stripMarkdown.ts +45 -0
  326. package/src/shared/utils/transliterate.ts +74 -0
  327. package/src/shared/utils/updateAccountSkinRender.ts +64 -0
  328. package/src/shared/utils/updater.ts +218 -0
  329. package/src/shared/utils/uploadImage.ts +195 -0
  330. package/src/shared/utils/user-status.ts +9 -0
  331. package/src/tiptap/index.ts +7 -0
  332. package/tsconfig.json +13 -0
@@ -0,0 +1,357 @@
1
+ /**
2
+ * API для работы с постами проектов
3
+ */
4
+
5
+ import type { EntityPost } from '../types/entities';
6
+ import { safeRequest } from '../utils/safeRequest';
7
+ import { graphqlRequest } from './graphql';
8
+
9
+ export type Post = EntityPost;
10
+
11
+ export interface PostInput {
12
+ projectId?: string; // Опционально - пост может быть без проекта
13
+ serverId?: string; // Опционально - пост может быть привязан к серверу
14
+ title: string;
15
+ description: string;
16
+ image?: string;
17
+ attachments?: string[];
18
+ }
19
+
20
+ const postAuthorFragment = `
21
+ author {
22
+ id
23
+ username
24
+ avatar
25
+ }
26
+ `;
27
+
28
+ /**
29
+ * Получает все посты (для фида главной страницы)
30
+ */
31
+ export const getAllPosts = (options?: {
32
+ take?: number;
33
+ skip?: number;
34
+ orderBy?: Array<{ date?: 'asc' | 'desc' }>;
35
+ }) =>
36
+ safeRequest(async (): Promise<EntityPost[]> => {
37
+ const query = `
38
+ query GetAllPosts($orderBy: [PostOrderByInput!]!, $take: Int, $skip: Int!) {
39
+ posts(orderBy: $orderBy, take: $take, skip: $skip) {
40
+ id
41
+ title
42
+ description
43
+ image
44
+ attachments
45
+ ${postAuthorFragment}
46
+ date
47
+ project {
48
+ id
49
+ name
50
+ }
51
+ server {
52
+ id
53
+ name
54
+ }
55
+ }
56
+ }
57
+ `;
58
+
59
+ const orderBy = options?.orderBy || [{ date: 'desc' }];
60
+
61
+ const result = await graphqlRequest<{ posts: EntityPost[] }>(query, {
62
+ orderBy,
63
+ take: options?.take || 48,
64
+ skip: options?.skip || 0,
65
+ });
66
+
67
+ return result.posts;
68
+ });
69
+
70
+ /**
71
+ * Получает пост по ID
72
+ */
73
+ export const getPost = (postId: string) =>
74
+ safeRequest(async (): Promise<EntityPost> => {
75
+ const query = `
76
+ query GetPost($where: PostWhereUniqueInput!) {
77
+ post(where: $where) {
78
+ id
79
+ title
80
+ description
81
+ image
82
+ attachments
83
+ ${postAuthorFragment}
84
+ date
85
+ project {
86
+ id
87
+ name
88
+ }
89
+ server {
90
+ id
91
+ name
92
+ }
93
+ }
94
+ }
95
+ `;
96
+
97
+ const result = await graphqlRequest<{ post: EntityPost }>(query, {
98
+ where: { id: postId },
99
+ });
100
+
101
+ return result.post;
102
+ });
103
+
104
+ /**
105
+ * Получает список постов проекта
106
+ */
107
+ export const getProjectPosts = (
108
+ projectId: string,
109
+ options?: {
110
+ take?: number;
111
+ skip?: number;
112
+ orderBy?: Array<{ date?: 'asc' | 'desc' }>;
113
+ },
114
+ ) =>
115
+ safeRequest(async (): Promise<EntityPost[]> => {
116
+ const query = `
117
+ query GetProjectPosts($where: PostWhereInput!, $orderBy: [PostOrderByInput!]!, $take: Int, $skip: Int!) {
118
+ posts(where: $where, orderBy: $orderBy, take: $take, skip: $skip) {
119
+ id
120
+ title
121
+ description
122
+ image
123
+ attachments
124
+ ${postAuthorFragment}
125
+ date
126
+ project {
127
+ id
128
+ name
129
+ }
130
+ server {
131
+ id
132
+ name
133
+ }
134
+ }
135
+ }
136
+ `;
137
+
138
+ const orderBy = options?.orderBy || [{ date: 'desc' }];
139
+
140
+ const result = await graphqlRequest<{ posts: EntityPost[] }>(query, {
141
+ where: {
142
+ project: { id: { equals: projectId } },
143
+ },
144
+ orderBy,
145
+ take: options?.take || 20,
146
+ skip: options?.skip || 0,
147
+ });
148
+
149
+ return result.posts;
150
+ });
151
+
152
+ /**
153
+ * Получает список постов сервера
154
+ */
155
+ export const getServerPosts = (
156
+ serverId: string,
157
+ options?: {
158
+ take?: number;
159
+ skip?: number;
160
+ orderBy?: Array<{ date?: 'asc' | 'desc' }>;
161
+ },
162
+ ) =>
163
+ safeRequest(async (): Promise<EntityPost[]> => {
164
+ const query = `
165
+ query GetServerPosts($where: PostWhereInput!, $orderBy: [PostOrderByInput!]!, $take: Int, $skip: Int!) {
166
+ posts(where: $where, orderBy: $orderBy, take: $take, skip: $skip) {
167
+ id
168
+ title
169
+ description
170
+ image
171
+ attachments
172
+ ${postAuthorFragment}
173
+ date
174
+ project {
175
+ id
176
+ name
177
+ }
178
+ server {
179
+ id
180
+ name
181
+ }
182
+ }
183
+ }
184
+ `;
185
+
186
+ const orderBy = options?.orderBy || [{ date: 'desc' }];
187
+
188
+ const result = await graphqlRequest<{ posts: EntityPost[] }>(query, {
189
+ where: {
190
+ server: { id: { equals: serverId } },
191
+ },
192
+ orderBy,
193
+ take: options?.take || 20,
194
+ skip: options?.skip || 0,
195
+ });
196
+
197
+ return result.posts;
198
+ });
199
+
200
+ /**
201
+ * Получает список постов по массиву серверов
202
+ */
203
+ export const getPostsByServers = (
204
+ serverIds: string[],
205
+ options?: {
206
+ take?: number;
207
+ skip?: number;
208
+ orderBy?: Array<{ date?: 'asc' | 'desc' }>;
209
+ },
210
+ ) =>
211
+ safeRequest(async (): Promise<EntityPost[]> => {
212
+ if (serverIds.length === 0) {
213
+ return [];
214
+ }
215
+
216
+ const query = `
217
+ query GetPostsByServers($where: PostWhereInput!, $orderBy: [PostOrderByInput!]!, $take: Int, $skip: Int!) {
218
+ posts(where: $where, orderBy: $orderBy, take: $take, skip: $skip) {
219
+ id
220
+ title
221
+ description
222
+ image
223
+ attachments
224
+ ${postAuthorFragment}
225
+ date
226
+ project {
227
+ id
228
+ name
229
+ }
230
+ server {
231
+ id
232
+ name
233
+ }
234
+ }
235
+ }
236
+ `;
237
+
238
+ const orderBy = options?.orderBy || [{ date: 'desc' }];
239
+
240
+ const result = await graphqlRequest<{ posts: EntityPost[] }>(query, {
241
+ where: {
242
+ server: { id: { in: serverIds } },
243
+ },
244
+ orderBy,
245
+ take: options?.take || 24,
246
+ skip: options?.skip || 0,
247
+ });
248
+
249
+ return result.posts;
250
+ });
251
+
252
+ /**
253
+ * Создает новый пост
254
+ */
255
+ export const createPost = (data: PostInput) =>
256
+ safeRequest(async (): Promise<EntityPost> => {
257
+ const mutation = `
258
+ mutation CreatePost($data: PostCreateInput!) {
259
+ createPost(data: $data) {
260
+ id
261
+ title
262
+ description
263
+ image
264
+ attachments
265
+ author {
266
+ id
267
+ username
268
+ avatar
269
+ }
270
+ date
271
+ }
272
+ }
273
+ `;
274
+
275
+ const createData: any = {
276
+ title: data.title,
277
+ description: data.description,
278
+ image: data.image || '',
279
+ attachments: data.attachments ?? [],
280
+ date: new Date().toISOString(),
281
+ };
282
+
283
+ // Привязываем к проекту или серверу, если указаны
284
+ if (data.projectId) {
285
+ createData.project = { connect: { id: data.projectId } };
286
+ }
287
+ if (data.serverId) {
288
+ createData.server = { connect: { id: data.serverId } };
289
+ }
290
+
291
+ const result = await graphqlRequest<{ createPost: EntityPost }>(mutation, {
292
+ data: createData,
293
+ });
294
+
295
+ return result.createPost;
296
+ });
297
+
298
+ /**
299
+ * Обновляет пост
300
+ */
301
+ export const updatePost = (
302
+ postId: string,
303
+ data: Partial<Omit<PostInput, 'projectId'>>,
304
+ ) =>
305
+ safeRequest(async (): Promise<EntityPost> => {
306
+ const mutation = `
307
+ mutation UpdatePost($where: PostWhereUniqueInput!, $data: PostUpdateInput!) {
308
+ updatePost(where: $where, data: $data) {
309
+ id
310
+ title
311
+ description
312
+ image
313
+ attachments
314
+ author {
315
+ id
316
+ username
317
+ avatar
318
+ }
319
+ date
320
+ }
321
+ }
322
+ `;
323
+
324
+ const updateData: any = {};
325
+ if (data.title !== undefined) updateData.title = data.title;
326
+ if (data.description !== undefined)
327
+ updateData.description = data.description;
328
+ if (data.image !== undefined) updateData.image = data.image;
329
+ if (data.attachments !== undefined) updateData.attachments = data.attachments;
330
+
331
+ const result = await graphqlRequest<{ updatePost: EntityPost }>(mutation, {
332
+ where: { id: postId },
333
+ data: updateData,
334
+ });
335
+
336
+ return result.updatePost;
337
+ });
338
+
339
+ /**
340
+ * Удаляет пост
341
+ */
342
+ export const deletePost = (postId: string) =>
343
+ safeRequest(async (): Promise<EntityPost> => {
344
+ const mutation = `
345
+ mutation DeletePost($where: PostWhereUniqueInput!) {
346
+ deletePost(where: $where) {
347
+ id
348
+ }
349
+ }
350
+ `;
351
+
352
+ const result = await graphqlRequest<{ deletePost: EntityPost }>(mutation, {
353
+ where: { id: postId },
354
+ });
355
+
356
+ return result.deletePost;
357
+ });
@@ -0,0 +1,379 @@
1
+ /**
2
+ * API для работы с серверами проектов
3
+ */
4
+
5
+ import type { EntityServer } from '../types/entities';
6
+ import { safeRequest } from '../utils/safeRequest';
7
+ import { graphqlRequest } from './graphql';
8
+
9
+ export interface ServerInput {
10
+ projectId?: string; // Опционально - сервер может быть без проекта
11
+ name: string;
12
+ address: string;
13
+ port: number;
14
+ status?: 'online' | 'offline';
15
+ buildId?: string;
16
+ buildName?: string;
17
+ players?: number;
18
+ maxPlayers?: number;
19
+ tags?: string[];
20
+ allowedProviders?: string[] | null;
21
+ image?: string;
22
+ description?: string;
23
+ rules?: string;
24
+ isPublic?: boolean;
25
+ }
26
+
27
+ /**
28
+ * Получает список всех серверов пользователя (где он автор проекта или сервер без проекта)
29
+ */
30
+ export const getUserServers = (userId: string) =>
31
+ safeRequest(async (): Promise<EntityServer[]> => {
32
+ // Получаем серверы, где пользователь является администратором через ServerMember
33
+ const adminServersQuery = `
34
+ query GetAdminServers($where: ServerMemberWhereInput!) {
35
+ serverMembers(where: $where) {
36
+ id
37
+ server {
38
+ id
39
+ name
40
+ address
41
+ port
42
+ status
43
+ build {
44
+ id
45
+ name
46
+ }
47
+ buildName
48
+ players
49
+ maxPlayers
50
+ tags
51
+ allowedProviders
52
+ image
53
+ description
54
+ rules
55
+ isPublic
56
+ project {
57
+ id
58
+ name
59
+ author {
60
+ id
61
+ }
62
+ }
63
+ }
64
+ }
65
+ }
66
+ `;
67
+
68
+ const adminServersResult = await graphqlRequest<{
69
+ serverMembers: Array<{ server: any }>;
70
+ }>(adminServersQuery, {
71
+ where: {
72
+ user: { id: { equals: userId } },
73
+ role: { equals: 'admin' },
74
+ },
75
+ });
76
+
77
+ // Преобразуем build в buildId для каждого сервера
78
+ return adminServersResult.serverMembers
79
+ .filter((member) => member.server) // Фильтруем только те, у которых есть сервер
80
+ .map((member: any) => {
81
+ const server = member.server;
82
+ if (server.build) {
83
+ server.buildId = server.build.id;
84
+ delete server.build;
85
+ }
86
+ return server as EntityServer;
87
+ });
88
+ });
89
+
90
+ /**
91
+ * Получает сервер по ID
92
+ */
93
+ export const getServer = (serverId: string) =>
94
+ safeRequest(async (): Promise<EntityServer> => {
95
+ const query = `
96
+ query GetProjectServer($where: ProjectServerWhereUniqueInput!) {
97
+ projectServer(where: $where) {
98
+ id
99
+ name
100
+ address
101
+ port
102
+ status
103
+ build {
104
+ id
105
+ name
106
+ }
107
+ buildName
108
+ players
109
+ maxPlayers
110
+ tags
111
+ allowedProviders
112
+ image
113
+ description
114
+ rules
115
+ isPublic
116
+ project {
117
+ id
118
+ name
119
+ author {
120
+ id
121
+ username
122
+ avatar
123
+ }
124
+ managers {
125
+ id
126
+ username
127
+ avatar
128
+ }
129
+ }
130
+ }
131
+ }
132
+ `;
133
+
134
+ const result = await graphqlRequest<{ projectServer: any }>(query, {
135
+ where: { id: serverId },
136
+ });
137
+
138
+ // Преобразуем build в buildId
139
+ const server = result.projectServer;
140
+ if (server.build) {
141
+ server.buildId = server.build.id;
142
+ delete server.build;
143
+ }
144
+
145
+ return server as EntityServer;
146
+ });
147
+
148
+ /**
149
+ * Создает новый сервер проекта (или без проекта)
150
+ */
151
+ export const createServer = (data: ServerInput) =>
152
+ safeRequest(async (): Promise<EntityServer> => {
153
+ const mutation = `
154
+ mutation CreateProjectServer($data: ProjectServerCreateInput!) {
155
+ createProjectServer(data: $data) {
156
+ id
157
+ name
158
+ address
159
+ port
160
+ status
161
+ buildName
162
+ players
163
+ maxPlayers
164
+ tags
165
+ allowedProviders
166
+ image
167
+ description
168
+ rules
169
+ isPublic
170
+ }
171
+ }
172
+ `;
173
+
174
+ const createData: any = {
175
+ name: data.name,
176
+ address: data.address,
177
+ port: data.port,
178
+ status: data.status || 'offline',
179
+ build: data.buildId ? { connect: { id: data.buildId } } : undefined,
180
+ buildName: data.buildName,
181
+ players: data.players,
182
+ maxPlayers: data.maxPlayers,
183
+ tags: data.tags || [],
184
+ allowedProviders: data.allowedProviders || null,
185
+ image: data.image || '',
186
+ description: data.description || '',
187
+ rules: data.rules || '',
188
+ isPublic: data.isPublic !== undefined ? data.isPublic : true,
189
+ };
190
+
191
+ // Привязываем к проекту только если указан
192
+ if (data.projectId) {
193
+ createData.project = { connect: { id: data.projectId } };
194
+ }
195
+
196
+ const result = await graphqlRequest<{ createProjectServer: EntityServer }>(
197
+ mutation,
198
+ {
199
+ data: createData,
200
+ },
201
+ );
202
+
203
+ return result.createProjectServer;
204
+ });
205
+
206
+ /**
207
+ * Обновляет сервер проекта
208
+ */
209
+ export const updateServer = (serverId: string, data: Partial<ServerInput>) =>
210
+ safeRequest(async (): Promise<EntityServer> => {
211
+ const mutation = `
212
+ mutation UpdateProjectServer($where: ProjectServerWhereUniqueInput!, $data: ProjectServerUpdateInput!) {
213
+ updateProjectServer(where: $where, data: $data) {
214
+ id
215
+ name
216
+ address
217
+ port
218
+ status
219
+ build {
220
+ id
221
+ name
222
+ }
223
+ buildName
224
+ players
225
+ maxPlayers
226
+ tags
227
+ allowedProviders
228
+ image
229
+ description
230
+ rules
231
+ isPublic
232
+ }
233
+ }
234
+ `;
235
+
236
+ const updateData: any = {};
237
+ if (data.name !== undefined) updateData.name = data.name;
238
+ if (data.address !== undefined) updateData.address = data.address;
239
+ if (data.port !== undefined) updateData.port = data.port;
240
+ if (data.status !== undefined) updateData.status = data.status;
241
+ if (data.buildId !== undefined) {
242
+ updateData.build = data.buildId
243
+ ? { connect: { id: data.buildId } }
244
+ : { disconnect: true };
245
+ }
246
+ if (data.buildName !== undefined) updateData.buildName = data.buildName;
247
+ if (data.players !== undefined) updateData.players = data.players;
248
+ if (data.maxPlayers !== undefined) updateData.maxPlayers = data.maxPlayers;
249
+ if (data.tags !== undefined) updateData.tags = data.tags;
250
+ if (data.allowedProviders !== undefined)
251
+ updateData.allowedProviders = data.allowedProviders;
252
+ if (data.image !== undefined) updateData.image = data.image;
253
+ if (data.description !== undefined)
254
+ updateData.description = data.description;
255
+ if (data.rules !== undefined) updateData.rules = data.rules;
256
+ if (data.isPublic !== undefined) updateData.isPublic = data.isPublic;
257
+
258
+ const result = await graphqlRequest<{ updateProjectServer: any }>(
259
+ mutation,
260
+ {
261
+ where: { id: serverId },
262
+ data: updateData,
263
+ },
264
+ );
265
+
266
+ // Преобразуем build в buildId
267
+ const server = result.updateProjectServer;
268
+ if (server.build) {
269
+ server.buildId = server.build.id;
270
+ delete server.build;
271
+ }
272
+
273
+ return server as EntityServer;
274
+ });
275
+
276
+ /**
277
+ * Удаляет сервер проекта
278
+ */
279
+ export const deleteServer = (serverId: string) =>
280
+ safeRequest(async (): Promise<EntityServer> => {
281
+ const mutation = `
282
+ mutation DeleteProjectServer($where: ProjectServerWhereUniqueInput!) {
283
+ deleteProjectServer(where: $where) {
284
+ id
285
+ }
286
+ }
287
+ `;
288
+
289
+ const result = await graphqlRequest<{ deleteProjectServer: EntityServer }>(
290
+ mutation,
291
+ {
292
+ where: { id: serverId },
293
+ },
294
+ );
295
+
296
+ return result.deleteProjectServer;
297
+ });
298
+
299
+ /**
300
+ * Получает список серверов с поиском и фильтрацией
301
+ */
302
+ export const getServers = (options?: {
303
+ take?: number;
304
+ skip?: number;
305
+ orderBy?: Array<{ name?: 'asc' | 'desc'; players?: 'asc' | 'desc' }>;
306
+ /** Только серверы с isPublic: true (библиотека, каталог). */
307
+ publicOnly?: boolean;
308
+ where?: {
309
+ search?: string;
310
+ };
311
+ }) =>
312
+ safeRequest(async (): Promise<EntityServer[]> => {
313
+ const query = `
314
+ query GetServers($where: ProjectServerWhereInput!, $orderBy: [ProjectServerOrderByInput!]!, $take: Int, $skip: Int!) {
315
+ projectServers(where: $where, orderBy: $orderBy, take: $take, skip: $skip) {
316
+ id
317
+ name
318
+ address
319
+ port
320
+ status
321
+ build {
322
+ id
323
+ name
324
+ }
325
+ buildName
326
+ players
327
+ maxPlayers
328
+ tags
329
+ image
330
+ description
331
+ isPublic
332
+ project {
333
+ id
334
+ name
335
+ author {
336
+ id
337
+ username
338
+ avatar
339
+ }
340
+ }
341
+ }
342
+ }
343
+ `;
344
+
345
+ const where: any = {};
346
+
347
+ if (options?.publicOnly) {
348
+ where.isPublic = { equals: true };
349
+ }
350
+
351
+ // Поиск по названию, описанию или адресу (case-insensitive)
352
+ if (options?.where?.search) {
353
+ where.OR = [
354
+ { name: { contains: options.where.search, mode: 'insensitive' } },
355
+ {
356
+ description: { contains: options.where.search, mode: 'insensitive' },
357
+ },
358
+ { address: { contains: options.where.search, mode: 'insensitive' } },
359
+ ];
360
+ }
361
+
362
+ const orderBy = options?.orderBy || [{ name: 'asc' }];
363
+
364
+ const result = await graphqlRequest<{ projectServers: any[] }>(query, {
365
+ where,
366
+ orderBy,
367
+ take: options?.take || 20,
368
+ skip: options?.skip || 0,
369
+ });
370
+
371
+ // Преобразуем build в buildId для каждого сервера
372
+ return result.projectServers.map((server: any) => {
373
+ if (server.build) {
374
+ server.buildId = server.build.id;
375
+ delete server.build;
376
+ }
377
+ return server as EntityServer;
378
+ });
379
+ });