queries.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import * as Types from './schema'
  2. import gql from 'graphql-tag'
  3. export type StorageNodeInfoFragment = {
  4. id: string
  5. operatorMetadata?: Types.Maybe<{ nodeEndpoint?: Types.Maybe<string> }>
  6. }
  7. export type GetStorageNodesInfoByBagIdQueryVariables = Types.Exact<{
  8. bagId?: Types.Maybe<Types.Scalars['String']>
  9. }>
  10. export type GetStorageNodesInfoByBagIdQuery = { storageBuckets: Array<StorageNodeInfoFragment> }
  11. export type DataObjectInfoFragment = {
  12. id: string
  13. size: any
  14. deletionPrize: any
  15. type:
  16. | { __typename: 'DataObjectTypeChannelAvatar'; channel?: Types.Maybe<{ id: string }> }
  17. | { __typename: 'DataObjectTypeChannelCoverPhoto'; channel?: Types.Maybe<{ id: string }> }
  18. | { __typename: 'DataObjectTypeVideoMedia'; video?: Types.Maybe<{ id: string }> }
  19. | { __typename: 'DataObjectTypeVideoThumbnail'; video?: Types.Maybe<{ id: string }> }
  20. | { __typename: 'DataObjectTypeUnknown' }
  21. }
  22. export type GetDataObjectsByBagIdQueryVariables = Types.Exact<{
  23. bagId?: Types.Maybe<Types.Scalars['ID']>
  24. }>
  25. export type GetDataObjectsByBagIdQuery = { storageDataObjects: Array<DataObjectInfoFragment> }
  26. export type GetDataObjectsChannelIdQueryVariables = Types.Exact<{
  27. channelId?: Types.Maybe<Types.Scalars['ID']>
  28. }>
  29. export type GetDataObjectsChannelIdQuery = { storageDataObjects: Array<DataObjectInfoFragment> }
  30. export type GetDataObjectsByVideoIdQueryVariables = Types.Exact<{
  31. videoId?: Types.Maybe<Types.Scalars['ID']>
  32. }>
  33. export type GetDataObjectsByVideoIdQuery = { storageDataObjects: Array<DataObjectInfoFragment> }
  34. export const StorageNodeInfo = gql`
  35. fragment StorageNodeInfo on StorageBucket {
  36. id
  37. operatorMetadata {
  38. nodeEndpoint
  39. }
  40. }
  41. `
  42. export const DataObjectInfo = gql`
  43. fragment DataObjectInfo on StorageDataObject {
  44. id
  45. size
  46. deletionPrize
  47. type {
  48. __typename
  49. ... on DataObjectTypeVideoMedia {
  50. video {
  51. id
  52. }
  53. }
  54. ... on DataObjectTypeVideoThumbnail {
  55. video {
  56. id
  57. }
  58. }
  59. ... on DataObjectTypeChannelAvatar {
  60. channel {
  61. id
  62. }
  63. }
  64. ... on DataObjectTypeChannelCoverPhoto {
  65. channel {
  66. id
  67. }
  68. }
  69. }
  70. }
  71. `
  72. export const GetStorageNodesInfoByBagId = gql`
  73. query getStorageNodesInfoByBagId($bagId: String) {
  74. storageBuckets(
  75. where: {
  76. operatorStatus_json: { isTypeOf_eq: "StorageBucketOperatorStatusActive" }
  77. bagAssignments_some: { storageBagId_eq: $bagId }
  78. operatorMetadata: { nodeEndpoint_contains: "http" }
  79. }
  80. ) {
  81. ...StorageNodeInfo
  82. }
  83. }
  84. ${StorageNodeInfo}
  85. `
  86. export const GetDataObjectsByBagId = gql`
  87. query getDataObjectsByBagId($bagId: ID) {
  88. storageDataObjects(where: { storageBag: { id_eq: $bagId } }) {
  89. ...DataObjectInfo
  90. }
  91. }
  92. ${DataObjectInfo}
  93. `
  94. export const GetDataObjectsChannelId = gql`
  95. query getDataObjectsChannelId($channelId: ID) {
  96. storageDataObjects(where: { type_json: { channelId_eq: $channelId } }) {
  97. ...DataObjectInfo
  98. }
  99. }
  100. ${DataObjectInfo}
  101. `
  102. export const GetDataObjectsByVideoId = gql`
  103. query getDataObjectsByVideoId($videoId: ID) {
  104. storageDataObjects(where: { type_json: { videoId_eq: $videoId } }) {
  105. ...DataObjectInfo
  106. }
  107. }
  108. ${DataObjectInfo}
  109. `