@inline-chat/realtime-sdk 0.0.3 → 0.0.4

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.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { InlineSdkClient } from "./sdk/inline-sdk-client.js";
2
- export type { InlineSdkClientOptions, InlineSdkSendMessageMedia, InlineSdkSendMessageParams, InlineSdkState, InlineSdkStateStore, InlineSdkUploadFileParams, InlineSdkUploadFileResult, InlineSdkUploadFileType, InlineInboundEvent, RpcInputForMethod, RpcResultForMethod, } from "./sdk/types.js";
2
+ export type { InlineSdkClientOptions, InlineSdkGetMessagesParams, InlineSdkSendMessageMedia, InlineSdkSendMessageParams, InlineSdkState, InlineSdkStateStore, InlineSdkUploadFileParams, InlineSdkUploadFileResult, InlineSdkUploadFileType, InlineInboundEvent, RpcInputForMethod, RpcResultForMethod, } from "./sdk/types.js";
3
3
  export type { InlineSdkLogger } from "./sdk/logger.js";
4
4
  export { JsonFileStateStore } from "./state/json-file-state-store.js";
5
5
  export { serializeStateV1, deserializeStateV1 } from "./state/serde.js";
@@ -1,6 +1,6 @@
1
- import { Method, type Peer, type RpcCall, type RpcResult } from "@inline-chat/protocol/core";
1
+ import { Method, type Message, type Peer, type RpcCall, type RpcResult } from "@inline-chat/protocol/core";
2
2
  import { type InlineIdLike } from "../ids.js";
3
- import type { InlineSdkClientOptions, InlineInboundEvent, InlineSdkSendMessageParams, InlineSdkState, InlineSdkUploadFileParams, InlineSdkUploadFileResult, MappedMethod, RpcInputForMethod, RpcResultForMethod } from "./types.js";
3
+ import type { InlineSdkClientOptions, InlineInboundEvent, InlineSdkGetMessagesParams, InlineSdkSendMessageParams, InlineSdkState, InlineSdkUploadFileParams, InlineSdkUploadFileResult, MappedMethod, RpcInputForMethod, RpcResultForMethod } from "./types.js";
4
4
  export declare class InlineSdkClient {
5
5
  private readonly options;
6
6
  private readonly log;
@@ -33,6 +33,9 @@ export declare class InlineSdkClient {
33
33
  peer?: Peer;
34
34
  title: string;
35
35
  }>;
36
+ getMessages(params: InlineSdkGetMessagesParams): Promise<{
37
+ messages: Message[];
38
+ }>;
36
39
  sendMessage(params: InlineSdkSendMessageParams): Promise<{
37
40
  messageId: bigint | null;
38
41
  }>;
@@ -1,4 +1,4 @@
1
- import { GetChatInput, GetMeInput, GetUpdatesInput, GetUpdatesResult_ResultType, GetUpdatesStateInput, InputPeer, MessageSendMode, Method, UpdateBucket, UpdateComposeAction_ComposeAction, } from "@inline-chat/protocol/core";
1
+ import { GetChatInput, GetMessagesInput, GetMeInput, GetUpdatesInput, GetUpdatesResult_ResultType, GetUpdatesStateInput, InputPeer, MessageSendMode, Method, UpdateBucket, UpdateComposeAction_ComposeAction, } from "@inline-chat/protocol/core";
2
2
  import { asInlineId } from "../ids.js";
3
3
  import { AsyncChannel } from "../utils/async-channel.js";
4
4
  import { ProtocolClient } from "../realtime/protocol-client.js";
@@ -147,6 +147,18 @@ export class InlineSdkClient {
147
147
  throw new Error("getChat: missing chat");
148
148
  return { chatId: chat.id, peer: chat.peerId, title: chat.title };
149
149
  }
150
+ async getMessages(params) {
151
+ const peerId = this.inputPeerFromTarget(params, "getMessages");
152
+ const messageIds = params.messageIds.map((messageId, index) => asInlineId(messageId, `messageIds[${index}]`));
153
+ const result = await this.invoke(Method.GET_MESSAGES, {
154
+ oneofKind: "getMessages",
155
+ getMessages: GetMessagesInput.create({
156
+ peerId,
157
+ messageIds,
158
+ }),
159
+ });
160
+ return { messages: result.getMessages.messages };
161
+ }
150
162
  async sendMessage(params) {
151
163
  if (params.entities != null && params.parseMarkdown != null) {
152
164
  throw new Error("sendMessage: provide either `entities` or `parseMarkdown`, not both");
@@ -41,6 +41,15 @@ export type InlineSdkSendMessageParams = {
41
41
  sendMode?: "silent";
42
42
  entities?: MessageEntities;
43
43
  };
44
+ export type InlineSdkGetMessagesParams = {
45
+ chatId: InlineIdLike;
46
+ userId?: never;
47
+ messageIds: InlineIdLike[];
48
+ } | {
49
+ userId: InlineIdLike;
50
+ chatId?: never;
51
+ messageIds: InlineIdLike[];
52
+ };
44
53
  export type InlineSdkBinaryInput = Blob | Uint8Array | ArrayBuffer | SharedArrayBuffer;
45
54
  export type InlineSdkUploadFileType = "photo" | "video" | "document";
46
55
  export type InlineSdkUploadFileParams = {
@@ -152,6 +161,9 @@ export declare const rpcInputKindByMethod: {
152
161
  readonly 33: "listBots";
153
162
  readonly 34: "revealBotToken";
154
163
  readonly 35: "moveThread";
164
+ readonly 36: "rotateBotToken";
165
+ readonly 37: "updateBotProfile";
166
+ readonly 38: "getMessages";
155
167
  };
156
168
  export declare const rpcResultKindByMethod: {
157
169
  readonly 0: undefined;
@@ -190,6 +202,9 @@ export declare const rpcResultKindByMethod: {
190
202
  readonly 33: "listBots";
191
203
  readonly 34: "revealBotToken";
192
204
  readonly 35: "moveThread";
205
+ readonly 36: "rotateBotToken";
206
+ readonly 37: "updateBotProfile";
207
+ readonly 38: "getMessages";
193
208
  };
194
209
  type RpcInputKindByMethod = typeof rpcInputKindByMethod;
195
210
  type RpcResultKindByMethod = typeof rpcResultKindByMethod;
package/dist/sdk/types.js CHANGED
@@ -35,6 +35,9 @@ export const rpcInputKindByMethod = {
35
35
  33: "listBots",
36
36
  34: "revealBotToken",
37
37
  35: "moveThread",
38
+ 36: "rotateBotToken",
39
+ 37: "updateBotProfile",
40
+ 38: "getMessages",
38
41
  };
39
42
  export const rpcResultKindByMethod = {
40
43
  0: undefined, // UNSPECIFIED
@@ -73,4 +76,7 @@ export const rpcResultKindByMethod = {
73
76
  33: "listBots",
74
77
  34: "revealBotToken",
75
78
  35: "moveThread",
79
+ 36: "rotateBotToken",
80
+ 37: "updateBotProfile",
81
+ 38: "getMessages",
76
82
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inline-chat/realtime-sdk",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "files": [
@@ -20,7 +20,7 @@
20
20
  "test": "vitest run --coverage"
21
21
  },
22
22
  "dependencies": {
23
- "@inline-chat/protocol": "^0.0.1",
23
+ "@inline-chat/protocol": "^0.0.2",
24
24
  "ws": "^8.18.3"
25
25
  },
26
26
  "devDependencies": {