@bernierllc/message-queue 0.2.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/CHANGELOG.md +17 -0
- package/LICENSE +7 -0
- package/README.md +399 -0
- package/dist/core/message-queue.d.ts +78 -0
- package/dist/core/message-queue.d.ts.map +1 -0
- package/dist/core/message-queue.js +373 -0
- package/dist/core/message-queue.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +78 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +18 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/validation.d.ts +30 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +201 -0
- package/dist/utils/validation.js.map +1 -0
- package/examples/basic-usage.ts +197 -0
- package/jest.config.cjs +18 -0
- package/package.json +53 -0
- package/src/core/message-queue.ts +444 -0
- package/src/index.ts +16 -0
- package/src/types/index.ts +95 -0
- package/src/utils/validation.ts +231 -0
- package/tests/message-queue.test.ts +398 -0
- package/tests/setup.ts +16 -0
- package/tests/validation.test.ts +302 -0
- package/tsconfig.json +28 -0
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (c) 2025 Bernier LLC
|
|
4
|
+
|
|
5
|
+
This file is licensed to the client under a limited-use license.
|
|
6
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.MessageQueue = void 0;
|
|
11
|
+
const types_1 = require("../types");
|
|
12
|
+
const validation_1 = require("../utils/validation");
|
|
13
|
+
const retry_policy_1 = require("@bernierllc/retry-policy");
|
|
14
|
+
class MessageQueue {
|
|
15
|
+
constructor(config, options = {}) {
|
|
16
|
+
this.messages = [];
|
|
17
|
+
this.eventHandlers = [];
|
|
18
|
+
this.isActive = true;
|
|
19
|
+
this.config = (0, validation_1.validateConfig)(config);
|
|
20
|
+
this.options = {
|
|
21
|
+
enableEvents: true,
|
|
22
|
+
enableStats: true,
|
|
23
|
+
enablePersistence: false,
|
|
24
|
+
...options
|
|
25
|
+
};
|
|
26
|
+
this.createdAt = new Date();
|
|
27
|
+
this.lastActivity = new Date();
|
|
28
|
+
this.stats = this.initializeStats();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Add a message to the queue
|
|
32
|
+
*/
|
|
33
|
+
addMessage(content, priority = types_1.MessagePriority.NORMAL, metadata) {
|
|
34
|
+
if (!this.isActive) {
|
|
35
|
+
return {
|
|
36
|
+
success: false,
|
|
37
|
+
error: 'Queue is not active'
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// Check if queue is full
|
|
41
|
+
if (this.config.maxSize && this.messages.length >= this.config.maxSize) {
|
|
42
|
+
this.emitEvent({
|
|
43
|
+
type: 'queue_full',
|
|
44
|
+
timestamp: new Date(),
|
|
45
|
+
data: { queueSize: this.messages.length, maxSize: this.config.maxSize }
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
success: false,
|
|
49
|
+
error: 'Queue is full'
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const message = {
|
|
53
|
+
id: (0, validation_1.generateId)(),
|
|
54
|
+
content,
|
|
55
|
+
priority,
|
|
56
|
+
timestamp: new Date(),
|
|
57
|
+
metadata: metadata || undefined,
|
|
58
|
+
retryCount: 0,
|
|
59
|
+
maxRetries: this.config.maxRetries || 0
|
|
60
|
+
};
|
|
61
|
+
// Set expiration if TTL is configured
|
|
62
|
+
if (this.config.defaultTtl) {
|
|
63
|
+
message.expiresAt = new Date(Date.now() + this.config.defaultTtl);
|
|
64
|
+
}
|
|
65
|
+
// Validate message
|
|
66
|
+
const validationResult = (0, validation_1.validateMessage)(message);
|
|
67
|
+
if (!validationResult.isValid) {
|
|
68
|
+
return {
|
|
69
|
+
success: false,
|
|
70
|
+
error: validationResult.error
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
// Add message to queue (maintain priority order)
|
|
74
|
+
this.insertMessageByPriority(message);
|
|
75
|
+
this.updateStats();
|
|
76
|
+
this.lastActivity = new Date();
|
|
77
|
+
this.emitEvent({
|
|
78
|
+
type: 'message_added',
|
|
79
|
+
messageId: message.id,
|
|
80
|
+
timestamp: new Date(),
|
|
81
|
+
data: { priority, queueSize: this.messages.length }
|
|
82
|
+
});
|
|
83
|
+
return {
|
|
84
|
+
success: true,
|
|
85
|
+
messageId: message.id,
|
|
86
|
+
stats: this.options.enableStats ? this.getStats() : undefined
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Get the next message from the queue
|
|
91
|
+
*/
|
|
92
|
+
getNextMessage() {
|
|
93
|
+
if (!this.isActive || this.messages.length === 0) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
// Remove expired messages
|
|
97
|
+
this.removeExpiredMessages();
|
|
98
|
+
if (this.messages.length === 0) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
const message = this.messages.shift();
|
|
102
|
+
this.updateStats();
|
|
103
|
+
this.lastActivity = new Date();
|
|
104
|
+
return message;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Process a message and handle retries
|
|
108
|
+
*/
|
|
109
|
+
async processMessage(processor) {
|
|
110
|
+
const message = this.getNextMessage();
|
|
111
|
+
if (!message) {
|
|
112
|
+
return {
|
|
113
|
+
success: false,
|
|
114
|
+
error: 'No messages available'
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
const startTime = Date.now();
|
|
118
|
+
let success = false;
|
|
119
|
+
try {
|
|
120
|
+
success = await processor(message);
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
success = false;
|
|
124
|
+
}
|
|
125
|
+
const processingTime = Date.now() - startTime;
|
|
126
|
+
if (success) {
|
|
127
|
+
this.stats.processedMessages++;
|
|
128
|
+
this.stats.averageProcessingTime =
|
|
129
|
+
(this.stats.averageProcessingTime * (this.stats.processedMessages - 1) + processingTime) / this.stats.processedMessages;
|
|
130
|
+
this.emitEvent({
|
|
131
|
+
type: 'message_processed',
|
|
132
|
+
messageId: message.id,
|
|
133
|
+
timestamp: new Date(),
|
|
134
|
+
data: { processingTime }
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
// Handle retry logic using @bernierllc/retry-policy
|
|
139
|
+
if (this.config.enableRetries && message.retryCount < message.maxRetries) {
|
|
140
|
+
message.retryCount++;
|
|
141
|
+
// Use retry-policy for backoff calculation
|
|
142
|
+
const retryOptions = {
|
|
143
|
+
maxRetries: message.maxRetries,
|
|
144
|
+
initialDelayMs: this.config.retryDelay || 1000,
|
|
145
|
+
maxDelayMs: this.config.retryMaxDelay || (this.config.retryDelay || 1000) * 10,
|
|
146
|
+
jitter: this.config.retryJitter !== false
|
|
147
|
+
};
|
|
148
|
+
const delay = (0, retry_policy_1.calculateRetryDelay)(message.retryCount, retryOptions);
|
|
149
|
+
// Add back to queue with calculated delay
|
|
150
|
+
setTimeout(() => {
|
|
151
|
+
// Check if we've exceeded max retries after this attempt
|
|
152
|
+
if (message.retryCount >= message.maxRetries) {
|
|
153
|
+
// Message has exceeded max retries, mark as failed
|
|
154
|
+
this.stats.failedMessages++;
|
|
155
|
+
this.emitEvent({
|
|
156
|
+
type: 'message_failed',
|
|
157
|
+
messageId: message.id,
|
|
158
|
+
timestamp: new Date(),
|
|
159
|
+
data: { retryCount: message.retryCount, maxRetries: message.maxRetries }
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
// Re-add to queue for next retry
|
|
164
|
+
this.insertMessageByPriority(message);
|
|
165
|
+
this.updateStats();
|
|
166
|
+
}
|
|
167
|
+
}, delay);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
// Message failed and retries are disabled or max retries exceeded
|
|
171
|
+
this.stats.failedMessages++;
|
|
172
|
+
this.emitEvent({
|
|
173
|
+
type: 'message_failed',
|
|
174
|
+
messageId: message.id,
|
|
175
|
+
timestamp: new Date(),
|
|
176
|
+
data: { retryCount: message.retryCount, maxRetries: message.maxRetries }
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
this.updateStats();
|
|
181
|
+
this.lastActivity = new Date();
|
|
182
|
+
return {
|
|
183
|
+
success: true,
|
|
184
|
+
stats: this.options.enableStats ? this.getStats() : undefined
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Get messages matching a filter
|
|
189
|
+
*/
|
|
190
|
+
getMessages(filter = {}) {
|
|
191
|
+
let filteredMessages = [...this.messages];
|
|
192
|
+
if (filter.priority !== undefined) {
|
|
193
|
+
filteredMessages = filteredMessages.filter(msg => msg.priority === filter.priority);
|
|
194
|
+
}
|
|
195
|
+
if (filter.fromTimestamp) {
|
|
196
|
+
filteredMessages = filteredMessages.filter(msg => msg.timestamp >= filter.fromTimestamp);
|
|
197
|
+
}
|
|
198
|
+
if (filter.toTimestamp) {
|
|
199
|
+
filteredMessages = filteredMessages.filter(msg => msg.timestamp <= filter.toTimestamp);
|
|
200
|
+
}
|
|
201
|
+
if (filter.metadata) {
|
|
202
|
+
filteredMessages = filteredMessages.filter(msg => {
|
|
203
|
+
if (!msg.metadata)
|
|
204
|
+
return false;
|
|
205
|
+
return Object.entries(filter.metadata).every(([key, value]) => msg.metadata[key] === value);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
// Apply pagination
|
|
209
|
+
const offset = filter.offset || 0;
|
|
210
|
+
const limit = filter.limit || filteredMessages.length;
|
|
211
|
+
return filteredMessages.slice(offset, offset + limit);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Remove a specific message from the queue
|
|
215
|
+
*/
|
|
216
|
+
removeMessage(messageId) {
|
|
217
|
+
const index = this.messages.findIndex(msg => msg.id === messageId);
|
|
218
|
+
if (index === -1) {
|
|
219
|
+
return {
|
|
220
|
+
success: false,
|
|
221
|
+
error: 'Message not found'
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
this.messages.splice(index, 1);
|
|
225
|
+
this.updateStats();
|
|
226
|
+
this.lastActivity = new Date();
|
|
227
|
+
return {
|
|
228
|
+
success: true,
|
|
229
|
+
stats: this.options.enableStats ? this.getStats() : undefined
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Clear all messages from the queue
|
|
234
|
+
*/
|
|
235
|
+
clear() {
|
|
236
|
+
const messageCount = this.messages.length;
|
|
237
|
+
this.messages = [];
|
|
238
|
+
this.updateStats();
|
|
239
|
+
this.lastActivity = new Date();
|
|
240
|
+
this.emitEvent({
|
|
241
|
+
type: 'queue_empty',
|
|
242
|
+
timestamp: new Date(),
|
|
243
|
+
data: { clearedCount: messageCount }
|
|
244
|
+
});
|
|
245
|
+
return {
|
|
246
|
+
success: true,
|
|
247
|
+
stats: this.options.enableStats ? this.getStats() : undefined
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Get queue statistics
|
|
252
|
+
*/
|
|
253
|
+
getStats() {
|
|
254
|
+
return { ...this.stats };
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Get queue information
|
|
258
|
+
*/
|
|
259
|
+
getInfo() {
|
|
260
|
+
return {
|
|
261
|
+
name: this.config.name,
|
|
262
|
+
config: { ...this.config },
|
|
263
|
+
stats: this.getStats(),
|
|
264
|
+
isActive: this.isActive,
|
|
265
|
+
createdAt: this.createdAt,
|
|
266
|
+
lastActivity: this.lastActivity
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Add event handler
|
|
271
|
+
*/
|
|
272
|
+
onEvent(handler) {
|
|
273
|
+
if (this.options.enableEvents) {
|
|
274
|
+
this.eventHandlers.push(handler);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Remove event handler
|
|
279
|
+
*/
|
|
280
|
+
offEvent(handler) {
|
|
281
|
+
const index = this.eventHandlers.indexOf(handler);
|
|
282
|
+
if (index !== -1) {
|
|
283
|
+
this.eventHandlers.splice(index, 1);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Pause the queue
|
|
288
|
+
*/
|
|
289
|
+
pause() {
|
|
290
|
+
this.isActive = false;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Resume the queue
|
|
294
|
+
*/
|
|
295
|
+
resume() {
|
|
296
|
+
this.isActive = true;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Get queue size
|
|
300
|
+
*/
|
|
301
|
+
get size() {
|
|
302
|
+
return this.messages.length;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Check if queue is empty
|
|
306
|
+
*/
|
|
307
|
+
get isEmpty() {
|
|
308
|
+
return this.messages.length === 0;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Check if queue is full
|
|
312
|
+
*/
|
|
313
|
+
get isFull() {
|
|
314
|
+
return this.config.maxSize ? this.messages.length >= this.config.maxSize : false;
|
|
315
|
+
}
|
|
316
|
+
// Private methods
|
|
317
|
+
insertMessageByPriority(message) {
|
|
318
|
+
// Insert message in priority order (highest priority first)
|
|
319
|
+
let insertIndex = 0;
|
|
320
|
+
for (let i = 0; i < this.messages.length; i++) {
|
|
321
|
+
const currentMessage = this.messages[i];
|
|
322
|
+
if (currentMessage && currentMessage.priority < message.priority) {
|
|
323
|
+
insertIndex = i;
|
|
324
|
+
break;
|
|
325
|
+
}
|
|
326
|
+
insertIndex = i + 1;
|
|
327
|
+
}
|
|
328
|
+
this.messages.splice(insertIndex, 0, message);
|
|
329
|
+
}
|
|
330
|
+
removeExpiredMessages() {
|
|
331
|
+
const now = new Date();
|
|
332
|
+
this.messages = this.messages.filter(msg => !msg.expiresAt || msg.expiresAt > now);
|
|
333
|
+
}
|
|
334
|
+
updateStats() {
|
|
335
|
+
if (!this.options.enableStats)
|
|
336
|
+
return;
|
|
337
|
+
this.stats.totalMessages = this.messages.length;
|
|
338
|
+
this.stats.pendingMessages = this.messages.length;
|
|
339
|
+
// Calculate oldest message age
|
|
340
|
+
if (this.messages.length > 0) {
|
|
341
|
+
const oldestMessage = this.messages.reduce((oldest, current) => current.timestamp < oldest.timestamp ? current : oldest);
|
|
342
|
+
this.stats.oldestMessageAge = Date.now() - oldestMessage.timestamp.getTime();
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
this.stats.oldestMessageAge = 0;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
initializeStats() {
|
|
349
|
+
return {
|
|
350
|
+
totalMessages: 0,
|
|
351
|
+
pendingMessages: 0,
|
|
352
|
+
processedMessages: 0,
|
|
353
|
+
failedMessages: 0,
|
|
354
|
+
averageProcessingTime: 0,
|
|
355
|
+
oldestMessageAge: 0
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
emitEvent(event) {
|
|
359
|
+
if (!this.options.enableEvents)
|
|
360
|
+
return;
|
|
361
|
+
this.eventHandlers.forEach(handler => {
|
|
362
|
+
try {
|
|
363
|
+
handler(event);
|
|
364
|
+
}
|
|
365
|
+
catch (error) {
|
|
366
|
+
// Silently handle handler errors to prevent queue disruption
|
|
367
|
+
console.error('Error in queue event handler:', error);
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
exports.MessageQueue = MessageQueue;
|
|
373
|
+
//# sourceMappingURL=message-queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-queue.js","sourceRoot":"","sources":["../../src/core/message-queue.ts"],"names":[],"mappings":";AAAA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,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CACxD,CAAC;YACF,IAAI,CAAC,KAAK,CAAC,gBAAgB,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,aAAa,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QAC/E,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,KAAK,CAAC,gBAAgB,GAAG,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;IAEO,eAAe;QACrB,OAAO;YACL,aAAa,EAAE,CAAC;YAChB,eAAe,EAAE,CAAC;YAClB,iBAAiB,EAAE,CAAC;YACpB,cAAc,EAAE,CAAC;YACjB,qBAAqB,EAAE,CAAC;YACxB,gBAAgB,EAAE,CAAC;SACpB,CAAC;IACJ,CAAC;IAEO,SAAS,CAAC,KAAiB;QACjC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY;YAAE,OAAO;QAEvC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YACnC,IAAI,CAAC;gBACH,OAAO,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,6DAA6D;gBAC7D,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;YACxD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AApaD,oCAoaC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (c) 2025 Bernier LLC
|
|
4
|
+
|
|
5
|
+
This file is licensed to the client under a limited-use license.
|
|
6
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
21
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.MessageQueue = void 0;
|
|
25
|
+
// Core Types
|
|
26
|
+
__exportStar(require("./types"), exports);
|
|
27
|
+
// Core Message Queue
|
|
28
|
+
var message_queue_1 = require("./core/message-queue");
|
|
29
|
+
Object.defineProperty(exports, "MessageQueue", { enumerable: true, get: function () { return message_queue_1.MessageQueue; } });
|
|
30
|
+
// Validation Utilities
|
|
31
|
+
__exportStar(require("./utils/validation"), exports);
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;;;;;;;;;;;;;;;AAEF,aAAa;AACb,0CAAwB;AAExB,qBAAqB;AACrB,sDAAoD;AAA3C,6GAAA,YAAY,OAAA;AAErB,uBAAuB;AACvB,qDAAmC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export interface Message {
|
|
2
|
+
id: string;
|
|
3
|
+
content: any;
|
|
4
|
+
priority: MessagePriority;
|
|
5
|
+
timestamp: Date;
|
|
6
|
+
expiresAt?: Date | undefined;
|
|
7
|
+
metadata?: Record<string, any> | undefined;
|
|
8
|
+
retryCount?: number | undefined;
|
|
9
|
+
maxRetries?: number | undefined;
|
|
10
|
+
}
|
|
11
|
+
export declare enum MessagePriority {
|
|
12
|
+
LOW = 0,
|
|
13
|
+
NORMAL = 1,
|
|
14
|
+
HIGH = 2,
|
|
15
|
+
URGENT = 3
|
|
16
|
+
}
|
|
17
|
+
export interface QueueConfig {
|
|
18
|
+
name: string;
|
|
19
|
+
maxSize?: number | undefined;
|
|
20
|
+
defaultPriority?: MessagePriority | undefined;
|
|
21
|
+
defaultTtl?: number | undefined;
|
|
22
|
+
enableRetries?: boolean | undefined;
|
|
23
|
+
maxRetries?: number | undefined;
|
|
24
|
+
retryDelay?: number | undefined;
|
|
25
|
+
retryMaxDelay?: number | undefined;
|
|
26
|
+
retryJitter?: boolean | undefined;
|
|
27
|
+
}
|
|
28
|
+
export interface QueueStats {
|
|
29
|
+
totalMessages: number;
|
|
30
|
+
pendingMessages: number;
|
|
31
|
+
processedMessages: number;
|
|
32
|
+
failedMessages: number;
|
|
33
|
+
averageProcessingTime: number;
|
|
34
|
+
oldestMessageAge: number;
|
|
35
|
+
}
|
|
36
|
+
export interface QueueResult {
|
|
37
|
+
success: boolean;
|
|
38
|
+
messageId?: string | undefined;
|
|
39
|
+
error?: string | undefined;
|
|
40
|
+
stats?: QueueStats | undefined;
|
|
41
|
+
}
|
|
42
|
+
export interface MessageFilter {
|
|
43
|
+
priority?: MessagePriority;
|
|
44
|
+
fromTimestamp?: Date;
|
|
45
|
+
toTimestamp?: Date;
|
|
46
|
+
metadata?: Record<string, any>;
|
|
47
|
+
limit?: number;
|
|
48
|
+
offset?: number;
|
|
49
|
+
}
|
|
50
|
+
export interface QueueEvent {
|
|
51
|
+
type: 'message_added' | 'message_processed' | 'message_failed' | 'queue_full' | 'queue_empty';
|
|
52
|
+
messageId?: string;
|
|
53
|
+
timestamp: Date;
|
|
54
|
+
data?: any;
|
|
55
|
+
}
|
|
56
|
+
export type QueueEventHandler = (event: QueueEvent) => void;
|
|
57
|
+
export interface QueueOptions {
|
|
58
|
+
enableEvents?: boolean;
|
|
59
|
+
enableStats?: boolean;
|
|
60
|
+
enablePersistence?: boolean;
|
|
61
|
+
persistenceConfig?: PersistenceConfig;
|
|
62
|
+
}
|
|
63
|
+
export interface PersistenceConfig {
|
|
64
|
+
type: 'memory' | 'file' | 'database';
|
|
65
|
+
path?: string;
|
|
66
|
+
connectionString?: string;
|
|
67
|
+
autoSave?: boolean;
|
|
68
|
+
saveInterval?: number;
|
|
69
|
+
}
|
|
70
|
+
export interface QueueInfo {
|
|
71
|
+
name: string;
|
|
72
|
+
config: QueueConfig;
|
|
73
|
+
stats: QueueStats;
|
|
74
|
+
isActive: boolean;
|
|
75
|
+
createdAt: Date;
|
|
76
|
+
lastActivity: Date;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,GAAG,CAAC;IACb,QAAQ,EAAE,eAAe,CAAC;IAC1B,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC;IAC3C,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED,oBAAY,eAAe;IAC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AM,WAAW,UAAU;IACzB,IAAI,EAAE,eAAe,GAAG,mBAAmB,GAAG,gBAAgB,GAAG,YAAY,GAAG,aAAa,CAAC;IAC9F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;IAChB,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ;AAED,MAAM,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;AAE5D,MAAM,WAAW,YAAY;IAC3B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,IAAI,CAAC;IAChB,YAAY,EAAE,IAAI,CAAC;CACpB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (c) 2025 Bernier LLC
|
|
4
|
+
|
|
5
|
+
This file is licensed to the client under a limited-use license.
|
|
6
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.MessagePriority = void 0;
|
|
11
|
+
var MessagePriority;
|
|
12
|
+
(function (MessagePriority) {
|
|
13
|
+
MessagePriority[MessagePriority["LOW"] = 0] = "LOW";
|
|
14
|
+
MessagePriority[MessagePriority["NORMAL"] = 1] = "NORMAL";
|
|
15
|
+
MessagePriority[MessagePriority["HIGH"] = 2] = "HIGH";
|
|
16
|
+
MessagePriority[MessagePriority["URGENT"] = 3] = "URGENT";
|
|
17
|
+
})(MessagePriority || (exports.MessagePriority = MessagePriority = {}));
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;AAaF,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,mDAAO,CAAA;IACP,yDAAU,CAAA;IACV,qDAAQ,CAAA;IACR,yDAAU,CAAA;AACZ,CAAC,EALW,eAAe,+BAAf,eAAe,QAK1B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Message, QueueConfig } from '../types';
|
|
2
|
+
export interface ValidationResult {
|
|
3
|
+
isValid: boolean;
|
|
4
|
+
error?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Generate a unique ID for messages
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateId(): string;
|
|
10
|
+
/**
|
|
11
|
+
* Validate a message object
|
|
12
|
+
*/
|
|
13
|
+
export declare function validateMessage(message: Message): ValidationResult;
|
|
14
|
+
/**
|
|
15
|
+
* Validate queue configuration
|
|
16
|
+
*/
|
|
17
|
+
export declare function validateConfig(config: QueueConfig): QueueConfig;
|
|
18
|
+
/**
|
|
19
|
+
* Validate message filter
|
|
20
|
+
*/
|
|
21
|
+
export declare function validateFilter(filter: any): ValidationResult;
|
|
22
|
+
/**
|
|
23
|
+
* Validate message ID format
|
|
24
|
+
*/
|
|
25
|
+
export declare function validateMessageId(messageId: string): ValidationResult;
|
|
26
|
+
/**
|
|
27
|
+
* Validate queue name
|
|
28
|
+
*/
|
|
29
|
+
export declare function validateQueueName(name: string): ValidationResult;
|
|
30
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/utils/validation.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAmB,MAAM,UAAU,CAAC;AAEjE,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,gBAAgB,CA0DlE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CA4C/D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,gBAAgB,CA4C5D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,CAgBrE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAuBhE"}
|