sdk-triggerx 0.1.10 → 0.1.11
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/api/getJobDataById.d.ts +2 -2
- package/dist/api/getJobDataById.js +16 -3
- package/dist/types.d.ts +16 -0
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TriggerXClient } from '../client';
|
|
2
|
-
import {
|
|
3
|
-
export declare const getJobDataById: (client: TriggerXClient, jobId: string) => Promise<
|
|
2
|
+
import { JobDataWithTasks } from '../types';
|
|
3
|
+
export declare const getJobDataById: (client: TriggerXClient, jobId: string) => Promise<JobDataWithTasks>;
|
|
@@ -5,16 +5,29 @@ exports.getJobDataById = void 0;
|
|
|
5
5
|
const getJobDataById = async (client, jobId) => {
|
|
6
6
|
const apiKey = client.getApiKey(); // Assuming you have a method to get the API key
|
|
7
7
|
try {
|
|
8
|
-
|
|
8
|
+
// First, fetch the job data
|
|
9
|
+
const jobResponse = await client.get(`/api/jobs/${jobId}`, {
|
|
9
10
|
headers: {
|
|
10
11
|
'Content-Type': 'application/json',
|
|
11
12
|
'X-API-KEY': apiKey,
|
|
12
13
|
},
|
|
13
14
|
});
|
|
14
|
-
|
|
15
|
+
// Then, fetch the task data (logs) for this job
|
|
16
|
+
const taskResponse = await client.get(`/api/tasks/job/${jobId}`, {
|
|
17
|
+
headers: {
|
|
18
|
+
'Content-Type': 'application/json',
|
|
19
|
+
'X-API-KEY': apiKey,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
// Combine both responses
|
|
23
|
+
const combinedResponse = {
|
|
24
|
+
jobData: jobResponse,
|
|
25
|
+
taskData: taskResponse
|
|
26
|
+
};
|
|
27
|
+
return combinedResponse;
|
|
15
28
|
}
|
|
16
29
|
catch (error) {
|
|
17
|
-
console.error('Error fetching job data by ID:', error);
|
|
30
|
+
console.error('Error fetching job data and task data by ID:', error);
|
|
18
31
|
throw error; // Rethrow the error for handling in the calling function
|
|
19
32
|
}
|
|
20
33
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -230,3 +230,19 @@ export interface UserData {
|
|
|
230
230
|
last_updated_at: Date;
|
|
231
231
|
email: string;
|
|
232
232
|
}
|
|
233
|
+
export interface TaskData {
|
|
234
|
+
task_id: number;
|
|
235
|
+
task_number: number;
|
|
236
|
+
task_opx_cost: number;
|
|
237
|
+
execution_timestamp: Date;
|
|
238
|
+
execution_tx_hash: string;
|
|
239
|
+
task_performer_id: number;
|
|
240
|
+
task_attester_ids: number[];
|
|
241
|
+
is_accepted: boolean;
|
|
242
|
+
tx_url: string;
|
|
243
|
+
task_status: string;
|
|
244
|
+
}
|
|
245
|
+
export interface JobDataWithTasks {
|
|
246
|
+
jobData: JobDataAPI;
|
|
247
|
+
taskData: TaskData[];
|
|
248
|
+
}
|