@fragno-dev/telegram-fragment 0.0.1
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/LICENSE.md +16 -0
- package/README.md +87 -0
- package/dist/browser/client/react.d.ts +226 -0
- package/dist/browser/client/react.d.ts.map +1 -0
- package/dist/browser/client/react.js +166 -0
- package/dist/browser/client/react.js.map +1 -0
- package/dist/browser/client/solid.d.ts +228 -0
- package/dist/browser/client/solid.d.ts.map +1 -0
- package/dist/browser/client/solid.js +136 -0
- package/dist/browser/client/solid.js.map +1 -0
- package/dist/browser/client/svelte.d.ts +223 -0
- package/dist/browser/client/svelte.d.ts.map +1 -0
- package/dist/browser/client/svelte.js +134 -0
- package/dist/browser/client/svelte.js.map +1 -0
- package/dist/browser/client/vanilla.d.ts +252 -0
- package/dist/browser/client/vanilla.d.ts.map +1 -0
- package/dist/browser/client/vanilla.js +160 -0
- package/dist/browser/client/vanilla.js.map +1 -0
- package/dist/browser/client/vue.d.ts +226 -0
- package/dist/browser/client/vue.d.ts.map +1 -0
- package/dist/browser/client/vue.js +133 -0
- package/dist/browser/client/vue.js.map +1 -0
- package/dist/browser/client-Bk-J98pf.d.ts +679 -0
- package/dist/browser/client-Bk-J98pf.d.ts.map +1 -0
- package/dist/browser/index.d.ts +1392 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +24 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/schema-QDMf15Vn.js +2343 -0
- package/dist/browser/schema-QDMf15Vn.js.map +1 -0
- package/dist/node/command-handler-api.js +42 -0
- package/dist/node/command-handler-api.js.map +1 -0
- package/dist/node/definition.d.ts +194 -0
- package/dist/node/definition.d.ts.map +1 -0
- package/dist/node/definition.js +90 -0
- package/dist/node/definition.js.map +1 -0
- package/dist/node/index.d.ts +587 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +29 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/routes.d.ts +385 -0
- package/dist/node/routes.d.ts.map +1 -0
- package/dist/node/routes.js +392 -0
- package/dist/node/routes.js.map +1 -0
- package/dist/node/schema.d.ts +13 -0
- package/dist/node/schema.d.ts.map +1 -0
- package/dist/node/schema.js +78 -0
- package/dist/node/schema.js.map +1 -0
- package/dist/node/services.js +589 -0
- package/dist/node/services.js.map +1 -0
- package/dist/node/telegram-api.js +41 -0
- package/dist/node/telegram-api.js.map +1 -0
- package/dist/node/telegram-utils.js +61 -0
- package/dist/node/telegram-utils.js.map +1 -0
- package/dist/node/types.d.ts +245 -0
- package/dist/node/types.d.ts.map +1 -0
- package/dist/node/types.js +92 -0
- package/dist/node/types.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +96 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { TelegramChatMemberSummary, TelegramChatSummary, TelegramCommandScope, TelegramFragmentConfig, TelegramHooksMap, TelegramMessage, TelegramMessageSummary, TelegramUpdate, TelegramUpdateType, TelegramUserSummary } from "./types.js";
|
|
2
|
+
import * as _fragno_dev_core0 from "@fragno-dev/core";
|
|
3
|
+
import * as _fragno_dev_db0 from "@fragno-dev/db";
|
|
4
|
+
import * as _fragno_dev_db_schema0 from "@fragno-dev/db/schema";
|
|
5
|
+
import * as _fragno_dev_db_fragment_definition_builder0 from "@fragno-dev/db/fragment-definition-builder";
|
|
6
|
+
|
|
7
|
+
//#region src/definition.d.ts
|
|
8
|
+
declare const telegramFragmentDefinition: _fragno_dev_core0.FragmentDefinition<TelegramFragmentConfig, _fragno_dev_db0.FragnoPublicConfigWithDatabase, _fragno_dev_db0.ImplicitDatabaseDependencies<_fragno_dev_db_schema0.Schema<{
|
|
9
|
+
user: _fragno_dev_db_schema0.Table<Record<"id", _fragno_dev_db_schema0.IdColumn<"varchar(128)", string | _fragno_dev_db_schema0.FragnoId | null, _fragno_dev_db_schema0.FragnoId>> & Record<"username", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"firstName", _fragno_dev_db_schema0.Column<"string", string, string>> & Record<"lastName", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"isBot", _fragno_dev_db_schema0.Column<"bool", boolean | null, boolean>> & Record<"languageCode", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"createdAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date>> & Record<"updatedAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date>>, Record<string, _fragno_dev_db_schema0.AnyRelation>, Record<string, _fragno_dev_db_schema0.Index<_fragno_dev_db_schema0.AnyColumn[], readonly string[]>> & Record<"idx_user_username", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"string", string | null, string | null>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["username"]>>>;
|
|
10
|
+
chat: _fragno_dev_db_schema0.Table<Record<"id", _fragno_dev_db_schema0.IdColumn<"varchar(128)", string | _fragno_dev_db_schema0.FragnoId | null, _fragno_dev_db_schema0.FragnoId>> & Record<"type", _fragno_dev_db_schema0.Column<"string", string, string>> & Record<"title", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"username", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"isForum", _fragno_dev_db_schema0.Column<"bool", boolean | null, boolean>> & Record<"commandBindings", _fragno_dev_db_schema0.Column<"json", unknown, unknown>> & Record<"createdAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date>> & Record<"updatedAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date>>, Record<string, _fragno_dev_db_schema0.AnyRelation>, Record<string, _fragno_dev_db_schema0.Index<_fragno_dev_db_schema0.AnyColumn[], readonly string[]>> & Record<"idx_chat_type", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"string", string, string>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["type"]>>>;
|
|
11
|
+
chatMember: _fragno_dev_db_schema0.Table<Record<"id", _fragno_dev_db_schema0.IdColumn<"varchar(128)", string | _fragno_dev_db_schema0.FragnoId | null, _fragno_dev_db_schema0.FragnoId>> & Record<"chatId", _fragno_dev_db_schema0.Column<"bigint", string | bigint | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference, _fragno_dev_db_schema0.FragnoReference>> & Record<"userId", _fragno_dev_db_schema0.Column<"bigint", string | bigint | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference, _fragno_dev_db_schema0.FragnoReference>> & Record<"status", _fragno_dev_db_schema0.Column<"string", string, string>> & Record<"joinedAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date | null>> & Record<"leftAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date | null>> & Record<"createdAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date>> & Record<"updatedAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date>>, Record<string, _fragno_dev_db_schema0.AnyRelation> & Record<"chatMemberChat", _fragno_dev_db_schema0.Relation<"one", _fragno_dev_db_schema0.Table<Record<"id", _fragno_dev_db_schema0.IdColumn<"varchar(128)", string | _fragno_dev_db_schema0.FragnoId | null, _fragno_dev_db_schema0.FragnoId>> & Record<"type", _fragno_dev_db_schema0.Column<"string", string, string>> & Record<"title", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"username", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"isForum", _fragno_dev_db_schema0.Column<"bool", boolean | null, boolean>> & Record<"commandBindings", _fragno_dev_db_schema0.Column<"json", unknown, unknown>> & Record<"createdAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date>> & Record<"updatedAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date>>, Record<string, _fragno_dev_db_schema0.AnyRelation>, Record<string, _fragno_dev_db_schema0.Index<_fragno_dev_db_schema0.AnyColumn[], readonly string[]>> & Record<"idx_chat_type", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"string", string, string>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["type"]>>>>> & Record<"chatMemberUser", _fragno_dev_db_schema0.Relation<"one", _fragno_dev_db_schema0.Table<Record<"id", _fragno_dev_db_schema0.IdColumn<"varchar(128)", string | _fragno_dev_db_schema0.FragnoId | null, _fragno_dev_db_schema0.FragnoId>> & Record<"username", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"firstName", _fragno_dev_db_schema0.Column<"string", string, string>> & Record<"lastName", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"isBot", _fragno_dev_db_schema0.Column<"bool", boolean | null, boolean>> & Record<"languageCode", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"createdAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date>> & Record<"updatedAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date>>, Record<string, _fragno_dev_db_schema0.AnyRelation>, Record<string, _fragno_dev_db_schema0.Index<_fragno_dev_db_schema0.AnyColumn[], readonly string[]>> & Record<"idx_user_username", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"string", string | null, string | null>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["username"]>>>>>, Record<string, _fragno_dev_db_schema0.Index<_fragno_dev_db_schema0.AnyColumn[], readonly string[]>> & Record<"idx_chat_member_chat", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"bigint", string | bigint | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference, _fragno_dev_db_schema0.FragnoReference>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["chatId"]>> & Record<"idx_chat_member_user", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"bigint", string | bigint | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference, _fragno_dev_db_schema0.FragnoReference>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["userId"]>> & Record<"idx_chat_member_unique", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"bigint", string | bigint | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference, _fragno_dev_db_schema0.FragnoReference>, _fragno_dev_db_schema0.Column<"bigint", string | bigint | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference, _fragno_dev_db_schema0.FragnoReference>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["chatId", "userId"]>>>;
|
|
12
|
+
message: _fragno_dev_db_schema0.Table<Record<"id", _fragno_dev_db_schema0.IdColumn<"varchar(128)", string | _fragno_dev_db_schema0.FragnoId | null, _fragno_dev_db_schema0.FragnoId>> & Record<"chatId", _fragno_dev_db_schema0.Column<"bigint", string | bigint | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference, _fragno_dev_db_schema0.FragnoReference>> & Record<"fromUserId", _fragno_dev_db_schema0.Column<"bigint", string | bigint | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference | null, _fragno_dev_db_schema0.FragnoReference | null>> & Record<"senderChatId", _fragno_dev_db_schema0.Column<"bigint", string | bigint | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference | null, _fragno_dev_db_schema0.FragnoReference | null>> & Record<"replyToMessageId", _fragno_dev_db_schema0.Column<"bigint", string | bigint | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference | null, _fragno_dev_db_schema0.FragnoReference | null>> & Record<"messageType", _fragno_dev_db_schema0.Column<"string", string, string>> & Record<"text", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"payload", _fragno_dev_db_schema0.Column<"json", unknown, unknown>> & Record<"sentAt", _fragno_dev_db_schema0.Column<"timestamp", Date | _fragno_dev_db0.DbNow, Date>> & Record<"editedAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date | null>> & Record<"commandName", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"createdAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date>>, Record<string, _fragno_dev_db_schema0.AnyRelation> & Record<"messageChat", _fragno_dev_db_schema0.Relation<"one", _fragno_dev_db_schema0.Table<Record<"id", _fragno_dev_db_schema0.IdColumn<"varchar(128)", string | _fragno_dev_db_schema0.FragnoId | null, _fragno_dev_db_schema0.FragnoId>> & Record<"type", _fragno_dev_db_schema0.Column<"string", string, string>> & Record<"title", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"username", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"isForum", _fragno_dev_db_schema0.Column<"bool", boolean | null, boolean>> & Record<"commandBindings", _fragno_dev_db_schema0.Column<"json", unknown, unknown>> & Record<"createdAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date>> & Record<"updatedAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date>>, Record<string, _fragno_dev_db_schema0.AnyRelation>, Record<string, _fragno_dev_db_schema0.Index<_fragno_dev_db_schema0.AnyColumn[], readonly string[]>> & Record<"idx_chat_type", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"string", string, string>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["type"]>>>>> & Record<"messageAuthor", _fragno_dev_db_schema0.Relation<"one", _fragno_dev_db_schema0.Table<Record<"id", _fragno_dev_db_schema0.IdColumn<"varchar(128)", string | _fragno_dev_db_schema0.FragnoId | null, _fragno_dev_db_schema0.FragnoId>> & Record<"username", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"firstName", _fragno_dev_db_schema0.Column<"string", string, string>> & Record<"lastName", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"isBot", _fragno_dev_db_schema0.Column<"bool", boolean | null, boolean>> & Record<"languageCode", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"createdAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date>> & Record<"updatedAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date>>, Record<string, _fragno_dev_db_schema0.AnyRelation>, Record<string, _fragno_dev_db_schema0.Index<_fragno_dev_db_schema0.AnyColumn[], readonly string[]>> & Record<"idx_user_username", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"string", string | null, string | null>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["username"]>>>>> & Record<"messageSenderChat", _fragno_dev_db_schema0.Relation<"one", _fragno_dev_db_schema0.Table<Record<"id", _fragno_dev_db_schema0.IdColumn<"varchar(128)", string | _fragno_dev_db_schema0.FragnoId | null, _fragno_dev_db_schema0.FragnoId>> & Record<"type", _fragno_dev_db_schema0.Column<"string", string, string>> & Record<"title", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"username", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"isForum", _fragno_dev_db_schema0.Column<"bool", boolean | null, boolean>> & Record<"commandBindings", _fragno_dev_db_schema0.Column<"json", unknown, unknown>> & Record<"createdAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date>> & Record<"updatedAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date>>, Record<string, _fragno_dev_db_schema0.AnyRelation>, Record<string, _fragno_dev_db_schema0.Index<_fragno_dev_db_schema0.AnyColumn[], readonly string[]>> & Record<"idx_chat_type", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"string", string, string>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["type"]>>>>> & Record<"messageReplyTo", _fragno_dev_db_schema0.Relation<"one", _fragno_dev_db_schema0.Table<Record<"id", _fragno_dev_db_schema0.IdColumn<"varchar(128)", string | _fragno_dev_db_schema0.FragnoId | null, _fragno_dev_db_schema0.FragnoId>> & Record<"chatId", _fragno_dev_db_schema0.Column<"bigint", string | bigint | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference, _fragno_dev_db_schema0.FragnoReference>> & Record<"fromUserId", _fragno_dev_db_schema0.Column<"bigint", string | bigint | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference | null, _fragno_dev_db_schema0.FragnoReference | null>> & Record<"senderChatId", _fragno_dev_db_schema0.Column<"bigint", string | bigint | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference | null, _fragno_dev_db_schema0.FragnoReference | null>> & Record<"replyToMessageId", _fragno_dev_db_schema0.Column<"bigint", string | bigint | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference | null, _fragno_dev_db_schema0.FragnoReference | null>> & Record<"messageType", _fragno_dev_db_schema0.Column<"string", string, string>> & Record<"text", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"payload", _fragno_dev_db_schema0.Column<"json", unknown, unknown>> & Record<"sentAt", _fragno_dev_db_schema0.Column<"timestamp", Date | _fragno_dev_db0.DbNow, Date>> & Record<"editedAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date | null>> & Record<"commandName", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"createdAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date>>, Record<string, _fragno_dev_db_schema0.AnyRelation> & Record<"messageChat", _fragno_dev_db_schema0.Relation<"one", _fragno_dev_db_schema0.Table<Record<"id", _fragno_dev_db_schema0.IdColumn<"varchar(128)", string | _fragno_dev_db_schema0.FragnoId | null, _fragno_dev_db_schema0.FragnoId>> & Record<"type", _fragno_dev_db_schema0.Column<"string", string, string>> & Record<"title", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"username", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"isForum", _fragno_dev_db_schema0.Column<"bool", boolean | null, boolean>> & Record<"commandBindings", _fragno_dev_db_schema0.Column<"json", unknown, unknown>> & Record<"createdAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date>> & Record<"updatedAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date>>, Record<string, _fragno_dev_db_schema0.AnyRelation>, Record<string, _fragno_dev_db_schema0.Index<_fragno_dev_db_schema0.AnyColumn[], readonly string[]>> & Record<"idx_chat_type", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"string", string, string>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["type"]>>>>> & Record<"messageAuthor", _fragno_dev_db_schema0.Relation<"one", _fragno_dev_db_schema0.Table<Record<"id", _fragno_dev_db_schema0.IdColumn<"varchar(128)", string | _fragno_dev_db_schema0.FragnoId | null, _fragno_dev_db_schema0.FragnoId>> & Record<"username", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"firstName", _fragno_dev_db_schema0.Column<"string", string, string>> & Record<"lastName", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"isBot", _fragno_dev_db_schema0.Column<"bool", boolean | null, boolean>> & Record<"languageCode", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"createdAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date>> & Record<"updatedAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date>>, Record<string, _fragno_dev_db_schema0.AnyRelation>, Record<string, _fragno_dev_db_schema0.Index<_fragno_dev_db_schema0.AnyColumn[], readonly string[]>> & Record<"idx_user_username", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"string", string | null, string | null>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["username"]>>>>> & Record<"messageSenderChat", _fragno_dev_db_schema0.Relation<"one", _fragno_dev_db_schema0.Table<Record<"id", _fragno_dev_db_schema0.IdColumn<"varchar(128)", string | _fragno_dev_db_schema0.FragnoId | null, _fragno_dev_db_schema0.FragnoId>> & Record<"type", _fragno_dev_db_schema0.Column<"string", string, string>> & Record<"title", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"username", _fragno_dev_db_schema0.Column<"string", string | null, string | null>> & Record<"isForum", _fragno_dev_db_schema0.Column<"bool", boolean | null, boolean>> & Record<"commandBindings", _fragno_dev_db_schema0.Column<"json", unknown, unknown>> & Record<"createdAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date>> & Record<"updatedAt", _fragno_dev_db_schema0.Column<"timestamp", (Date | _fragno_dev_db0.DbNow) | null, Date>>, Record<string, _fragno_dev_db_schema0.AnyRelation>, Record<string, _fragno_dev_db_schema0.Index<_fragno_dev_db_schema0.AnyColumn[], readonly string[]>> & Record<"idx_chat_type", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"string", string, string>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["type"]>>>>>, Record<string, _fragno_dev_db_schema0.Index<_fragno_dev_db_schema0.AnyColumn[], readonly string[]>> & Record<"idx_message_chat", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"bigint", string | bigint | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference, _fragno_dev_db_schema0.FragnoReference>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["chatId"]>> & Record<"idx_message_chat_sent", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"bigint", string | bigint | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference, _fragno_dev_db_schema0.FragnoReference>, _fragno_dev_db_schema0.Column<"timestamp", Date | _fragno_dev_db0.DbNow, Date>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["chatId", "sentAt"]>> & Record<"idx_message_from", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"bigint", string | bigint | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference | null, _fragno_dev_db_schema0.FragnoReference | null>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["fromUserId"]>> & Record<"idx_message_sent", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"timestamp", Date | _fragno_dev_db0.DbNow, Date>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["sentAt"]>>>>>, Record<string, _fragno_dev_db_schema0.Index<_fragno_dev_db_schema0.AnyColumn[], readonly string[]>> & Record<"idx_message_chat", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"bigint", string | bigint | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference, _fragno_dev_db_schema0.FragnoReference>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["chatId"]>> & Record<"idx_message_chat_sent", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"bigint", string | bigint | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference, _fragno_dev_db_schema0.FragnoReference>, _fragno_dev_db_schema0.Column<"timestamp", Date | _fragno_dev_db0.DbNow, Date>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["chatId", "sentAt"]>> & Record<"idx_message_from", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"bigint", string | bigint | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference | null, _fragno_dev_db_schema0.FragnoReference | null>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["fromUserId"]>> & Record<"idx_message_sent", _fragno_dev_db_schema0.Index<readonly [_fragno_dev_db_schema0.Column<"timestamp", Date | _fragno_dev_db0.DbNow, Date>] & _fragno_dev_db_schema0.AnyColumn[], readonly ["sentAt"]>>>;
|
|
13
|
+
}>>, {
|
|
14
|
+
processIncomingUpdate: (this: _fragno_dev_db0.DatabaseServiceContext<TelegramHooksMap>, update: TelegramUpdate) => _fragno_dev_db0.TxResult<{
|
|
15
|
+
kind: "ignored";
|
|
16
|
+
updateId: number;
|
|
17
|
+
}, {
|
|
18
|
+
kind: "ignored";
|
|
19
|
+
updateId: number;
|
|
20
|
+
}> | _fragno_dev_db0.TxResult<{
|
|
21
|
+
kind: "ignored";
|
|
22
|
+
updateId: number;
|
|
23
|
+
} | {
|
|
24
|
+
kind: "message";
|
|
25
|
+
updateId: number;
|
|
26
|
+
updateType: TelegramMessageSummary["messageType"];
|
|
27
|
+
chat: TelegramChatSummary;
|
|
28
|
+
message: TelegramMessageSummary;
|
|
29
|
+
fromUser: TelegramUserSummary | null;
|
|
30
|
+
command: {
|
|
31
|
+
name: string;
|
|
32
|
+
args: string;
|
|
33
|
+
raw: string;
|
|
34
|
+
scopes: TelegramCommandScope[];
|
|
35
|
+
} | null;
|
|
36
|
+
}, [{
|
|
37
|
+
id: string | _fragno_dev_db_schema0.FragnoId;
|
|
38
|
+
type: string;
|
|
39
|
+
title: string | null;
|
|
40
|
+
username: string | null;
|
|
41
|
+
isForum: boolean;
|
|
42
|
+
commandBindings: unknown | null;
|
|
43
|
+
createdAt: Date;
|
|
44
|
+
updatedAt: Date;
|
|
45
|
+
}[], {
|
|
46
|
+
id: string | _fragno_dev_db_schema0.FragnoId;
|
|
47
|
+
username: string | null;
|
|
48
|
+
firstName: string;
|
|
49
|
+
lastName: string | null;
|
|
50
|
+
isBot: boolean;
|
|
51
|
+
languageCode: string | null;
|
|
52
|
+
createdAt: Date;
|
|
53
|
+
updatedAt: Date;
|
|
54
|
+
}[], {
|
|
55
|
+
id: string | _fragno_dev_db_schema0.FragnoId;
|
|
56
|
+
chatId: string | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference;
|
|
57
|
+
userId: string | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference;
|
|
58
|
+
status: string;
|
|
59
|
+
joinedAt: Date | null;
|
|
60
|
+
leftAt: Date | null;
|
|
61
|
+
createdAt: Date;
|
|
62
|
+
updatedAt: Date;
|
|
63
|
+
chatMemberUser?: {
|
|
64
|
+
id: string | _fragno_dev_db_schema0.FragnoId;
|
|
65
|
+
username: string | null;
|
|
66
|
+
firstName: string;
|
|
67
|
+
lastName: string | null;
|
|
68
|
+
isBot: boolean;
|
|
69
|
+
languageCode: string | null;
|
|
70
|
+
createdAt: Date;
|
|
71
|
+
updatedAt: Date;
|
|
72
|
+
} | null;
|
|
73
|
+
}[], {
|
|
74
|
+
id: string | _fragno_dev_db_schema0.FragnoId;
|
|
75
|
+
chatId: string | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference;
|
|
76
|
+
fromUserId: (string | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference) | null;
|
|
77
|
+
senderChatId: (string | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference) | null;
|
|
78
|
+
replyToMessageId: (string | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference) | null;
|
|
79
|
+
messageType: string;
|
|
80
|
+
text: string | null;
|
|
81
|
+
payload: unknown | null;
|
|
82
|
+
sentAt: Date;
|
|
83
|
+
editedAt: Date | null;
|
|
84
|
+
commandName: string | null;
|
|
85
|
+
messageAuthor?: {
|
|
86
|
+
id: string | _fragno_dev_db_schema0.FragnoId;
|
|
87
|
+
username: string | null;
|
|
88
|
+
firstName: string;
|
|
89
|
+
lastName: string | null;
|
|
90
|
+
isBot: boolean;
|
|
91
|
+
languageCode: string | null;
|
|
92
|
+
createdAt: Date;
|
|
93
|
+
updatedAt: Date;
|
|
94
|
+
} | null;
|
|
95
|
+
} | null]>;
|
|
96
|
+
bindCommand: (this: _fragno_dev_db0.DatabaseServiceContext<TelegramHooksMap>, input: {
|
|
97
|
+
chatId: string;
|
|
98
|
+
commandName: string;
|
|
99
|
+
enabled: boolean;
|
|
100
|
+
scopes?: TelegramCommandScope[];
|
|
101
|
+
}) => _fragno_dev_db0.TxResult<{
|
|
102
|
+
ok: false;
|
|
103
|
+
reason: "chat_not_found";
|
|
104
|
+
binding?: undefined;
|
|
105
|
+
} | {
|
|
106
|
+
ok: true;
|
|
107
|
+
binding: {
|
|
108
|
+
chatId: string;
|
|
109
|
+
commandName: string;
|
|
110
|
+
enabled: boolean;
|
|
111
|
+
scopes: ("private" | "group" | "supergroup" | "channel")[] | undefined;
|
|
112
|
+
};
|
|
113
|
+
reason?: undefined;
|
|
114
|
+
}, [{
|
|
115
|
+
id: _fragno_dev_db_schema0.FragnoId;
|
|
116
|
+
type: string;
|
|
117
|
+
title: string | null;
|
|
118
|
+
username: string | null;
|
|
119
|
+
isForum: boolean;
|
|
120
|
+
commandBindings: unknown;
|
|
121
|
+
createdAt: Date;
|
|
122
|
+
updatedAt: Date;
|
|
123
|
+
} | null]>;
|
|
124
|
+
listChats: (this: _fragno_dev_db0.DatabaseServiceContext<TelegramHooksMap>, type?: TelegramChatSummary["type"]) => _fragno_dev_db0.TxResult<TelegramChatSummary[], TelegramChatSummary[]>;
|
|
125
|
+
getChat: (this: _fragno_dev_db0.DatabaseServiceContext<TelegramHooksMap>, chatId: string) => _fragno_dev_db0.TxResult<TelegramChatSummary | null, TelegramChatSummary | null>;
|
|
126
|
+
getChatWithMembers: (this: _fragno_dev_db0.DatabaseServiceContext<TelegramHooksMap>, chatId: string) => _fragno_dev_db0.TxResult<{
|
|
127
|
+
chat: TelegramChatSummary | null;
|
|
128
|
+
members: TelegramChatMemberSummary[];
|
|
129
|
+
}, {
|
|
130
|
+
chat: TelegramChatSummary | null;
|
|
131
|
+
members: TelegramChatMemberSummary[];
|
|
132
|
+
}>;
|
|
133
|
+
listMessages: (this: _fragno_dev_db0.DatabaseServiceContext<TelegramHooksMap>, input: {
|
|
134
|
+
chatId: string;
|
|
135
|
+
pageSize: number;
|
|
136
|
+
order: "asc" | "desc";
|
|
137
|
+
cursor?: _fragno_dev_db0.Cursor;
|
|
138
|
+
}) => _fragno_dev_db0.TxResult<{
|
|
139
|
+
messages: TelegramMessageSummary[];
|
|
140
|
+
cursor: _fragno_dev_db0.Cursor | undefined;
|
|
141
|
+
hasNextPage: boolean;
|
|
142
|
+
}, {
|
|
143
|
+
messages: TelegramMessageSummary[];
|
|
144
|
+
cursor: _fragno_dev_db0.Cursor | undefined;
|
|
145
|
+
hasNextPage: boolean;
|
|
146
|
+
}>;
|
|
147
|
+
upsertOutgoingMessage: (this: _fragno_dev_db0.DatabaseServiceContext<TelegramHooksMap>, input: {
|
|
148
|
+
message: TelegramMessage;
|
|
149
|
+
messageType: TelegramUpdateType;
|
|
150
|
+
}) => _fragno_dev_db0.TxResult<void, [{
|
|
151
|
+
id: string | _fragno_dev_db_schema0.FragnoId;
|
|
152
|
+
type: string;
|
|
153
|
+
title: string | null;
|
|
154
|
+
username: string | null;
|
|
155
|
+
isForum: boolean;
|
|
156
|
+
commandBindings: unknown | null;
|
|
157
|
+
createdAt: Date;
|
|
158
|
+
updatedAt: Date;
|
|
159
|
+
}[], {
|
|
160
|
+
id: string | _fragno_dev_db_schema0.FragnoId;
|
|
161
|
+
username: string | null;
|
|
162
|
+
firstName: string;
|
|
163
|
+
lastName: string | null;
|
|
164
|
+
isBot: boolean;
|
|
165
|
+
languageCode: string | null;
|
|
166
|
+
createdAt: Date;
|
|
167
|
+
updatedAt: Date;
|
|
168
|
+
}[], {
|
|
169
|
+
id: string | _fragno_dev_db_schema0.FragnoId;
|
|
170
|
+
chatId: string | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference;
|
|
171
|
+
fromUserId: (string | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference) | null;
|
|
172
|
+
senderChatId: (string | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference) | null;
|
|
173
|
+
replyToMessageId: (string | _fragno_dev_db_schema0.FragnoId | _fragno_dev_db_schema0.FragnoReference) | null;
|
|
174
|
+
messageType: string;
|
|
175
|
+
text: string | null;
|
|
176
|
+
payload: unknown | null;
|
|
177
|
+
sentAt: Date;
|
|
178
|
+
editedAt: Date | null;
|
|
179
|
+
commandName: string | null;
|
|
180
|
+
messageAuthor?: {
|
|
181
|
+
id: string | _fragno_dev_db_schema0.FragnoId;
|
|
182
|
+
username: string | null;
|
|
183
|
+
firstName: string;
|
|
184
|
+
lastName: string | null;
|
|
185
|
+
isBot: boolean;
|
|
186
|
+
languageCode: string | null;
|
|
187
|
+
createdAt: Date;
|
|
188
|
+
updatedAt: Date;
|
|
189
|
+
} | null;
|
|
190
|
+
} | null]>;
|
|
191
|
+
}, {}, {}, {}, _fragno_dev_db0.DatabaseServiceContext<TelegramHooksMap>, _fragno_dev_db0.DatabaseRequestContext<TelegramHooksMap>, _fragno_dev_db_fragment_definition_builder0.DatabaseRequestStorage, []>;
|
|
192
|
+
//#endregion
|
|
193
|
+
export { telegramFragmentDefinition };
|
|
194
|
+
//# sourceMappingURL=definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.d.ts","names":[],"sources":["../../src/definition.ts"],"mappings":";;;;;;;cAca,0BAAA,oBAA0B,kBAAA,CAAA,sBAAA,EAAA,eAAA,CAAA,8BAAA,EAAA,eAAA,CAAA,4BAAA,wBAAA,MAAA;2GAAA,sBAAA,CAAA,QAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA4H4rsB,sBAAA,CAAA,QAAA;;;;;;;;;;;;;;;;;;;;;;6BAAszF,MAAA;EAAA;cAAA,sBAAA"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { telegramSchema } from "./schema.js";
|
|
2
|
+
import { createCommandHandlerApi } from "./command-handler-api.js";
|
|
3
|
+
import { parseTelegramUpdate } from "./telegram-utils.js";
|
|
4
|
+
import { createProcessIncomingUpdateOps, createTelegramServices, createUpsertOutgoingMessageOps } from "./services.js";
|
|
5
|
+
import { createTelegramApi } from "./telegram-api.js";
|
|
6
|
+
import { defineFragment } from "@fragno-dev/core";
|
|
7
|
+
import { ExponentialBackoffRetryPolicy, withDatabase } from "@fragno-dev/db";
|
|
8
|
+
|
|
9
|
+
//#region src/definition.ts
|
|
10
|
+
const telegramFragmentDefinition = defineFragment("telegram-fragment").extend(withDatabase(telegramSchema)).providesBaseService(({ defineService, config }) => defineService({ ...createTelegramServices(config) })).provideHooks(({ defineHook, config }) => {
|
|
11
|
+
const api = createTelegramApi(config);
|
|
12
|
+
const hooks = config.hooks;
|
|
13
|
+
const buildProcessIncomingUpdateOps = createProcessIncomingUpdateOps(config);
|
|
14
|
+
return {
|
|
15
|
+
internalOutgoingMessage: defineHook(async function(payload) {
|
|
16
|
+
const messageType = payload.action === "editMessageText" ? "edited_message" : "message";
|
|
17
|
+
const result = payload.action === "editMessageText" ? await api.editMessageText(payload.payload) : await api.sendMessage(payload.payload);
|
|
18
|
+
if (!result.ok) throw new Error(result.description ?? "Telegram API error");
|
|
19
|
+
try {
|
|
20
|
+
const ops = createUpsertOutgoingMessageOps({
|
|
21
|
+
message: result.result,
|
|
22
|
+
messageType
|
|
23
|
+
});
|
|
24
|
+
await this.handlerTx().retrieve(({ forSchema }) => ops.retrieve(forSchema(telegramSchema))).mutate(({ forSchema, retrieveResult }) => ops.mutate({
|
|
25
|
+
uow: forSchema(telegramSchema),
|
|
26
|
+
retrieveResult
|
|
27
|
+
})).execute();
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error("telegram outgoing message persist error", error);
|
|
30
|
+
}
|
|
31
|
+
}),
|
|
32
|
+
internalProcessUpdate: defineHook(async function({ update }) {
|
|
33
|
+
const ops = buildProcessIncomingUpdateOps(update);
|
|
34
|
+
const result = ops.kind === "ignored" ? ops : await this.handlerTx({ retryPolicy: new ExponentialBackoffRetryPolicy({
|
|
35
|
+
maxRetries: 5,
|
|
36
|
+
initialDelayMs: 10,
|
|
37
|
+
maxDelayMs: 250
|
|
38
|
+
}) }).retrieve(({ forSchema }) => ops.retrieve(forSchema(telegramSchema))).mutate(({ forSchema, retrieveResult }) => ops.mutate({
|
|
39
|
+
uow: forSchema(telegramSchema),
|
|
40
|
+
retrieveResult
|
|
41
|
+
})).transform(({ mutateResult }) => mutateResult).execute();
|
|
42
|
+
if (result.kind !== "message" || !result.command) return;
|
|
43
|
+
const parsed = parseTelegramUpdate(update);
|
|
44
|
+
if (!parsed) return;
|
|
45
|
+
const definition = (config.commands ?? {})[result.command.name];
|
|
46
|
+
if (!definition) return;
|
|
47
|
+
const { api: handlerApi, flush } = createCommandHandlerApi(api, this.handlerTx);
|
|
48
|
+
let handlerError;
|
|
49
|
+
try {
|
|
50
|
+
await definition.handler({
|
|
51
|
+
updateId: result.updateId,
|
|
52
|
+
idempotencyKey: this.idempotencyKey,
|
|
53
|
+
update,
|
|
54
|
+
message: parsed.message,
|
|
55
|
+
chat: result.chat,
|
|
56
|
+
fromUser: result.fromUser,
|
|
57
|
+
command: {
|
|
58
|
+
name: result.command.name,
|
|
59
|
+
args: result.command.args,
|
|
60
|
+
raw: result.command.raw
|
|
61
|
+
},
|
|
62
|
+
api: handlerApi,
|
|
63
|
+
handlerTx: this.handlerTx
|
|
64
|
+
});
|
|
65
|
+
} catch (error) {
|
|
66
|
+
handlerError = error;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
await flush();
|
|
70
|
+
} catch (error) {
|
|
71
|
+
if (!handlerError) throw error;
|
|
72
|
+
console.error("telegram outgoing message enqueue error", error);
|
|
73
|
+
}
|
|
74
|
+
if (handlerError) throw handlerError;
|
|
75
|
+
}),
|
|
76
|
+
onMessageReceived: defineHook(async function(payload) {
|
|
77
|
+
await hooks?.onMessageReceived?.(payload);
|
|
78
|
+
}),
|
|
79
|
+
onCommandMatched: defineHook(async function(payload) {
|
|
80
|
+
await hooks?.onCommandMatched?.(payload);
|
|
81
|
+
}),
|
|
82
|
+
onChatMemberUpdated: defineHook(async function(payload) {
|
|
83
|
+
await hooks?.onChatMemberUpdated?.(payload);
|
|
84
|
+
})
|
|
85
|
+
};
|
|
86
|
+
}).build();
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
export { telegramFragmentDefinition };
|
|
90
|
+
//# sourceMappingURL=definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.js","names":[],"sources":["../../src/definition.ts"],"sourcesContent":["import { defineFragment } from \"@fragno-dev/core\";\nimport { ExponentialBackoffRetryPolicy, withDatabase } from \"@fragno-dev/db\";\n\nimport { createCommandHandlerApi } from \"./command-handler-api\";\nimport { telegramSchema } from \"./schema\";\nimport {\n createProcessIncomingUpdateOps,\n createTelegramServices,\n createUpsertOutgoingMessageOps,\n} from \"./services\";\nimport { createTelegramApi } from \"./telegram-api\";\nimport { parseTelegramUpdate } from \"./telegram-utils\";\nimport type { TelegramFragmentConfig, TelegramHooksMap } from \"./types\";\n\nexport const telegramFragmentDefinition = defineFragment<TelegramFragmentConfig>(\n \"telegram-fragment\",\n)\n .extend(withDatabase(telegramSchema))\n .providesBaseService(({ defineService, config }) =>\n defineService({\n ...createTelegramServices(config),\n }),\n )\n .provideHooks<TelegramHooksMap>(({ defineHook, config }) => {\n const api = createTelegramApi(config);\n const hooks = config.hooks;\n const buildProcessIncomingUpdateOps = createProcessIncomingUpdateOps(config);\n\n return {\n internalOutgoingMessage: defineHook(async function (payload) {\n const messageType = payload.action === \"editMessageText\" ? \"edited_message\" : \"message\";\n const result =\n payload.action === \"editMessageText\"\n ? await api.editMessageText(payload.payload)\n : await api.sendMessage(payload.payload);\n\n if (!result.ok) {\n throw new Error(result.description ?? \"Telegram API error\");\n }\n\n // NOTE: Avoid throwing after the API call to minimize duplicate sends on retries.\n // TODO: Add a placeholder/intent record so we can keep the API call last without\n // risking a missing message record on persistence failures.\n try {\n const ops = createUpsertOutgoingMessageOps({\n message: result.result,\n messageType,\n });\n await this.handlerTx()\n .retrieve(({ forSchema }) => ops.retrieve(forSchema(telegramSchema)))\n .mutate(({ forSchema, retrieveResult }) =>\n ops.mutate({ uow: forSchema(telegramSchema), retrieveResult }),\n )\n .execute();\n } catch (error) {\n console.error(\"telegram outgoing message persist error\", error);\n }\n }),\n internalProcessUpdate: defineHook(async function ({ update }) {\n const ops = buildProcessIncomingUpdateOps(update);\n const result =\n ops.kind === \"ignored\"\n ? ops\n : await this.handlerTx({\n retryPolicy: new ExponentialBackoffRetryPolicy({\n maxRetries: 5,\n initialDelayMs: 10,\n maxDelayMs: 250,\n }),\n })\n .retrieve(({ forSchema }) => ops.retrieve(forSchema(telegramSchema)))\n .mutate(({ forSchema, retrieveResult }) =>\n ops.mutate({ uow: forSchema(telegramSchema), retrieveResult }),\n )\n .transform(({ mutateResult }) => mutateResult)\n .execute();\n\n if (result.kind !== \"message\" || !result.command) {\n return;\n }\n\n const parsed = parseTelegramUpdate(update);\n if (!parsed) {\n return;\n }\n\n const definition = (config.commands ?? {})[result.command.name];\n if (!definition) {\n return;\n }\n\n const { api: handlerApi, flush } = createCommandHandlerApi(api, this.handlerTx);\n let handlerError: unknown;\n try {\n await definition.handler({\n updateId: result.updateId,\n idempotencyKey: this.idempotencyKey,\n update,\n message: parsed.message,\n chat: result.chat,\n fromUser: result.fromUser,\n command: {\n name: result.command.name,\n args: result.command.args,\n raw: result.command.raw,\n },\n api: handlerApi,\n handlerTx: this.handlerTx,\n });\n } catch (error) {\n handlerError = error;\n }\n\n try {\n await flush();\n } catch (error) {\n if (!handlerError) {\n throw error;\n }\n console.error(\"telegram outgoing message enqueue error\", error);\n }\n\n if (handlerError) {\n throw handlerError;\n }\n }),\n onMessageReceived: defineHook(async function (payload) {\n await hooks?.onMessageReceived?.(payload);\n }),\n onCommandMatched: defineHook(async function (payload) {\n await hooks?.onCommandMatched?.(payload);\n }),\n onChatMemberUpdated: defineHook(async function (payload) {\n await hooks?.onChatMemberUpdated?.(payload);\n }),\n };\n })\n .build();\n"],"mappings":";;;;;;;;;AAcA,MAAa,6BAA6B,eACxC,oBACD,CACE,OAAO,aAAa,eAAe,CAAC,CACpC,qBAAqB,EAAE,eAAe,aACrC,cAAc,EACZ,GAAG,uBAAuB,OAAO,EAClC,CAAC,CACH,CACA,cAAgC,EAAE,YAAY,aAAa;CAC1D,MAAM,MAAM,kBAAkB,OAAO;CACrC,MAAM,QAAQ,OAAO;CACrB,MAAM,gCAAgC,+BAA+B,OAAO;AAE5E,QAAO;EACL,yBAAyB,WAAW,eAAgB,SAAS;GAC3D,MAAM,cAAc,QAAQ,WAAW,oBAAoB,mBAAmB;GAC9E,MAAM,SACJ,QAAQ,WAAW,oBACf,MAAM,IAAI,gBAAgB,QAAQ,QAAQ,GAC1C,MAAM,IAAI,YAAY,QAAQ,QAAQ;AAE5C,OAAI,CAAC,OAAO,GACV,OAAM,IAAI,MAAM,OAAO,eAAe,qBAAqB;AAM7D,OAAI;IACF,MAAM,MAAM,+BAA+B;KACzC,SAAS,OAAO;KAChB;KACD,CAAC;AACF,UAAM,KAAK,WAAW,CACnB,UAAU,EAAE,gBAAgB,IAAI,SAAS,UAAU,eAAe,CAAC,CAAC,CACpE,QAAQ,EAAE,WAAW,qBACpB,IAAI,OAAO;KAAE,KAAK,UAAU,eAAe;KAAE;KAAgB,CAAC,CAC/D,CACA,SAAS;YACL,OAAO;AACd,YAAQ,MAAM,2CAA2C,MAAM;;IAEjE;EACF,uBAAuB,WAAW,eAAgB,EAAE,UAAU;GAC5D,MAAM,MAAM,8BAA8B,OAAO;GACjD,MAAM,SACJ,IAAI,SAAS,YACT,MACA,MAAM,KAAK,UAAU,EACnB,aAAa,IAAI,8BAA8B;IAC7C,YAAY;IACZ,gBAAgB;IAChB,YAAY;IACb,CAAC,EACH,CAAC,CACC,UAAU,EAAE,gBAAgB,IAAI,SAAS,UAAU,eAAe,CAAC,CAAC,CACpE,QAAQ,EAAE,WAAW,qBACpB,IAAI,OAAO;IAAE,KAAK,UAAU,eAAe;IAAE;IAAgB,CAAC,CAC/D,CACA,WAAW,EAAE,mBAAmB,aAAa,CAC7C,SAAS;AAElB,OAAI,OAAO,SAAS,aAAa,CAAC,OAAO,QACvC;GAGF,MAAM,SAAS,oBAAoB,OAAO;AAC1C,OAAI,CAAC,OACH;GAGF,MAAM,cAAc,OAAO,YAAY,EAAE,EAAE,OAAO,QAAQ;AAC1D,OAAI,CAAC,WACH;GAGF,MAAM,EAAE,KAAK,YAAY,UAAU,wBAAwB,KAAK,KAAK,UAAU;GAC/E,IAAI;AACJ,OAAI;AACF,UAAM,WAAW,QAAQ;KACvB,UAAU,OAAO;KACjB,gBAAgB,KAAK;KACrB;KACA,SAAS,OAAO;KAChB,MAAM,OAAO;KACb,UAAU,OAAO;KACjB,SAAS;MACP,MAAM,OAAO,QAAQ;MACrB,MAAM,OAAO,QAAQ;MACrB,KAAK,OAAO,QAAQ;MACrB;KACD,KAAK;KACL,WAAW,KAAK;KACjB,CAAC;YACK,OAAO;AACd,mBAAe;;AAGjB,OAAI;AACF,UAAM,OAAO;YACN,OAAO;AACd,QAAI,CAAC,aACH,OAAM;AAER,YAAQ,MAAM,2CAA2C,MAAM;;AAGjE,OAAI,aACF,OAAM;IAER;EACF,mBAAmB,WAAW,eAAgB,SAAS;AACrD,SAAM,OAAO,oBAAoB,QAAQ;IACzC;EACF,kBAAkB,WAAW,eAAgB,SAAS;AACpD,SAAM,OAAO,mBAAmB,QAAQ;IACxC;EACF,qBAAqB,WAAW,eAAgB,SAAS;AACvD,SAAM,OAAO,sBAAsB,QAAQ;IAC3C;EACH;EACD,CACD,OAAO"}
|