dt-common-device 9.1.5 → 9.1.7
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/admin/Admin.repository.d.ts +7 -0
- package/dist/admin/Admin.repository.js +182 -0
- package/dist/admin/Admin.service.d.ts +5 -0
- package/dist/admin/Admin.service.js +17 -0
- package/dist/admin/index.d.ts +1 -0
- package/dist/admin/index.js +17 -0
- package/dist/audit/AuditProperties.d.ts +16 -0
- package/dist/audit/AuditProperties.js +2 -0
- package/dist/chronicle/Cronicle.service.d.ts +2 -6
- package/dist/chronicle/Cronicle.service.js +2 -19
- package/dist/chronicle/IChronicle.interface.d.ts +14 -0
- package/dist/chronicle/IChronicle.interface.js +2 -0
- package/dist/chronicle/ICronicle.interface.d.ts +0 -1
- package/dist/chronicle/chronicle.service.d.ts +4 -0
- package/dist/chronicle/chronicle.service.js +44 -0
- package/dist/connection/Connection.repository.d.ts +8 -0
- package/dist/connection/Connection.repository.js +92 -0
- package/dist/connection/Connection.service.d.ts +8 -0
- package/dist/connection/Connection.service.js +32 -0
- package/dist/connection/IConnection.d.ts +28 -0
- package/dist/connection/IConnection.js +16 -0
- package/dist/connection/index.d.ts +2 -0
- package/dist/connection/index.js +18 -0
- package/dist/copilotQueue/examples/CopilotQueue.example.d.ts +37 -0
- package/dist/copilotQueue/examples/CopilotQueue.example.js +140 -0
- package/dist/copilotQueue/examples/index.d.ts +1 -0
- package/dist/copilotQueue/examples/index.js +17 -0
- package/dist/copilotQueue/index.d.ts +4 -0
- package/dist/copilotQueue/index.js +21 -0
- package/dist/copilotQueue/interfaces/ICopilotQueueRequest.d.ts +27 -0
- package/dist/copilotQueue/interfaces/ICopilotQueueRequest.js +2 -0
- package/dist/copilotQueue/interfaces/ICopilotQueueService.d.ts +24 -0
- package/dist/copilotQueue/interfaces/ICopilotQueueService.js +2 -0
- package/dist/copilotQueue/interfaces/index.d.ts +2 -0
- package/dist/copilotQueue/interfaces/index.js +18 -0
- package/dist/copilotQueue/services/CopilotQueue.service.d.ts +13 -0
- package/dist/copilotQueue/services/CopilotQueue.service.js +196 -0
- package/dist/copilotQueue/services/index.d.ts +1 -0
- package/dist/copilotQueue/services/index.js +17 -0
- package/dist/copilotQueue/types/copilot.types.d.ts +13 -0
- package/dist/copilotQueue/types/copilot.types.js +2 -0
- package/dist/copilotQueue/types/index.d.ts +1 -0
- package/dist/copilotQueue/types/index.js +17 -0
- package/dist/copilotQueue/utils/index.d.ts +1 -0
- package/dist/copilotQueue/utils/index.js +17 -0
- package/dist/copilotQueue/utils/queueManager.d.ts +31 -0
- package/dist/copilotQueue/utils/queueManager.js +156 -0
- package/dist/device/cloud/entities/CloudConnection.d.ts +6 -0
- package/dist/device/cloud/entities/CloudConnection.js +6 -0
- package/dist/device/cloud/entities/CloudDevice.d.ts +16 -0
- package/dist/device/cloud/entities/CloudDevice.js +26 -0
- package/dist/device/cloud/entities/CloudDeviceService.d.ts +5 -0
- package/dist/device/cloud/entities/CloudDeviceService.js +9 -0
- package/dist/device/cloud/entities/DeviceFactory.d.ts +7 -0
- package/dist/device/cloud/entities/DeviceFactory.js +80 -0
- package/dist/device/cloud/entities/index.d.ts +3 -0
- package/dist/device/cloud/entities/index.js +19 -0
- package/dist/device/cloud/interface.d.ts +101 -0
- package/dist/device/cloud/interface.js +3 -0
- package/dist/device/cloud/interfaces/ICloudConnection.d.ts +5 -0
- package/dist/device/cloud/interfaces/ICloudConnection.js +2 -0
- package/dist/device/cloud/interfaces/ICloudDevice.d.ts +9 -0
- package/dist/device/cloud/interfaces/ICloudDevice.js +2 -0
- package/dist/device/cloud/interfaces/ICloudDeviceService.d.ts +4 -0
- package/dist/device/cloud/interfaces/ICloudDeviceService.js +2 -0
- package/dist/device/cloud/interfaces/IConnectionService.d.ts +7 -0
- package/dist/device/cloud/interfaces/IConnectionService.js +2 -0
- package/dist/device/cloud/interfaces/IDeviceConnectionService.d.ts +7 -0
- package/dist/device/cloud/interfaces/IDeviceConnectionService.js +3 -0
- package/dist/device/cloud/interfaces/IDeviceFactory.d.ts +4 -0
- package/dist/device/cloud/interfaces/IDeviceFactory.js +2 -0
- package/dist/device/cloud/interfaces/IDeviceService.d.ts +8 -0
- package/dist/device/cloud/interfaces/IDeviceService.js +2 -0
- package/dist/device/cloud/interfaces/IDevicesService.d.ts +9 -0
- package/dist/device/cloud/interfaces/IDevicesService.js +2 -0
- package/dist/device/cloud/interfaces/IHubService.d.ts +5 -0
- package/dist/device/cloud/interfaces/IHubService.js +2 -0
- package/dist/device/cloud/interfaces/IRawDataTransformer.d.ts +4 -0
- package/dist/device/cloud/interfaces/IRawDataTransformer.js +2 -0
- package/dist/device/cloud/interfaces/IRawDevice.d.ts +17 -0
- package/dist/device/cloud/interfaces/IRawDevice.js +11 -0
- package/dist/device/cloud/interfaces/index.d.ts +5 -0
- package/dist/device/cloud/interfaces/index.js +21 -0
- package/dist/device/cloud/services/CloudDevice.service.d.ts +5 -0
- package/dist/device/cloud/services/CloudDevice.service.js +9 -0
- package/dist/device/cloud/services/Connection.service.d.ts +8 -0
- package/dist/device/cloud/services/Connection.service.js +6 -0
- package/dist/device/cloud/services/Device.service.d.ts +39 -0
- package/dist/device/cloud/services/Device.service.js +9 -0
- package/dist/device/cloud/services/DeviceCloudService.d.ts +42 -0
- package/dist/device/cloud/services/DeviceCloudService.js +59 -0
- package/dist/device/cloud/services/DeviceHub.service.d.ts +3 -0
- package/dist/device/cloud/services/DeviceHub.service.js +6 -0
- package/dist/device/cloud/services/Hub.service.d.ts +25 -0
- package/dist/device/cloud/services/Hub.service.js +9 -0
- package/dist/device/cloud/services/SmartThingsDeviceService.d.ts +38 -0
- package/dist/device/cloud/services/SmartThingsDeviceService.js +52 -0
- package/dist/device/cloud/services/index.d.ts +2 -0
- package/dist/device/cloud/services/index.js +18 -0
- package/dist/device/cloud/types.d.ts +52 -0
- package/dist/device/cloud/types.js +15 -0
- package/dist/device/index.d.ts +4 -0
- package/dist/device/index.js +20 -0
- package/dist/device/local/entities/AlertBuilder.d.ts +87 -0
- package/dist/device/local/entities/AlertBuilder.example.d.ts +11 -0
- package/dist/device/local/entities/AlertBuilder.example.js +117 -0
- package/dist/device/local/entities/AlertBuilder.js +179 -0
- package/dist/device/local/entities/IssueBuilder.d.ts +109 -0
- package/dist/device/local/entities/IssueBuilder.example.d.ts +16 -0
- package/dist/device/local/entities/IssueBuilder.example.js +196 -0
- package/dist/device/local/entities/IssueBuilder.js +237 -0
- package/dist/device/local/entities/index.d.ts +2 -0
- package/dist/device/local/entities/index.js +7 -0
- package/dist/device/local/events/EventHandler.d.ts +11 -0
- package/dist/device/local/events/EventHandler.js +86 -0
- package/dist/device/local/events/Events.d.ts +54 -0
- package/dist/device/local/events/Events.js +57 -0
- package/dist/device/local/events/index.d.ts +2 -0
- package/dist/device/local/events/index.js +7 -0
- package/dist/device/local/handler/EventHandler.d.ts +7 -0
- package/dist/device/local/handler/EventHandler.js +44 -0
- package/dist/device/local/interface.d.ts +0 -0
- package/dist/device/local/interface.js +1 -0
- package/dist/device/local/interfaces/IConnection.d.ts +26 -0
- package/dist/device/local/interfaces/IConnection.js +14 -0
- package/dist/device/local/interfaces/IDevice.d.ts +68 -0
- package/dist/device/local/interfaces/IDevice.js +10 -0
- package/dist/device/local/interfaces/IDtDevice.d.ts +16 -0
- package/dist/device/local/interfaces/IDtDevice.js +2 -0
- package/dist/device/local/interfaces/IHub.d.ts +46 -0
- package/dist/device/local/interfaces/IHub.js +2 -0
- package/dist/device/local/interfaces/IProperty.d.ts +29 -0
- package/dist/device/local/interfaces/IProperty.js +2 -0
- package/dist/device/local/interfaces/ISchedule.d.ts +25 -0
- package/dist/device/local/interfaces/ISchedule.js +2 -0
- package/dist/device/local/interfaces/index.d.ts +3 -0
- package/dist/device/local/interfaces/index.js +19 -0
- package/dist/device/local/models/Alert.model.d.ts +28 -0
- package/dist/device/local/models/Alert.model.js +222 -0
- package/dist/device/local/models/Issue.model.d.ts +28 -0
- package/dist/device/local/models/Issue.model.js +260 -0
- package/dist/device/local/repository/Alert.repository.d.ts +106 -0
- package/dist/device/local/repository/Alert.repository.js +374 -0
- package/dist/device/local/repository/Connection.repository.d.ts +8 -0
- package/dist/device/local/repository/Connection.repository.js +92 -0
- package/dist/device/local/repository/Device.repository.d.ts +30 -0
- package/dist/device/local/repository/Device.repository.js +325 -0
- package/dist/device/local/repository/Hub.repository.d.ts +13 -0
- package/dist/device/local/repository/Hub.repository.js +139 -0
- package/dist/device/local/repository/Issue.repository.d.ts +113 -0
- package/dist/device/local/repository/Issue.repository.js +401 -0
- package/dist/device/local/repository/Property.repository.d.ts +8 -0
- package/dist/device/local/repository/Property.repository.js +95 -0
- package/dist/device/local/repository/Schedule.repository.d.ts +9 -0
- package/dist/device/local/repository/Schedule.repository.js +109 -0
- package/dist/device/local/services/Alert.service.d.ts +137 -0
- package/dist/device/local/services/Alert.service.js +475 -0
- package/dist/device/local/services/AlertService.example.d.ts +55 -0
- package/dist/device/local/services/AlertService.example.js +148 -0
- package/dist/device/local/services/Connection.service.d.ts +8 -0
- package/dist/device/local/services/Connection.service.js +32 -0
- package/dist/device/local/services/Device.service.d.ts +40 -0
- package/dist/device/local/services/Device.service.js +391 -0
- package/dist/device/local/services/DeviceHub.service.d.ts +11 -0
- package/dist/device/local/services/DeviceHub.service.js +40 -0
- package/dist/device/local/services/Hub.service.d.ts +12 -0
- package/dist/device/local/services/Hub.service.js +107 -0
- package/dist/device/local/services/Issue.service.d.ts +168 -0
- package/dist/device/local/services/Issue.service.js +642 -0
- package/dist/device/local/services/IssueService.example.d.ts +68 -0
- package/dist/device/local/services/IssueService.example.js +177 -0
- package/dist/device/local/services/Property.service.d.ts +8 -0
- package/dist/device/local/services/Property.service.js +36 -0
- package/dist/device/local/services/Schedule.service.d.ts +9 -0
- package/dist/device/local/services/Schedule.service.js +26 -0
- package/dist/device/local/services/index.d.ts +3 -0
- package/dist/device/local/services/index.js +19 -0
- package/dist/entities/accessGroup/AccessGroup.repository.d.ts +1 -2
- package/dist/entities/accessGroup/AccessGroup.repository.js +1 -4
- package/dist/entities/accessGroup/AccessGroup.service.d.ts +1 -2
- package/dist/entities/accessGroup/AccessGroup.service.js +3 -4
- package/dist/entities/guest/Guest.repository.d.ts +1 -1
- package/dist/entities/guest/Guest.repository.js +2 -5
- package/dist/entities/guest/Guest.service.d.ts +1 -1
- package/dist/entities/guest/Guest.service.js +1 -4
- package/dist/entities/schedules/Schedule.repository.d.ts +1 -1
- package/dist/entities/schedules/Schedule.repository.js +2 -5
- package/dist/entities/schedules/Schedule.service.d.ts +1 -1
- package/dist/entities/schedules/Schedule.service.js +1 -4
- package/dist/entities/user/User.repository.js +1 -4
- package/dist/entities/user/User.service.d.ts +1 -1
- package/dist/entities/user/User.service.js +1 -4
- package/dist/entities/zone/Zone.service.js +1 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/pms/IPms.d.ts +6 -0
- package/dist/pms/IPms.js +10 -0
- package/dist/pms/index.d.ts +1 -0
- package/dist/pms/index.js +18 -0
- package/dist/pms/webhookQueue/examples/index.d.ts +2 -0
- package/dist/pms/webhookQueue/examples/index.js +18 -0
- package/dist/pms/webhookQueue/examples/pms-integration.d.ts +65 -0
- package/dist/pms/webhookQueue/examples/pms-integration.js +254 -0
- package/dist/pms/webhookQueue/examples/usage.d.ts +7 -0
- package/dist/pms/webhookQueue/examples/usage.js +175 -0
- package/dist/pms/webhookQueue/index.d.ts +3 -0
- package/dist/pms/webhookQueue/index.js +20 -0
- package/dist/pms/webhookQueue/interfaces/IWebhookQueue.d.ts +33 -0
- package/dist/pms/webhookQueue/interfaces/IWebhookQueue.js +2 -0
- package/dist/pms/webhookQueue/interfaces/IWebhookWorker.d.ts +38 -0
- package/dist/pms/webhookQueue/interfaces/IWebhookWorker.js +2 -0
- package/dist/pms/webhookQueue/interfaces/index.d.ts +1 -0
- package/dist/pms/webhookQueue/interfaces/index.js +17 -0
- package/dist/pms/webhookQueue/services/WebhookQueueFactory.d.ts +38 -0
- package/dist/pms/webhookQueue/services/WebhookQueueFactory.js +131 -0
- package/dist/pms/webhookQueue/services/WebhookQueueIntegration.d.ts +70 -0
- package/dist/pms/webhookQueue/services/WebhookQueueIntegration.js +207 -0
- package/dist/pms/webhookQueue/services/WebhookQueueService.d.ts +45 -0
- package/dist/pms/webhookQueue/services/WebhookQueueService.js +270 -0
- package/dist/pms/webhookQueue/services/WebhookWorker.d.ts +37 -0
- package/dist/pms/webhookQueue/services/WebhookWorker.js +201 -0
- package/dist/pms/webhookQueue/services/index.d.ts +1 -0
- package/dist/pms/webhookQueue/services/index.js +17 -0
- package/dist/pms/webhookQueue/types/index.d.ts +1 -0
- package/dist/pms/webhookQueue/types/index.js +17 -0
- package/dist/pms/webhookQueue/types/webhook.types.d.ts +39 -0
- package/dist/pms/webhookQueue/types/webhook.types.js +2 -0
- package/dist/property/IProperty.d.ts +29 -0
- package/dist/property/IProperty.js +2 -0
- package/dist/property/Property.repository.d.ts +8 -0
- package/dist/property/Property.repository.js +109 -0
- package/dist/property/Property.service.d.ts +8 -0
- package/dist/property/Property.service.js +124 -0
- package/dist/property/index.d.ts +2 -0
- package/dist/property/index.js +18 -0
- package/dist/queue/interfaces/IHttpRequestJob.d.ts +9 -0
- package/dist/queue/interfaces/IHttpRequestJob.js +2 -0
- package/dist/types/alert.types.d.ts +57 -0
- package/dist/types/alert.types.js +22 -0
- package/dist/types/config.types.d.ts +19 -0
- package/dist/types/config.types.js +2 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +19 -0
- package/dist/types/issue.types.d.ts +90 -0
- package/dist/types/issue.types.js +40 -0
- package/dist/utils/http-utils.d.ts +13 -0
- package/dist/utils/http-utils.js +117 -0
- package/package.json +1 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CopilotQueueExample = void 0;
|
|
4
|
+
const typedi_1 = require("typedi");
|
|
5
|
+
const index_1 = require("../index");
|
|
6
|
+
/**
|
|
7
|
+
* Example usage of CopilotQueueService
|
|
8
|
+
* This demonstrates how to use the queue system to handle API requests with FIFO ordering per property
|
|
9
|
+
*/
|
|
10
|
+
class CopilotQueueExample {
|
|
11
|
+
constructor() {
|
|
12
|
+
// Get the service instance from the DI container
|
|
13
|
+
this.copilotQueueService = typedi_1.Container.get(index_1.CopilotQueueService);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Example: Add a simple GET request to the queue
|
|
17
|
+
*/
|
|
18
|
+
async addGetRequest(propertyId, url) {
|
|
19
|
+
const request = {
|
|
20
|
+
url,
|
|
21
|
+
method: 'GET',
|
|
22
|
+
propertyId,
|
|
23
|
+
headers: {
|
|
24
|
+
'Authorization': 'Bearer your-token-here',
|
|
25
|
+
'Accept': 'application/json',
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
const result = await this.copilotQueueService.addQueueRequest(request);
|
|
29
|
+
console.log(`GET request queued with job ID: ${result.jobId}`);
|
|
30
|
+
return result.jobId;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Example: Add a POST request with body to the queue
|
|
34
|
+
*/
|
|
35
|
+
async addPostRequest(propertyId, url, data) {
|
|
36
|
+
const request = {
|
|
37
|
+
url,
|
|
38
|
+
method: 'POST',
|
|
39
|
+
propertyId,
|
|
40
|
+
headers: {
|
|
41
|
+
'Authorization': 'Bearer your-token-here',
|
|
42
|
+
'Content-Type': 'application/json',
|
|
43
|
+
},
|
|
44
|
+
body: data,
|
|
45
|
+
};
|
|
46
|
+
const options = {
|
|
47
|
+
priority: 1, // Higher priority
|
|
48
|
+
attempts: 5, // Retry up to 5 times
|
|
49
|
+
backoff: {
|
|
50
|
+
type: 'exponential',
|
|
51
|
+
delay: 3000,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
const result = await this.copilotQueueService.addQueueRequest(request, options);
|
|
55
|
+
console.log(`POST request queued with job ID: ${result.jobId}`);
|
|
56
|
+
return result.jobId;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Example: Add multiple requests for different properties
|
|
60
|
+
* This demonstrates FIFO ordering per property
|
|
61
|
+
*/
|
|
62
|
+
async addMultipleRequests() {
|
|
63
|
+
const requests = [
|
|
64
|
+
{ propertyId: 'property-1', url: 'https://api.example.com/endpoint1', method: 'GET' },
|
|
65
|
+
{ propertyId: 'property-2', url: 'https://api.example.com/endpoint2', method: 'POST', body: { data: 'test' } },
|
|
66
|
+
{ propertyId: 'property-1', url: 'https://api.example.com/endpoint3', method: 'PUT', body: { update: 'data' } },
|
|
67
|
+
{ propertyId: 'property-2', url: 'https://api.example.com/endpoint4', method: 'GET' },
|
|
68
|
+
{ propertyId: 'property-1', url: 'https://api.example.com/endpoint5', method: 'DELETE' },
|
|
69
|
+
];
|
|
70
|
+
const jobIds = [];
|
|
71
|
+
for (const req of requests) {
|
|
72
|
+
const request = {
|
|
73
|
+
url: req.url,
|
|
74
|
+
method: req.method,
|
|
75
|
+
propertyId: req.propertyId,
|
|
76
|
+
headers: {
|
|
77
|
+
'Authorization': 'Bearer your-token-here',
|
|
78
|
+
},
|
|
79
|
+
body: req.body,
|
|
80
|
+
};
|
|
81
|
+
const result = await this.copilotQueueService.addQueueRequest(request);
|
|
82
|
+
jobIds.push(result.jobId);
|
|
83
|
+
console.log(`Request queued for ${req.propertyId}: ${req.method} ${req.url} (Job ID: ${result.jobId})`);
|
|
84
|
+
}
|
|
85
|
+
console.log('All requests queued. Jobs will be processed in FIFO order per property.');
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Example: Monitor job status
|
|
89
|
+
*/
|
|
90
|
+
async monitorJob(jobId) {
|
|
91
|
+
const status = await this.copilotQueueService.getJobStatus(jobId);
|
|
92
|
+
console.log('Job Status:', status);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Example: Get all jobs for a specific property
|
|
96
|
+
*/
|
|
97
|
+
async getPropertyJobs(propertyId) {
|
|
98
|
+
const jobs = await this.copilotQueueService.getJobsByProperty(propertyId);
|
|
99
|
+
console.log(`Jobs for property ${propertyId}:`, jobs);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Example: Cancel a job
|
|
103
|
+
*/
|
|
104
|
+
async cancelJob(jobId) {
|
|
105
|
+
const cancelled = await this.copilotQueueService.cancelJob(jobId);
|
|
106
|
+
console.log(`Job ${jobId} cancelled: ${cancelled}`);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Example: Graceful shutdown
|
|
110
|
+
*/
|
|
111
|
+
async shutdown() {
|
|
112
|
+
await this.copilotQueueService.shutdown();
|
|
113
|
+
console.log('CopilotQueue service shutdown complete');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.CopilotQueueExample = CopilotQueueExample;
|
|
117
|
+
// Usage example
|
|
118
|
+
async function runExample() {
|
|
119
|
+
const example = new CopilotQueueExample();
|
|
120
|
+
try {
|
|
121
|
+
// Add some requests
|
|
122
|
+
await example.addMultipleRequests();
|
|
123
|
+
// Wait a bit for processing
|
|
124
|
+
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
125
|
+
// Check job status
|
|
126
|
+
const jobId = await example.addGetRequest('property-1', 'https://api.example.com/test');
|
|
127
|
+
await example.monitorJob(jobId);
|
|
128
|
+
// Get jobs for a property
|
|
129
|
+
await example.getPropertyJobs('property-1');
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
console.error('Example error:', error);
|
|
133
|
+
}
|
|
134
|
+
finally {
|
|
135
|
+
// Cleanup
|
|
136
|
+
await example.shutdown();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// Uncomment to run the example
|
|
140
|
+
// runExample();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CopilotQueue.example';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./CopilotQueue.example"), exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// Main copilot queue exports
|
|
18
|
+
__exportStar(require("./interfaces"), exports);
|
|
19
|
+
__exportStar(require("./services"), exports);
|
|
20
|
+
__exportStar(require("./types"), exports);
|
|
21
|
+
__exportStar(require("./utils"), exports);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface ICopilotQueueRequest {
|
|
2
|
+
url: string;
|
|
3
|
+
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
params?: Record<string, string>;
|
|
6
|
+
query?: Record<string, string>;
|
|
7
|
+
body: any;
|
|
8
|
+
timestamp?: number;
|
|
9
|
+
jobId?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ICopilotQueueResponse {
|
|
12
|
+
success: boolean;
|
|
13
|
+
data?: any;
|
|
14
|
+
error?: string;
|
|
15
|
+
jobId: string;
|
|
16
|
+
propertyId: string;
|
|
17
|
+
processingTime?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface ICopilotQueueOptions {
|
|
20
|
+
delay?: number;
|
|
21
|
+
priority?: number;
|
|
22
|
+
attempts?: number;
|
|
23
|
+
backoff?: {
|
|
24
|
+
type: "fixed" | "exponential";
|
|
25
|
+
delay: number;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ICopilotQueueRequest, ICopilotQueueOptions } from "./ICopilotQueueRequest";
|
|
2
|
+
export interface ICopilotQueueService {
|
|
3
|
+
/**
|
|
4
|
+
* Add a request to the queue for processing
|
|
5
|
+
* @param request - The request data including URL, method, headers, and body (with propertyId)
|
|
6
|
+
* @param options - Optional queue configuration
|
|
7
|
+
* @returns Promise with job ID and queue response
|
|
8
|
+
*/
|
|
9
|
+
addQueueRequest(request: ICopilotQueueRequest, options?: ICopilotQueueOptions): Promise<{
|
|
10
|
+
jobId: string;
|
|
11
|
+
queued: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* Get the status of a queued job
|
|
15
|
+
* @param jobId - The job ID to check
|
|
16
|
+
* @returns Promise with job status
|
|
17
|
+
*/
|
|
18
|
+
getJobStatus(jobId: string): Promise<any>;
|
|
19
|
+
/**
|
|
20
|
+
* Shutdown the queue service
|
|
21
|
+
* @returns Promise that resolves when shutdown is complete
|
|
22
|
+
*/
|
|
23
|
+
shutdown(): Promise<void>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ICopilotQueueRequest"), exports);
|
|
18
|
+
__exportStar(require("./ICopilotQueueService"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ICopilotQueueService, ICopilotQueueRequest, ICopilotQueueOptions } from "../interfaces";
|
|
2
|
+
export declare class CopilotQueueService implements ICopilotQueueService {
|
|
3
|
+
private readonly copilotQueues;
|
|
4
|
+
private readonly workers;
|
|
5
|
+
constructor();
|
|
6
|
+
private processRequest;
|
|
7
|
+
addQueueRequest(request: ICopilotQueueRequest, options?: ICopilotQueueOptions): Promise<{
|
|
8
|
+
jobId: string;
|
|
9
|
+
queued: boolean;
|
|
10
|
+
}>;
|
|
11
|
+
getJobStatus(jobId: string): Promise<any>;
|
|
12
|
+
shutdown(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
+
var _, done = false;
|
|
8
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
+
var context = {};
|
|
10
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
+
if (kind === "accessor") {
|
|
15
|
+
if (result === void 0) continue;
|
|
16
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
+
}
|
|
21
|
+
else if (_ = accept(result)) {
|
|
22
|
+
if (kind === "field") initializers.unshift(_);
|
|
23
|
+
else descriptor[key] = _;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
+
done = true;
|
|
28
|
+
};
|
|
29
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
+
var useValue = arguments.length > 2;
|
|
31
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
+
}
|
|
34
|
+
return useValue ? value : void 0;
|
|
35
|
+
};
|
|
36
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
37
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
38
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
39
|
+
};
|
|
40
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
|
+
};
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.CopilotQueueService = void 0;
|
|
45
|
+
const typedi_1 = require("typedi");
|
|
46
|
+
const axios_1 = __importDefault(require("axios"));
|
|
47
|
+
const config_1 = require("../../config/config");
|
|
48
|
+
const utils_1 = require("../utils");
|
|
49
|
+
let CopilotQueueService = (() => {
|
|
50
|
+
let _classDecorators = [(0, typedi_1.Service)()];
|
|
51
|
+
let _classDescriptor;
|
|
52
|
+
let _classExtraInitializers = [];
|
|
53
|
+
let _classThis;
|
|
54
|
+
var CopilotQueueService = _classThis = class {
|
|
55
|
+
constructor() {
|
|
56
|
+
this.copilotQueues = new Map(); // BullMQ Queue instances
|
|
57
|
+
this.workers = new Map(); // BullMQ Worker instances
|
|
58
|
+
}
|
|
59
|
+
async processRequest(job) {
|
|
60
|
+
const { url, method, headers, body } = job.data;
|
|
61
|
+
const propertyId = body?.propertyId;
|
|
62
|
+
const startTime = Date.now();
|
|
63
|
+
try {
|
|
64
|
+
(0, config_1.getConfig)().LOGGER.info(`Processing request for property ${propertyId}: ${method} ${url}`);
|
|
65
|
+
// Prepare axios request configuration
|
|
66
|
+
const axiosConfig = {
|
|
67
|
+
method: method.toLowerCase(),
|
|
68
|
+
url,
|
|
69
|
+
headers: {
|
|
70
|
+
"Content-Type": "application/json",
|
|
71
|
+
...headers,
|
|
72
|
+
},
|
|
73
|
+
timeout: 30000, // 30 second timeout
|
|
74
|
+
};
|
|
75
|
+
// Add body for POST, PUT, PATCH requests
|
|
76
|
+
if (body && ["post", "put", "patch"].includes(method.toLowerCase())) {
|
|
77
|
+
axiosConfig.data = body;
|
|
78
|
+
}
|
|
79
|
+
// Execute the HTTP request (fire and forget - no response processing)
|
|
80
|
+
await (0, axios_1.default)(axiosConfig);
|
|
81
|
+
const responseTime = Date.now() - startTime;
|
|
82
|
+
(0, config_1.getConfig)().LOGGER.info(`Request executed for property ${propertyId}: ${method} ${url} (${responseTime}ms)`);
|
|
83
|
+
return {
|
|
84
|
+
success: true,
|
|
85
|
+
responseTime,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
const responseTime = Date.now() - startTime;
|
|
90
|
+
const errorMessage = error.response?.data?.message || error.message || "Unknown error";
|
|
91
|
+
(0, config_1.getConfig)().LOGGER.error(`Request failed for property ${propertyId}: ${errorMessage} (${responseTime}ms)`);
|
|
92
|
+
return {
|
|
93
|
+
success: false,
|
|
94
|
+
error: errorMessage,
|
|
95
|
+
statusCode: error.response?.status || 500,
|
|
96
|
+
responseTime,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async addQueueRequest(request, options) {
|
|
101
|
+
try {
|
|
102
|
+
// Validate required fields
|
|
103
|
+
if (!request.url ||
|
|
104
|
+
!request.method ||
|
|
105
|
+
!request.body ||
|
|
106
|
+
!request.body.propertyId) {
|
|
107
|
+
throw new Error("Missing required fields: url, method, and body with propertyId are required");
|
|
108
|
+
}
|
|
109
|
+
const propertyId = request.body.propertyId;
|
|
110
|
+
const queueName = utils_1.QueueManager.generateQueueName(propertyId);
|
|
111
|
+
// Get or create queue and worker using the QueueManager
|
|
112
|
+
const queue = await utils_1.QueueManager.getOrCreateQueue(queueName, this.copilotQueues);
|
|
113
|
+
// Create worker for this queue if it doesn't exist
|
|
114
|
+
await utils_1.QueueManager.getOrCreateWorker(queueName, this.workers, this.copilotQueues, this.processRequest.bind(this));
|
|
115
|
+
// Prepare job data
|
|
116
|
+
const jobData = {
|
|
117
|
+
url: request.url,
|
|
118
|
+
method: request.method,
|
|
119
|
+
headers: request.headers,
|
|
120
|
+
body: request.body,
|
|
121
|
+
timestamp: Date.now(),
|
|
122
|
+
};
|
|
123
|
+
// Add job to queue with TTL (similar to WebhookQueueService)
|
|
124
|
+
const job = await queue.add("copilot-request", jobData, {
|
|
125
|
+
removeOnComplete: { age: 5 * 60 }, // Remove after 5 minutes
|
|
126
|
+
removeOnFail: { age: 10 * 60 }, // Remove failed jobs after 10 minutes
|
|
127
|
+
attempts: 1, // No retries - execute only once
|
|
128
|
+
delay: options?.delay || 0,
|
|
129
|
+
priority: options?.priority || 0,
|
|
130
|
+
// Use propertyId as job group to ensure FIFO ordering per property
|
|
131
|
+
jobId: utils_1.QueueManager.generateJobId(propertyId),
|
|
132
|
+
});
|
|
133
|
+
(0, config_1.getConfig)().LOGGER.info(`Request queued for property ${propertyId}: ${request.method} ${request.url} (Job ID: ${job.id})`);
|
|
134
|
+
return {
|
|
135
|
+
jobId: job.id,
|
|
136
|
+
queued: true,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
(0, config_1.getConfig)().LOGGER.error("Failed to add request to queue:", error.message);
|
|
141
|
+
throw error;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
async getJobStatus(jobId) {
|
|
145
|
+
try {
|
|
146
|
+
// Extract propertyId from jobId (format: propertyId-timestamp-random)
|
|
147
|
+
const propertyId = utils_1.QueueManager.extractPropertyIdFromJobId(jobId);
|
|
148
|
+
const queueName = utils_1.QueueManager.generateQueueName(propertyId);
|
|
149
|
+
// Get or create queue
|
|
150
|
+
const queue = await utils_1.QueueManager.getOrCreateQueue(queueName, this.copilotQueues);
|
|
151
|
+
const job = await queue.getJob(jobId);
|
|
152
|
+
if (!job) {
|
|
153
|
+
return { exists: false };
|
|
154
|
+
}
|
|
155
|
+
const state = await job.getState();
|
|
156
|
+
return {
|
|
157
|
+
exists: true,
|
|
158
|
+
id: job.id,
|
|
159
|
+
state,
|
|
160
|
+
data: job.data,
|
|
161
|
+
progress: job.progress,
|
|
162
|
+
returnvalue: job.returnvalue,
|
|
163
|
+
failedReason: job.failedReason,
|
|
164
|
+
processedOn: job.processedOn,
|
|
165
|
+
finishedOn: job.finishedOn,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
(0, config_1.getConfig)().LOGGER.error(`Failed to get job status for ${jobId}:`, error.message);
|
|
170
|
+
throw error;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
async shutdown() {
|
|
174
|
+
try {
|
|
175
|
+
(0, config_1.getConfig)().LOGGER.info("Shutting down CopilotQueue service...");
|
|
176
|
+
// Close all workers and queues using QueueManager
|
|
177
|
+
await utils_1.QueueManager.closeAllWorkersAndQueues(this.workers, this.copilotQueues);
|
|
178
|
+
(0, config_1.getConfig)().LOGGER.info("CopilotQueue service shutdown complete");
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
(0, config_1.getConfig)().LOGGER.error("Error during CopilotQueue shutdown:", error.message);
|
|
182
|
+
throw error;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
__setFunctionName(_classThis, "CopilotQueueService");
|
|
187
|
+
(() => {
|
|
188
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
189
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
190
|
+
CopilotQueueService = _classThis = _classDescriptor.value;
|
|
191
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
192
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
193
|
+
})();
|
|
194
|
+
return CopilotQueueService = _classThis;
|
|
195
|
+
})();
|
|
196
|
+
exports.CopilotQueueService = CopilotQueueService;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./CopilotQueue.service";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./CopilotQueue.service"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Job, Queue, Worker } from "bullmq";
|
|
2
|
+
export interface CopilotJobData {
|
|
3
|
+
url: string;
|
|
4
|
+
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
5
|
+
params?: Record<string, string>;
|
|
6
|
+
query?: Record<string, string>;
|
|
7
|
+
headers?: Record<string, string>;
|
|
8
|
+
body: any;
|
|
9
|
+
timestamp?: number;
|
|
10
|
+
}
|
|
11
|
+
export type CopilotQueue = Queue<CopilotJobData>;
|
|
12
|
+
export type CopilotWorker = Worker<CopilotJobData>;
|
|
13
|
+
export type CopilotJob = Job<CopilotJobData>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./copilot.types";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./copilot.types"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./queueManager";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./queueManager"), exports);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Job } from "bullmq";
|
|
2
|
+
export declare class QueueManager {
|
|
3
|
+
/**
|
|
4
|
+
* Get or create a BullMQ queue
|
|
5
|
+
*/
|
|
6
|
+
static getOrCreateQueue(queueKey: string, queues: Map<string, any>): Promise<any>;
|
|
7
|
+
/**
|
|
8
|
+
* Get or create a BullMQ worker
|
|
9
|
+
*/
|
|
10
|
+
static getOrCreateWorker(queueKey: string, workers: Map<string, any>, queues: Map<string, any>, processor: (job: Job) => Promise<any>): Promise<any>;
|
|
11
|
+
/**
|
|
12
|
+
* Check if queue is empty and cleanup worker if no jobs are pending
|
|
13
|
+
*/
|
|
14
|
+
static checkAndCleanupWorker(queueKey: string, workers: Map<string, any>, queues: Map<string, any>): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Close all workers and queues
|
|
17
|
+
*/
|
|
18
|
+
static closeAllWorkersAndQueues(workers: Map<string, any>, queues: Map<string, any>): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Generate queue name for a property
|
|
21
|
+
*/
|
|
22
|
+
static generateQueueName(propertyId: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Extract property ID from job ID
|
|
25
|
+
*/
|
|
26
|
+
static extractPropertyIdFromJobId(jobId: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Generate unique job ID
|
|
29
|
+
*/
|
|
30
|
+
static generateJobId(propertyId: string): string;
|
|
31
|
+
}
|