dt-common-device 13.9.2 → 13.10.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.
@@ -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 () => {
@@ -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.
@@ -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,
@@ -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<void>;
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<any>;
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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dt-common-device",
3
- "version": "13.9.2",
3
+ "version": "13.10.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [