@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,392 @@
|
|
|
1
|
+
import { telegramSchema } from "./schema.js";
|
|
2
|
+
import { telegramChatTypeSchema, telegramCommandBindingsSchema, telegramUpdateSchema } from "./types.js";
|
|
3
|
+
import { DEFAULT_COMMAND_SCOPES, parseCommandBindings } from "./telegram-utils.js";
|
|
4
|
+
import { createTelegramApi } from "./telegram-api.js";
|
|
5
|
+
import { telegramFragmentDefinition } from "./definition.js";
|
|
6
|
+
import { defineRoutes } from "@fragno-dev/core";
|
|
7
|
+
import { ExponentialBackoffRetryPolicy, decodeCursor } from "@fragno-dev/db";
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
|
|
10
|
+
//#region src/routes.ts
|
|
11
|
+
const chatSummarySchema = z.object({
|
|
12
|
+
id: z.string(),
|
|
13
|
+
type: telegramChatTypeSchema,
|
|
14
|
+
title: z.string().nullable(),
|
|
15
|
+
username: z.string().nullable(),
|
|
16
|
+
isForum: z.boolean(),
|
|
17
|
+
commandBindings: telegramCommandBindingsSchema.nullable(),
|
|
18
|
+
createdAt: z.date(),
|
|
19
|
+
updatedAt: z.date()
|
|
20
|
+
});
|
|
21
|
+
const userSummarySchema = z.object({
|
|
22
|
+
id: z.string(),
|
|
23
|
+
username: z.string().nullable(),
|
|
24
|
+
firstName: z.string(),
|
|
25
|
+
lastName: z.string().nullable(),
|
|
26
|
+
isBot: z.boolean(),
|
|
27
|
+
languageCode: z.string().nullable(),
|
|
28
|
+
createdAt: z.date(),
|
|
29
|
+
updatedAt: z.date()
|
|
30
|
+
});
|
|
31
|
+
const chatMemberSummarySchema = z.object({
|
|
32
|
+
id: z.string(),
|
|
33
|
+
chatId: z.string(),
|
|
34
|
+
userId: z.string(),
|
|
35
|
+
status: z.string(),
|
|
36
|
+
joinedAt: z.date().nullable(),
|
|
37
|
+
leftAt: z.date().nullable(),
|
|
38
|
+
user: userSummarySchema.nullable(),
|
|
39
|
+
createdAt: z.date(),
|
|
40
|
+
updatedAt: z.date()
|
|
41
|
+
});
|
|
42
|
+
const messageSummarySchema = z.object({
|
|
43
|
+
id: z.string(),
|
|
44
|
+
chatId: z.string(),
|
|
45
|
+
fromUserId: z.string().nullable(),
|
|
46
|
+
senderChatId: z.string().nullable(),
|
|
47
|
+
replyToMessageId: z.string().nullable(),
|
|
48
|
+
messageType: z.enum([
|
|
49
|
+
"message",
|
|
50
|
+
"edited_message",
|
|
51
|
+
"channel_post"
|
|
52
|
+
]),
|
|
53
|
+
text: z.string().nullable(),
|
|
54
|
+
payload: z.unknown().nullable(),
|
|
55
|
+
sentAt: z.date(),
|
|
56
|
+
editedAt: z.date().nullable(),
|
|
57
|
+
commandName: z.string().nullable(),
|
|
58
|
+
fromUser: userSummarySchema.nullable()
|
|
59
|
+
});
|
|
60
|
+
const commandBindingInputSchema = z.object({
|
|
61
|
+
chatId: z.string(),
|
|
62
|
+
commandName: z.string(),
|
|
63
|
+
enabled: z.boolean().optional().default(true),
|
|
64
|
+
scopes: z.array(telegramChatTypeSchema).optional()
|
|
65
|
+
});
|
|
66
|
+
const commandBindingOutputSchema = z.object({
|
|
67
|
+
chatId: z.string(),
|
|
68
|
+
commandName: z.string(),
|
|
69
|
+
enabled: z.boolean(),
|
|
70
|
+
scopes: z.array(telegramChatTypeSchema).optional()
|
|
71
|
+
});
|
|
72
|
+
const commandOutputSchema = z.object({
|
|
73
|
+
name: z.string(),
|
|
74
|
+
description: z.string().optional(),
|
|
75
|
+
scopes: z.array(telegramChatTypeSchema),
|
|
76
|
+
enabled: z.boolean().optional(),
|
|
77
|
+
effectiveScopes: z.array(telegramChatTypeSchema).optional(),
|
|
78
|
+
binding: z.object({
|
|
79
|
+
enabled: z.boolean().optional(),
|
|
80
|
+
scopes: z.array(telegramChatTypeSchema).optional()
|
|
81
|
+
}).nullable().optional()
|
|
82
|
+
});
|
|
83
|
+
const actionSchema = z.enum([
|
|
84
|
+
"typing",
|
|
85
|
+
"upload_photo",
|
|
86
|
+
"record_video",
|
|
87
|
+
"upload_video",
|
|
88
|
+
"record_voice",
|
|
89
|
+
"upload_voice",
|
|
90
|
+
"upload_document",
|
|
91
|
+
"choose_sticker",
|
|
92
|
+
"find_location",
|
|
93
|
+
"record_video_note",
|
|
94
|
+
"upload_video_note"
|
|
95
|
+
]);
|
|
96
|
+
const positiveIntSchema = z.coerce.number().int().positive();
|
|
97
|
+
const sendMessageSchema = z.object({
|
|
98
|
+
text: z.string().min(1),
|
|
99
|
+
parseMode: z.enum([
|
|
100
|
+
"MarkdownV2",
|
|
101
|
+
"Markdown",
|
|
102
|
+
"HTML"
|
|
103
|
+
]).optional(),
|
|
104
|
+
disableWebPagePreview: z.boolean().optional(),
|
|
105
|
+
replyToMessageId: positiveIntSchema.optional()
|
|
106
|
+
});
|
|
107
|
+
const editMessageSchema = z.object({
|
|
108
|
+
text: z.string().min(1),
|
|
109
|
+
parseMode: z.enum([
|
|
110
|
+
"MarkdownV2",
|
|
111
|
+
"Markdown",
|
|
112
|
+
"HTML"
|
|
113
|
+
]).optional(),
|
|
114
|
+
disableWebPagePreview: z.boolean().optional()
|
|
115
|
+
});
|
|
116
|
+
const queuedMessageSchema = z.object({
|
|
117
|
+
ok: z.boolean(),
|
|
118
|
+
queued: z.boolean()
|
|
119
|
+
});
|
|
120
|
+
const webhookOutputSchema = z.object({
|
|
121
|
+
ok: z.boolean(),
|
|
122
|
+
duplicate: z.boolean().optional()
|
|
123
|
+
});
|
|
124
|
+
const isDuplicateHookError = (error) => {
|
|
125
|
+
if (!error || typeof error !== "object") return false;
|
|
126
|
+
const code = "code" in error ? String(error.code) : "";
|
|
127
|
+
const message = "message" in error ? String(error.message) : "";
|
|
128
|
+
if (code === "SQLITE_CONSTRAINT" || code === "23505") return message.includes("fragno_hooks") || message.includes("hook");
|
|
129
|
+
return message.toLowerCase().includes("duplicate") || message.toLowerCase().includes("unique");
|
|
130
|
+
};
|
|
131
|
+
const filterUndefined = (payload) => Object.fromEntries(Object.entries(payload).filter(([, value]) => value !== void 0));
|
|
132
|
+
const telegramRoutesFactory = defineRoutes(telegramFragmentDefinition).create(({ defineRoute, services, config }) => {
|
|
133
|
+
const api = createTelegramApi(config);
|
|
134
|
+
return [
|
|
135
|
+
defineRoute({
|
|
136
|
+
method: "POST",
|
|
137
|
+
path: "/telegram/webhook",
|
|
138
|
+
inputSchema: telegramUpdateSchema,
|
|
139
|
+
outputSchema: webhookOutputSchema,
|
|
140
|
+
errorCodes: ["UNAUTHORIZED"],
|
|
141
|
+
handler: async function({ headers, input }, { json, error }) {
|
|
142
|
+
const secret = headers.get("x-telegram-bot-api-secret-token");
|
|
143
|
+
if (!secret || secret !== config.webhookSecretToken) return error({
|
|
144
|
+
message: "Unauthorized",
|
|
145
|
+
code: "UNAUTHORIZED"
|
|
146
|
+
}, 401);
|
|
147
|
+
const update = await input.valid();
|
|
148
|
+
try {
|
|
149
|
+
await this.handlerTx().mutate(({ forSchema }) => {
|
|
150
|
+
forSchema(telegramSchema, {}).triggerHook("internalProcessUpdate", { update }, { id: String(update.update_id) });
|
|
151
|
+
}).execute();
|
|
152
|
+
return json({ ok: true });
|
|
153
|
+
} catch (err) {
|
|
154
|
+
console.error("telegram webhook hook insert error", err);
|
|
155
|
+
if (isDuplicateHookError(err)) return json({
|
|
156
|
+
ok: true,
|
|
157
|
+
duplicate: true
|
|
158
|
+
});
|
|
159
|
+
throw err;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}),
|
|
163
|
+
defineRoute({
|
|
164
|
+
method: "POST",
|
|
165
|
+
path: "/commands/bind",
|
|
166
|
+
inputSchema: commandBindingInputSchema,
|
|
167
|
+
outputSchema: commandBindingOutputSchema,
|
|
168
|
+
errorCodes: [
|
|
169
|
+
"chat_not_found",
|
|
170
|
+
"command_not_found",
|
|
171
|
+
"invalid_scopes"
|
|
172
|
+
],
|
|
173
|
+
handler: async function({ input }, { json, error }) {
|
|
174
|
+
const payload = await input.valid();
|
|
175
|
+
const command = (config.commands ?? {})[payload.commandName];
|
|
176
|
+
if (!command) return error({
|
|
177
|
+
message: "Command not found",
|
|
178
|
+
code: "command_not_found"
|
|
179
|
+
}, 404);
|
|
180
|
+
const allowedScopes = command.scopes ?? DEFAULT_COMMAND_SCOPES;
|
|
181
|
+
if (payload.scopes && !payload.scopes.every((scope) => allowedScopes.includes(scope))) return error({
|
|
182
|
+
message: "Invalid scopes",
|
|
183
|
+
code: "invalid_scopes"
|
|
184
|
+
}, 400);
|
|
185
|
+
const result = await this.handlerTx({ retryPolicy: new ExponentialBackoffRetryPolicy({
|
|
186
|
+
maxRetries: 5,
|
|
187
|
+
initialDelayMs: 10,
|
|
188
|
+
maxDelayMs: 250
|
|
189
|
+
}) }).withServiceCalls(() => [services.bindCommand({
|
|
190
|
+
chatId: payload.chatId,
|
|
191
|
+
commandName: payload.commandName,
|
|
192
|
+
enabled: payload.enabled,
|
|
193
|
+
scopes: payload.scopes
|
|
194
|
+
})]).transform(({ serviceResult: [result] }) => result).execute();
|
|
195
|
+
if (!result.ok) return error({
|
|
196
|
+
message: "Chat not found",
|
|
197
|
+
code: "chat_not_found"
|
|
198
|
+
}, 404);
|
|
199
|
+
return json(result.binding);
|
|
200
|
+
}
|
|
201
|
+
}),
|
|
202
|
+
defineRoute({
|
|
203
|
+
method: "GET",
|
|
204
|
+
path: "/commands",
|
|
205
|
+
queryParameters: ["chatId"],
|
|
206
|
+
outputSchema: z.object({ commands: z.array(commandOutputSchema) }),
|
|
207
|
+
errorCodes: ["chat_not_found"],
|
|
208
|
+
handler: async function({ query }, { json, error }) {
|
|
209
|
+
const chatId = query.get("chatId") ?? void 0;
|
|
210
|
+
const commandDefinitions = Object.values(config.commands ?? {});
|
|
211
|
+
if (!chatId) return json({ commands: commandDefinitions.map((command) => ({
|
|
212
|
+
name: command.name,
|
|
213
|
+
description: command.description,
|
|
214
|
+
scopes: command.scopes ?? DEFAULT_COMMAND_SCOPES
|
|
215
|
+
})) });
|
|
216
|
+
const chat = await this.handlerTx().withServiceCalls(() => [services.getChat(chatId)]).transform(({ serviceResult: [result] }) => result).execute();
|
|
217
|
+
if (!chat) return error({
|
|
218
|
+
message: "Chat not found",
|
|
219
|
+
code: "chat_not_found"
|
|
220
|
+
}, 404);
|
|
221
|
+
const bindings = parseCommandBindings(chat.commandBindings);
|
|
222
|
+
return json({ commands: commandDefinitions.map((command) => {
|
|
223
|
+
const binding = bindings[command.name] ?? null;
|
|
224
|
+
const enabled = binding ? binding.enabled !== false : true;
|
|
225
|
+
const defaultScopes = command.scopes ?? DEFAULT_COMMAND_SCOPES;
|
|
226
|
+
const effectiveScopes = binding?.scopes ?? defaultScopes;
|
|
227
|
+
return {
|
|
228
|
+
name: command.name,
|
|
229
|
+
description: command.description,
|
|
230
|
+
scopes: defaultScopes,
|
|
231
|
+
enabled,
|
|
232
|
+
effectiveScopes,
|
|
233
|
+
binding
|
|
234
|
+
};
|
|
235
|
+
}) });
|
|
236
|
+
}
|
|
237
|
+
}),
|
|
238
|
+
defineRoute({
|
|
239
|
+
method: "GET",
|
|
240
|
+
path: "/chats",
|
|
241
|
+
queryParameters: ["type"],
|
|
242
|
+
outputSchema: z.array(chatSummarySchema),
|
|
243
|
+
handler: async function({ query }, { json }) {
|
|
244
|
+
const parsed = z.object({ type: telegramChatTypeSchema.optional() }).parse({ type: query.get("type") ?? void 0 });
|
|
245
|
+
return json(await this.handlerTx().withServiceCalls(() => [services.listChats(parsed.type)]).transform(({ serviceResult: [result] }) => result).execute());
|
|
246
|
+
}
|
|
247
|
+
}),
|
|
248
|
+
defineRoute({
|
|
249
|
+
method: "GET",
|
|
250
|
+
path: "/chats/:chatId",
|
|
251
|
+
outputSchema: z.object({
|
|
252
|
+
chat: chatSummarySchema,
|
|
253
|
+
members: z.array(chatMemberSummarySchema)
|
|
254
|
+
}),
|
|
255
|
+
errorCodes: ["chat_not_found"],
|
|
256
|
+
handler: async function({ pathParams }, { json, error }) {
|
|
257
|
+
const result = await this.handlerTx().withServiceCalls(() => [services.getChatWithMembers(pathParams.chatId)]).transform(({ serviceResult: [result] }) => result).execute();
|
|
258
|
+
if (!result.chat) return error({
|
|
259
|
+
message: "Chat not found",
|
|
260
|
+
code: "chat_not_found"
|
|
261
|
+
}, 404);
|
|
262
|
+
return json({
|
|
263
|
+
chat: result.chat,
|
|
264
|
+
members: result.members
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
}),
|
|
268
|
+
defineRoute({
|
|
269
|
+
method: "GET",
|
|
270
|
+
path: "/chats/:chatId/messages",
|
|
271
|
+
queryParameters: [
|
|
272
|
+
"cursor",
|
|
273
|
+
"pageSize",
|
|
274
|
+
"order"
|
|
275
|
+
],
|
|
276
|
+
outputSchema: z.object({
|
|
277
|
+
messages: z.array(messageSummarySchema),
|
|
278
|
+
cursor: z.string().optional(),
|
|
279
|
+
hasNextPage: z.boolean()
|
|
280
|
+
}),
|
|
281
|
+
handler: async function({ pathParams, query }, { json }) {
|
|
282
|
+
const parsed = z.object({
|
|
283
|
+
cursor: z.string().optional(),
|
|
284
|
+
pageSize: z.coerce.number().min(1).max(100).catch(50),
|
|
285
|
+
order: z.enum(["asc", "desc"]).catch("desc")
|
|
286
|
+
}).parse({
|
|
287
|
+
cursor: query.get("cursor") ?? void 0,
|
|
288
|
+
pageSize: query.get("pageSize"),
|
|
289
|
+
order: query.get("order")
|
|
290
|
+
});
|
|
291
|
+
const cursor = parsed.cursor ? (() => {
|
|
292
|
+
try {
|
|
293
|
+
return decodeCursor(parsed.cursor);
|
|
294
|
+
} catch {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
})() : void 0;
|
|
298
|
+
const result = await this.handlerTx().withServiceCalls(() => [services.listMessages({
|
|
299
|
+
chatId: pathParams.chatId,
|
|
300
|
+
pageSize: parsed.pageSize,
|
|
301
|
+
order: parsed.order,
|
|
302
|
+
cursor
|
|
303
|
+
})]).transform(({ serviceResult: [result] }) => result).execute();
|
|
304
|
+
return json({
|
|
305
|
+
messages: result.messages,
|
|
306
|
+
cursor: result.cursor?.encode(),
|
|
307
|
+
hasNextPage: result.hasNextPage
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
}),
|
|
311
|
+
defineRoute({
|
|
312
|
+
method: "POST",
|
|
313
|
+
path: "/chats/:chatId/actions",
|
|
314
|
+
inputSchema: z.object({ action: actionSchema }),
|
|
315
|
+
outputSchema: z.object({ ok: z.boolean() }),
|
|
316
|
+
errorCodes: ["TELEGRAM_API_ERROR"],
|
|
317
|
+
handler: async function({ pathParams, input }, { json, error }) {
|
|
318
|
+
const { action } = await input.valid();
|
|
319
|
+
const result = await api.sendChatAction({
|
|
320
|
+
chat_id: pathParams.chatId,
|
|
321
|
+
action
|
|
322
|
+
});
|
|
323
|
+
if (!result.ok) return error({
|
|
324
|
+
message: result.description ?? "Telegram API error",
|
|
325
|
+
code: "TELEGRAM_API_ERROR"
|
|
326
|
+
}, 502);
|
|
327
|
+
return json({ ok: true });
|
|
328
|
+
}
|
|
329
|
+
}),
|
|
330
|
+
defineRoute({
|
|
331
|
+
method: "POST",
|
|
332
|
+
path: "/chats/:chatId/send",
|
|
333
|
+
inputSchema: sendMessageSchema,
|
|
334
|
+
outputSchema: queuedMessageSchema,
|
|
335
|
+
handler: async function({ pathParams, input }, { json }) {
|
|
336
|
+
const payload = await input.valid();
|
|
337
|
+
await this.handlerTx().mutate(({ forSchema }) => {
|
|
338
|
+
forSchema(telegramSchema, {}).triggerHook("internalOutgoingMessage", {
|
|
339
|
+
action: "sendMessage",
|
|
340
|
+
payload: filterUndefined({
|
|
341
|
+
chat_id: pathParams.chatId,
|
|
342
|
+
text: payload.text,
|
|
343
|
+
parse_mode: payload.parseMode,
|
|
344
|
+
disable_web_page_preview: payload.disableWebPagePreview,
|
|
345
|
+
reply_to_message_id: payload.replyToMessageId
|
|
346
|
+
})
|
|
347
|
+
});
|
|
348
|
+
}).execute();
|
|
349
|
+
return json({
|
|
350
|
+
ok: true,
|
|
351
|
+
queued: true
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
}),
|
|
355
|
+
defineRoute({
|
|
356
|
+
method: "POST",
|
|
357
|
+
path: "/chats/:chatId/messages/:messageId/edit",
|
|
358
|
+
inputSchema: editMessageSchema,
|
|
359
|
+
outputSchema: queuedMessageSchema,
|
|
360
|
+
errorCodes: ["INVALID_MESSAGE_ID"],
|
|
361
|
+
handler: async function({ pathParams, input }, { json, error }) {
|
|
362
|
+
const payload = await input.valid();
|
|
363
|
+
const messageIdResult = positiveIntSchema.safeParse(pathParams.messageId);
|
|
364
|
+
if (!messageIdResult.success) return error({
|
|
365
|
+
message: "Invalid message id",
|
|
366
|
+
code: "INVALID_MESSAGE_ID"
|
|
367
|
+
}, 400);
|
|
368
|
+
const messageId = messageIdResult.data;
|
|
369
|
+
await this.handlerTx().mutate(({ forSchema }) => {
|
|
370
|
+
forSchema(telegramSchema, {}).triggerHook("internalOutgoingMessage", {
|
|
371
|
+
action: "editMessageText",
|
|
372
|
+
payload: filterUndefined({
|
|
373
|
+
chat_id: pathParams.chatId,
|
|
374
|
+
message_id: messageId,
|
|
375
|
+
text: payload.text,
|
|
376
|
+
parse_mode: payload.parseMode,
|
|
377
|
+
disable_web_page_preview: payload.disableWebPagePreview
|
|
378
|
+
})
|
|
379
|
+
});
|
|
380
|
+
}).execute();
|
|
381
|
+
return json({
|
|
382
|
+
ok: true,
|
|
383
|
+
queued: true
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
})
|
|
387
|
+
];
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
//#endregion
|
|
391
|
+
export { telegramRoutesFactory };
|
|
392
|
+
//# sourceMappingURL=routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.js","names":[],"sources":["../../src/routes.ts"],"sourcesContent":["import { z } from \"zod\";\n\nimport { defineRoutes } from \"@fragno-dev/core\";\nimport { decodeCursor } from \"@fragno-dev/db\";\nimport { ExponentialBackoffRetryPolicy } from \"@fragno-dev/db\";\n\nimport { telegramFragmentDefinition } from \"./definition\";\nimport { telegramSchema } from \"./schema\";\nimport { createTelegramApi } from \"./telegram-api\";\nimport { DEFAULT_COMMAND_SCOPES, parseCommandBindings } from \"./telegram-utils\";\nimport {\n telegramChatTypeSchema,\n telegramCommandBindingsSchema,\n telegramUpdateSchema,\n} from \"./types\";\nimport type { TelegramCommandScope, TelegramHooksMap } from \"./types\";\n\nconst chatSummarySchema = z.object({\n id: z.string(),\n type: telegramChatTypeSchema,\n title: z.string().nullable(),\n username: z.string().nullable(),\n isForum: z.boolean(),\n commandBindings: telegramCommandBindingsSchema.nullable(),\n createdAt: z.date(),\n updatedAt: z.date(),\n});\n\nconst userSummarySchema = z.object({\n id: z.string(),\n username: z.string().nullable(),\n firstName: z.string(),\n lastName: z.string().nullable(),\n isBot: z.boolean(),\n languageCode: z.string().nullable(),\n createdAt: z.date(),\n updatedAt: z.date(),\n});\n\nconst chatMemberSummarySchema = z.object({\n id: z.string(),\n chatId: z.string(),\n userId: z.string(),\n status: z.string(),\n joinedAt: z.date().nullable(),\n leftAt: z.date().nullable(),\n user: userSummarySchema.nullable(),\n createdAt: z.date(),\n updatedAt: z.date(),\n});\n\nconst messageSummarySchema = z.object({\n id: z.string(),\n chatId: z.string(),\n fromUserId: z.string().nullable(),\n senderChatId: z.string().nullable(),\n replyToMessageId: z.string().nullable(),\n messageType: z.enum([\"message\", \"edited_message\", \"channel_post\"]),\n text: z.string().nullable(),\n payload: z.unknown().nullable(),\n sentAt: z.date(),\n editedAt: z.date().nullable(),\n commandName: z.string().nullable(),\n fromUser: userSummarySchema.nullable(),\n});\n\nconst commandBindingInputSchema = z.object({\n chatId: z.string(),\n commandName: z.string(),\n enabled: z.boolean().optional().default(true),\n scopes: z.array(telegramChatTypeSchema).optional(),\n});\n\nconst commandBindingOutputSchema = z.object({\n chatId: z.string(),\n commandName: z.string(),\n enabled: z.boolean(),\n scopes: z.array(telegramChatTypeSchema).optional(),\n});\n\nconst commandOutputSchema = z.object({\n name: z.string(),\n description: z.string().optional(),\n scopes: z.array(telegramChatTypeSchema),\n enabled: z.boolean().optional(),\n effectiveScopes: z.array(telegramChatTypeSchema).optional(),\n binding: z\n .object({\n enabled: z.boolean().optional(),\n scopes: z.array(telegramChatTypeSchema).optional(),\n })\n .nullable()\n .optional(),\n});\n\nconst actionSchema = z.enum([\n \"typing\",\n \"upload_photo\",\n \"record_video\",\n \"upload_video\",\n \"record_voice\",\n \"upload_voice\",\n \"upload_document\",\n \"choose_sticker\",\n \"find_location\",\n \"record_video_note\",\n \"upload_video_note\",\n]);\n\nconst positiveIntSchema = z.coerce.number().int().positive();\n\nconst sendMessageSchema = z.object({\n text: z.string().min(1),\n parseMode: z.enum([\"MarkdownV2\", \"Markdown\", \"HTML\"]).optional(),\n disableWebPagePreview: z.boolean().optional(),\n replyToMessageId: positiveIntSchema.optional(),\n});\n\nconst editMessageSchema = z.object({\n text: z.string().min(1),\n parseMode: z.enum([\"MarkdownV2\", \"Markdown\", \"HTML\"]).optional(),\n disableWebPagePreview: z.boolean().optional(),\n});\n\nconst queuedMessageSchema = z.object({\n ok: z.boolean(),\n queued: z.boolean(),\n});\n\nconst webhookOutputSchema = z.object({\n ok: z.boolean(),\n duplicate: z.boolean().optional(),\n});\n\nconst isDuplicateHookError = (error: unknown): boolean => {\n if (!error || typeof error !== \"object\") {\n return false;\n }\n const code = \"code\" in error ? String(error.code) : \"\";\n const message = \"message\" in error ? String(error.message) : \"\";\n if (code === \"SQLITE_CONSTRAINT\" || code === \"23505\") {\n return message.includes(\"fragno_hooks\") || message.includes(\"hook\");\n }\n return message.toLowerCase().includes(\"duplicate\") || message.toLowerCase().includes(\"unique\");\n};\n\nconst filterUndefined = (payload: Record<string, unknown>) =>\n Object.fromEntries(Object.entries(payload).filter(([, value]) => value !== undefined));\n\nexport const telegramRoutesFactory = defineRoutes(telegramFragmentDefinition).create(\n ({ defineRoute, services, config }) => {\n const api = createTelegramApi(config);\n\n return [\n defineRoute({\n method: \"POST\",\n path: \"/telegram/webhook\",\n inputSchema: telegramUpdateSchema,\n outputSchema: webhookOutputSchema,\n errorCodes: [\"UNAUTHORIZED\"] as const,\n handler: async function ({ headers, input }, { json, error }) {\n const secret = headers.get(\"x-telegram-bot-api-secret-token\");\n if (!secret || secret !== config.webhookSecretToken) {\n return error({ message: \"Unauthorized\", code: \"UNAUTHORIZED\" }, 401);\n }\n\n const update = await input.valid();\n\n try {\n await this.handlerTx()\n .mutate(({ forSchema }) => {\n const uow = forSchema(telegramSchema, {} as TelegramHooksMap);\n uow.triggerHook(\n \"internalProcessUpdate\",\n { update },\n { id: String(update.update_id) },\n );\n })\n .execute();\n\n return json({ ok: true });\n } catch (err) {\n console.error(\"telegram webhook hook insert error\", err);\n if (isDuplicateHookError(err)) {\n return json({ ok: true, duplicate: true });\n }\n throw err;\n }\n },\n }),\n\n defineRoute({\n method: \"POST\",\n path: \"/commands/bind\",\n inputSchema: commandBindingInputSchema,\n outputSchema: commandBindingOutputSchema,\n errorCodes: [\"chat_not_found\", \"command_not_found\", \"invalid_scopes\"] as const,\n handler: async function ({ input }, { json, error }) {\n const payload = await input.valid();\n const command = (config.commands ?? {})[payload.commandName];\n\n if (!command) {\n return error({ message: \"Command not found\", code: \"command_not_found\" }, 404);\n }\n\n const allowedScopes = command.scopes ?? DEFAULT_COMMAND_SCOPES;\n if (\n payload.scopes &&\n !payload.scopes.every((scope: TelegramCommandScope) => allowedScopes.includes(scope))\n ) {\n return error({ message: \"Invalid scopes\", code: \"invalid_scopes\" }, 400);\n }\n\n const result = await this.handlerTx({\n retryPolicy: new ExponentialBackoffRetryPolicy({\n maxRetries: 5,\n initialDelayMs: 10,\n maxDelayMs: 250,\n }),\n })\n .withServiceCalls(\n () =>\n [\n services.bindCommand({\n chatId: payload.chatId,\n commandName: payload.commandName,\n enabled: payload.enabled,\n scopes: payload.scopes,\n }),\n ] as const,\n )\n .transform(({ serviceResult: [result] }) => result)\n .execute();\n\n if (!result.ok) {\n return error({ message: \"Chat not found\", code: \"chat_not_found\" }, 404);\n }\n\n return json(result.binding);\n },\n }),\n\n defineRoute({\n method: \"GET\",\n path: \"/commands\",\n queryParameters: [\"chatId\"],\n outputSchema: z.object({\n commands: z.array(commandOutputSchema),\n }),\n errorCodes: [\"chat_not_found\"] as const,\n handler: async function ({ query }, { json, error }) {\n const chatId = query.get(\"chatId\") ?? undefined;\n const commandDefinitions = Object.values(config.commands ?? {});\n\n if (!chatId) {\n return json({\n commands: commandDefinitions.map((command) => ({\n name: command.name,\n description: command.description,\n scopes: command.scopes ?? DEFAULT_COMMAND_SCOPES,\n })),\n });\n }\n\n const chat = await this.handlerTx()\n .withServiceCalls(() => [services.getChat(chatId)] as const)\n .transform(({ serviceResult: [result] }) => result)\n .execute();\n\n if (!chat) {\n return error({ message: \"Chat not found\", code: \"chat_not_found\" }, 404);\n }\n\n const bindings = parseCommandBindings(chat.commandBindings);\n\n return json({\n commands: commandDefinitions.map((command) => {\n const binding = bindings[command.name] ?? null;\n const enabled = binding ? binding.enabled !== false : true;\n const defaultScopes = command.scopes ?? DEFAULT_COMMAND_SCOPES;\n const effectiveScopes = binding?.scopes ?? defaultScopes;\n\n return {\n name: command.name,\n description: command.description,\n scopes: defaultScopes,\n enabled,\n effectiveScopes,\n binding,\n };\n }),\n });\n },\n }),\n\n defineRoute({\n method: \"GET\",\n path: \"/chats\",\n queryParameters: [\"type\"],\n outputSchema: z.array(chatSummarySchema),\n handler: async function ({ query }, { json }) {\n const parsed = z\n .object({ type: telegramChatTypeSchema.optional() })\n .parse({ type: query.get(\"type\") ?? undefined });\n\n const chats = await this.handlerTx()\n .withServiceCalls(() => [services.listChats(parsed.type)] as const)\n .transform(({ serviceResult: [result] }) => result)\n .execute();\n\n return json(chats);\n },\n }),\n\n defineRoute({\n method: \"GET\",\n path: \"/chats/:chatId\",\n outputSchema: z.object({\n chat: chatSummarySchema,\n members: z.array(chatMemberSummarySchema),\n }),\n errorCodes: [\"chat_not_found\"] as const,\n handler: async function ({ pathParams }, { json, error }) {\n const result = await this.handlerTx()\n .withServiceCalls(() => [services.getChatWithMembers(pathParams.chatId)] as const)\n .transform(({ serviceResult: [result] }) => result)\n .execute();\n\n if (!result.chat) {\n return error({ message: \"Chat not found\", code: \"chat_not_found\" }, 404);\n }\n\n return json({\n chat: result.chat,\n members: result.members,\n });\n },\n }),\n\n defineRoute({\n method: \"GET\",\n path: \"/chats/:chatId/messages\",\n queryParameters: [\"cursor\", \"pageSize\", \"order\"],\n outputSchema: z.object({\n messages: z.array(messageSummarySchema),\n cursor: z.string().optional(),\n hasNextPage: z.boolean(),\n }),\n handler: async function ({ pathParams, query }, { json }) {\n const parsed = z\n .object({\n cursor: z.string().optional(),\n pageSize: z.coerce.number().min(1).max(100).catch(50),\n order: z.enum([\"asc\", \"desc\"]).catch(\"desc\"),\n })\n .parse({\n cursor: query.get(\"cursor\") ?? undefined,\n pageSize: query.get(\"pageSize\"),\n order: query.get(\"order\"),\n });\n\n const cursor = parsed.cursor\n ? (() => {\n try {\n return decodeCursor(parsed.cursor!);\n } catch {\n return undefined;\n }\n })()\n : undefined;\n\n const result = await this.handlerTx()\n .withServiceCalls(\n () =>\n [\n services.listMessages({\n chatId: pathParams.chatId,\n pageSize: parsed.pageSize,\n order: parsed.order,\n cursor,\n }),\n ] as const,\n )\n .transform(({ serviceResult: [result] }) => result)\n .execute();\n\n return json({\n messages: result.messages,\n cursor: result.cursor?.encode(),\n hasNextPage: result.hasNextPage,\n });\n },\n }),\n\n defineRoute({\n method: \"POST\",\n path: \"/chats/:chatId/actions\",\n inputSchema: z.object({ action: actionSchema }),\n outputSchema: z.object({ ok: z.boolean() }),\n errorCodes: [\"TELEGRAM_API_ERROR\"] as const,\n handler: async function ({ pathParams, input }, { json, error }) {\n const { action } = await input.valid();\n const result = await api.sendChatAction({\n chat_id: pathParams.chatId,\n action,\n });\n\n if (!result.ok) {\n return error(\n { message: result.description ?? \"Telegram API error\", code: \"TELEGRAM_API_ERROR\" },\n 502,\n );\n }\n\n return json({ ok: true });\n },\n }),\n\n defineRoute({\n method: \"POST\",\n path: \"/chats/:chatId/send\",\n inputSchema: sendMessageSchema,\n outputSchema: queuedMessageSchema,\n handler: async function ({ pathParams, input }, { json }) {\n const payload = await input.valid();\n\n await this.handlerTx()\n .mutate(({ forSchema }) => {\n const uow = forSchema(telegramSchema, {} as TelegramHooksMap);\n uow.triggerHook(\"internalOutgoingMessage\", {\n action: \"sendMessage\",\n payload: filterUndefined({\n chat_id: pathParams.chatId,\n text: payload.text,\n parse_mode: payload.parseMode,\n disable_web_page_preview: payload.disableWebPagePreview,\n reply_to_message_id: payload.replyToMessageId,\n }),\n });\n })\n .execute();\n\n return json({ ok: true, queued: true });\n },\n }),\n\n defineRoute({\n method: \"POST\",\n path: \"/chats/:chatId/messages/:messageId/edit\",\n inputSchema: editMessageSchema,\n outputSchema: queuedMessageSchema,\n errorCodes: [\"INVALID_MESSAGE_ID\"] as const,\n handler: async function ({ pathParams, input }, { json, error }) {\n const payload = await input.valid();\n const messageIdResult = positiveIntSchema.safeParse(pathParams.messageId);\n if (!messageIdResult.success) {\n return error({ message: \"Invalid message id\", code: \"INVALID_MESSAGE_ID\" }, 400);\n }\n const messageId = messageIdResult.data;\n\n await this.handlerTx()\n .mutate(({ forSchema }) => {\n const uow = forSchema(telegramSchema, {} as TelegramHooksMap);\n uow.triggerHook(\"internalOutgoingMessage\", {\n action: \"editMessageText\",\n payload: filterUndefined({\n chat_id: pathParams.chatId,\n message_id: messageId,\n text: payload.text,\n parse_mode: payload.parseMode,\n disable_web_page_preview: payload.disableWebPagePreview,\n }),\n });\n })\n .execute();\n\n return json({ ok: true, queued: true });\n },\n }),\n ];\n },\n);\n"],"mappings":";;;;;;;;;;AAiBA,MAAM,oBAAoB,EAAE,OAAO;CACjC,IAAI,EAAE,QAAQ;CACd,MAAM;CACN,OAAO,EAAE,QAAQ,CAAC,UAAU;CAC5B,UAAU,EAAE,QAAQ,CAAC,UAAU;CAC/B,SAAS,EAAE,SAAS;CACpB,iBAAiB,8BAA8B,UAAU;CACzD,WAAW,EAAE,MAAM;CACnB,WAAW,EAAE,MAAM;CACpB,CAAC;AAEF,MAAM,oBAAoB,EAAE,OAAO;CACjC,IAAI,EAAE,QAAQ;CACd,UAAU,EAAE,QAAQ,CAAC,UAAU;CAC/B,WAAW,EAAE,QAAQ;CACrB,UAAU,EAAE,QAAQ,CAAC,UAAU;CAC/B,OAAO,EAAE,SAAS;CAClB,cAAc,EAAE,QAAQ,CAAC,UAAU;CACnC,WAAW,EAAE,MAAM;CACnB,WAAW,EAAE,MAAM;CACpB,CAAC;AAEF,MAAM,0BAA0B,EAAE,OAAO;CACvC,IAAI,EAAE,QAAQ;CACd,QAAQ,EAAE,QAAQ;CAClB,QAAQ,EAAE,QAAQ;CAClB,QAAQ,EAAE,QAAQ;CAClB,UAAU,EAAE,MAAM,CAAC,UAAU;CAC7B,QAAQ,EAAE,MAAM,CAAC,UAAU;CAC3B,MAAM,kBAAkB,UAAU;CAClC,WAAW,EAAE,MAAM;CACnB,WAAW,EAAE,MAAM;CACpB,CAAC;AAEF,MAAM,uBAAuB,EAAE,OAAO;CACpC,IAAI,EAAE,QAAQ;CACd,QAAQ,EAAE,QAAQ;CAClB,YAAY,EAAE,QAAQ,CAAC,UAAU;CACjC,cAAc,EAAE,QAAQ,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H,CAAC;MACF,CACD,SAAS;AAEZ,WAAO,KAAK;KAAE,IAAI;KAAM,QAAQ;KAAM,CAAC;;GAE1C,CAAC;EACH;EAEJ"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as _fragno_dev_db0 from "@fragno-dev/db";
|
|
2
|
+
import * as _fragno_dev_db_schema0 from "@fragno-dev/db/schema";
|
|
3
|
+
|
|
4
|
+
//#region src/schema.d.ts
|
|
5
|
+
declare const telegramSchema: _fragno_dev_db_schema0.Schema<{
|
|
6
|
+
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"]>>>;
|
|
7
|
+
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"]>>>;
|
|
8
|
+
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"]>>>;
|
|
9
|
+
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"]>>>;
|
|
10
|
+
}>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { telegramSchema };
|
|
13
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","names":[],"sources":["../../src/schema.ts"],"mappings":";;;;cAEa,cAAA,yBAAc,MAAA;2GAgHzB,sBAAA,CAAA,QAAA"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { column, idColumn, referenceColumn, schema } from "@fragno-dev/db/schema";
|
|
2
|
+
|
|
3
|
+
//#region src/schema.ts
|
|
4
|
+
const telegramSchema = schema("telegram-fragment", (s) => {
|
|
5
|
+
return s.addTable("user", (t) => {
|
|
6
|
+
return t.addColumn("id", idColumn()).addColumn("username", column("string").nullable()).addColumn("firstName", column("string")).addColumn("lastName", column("string").nullable()).addColumn("isBot", column("bool").defaultTo(false)).addColumn("languageCode", column("string").nullable()).addColumn("createdAt", column("timestamp").defaultTo((b) => b.now())).addColumn("updatedAt", column("timestamp").defaultTo((b) => b.now())).createIndex("idx_user_username", ["username"]);
|
|
7
|
+
}).addTable("chat", (t) => {
|
|
8
|
+
return t.addColumn("id", idColumn()).addColumn("type", column("string")).addColumn("title", column("string").nullable()).addColumn("username", column("string").nullable()).addColumn("isForum", column("bool").defaultTo(false)).addColumn("commandBindings", column("json").nullable()).addColumn("createdAt", column("timestamp").defaultTo((b) => b.now())).addColumn("updatedAt", column("timestamp").defaultTo((b) => b.now())).createIndex("idx_chat_type", ["type"]);
|
|
9
|
+
}).addTable("chatMember", (t) => {
|
|
10
|
+
return t.addColumn("id", idColumn()).addColumn("chatId", referenceColumn()).addColumn("userId", referenceColumn()).addColumn("status", column("string")).addColumn("joinedAt", column("timestamp").nullable()).addColumn("leftAt", column("timestamp").nullable()).addColumn("createdAt", column("timestamp").defaultTo((b) => b.now())).addColumn("updatedAt", column("timestamp").defaultTo((b) => b.now())).createIndex("idx_chat_member_chat", ["chatId"]).createIndex("idx_chat_member_user", ["userId"]).createIndex("idx_chat_member_unique", ["chatId", "userId"], { unique: true });
|
|
11
|
+
}).addTable("message", (t) => {
|
|
12
|
+
return t.addColumn("id", idColumn()).addColumn("chatId", referenceColumn()).addColumn("fromUserId", referenceColumn().nullable()).addColumn("senderChatId", referenceColumn().nullable()).addColumn("replyToMessageId", referenceColumn().nullable()).addColumn("messageType", column("string")).addColumn("text", column("string").nullable()).addColumn("payload", column("json").nullable()).addColumn("sentAt", column("timestamp")).addColumn("editedAt", column("timestamp").nullable()).addColumn("commandName", column("string").nullable()).addColumn("createdAt", column("timestamp").defaultTo((b) => b.now())).createIndex("idx_message_chat", ["chatId"]).createIndex("idx_message_chat_sent", ["chatId", "sentAt"]).createIndex("idx_message_from", ["fromUserId"]).createIndex("idx_message_sent", ["sentAt"]);
|
|
13
|
+
}).addReference("chatMemberChat", {
|
|
14
|
+
type: "one",
|
|
15
|
+
from: {
|
|
16
|
+
table: "chatMember",
|
|
17
|
+
column: "chatId"
|
|
18
|
+
},
|
|
19
|
+
to: {
|
|
20
|
+
table: "chat",
|
|
21
|
+
column: "id"
|
|
22
|
+
}
|
|
23
|
+
}).addReference("chatMemberUser", {
|
|
24
|
+
type: "one",
|
|
25
|
+
from: {
|
|
26
|
+
table: "chatMember",
|
|
27
|
+
column: "userId"
|
|
28
|
+
},
|
|
29
|
+
to: {
|
|
30
|
+
table: "user",
|
|
31
|
+
column: "id"
|
|
32
|
+
}
|
|
33
|
+
}).addReference("messageChat", {
|
|
34
|
+
type: "one",
|
|
35
|
+
from: {
|
|
36
|
+
table: "message",
|
|
37
|
+
column: "chatId"
|
|
38
|
+
},
|
|
39
|
+
to: {
|
|
40
|
+
table: "chat",
|
|
41
|
+
column: "id"
|
|
42
|
+
}
|
|
43
|
+
}).addReference("messageAuthor", {
|
|
44
|
+
type: "one",
|
|
45
|
+
from: {
|
|
46
|
+
table: "message",
|
|
47
|
+
column: "fromUserId"
|
|
48
|
+
},
|
|
49
|
+
to: {
|
|
50
|
+
table: "user",
|
|
51
|
+
column: "id"
|
|
52
|
+
}
|
|
53
|
+
}).addReference("messageSenderChat", {
|
|
54
|
+
type: "one",
|
|
55
|
+
from: {
|
|
56
|
+
table: "message",
|
|
57
|
+
column: "senderChatId"
|
|
58
|
+
},
|
|
59
|
+
to: {
|
|
60
|
+
table: "chat",
|
|
61
|
+
column: "id"
|
|
62
|
+
}
|
|
63
|
+
}).addReference("messageReplyTo", {
|
|
64
|
+
type: "one",
|
|
65
|
+
from: {
|
|
66
|
+
table: "message",
|
|
67
|
+
column: "replyToMessageId"
|
|
68
|
+
},
|
|
69
|
+
to: {
|
|
70
|
+
table: "message",
|
|
71
|
+
column: "id"
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
//#endregion
|
|
77
|
+
export { telegramSchema };
|
|
78
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","names":[],"sources":["../../src/schema.ts"],"sourcesContent":["import { column, idColumn, referenceColumn, schema } from \"@fragno-dev/db/schema\";\n\nexport const telegramSchema = schema(\"telegram-fragment\", (s) => {\n return s\n .addTable(\"user\", (t) => {\n return t\n .addColumn(\"id\", idColumn())\n .addColumn(\"username\", column(\"string\").nullable())\n .addColumn(\"firstName\", column(\"string\"))\n .addColumn(\"lastName\", column(\"string\").nullable())\n .addColumn(\"isBot\", column(\"bool\").defaultTo(false))\n .addColumn(\"languageCode\", column(\"string\").nullable())\n .addColumn(\n \"createdAt\",\n column(\"timestamp\").defaultTo((b) => b.now()),\n )\n .addColumn(\n \"updatedAt\",\n column(\"timestamp\").defaultTo((b) => b.now()),\n )\n .createIndex(\"idx_user_username\", [\"username\"]);\n })\n .addTable(\"chat\", (t) => {\n return t\n .addColumn(\"id\", idColumn())\n .addColumn(\"type\", column(\"string\"))\n .addColumn(\"title\", column(\"string\").nullable())\n .addColumn(\"username\", column(\"string\").nullable())\n .addColumn(\"isForum\", column(\"bool\").defaultTo(false))\n .addColumn(\"commandBindings\", column(\"json\").nullable())\n .addColumn(\n \"createdAt\",\n column(\"timestamp\").defaultTo((b) => b.now()),\n )\n .addColumn(\n \"updatedAt\",\n column(\"timestamp\").defaultTo((b) => b.now()),\n )\n .createIndex(\"idx_chat_type\", [\"type\"]);\n })\n .addTable(\"chatMember\", (t) => {\n return t\n .addColumn(\"id\", idColumn())\n .addColumn(\"chatId\", referenceColumn())\n .addColumn(\"userId\", referenceColumn())\n .addColumn(\"status\", column(\"string\"))\n .addColumn(\"joinedAt\", column(\"timestamp\").nullable())\n .addColumn(\"leftAt\", column(\"timestamp\").nullable())\n .addColumn(\n \"createdAt\",\n column(\"timestamp\").defaultTo((b) => b.now()),\n )\n .addColumn(\n \"updatedAt\",\n column(\"timestamp\").defaultTo((b) => b.now()),\n )\n .createIndex(\"idx_chat_member_chat\", [\"chatId\"])\n .createIndex(\"idx_chat_member_user\", [\"userId\"])\n .createIndex(\"idx_chat_member_unique\", [\"chatId\", \"userId\"], {\n unique: true,\n });\n })\n .addTable(\"message\", (t) => {\n return t\n .addColumn(\"id\", idColumn())\n .addColumn(\"chatId\", referenceColumn())\n .addColumn(\"fromUserId\", referenceColumn().nullable())\n .addColumn(\"senderChatId\", referenceColumn().nullable())\n .addColumn(\"replyToMessageId\", referenceColumn().nullable())\n .addColumn(\"messageType\", column(\"string\"))\n .addColumn(\"text\", column(\"string\").nullable())\n .addColumn(\"payload\", column(\"json\").nullable())\n .addColumn(\"sentAt\", column(\"timestamp\"))\n .addColumn(\"editedAt\", column(\"timestamp\").nullable())\n .addColumn(\"commandName\", column(\"string\").nullable())\n .addColumn(\n \"createdAt\",\n column(\"timestamp\").defaultTo((b) => b.now()),\n )\n .createIndex(\"idx_message_chat\", [\"chatId\"])\n .createIndex(\"idx_message_chat_sent\", [\"chatId\", \"sentAt\"])\n .createIndex(\"idx_message_from\", [\"fromUserId\"])\n .createIndex(\"idx_message_sent\", [\"sentAt\"]);\n })\n .addReference(\"chatMemberChat\", {\n type: \"one\",\n from: { table: \"chatMember\", column: \"chatId\" },\n to: { table: \"chat\", column: \"id\" },\n })\n .addReference(\"chatMemberUser\", {\n type: \"one\",\n from: { table: \"chatMember\", column: \"userId\" },\n to: { table: \"user\", column: \"id\" },\n })\n .addReference(\"messageChat\", {\n type: \"one\",\n from: { table: \"message\", column: \"chatId\" },\n to: { table: \"chat\", column: \"id\" },\n })\n .addReference(\"messageAuthor\", {\n type: \"one\",\n from: { table: \"message\", column: \"fromUserId\" },\n to: { table: \"user\", column: \"id\" },\n })\n .addReference(\"messageSenderChat\", {\n type: \"one\",\n from: { table: \"message\", column: \"senderChatId\" },\n to: { table: \"chat\", column: \"id\" },\n })\n .addReference(\"messageReplyTo\", {\n type: \"one\",\n from: { table: \"message\", column: \"replyToMessageId\" },\n to: { table: \"message\", column: \"id\" },\n });\n});\n"],"mappings":";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