@centrali-io/centrali-sdk 4.4.5 → 4.4.6
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/index.js +42 -0
- package/index.ts +60 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -87,6 +87,7 @@ exports.getComputeFunctionTestApiPath = getComputeFunctionTestApiPath;
|
|
|
87
87
|
exports.getFunctionRunsApiPath = getFunctionRunsApiPath;
|
|
88
88
|
exports.getFunctionRunsByTriggerApiPath = getFunctionRunsByTriggerApiPath;
|
|
89
89
|
exports.getFunctionRunsByFunctionApiPath = getFunctionRunsByFunctionApiPath;
|
|
90
|
+
exports.getComputeJobStatusApiPath = getComputeJobStatusApiPath;
|
|
90
91
|
exports.getSmartQueryTestApiPath = getSmartQueryTestApiPath;
|
|
91
92
|
exports.getValidationSuggestionsApiPath = getValidationSuggestionsApiPath;
|
|
92
93
|
exports.getValidationSuggestionAcceptApiPath = getValidationSuggestionAcceptApiPath;
|
|
@@ -681,6 +682,15 @@ function getFunctionRunsByFunctionApiPath(workspaceId, functionId) {
|
|
|
681
682
|
return `data/workspace/${workspaceId}/api/v1/function-runs/function/${functionId}`;
|
|
682
683
|
}
|
|
683
684
|
// =====================================================
|
|
685
|
+
// Compute Job Status API Path Helper
|
|
686
|
+
// =====================================================
|
|
687
|
+
/**
|
|
688
|
+
* Generate Compute Job Status API URL PATH.
|
|
689
|
+
*/
|
|
690
|
+
function getComputeJobStatusApiPath(workspaceId, jobId) {
|
|
691
|
+
return `data/workspace/${workspaceId}/api/v1/jobs/compute/${jobId}`;
|
|
692
|
+
}
|
|
693
|
+
// =====================================================
|
|
684
694
|
// Smart Query Test API Path Helper (Configuration-as-Code)
|
|
685
695
|
// =====================================================
|
|
686
696
|
/**
|
|
@@ -2619,6 +2629,38 @@ class FunctionRunsManager {
|
|
|
2619
2629
|
queryParams.status = options.status;
|
|
2620
2630
|
return this.requestFn('GET', path, null, queryParams);
|
|
2621
2631
|
}
|
|
2632
|
+
/**
|
|
2633
|
+
* Get the status of a compute job by job ID.
|
|
2634
|
+
*
|
|
2635
|
+
* This is the primary way to poll for the result of an async trigger
|
|
2636
|
+
* invocation. The job ID is returned by `client.triggers.invoke()`.
|
|
2637
|
+
*
|
|
2638
|
+
* @param jobId - The job ID returned by invoke
|
|
2639
|
+
* @returns Job status including returnValue (on success) or failedReason (on failure)
|
|
2640
|
+
*
|
|
2641
|
+
* @example
|
|
2642
|
+
* ```ts
|
|
2643
|
+
* // Invoke a trigger and poll for the result
|
|
2644
|
+
* const { data: jobId } = await client.triggers.invoke('trigger-uuid');
|
|
2645
|
+
*
|
|
2646
|
+
* // Poll until complete
|
|
2647
|
+
* let job;
|
|
2648
|
+
* do {
|
|
2649
|
+
* await new Promise(r => setTimeout(r, 1000));
|
|
2650
|
+
* job = await client.runs.getJobStatus(jobId);
|
|
2651
|
+
* } while (job.data.status === 'queued' || job.data.status === 'running');
|
|
2652
|
+
*
|
|
2653
|
+
* if (job.data.status === 'completed') {
|
|
2654
|
+
* console.log('Result:', job.data.returnValue);
|
|
2655
|
+
* } else {
|
|
2656
|
+
* console.error('Failed:', job.data.failedReason);
|
|
2657
|
+
* }
|
|
2658
|
+
* ```
|
|
2659
|
+
*/
|
|
2660
|
+
getJobStatus(jobId) {
|
|
2661
|
+
const path = getComputeJobStatusApiPath(this.workspaceId, jobId);
|
|
2662
|
+
return this.requestFn('GET', path);
|
|
2663
|
+
}
|
|
2622
2664
|
}
|
|
2623
2665
|
exports.FunctionRunsManager = FunctionRunsManager;
|
|
2624
2666
|
/**
|
package/index.ts
CHANGED
|
@@ -1840,6 +1840,22 @@ export interface ListFunctionRunsOptions {
|
|
|
1840
1840
|
status?: FunctionRunStatus;
|
|
1841
1841
|
}
|
|
1842
1842
|
|
|
1843
|
+
/**
|
|
1844
|
+
* Status of a compute job in the execution pipeline.
|
|
1845
|
+
*/
|
|
1846
|
+
export type ComputeJobStatus = 'queued' | 'running' | 'completed' | 'failed';
|
|
1847
|
+
|
|
1848
|
+
/**
|
|
1849
|
+
* A compute job status response from the job status endpoint.
|
|
1850
|
+
* Represents the state of an async compute execution.
|
|
1851
|
+
*/
|
|
1852
|
+
export interface ComputeJobStatusResponse {
|
|
1853
|
+
jobId: string;
|
|
1854
|
+
status: ComputeJobStatus;
|
|
1855
|
+
returnValue?: any;
|
|
1856
|
+
failedReason?: string | null;
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1843
1859
|
// =====================================================
|
|
1844
1860
|
// Trigger CRUD Types (Configuration-as-Code)
|
|
1845
1861
|
// =====================================================
|
|
@@ -2820,6 +2836,17 @@ export function getFunctionRunsByFunctionApiPath(workspaceId: string, functionId
|
|
|
2820
2836
|
return `data/workspace/${workspaceId}/api/v1/function-runs/function/${functionId}`;
|
|
2821
2837
|
}
|
|
2822
2838
|
|
|
2839
|
+
// =====================================================
|
|
2840
|
+
// Compute Job Status API Path Helper
|
|
2841
|
+
// =====================================================
|
|
2842
|
+
|
|
2843
|
+
/**
|
|
2844
|
+
* Generate Compute Job Status API URL PATH.
|
|
2845
|
+
*/
|
|
2846
|
+
export function getComputeJobStatusApiPath(workspaceId: string, jobId: string): string {
|
|
2847
|
+
return `data/workspace/${workspaceId}/api/v1/jobs/compute/${jobId}`;
|
|
2848
|
+
}
|
|
2849
|
+
|
|
2823
2850
|
// =====================================================
|
|
2824
2851
|
// Smart Query Test API Path Helper (Configuration-as-Code)
|
|
2825
2852
|
// =====================================================
|
|
@@ -4939,6 +4966,39 @@ export class FunctionRunsManager {
|
|
|
4939
4966
|
if (options?.status) queryParams.status = options.status;
|
|
4940
4967
|
return this.requestFn<PaginatedResponse<FunctionRun>>('GET', path, null, queryParams);
|
|
4941
4968
|
}
|
|
4969
|
+
|
|
4970
|
+
/**
|
|
4971
|
+
* Get the status of a compute job by job ID.
|
|
4972
|
+
*
|
|
4973
|
+
* This is the primary way to poll for the result of an async trigger
|
|
4974
|
+
* invocation. The job ID is returned by `client.triggers.invoke()`.
|
|
4975
|
+
*
|
|
4976
|
+
* @param jobId - The job ID returned by invoke
|
|
4977
|
+
* @returns Job status including returnValue (on success) or failedReason (on failure)
|
|
4978
|
+
*
|
|
4979
|
+
* @example
|
|
4980
|
+
* ```ts
|
|
4981
|
+
* // Invoke a trigger and poll for the result
|
|
4982
|
+
* const { data: jobId } = await client.triggers.invoke('trigger-uuid');
|
|
4983
|
+
*
|
|
4984
|
+
* // Poll until complete
|
|
4985
|
+
* let job;
|
|
4986
|
+
* do {
|
|
4987
|
+
* await new Promise(r => setTimeout(r, 1000));
|
|
4988
|
+
* job = await client.runs.getJobStatus(jobId);
|
|
4989
|
+
* } while (job.data.status === 'queued' || job.data.status === 'running');
|
|
4990
|
+
*
|
|
4991
|
+
* if (job.data.status === 'completed') {
|
|
4992
|
+
* console.log('Result:', job.data.returnValue);
|
|
4993
|
+
* } else {
|
|
4994
|
+
* console.error('Failed:', job.data.failedReason);
|
|
4995
|
+
* }
|
|
4996
|
+
* ```
|
|
4997
|
+
*/
|
|
4998
|
+
public getJobStatus(jobId: string): Promise<ApiResponse<ComputeJobStatusResponse>> {
|
|
4999
|
+
const path = getComputeJobStatusApiPath(this.workspaceId, jobId);
|
|
5000
|
+
return this.requestFn<ComputeJobStatusResponse>('GET', path);
|
|
5001
|
+
}
|
|
4942
5002
|
}
|
|
4943
5003
|
|
|
4944
5004
|
/**
|