API संदर्भ

Chat

स्थानीय चैट संदेशों, चैनलों और पेयर किए गए peers को प्रबंधित करें। सभी GraphQL ऑपरेशन POST /graphql पर भेजे जाते हैं।

प्रकार परिभाषाएँ

bash
type ChatItem {
  id: ID!
  fromId: String!      # "me" | peerId
  toId: String!        # peerId (direct) | "" (channel)
  channelId: String!   # "" for direct messages
  content: String!     # JSON-encoded message payload
  createdAt: String!   # ISO 8601
  updatedAt: String!
  status: String!      # "sent" | "pending" | "failed"
  statusData: String!  # extra info on failure
}

type ChatChannel {
  id: String!
  name: String!
  owner: String!             # "me" | peerId
  members: [ChatChannelMember!]!
  version: Int!
  status: String!            # "active" | "left"
  createdAt: String!
  updatedAt: String!
}

type ChatChannelMember {
  id: String!
  status: String!            # "active" | "pending"
}

type Peer {
  id: String!
  name: String!
  ip: String!
  status: String!            # "online" | "offline"
  port: Int!
  deviceType: String!        # "phone" | "tablet" | "pc"
  createdAt: String!
  updatedAt: String!
}

type AppFile {
  id: ID!
  size: Int!                 # bytes
  mimeType: String!
  realPath: String!
  fileName: String!
  createdAt: String!
  updatedAt: String!
}

ऑपरेशन

query

chatItems

एक वार्तालाप के सभी संदेश प्राप्त करें। id के आगे "channel:" या "peer:" जोड़ें।

bash
query GetChatItems($id: String!) {
  chatItems(id: $id) {
    id fromId toId channelId
    content createdAt updatedAt status statusData
  }
}
query

latestChatItems

हर वार्तालाप (चैनल + peers) का नवीनतम संदेश प्राप्त करें। वार्तालाप सूची पूर्वावलोकन बनाने के लिए उपयोगी।

bash
query GetLatestChatItems {
  latestChatItems {
    id fromId toId channelId content createdAt updatedAt status
  }
}
query

chatChannels

डिवाइस के स्वामित्व वाले या जुड़े सभी चैट चैनलों को सूचीबद्ध करें।

bash
query GetChatChannels {
  chatChannels {
    id name owner version status createdAt updatedAt
    members { id status }
  }
}
query

peers

इस डिवाइस के साथ पेयर किए गए सभी ज्ञात peers को सूचीबद्ध करें।

bash
query GetPeers {
  peers { id name ip status port deviceType createdAt updatedAt }
}
mutation

deletePeer

इस डिवाइस से एक peer रिकॉर्ड हटाएँ। रिमोट पक्ष पर अनपेयर नहीं करता; स्वच्छ द्विपक्षीय अनपेयर के लिए unpairPeer का उपयोग करें।

bash
mutation DeletePeer($id: ID!) {
  deletePeer(id: $id)
}
mutation

unpairPeer

एक peer डिवाइस अनपेयर करें। इस डिवाइस पर पेयरिंग स्थिति साफ़ करता है और पहुँच योग्य होने पर रिमोट peer को सिग्नल करता है।

bash
mutation UnpairPeer($id: ID!) {
  unpairPeer(id: $id)
}
query

appFiles

चैट के माध्यम से साझा की गई फ़ाइलों की पेजिनेटेड सूची।

bash
query GetAppFiles($offset: Int!, $limit: Int!) {
  appFiles(offset: $offset, limit: $limit) {
    id size mimeType realPath fileName createdAt updatedAt
  }
}
query

appFileCount

चैट के माध्यम से साझा की गई फ़ाइलों की कुल संख्या।

bash
query GetAppFileCount {
  appFileCount
}
mutation

sendChatItem

किसी चैनल या peer को संदेश भेजें। toId प्रारूप: "channel:<id>" या "peer:<id>"।

bash
mutation SendChatItem($toId: String!, $content: String!) {
  sendChatItem(toId: $toId, content: $content) {
    id fromId toId channelId content createdAt updatedAt status
  }
}
mutation

deleteChatItem

ID द्वारा एक चैट संदेश हटाएँ।

bash
mutation DeleteChatItem($id: ID!) {
  deleteChatItem(id: $id)
}
mutation

deleteChatItems

किसी query से मेल खाने वाले चैट संदेशों को थोक में हटाएँ (उदा. "id:msg_x,id:msg_y")।

bash
mutation DeleteChatItems($query: String!) {
  deleteChatItems(query: $query)
}
mutation

retryChatItem

विफल संदेश को पुनः भेजें।

bash
mutation RetryChatItem($id: ID!) {
  retryChatItem(id: $id) { id status }
}
mutation

createChatChannel

इस डिवाइस के स्वामित्व वाला एक नया एन्क्रिप्टेड चैनल बनाएँ।

bash
mutation CreateChatChannel($name: String!) {
  createChatChannel(name: $name) {
    id name owner version status createdAt
  }
}
mutation

updateChatChannel

एक चैट चैनल का नाम बदलें।

bash
mutation UpdateChatChannel($id: ID!, $name: String!) {
  updateChatChannel(id: $id, name: $name) { id name version updatedAt }
}
mutation

deleteChatChannel

एक चैनल और उसके सभी संदेश हटाएँ।

bash
mutation DeleteChatChannel($id: ID!) {
  deleteChatChannel(id: $id)
}
mutation

leaveChatChannel

ऐसा चैनल छोड़ें जिसके आप स्वामी नहीं हैं।

bash
mutation LeaveChatChannel($id: ID!) {
  leaveChatChannel(id: $id)
}
mutation

addChatChannelMember

अपने स्वामित्व वाले चैनल में एक peer को आमंत्रित करें।

bash
mutation AddMember($id: ID!, $peerId: String!) {
  addChatChannelMember(id: $id, peerId: $peerId) {
    id members { id status }
  }
}
mutation

removeChatChannelMember

अपने स्वामित्व वाले चैनल से एक सदस्य हटाएँ।

bash
mutation RemoveMember($id: ID!, $peerId: String!) {
  removeChatChannelMember(id: $id, peerId: $peerId) {
    id members { id status }
  }
}
mutation

acceptChatChannelInvite

आपको आमंत्रित किए गए चैनल में शामिल होने के निमंत्रण को स्वीकार करें।

bash
mutation AcceptChatChannelInvite($id: ID!) {
  acceptChatChannelInvite(id: $id)
}
mutation

declineChatChannelInvite

एक लंबित चैनल निमंत्रण को अस्वीकार करें।

bash
mutation DeclineChatChannelInvite($id: ID!) {
  declineChatChannelInvite(id: $id)
}