@pinet/broker-core 0.2.11 → 0.2.12

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/schema.d.ts CHANGED
@@ -266,6 +266,7 @@ export declare class BrokerDB implements BrokerDBInterface {
266
266
  getAllowedUsers(): Set<string> | null;
267
267
  getChannelAssignment(_channel: string): ChannelAssignment | null;
268
268
  getThread(threadId: string): ThreadInfo | null;
269
+ getMessagesForThread(threadId: string, limit?: number): BrokerMessage[];
269
270
  getThreads(ownerAgent?: string): ThreadInfo[];
270
271
  getPendingBacklog(limit?: number): BacklogEntry[];
271
272
  getBacklogCount(status?: BacklogEntry["status"]): number;
package/dist/schema.js CHANGED
@@ -3449,6 +3449,19 @@ export class BrokerDB {
3449
3449
  const row = db.prepare("SELECT * FROM threads WHERE thread_id = ?").get(threadId);
3450
3450
  return row ? rowToThread(row) : null;
3451
3451
  }
3452
+ getMessagesForThread(threadId, limit = 50) {
3453
+ const db = this.getDb();
3454
+ const rows = db
3455
+ .prepare(`SELECT * FROM (
3456
+ SELECT * FROM messages
3457
+ WHERE thread_id = ?
3458
+ ORDER BY id DESC
3459
+ LIMIT ?
3460
+ )
3461
+ ORDER BY id ASC`)
3462
+ .all(threadId, limit);
3463
+ return rows.map(rowToBrokerMessage);
3464
+ }
3452
3465
  getThreads(ownerAgent) {
3453
3466
  const db = this.getDb();
3454
3467
  if (ownerAgent) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pinet/broker-core",
3
- "version": "0.2.11",
3
+ "version": "0.2.12",
4
4
  "type": "module",
5
5
  "description": "Transport-neutral broker kernel primitives for pi transports",
6
6
  "author": "Will Porcellini <5994936+gugu91@users.noreply.github.com>",
@@ -43,7 +43,7 @@
43
43
  "test": "vitest run --config ../vitest.config.ts *.test.ts"
44
44
  },
45
45
  "dependencies": {
46
- "@pinet/transport-core": "0.2.11"
46
+ "@pinet/transport-core": "0.2.12"
47
47
  },
48
48
  "types": "./dist/index.d.ts"
49
49
  }