dt-common-device 13.9.2 → 13.10.2
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/audit/AuditUtils.js +2 -0
- package/dist/config/config.d.ts +1 -1
- package/dist/config/config.js +3 -3
- package/dist/constants/Event.d.ts +10 -0
- package/dist/constants/Event.js +10 -0
- package/dist/cronicle/Cronicle.service.d.ts +3 -3
- package/dist/cronicle/Cronicle.service.js +4 -3
- package/dist/cronicle/ICronicle.interface.d.ts +67 -0
- package/dist/queue/utils/rateLimit.utils.js +6 -0
- package/package.json +1 -1
package/dist/audit/AuditUtils.js
CHANGED
|
@@ -303,6 +303,8 @@ let AuditUtils = (() => {
|
|
|
303
303
|
}
|
|
304
304
|
async getZoneName(zoneId) {
|
|
305
305
|
try {
|
|
306
|
+
if (zoneId === "triggered_externally")
|
|
307
|
+
return "zone_not_found";
|
|
306
308
|
if (!(0, class_validator_1.isUUID)(zoneId))
|
|
307
309
|
return "zone_not_found";
|
|
308
310
|
return await this.getCachedEntityData("zone", zoneId, async () => {
|
package/dist/config/config.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export declare function getHeartbeatSqsQueueUrl(): string;
|
|
|
12
12
|
export declare function getIssueSqsQueueUrl(): string;
|
|
13
13
|
export declare function getEventSubscription(): InternalEventSubscription | null;
|
|
14
14
|
export declare function checkRequiredEnv(requiredEnvs: string[]): void;
|
|
15
|
-
export declare function ensureAuditInitialized(): void
|
|
15
|
+
export declare function ensureAuditInitialized(): Promise<void>;
|
|
16
16
|
export declare function getLogger(): ILogger;
|
|
17
17
|
/**
|
|
18
18
|
* Returns the PostgreSQL DB URI from environment variables.
|
package/dist/config/config.js
CHANGED
|
@@ -103,7 +103,7 @@ async function initialize(cfg) {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
// Initialize audit
|
|
106
|
-
ensureAuditInitialized();
|
|
106
|
+
await ensureAuditInitialized();
|
|
107
107
|
cfg.LOGGER.info("dt-common-device: Initialization completed successfully");
|
|
108
108
|
}
|
|
109
109
|
async function validateInternalEventHandler(cfg) {
|
|
@@ -224,7 +224,7 @@ function checkRequiredEnv(requiredEnvs) {
|
|
|
224
224
|
throw new Error(`Missing required environment variables: ${missing.join(", ")}`);
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
|
-
function ensureAuditInitialized() {
|
|
227
|
+
async function ensureAuditInitialized() {
|
|
228
228
|
if (auditInitialized)
|
|
229
229
|
return;
|
|
230
230
|
// const apiKey = process.env.POSTHOG_API_KEY;
|
|
@@ -237,7 +237,7 @@ function ensureAuditInitialized() {
|
|
|
237
237
|
getConfig().LOGGER.error("CLICKHOUSE_HOST, CLICKHOUSE_DATABASE, CLICKHOUSE_USERNAME, CLICKHOUSE_PASSWORD must be set in environment variables");
|
|
238
238
|
throw new Error("dt-common-device: CLICKHOUSE_HOST, CLICKHOUSE_DATABASE, CLICKHOUSE_USERNAME, CLICKHOUSE_PASSWORD must be set in environment variables");
|
|
239
239
|
}
|
|
240
|
-
(0, dt_audit_library_1.initializeAudit)({
|
|
240
|
+
await (0, dt_audit_library_1.initializeAudit)({
|
|
241
241
|
host,
|
|
242
242
|
database,
|
|
243
243
|
username,
|
|
@@ -148,6 +148,11 @@ export declare const DT_EVENT_TYPES: {
|
|
|
148
148
|
ENABLED: string;
|
|
149
149
|
DISABLED: string;
|
|
150
150
|
};
|
|
151
|
+
BULK_DELETE: {
|
|
152
|
+
ATTEMPT: string;
|
|
153
|
+
SUCCESS: string;
|
|
154
|
+
FAILED: string;
|
|
155
|
+
};
|
|
151
156
|
};
|
|
152
157
|
ZONE: {
|
|
153
158
|
CREATE: {
|
|
@@ -169,6 +174,11 @@ export declare const DT_EVENT_TYPES: {
|
|
|
169
174
|
ENABLED: string;
|
|
170
175
|
DISABLED: string;
|
|
171
176
|
};
|
|
177
|
+
BULK_DELETE: {
|
|
178
|
+
ATTEMPT: string;
|
|
179
|
+
SUCCESS: string;
|
|
180
|
+
FAILED: string;
|
|
181
|
+
};
|
|
172
182
|
};
|
|
173
183
|
ISSUE: {
|
|
174
184
|
CREATE: {
|
package/dist/constants/Event.js
CHANGED
|
@@ -151,6 +151,11 @@ exports.DT_EVENT_TYPES = {
|
|
|
151
151
|
ENABLED: "access_group.maintenance_mode.enabled",
|
|
152
152
|
DISABLED: "access_group.maintenance_mode.disabled",
|
|
153
153
|
},
|
|
154
|
+
BULK_DELETE: {
|
|
155
|
+
ATTEMPT: "accessgroup.bulk_delete.attempt",
|
|
156
|
+
SUCCESS: "accessgroup.bulk_delete.success",
|
|
157
|
+
FAILED: "accessgroup.bulk_delete.failed",
|
|
158
|
+
},
|
|
154
159
|
},
|
|
155
160
|
ZONE: {
|
|
156
161
|
CREATE: {
|
|
@@ -172,6 +177,11 @@ exports.DT_EVENT_TYPES = {
|
|
|
172
177
|
ENABLED: "zone.maintenance_mode.enabled",
|
|
173
178
|
DISABLED: "zone.maintenance_mode.disabled",
|
|
174
179
|
},
|
|
180
|
+
BULK_DELETE: {
|
|
181
|
+
ATTEMPT: "zone.bulk_delete.attempt",
|
|
182
|
+
SUCCESS: "zone.bulk_delete.success",
|
|
183
|
+
FAILED: "zone.bulk_delete.failed",
|
|
184
|
+
},
|
|
175
185
|
},
|
|
176
186
|
ISSUE: {
|
|
177
187
|
CREATE: {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { ICronicle } from "./ICronicle.interface";
|
|
1
|
+
import { ICronicle, ListSchedules } from "./ICronicle.interface";
|
|
2
2
|
export declare class CronicleService {
|
|
3
3
|
private readonly cronicleEndpoint;
|
|
4
4
|
private readonly cronicleApiKey;
|
|
5
5
|
constructor();
|
|
6
6
|
registerJob(payload: ICronicle): Promise<void>;
|
|
7
|
-
updateJob(payload: ICronicle): Promise<
|
|
7
|
+
updateJob(payload: ICronicle): Promise<any>;
|
|
8
8
|
getJob(jobId: string): Promise<any>;
|
|
9
9
|
getSchedules(filter: {
|
|
10
10
|
offset: number;
|
|
11
11
|
limit: number;
|
|
12
|
-
}): Promise<
|
|
12
|
+
}): Promise<ListSchedules | null>;
|
|
13
13
|
deleteJob(jobId: string): Promise<void>;
|
|
14
14
|
}
|
|
@@ -67,7 +67,7 @@ class CronicleService {
|
|
|
67
67
|
croniclePayload.title = name;
|
|
68
68
|
if (timezone)
|
|
69
69
|
croniclePayload.timeZone = timezone;
|
|
70
|
-
if (enabled)
|
|
70
|
+
if (enabled !== undefined)
|
|
71
71
|
croniclePayload.enabled = enabled ? 1 : 0;
|
|
72
72
|
if (target)
|
|
73
73
|
croniclePayload.target = target;
|
|
@@ -89,7 +89,8 @@ class CronicleService {
|
|
|
89
89
|
max_children: 1,
|
|
90
90
|
api_key: this.cronicleApiKey,
|
|
91
91
|
};
|
|
92
|
-
await axios_1.default.post(`${this.cronicleEndpoint}/update_event/v1`, payload);
|
|
92
|
+
const result = await axios_1.default.post(`${this.cronicleEndpoint}/update_event/v1`, payload);
|
|
93
|
+
return result.data;
|
|
93
94
|
}
|
|
94
95
|
catch (error) {
|
|
95
96
|
(0, config_1.getConfig)().LOGGER.error(`Failed to update Cronicle job: ${error.message}`);
|
|
@@ -119,7 +120,7 @@ class CronicleService {
|
|
|
119
120
|
}
|
|
120
121
|
catch (error) {
|
|
121
122
|
(0, config_1.getConfig)().LOGGER.error(`Failed to get schedules: ${error.message}`);
|
|
122
|
-
return;
|
|
123
|
+
return null;
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
126
|
async deleteJob(jobId) {
|
|
@@ -17,3 +17,70 @@ export interface ICronicle {
|
|
|
17
17
|
enabled?: boolean;
|
|
18
18
|
notes?: string;
|
|
19
19
|
}
|
|
20
|
+
export interface CronicleJob {
|
|
21
|
+
id: string;
|
|
22
|
+
title: string;
|
|
23
|
+
category: string;
|
|
24
|
+
plugin: string;
|
|
25
|
+
timeZone?: string;
|
|
26
|
+
timezone?: string;
|
|
27
|
+
enabled: number;
|
|
28
|
+
max_children: number;
|
|
29
|
+
target: string;
|
|
30
|
+
params: {
|
|
31
|
+
timeout: number;
|
|
32
|
+
headers: {
|
|
33
|
+
"Content-Type": string;
|
|
34
|
+
"x-api-key": string;
|
|
35
|
+
"User-Agent": string;
|
|
36
|
+
[key: string]: string;
|
|
37
|
+
};
|
|
38
|
+
url: string;
|
|
39
|
+
method: string;
|
|
40
|
+
data: string;
|
|
41
|
+
follow: number;
|
|
42
|
+
ssl_cert_bypass: number;
|
|
43
|
+
success_match: string;
|
|
44
|
+
error_match: string;
|
|
45
|
+
};
|
|
46
|
+
data: {
|
|
47
|
+
name: string;
|
|
48
|
+
cronJobId: string;
|
|
49
|
+
apiUrl: string;
|
|
50
|
+
method: string;
|
|
51
|
+
target: string;
|
|
52
|
+
schedule: {
|
|
53
|
+
years?: number[];
|
|
54
|
+
months?: number[];
|
|
55
|
+
days?: number[];
|
|
56
|
+
weekdays?: number[];
|
|
57
|
+
hours?: number[];
|
|
58
|
+
minutes?: number[];
|
|
59
|
+
};
|
|
60
|
+
notes: string;
|
|
61
|
+
};
|
|
62
|
+
timing: {
|
|
63
|
+
years?: number[];
|
|
64
|
+
months?: number[];
|
|
65
|
+
days?: number[];
|
|
66
|
+
weekdays?: number[];
|
|
67
|
+
hours?: number[];
|
|
68
|
+
minutes?: number[];
|
|
69
|
+
};
|
|
70
|
+
timeout: number;
|
|
71
|
+
notes: string;
|
|
72
|
+
modified: number;
|
|
73
|
+
created: number;
|
|
74
|
+
api_key: string;
|
|
75
|
+
}
|
|
76
|
+
export interface ListSchedules {
|
|
77
|
+
code: number;
|
|
78
|
+
list: {
|
|
79
|
+
page_size: number;
|
|
80
|
+
first_page: number;
|
|
81
|
+
last_page: number;
|
|
82
|
+
length: number;
|
|
83
|
+
type: string;
|
|
84
|
+
};
|
|
85
|
+
rows: CronicleJob[];
|
|
86
|
+
}
|
|
@@ -141,6 +141,12 @@ class RateLimitUtils {
|
|
|
141
141
|
provider: constants_1.CONNECTION_PROVIDERS.SIFELY,
|
|
142
142
|
maxTimeoutWindowMs: 120000,
|
|
143
143
|
});
|
|
144
|
+
configs.set(constants_1.CONNECTION_PROVIDERS.DUSAW, {
|
|
145
|
+
maxRequests: 10,
|
|
146
|
+
windowMs: 60000, // 1 minute
|
|
147
|
+
provider: constants_1.CONNECTION_PROVIDERS.DUSAW,
|
|
148
|
+
maxTimeoutWindowMs: 120000,
|
|
149
|
+
});
|
|
144
150
|
return configs;
|
|
145
151
|
}
|
|
146
152
|
static async isRateLimitAllowed(connectionId, provider, rateLimitConfigs) {
|