@adatechnology/meta-whatsapp-module 0.11.0 → 0.12.0
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/README.md +64 -0
- package/dist/index.cjs +520 -100
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +303 -3
- package/dist/index.d.ts +303 -3
- package/dist/index.js +434 -25
- package/dist/index.js.map +1 -1
- package/dist/migrations/20261126120000_quick_replies/migration.sql +18 -0
- package/dist/migrations/20261126130000_flow_graph_origin/migration.sql +10 -0
- package/dist/migrations/20261126130000_flow_graph_origin/snapshot.json +1675 -0
- package/dist/migrations-journal/0011_quick_replies.sql +18 -0
- package/dist/migrations-journal/0012_flow_graph_origin.sql +10 -0
- package/dist/migrations-journal/meta/_journal.json +14 -0
- package/package.json +4 -3
package/dist/index.cjs
CHANGED
|
@@ -23,14 +23,17 @@ var index_exports = {};
|
|
|
23
23
|
__export(index_exports, {
|
|
24
24
|
CountInboundLocationsUseCase: () => CountInboundLocationsUseCase,
|
|
25
25
|
CreateFlowGraphUseCase: () => CreateFlowGraphUseCase,
|
|
26
|
+
CreateQuickReplyUseCase: () => CreateQuickReplyUseCase,
|
|
26
27
|
DEFAULT_FALLBACK_LIST_LABEL: () => DEFAULT_FALLBACK_LIST_LABEL,
|
|
27
28
|
DEFAULT_FLOW_GRAPH_CACHE_TTL_SECONDS: () => DEFAULT_FLOW_GRAPH_CACHE_TTL_SECONDS,
|
|
28
29
|
DEFAULT_FLOW_TEXT: () => DEFAULT_FLOW_TEXT,
|
|
29
30
|
DEFAULT_MAX_INVALID_ANSWERS: () => DEFAULT_MAX_INVALID_ANSWERS,
|
|
31
|
+
DEFAULT_QUICK_REPLY_WRITE_SCOPES: () => DEFAULT_QUICK_REPLY_WRITE_SCOPES,
|
|
30
32
|
DEFAULT_START_FLOW_KEY: () => DEFAULT_START_FLOW_KEY,
|
|
31
33
|
DYNAMIC_CHOICE_MORE_ID: () => DYNAMIC_CHOICE_MORE_ID,
|
|
32
34
|
DeleteConversationUseCase: () => DeleteConversationUseCase,
|
|
33
35
|
DeleteFlowGraphUseCase: () => DeleteFlowGraphUseCase,
|
|
36
|
+
DeleteQuickReplyUseCase: () => DeleteQuickReplyUseCase,
|
|
34
37
|
DocumentRepository: () => DocumentRepository,
|
|
35
38
|
ExportConversationUseCase: () => ExportConversationUseCase,
|
|
36
39
|
FLOW_RUNTIME_CONTEXT_KEY: () => FLOW_RUNTIME_CONTEXT_KEY,
|
|
@@ -53,19 +56,23 @@ __export(index_exports, {
|
|
|
53
56
|
ListConversationsUseCase: () => ListConversationsUseCase,
|
|
54
57
|
ListFlowGraphsUseCase: () => ListFlowGraphsUseCase,
|
|
55
58
|
ListMessagesUseCase: () => ListMessagesUseCase,
|
|
59
|
+
ListQuickRepliesUseCase: () => ListQuickRepliesUseCase,
|
|
56
60
|
LogMessageUseCase: () => LogMessageUseCase,
|
|
57
61
|
META_WHATSAPP_MIGRATIONS_TABLE: () => META_WHATSAPP_MIGRATIONS_TABLE,
|
|
58
62
|
MessageRepository: () => MessageRepository,
|
|
59
63
|
OptimisticLockError: () => OptimisticLockError,
|
|
60
|
-
PREVIEW_MEDIA_ID_PREFIX: () =>
|
|
64
|
+
PREVIEW_MEDIA_ID_PREFIX: () => import_meta_whatsapp_contracts18.PREVIEW_MEDIA_ID_PREFIX,
|
|
61
65
|
PRODUCT_LIST_LIMIT: () => PRODUCT_LIST_LIMIT,
|
|
62
66
|
PostgresAdvisoryFlowTurnLock: () => PostgresAdvisoryFlowTurnLock,
|
|
63
67
|
ProcessInboundDispatchUseCase: () => ProcessInboundDispatchUseCase,
|
|
64
68
|
PurgeExpiredDocumentsUseCase: () => PurgeExpiredDocumentsUseCase,
|
|
69
|
+
QUICK_REPLY_SCOPE: () => QUICK_REPLY_SCOPE,
|
|
70
|
+
QuickReplyRepository: () => QuickReplyRepository,
|
|
65
71
|
ReceiveWebhookUseCase: () => ReceiveWebhookUseCase,
|
|
66
72
|
RedactInboundLocationsUseCase: () => RedactInboundLocationsUseCase,
|
|
67
73
|
ReleaseConversationUseCase: () => ReleaseConversationUseCase,
|
|
68
74
|
RequestHumanConversationUseCase: () => RequestHumanConversationUseCase,
|
|
75
|
+
ReseedFlowGraphUseCase: () => ReseedFlowGraphUseCase,
|
|
69
76
|
SaveFlowGraphUseCase: () => SaveFlowGraphUseCase,
|
|
70
77
|
SendMessageUseCase: () => SendMessageUseCase,
|
|
71
78
|
SessionRepository: () => SessionRepository,
|
|
@@ -76,6 +83,7 @@ __export(index_exports, {
|
|
|
76
83
|
TRANSCRIPTION_STATUS: () => TRANSCRIPTION_STATUS,
|
|
77
84
|
TakeoverConversationUseCase: () => TakeoverConversationUseCase,
|
|
78
85
|
TranscribeAudioUseCase: () => TranscribeAudioUseCase,
|
|
86
|
+
UpdateQuickReplyUseCase: () => UpdateQuickReplyUseCase,
|
|
79
87
|
WEBHOOK_CLAIM_TTL_SECONDS: () => import_meta_graph_core3.WEBHOOK_CLAIM_TTL_SECONDS,
|
|
80
88
|
WEBHOOK_NONCE_TTL_SECONDS: () => import_meta_graph_core3.WEBHOOK_NONCE_TTL_SECONDS,
|
|
81
89
|
WhatsAppChannelAdapter: () => WhatsAppChannelAdapter,
|
|
@@ -84,6 +92,7 @@ __export(index_exports, {
|
|
|
84
92
|
claimWebhookDelivery: () => claimWebhookDelivery,
|
|
85
93
|
confirmWebhookDelivery: () => confirmWebhookDelivery,
|
|
86
94
|
createMetaWhatsAppModule: () => createMetaWhatsAppModule,
|
|
95
|
+
createMetaWhatsAppQuickReplyRoutes: () => createMetaWhatsAppQuickReplyRoutes,
|
|
87
96
|
createSendMediaAction: () => createSendMediaAction,
|
|
88
97
|
createSendProductListAction: () => createSendProductListAction,
|
|
89
98
|
createTranscriptionPolicyResolver: () => createTranscriptionPolicyResolver,
|
|
@@ -99,17 +108,19 @@ __export(index_exports, {
|
|
|
99
108
|
messages: () => messages,
|
|
100
109
|
metaWhatsAppMigrationsFolder: () => metaWhatsAppMigrationsFolder,
|
|
101
110
|
metaWhatsAppSchema: () => metaWhatsAppSchema,
|
|
111
|
+
quickReplies: () => quickReplies,
|
|
102
112
|
readFlowInbound: () => readFlowInbound,
|
|
103
113
|
redeemSseTicket: () => redeemSseTicket,
|
|
104
114
|
resolveFailureStatus: () => resolveFailureStatus,
|
|
105
115
|
resolveFlowAnswer: () => resolveFlowAnswer,
|
|
106
116
|
resolveFlowConfigText: () => resolveFlowConfigText,
|
|
107
117
|
resolveFlowTimeZone: () => resolveFlowTimeZone,
|
|
108
|
-
resolvePreviewUploadId: () =>
|
|
118
|
+
resolvePreviewUploadId: () => import_meta_whatsapp_contracts18.resolvePreviewUploadId,
|
|
109
119
|
runMetaWhatsAppMigrations: () => runMetaWhatsAppMigrations,
|
|
110
120
|
sessions: () => sessions,
|
|
111
121
|
settings: () => settings,
|
|
112
|
-
toPreviewMediaId: () =>
|
|
122
|
+
toPreviewMediaId: () => import_meta_whatsapp_contracts18.toPreviewMediaId,
|
|
123
|
+
toQuickReplyView: () => toQuickReplyView,
|
|
113
124
|
toSessionContract: () => toSessionContract,
|
|
114
125
|
transcriptionRetryAfterSeconds: () => transcriptionRetryAfterSeconds,
|
|
115
126
|
verifyWebhookChallenge: () => verifyWebhookChallenge,
|
|
@@ -120,7 +131,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
120
131
|
// src/createMetaWhatsAppModule.ts
|
|
121
132
|
var import_meta_whatsapp_provider = require("@adatechnology/meta-whatsapp-provider");
|
|
122
133
|
var import_testing = require("@adatechnology/meta-whatsapp-contracts/testing");
|
|
123
|
-
var
|
|
134
|
+
var import_meta_whatsapp_contracts23 = require("@adatechnology/meta-whatsapp-contracts");
|
|
124
135
|
|
|
125
136
|
// src/repositories/SessionRepository.ts
|
|
126
137
|
var import_drizzle_orm2 = require("drizzle-orm");
|
|
@@ -324,6 +335,14 @@ var flowGraphs = metaWhatsAppSchema.table("flow_graphs", {
|
|
|
324
335
|
menuOptionLabel: (0, import_pg_core.varchar)("menu_option_label", {
|
|
325
336
|
length: 64
|
|
326
337
|
}),
|
|
338
|
+
// 'seed' | 'edited' (FLOW_GRAPH_ORIGIN). Linha anterior ao campo vira 'edited': sem como saber se
|
|
339
|
+
// alguém mexeu, o reseed do produto não pode sobrescrevê-la.
|
|
340
|
+
origin: (0, import_pg_core.varchar)("origin", {
|
|
341
|
+
length: 16
|
|
342
|
+
}).notNull().default("edited"),
|
|
343
|
+
seedVersion: (0, import_pg_core.varchar)("seed_version", {
|
|
344
|
+
length: 64
|
|
345
|
+
}),
|
|
327
346
|
createdAt: (0, import_pg_core.timestamp)("created_at", {
|
|
328
347
|
withTimezone: true
|
|
329
348
|
}).notNull().defaultNow(),
|
|
@@ -381,6 +400,29 @@ var flowMedia = metaWhatsAppSchema.table("flow_media", {
|
|
|
381
400
|
// receberia o documento repetido.
|
|
382
401
|
(0, import_pg_core.uniqueIndex)("idx_flow_media_node_upload").on(table.companyId, table.flowKey, table.nodeId, table.uploadId)
|
|
383
402
|
]);
|
|
403
|
+
var quickReplies = metaWhatsAppSchema.table("quick_replies", {
|
|
404
|
+
id: (0, import_pg_core.uuid)("id").primaryKey().defaultRandom(),
|
|
405
|
+
companyId: (0, import_pg_core.uuid)("company_id").notNull(),
|
|
406
|
+
title: (0, import_pg_core.varchar)("title", {
|
|
407
|
+
length: 40
|
|
408
|
+
}).notNull(),
|
|
409
|
+
shortcut: (0, import_pg_core.varchar)("shortcut", {
|
|
410
|
+
length: 20
|
|
411
|
+
}).notNull(),
|
|
412
|
+
body: (0, import_pg_core.varchar)("body", {
|
|
413
|
+
length: 1e3
|
|
414
|
+
}).notNull(),
|
|
415
|
+
sortOrder: (0, import_pg_core.integer)("sort_order").notNull().default(0),
|
|
416
|
+
createdAt: (0, import_pg_core.timestamp)("created_at", {
|
|
417
|
+
withTimezone: true
|
|
418
|
+
}).notNull().defaultNow(),
|
|
419
|
+
updatedAt: (0, import_pg_core.timestamp)("updated_at", {
|
|
420
|
+
withTimezone: true
|
|
421
|
+
}).notNull().defaultNow()
|
|
422
|
+
}, (table) => [
|
|
423
|
+
(0, import_pg_core.uniqueIndex)("idx_quick_replies_company_shortcut").on(table.companyId, table.shortcut),
|
|
424
|
+
(0, import_pg_core.index)("idx_quick_replies_company_order").on(table.companyId, table.sortOrder)
|
|
425
|
+
]);
|
|
384
426
|
var settings = metaWhatsAppSchema.table("settings", {
|
|
385
427
|
companyId: (0, import_pg_core.uuid)("company_id").primaryKey(),
|
|
386
428
|
templateName: (0, import_pg_core.varchar)("template_name", {
|
|
@@ -837,6 +879,7 @@ var MessageRepository = class {
|
|
|
837
879
|
// src/repositories/FlowGraphRepository.ts
|
|
838
880
|
var import_drizzle_orm4 = require("drizzle-orm");
|
|
839
881
|
var import_meta_whatsapp_contracts = require("@adatechnology/meta-whatsapp-contracts");
|
|
882
|
+
var import_meta_whatsapp_contracts2 = require("@adatechnology/meta-whatsapp-contracts");
|
|
840
883
|
var InvalidFlowGraphError = class extends Error {
|
|
841
884
|
static {
|
|
842
885
|
__name(this, "InvalidFlowGraphError");
|
|
@@ -855,10 +898,18 @@ function toContractGraph(row) {
|
|
|
855
898
|
label: row.label,
|
|
856
899
|
startNodeId: row.startNodeId,
|
|
857
900
|
version: row.version,
|
|
858
|
-
nodes: parsed.data
|
|
901
|
+
nodes: parsed.data,
|
|
902
|
+
origin: toOrigin(row.origin),
|
|
903
|
+
...row.seedVersion ? {
|
|
904
|
+
seedVersion: row.seedVersion
|
|
905
|
+
} : {}
|
|
859
906
|
};
|
|
860
907
|
}
|
|
861
908
|
__name(toContractGraph, "toContractGraph");
|
|
909
|
+
function toOrigin(value) {
|
|
910
|
+
return value === import_meta_whatsapp_contracts2.FLOW_GRAPH_ORIGIN.SEED ? import_meta_whatsapp_contracts2.FLOW_GRAPH_ORIGIN.SEED : import_meta_whatsapp_contracts2.FLOW_GRAPH_ORIGIN.EDITED;
|
|
911
|
+
}
|
|
912
|
+
__name(toOrigin, "toOrigin");
|
|
862
913
|
var OptimisticLockError = class extends Error {
|
|
863
914
|
static {
|
|
864
915
|
__name(this, "OptimisticLockError");
|
|
@@ -897,7 +948,11 @@ var FlowGraphRepository = class {
|
|
|
897
948
|
nodeCount: Object.keys(row.nodes).length,
|
|
898
949
|
showInMenu: row.showInMenu,
|
|
899
950
|
menuOptionLabel: row.menuOptionLabel ?? void 0,
|
|
900
|
-
updatedAt: row.updatedAt.toISOString()
|
|
951
|
+
updatedAt: row.updatedAt.toISOString(),
|
|
952
|
+
origin: toOrigin(row.origin),
|
|
953
|
+
...row.seedVersion ? {
|
|
954
|
+
seedVersion: row.seedVersion
|
|
955
|
+
} : {}
|
|
901
956
|
}));
|
|
902
957
|
}
|
|
903
958
|
// Valida antes de gravar: aceitar um grafo malformado e só reclamar na leitura empurraria a
|
|
@@ -915,7 +970,10 @@ var FlowGraphRepository = class {
|
|
|
915
970
|
startNodeId: graph.startNodeId,
|
|
916
971
|
nodes: graph.nodes,
|
|
917
972
|
showInMenu: graph.showInMenu ?? false,
|
|
918
|
-
menuOptionLabel: graph.menuOptionLabel
|
|
973
|
+
menuOptionLabel: graph.menuOptionLabel,
|
|
974
|
+
// Quem informa `seedVersion` é o produto semeando; criado pelo editor não traz e fica `edited`.
|
|
975
|
+
origin: graph.seedVersion ? import_meta_whatsapp_contracts2.FLOW_GRAPH_ORIGIN.SEED : import_meta_whatsapp_contracts2.FLOW_GRAPH_ORIGIN.EDITED,
|
|
976
|
+
seedVersion: graph.seedVersion ?? null
|
|
919
977
|
}).returning();
|
|
920
978
|
const createdGraph = toContractGraph(created);
|
|
921
979
|
await this.cache?.invalidate(companyId, createdGraph.key);
|
|
@@ -929,6 +987,8 @@ var FlowGraphRepository = class {
|
|
|
929
987
|
label: graph.label,
|
|
930
988
|
startNodeId: graph.startNodeId,
|
|
931
989
|
nodes: graph.nodes,
|
|
990
|
+
// Salvar é sempre edição humana, mesmo que o editor devolva `origin: 'seed'` do grafo que carregou.
|
|
991
|
+
origin: import_meta_whatsapp_contracts2.FLOW_GRAPH_ORIGIN.EDITED,
|
|
932
992
|
version: expectedVersion + 1,
|
|
933
993
|
updatedAt: /* @__PURE__ */ new Date()
|
|
934
994
|
}).where((0, import_drizzle_orm4.and)((0, import_drizzle_orm4.eq)(flowGraphs.companyId, companyId), (0, import_drizzle_orm4.eq)(flowGraphs.key, graph.key), (0, import_drizzle_orm4.eq)(flowGraphs.version, expectedVersion))).returning();
|
|
@@ -936,6 +996,38 @@ var FlowGraphRepository = class {
|
|
|
936
996
|
await this.cache?.invalidate(companyId, graph.key);
|
|
937
997
|
return toContractGraph(rows[0]);
|
|
938
998
|
}
|
|
999
|
+
/**
|
|
1000
|
+
* Atualiza um grafo semeado que ninguém editou. A condição `origin = 'seed'` vai no próprio UPDATE:
|
|
1001
|
+
* se uma pessoa salvar pelo editor entre a leitura e a escrita, o grafo vira `edited` e este update
|
|
1002
|
+
* não casa nenhuma linha — a edição nunca é sobrescrita. Idempotente por `seedVersion`.
|
|
1003
|
+
*/
|
|
1004
|
+
async reseed(params) {
|
|
1005
|
+
this.assertValidNodes(params.key, params.content.nodes);
|
|
1006
|
+
const rows = await this.db.update(flowGraphs).set({
|
|
1007
|
+
label: params.content.label,
|
|
1008
|
+
startNodeId: params.content.startNodeId,
|
|
1009
|
+
nodes: params.content.nodes,
|
|
1010
|
+
seedVersion: params.seedVersion,
|
|
1011
|
+
version: import_drizzle_orm4.sql`${flowGraphs.version} + 1`,
|
|
1012
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
1013
|
+
}).where((0, import_drizzle_orm4.and)((0, import_drizzle_orm4.eq)(flowGraphs.companyId, params.companyId), (0, import_drizzle_orm4.eq)(flowGraphs.key, params.key), (0, import_drizzle_orm4.eq)(flowGraphs.origin, import_meta_whatsapp_contracts2.FLOW_GRAPH_ORIGIN.SEED), import_drizzle_orm4.sql`${flowGraphs.seedVersion} is distinct from ${params.seedVersion}`)).returning();
|
|
1014
|
+
if (rows.length > 0) {
|
|
1015
|
+
await this.cache?.invalidate(params.companyId, params.key);
|
|
1016
|
+
return {
|
|
1017
|
+
status: "updated",
|
|
1018
|
+
graph: toContractGraph(rows[0])
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
const [existing] = await this.db.select({
|
|
1022
|
+
origin: flowGraphs.origin
|
|
1023
|
+
}).from(flowGraphs).where((0, import_drizzle_orm4.and)((0, import_drizzle_orm4.eq)(flowGraphs.companyId, params.companyId), (0, import_drizzle_orm4.eq)(flowGraphs.key, params.key))).limit(1);
|
|
1024
|
+
if (!existing) return {
|
|
1025
|
+
status: "missing"
|
|
1026
|
+
};
|
|
1027
|
+
return {
|
|
1028
|
+
status: existing.origin === import_meta_whatsapp_contracts2.FLOW_GRAPH_ORIGIN.SEED ? "current" : "edited"
|
|
1029
|
+
};
|
|
1030
|
+
}
|
|
939
1031
|
async delete(companyId, key) {
|
|
940
1032
|
await this.db.delete(flowGraphs).where((0, import_drizzle_orm4.and)((0, import_drizzle_orm4.eq)(flowGraphs.companyId, companyId), (0, import_drizzle_orm4.eq)(flowGraphs.key, key)));
|
|
941
1033
|
await this.cache?.invalidate(companyId, key);
|
|
@@ -1137,7 +1229,7 @@ var LogMessageUseCase = class {
|
|
|
1137
1229
|
};
|
|
1138
1230
|
|
|
1139
1231
|
// src/use-cases/SendMessage.use-case.ts
|
|
1140
|
-
var
|
|
1232
|
+
var import_meta_whatsapp_contracts3 = require("@adatechnology/meta-whatsapp-contracts");
|
|
1141
1233
|
var WHATSAPP_WINDOW_HOURS = 24;
|
|
1142
1234
|
var DEFAULT_FALLBACK_LIST_LABEL = "Op\xE7\xF5es";
|
|
1143
1235
|
var SendMessageUseCase = class {
|
|
@@ -1158,8 +1250,8 @@ var SendMessageUseCase = class {
|
|
|
1158
1250
|
}
|
|
1159
1251
|
async assertWithinWindow(companyId, whatsappNumber) {
|
|
1160
1252
|
const hours = await this.sessionRepository.hoursSinceLastInbound(companyId, whatsappNumber);
|
|
1161
|
-
if (hours === void 0) throw new
|
|
1162
|
-
if (hours >= WHATSAPP_WINDOW_HOURS) throw new
|
|
1253
|
+
if (hours === void 0) throw new import_meta_whatsapp_contracts3.WindowExpiredError();
|
|
1254
|
+
if (hours >= WHATSAPP_WINDOW_HOURS) throw new import_meta_whatsapp_contracts3.WindowExpiredError(hours);
|
|
1163
1255
|
}
|
|
1164
1256
|
async sendText(params) {
|
|
1165
1257
|
await this.assertWithinWindow(params.companyId, params.whatsappNumber);
|
|
@@ -1233,7 +1325,7 @@ var SendMessageUseCase = class {
|
|
|
1233
1325
|
* títulos das opções) em `payload.interactive`, para o histórico mostrar o que foi oferecido.
|
|
1234
1326
|
*/
|
|
1235
1327
|
async sendInteractive(params) {
|
|
1236
|
-
(0,
|
|
1328
|
+
(0, import_meta_whatsapp_contracts3.assertInteractiveWithinLimits)(params.interactive);
|
|
1237
1329
|
await this.assertWithinWindow(params.companyId, params.whatsappNumber);
|
|
1238
1330
|
const { externalMessageId } = await this.sendInteractiveThroughChannel(params);
|
|
1239
1331
|
return this.logMessage.execute({
|
|
@@ -1383,7 +1475,7 @@ var ReleaseConversationUseCase = class {
|
|
|
1383
1475
|
};
|
|
1384
1476
|
|
|
1385
1477
|
// src/use-cases/RequestHumanConversation.use-case.ts
|
|
1386
|
-
var
|
|
1478
|
+
var import_meta_whatsapp_contracts4 = require("@adatechnology/meta-whatsapp-contracts");
|
|
1387
1479
|
|
|
1388
1480
|
// src/channel/inboundDispatch.ts
|
|
1389
1481
|
var import_meta_graph_core = require("@adatechnology/meta-graph-core");
|
|
@@ -1510,7 +1602,7 @@ var RequestHumanConversationUseCase = class {
|
|
|
1510
1602
|
async execute(params) {
|
|
1511
1603
|
await this.sessionRepository.requestHuman(params.companyId, params.whatsappNumber);
|
|
1512
1604
|
const session = await this.sessionRepository.getContext(params.companyId, params.whatsappNumber);
|
|
1513
|
-
if (!session) throw new
|
|
1605
|
+
if (!session) throw new import_meta_whatsapp_contracts4.SessionNotFoundError(params.whatsappNumber);
|
|
1514
1606
|
this.realtime?.emit(`conv:${params.whatsappNumber}`, "human-requested", {
|
|
1515
1607
|
companyId: params.companyId,
|
|
1516
1608
|
humanRequestedAt: session.humanRequestedAt?.toISOString() ?? null
|
|
@@ -1548,7 +1640,7 @@ var ListConversationsUseCase = class {
|
|
|
1548
1640
|
};
|
|
1549
1641
|
|
|
1550
1642
|
// src/use-cases/ListMessages.use-case.ts
|
|
1551
|
-
var
|
|
1643
|
+
var import_meta_whatsapp_contracts5 = require("@adatechnology/meta-whatsapp-contracts");
|
|
1552
1644
|
var ListMessagesUseCase = class {
|
|
1553
1645
|
static {
|
|
1554
1646
|
__name(this, "ListMessagesUseCase");
|
|
@@ -1561,7 +1653,7 @@ var ListMessagesUseCase = class {
|
|
|
1561
1653
|
}
|
|
1562
1654
|
async execute(params) {
|
|
1563
1655
|
const session = await this.sessionRepository.getContext(params.companyId, params.whatsappNumber);
|
|
1564
|
-
if (!session) throw new
|
|
1656
|
+
if (!session) throw new import_meta_whatsapp_contracts5.SessionNotFoundError(params.whatsappNumber);
|
|
1565
1657
|
const repoParams = {
|
|
1566
1658
|
companyId: params.companyId,
|
|
1567
1659
|
sessionId: session.id,
|
|
@@ -1573,7 +1665,7 @@ var ListMessagesUseCase = class {
|
|
|
1573
1665
|
};
|
|
1574
1666
|
|
|
1575
1667
|
// src/use-cases/ListConversationDocuments.use-case.ts
|
|
1576
|
-
var
|
|
1668
|
+
var import_meta_whatsapp_contracts6 = require("@adatechnology/meta-whatsapp-contracts");
|
|
1577
1669
|
var ListConversationDocumentsUseCase = class {
|
|
1578
1670
|
static {
|
|
1579
1671
|
__name(this, "ListConversationDocumentsUseCase");
|
|
@@ -1586,7 +1678,7 @@ var ListConversationDocumentsUseCase = class {
|
|
|
1586
1678
|
}
|
|
1587
1679
|
async execute(params) {
|
|
1588
1680
|
const session = await this.sessionRepository.getContext(params.companyId, params.whatsappNumber);
|
|
1589
|
-
if (!session) throw new
|
|
1681
|
+
if (!session) throw new import_meta_whatsapp_contracts6.SessionNotFoundError(params.whatsappNumber);
|
|
1590
1682
|
const { rows, total } = await this.documentRepository.listByConversation({
|
|
1591
1683
|
companyId: params.companyId,
|
|
1592
1684
|
sessionId: session.id,
|
|
@@ -1664,7 +1756,7 @@ var ListCompanyDocumentsUseCase = class {
|
|
|
1664
1756
|
};
|
|
1665
1757
|
|
|
1666
1758
|
// src/use-cases/DeleteConversation.use-case.ts
|
|
1667
|
-
var
|
|
1759
|
+
var import_meta_whatsapp_contracts7 = require("@adatechnology/meta-whatsapp-contracts");
|
|
1668
1760
|
var DeleteConversationUseCase = class {
|
|
1669
1761
|
static {
|
|
1670
1762
|
__name(this, "DeleteConversationUseCase");
|
|
@@ -1679,7 +1771,7 @@ var DeleteConversationUseCase = class {
|
|
|
1679
1771
|
}
|
|
1680
1772
|
async execute(params) {
|
|
1681
1773
|
const session = await this.sessionRepository.getContext(params.companyId, params.whatsappNumber);
|
|
1682
|
-
if (!session) throw new
|
|
1774
|
+
if (!session) throw new import_meta_whatsapp_contracts7.SessionNotFoundError(params.whatsappNumber);
|
|
1683
1775
|
const uploadIds = await this.documentRepository.listUploadIdsBySession(params.companyId, session.id);
|
|
1684
1776
|
if (uploadIds.length > 0 && !this.objectStorage?.delete) {
|
|
1685
1777
|
throw new Error("storage_delete_unsupported: a conversa tem arquivos e o storage injetado n\xE3o implementa delete");
|
|
@@ -1924,8 +2016,171 @@ var DocumentRepository = class {
|
|
|
1924
2016
|
}
|
|
1925
2017
|
};
|
|
1926
2018
|
|
|
2019
|
+
// src/repositories/QuickReplyRepository.ts
|
|
2020
|
+
var import_drizzle_orm7 = require("drizzle-orm");
|
|
2021
|
+
var import_meta_whatsapp_contracts8 = require("@adatechnology/meta-whatsapp-contracts");
|
|
2022
|
+
var UNIQUE_VIOLATION_SQLSTATE = "23505";
|
|
2023
|
+
function hasUniqueViolationState(error) {
|
|
2024
|
+
const state = error;
|
|
2025
|
+
return state?.code === UNIQUE_VIOLATION_SQLSTATE || state?.errno === UNIQUE_VIOLATION_SQLSTATE;
|
|
2026
|
+
}
|
|
2027
|
+
__name(hasUniqueViolationState, "hasUniqueViolationState");
|
|
2028
|
+
function isUniqueViolation(error) {
|
|
2029
|
+
return hasUniqueViolationState(error) || hasUniqueViolationState(error?.cause);
|
|
2030
|
+
}
|
|
2031
|
+
__name(isUniqueViolation, "isUniqueViolation");
|
|
2032
|
+
function escapeLikePattern(text2) {
|
|
2033
|
+
return text2.replace(/[\\%_]/g, (character) => `\\${character}`);
|
|
2034
|
+
}
|
|
2035
|
+
__name(escapeLikePattern, "escapeLikePattern");
|
|
2036
|
+
var QuickReplyRepository = class {
|
|
2037
|
+
static {
|
|
2038
|
+
__name(this, "QuickReplyRepository");
|
|
2039
|
+
}
|
|
2040
|
+
db;
|
|
2041
|
+
constructor(db) {
|
|
2042
|
+
this.db = db;
|
|
2043
|
+
}
|
|
2044
|
+
async list(params) {
|
|
2045
|
+
const filters = [
|
|
2046
|
+
(0, import_drizzle_orm7.eq)(quickReplies.companyId, params.companyId)
|
|
2047
|
+
];
|
|
2048
|
+
if (params.search) {
|
|
2049
|
+
const pattern = `%${escapeLikePattern(params.search)}%`;
|
|
2050
|
+
const matches = (0, import_drizzle_orm7.or)((0, import_drizzle_orm7.ilike)(quickReplies.title, pattern), (0, import_drizzle_orm7.ilike)(quickReplies.shortcut, pattern), (0, import_drizzle_orm7.ilike)(quickReplies.body, pattern));
|
|
2051
|
+
if (matches) filters.push(matches);
|
|
2052
|
+
}
|
|
2053
|
+
return this.db.select().from(quickReplies).where((0, import_drizzle_orm7.and)(...filters)).orderBy((0, import_drizzle_orm7.asc)(quickReplies.sortOrder), (0, import_drizzle_orm7.asc)(quickReplies.title), (0, import_drizzle_orm7.asc)(quickReplies.id));
|
|
2054
|
+
}
|
|
2055
|
+
async get(companyId, id) {
|
|
2056
|
+
const [row] = await this.db.select().from(quickReplies).where((0, import_drizzle_orm7.and)((0, import_drizzle_orm7.eq)(quickReplies.companyId, companyId), (0, import_drizzle_orm7.eq)(quickReplies.id, id))).limit(1);
|
|
2057
|
+
return row;
|
|
2058
|
+
}
|
|
2059
|
+
async create(params) {
|
|
2060
|
+
const [totals] = await this.db.select({
|
|
2061
|
+
total: (0, import_drizzle_orm7.count)(),
|
|
2062
|
+
highestOrder: (0, import_drizzle_orm7.max)(quickReplies.sortOrder)
|
|
2063
|
+
}).from(quickReplies).where((0, import_drizzle_orm7.eq)(quickReplies.companyId, params.companyId));
|
|
2064
|
+
if ((totals?.total ?? 0) >= import_meta_whatsapp_contracts8.QUICK_REPLY_LIMITS.MAX_PER_COMPANY) {
|
|
2065
|
+
throw new import_meta_whatsapp_contracts8.QuickReplyLimitReachedError(import_meta_whatsapp_contracts8.QUICK_REPLY_LIMITS.MAX_PER_COMPANY);
|
|
2066
|
+
}
|
|
2067
|
+
try {
|
|
2068
|
+
const [row] = await this.db.insert(quickReplies).values({
|
|
2069
|
+
companyId: params.companyId,
|
|
2070
|
+
title: params.title,
|
|
2071
|
+
shortcut: params.shortcut,
|
|
2072
|
+
body: params.body,
|
|
2073
|
+
// Sem ordem explícita vai para o fim da lista.
|
|
2074
|
+
sortOrder: params.sortOrder ?? (totals?.highestOrder ?? -1) + 1
|
|
2075
|
+
}).returning();
|
|
2076
|
+
return row;
|
|
2077
|
+
} catch (error) {
|
|
2078
|
+
if (isUniqueViolation(error)) throw new import_meta_whatsapp_contracts8.QuickReplyShortcutTakenError(params.shortcut);
|
|
2079
|
+
throw error;
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
async update(params) {
|
|
2083
|
+
const [taken] = await this.db.select({
|
|
2084
|
+
id: quickReplies.id
|
|
2085
|
+
}).from(quickReplies).where((0, import_drizzle_orm7.and)((0, import_drizzle_orm7.eq)(quickReplies.companyId, params.companyId), (0, import_drizzle_orm7.eq)(quickReplies.shortcut, params.shortcut), (0, import_drizzle_orm7.ne)(quickReplies.id, params.id))).limit(1);
|
|
2086
|
+
if (taken) throw new import_meta_whatsapp_contracts8.QuickReplyShortcutTakenError(params.shortcut);
|
|
2087
|
+
try {
|
|
2088
|
+
const [row] = await this.db.update(quickReplies).set({
|
|
2089
|
+
title: params.title,
|
|
2090
|
+
shortcut: params.shortcut,
|
|
2091
|
+
body: params.body,
|
|
2092
|
+
...params.sortOrder !== void 0 ? {
|
|
2093
|
+
sortOrder: params.sortOrder
|
|
2094
|
+
} : {},
|
|
2095
|
+
updatedAt: import_drizzle_orm7.sql`now()`
|
|
2096
|
+
}).where((0, import_drizzle_orm7.and)((0, import_drizzle_orm7.eq)(quickReplies.companyId, params.companyId), (0, import_drizzle_orm7.eq)(quickReplies.id, params.id))).returning();
|
|
2097
|
+
if (!row) throw new import_meta_whatsapp_contracts8.QuickReplyNotFoundError(params.id);
|
|
2098
|
+
return row;
|
|
2099
|
+
} catch (error) {
|
|
2100
|
+
if (isUniqueViolation(error)) throw new import_meta_whatsapp_contracts8.QuickReplyShortcutTakenError(params.shortcut);
|
|
2101
|
+
throw error;
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
async delete(companyId, id) {
|
|
2105
|
+
const rows = await this.db.delete(quickReplies).where((0, import_drizzle_orm7.and)((0, import_drizzle_orm7.eq)(quickReplies.companyId, companyId), (0, import_drizzle_orm7.eq)(quickReplies.id, id))).returning({
|
|
2106
|
+
id: quickReplies.id
|
|
2107
|
+
});
|
|
2108
|
+
return rows.length > 0;
|
|
2109
|
+
}
|
|
2110
|
+
};
|
|
2111
|
+
|
|
2112
|
+
// src/use-cases/QuickReply.use-cases.ts
|
|
2113
|
+
var import_meta_whatsapp_contracts9 = require("@adatechnology/meta-whatsapp-contracts");
|
|
2114
|
+
function toQuickReplyView(row) {
|
|
2115
|
+
return {
|
|
2116
|
+
id: row.id,
|
|
2117
|
+
title: row.title,
|
|
2118
|
+
shortcut: row.shortcut,
|
|
2119
|
+
body: row.body,
|
|
2120
|
+
sortOrder: row.sortOrder,
|
|
2121
|
+
createdAt: row.createdAt.toISOString(),
|
|
2122
|
+
updatedAt: row.updatedAt.toISOString()
|
|
2123
|
+
};
|
|
2124
|
+
}
|
|
2125
|
+
__name(toQuickReplyView, "toQuickReplyView");
|
|
2126
|
+
var ListQuickRepliesUseCase = class {
|
|
2127
|
+
static {
|
|
2128
|
+
__name(this, "ListQuickRepliesUseCase");
|
|
2129
|
+
}
|
|
2130
|
+
repository;
|
|
2131
|
+
constructor(repository) {
|
|
2132
|
+
this.repository = repository;
|
|
2133
|
+
}
|
|
2134
|
+
async execute(params) {
|
|
2135
|
+
const rows = await this.repository.list({
|
|
2136
|
+
companyId: params.companyId,
|
|
2137
|
+
...params.search ? {
|
|
2138
|
+
search: params.search
|
|
2139
|
+
} : {}
|
|
2140
|
+
});
|
|
2141
|
+
return rows.map(toQuickReplyView);
|
|
2142
|
+
}
|
|
2143
|
+
};
|
|
2144
|
+
var CreateQuickReplyUseCase = class {
|
|
2145
|
+
static {
|
|
2146
|
+
__name(this, "CreateQuickReplyUseCase");
|
|
2147
|
+
}
|
|
2148
|
+
repository;
|
|
2149
|
+
constructor(repository) {
|
|
2150
|
+
this.repository = repository;
|
|
2151
|
+
}
|
|
2152
|
+
async execute(params) {
|
|
2153
|
+
return toQuickReplyView(await this.repository.create(params));
|
|
2154
|
+
}
|
|
2155
|
+
};
|
|
2156
|
+
var UpdateQuickReplyUseCase = class {
|
|
2157
|
+
static {
|
|
2158
|
+
__name(this, "UpdateQuickReplyUseCase");
|
|
2159
|
+
}
|
|
2160
|
+
repository;
|
|
2161
|
+
constructor(repository) {
|
|
2162
|
+
this.repository = repository;
|
|
2163
|
+
}
|
|
2164
|
+
async execute(params) {
|
|
2165
|
+
return toQuickReplyView(await this.repository.update(params));
|
|
2166
|
+
}
|
|
2167
|
+
};
|
|
2168
|
+
var DeleteQuickReplyUseCase = class {
|
|
2169
|
+
static {
|
|
2170
|
+
__name(this, "DeleteQuickReplyUseCase");
|
|
2171
|
+
}
|
|
2172
|
+
repository;
|
|
2173
|
+
constructor(repository) {
|
|
2174
|
+
this.repository = repository;
|
|
2175
|
+
}
|
|
2176
|
+
async execute(params) {
|
|
2177
|
+
const wasDeleted = await this.repository.delete(params.companyId, params.id);
|
|
2178
|
+
if (!wasDeleted) throw new import_meta_whatsapp_contracts9.QuickReplyNotFoundError(params.id);
|
|
2179
|
+
}
|
|
2180
|
+
};
|
|
2181
|
+
|
|
1927
2182
|
// src/use-cases/ExportConversation.use-case.ts
|
|
1928
|
-
var
|
|
2183
|
+
var import_meta_whatsapp_contracts10 = require("@adatechnology/meta-whatsapp-contracts");
|
|
1929
2184
|
var ExportConversationUseCase = class {
|
|
1930
2185
|
static {
|
|
1931
2186
|
__name(this, "ExportConversationUseCase");
|
|
@@ -1936,7 +2191,7 @@ var ExportConversationUseCase = class {
|
|
|
1936
2191
|
}
|
|
1937
2192
|
async execute(params) {
|
|
1938
2193
|
const result = await this.sessionRepository.exportConversation(params.companyId, params.whatsappNumber);
|
|
1939
|
-
if (!result) throw new
|
|
2194
|
+
if (!result) throw new import_meta_whatsapp_contracts10.SessionNotFoundError(params.whatsappNumber);
|
|
1940
2195
|
return result;
|
|
1941
2196
|
}
|
|
1942
2197
|
};
|
|
@@ -1990,6 +2245,18 @@ var SaveFlowGraphUseCase = class {
|
|
|
1990
2245
|
return this.flowGraphRepository.save(params.companyId, params.graph, params.expectedVersion);
|
|
1991
2246
|
}
|
|
1992
2247
|
};
|
|
2248
|
+
var ReseedFlowGraphUseCase = class {
|
|
2249
|
+
static {
|
|
2250
|
+
__name(this, "ReseedFlowGraphUseCase");
|
|
2251
|
+
}
|
|
2252
|
+
flowGraphRepository;
|
|
2253
|
+
constructor(flowGraphRepository) {
|
|
2254
|
+
this.flowGraphRepository = flowGraphRepository;
|
|
2255
|
+
}
|
|
2256
|
+
async execute(params) {
|
|
2257
|
+
return this.flowGraphRepository.reseed(params);
|
|
2258
|
+
}
|
|
2259
|
+
};
|
|
1993
2260
|
var DeleteFlowGraphUseCase = class {
|
|
1994
2261
|
static {
|
|
1995
2262
|
__name(this, "DeleteFlowGraphUseCase");
|
|
@@ -2016,7 +2283,7 @@ var GetLiveFlowPositionsUseCase = class {
|
|
|
2016
2283
|
};
|
|
2017
2284
|
|
|
2018
2285
|
// src/flows/FlowInterpreter.ts
|
|
2019
|
-
var
|
|
2286
|
+
var import_meta_whatsapp_contracts11 = require("@adatechnology/meta-whatsapp-contracts");
|
|
2020
2287
|
var DEFAULT_MAX_STEPS = 50;
|
|
2021
2288
|
function evaluateCondition(node, context) {
|
|
2022
2289
|
if (!node.conditionContextKey || !node.conditionOperator || !node.conditionValue) return false;
|
|
@@ -2119,9 +2386,9 @@ var FlowInterpreter = class {
|
|
|
2119
2386
|
kind: "terminal",
|
|
2120
2387
|
context: input.context
|
|
2121
2388
|
};
|
|
2122
|
-
if ((0,
|
|
2389
|
+
if ((0, import_meta_whatsapp_contracts11.isCrossFlowTarget)(nextNodeId)) return {
|
|
2123
2390
|
kind: "cross-flow",
|
|
2124
|
-
flowKey: (0,
|
|
2391
|
+
flowKey: (0, import_meta_whatsapp_contracts11.crossFlowKey)(nextNodeId),
|
|
2125
2392
|
context: input.context
|
|
2126
2393
|
};
|
|
2127
2394
|
if (!input.graph.nodes[nextNodeId]) return {
|
|
@@ -2181,10 +2448,10 @@ var FlowInterpreter = class {
|
|
|
2181
2448
|
};
|
|
2182
2449
|
|
|
2183
2450
|
// src/flows/FlowRunner.ts
|
|
2184
|
-
var
|
|
2451
|
+
var import_meta_whatsapp_contracts16 = require("@adatechnology/meta-whatsapp-contracts");
|
|
2185
2452
|
|
|
2186
2453
|
// src/flows/resolveFlowAnswer.ts
|
|
2187
|
-
var
|
|
2454
|
+
var import_meta_whatsapp_contracts12 = require("@adatechnology/meta-whatsapp-contracts");
|
|
2188
2455
|
|
|
2189
2456
|
// src/flows/flowRunner.constant.ts
|
|
2190
2457
|
var DEFAULT_START_FLOW_KEY = "main";
|
|
@@ -2210,12 +2477,12 @@ function isChoiceNode(node) {
|
|
|
2210
2477
|
__name(isChoiceNode, "isChoiceNode");
|
|
2211
2478
|
function keywordRoute(node, answer, isInteractiveReply) {
|
|
2212
2479
|
if (isInteractiveReply || typeof node.next !== "object" || !node.next.byKeyword) return void 0;
|
|
2213
|
-
return (0,
|
|
2480
|
+
return (0, import_meta_whatsapp_contracts12.matchFlowKeywordRoute)(answer, node.next.byKeyword);
|
|
2214
2481
|
}
|
|
2215
2482
|
__name(keywordRoute, "keywordRoute");
|
|
2216
2483
|
function matchOption(answer, options, isInteractiveReply) {
|
|
2217
2484
|
if (isInteractiveReply) return options.some(([id]) => id === answer) ? answer : void 0;
|
|
2218
|
-
return (0,
|
|
2485
|
+
return (0, import_meta_whatsapp_contracts12.matchFlowChoice)(answer, options);
|
|
2219
2486
|
}
|
|
2220
2487
|
__name(matchOption, "matchOption");
|
|
2221
2488
|
function resolveChoice(params, answer) {
|
|
@@ -2257,7 +2524,7 @@ function resolveQuestion(params, answer) {
|
|
|
2257
2524
|
kind: "jump",
|
|
2258
2525
|
target
|
|
2259
2526
|
};
|
|
2260
|
-
const result = (0,
|
|
2527
|
+
const result = (0, import_meta_whatsapp_contracts12.validateFlowAnswer)({
|
|
2261
2528
|
node: params.node,
|
|
2262
2529
|
answer,
|
|
2263
2530
|
context: params.context,
|
|
@@ -2285,10 +2552,10 @@ function resolveFlowAnswer(params) {
|
|
|
2285
2552
|
__name(resolveFlowAnswer, "resolveFlowAnswer");
|
|
2286
2553
|
|
|
2287
2554
|
// src/flows/FlowQuestionRenderer.ts
|
|
2288
|
-
var
|
|
2555
|
+
var import_meta_whatsapp_contracts14 = require("@adatechnology/meta-whatsapp-contracts");
|
|
2289
2556
|
|
|
2290
2557
|
// src/flows/buildFlowChoiceMessage.ts
|
|
2291
|
-
var
|
|
2558
|
+
var import_meta_whatsapp_contracts13 = require("@adatechnology/meta-whatsapp-contracts");
|
|
2292
2559
|
function groupSections(options) {
|
|
2293
2560
|
const sections = [];
|
|
2294
2561
|
for (const option of options) {
|
|
@@ -2321,7 +2588,7 @@ function asNumberedText(params) {
|
|
|
2321
2588
|
const description = option.description ? ` \u2014 ${option.description}` : "";
|
|
2322
2589
|
return `${index2 + 1}. ${option.title}${description}`;
|
|
2323
2590
|
});
|
|
2324
|
-
const limit =
|
|
2591
|
+
const limit = import_meta_whatsapp_contracts13.WHATSAPP_CHOICE_LIMIT.TEXT_BODY_LENGTH;
|
|
2325
2592
|
const full = `${params.body}
|
|
2326
2593
|
|
|
2327
2594
|
${lines.join("\n")}`;
|
|
@@ -2348,7 +2615,7 @@ ${line}`;
|
|
|
2348
2615
|
__name(asNumberedText, "asNumberedText");
|
|
2349
2616
|
function buildFlowChoiceMessage(params) {
|
|
2350
2617
|
const isPlain = params.options.every((option) => !option.description && !option.section);
|
|
2351
|
-
if (isPlain && params.options.length <=
|
|
2618
|
+
if (isPlain && params.options.length <= import_meta_whatsapp_contracts13.WHATSAPP_CHOICE_LIMIT.BUTTONS) {
|
|
2352
2619
|
const buttons = {
|
|
2353
2620
|
kind: "buttons",
|
|
2354
2621
|
body: params.body,
|
|
@@ -2357,7 +2624,7 @@ function buildFlowChoiceMessage(params) {
|
|
|
2357
2624
|
title: option.title
|
|
2358
2625
|
}))
|
|
2359
2626
|
};
|
|
2360
|
-
if ((0,
|
|
2627
|
+
if ((0, import_meta_whatsapp_contracts13.listInteractiveLimitViolations)(buttons).length === 0) return {
|
|
2361
2628
|
kind: "interactive",
|
|
2362
2629
|
interactive: buttons
|
|
2363
2630
|
};
|
|
@@ -2368,7 +2635,7 @@ function buildFlowChoiceMessage(params) {
|
|
|
2368
2635
|
buttonLabel: params.listButtonLabel,
|
|
2369
2636
|
sections: groupSections(params.options)
|
|
2370
2637
|
};
|
|
2371
|
-
if ((0,
|
|
2638
|
+
if ((0, import_meta_whatsapp_contracts13.listInteractiveLimitViolations)(list).length === 0) return {
|
|
2372
2639
|
kind: "interactive",
|
|
2373
2640
|
interactive: list
|
|
2374
2641
|
};
|
|
@@ -2405,7 +2672,7 @@ var FlowQuestionRenderer = class {
|
|
|
2405
2672
|
this.providers.set(key, provider);
|
|
2406
2673
|
}
|
|
2407
2674
|
interpolate(text2, variables) {
|
|
2408
|
-
return (0,
|
|
2675
|
+
return (0, import_meta_whatsapp_contracts14.interpolateFlowText)(text2, variables, this.config.formatValue ? {
|
|
2409
2676
|
formatValue: this.config.formatValue
|
|
2410
2677
|
} : {});
|
|
2411
2678
|
}
|
|
@@ -2416,7 +2683,7 @@ var FlowQuestionRenderer = class {
|
|
|
2416
2683
|
...params.variables
|
|
2417
2684
|
};
|
|
2418
2685
|
const body = this.interpolate(node.question ?? this.config.choicePrompt ?? DEFAULT_FLOW_TEXT.CHOICE_PROMPT, variables);
|
|
2419
|
-
const listButtonLabel = node.listButtonLabel ?? this.config.listButtonLabel ?? DEFAULT_FLOW_TEXT.LIST_BUTTON_LABEL;
|
|
2686
|
+
const listButtonLabel = this.interpolate(node.listButtonLabel ?? this.config.listButtonLabel ?? DEFAULT_FLOW_TEXT.LIST_BUTTON_LABEL, variables);
|
|
2420
2687
|
if (node.type === "dynamic_choice") {
|
|
2421
2688
|
const options = await this.loadDynamicOptions(params);
|
|
2422
2689
|
const shown = options.map((option) => [
|
|
@@ -2477,8 +2744,8 @@ var FlowQuestionRenderer = class {
|
|
|
2477
2744
|
async loadDynamicOptions(params) {
|
|
2478
2745
|
const { node } = params;
|
|
2479
2746
|
const provider = node.choiceProvider ? this.providers.get(node.choiceProvider) : void 0;
|
|
2480
|
-
if (!provider) throw new
|
|
2481
|
-
const pageSize =
|
|
2747
|
+
if (!provider) throw new import_meta_whatsapp_contracts14.FlowRunnerError("provider-missing", node.choiceProvider ?? node.id);
|
|
2748
|
+
const pageSize = import_meta_whatsapp_contracts14.WHATSAPP_CHOICE_LIMIT.LIST_ROWS - 1;
|
|
2482
2749
|
const result = await provider({
|
|
2483
2750
|
node,
|
|
2484
2751
|
session: params.session,
|
|
@@ -2526,16 +2793,16 @@ function readFlowInbound(message) {
|
|
|
2526
2793
|
__name(readFlowInbound, "readFlowInbound");
|
|
2527
2794
|
|
|
2528
2795
|
// src/flows/matchGlobalKeyword.ts
|
|
2529
|
-
var
|
|
2796
|
+
var import_meta_whatsapp_contracts15 = require("@adatechnology/meta-whatsapp-contracts");
|
|
2530
2797
|
function matchGlobalKeyword(text2, entries) {
|
|
2531
|
-
const normalized = (0,
|
|
2798
|
+
const normalized = (0, import_meta_whatsapp_contracts15.normalizeFlowText)(text2);
|
|
2532
2799
|
if (normalized.length === 0) return void 0;
|
|
2533
2800
|
const padded = ` ${normalized} `;
|
|
2534
2801
|
let best;
|
|
2535
2802
|
for (const entry of entries) {
|
|
2536
2803
|
const isWordMatch = entry.match === "word";
|
|
2537
2804
|
for (const keyword of entry.keywords) {
|
|
2538
|
-
const normalizedKeyword = (0,
|
|
2805
|
+
const normalizedKeyword = (0, import_meta_whatsapp_contracts15.normalizeFlowText)(keyword);
|
|
2539
2806
|
if (normalizedKeyword.length === 0) continue;
|
|
2540
2807
|
const isMatch = isWordMatch ? padded.includes(` ${normalizedKeyword} `) : normalizedKeyword === normalized;
|
|
2541
2808
|
if (isMatch && (!best || normalizedKeyword.length > best.length)) {
|
|
@@ -2582,7 +2849,7 @@ __name(contactVariables, "contactVariables");
|
|
|
2582
2849
|
function resolveFlowTimeZone(config) {
|
|
2583
2850
|
const businessHours = config.handoff?.businessHours;
|
|
2584
2851
|
const timeZone = config.timeZone ?? (typeof businessHours === "object" ? businessHours.timeZone : void 0);
|
|
2585
|
-
if (!timeZone) throw new
|
|
2852
|
+
if (!timeZone) throw new import_meta_whatsapp_contracts16.ConfigMissingError("features.flowRunner.timeZone");
|
|
2586
2853
|
new Intl.DateTimeFormat("en-US", {
|
|
2587
2854
|
timeZone
|
|
2588
2855
|
});
|
|
@@ -2687,7 +2954,7 @@ var FlowRunner = class {
|
|
|
2687
2954
|
const graph = savedGraph ?? (isStale ? await this.loadGraph(turn.companyId, this.startFlowKey()) : void 0);
|
|
2688
2955
|
if (!graph) return "no-flow";
|
|
2689
2956
|
await this.claim(turn);
|
|
2690
|
-
if (isStale) await this.report(turn, savedFlowKey, turn.session.currentNodeId, "cross-flow", new
|
|
2957
|
+
if (isStale) await this.report(turn, savedFlowKey, turn.session.currentNodeId, "cross-flow", new import_meta_whatsapp_contracts16.FlowRunnerError("flow-not-found", savedFlowKey));
|
|
2691
2958
|
const node = !isStale && turn.session.currentNodeId ? graph.nodes[turn.session.currentNodeId] : void 0;
|
|
2692
2959
|
const context = {
|
|
2693
2960
|
...turn.session.context
|
|
@@ -2765,7 +3032,7 @@ var FlowRunner = class {
|
|
|
2765
3032
|
const { config } = this.dependencies;
|
|
2766
3033
|
return {
|
|
2767
3034
|
now: config.now?.() ?? /* @__PURE__ */ new Date(),
|
|
2768
|
-
locale: config.dateLocale ??
|
|
3035
|
+
locale: config.dateLocale ?? import_meta_whatsapp_contracts16.FLOW_DATE_LOCALE_PT_BR,
|
|
2769
3036
|
timeZone: this.timeZone
|
|
2770
3037
|
};
|
|
2771
3038
|
}
|
|
@@ -2800,7 +3067,7 @@ var FlowRunner = class {
|
|
|
2800
3067
|
await this.handOff(turn, context);
|
|
2801
3068
|
return "handled";
|
|
2802
3069
|
}
|
|
2803
|
-
const flowKey = target === "restart" ? this.startFlowKey() : (0,
|
|
3070
|
+
const flowKey = target === "restart" ? this.startFlowKey() : (0, import_meta_whatsapp_contracts16.crossFlowKey)(target);
|
|
2804
3071
|
const graph = await this.loadGraph(turn.companyId, flowKey);
|
|
2805
3072
|
if (!graph) return "no-flow";
|
|
2806
3073
|
await this.claim(turn);
|
|
@@ -2986,8 +3253,8 @@ var FlowRunner = class {
|
|
|
2986
3253
|
});
|
|
2987
3254
|
}
|
|
2988
3255
|
async jumpTo(turn, graph, target, context) {
|
|
2989
|
-
if ((0,
|
|
2990
|
-
const targetGraph = await this.loadGraph(turn.companyId, (0,
|
|
3256
|
+
if ((0, import_meta_whatsapp_contracts16.isCrossFlowTarget)(target)) {
|
|
3257
|
+
const targetGraph = await this.loadGraph(turn.companyId, (0, import_meta_whatsapp_contracts16.crossFlowKey)(target));
|
|
2991
3258
|
if (!targetGraph) return this.reportMissingFlow(turn, graph.key, target, context);
|
|
2992
3259
|
return this.runFrom(turn, {
|
|
2993
3260
|
graph: targetGraph,
|
|
@@ -3045,7 +3312,7 @@ var FlowRunner = class {
|
|
|
3045
3312
|
nodeId: null,
|
|
3046
3313
|
context: result.context
|
|
3047
3314
|
});
|
|
3048
|
-
return this.report(turn, params.graph.key, null, "max-steps", new
|
|
3315
|
+
return this.report(turn, params.graph.key, null, "max-steps", new import_meta_whatsapp_contracts16.FlowRunnerError("cycle", result.visited.join(" -> ")));
|
|
3049
3316
|
}
|
|
3050
3317
|
const target = await this.loadGraph(turn.companyId, result.flowKey);
|
|
3051
3318
|
if (!target) return this.reportMissingFlow(turn, params.graph.key, result.flowKey, result.context);
|
|
@@ -3061,7 +3328,7 @@ var FlowRunner = class {
|
|
|
3061
3328
|
nodeId: null,
|
|
3062
3329
|
context: params.context
|
|
3063
3330
|
});
|
|
3064
|
-
return this.report(turn, params.graph.key, null, "cross-flow", new
|
|
3331
|
+
return this.report(turn, params.graph.key, null, "cross-flow", new import_meta_whatsapp_contracts16.FlowRunnerError("too-many-jumps", params.graph.key));
|
|
3065
3332
|
}
|
|
3066
3333
|
/** Grava a posição no nó e pergunta. Para `dynamic_choice`, busca a página antes de gravar. */
|
|
3067
3334
|
async awaitAnswer(turn, graph, node, context, page) {
|
|
@@ -3127,7 +3394,7 @@ var FlowRunner = class {
|
|
|
3127
3394
|
nodeId: null,
|
|
3128
3395
|
context
|
|
3129
3396
|
});
|
|
3130
|
-
await this.report(turn, fromFlowKey, null, "cross-flow", new
|
|
3397
|
+
await this.report(turn, fromFlowKey, null, "cross-flow", new import_meta_whatsapp_contracts16.FlowRunnerError("flow-not-found", target));
|
|
3131
3398
|
}
|
|
3132
3399
|
/**
|
|
3133
3400
|
* Nunca relança: só é chamado depois de o turno ter sido gravado, e relançar faria a fila repetir
|
|
@@ -3150,7 +3417,7 @@ var FlowRunner = class {
|
|
|
3150
3417
|
};
|
|
3151
3418
|
|
|
3152
3419
|
// src/flows/FlowHandoff.ts
|
|
3153
|
-
var
|
|
3420
|
+
var import_meta_whatsapp_contracts17 = require("@adatechnology/meta-whatsapp-contracts");
|
|
3154
3421
|
function readParam(node, key) {
|
|
3155
3422
|
const value = node?.actionParams?.[key];
|
|
3156
3423
|
return typeof value === "string" && value.trim().length > 0 ? value : void 0;
|
|
@@ -3180,7 +3447,7 @@ var FlowHandoff = class {
|
|
|
3180
3447
|
await sendMessage.sendText({
|
|
3181
3448
|
companyId: params.companyId,
|
|
3182
3449
|
whatsappNumber: params.whatsappNumber,
|
|
3183
|
-
body: (0,
|
|
3450
|
+
body: (0, import_meta_whatsapp_contracts17.interpolateFlowText)(template, params.variables, interpolation),
|
|
3184
3451
|
sender: "bot",
|
|
3185
3452
|
startState
|
|
3186
3453
|
});
|
|
@@ -3223,7 +3490,7 @@ var FlowHandoff = class {
|
|
|
3223
3490
|
async isWithinHours(companyId) {
|
|
3224
3491
|
const source = this.dependencies.config.businessHours;
|
|
3225
3492
|
const hours = typeof source === "function" ? await source(companyId) : source;
|
|
3226
|
-
return hours ? (0,
|
|
3493
|
+
return hours ? (0, import_meta_whatsapp_contracts17.isWithinBusinessHours)(hours, this.dependencies.now()) : true;
|
|
3227
3494
|
}
|
|
3228
3495
|
async messageFor(isWithinHours, params) {
|
|
3229
3496
|
const { config } = this.dependencies;
|
|
@@ -3256,7 +3523,7 @@ var FlowHandoff = class {
|
|
|
3256
3523
|
};
|
|
3257
3524
|
|
|
3258
3525
|
// src/flows/flowTurnLock.ts
|
|
3259
|
-
var
|
|
3526
|
+
var import_drizzle_orm8 = require("drizzle-orm");
|
|
3260
3527
|
function lockName(key) {
|
|
3261
3528
|
return `meta_whatsapp_flow:${key.companyId}:${key.whatsappNumber}`;
|
|
3262
3529
|
}
|
|
@@ -3271,7 +3538,7 @@ var PostgresAdvisoryFlowTurnLock = class {
|
|
|
3271
3538
|
}
|
|
3272
3539
|
withLock(key, work) {
|
|
3273
3540
|
return this.db.transaction(async (transaction) => {
|
|
3274
|
-
await transaction.execute(
|
|
3541
|
+
await transaction.execute(import_drizzle_orm8.sql`select pg_advisory_xact_lock(hashtext(${lockName(key)}))`);
|
|
3275
3542
|
return work();
|
|
3276
3543
|
});
|
|
3277
3544
|
}
|
|
@@ -3459,7 +3726,7 @@ async function listAvailableProducts(params) {
|
|
|
3459
3726
|
__name(listAvailableProducts, "listAvailableProducts");
|
|
3460
3727
|
|
|
3461
3728
|
// src/repositories/FlowMediaRepository.ts
|
|
3462
|
-
var
|
|
3729
|
+
var import_drizzle_orm9 = require("drizzle-orm");
|
|
3463
3730
|
var FlowMediaRepository = class {
|
|
3464
3731
|
static {
|
|
3465
3732
|
__name(this, "FlowMediaRepository");
|
|
@@ -3469,18 +3736,18 @@ var FlowMediaRepository = class {
|
|
|
3469
3736
|
this.db = db;
|
|
3470
3737
|
}
|
|
3471
3738
|
locationFilter(location) {
|
|
3472
|
-
return (0,
|
|
3739
|
+
return (0, import_drizzle_orm9.and)((0, import_drizzle_orm9.eq)(flowMedia.companyId, location.companyId), (0, import_drizzle_orm9.eq)(flowMedia.flowKey, location.flowKey), (0, import_drizzle_orm9.eq)(flowMedia.nodeId, location.nodeId));
|
|
3473
3740
|
}
|
|
3474
3741
|
// O que o nó realmente envia, na ordem de envio. `active` filtrado aqui e não no chamador:
|
|
3475
3742
|
// é a razão de a coluna existir, e um chamador que esquecesse do filtro mandaria ao cliente
|
|
3476
3743
|
// justamente o material que alguém desligou.
|
|
3477
3744
|
async listActive(location) {
|
|
3478
|
-
return this.db.select().from(flowMedia).where((0,
|
|
3745
|
+
return this.db.select().from(flowMedia).where((0, import_drizzle_orm9.and)(this.locationFilter(location), (0, import_drizzle_orm9.eq)(flowMedia.active, true))).orderBy((0, import_drizzle_orm9.asc)(flowMedia.sortOrder), (0, import_drizzle_orm9.asc)(flowMedia.createdAt));
|
|
3479
3746
|
}
|
|
3480
3747
|
// Inclui os desligados — é a visão do editor, onde desligar precisa continuar visível para
|
|
3481
3748
|
// poder ser religado.
|
|
3482
3749
|
async listAll(location) {
|
|
3483
|
-
return this.db.select().from(flowMedia).where(this.locationFilter(location)).orderBy((0,
|
|
3750
|
+
return this.db.select().from(flowMedia).where(this.locationFilter(location)).orderBy((0, import_drizzle_orm9.asc)(flowMedia.sortOrder), (0, import_drizzle_orm9.asc)(flowMedia.createdAt));
|
|
3484
3751
|
}
|
|
3485
3752
|
/**
|
|
3486
3753
|
* Anexa um arquivo já existente no storage ao nó.
|
|
@@ -3511,7 +3778,7 @@ var FlowMediaRepository = class {
|
|
|
3511
3778
|
caption: params.caption ?? null,
|
|
3512
3779
|
sortOrder: params.sortOrder ?? 0,
|
|
3513
3780
|
active: true,
|
|
3514
|
-
updatedAt:
|
|
3781
|
+
updatedAt: import_drizzle_orm9.sql`now()`
|
|
3515
3782
|
}
|
|
3516
3783
|
}).returning();
|
|
3517
3784
|
return row;
|
|
@@ -3527,8 +3794,8 @@ var FlowMediaRepository = class {
|
|
|
3527
3794
|
...params.active !== void 0 ? {
|
|
3528
3795
|
active: params.active
|
|
3529
3796
|
} : {},
|
|
3530
|
-
updatedAt:
|
|
3531
|
-
}).where((0,
|
|
3797
|
+
updatedAt: import_drizzle_orm9.sql`now()`
|
|
3798
|
+
}).where((0, import_drizzle_orm9.and)((0, import_drizzle_orm9.eq)(flowMedia.companyId, params.companyId), (0, import_drizzle_orm9.eq)(flowMedia.id, params.id))).returning();
|
|
3532
3799
|
return row;
|
|
3533
3800
|
}
|
|
3534
3801
|
/**
|
|
@@ -3537,17 +3804,17 @@ var FlowMediaRepository = class {
|
|
|
3537
3804
|
* host, que é dono da biblioteca de arquivos.
|
|
3538
3805
|
*/
|
|
3539
3806
|
async detach(params) {
|
|
3540
|
-
await this.db.delete(flowMedia).where((0,
|
|
3807
|
+
await this.db.delete(flowMedia).where((0, import_drizzle_orm9.and)((0, import_drizzle_orm9.eq)(flowMedia.companyId, params.companyId), (0, import_drizzle_orm9.eq)(flowMedia.id, params.id)));
|
|
3541
3808
|
}
|
|
3542
3809
|
// Chamado ao salvar o grafo: nós apagados no editor deixam linhas que nada mais alcança.
|
|
3543
3810
|
async detachRemovedNodes(params) {
|
|
3544
|
-
const condition = params.existingNodeIds.length === 0 ? void 0 :
|
|
3545
|
-
await this.db.delete(flowMedia).where((0,
|
|
3811
|
+
const condition = params.existingNodeIds.length === 0 ? void 0 : import_drizzle_orm9.sql`${flowMedia.nodeId} NOT IN ${params.existingNodeIds}`;
|
|
3812
|
+
await this.db.delete(flowMedia).where((0, import_drizzle_orm9.and)((0, import_drizzle_orm9.eq)(flowMedia.companyId, params.companyId), (0, import_drizzle_orm9.eq)(flowMedia.flowKey, params.flowKey), condition));
|
|
3546
3813
|
}
|
|
3547
3814
|
};
|
|
3548
3815
|
|
|
3549
3816
|
// src/repositories/FlowMediaIdRepository.ts
|
|
3550
|
-
var
|
|
3817
|
+
var import_drizzle_orm10 = require("drizzle-orm");
|
|
3551
3818
|
var FlowMediaIdRepository = class {
|
|
3552
3819
|
static {
|
|
3553
3820
|
__name(this, "FlowMediaIdRepository");
|
|
@@ -3559,7 +3826,7 @@ var FlowMediaIdRepository = class {
|
|
|
3559
3826
|
async get(params) {
|
|
3560
3827
|
const rows = await this.db.select({
|
|
3561
3828
|
ids: flowMedia.metaMediaIds
|
|
3562
|
-
}).from(flowMedia).where((0,
|
|
3829
|
+
}).from(flowMedia).where((0, import_drizzle_orm10.eq)(flowMedia.id, params.flowMediaId)).limit(1);
|
|
3563
3830
|
return rows[0]?.ids?.[params.senderKey];
|
|
3564
3831
|
}
|
|
3565
3832
|
/**
|
|
@@ -3571,23 +3838,23 @@ var FlowMediaIdRepository = class {
|
|
|
3571
3838
|
*/
|
|
3572
3839
|
async set(params) {
|
|
3573
3840
|
await this.db.update(flowMedia).set({
|
|
3574
|
-
metaMediaIds:
|
|
3575
|
-
}).where((0,
|
|
3841
|
+
metaMediaIds: import_drizzle_orm10.sql`jsonb_set(${flowMedia.metaMediaIds}, ARRAY[${params.senderKey}::text], to_jsonb(${params.mediaId}::text), true)`
|
|
3842
|
+
}).where((0, import_drizzle_orm10.eq)(flowMedia.id, params.flowMediaId));
|
|
3576
3843
|
}
|
|
3577
3844
|
/** Remove só a chave deste número — o id do outro número continua válido. */
|
|
3578
3845
|
async clear(params) {
|
|
3579
3846
|
await this.db.update(flowMedia).set({
|
|
3580
|
-
metaMediaIds:
|
|
3581
|
-
}).where((0,
|
|
3847
|
+
metaMediaIds: import_drizzle_orm10.sql`${flowMedia.metaMediaIds} - ${params.senderKey}::text`
|
|
3848
|
+
}).where((0, import_drizzle_orm10.eq)(flowMedia.id, params.flowMediaId));
|
|
3582
3849
|
}
|
|
3583
3850
|
};
|
|
3584
3851
|
|
|
3585
3852
|
// src/channel/WhatsAppChannelAdapter.ts
|
|
3586
3853
|
var import_meta_graph_core2 = require("@adatechnology/meta-graph-core");
|
|
3587
|
-
var
|
|
3854
|
+
var import_meta_whatsapp_contracts19 = require("@adatechnology/meta-whatsapp-contracts");
|
|
3588
3855
|
|
|
3589
3856
|
// src/channel/previewMedia.ts
|
|
3590
|
-
var
|
|
3857
|
+
var import_meta_whatsapp_contracts18 = require("@adatechnology/meta-whatsapp-contracts");
|
|
3591
3858
|
|
|
3592
3859
|
// src/channel/WhatsAppChannelAdapter.ts
|
|
3593
3860
|
var WhatsAppChannelAdapter = class {
|
|
@@ -3604,14 +3871,14 @@ var WhatsAppChannelAdapter = class {
|
|
|
3604
3871
|
}
|
|
3605
3872
|
/** `preview.<uuid>` quando o destino é contato do simulador e o recurso está ligado. */
|
|
3606
3873
|
previewMessageId(to) {
|
|
3607
|
-
if (!this.previewContacts?.isEnabled || !(0,
|
|
3874
|
+
if (!this.previewContacts?.isEnabled || !(0, import_meta_whatsapp_contracts19.isPreviewContact)(to)) return void 0;
|
|
3608
3875
|
return `preview.${this.previewContacts.generateId?.() ?? globalThis.crypto.randomUUID()}`;
|
|
3609
3876
|
}
|
|
3610
3877
|
async translateErrors(operation) {
|
|
3611
3878
|
try {
|
|
3612
3879
|
return await operation();
|
|
3613
3880
|
} catch (error) {
|
|
3614
|
-
if (error instanceof import_meta_graph_core2.WhatsAppWindowExpiredError) throw new
|
|
3881
|
+
if (error instanceof import_meta_graph_core2.WhatsAppWindowExpiredError) throw new import_meta_whatsapp_contracts19.WindowExpiredError();
|
|
3615
3882
|
throw error;
|
|
3616
3883
|
}
|
|
3617
3884
|
}
|
|
@@ -3714,7 +3981,7 @@ var WhatsAppChannelAdapter = class {
|
|
|
3714
3981
|
* tentar buscá-lo lá renderia um 404 confuso em vez do áudio que o operador acabou de gravar.
|
|
3715
3982
|
*/
|
|
3716
3983
|
async fetchMediaAsBase64(mediaId) {
|
|
3717
|
-
const uploadId = this.previewMedia?.isEnabled ? (0,
|
|
3984
|
+
const uploadId = this.previewMedia?.isEnabled ? (0, import_meta_whatsapp_contracts18.resolvePreviewUploadId)(mediaId) : void 0;
|
|
3718
3985
|
if (uploadId) {
|
|
3719
3986
|
const buffer = await this.previewMedia.objectStorage.getObject(uploadId);
|
|
3720
3987
|
return {
|
|
@@ -3727,19 +3994,19 @@ var WhatsAppChannelAdapter = class {
|
|
|
3727
3994
|
};
|
|
3728
3995
|
|
|
3729
3996
|
// src/channel/ReceiveWebhook.use-case.ts
|
|
3730
|
-
var
|
|
3997
|
+
var import_meta_whatsapp_contracts22 = require("@adatechnology/meta-whatsapp-contracts");
|
|
3731
3998
|
|
|
3732
3999
|
// src/channel/webhookSecurity.ts
|
|
3733
4000
|
var import_meta_graph_core3 = require("@adatechnology/meta-graph-core");
|
|
3734
|
-
var
|
|
4001
|
+
var import_meta_whatsapp_contracts20 = require("@adatechnology/meta-whatsapp-contracts");
|
|
3735
4002
|
var WEBHOOK_NONCE_NAMESPACE = "meta-whatsapp";
|
|
3736
4003
|
function verifyWebhookChallenge(params) {
|
|
3737
|
-
if (!(0, import_meta_graph_core3.isValidWebhookChallenge)(params)) throw new
|
|
4004
|
+
if (!(0, import_meta_graph_core3.isValidWebhookChallenge)(params)) throw new import_meta_whatsapp_contracts20.InvalidWebhookSignatureError();
|
|
3738
4005
|
return params.challenge;
|
|
3739
4006
|
}
|
|
3740
4007
|
__name(verifyWebhookChallenge, "verifyWebhookChallenge");
|
|
3741
4008
|
function verifyWebhookSignature(params) {
|
|
3742
|
-
if (!(0, import_meta_graph_core3.isValidWebhookSignature)(params)) throw new
|
|
4009
|
+
if (!(0, import_meta_graph_core3.isValidWebhookSignature)(params)) throw new import_meta_whatsapp_contracts20.InvalidWebhookSignatureError();
|
|
3743
4010
|
}
|
|
3744
4011
|
__name(verifyWebhookSignature, "verifyWebhookSignature");
|
|
3745
4012
|
function deliveryKey(signatureHeader) {
|
|
@@ -3759,10 +4026,10 @@ async function confirmWebhookDelivery(params) {
|
|
|
3759
4026
|
__name(confirmWebhookDelivery, "confirmWebhookDelivery");
|
|
3760
4027
|
|
|
3761
4028
|
// src/channel/IngestInboundMedia.use-case.ts
|
|
3762
|
-
var
|
|
4029
|
+
var import_drizzle_orm11 = require("drizzle-orm");
|
|
3763
4030
|
|
|
3764
4031
|
// src/use-cases/TranscribeAudio.use-case.ts
|
|
3765
|
-
var
|
|
4032
|
+
var import_meta_whatsapp_contracts21 = require("@adatechnology/meta-whatsapp-contracts");
|
|
3766
4033
|
|
|
3767
4034
|
// src/transcription.types.ts
|
|
3768
4035
|
var TRANSCRIPTION_STATUS = {
|
|
@@ -3823,7 +4090,7 @@ var TranscribeAudioUseCase = class {
|
|
|
3823
4090
|
}
|
|
3824
4091
|
if (this.dependencies.resolvePolicy) {
|
|
3825
4092
|
const policy = await this.dependencies.resolvePolicy(params.companyId);
|
|
3826
|
-
if (!policy.isEnabled) throw new
|
|
4093
|
+
if (!policy.isEnabled) throw new import_meta_whatsapp_contracts21.TranscriptionDisabledError();
|
|
3827
4094
|
}
|
|
3828
4095
|
const audio = extractAudioReference(message);
|
|
3829
4096
|
const buffer = await this.dependencies.objectStorage.getObject(audio.uploadId);
|
|
@@ -3900,11 +4167,11 @@ function extractAudioReference(message) {
|
|
|
3900
4167
|
const audio = payload["audio"];
|
|
3901
4168
|
const mimeType = typeof payload["mimeType"] === "string" ? payload["mimeType"] : audio?.mime_type;
|
|
3902
4169
|
if (!isAudioMimeType(mimeType) && !audio) {
|
|
3903
|
-
throw new
|
|
4170
|
+
throw new import_meta_whatsapp_contracts21.MessageNotAudioError(message.id, message.type);
|
|
3904
4171
|
}
|
|
3905
4172
|
const uploadId = payload["uploadId"];
|
|
3906
4173
|
if (typeof uploadId !== "string" || uploadId.length === 0) {
|
|
3907
|
-
throw new
|
|
4174
|
+
throw new import_meta_whatsapp_contracts21.AudioNotIngestedError(message.id);
|
|
3908
4175
|
}
|
|
3909
4176
|
return {
|
|
3910
4177
|
uploadId,
|
|
@@ -3931,7 +4198,7 @@ var IngestInboundMediaUseCase = class {
|
|
|
3931
4198
|
this.transcription = transcription;
|
|
3932
4199
|
}
|
|
3933
4200
|
async execute(params) {
|
|
3934
|
-
const [message] = await this.db.select().from(messages).where((0,
|
|
4201
|
+
const [message] = await this.db.select().from(messages).where((0, import_drizzle_orm11.and)((0, import_drizzle_orm11.eq)(messages.companyId, params.companyId), (0, import_drizzle_orm11.eq)(messages.id, params.messageId))).limit(1);
|
|
3935
4202
|
if (!message) throw new Error(`Mensagem ${params.messageId} n\xE3o encontrada para ingest\xE3o de m\xEDdia`);
|
|
3936
4203
|
const payload = message.payload ?? {};
|
|
3937
4204
|
if (payload["uploadId"] && payload["sourceMediaId"] === params.sourceMediaId) {
|
|
@@ -3962,7 +4229,7 @@ var IngestInboundMediaUseCase = class {
|
|
|
3962
4229
|
};
|
|
3963
4230
|
await this.db.update(messages).set({
|
|
3964
4231
|
payload: updatedPayload
|
|
3965
|
-
}).where((0,
|
|
4232
|
+
}).where((0, import_drizzle_orm11.and)((0, import_drizzle_orm11.eq)(messages.companyId, params.companyId), (0, import_drizzle_orm11.eq)(messages.id, params.messageId)));
|
|
3966
4233
|
await this.documentRepository?.link({
|
|
3967
4234
|
companyId: params.companyId,
|
|
3968
4235
|
sessionId: message.sessionId,
|
|
@@ -4120,8 +4387,8 @@ function extractPayload(message, { isLocationRedacted } = DEFAULT_EXTRACTION_OPT
|
|
|
4120
4387
|
}
|
|
4121
4388
|
__name(extractPayload, "extractPayload");
|
|
4122
4389
|
var ACCOUNT_EVENT_FIELDS = [
|
|
4123
|
-
|
|
4124
|
-
|
|
4390
|
+
import_meta_whatsapp_contracts22.WHATSAPP_WEBHOOK_FIELDS.TEMPLATE_STATUS_UPDATE,
|
|
4391
|
+
import_meta_whatsapp_contracts22.WHATSAPP_WEBHOOK_FIELDS.PHONE_NUMBER_QUALITY_UPDATE
|
|
4125
4392
|
];
|
|
4126
4393
|
function isAccountEventField(field) {
|
|
4127
4394
|
return field !== void 0 && ACCOUNT_EVENT_FIELDS.includes(field);
|
|
@@ -4163,7 +4430,7 @@ var ReceiveWebhookUseCase = class {
|
|
|
4163
4430
|
...EMPTY_RESULT
|
|
4164
4431
|
};
|
|
4165
4432
|
const rawText = typeof input.rawBody === "string" ? input.rawBody : input.rawBody.toString("utf8");
|
|
4166
|
-
const parsed =
|
|
4433
|
+
const parsed = import_meta_whatsapp_contracts22.whatsAppWebhookPayloadSchema.safeParse(JSON.parse(rawText));
|
|
4167
4434
|
if (!parsed.success) {
|
|
4168
4435
|
await this.params.hooks?.onUnhandledWebhookEvent?.({
|
|
4169
4436
|
field: void 0,
|
|
@@ -4196,7 +4463,7 @@ var ReceiveWebhookUseCase = class {
|
|
|
4196
4463
|
continue;
|
|
4197
4464
|
}
|
|
4198
4465
|
for (const message of change.value.messages ?? []) {
|
|
4199
|
-
const profileName = (0,
|
|
4466
|
+
const profileName = (0, import_meta_whatsapp_contracts22.resolveContactProfileName)({
|
|
4200
4467
|
contacts: change.value.contacts,
|
|
4201
4468
|
from: message.from
|
|
4202
4469
|
});
|
|
@@ -4234,8 +4501,8 @@ var ReceiveWebhookUseCase = class {
|
|
|
4234
4501
|
// Devolve `false` quando o corpo não bate com o schema do field — o chamador conta como não
|
|
4235
4502
|
// tratado. O host é avisado nos dois casos, mas com `reason` diferente.
|
|
4236
4503
|
async handleAccountEvent(change) {
|
|
4237
|
-
if (change.field ===
|
|
4238
|
-
const update =
|
|
4504
|
+
if (change.field === import_meta_whatsapp_contracts22.WHATSAPP_WEBHOOK_FIELDS.TEMPLATE_STATUS_UPDATE) {
|
|
4505
|
+
const update = import_meta_whatsapp_contracts22.whatsAppTemplateStatusUpdateSchema.safeParse(change.value);
|
|
4239
4506
|
if (!update.success) {
|
|
4240
4507
|
await this.params.hooks?.onUnhandledWebhookEvent?.({
|
|
4241
4508
|
field: change.field,
|
|
@@ -4247,7 +4514,7 @@ var ReceiveWebhookUseCase = class {
|
|
|
4247
4514
|
await this.params.hooks?.onTemplateStatusUpdate?.(update.data);
|
|
4248
4515
|
return true;
|
|
4249
4516
|
}
|
|
4250
|
-
const quality =
|
|
4517
|
+
const quality = import_meta_whatsapp_contracts22.whatsAppPhoneNumberQualityUpdateSchema.safeParse(change.value);
|
|
4251
4518
|
if (!quality.success) {
|
|
4252
4519
|
await this.params.hooks?.onUnhandledWebhookEvent?.({
|
|
4253
4520
|
field: change.field,
|
|
@@ -4379,7 +4646,7 @@ var StorePreviewMediaUseCase = class {
|
|
|
4379
4646
|
key
|
|
4380
4647
|
});
|
|
4381
4648
|
return {
|
|
4382
|
-
mediaId: (0,
|
|
4649
|
+
mediaId: (0, import_meta_whatsapp_contracts18.toPreviewMediaId)(uploadId),
|
|
4383
4650
|
uploadId
|
|
4384
4651
|
};
|
|
4385
4652
|
}
|
|
@@ -4411,6 +4678,7 @@ function createMetaWhatsAppModule(params) {
|
|
|
4411
4678
|
const flowGraphCache = flowGraphCacheFeature && providers.cache ? new FlowGraphCache(providers.cache, typeof flowGraphCacheFeature === "object" ? flowGraphCacheFeature.ttlSeconds ?? DEFAULT_FLOW_GRAPH_CACHE_TTL_SECONDS : DEFAULT_FLOW_GRAPH_CACHE_TTL_SECONDS) : void 0;
|
|
4412
4679
|
const flowGraphRepository = new FlowGraphRepository(db, flowGraphCache);
|
|
4413
4680
|
const documentRepository = new DocumentRepository(db);
|
|
4681
|
+
const quickReplyRepository = new QuickReplyRepository(db);
|
|
4414
4682
|
const flowMediaRepository = new FlowMediaRepository(db);
|
|
4415
4683
|
const logMessage = new LogMessageUseCase(sessionRepository, messageRepository, providers.realtime, providers.moderator);
|
|
4416
4684
|
const sendMessage = new SendMessageUseCase(channel, sessionRepository, logMessage, providers.objectStorage, documentRepository);
|
|
@@ -4446,7 +4714,7 @@ function createMetaWhatsAppModule(params) {
|
|
|
4446
4714
|
} : {}
|
|
4447
4715
|
}) : void 0;
|
|
4448
4716
|
if (flowInterpreter && flowRunner && flowHandoff) {
|
|
4449
|
-
flowInterpreter.registerFlowAction(
|
|
4717
|
+
flowInterpreter.registerFlowAction(import_meta_whatsapp_contracts23.FLOW_ACTION_KIND.HANDOFF, flowHandoff.createActionHandler((turn) => flowRunner.variablesFor(turn)));
|
|
4450
4718
|
}
|
|
4451
4719
|
const receiveWebhook = new ReceiveWebhookUseCase({
|
|
4452
4720
|
appSecret: config.appSecret,
|
|
@@ -4467,7 +4735,7 @@ function createMetaWhatsAppModule(params) {
|
|
|
4467
4735
|
} : {}
|
|
4468
4736
|
});
|
|
4469
4737
|
if (flowInterpreter && providers.objectStorage?.getObject) {
|
|
4470
|
-
flowInterpreter.registerFlowAction(
|
|
4738
|
+
flowInterpreter.registerFlowAction(import_meta_whatsapp_contracts23.FLOW_ACTION_KIND.SEND_MEDIA, createSendMediaAction({
|
|
4471
4739
|
flowMediaRepository,
|
|
4472
4740
|
objectStorage: providers.objectStorage,
|
|
4473
4741
|
logMessage,
|
|
@@ -4484,7 +4752,7 @@ function createMetaWhatsAppModule(params) {
|
|
|
4484
4752
|
}));
|
|
4485
4753
|
}
|
|
4486
4754
|
if (flowInterpreter && providers.catalog && config.catalogId) {
|
|
4487
|
-
flowInterpreter.registerFlowAction(
|
|
4755
|
+
flowInterpreter.registerFlowAction(import_meta_whatsapp_contracts23.FLOW_ACTION_KIND.SEND_PRODUCT_LIST, createSendProductListAction({
|
|
4488
4756
|
catalog: providers.catalog,
|
|
4489
4757
|
catalogId: config.catalogId,
|
|
4490
4758
|
logMessage,
|
|
@@ -4568,6 +4836,18 @@ function createMetaWhatsAppModule(params) {
|
|
|
4568
4836
|
} : void 0,
|
|
4569
4837
|
settings: settingsRepository,
|
|
4570
4838
|
/**
|
|
4839
|
+
* Respostas rápidas por empresa (o `/atalho` do composer). Só texto. As rotas HTTP saem de
|
|
4840
|
+
* `createMetaWhatsAppQuickReplyRoutes({ module })`; o host que prefere as próprias usa os
|
|
4841
|
+
* casos de uso daqui.
|
|
4842
|
+
*/
|
|
4843
|
+
quickReplies: {
|
|
4844
|
+
list: new ListQuickRepliesUseCase(quickReplyRepository),
|
|
4845
|
+
create: new CreateQuickReplyUseCase(quickReplyRepository),
|
|
4846
|
+
update: new UpdateQuickReplyUseCase(quickReplyRepository),
|
|
4847
|
+
delete: new DeleteQuickReplyUseCase(quickReplyRepository),
|
|
4848
|
+
repository: quickReplyRepository
|
|
4849
|
+
},
|
|
4850
|
+
/**
|
|
4571
4851
|
* `undefined` quando o recurso não está ligado (ou falta storage legível). O host consulta a
|
|
4572
4852
|
* ausência para não registrar a rota de upload — e o preview, sem a rota, esconde o microfone.
|
|
4573
4853
|
*/
|
|
@@ -4613,13 +4893,14 @@ function createMetaWhatsAppModule(params) {
|
|
|
4613
4893
|
// undefined quando `features.flowRunner` está desligado — o host dirige a conversa.
|
|
4614
4894
|
runner: flowRunner,
|
|
4615
4895
|
registerDynamicChoiceProvider: /* @__PURE__ */ __name((key, provider) => {
|
|
4616
|
-
if (!flowRunner) throw new
|
|
4896
|
+
if (!flowRunner) throw new import_meta_whatsapp_contracts23.ConfigMissingError("features.flowRunner");
|
|
4617
4897
|
flowRunner.registerDynamicChoiceProvider(key, provider);
|
|
4618
4898
|
}, "registerDynamicChoiceProvider"),
|
|
4619
4899
|
get: new GetFlowGraphUseCase(flowGraphRepository),
|
|
4620
4900
|
list: new ListFlowGraphsUseCase(flowGraphRepository),
|
|
4621
4901
|
create: new CreateFlowGraphUseCase(flowGraphRepository),
|
|
4622
4902
|
save: new SaveFlowGraphUseCase(flowGraphRepository),
|
|
4903
|
+
reseed: new ReseedFlowGraphUseCase(flowGraphRepository),
|
|
4623
4904
|
delete: new DeleteFlowGraphUseCase(flowGraphRepository),
|
|
4624
4905
|
livePositions: new GetLiveFlowPositionsUseCase(flowGraphRepository),
|
|
4625
4906
|
repository: flowGraphRepository,
|
|
@@ -4737,18 +5018,149 @@ async function redeemSseTicket(store, ticket) {
|
|
|
4737
5018
|
return JSON.parse(raw);
|
|
4738
5019
|
}
|
|
4739
5020
|
__name(redeemSseTicket, "redeemSseTicket");
|
|
5021
|
+
|
|
5022
|
+
// src/http/quickReplyRoutes.ts
|
|
5023
|
+
var import_meta_whatsapp_contracts24 = require("@adatechnology/meta-whatsapp-contracts");
|
|
5024
|
+
var import_module_http = require("@adatechnology/module-http");
|
|
5025
|
+
|
|
5026
|
+
// src/http/quickReplyScope.constant.ts
|
|
5027
|
+
var QUICK_REPLY_SCOPE = {
|
|
5028
|
+
WRITE: "quick-replies:write"
|
|
5029
|
+
};
|
|
5030
|
+
var DEFAULT_QUICK_REPLY_WRITE_SCOPES = [
|
|
5031
|
+
QUICK_REPLY_SCOPE.WRITE
|
|
5032
|
+
];
|
|
5033
|
+
|
|
5034
|
+
// src/http/quickReplyRoutes.ts
|
|
5035
|
+
function requireCompany(context) {
|
|
5036
|
+
if (!context.auth?.companyId) {
|
|
5037
|
+
throw new import_meta_whatsapp_contracts24.MetaWhatsAppError("Rota exige contexto autenticado.", 401, import_meta_whatsapp_contracts24.META_WHATSAPP_ERROR_CODES.CONFIG_MISSING);
|
|
5038
|
+
}
|
|
5039
|
+
return context.auth.companyId;
|
|
5040
|
+
}
|
|
5041
|
+
__name(requireCompany, "requireCompany");
|
|
5042
|
+
function requireId(context) {
|
|
5043
|
+
const id = context.params.id;
|
|
5044
|
+
if (!id) throw new import_meta_whatsapp_contracts24.QuickReplyNotFoundError("");
|
|
5045
|
+
return id;
|
|
5046
|
+
}
|
|
5047
|
+
__name(requireId, "requireId");
|
|
5048
|
+
function createMetaWhatsAppQuickReplyRoutes(params) {
|
|
5049
|
+
const { list, create, update, delete: remove } = params.module.quickReplies;
|
|
5050
|
+
const write = {
|
|
5051
|
+
scope: import_module_http.ROUTE_SCOPE.ADMIN,
|
|
5052
|
+
requiredScopes: params.scopes?.write ?? DEFAULT_QUICK_REPLY_WRITE_SCOPES
|
|
5053
|
+
};
|
|
5054
|
+
const read = {
|
|
5055
|
+
scope: import_module_http.ROUTE_SCOPE.USER,
|
|
5056
|
+
...params.scopes?.read?.length ? {
|
|
5057
|
+
requiredScopes: params.scopes.read
|
|
5058
|
+
} : {}
|
|
5059
|
+
};
|
|
5060
|
+
const routes = [
|
|
5061
|
+
{
|
|
5062
|
+
...read,
|
|
5063
|
+
method: import_module_http.HTTP_METHOD.GET,
|
|
5064
|
+
path: "/quick-replies",
|
|
5065
|
+
querySchema: import_meta_whatsapp_contracts24.listWhatsAppQuickRepliesQuerySchema,
|
|
5066
|
+
operationId: "listWhatsAppQuickReplies",
|
|
5067
|
+
summary: "Lista as respostas r\xE1pidas da empresa, na ordem de exibi\xE7\xE3o",
|
|
5068
|
+
async handler(context) {
|
|
5069
|
+
const query = context.query;
|
|
5070
|
+
const data = await list.execute({
|
|
5071
|
+
companyId: requireCompany(context),
|
|
5072
|
+
...query
|
|
5073
|
+
});
|
|
5074
|
+
return {
|
|
5075
|
+
kind: "json",
|
|
5076
|
+
status: 200,
|
|
5077
|
+
body: {
|
|
5078
|
+
data
|
|
5079
|
+
}
|
|
5080
|
+
};
|
|
5081
|
+
}
|
|
5082
|
+
},
|
|
5083
|
+
{
|
|
5084
|
+
...write,
|
|
5085
|
+
method: import_module_http.HTTP_METHOD.POST,
|
|
5086
|
+
path: "/quick-replies",
|
|
5087
|
+
bodySchema: import_meta_whatsapp_contracts24.whatsAppQuickReplyInputSchema,
|
|
5088
|
+
operationId: "createWhatsAppQuickReply",
|
|
5089
|
+
summary: "Cria uma resposta r\xE1pida (atalho \xFAnico por empresa)",
|
|
5090
|
+
async handler(context) {
|
|
5091
|
+
const input = context.body;
|
|
5092
|
+
const data = await create.execute({
|
|
5093
|
+
...input,
|
|
5094
|
+
companyId: requireCompany(context)
|
|
5095
|
+
});
|
|
5096
|
+
return {
|
|
5097
|
+
kind: "json",
|
|
5098
|
+
status: 201,
|
|
5099
|
+
body: {
|
|
5100
|
+
data
|
|
5101
|
+
}
|
|
5102
|
+
};
|
|
5103
|
+
}
|
|
5104
|
+
},
|
|
5105
|
+
{
|
|
5106
|
+
...write,
|
|
5107
|
+
method: import_module_http.HTTP_METHOD.PUT,
|
|
5108
|
+
path: "/quick-replies/:id",
|
|
5109
|
+
bodySchema: import_meta_whatsapp_contracts24.whatsAppQuickReplyInputSchema,
|
|
5110
|
+
operationId: "updateWhatsAppQuickReply",
|
|
5111
|
+
summary: "Substitui t\xEDtulo, atalho e texto de uma resposta r\xE1pida",
|
|
5112
|
+
async handler(context) {
|
|
5113
|
+
const input = context.body;
|
|
5114
|
+
const data = await update.execute({
|
|
5115
|
+
...input,
|
|
5116
|
+
companyId: requireCompany(context),
|
|
5117
|
+
id: requireId(context)
|
|
5118
|
+
});
|
|
5119
|
+
return {
|
|
5120
|
+
kind: "json",
|
|
5121
|
+
status: 200,
|
|
5122
|
+
body: {
|
|
5123
|
+
data
|
|
5124
|
+
}
|
|
5125
|
+
};
|
|
5126
|
+
}
|
|
5127
|
+
},
|
|
5128
|
+
{
|
|
5129
|
+
...write,
|
|
5130
|
+
method: import_module_http.HTTP_METHOD.DELETE,
|
|
5131
|
+
path: "/quick-replies/:id",
|
|
5132
|
+
operationId: "deleteWhatsAppQuickReply",
|
|
5133
|
+
summary: "Apaga uma resposta r\xE1pida",
|
|
5134
|
+
async handler(context) {
|
|
5135
|
+
await remove.execute({
|
|
5136
|
+
companyId: requireCompany(context),
|
|
5137
|
+
id: requireId(context)
|
|
5138
|
+
});
|
|
5139
|
+
return {
|
|
5140
|
+
kind: "empty",
|
|
5141
|
+
status: 204
|
|
5142
|
+
};
|
|
5143
|
+
}
|
|
5144
|
+
}
|
|
5145
|
+
];
|
|
5146
|
+
return routes;
|
|
5147
|
+
}
|
|
5148
|
+
__name(createMetaWhatsAppQuickReplyRoutes, "createMetaWhatsAppQuickReplyRoutes");
|
|
4740
5149
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4741
5150
|
0 && (module.exports = {
|
|
4742
5151
|
CountInboundLocationsUseCase,
|
|
4743
5152
|
CreateFlowGraphUseCase,
|
|
5153
|
+
CreateQuickReplyUseCase,
|
|
4744
5154
|
DEFAULT_FALLBACK_LIST_LABEL,
|
|
4745
5155
|
DEFAULT_FLOW_GRAPH_CACHE_TTL_SECONDS,
|
|
4746
5156
|
DEFAULT_FLOW_TEXT,
|
|
4747
5157
|
DEFAULT_MAX_INVALID_ANSWERS,
|
|
5158
|
+
DEFAULT_QUICK_REPLY_WRITE_SCOPES,
|
|
4748
5159
|
DEFAULT_START_FLOW_KEY,
|
|
4749
5160
|
DYNAMIC_CHOICE_MORE_ID,
|
|
4750
5161
|
DeleteConversationUseCase,
|
|
4751
5162
|
DeleteFlowGraphUseCase,
|
|
5163
|
+
DeleteQuickReplyUseCase,
|
|
4752
5164
|
DocumentRepository,
|
|
4753
5165
|
ExportConversationUseCase,
|
|
4754
5166
|
FLOW_RUNTIME_CONTEXT_KEY,
|
|
@@ -4771,6 +5183,7 @@ __name(redeemSseTicket, "redeemSseTicket");
|
|
|
4771
5183
|
ListConversationsUseCase,
|
|
4772
5184
|
ListFlowGraphsUseCase,
|
|
4773
5185
|
ListMessagesUseCase,
|
|
5186
|
+
ListQuickRepliesUseCase,
|
|
4774
5187
|
LogMessageUseCase,
|
|
4775
5188
|
META_WHATSAPP_MIGRATIONS_TABLE,
|
|
4776
5189
|
MessageRepository,
|
|
@@ -4780,10 +5193,13 @@ __name(redeemSseTicket, "redeemSseTicket");
|
|
|
4780
5193
|
PostgresAdvisoryFlowTurnLock,
|
|
4781
5194
|
ProcessInboundDispatchUseCase,
|
|
4782
5195
|
PurgeExpiredDocumentsUseCase,
|
|
5196
|
+
QUICK_REPLY_SCOPE,
|
|
5197
|
+
QuickReplyRepository,
|
|
4783
5198
|
ReceiveWebhookUseCase,
|
|
4784
5199
|
RedactInboundLocationsUseCase,
|
|
4785
5200
|
ReleaseConversationUseCase,
|
|
4786
5201
|
RequestHumanConversationUseCase,
|
|
5202
|
+
ReseedFlowGraphUseCase,
|
|
4787
5203
|
SaveFlowGraphUseCase,
|
|
4788
5204
|
SendMessageUseCase,
|
|
4789
5205
|
SessionRepository,
|
|
@@ -4794,6 +5210,7 @@ __name(redeemSseTicket, "redeemSseTicket");
|
|
|
4794
5210
|
TRANSCRIPTION_STATUS,
|
|
4795
5211
|
TakeoverConversationUseCase,
|
|
4796
5212
|
TranscribeAudioUseCase,
|
|
5213
|
+
UpdateQuickReplyUseCase,
|
|
4797
5214
|
WEBHOOK_CLAIM_TTL_SECONDS,
|
|
4798
5215
|
WEBHOOK_NONCE_TTL_SECONDS,
|
|
4799
5216
|
WhatsAppChannelAdapter,
|
|
@@ -4802,6 +5219,7 @@ __name(redeemSseTicket, "redeemSseTicket");
|
|
|
4802
5219
|
claimWebhookDelivery,
|
|
4803
5220
|
confirmWebhookDelivery,
|
|
4804
5221
|
createMetaWhatsAppModule,
|
|
5222
|
+
createMetaWhatsAppQuickReplyRoutes,
|
|
4805
5223
|
createSendMediaAction,
|
|
4806
5224
|
createSendProductListAction,
|
|
4807
5225
|
createTranscriptionPolicyResolver,
|
|
@@ -4817,6 +5235,7 @@ __name(redeemSseTicket, "redeemSseTicket");
|
|
|
4817
5235
|
messages,
|
|
4818
5236
|
metaWhatsAppMigrationsFolder,
|
|
4819
5237
|
metaWhatsAppSchema,
|
|
5238
|
+
quickReplies,
|
|
4820
5239
|
readFlowInbound,
|
|
4821
5240
|
redeemSseTicket,
|
|
4822
5241
|
resolveFailureStatus,
|
|
@@ -4828,6 +5247,7 @@ __name(redeemSseTicket, "redeemSseTicket");
|
|
|
4828
5247
|
sessions,
|
|
4829
5248
|
settings,
|
|
4830
5249
|
toPreviewMediaId,
|
|
5250
|
+
toQuickReplyView,
|
|
4831
5251
|
toSessionContract,
|
|
4832
5252
|
transcriptionRetryAfterSeconds,
|
|
4833
5253
|
verifyWebhookChallenge,
|