@adatechnology/meta-whatsapp-module 0.13.0 → 0.14.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/dist/index.cjs +12 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -699,6 +699,7 @@ var import_drizzle_orm3 = require("drizzle-orm");
|
|
|
699
699
|
var INBOUND_LOCATION_CONTENT = "\u{1F4CD} Localiza\xE7\xE3o";
|
|
700
700
|
|
|
701
701
|
// src/repositories/MessageRepository.ts
|
|
702
|
+
var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
702
703
|
var DEFAULT_LIMIT2 = 50;
|
|
703
704
|
var MessageRepository = class {
|
|
704
705
|
static {
|
|
@@ -871,7 +872,15 @@ var MessageRepository = class {
|
|
|
871
872
|
(0, import_drizzle_orm3.eq)(messages.companyId, params.companyId),
|
|
872
873
|
(0, import_drizzle_orm3.eq)(messages.sessionId, params.sessionId)
|
|
873
874
|
];
|
|
874
|
-
if (params.
|
|
875
|
+
if (params.beforeId && UUID_PATTERN.test(params.beforeId)) {
|
|
876
|
+
const compositeCursor = import_drizzle_orm3.sql`(${messages.createdAt}, ${messages.id}) < (
|
|
877
|
+
select cursor_row.created_at, cursor_row.id from ${messages} as cursor_row
|
|
878
|
+
where cursor_row.id = ${params.beforeId}
|
|
879
|
+
and cursor_row.company_id = ${params.companyId}
|
|
880
|
+
and cursor_row.session_id = ${params.sessionId}
|
|
881
|
+
)`;
|
|
882
|
+
conditions.push(params.before ? import_drizzle_orm3.sql`coalesce(${compositeCursor}, ${(0, import_drizzle_orm3.lt)(messages.createdAt, new Date(params.before))})` : compositeCursor);
|
|
883
|
+
} else if (params.before) conditions.push((0, import_drizzle_orm3.lt)(messages.createdAt, new Date(params.before)));
|
|
875
884
|
const newestFirst = await this.db.select().from(messages).where((0, import_drizzle_orm3.and)(...conditions)).orderBy((0, import_drizzle_orm3.desc)(messages.createdAt), (0, import_drizzle_orm3.desc)(messages.id)).limit(params.limit ?? DEFAULT_LIMIT2);
|
|
876
885
|
return newestFirst.reverse();
|
|
877
886
|
}
|
|
@@ -1659,7 +1668,8 @@ var ListMessagesUseCase = class {
|
|
|
1659
1668
|
companyId: params.companyId,
|
|
1660
1669
|
sessionId: session.id,
|
|
1661
1670
|
limit: params.limit,
|
|
1662
|
-
before: params.before
|
|
1671
|
+
before: params.before,
|
|
1672
|
+
beforeId: params.beforeId
|
|
1663
1673
|
};
|
|
1664
1674
|
return this.messageRepository.listByConversation(repoParams);
|
|
1665
1675
|
}
|