@rodrigobeber/patoai-dtos 4.7.71 → 4.7.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/uh/index.d.ts +2 -0
- package/dist/uh/index.js +2 -0
- package/dist/uh/telegram.dto.d.ts +29 -0
- package/dist/uh/telegram.dto.js +2 -0
- package/dist/uh/uh-public-url.d.ts +23 -0
- package/dist/uh/uh-public-url.js +32 -0
- package/package.json +1 -1
package/dist/uh/index.d.ts
CHANGED
package/dist/uh/index.js
CHANGED
|
@@ -30,3 +30,5 @@ __exportStar(require("./sent-template.dto"), exports);
|
|
|
30
30
|
__exportStar(require("./send-text.dto"), exports);
|
|
31
31
|
__exportStar(require("./send-buttons.dto"), exports);
|
|
32
32
|
__exportStar(require("./message-status.dto"), exports);
|
|
33
|
+
__exportStar(require("./telegram.dto"), exports);
|
|
34
|
+
__exportStar(require("./uh-public-url"), exports);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contrato RPC crew -> uh para o ciclo de vida do webhook do Telegram.
|
|
3
|
+
*
|
|
4
|
+
* O onboarding e feito no crew, mas quem fala com a Bot API e o uh: o `secret_token`
|
|
5
|
+
* do webhook e o APP_SECRET do uh e a URL registrada e a rota do proprio uh
|
|
6
|
+
* (POST /telegram/:botId). Por isso getMe/setWebhook/deleteWebhook rodam la.
|
|
7
|
+
*/
|
|
8
|
+
export interface TelegramSetupDto {
|
|
9
|
+
/** Token do bot no formato `<botId>:<hash>`, obtido no @BotFather. */
|
|
10
|
+
token: string;
|
|
11
|
+
}
|
|
12
|
+
export interface TelegramSetupResultDto {
|
|
13
|
+
/** Id numerico do bot (prefixo do token). Vira o `channelId` do canal. */
|
|
14
|
+
botId: string;
|
|
15
|
+
username: string;
|
|
16
|
+
firstName: string;
|
|
17
|
+
/** URL registrada no setWebhook (sem o secret da query). */
|
|
18
|
+
webhookUrl: string;
|
|
19
|
+
}
|
|
20
|
+
export interface TelegramWebhookInfoDto {
|
|
21
|
+
botId: string;
|
|
22
|
+
username: string;
|
|
23
|
+
/** URL atualmente registrada no Telegram. Vazia quando nao ha webhook. */
|
|
24
|
+
url: string;
|
|
25
|
+
pendingUpdateCount: number;
|
|
26
|
+
lastErrorMessage?: string;
|
|
27
|
+
/** Unix timestamp (segundos) do ultimo erro de entrega. */
|
|
28
|
+
lastErrorDate?: number;
|
|
29
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* URL publica do patoai-uh — o endereco onde os canais registram seus webhooks
|
|
3
|
+
* (Telegram `setWebhook`, Evolution). FONTE UNICA: o uh e o crew derivam daqui.
|
|
4
|
+
*/
|
|
5
|
+
/** Tunel que expoe o Traefik local em dev (o uh precisa ser alcancavel pela internet). */
|
|
6
|
+
export declare const UH_DEV_PUBLIC_URL = "https://f20bzrdj-8090.brs.devtunnels.ms/uh";
|
|
7
|
+
/**
|
|
8
|
+
* Deriva a URL publica do uh a partir da URL do painel (`FRONTEND_URL`), que ja chega em todos
|
|
9
|
+
* os pods pelo `env-configmap`:
|
|
10
|
+
*
|
|
11
|
+
* chat.upflows.com.br -> uh.upflows.com.br (prod)
|
|
12
|
+
* chat-hml.upflows.com.br -> uh-hml.upflows.com.br (hml)
|
|
13
|
+
* chat-tst.upflows.com.br -> uh-tst.upflows.com.br (tst)
|
|
14
|
+
*
|
|
15
|
+
* Sem match (dev, onde `FRONTEND_URL` e localhost), cai no tunel de desenvolvimento.
|
|
16
|
+
*
|
|
17
|
+
* NAO derivar isso de `NODE_ENV`: HML e TST usam AMBOS `staging`, entao o TST acabaria
|
|
18
|
+
* apontando para o host do HML — bug silencioso que o `evolution.webhookUrl` do crew carregava.
|
|
19
|
+
*
|
|
20
|
+
* Premissa: a convencao de dominio `<servico>[-ambiente].upflows.com.br`, valida hoje para todos
|
|
21
|
+
* os servicos. Se o painel ganhar dominio proprio (white-label), esta derivacao para de valer.
|
|
22
|
+
*/
|
|
23
|
+
export declare function buildUhPublicUrl(frontendUrl?: string): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* URL publica do patoai-uh — o endereco onde os canais registram seus webhooks
|
|
4
|
+
* (Telegram `setWebhook`, Evolution). FONTE UNICA: o uh e o crew derivam daqui.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.UH_DEV_PUBLIC_URL = void 0;
|
|
8
|
+
exports.buildUhPublicUrl = buildUhPublicUrl;
|
|
9
|
+
/** Tunel que expoe o Traefik local em dev (o uh precisa ser alcancavel pela internet). */
|
|
10
|
+
exports.UH_DEV_PUBLIC_URL = 'https://f20bzrdj-8090.brs.devtunnels.ms/uh';
|
|
11
|
+
/** `https://chat-hml.upflows.com.br` -> captura `-hml`. Em producao o sufixo e vazio. */
|
|
12
|
+
const PANEL_URL_REGEX = /^https:\/\/chat(-[a-z]+)?\.upflows\.com\.br\/?$/i;
|
|
13
|
+
/**
|
|
14
|
+
* Deriva a URL publica do uh a partir da URL do painel (`FRONTEND_URL`), que ja chega em todos
|
|
15
|
+
* os pods pelo `env-configmap`:
|
|
16
|
+
*
|
|
17
|
+
* chat.upflows.com.br -> uh.upflows.com.br (prod)
|
|
18
|
+
* chat-hml.upflows.com.br -> uh-hml.upflows.com.br (hml)
|
|
19
|
+
* chat-tst.upflows.com.br -> uh-tst.upflows.com.br (tst)
|
|
20
|
+
*
|
|
21
|
+
* Sem match (dev, onde `FRONTEND_URL` e localhost), cai no tunel de desenvolvimento.
|
|
22
|
+
*
|
|
23
|
+
* NAO derivar isso de `NODE_ENV`: HML e TST usam AMBOS `staging`, entao o TST acabaria
|
|
24
|
+
* apontando para o host do HML — bug silencioso que o `evolution.webhookUrl` do crew carregava.
|
|
25
|
+
*
|
|
26
|
+
* Premissa: a convencao de dominio `<servico>[-ambiente].upflows.com.br`, valida hoje para todos
|
|
27
|
+
* os servicos. Se o painel ganhar dominio proprio (white-label), esta derivacao para de valer.
|
|
28
|
+
*/
|
|
29
|
+
function buildUhPublicUrl(frontendUrl) {
|
|
30
|
+
const match = PANEL_URL_REGEX.exec((frontendUrl === null || frontendUrl === void 0 ? void 0 : frontendUrl.trim()) || '');
|
|
31
|
+
return match ? `https://uh${match[1] || ''}.upflows.com.br` : exports.UH_DEV_PUBLIC_URL;
|
|
32
|
+
}
|