@blaxel/core 0.2.6-dev.74 → 0.2.6-preview.5
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/authentication/clientcredentials.d.ts +0 -2
- package/dist/authentication/clientcredentials.js +1 -16
- package/dist/client/sdk.gen.d.ts +1 -3
- package/dist/client/sdk.gen.js +1 -27
- package/dist/client/types.gen.d.ts +189 -31
- package/dist/jobs/index.d.ts +0 -2
- package/dist/jobs/index.js +0 -2
- package/dist/jobs/jobs.d.ts +8 -10
- package/dist/jobs/jobs.js +40 -80
- package/dist/sandbox/client/sdk.gen.d.ts +12 -2
- package/dist/sandbox/client/sdk.gen.js +23 -1
- package/dist/sandbox/client/types.gen.d.ts +55 -14
- package/dist/sandbox/session.js +2 -0
- package/dist/sandbox/types.d.ts +2 -0
- package/dist/telemetry/telemetry.d.ts +1 -4
- package/dist/telemetry/telemetry.js +2 -9
- package/package.json +1 -1
- package/dist/jobs/start.d.ts +0 -1
- package/dist/jobs/start.js +0 -83
- package/dist/jobs/types.d.ts +0 -3
- package/dist/jobs/types.js +0 -2
|
@@ -9,8 +9,6 @@ export declare class ClientCredentials extends Credentials {
|
|
|
9
9
|
get workspace(): string;
|
|
10
10
|
needRefresh(): boolean;
|
|
11
11
|
authenticate(): Promise<void>;
|
|
12
|
-
private sleep;
|
|
13
|
-
processWithRetry(retry?: number): Promise<void>;
|
|
14
12
|
process(): Promise<void>;
|
|
15
13
|
get authorization(): string;
|
|
16
14
|
get token(): string;
|
|
@@ -42,24 +42,9 @@ class ClientCredentials extends credentials_js_1.Credentials {
|
|
|
42
42
|
if (!this.needRefresh()) {
|
|
43
43
|
return this.currentPromise || Promise.resolve();
|
|
44
44
|
}
|
|
45
|
-
this.currentPromise = this.
|
|
45
|
+
this.currentPromise = this.process();
|
|
46
46
|
return this.currentPromise;
|
|
47
47
|
}
|
|
48
|
-
sleep(ms) {
|
|
49
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
50
|
-
}
|
|
51
|
-
async processWithRetry(retry = 3) {
|
|
52
|
-
try {
|
|
53
|
-
return await this.process();
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
if (retry > 0) {
|
|
57
|
-
await this.sleep(1000);
|
|
58
|
-
return this.processWithRetry(retry - 1);
|
|
59
|
-
}
|
|
60
|
-
throw error;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
48
|
async process() {
|
|
64
49
|
const response = await (0, authentication_js_1.oauthToken)({
|
|
65
50
|
headers: {
|
package/dist/client/sdk.gen.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch';
|
|
2
|
-
import type { ListAgentsData, CreateAgentData, DeleteAgentData, GetAgentData, UpdateAgentData, ListAgentRevisionsData, GetConfigurationData, ListFunctionsData, CreateFunctionData, DeleteFunctionData, GetFunctionData, UpdateFunctionData, ListFunctionRevisionsData, GetIntegrationData, ListIntegrationConnectionsData, CreateIntegrationConnectionData, DeleteIntegrationConnectionData, GetIntegrationConnectionData, UpdateIntegrationConnectionData, GetIntegrationConnectionModelEndpointConfigurationsData, ListIntegrationConnectionModelsData, GetIntegrationConnectionModelData, ListJobsData, CreateJobData, DeleteJobData, GetJobData, UpdateJobData, ListJobRevisionsData, ListKnowledgebasesData, CreateKnowledgebaseData, DeleteKnowledgebaseData, GetKnowledgebaseData, UpdateKnowledgebaseData, ListKnowledgebaseRevisionsData, ListLocationsData, ListMcpHubDefinitionsData, ListModelsData, CreateModelData, DeleteModelData, GetModelData, UpdateModelData, ListModelRevisionsData, ListPoliciesData, CreatePolicyData, DeletePolicyData, GetPolicyData, UpdatePolicyData, ListPrivateClustersData, CreatePrivateClusterData, DeletePrivateClusterData, GetPrivateClusterData, UpdatePrivateClusterData, GetPrivateClusterHealthData, UpdatePrivateClusterHealthData, ListAllPendingInvitationsData, ListSandboxHubDefinitionsData, ListSandboxesData, CreateSandboxData, DeleteSandboxData, GetSandboxData, UpdateSandboxData, ListSandboxPreviewsData, CreateSandboxPreviewData, DeleteSandboxPreviewData, GetSandboxPreviewData, UpdateSandboxPreviewData, ListSandboxPreviewTokensData, CreateSandboxPreviewTokenData, DeleteSandboxPreviewTokenData, StartSandboxData, StopSandboxData, GetWorkspaceServiceAccountsData, CreateWorkspaceServiceAccountData, DeleteWorkspaceServiceAccountData, UpdateWorkspaceServiceAccountData, ListApiKeysForServiceAccountData, CreateApiKeyForServiceAccountData, DeleteApiKeyForServiceAccountData, ListTemplatesData, GetTemplateData,
|
|
2
|
+
import type { ListAgentsData, CreateAgentData, DeleteAgentData, GetAgentData, UpdateAgentData, ListAgentRevisionsData, GetConfigurationData, ListFunctionsData, CreateFunctionData, DeleteFunctionData, GetFunctionData, UpdateFunctionData, ListFunctionRevisionsData, GetIntegrationData, ListIntegrationConnectionsData, CreateIntegrationConnectionData, DeleteIntegrationConnectionData, GetIntegrationConnectionData, UpdateIntegrationConnectionData, GetIntegrationConnectionModelEndpointConfigurationsData, ListIntegrationConnectionModelsData, GetIntegrationConnectionModelData, ListJobsData, CreateJobData, DeleteJobData, GetJobData, UpdateJobData, ListJobRevisionsData, ListKnowledgebasesData, CreateKnowledgebaseData, DeleteKnowledgebaseData, GetKnowledgebaseData, UpdateKnowledgebaseData, ListKnowledgebaseRevisionsData, ListLocationsData, ListMcpHubDefinitionsData, ListModelsData, CreateModelData, DeleteModelData, GetModelData, UpdateModelData, ListModelRevisionsData, ListPoliciesData, CreatePolicyData, DeletePolicyData, GetPolicyData, UpdatePolicyData, ListPrivateClustersData, CreatePrivateClusterData, DeletePrivateClusterData, GetPrivateClusterData, UpdatePrivateClusterData, GetPrivateClusterHealthData, UpdatePrivateClusterHealthData, ListAllPendingInvitationsData, ListSandboxHubDefinitionsData, ListSandboxesData, CreateSandboxData, DeleteSandboxData, GetSandboxData, UpdateSandboxData, ListSandboxPreviewsData, CreateSandboxPreviewData, DeleteSandboxPreviewData, GetSandboxPreviewData, UpdateSandboxPreviewData, ListSandboxPreviewTokensData, CreateSandboxPreviewTokenData, DeleteSandboxPreviewTokenData, StartSandboxData, StopSandboxData, GetWorkspaceServiceAccountsData, CreateWorkspaceServiceAccountData, DeleteWorkspaceServiceAccountData, UpdateWorkspaceServiceAccountData, ListApiKeysForServiceAccountData, CreateApiKeyForServiceAccountData, DeleteApiKeyForServiceAccountData, ListTemplatesData, GetTemplateData, ListWorkspaceUsersData, InviteWorkspaceUserData, RemoveWorkspaceUserData, UpdateWorkspaceUserRoleData, ListWorkspacesData, CreateWorspaceData, DeleteWorkspaceData, GetWorkspaceData, UpdateWorkspaceData, DeclineWorkspaceInvitationData, AcceptWorkspaceInvitationData, LeaveWorkspaceData, CheckWorkspaceAvailabilityData } from './types.gen.js';
|
|
3
3
|
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
|
|
4
4
|
/**
|
|
5
5
|
* You can provide a client instance returned by `createClient()` instead of
|
|
@@ -413,8 +413,6 @@ export declare const listTemplates: <ThrowOnError extends boolean = false>(optio
|
|
|
413
413
|
* Returns a template by name.
|
|
414
414
|
*/
|
|
415
415
|
export declare const getTemplate: <ThrowOnError extends boolean = false>(options: Options<GetTemplateData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen.js").Template, unknown, ThrowOnError>;
|
|
416
|
-
export declare const getTemplateContents: <ThrowOnError extends boolean = false>(options: Options<GetTemplateContentsData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<string[], unknown, ThrowOnError>;
|
|
417
|
-
export declare const getTemplateFileContents: <ThrowOnError extends boolean = false>(options: Options<GetTemplateFileContentsData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<string, unknown, ThrowOnError>;
|
|
418
416
|
/**
|
|
419
417
|
* List users in workspace
|
|
420
418
|
* Returns a list of all users in the workspace.
|
package/dist/client/sdk.gen.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.deletePrivateCluster = exports.createPrivateCluster = exports.listPrivateClusters = exports.updatePolicy = exports.getPolicy = exports.deletePolicy = exports.createPolicy = exports.listPolicies = exports.listModelRevisions = exports.updateModel = exports.getModel = exports.deleteModel = exports.createModel = exports.listModels = exports.listMcpHubDefinitions = exports.listLocations = exports.listKnowledgebaseRevisions = exports.updateKnowledgebase = exports.getKnowledgebase = exports.deleteKnowledgebase = exports.createKnowledgebase = exports.listKnowledgebases = exports.listJobRevisions = exports.updateJob = exports.getJob = exports.deleteJob = exports.createJob = exports.listJobs = exports.getIntegrationConnectionModel = exports.listIntegrationConnectionModels = exports.getIntegrationConnectionModelEndpointConfigurations = exports.updateIntegrationConnection = exports.getIntegrationConnection = exports.deleteIntegrationConnection = exports.createIntegrationConnection = exports.listIntegrationConnections = exports.getIntegration = exports.listFunctionRevisions = exports.updateFunction = exports.getFunction = exports.deleteFunction = exports.createFunction = exports.listFunctions = exports.getConfiguration = exports.listAgentRevisions = exports.updateAgent = exports.getAgent = exports.deleteAgent = exports.createAgent = exports.listAgents = void 0;
|
|
5
|
-
exports.checkWorkspaceAvailability = exports.leaveWorkspace = exports.acceptWorkspaceInvitation = exports.declineWorkspaceInvitation = exports.updateWorkspace = exports.getWorkspace = exports.deleteWorkspace = exports.createWorspace = exports.listWorkspaces = exports.updateWorkspaceUserRole = exports.removeWorkspaceUser = exports.inviteWorkspaceUser = exports.listWorkspaceUsers = exports.
|
|
5
|
+
exports.checkWorkspaceAvailability = exports.leaveWorkspace = exports.acceptWorkspaceInvitation = exports.declineWorkspaceInvitation = exports.updateWorkspace = exports.getWorkspace = exports.deleteWorkspace = exports.createWorspace = exports.listWorkspaces = exports.updateWorkspaceUserRole = exports.removeWorkspaceUser = exports.inviteWorkspaceUser = exports.listWorkspaceUsers = exports.getTemplate = exports.listTemplates = exports.deleteApiKeyForServiceAccount = exports.createApiKeyForServiceAccount = exports.listApiKeysForServiceAccount = exports.updateWorkspaceServiceAccount = exports.deleteWorkspaceServiceAccount = exports.createWorkspaceServiceAccount = exports.getWorkspaceServiceAccounts = exports.stopSandbox = exports.startSandbox = exports.deleteSandboxPreviewToken = exports.createSandboxPreviewToken = exports.listSandboxPreviewTokens = exports.updateSandboxPreview = exports.getSandboxPreview = exports.deleteSandboxPreview = exports.createSandboxPreview = exports.listSandboxPreviews = exports.updateSandbox = exports.getSandbox = exports.deleteSandbox = exports.createSandbox = exports.listSandboxes = exports.listSandboxHubDefinitions = exports.listAllPendingInvitations = exports.updatePrivateClusterHealth = exports.getPrivateClusterHealth = exports.updatePrivateCluster = exports.getPrivateCluster = void 0;
|
|
6
6
|
const client_gen_1 = require("./client.gen");
|
|
7
7
|
/**
|
|
8
8
|
* List all agents
|
|
@@ -1425,32 +1425,6 @@ const getTemplate = (options) => {
|
|
|
1425
1425
|
});
|
|
1426
1426
|
};
|
|
1427
1427
|
exports.getTemplate = getTemplate;
|
|
1428
|
-
const getTemplateContents = (options) => {
|
|
1429
|
-
return (options.client ?? client_gen_1.client).get({
|
|
1430
|
-
security: [
|
|
1431
|
-
{
|
|
1432
|
-
scheme: 'bearer',
|
|
1433
|
-
type: 'http'
|
|
1434
|
-
}
|
|
1435
|
-
],
|
|
1436
|
-
url: '/templates/{templateName}/contents',
|
|
1437
|
-
...options
|
|
1438
|
-
});
|
|
1439
|
-
};
|
|
1440
|
-
exports.getTemplateContents = getTemplateContents;
|
|
1441
|
-
const getTemplateFileContents = (options) => {
|
|
1442
|
-
return (options.client ?? client_gen_1.client).get({
|
|
1443
|
-
security: [
|
|
1444
|
-
{
|
|
1445
|
-
scheme: 'bearer',
|
|
1446
|
-
type: 'http'
|
|
1447
|
-
}
|
|
1448
|
-
],
|
|
1449
|
-
url: '/templates/{templateName}/contents/{fileName}',
|
|
1450
|
-
...options
|
|
1451
|
-
});
|
|
1452
|
-
};
|
|
1453
|
-
exports.getTemplateFileContents = getTemplateFileContents;
|
|
1454
1428
|
/**
|
|
1455
1429
|
* List users in workspace
|
|
1456
1430
|
* Returns a list of all users in the workspace.
|
|
@@ -651,10 +651,183 @@ export type Job = {
|
|
|
651
651
|
*/
|
|
652
652
|
status?: string;
|
|
653
653
|
};
|
|
654
|
+
/**
|
|
655
|
+
* Configuration for a job execution
|
|
656
|
+
*/
|
|
657
|
+
export type JobExecutionConfig = {
|
|
658
|
+
/**
|
|
659
|
+
* The maximum number of concurrent tasks for an execution
|
|
660
|
+
*/
|
|
661
|
+
maxConcurrentTasks?: number;
|
|
662
|
+
/**
|
|
663
|
+
* The maximum number of retries for the job execution
|
|
664
|
+
*/
|
|
665
|
+
maxRetries?: number;
|
|
666
|
+
/**
|
|
667
|
+
* The timeout for the job execution in seconds
|
|
668
|
+
*/
|
|
669
|
+
timeout?: number;
|
|
670
|
+
};
|
|
671
|
+
/**
|
|
672
|
+
* Metrics for job
|
|
673
|
+
*/
|
|
674
|
+
export type JobMetrics = {
|
|
675
|
+
/**
|
|
676
|
+
* Billable time
|
|
677
|
+
*/
|
|
678
|
+
billableTime?: Array<unknown>;
|
|
679
|
+
/**
|
|
680
|
+
* CPU usage
|
|
681
|
+
*/
|
|
682
|
+
cpuUsage?: Array<unknown>;
|
|
683
|
+
/**
|
|
684
|
+
* Executions chart
|
|
685
|
+
*/
|
|
686
|
+
executionsChart?: {
|
|
687
|
+
[key: string]: unknown;
|
|
688
|
+
};
|
|
689
|
+
/**
|
|
690
|
+
* Executions running
|
|
691
|
+
*/
|
|
692
|
+
executionsRunning?: Array<unknown>;
|
|
693
|
+
/**
|
|
694
|
+
* Total executions
|
|
695
|
+
*/
|
|
696
|
+
executionsTotal?: {
|
|
697
|
+
[key: string]: unknown;
|
|
698
|
+
};
|
|
699
|
+
/**
|
|
700
|
+
* RAM usage
|
|
701
|
+
*/
|
|
702
|
+
ramUsage?: Array<unknown>;
|
|
703
|
+
/**
|
|
704
|
+
* Tasks chart
|
|
705
|
+
*/
|
|
706
|
+
tasksChart?: {
|
|
707
|
+
[key: string]: unknown;
|
|
708
|
+
};
|
|
709
|
+
/**
|
|
710
|
+
* Tasks running
|
|
711
|
+
*/
|
|
712
|
+
tasksRunning?: Array<unknown>;
|
|
713
|
+
/**
|
|
714
|
+
* Total tasks
|
|
715
|
+
*/
|
|
716
|
+
tasksTotal?: {
|
|
717
|
+
[key: string]: unknown;
|
|
718
|
+
};
|
|
719
|
+
};
|
|
654
720
|
/**
|
|
655
721
|
* Job specification
|
|
656
722
|
*/
|
|
657
723
|
export type JobSpec = CoreSpec & unknown;
|
|
724
|
+
/**
|
|
725
|
+
* Jobs chart
|
|
726
|
+
*/
|
|
727
|
+
export type JobsChart = {
|
|
728
|
+
failed?: JobsChartValue;
|
|
729
|
+
success?: JobsChartValue;
|
|
730
|
+
};
|
|
731
|
+
/**
|
|
732
|
+
* Jobs CPU usage
|
|
733
|
+
*/
|
|
734
|
+
export type JobsChartValue = {
|
|
735
|
+
/**
|
|
736
|
+
* Metric timestamp
|
|
737
|
+
*/
|
|
738
|
+
timestamp?: string;
|
|
739
|
+
/**
|
|
740
|
+
* Metric value
|
|
741
|
+
*/
|
|
742
|
+
value?: number;
|
|
743
|
+
};
|
|
744
|
+
/**
|
|
745
|
+
* Jobs executions
|
|
746
|
+
*/
|
|
747
|
+
export type JobsExecutions = {
|
|
748
|
+
/**
|
|
749
|
+
* Failed executions
|
|
750
|
+
*/
|
|
751
|
+
failed?: number;
|
|
752
|
+
/**
|
|
753
|
+
* Running executions
|
|
754
|
+
*/
|
|
755
|
+
running?: number;
|
|
756
|
+
/**
|
|
757
|
+
* Success executions
|
|
758
|
+
*/
|
|
759
|
+
success?: number;
|
|
760
|
+
/**
|
|
761
|
+
* Total executions
|
|
762
|
+
*/
|
|
763
|
+
total?: number;
|
|
764
|
+
};
|
|
765
|
+
/**
|
|
766
|
+
* Jobs chart
|
|
767
|
+
*/
|
|
768
|
+
export type JobsNetworkChart = {
|
|
769
|
+
received?: JobsChartValue;
|
|
770
|
+
sent?: JobsChartValue;
|
|
771
|
+
};
|
|
772
|
+
/**
|
|
773
|
+
* Jobs chart
|
|
774
|
+
*/
|
|
775
|
+
export type JobsSuccessFailedChart = {
|
|
776
|
+
failed?: JobsChartValue;
|
|
777
|
+
retried?: JobsChartValue;
|
|
778
|
+
success?: JobsChartValue;
|
|
779
|
+
/**
|
|
780
|
+
* Metric timestamp
|
|
781
|
+
*/
|
|
782
|
+
timestamp?: string;
|
|
783
|
+
total?: JobsChartValue;
|
|
784
|
+
};
|
|
785
|
+
/**
|
|
786
|
+
* Jobs tasks
|
|
787
|
+
*/
|
|
788
|
+
export type JobsTasks = {
|
|
789
|
+
/**
|
|
790
|
+
* Failed executions
|
|
791
|
+
*/
|
|
792
|
+
failed?: number;
|
|
793
|
+
/**
|
|
794
|
+
* Running executions
|
|
795
|
+
*/
|
|
796
|
+
running?: number;
|
|
797
|
+
/**
|
|
798
|
+
* Success executions
|
|
799
|
+
*/
|
|
800
|
+
success?: number;
|
|
801
|
+
/**
|
|
802
|
+
* Total executions
|
|
803
|
+
*/
|
|
804
|
+
total?: number;
|
|
805
|
+
};
|
|
806
|
+
/**
|
|
807
|
+
* Jobs executions
|
|
808
|
+
*/
|
|
809
|
+
export type JobsTotal = {
|
|
810
|
+
/**
|
|
811
|
+
* Failed executions
|
|
812
|
+
*/
|
|
813
|
+
failed?: number;
|
|
814
|
+
/**
|
|
815
|
+
* Retried executions
|
|
816
|
+
*/
|
|
817
|
+
retried?: number;
|
|
818
|
+
/**
|
|
819
|
+
* Running executions
|
|
820
|
+
*/
|
|
821
|
+
running?: number;
|
|
822
|
+
/**
|
|
823
|
+
* Success executions
|
|
824
|
+
*/
|
|
825
|
+
success?: number;
|
|
826
|
+
/**
|
|
827
|
+
* Total executions
|
|
828
|
+
*/
|
|
829
|
+
total?: number;
|
|
830
|
+
};
|
|
658
831
|
/**
|
|
659
832
|
* Knowledgebase
|
|
660
833
|
*/
|
|
@@ -1242,6 +1415,18 @@ export type PreviewSpec = {
|
|
|
1242
1415
|
* Whether the preview is public
|
|
1243
1416
|
*/
|
|
1244
1417
|
public?: boolean;
|
|
1418
|
+
/**
|
|
1419
|
+
* Those headers will be set in all requests to your preview. This is especially useful to set the Authorization header.
|
|
1420
|
+
*/
|
|
1421
|
+
requestHeaders?: {
|
|
1422
|
+
[key: string]: string;
|
|
1423
|
+
};
|
|
1424
|
+
/**
|
|
1425
|
+
* Those headers will be set in all responses of your preview. This is especially useful to set the CORS headers.
|
|
1426
|
+
*/
|
|
1427
|
+
responseHeaders?: {
|
|
1428
|
+
[key: string]: string;
|
|
1429
|
+
};
|
|
1245
1430
|
/**
|
|
1246
1431
|
* URL of the preview
|
|
1247
1432
|
*/
|
|
@@ -1640,6 +1825,10 @@ export type Runtime = {
|
|
|
1640
1825
|
* The Docker image for the deployment
|
|
1641
1826
|
*/
|
|
1642
1827
|
image?: string;
|
|
1828
|
+
/**
|
|
1829
|
+
* The maximum number of concurrent task for an execution
|
|
1830
|
+
*/
|
|
1831
|
+
maxConcurrentTasks?: number;
|
|
1643
1832
|
/**
|
|
1644
1833
|
* The maximum number of retries for the deployment
|
|
1645
1834
|
*/
|
|
@@ -3743,37 +3932,6 @@ export type GetTemplateResponses = {
|
|
|
3743
3932
|
200: Template;
|
|
3744
3933
|
};
|
|
3745
3934
|
export type GetTemplateResponse = GetTemplateResponses[keyof GetTemplateResponses];
|
|
3746
|
-
export type GetTemplateContentsData = {
|
|
3747
|
-
body?: never;
|
|
3748
|
-
path: {
|
|
3749
|
-
templateName: string;
|
|
3750
|
-
};
|
|
3751
|
-
query?: never;
|
|
3752
|
-
url: '/templates/{templateName}/contents';
|
|
3753
|
-
};
|
|
3754
|
-
export type GetTemplateContentsResponses = {
|
|
3755
|
-
/**
|
|
3756
|
-
* List of files in the template
|
|
3757
|
-
*/
|
|
3758
|
-
200: Array<string>;
|
|
3759
|
-
};
|
|
3760
|
-
export type GetTemplateContentsResponse = GetTemplateContentsResponses[keyof GetTemplateContentsResponses];
|
|
3761
|
-
export type GetTemplateFileContentsData = {
|
|
3762
|
-
body?: never;
|
|
3763
|
-
path: {
|
|
3764
|
-
templateName: string;
|
|
3765
|
-
fileName: string;
|
|
3766
|
-
};
|
|
3767
|
-
query?: never;
|
|
3768
|
-
url: '/templates/{templateName}/contents/{fileName}';
|
|
3769
|
-
};
|
|
3770
|
-
export type GetTemplateFileContentsResponses = {
|
|
3771
|
-
/**
|
|
3772
|
-
* Content of the file
|
|
3773
|
-
*/
|
|
3774
|
-
200: string;
|
|
3775
|
-
};
|
|
3776
|
-
export type GetTemplateFileContentsResponse = GetTemplateFileContentsResponses[keyof GetTemplateFileContentsResponses];
|
|
3777
3935
|
export type ListWorkspaceUsersData = {
|
|
3778
3936
|
body?: never;
|
|
3779
3937
|
path?: never;
|
package/dist/jobs/index.d.ts
CHANGED
package/dist/jobs/index.js
CHANGED
|
@@ -15,5 +15,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./jobs.js"), exports);
|
|
18
|
-
__exportStar(require("./start.js"), exports);
|
|
19
|
-
__exportStar(require("./types.js"), exports);
|
package/dist/jobs/jobs.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
declare class BlJob {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
get
|
|
7
|
-
get
|
|
8
|
-
|
|
9
|
-
call(url: URL, tasks: Record<string, unknown>[]): Promise<Response>;
|
|
10
|
-
run(tasks: Record<string, unknown>[]): Promise<string>;
|
|
2
|
+
getArguments(): Promise<{
|
|
3
|
+
[key: number]: any;
|
|
4
|
+
}>;
|
|
5
|
+
private parseCommandLineArgs;
|
|
6
|
+
get indexKey(): string;
|
|
7
|
+
get index(): number;
|
|
8
|
+
start(func: (args: any) => Promise<void>): Promise<void>;
|
|
11
9
|
}
|
|
12
|
-
export declare const blJob:
|
|
10
|
+
export declare const blJob: BlJob;
|
|
13
11
|
export {};
|
package/dist/jobs/jobs.js
CHANGED
|
@@ -2,94 +2,54 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.blJob = void 0;
|
|
4
4
|
const env_js_1 = require("../common/env.js");
|
|
5
|
-
const internal_js_1 = require("../common/internal.js");
|
|
6
|
-
const logger_js_1 = require("../common/logger.js");
|
|
7
|
-
const settings_js_1 = require("../common/settings.js");
|
|
8
|
-
const telemetry_js_1 = require("../telemetry/telemetry.js");
|
|
9
5
|
class BlJob {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
get fallbackUrl() {
|
|
15
|
-
if (this.externalUrl != this.url) {
|
|
16
|
-
return this.externalUrl;
|
|
6
|
+
async getArguments() {
|
|
7
|
+
if (!env_js_1.env.BL_EXECUTION_DATA_URL) {
|
|
8
|
+
const args = this.parseCommandLineArgs();
|
|
9
|
+
return args;
|
|
17
10
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
11
|
+
const response = await fetch(env_js_1.env.BL_EXECUTION_DATA_URL);
|
|
12
|
+
const data = await response.json();
|
|
13
|
+
return data.tasks[this.index] ?? {};
|
|
14
|
+
}
|
|
15
|
+
parseCommandLineArgs() {
|
|
16
|
+
const args = process.argv.slice(2);
|
|
17
|
+
const result = {};
|
|
18
|
+
for (let i = 0; i < args.length; i++) {
|
|
19
|
+
const arg = args[i];
|
|
20
|
+
if (arg.startsWith('--')) {
|
|
21
|
+
const key = arg.slice(2);
|
|
22
|
+
const value = args[i + 1];
|
|
23
|
+
if (value && !value.startsWith('--')) {
|
|
24
|
+
result[key] = value;
|
|
25
|
+
i++;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
result[key] = 'true';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
31
|
}
|
|
32
|
-
return
|
|
32
|
+
return result;
|
|
33
33
|
}
|
|
34
|
-
get
|
|
35
|
-
|
|
36
|
-
return this.forcedUrl;
|
|
37
|
-
if (settings_js_1.settings.runInternalHostname)
|
|
38
|
-
return this.internalUrl;
|
|
39
|
-
return this.externalUrl;
|
|
34
|
+
get indexKey() {
|
|
35
|
+
return env_js_1.env.BL_TASK_KEY ?? "TASK_INDEX";
|
|
40
36
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
tasks: tasks
|
|
44
|
-
};
|
|
45
|
-
const response = await fetch(url + "/executions", {
|
|
46
|
-
method: "POST",
|
|
47
|
-
headers: {
|
|
48
|
-
...settings_js_1.settings.headers,
|
|
49
|
-
"Content-Type": "application/json",
|
|
50
|
-
},
|
|
51
|
-
body: JSON.stringify(body),
|
|
52
|
-
});
|
|
53
|
-
return response;
|
|
37
|
+
get index() {
|
|
38
|
+
return env_js_1.env[this.indexKey] ? Number(env_js_1.env[this.indexKey]) ?? 0 : 0;
|
|
54
39
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"job.name": this.jobName,
|
|
60
|
-
"span.type": "job.run",
|
|
61
|
-
},
|
|
62
|
-
isRoot: false,
|
|
63
|
-
});
|
|
40
|
+
/*
|
|
41
|
+
Run a job defined in a function, it's run in the current process
|
|
42
|
+
*/
|
|
43
|
+
async start(func) {
|
|
64
44
|
try {
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
catch (err) {
|
|
69
|
-
if (err instanceof Error) {
|
|
70
|
-
if (!this.fallbackUrl) {
|
|
71
|
-
span.setAttribute("job.run.error", err.stack);
|
|
72
|
-
throw err;
|
|
73
|
-
}
|
|
74
|
-
try {
|
|
75
|
-
const response = await this.call(this.fallbackUrl, tasks);
|
|
76
|
-
return await response.text();
|
|
77
|
-
}
|
|
78
|
-
catch (err) {
|
|
79
|
-
if (err instanceof Error) {
|
|
80
|
-
span.setAttribute("job.run.error", err.stack);
|
|
81
|
-
}
|
|
82
|
-
throw err;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
throw err;
|
|
45
|
+
const parsedArgs = await this.getArguments();
|
|
46
|
+
await func(parsedArgs);
|
|
47
|
+
process.exit(0);
|
|
86
48
|
}
|
|
87
|
-
|
|
88
|
-
|
|
49
|
+
catch (error) {
|
|
50
|
+
console.error('Job execution failed:', error);
|
|
51
|
+
process.exit(1);
|
|
89
52
|
}
|
|
90
53
|
}
|
|
91
54
|
}
|
|
92
|
-
|
|
93
|
-
return new BlJob(jobName);
|
|
94
|
-
};
|
|
95
|
-
exports.blJob = blJob;
|
|
55
|
+
exports.blJob = new BlJob();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch';
|
|
2
|
-
import type { DeleteFilesystemByPathData, GetFilesystemByPathData, PutFilesystemByPathData, DeleteNetworkProcessByPidMonitorData, PostNetworkProcessByPidMonitorData, GetNetworkProcessByPidPortsData, GetProcessData, PostProcessData, DeleteProcessByIdentifierData, GetProcessByIdentifierData, DeleteProcessByIdentifierKillData, GetProcessByIdentifierLogsData, GetProcessByIdentifierLogsStreamData, GetWatchFilesystemByPathData } from './types.gen';
|
|
2
|
+
import type { DeleteFilesystemByPathData, GetFilesystemByPathData, PutFilesystemByPathData, DeleteNetworkProcessByPidMonitorData, PostNetworkProcessByPidMonitorData, GetNetworkProcessByPidPortsData, GetProcessData, PostProcessData, DeleteProcessByIdentifierData, GetProcessByIdentifierData, DeleteProcessByIdentifierKillData, GetProcessByIdentifierLogsData, GetProcessByIdentifierLogsStreamData, GetWatchFilesystemByPathData, GetWsProcessByIdentifierLogsStreamData, GetWsWatchFilesystemByPathData } from './types.gen';
|
|
3
3
|
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
|
|
4
4
|
/**
|
|
5
5
|
* You can provide a client instance returned by `createClient()` instead of
|
|
@@ -22,7 +22,7 @@ export declare const deleteFilesystemByPath: <ThrowOnError extends boolean = fal
|
|
|
22
22
|
* Get file or directory information
|
|
23
23
|
* Get content of a file or listing of a directory
|
|
24
24
|
*/
|
|
25
|
-
export declare const getFilesystemByPath: <ThrowOnError extends boolean = false>(options: Options<GetFilesystemByPathData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").
|
|
25
|
+
export declare const getFilesystemByPath: <ThrowOnError extends boolean = false>(options: Options<GetFilesystemByPathData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<import("./types.gen").Directory | import("./types.gen").FileWithContent, import("./types.gen").ErrorResponse, ThrowOnError>;
|
|
26
26
|
/**
|
|
27
27
|
* Create or update file or directory
|
|
28
28
|
* Create or update a file or directory
|
|
@@ -91,3 +91,13 @@ export declare const getProcessByIdentifierLogsStream: <ThrowOnError extends boo
|
|
|
91
91
|
* Streams the path of modified files (one per line) in the given directory. Closes when the client disconnects.
|
|
92
92
|
*/
|
|
93
93
|
export declare const getWatchFilesystemByPath: <ThrowOnError extends boolean = false>(options: Options<GetWatchFilesystemByPathData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<string, import("./types.gen").ErrorResponse, ThrowOnError>;
|
|
94
|
+
/**
|
|
95
|
+
* Stream process logs in real time via WebSocket
|
|
96
|
+
* Streams the stdout and stderr output of a process in real time as JSON messages. Closes when the process exits or the client disconnects.
|
|
97
|
+
*/
|
|
98
|
+
export declare const getWsProcessByIdentifierLogsStream: <ThrowOnError extends boolean = false>(options: Options<GetWsProcessByIdentifierLogsStreamData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<unknown, import("./types.gen").ErrorResponse, ThrowOnError>;
|
|
99
|
+
/**
|
|
100
|
+
* Stream file modification events in a directory via WebSocket
|
|
101
|
+
* Streams JSON events of modified files in the given directory. Closes when the client disconnects.
|
|
102
|
+
*/
|
|
103
|
+
export declare const getWsWatchFilesystemByPath: <ThrowOnError extends boolean = false>(options: Options<GetWsWatchFilesystemByPathData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<unknown, import("./types.gen").ErrorResponse, ThrowOnError>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.getWatchFilesystemByPath = exports.getProcessByIdentifierLogsStream = exports.getProcessByIdentifierLogs = exports.deleteProcessByIdentifierKill = exports.getProcessByIdentifier = exports.deleteProcessByIdentifier = exports.postProcess = exports.getProcess = exports.getNetworkProcessByPidPorts = exports.postNetworkProcessByPidMonitor = exports.deleteNetworkProcessByPidMonitor = exports.putFilesystemByPath = exports.getFilesystemByPath = exports.deleteFilesystemByPath = void 0;
|
|
4
|
+
exports.getWsWatchFilesystemByPath = exports.getWsProcessByIdentifierLogsStream = exports.getWatchFilesystemByPath = exports.getProcessByIdentifierLogsStream = exports.getProcessByIdentifierLogs = exports.deleteProcessByIdentifierKill = exports.getProcessByIdentifier = exports.deleteProcessByIdentifier = exports.postProcess = exports.getProcess = exports.getNetworkProcessByPidPorts = exports.postNetworkProcessByPidMonitor = exports.deleteNetworkProcessByPidMonitor = exports.putFilesystemByPath = exports.getFilesystemByPath = exports.deleteFilesystemByPath = void 0;
|
|
5
5
|
const client_gen_1 = require("./client.gen");
|
|
6
6
|
/**
|
|
7
7
|
* Delete file or directory
|
|
@@ -173,3 +173,25 @@ const getWatchFilesystemByPath = (options) => {
|
|
|
173
173
|
});
|
|
174
174
|
};
|
|
175
175
|
exports.getWatchFilesystemByPath = getWatchFilesystemByPath;
|
|
176
|
+
/**
|
|
177
|
+
* Stream process logs in real time via WebSocket
|
|
178
|
+
* Streams the stdout and stderr output of a process in real time as JSON messages. Closes when the process exits or the client disconnects.
|
|
179
|
+
*/
|
|
180
|
+
const getWsProcessByIdentifierLogsStream = (options) => {
|
|
181
|
+
return (options.client ?? client_gen_1.client).get({
|
|
182
|
+
url: '/ws/process/{identifier}/logs/stream',
|
|
183
|
+
...options
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
exports.getWsProcessByIdentifierLogsStream = getWsProcessByIdentifierLogsStream;
|
|
187
|
+
/**
|
|
188
|
+
* Stream file modification events in a directory via WebSocket
|
|
189
|
+
* Streams JSON events of modified files in the given directory. Closes when the client disconnects.
|
|
190
|
+
*/
|
|
191
|
+
const getWsWatchFilesystemByPath = (options) => {
|
|
192
|
+
return (options.client ?? client_gen_1.client).get({
|
|
193
|
+
url: '/ws/watch/filesystem/{path}',
|
|
194
|
+
...options
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
exports.getWsWatchFilesystemByPath = getWsWatchFilesystemByPath;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
export type Directory = {
|
|
2
|
+
files?: Array<File>;
|
|
3
|
+
path?: string;
|
|
4
|
+
/**
|
|
5
|
+
* @name Subdirectories
|
|
6
|
+
*/
|
|
7
|
+
subdirectories?: Array<Subdirectory>;
|
|
8
|
+
};
|
|
1
9
|
export type ErrorResponse = {
|
|
2
10
|
error?: string;
|
|
3
11
|
};
|
|
@@ -6,9 +14,6 @@ export type File = {
|
|
|
6
14
|
lastModified?: string;
|
|
7
15
|
owner?: string;
|
|
8
16
|
path?: string;
|
|
9
|
-
/**
|
|
10
|
-
* swagger:strfmt string
|
|
11
|
-
*/
|
|
12
17
|
permissions?: string;
|
|
13
18
|
size?: number;
|
|
14
19
|
};
|
|
@@ -23,9 +28,6 @@ export type FileWithContent = {
|
|
|
23
28
|
lastModified?: string;
|
|
24
29
|
owner?: string;
|
|
25
30
|
path?: string;
|
|
26
|
-
/**
|
|
27
|
-
* swagger:strfmt string
|
|
28
|
-
*/
|
|
29
31
|
permissions?: string;
|
|
30
32
|
size?: number;
|
|
31
33
|
};
|
|
@@ -56,17 +58,12 @@ export type ProcessResponse = {
|
|
|
56
58
|
status?: string;
|
|
57
59
|
workingDir?: string;
|
|
58
60
|
};
|
|
59
|
-
export type
|
|
60
|
-
message?: string;
|
|
61
|
+
export type Subdirectory = {
|
|
61
62
|
path?: string;
|
|
62
63
|
};
|
|
63
|
-
export type
|
|
64
|
-
|
|
64
|
+
export type SuccessResponse = {
|
|
65
|
+
message?: string;
|
|
65
66
|
path?: string;
|
|
66
|
-
/**
|
|
67
|
-
* @name Subdirectories
|
|
68
|
-
*/
|
|
69
|
-
subdirectories?: Array<Directory>;
|
|
70
67
|
};
|
|
71
68
|
export type DeleteFilesystemByPathData = {
|
|
72
69
|
body?: never;
|
|
@@ -474,6 +471,50 @@ export type GetWatchFilesystemByPathResponses = {
|
|
|
474
471
|
200: string;
|
|
475
472
|
};
|
|
476
473
|
export type GetWatchFilesystemByPathResponse = GetWatchFilesystemByPathResponses[keyof GetWatchFilesystemByPathResponses];
|
|
474
|
+
export type GetWsProcessByIdentifierLogsStreamData = {
|
|
475
|
+
body?: never;
|
|
476
|
+
path: {
|
|
477
|
+
/**
|
|
478
|
+
* Process identifier (PID or name)
|
|
479
|
+
*/
|
|
480
|
+
identifier: string;
|
|
481
|
+
};
|
|
482
|
+
query?: never;
|
|
483
|
+
url: '/ws/process/{identifier}/logs/stream';
|
|
484
|
+
};
|
|
485
|
+
export type GetWsProcessByIdentifierLogsStreamErrors = {
|
|
486
|
+
/**
|
|
487
|
+
* Process not found
|
|
488
|
+
*/
|
|
489
|
+
404: ErrorResponse;
|
|
490
|
+
/**
|
|
491
|
+
* Internal server error
|
|
492
|
+
*/
|
|
493
|
+
500: ErrorResponse;
|
|
494
|
+
};
|
|
495
|
+
export type GetWsProcessByIdentifierLogsStreamError = GetWsProcessByIdentifierLogsStreamErrors[keyof GetWsProcessByIdentifierLogsStreamErrors];
|
|
496
|
+
export type GetWsWatchFilesystemByPathData = {
|
|
497
|
+
body?: never;
|
|
498
|
+
path: {
|
|
499
|
+
/**
|
|
500
|
+
* Directory path to watch
|
|
501
|
+
*/
|
|
502
|
+
path: string;
|
|
503
|
+
};
|
|
504
|
+
query?: never;
|
|
505
|
+
url: '/ws/watch/filesystem/{path}';
|
|
506
|
+
};
|
|
507
|
+
export type GetWsWatchFilesystemByPathErrors = {
|
|
508
|
+
/**
|
|
509
|
+
* Invalid path
|
|
510
|
+
*/
|
|
511
|
+
400: ErrorResponse;
|
|
512
|
+
/**
|
|
513
|
+
* Internal server error
|
|
514
|
+
*/
|
|
515
|
+
500: ErrorResponse;
|
|
516
|
+
};
|
|
517
|
+
export type GetWsWatchFilesystemByPathError = GetWsWatchFilesystemByPathErrors[keyof GetWsWatchFilesystemByPathErrors];
|
|
477
518
|
export type ClientOptions = {
|
|
478
519
|
baseUrl: `${string}://localhost:8080` | (string & {});
|
|
479
520
|
};
|
package/dist/sandbox/session.js
CHANGED
package/dist/sandbox/types.d.ts
CHANGED
|
@@ -32,8 +32,6 @@ export interface BlaxelSpan {
|
|
|
32
32
|
export interface BlaxelTelemetryProvider {
|
|
33
33
|
/** Create a new span */
|
|
34
34
|
startSpan(name: string, options?: BlaxelSpanOptions): BlaxelSpan;
|
|
35
|
-
/** Flush the telemetry provider */
|
|
36
|
-
flush(): Promise<void>;
|
|
37
35
|
}
|
|
38
36
|
/**
|
|
39
37
|
* Registry for managing the global telemetry provider
|
|
@@ -57,6 +55,5 @@ export declare const telemetryRegistry: TelemetryRegistry;
|
|
|
57
55
|
* Create a span with the registered provider
|
|
58
56
|
*/
|
|
59
57
|
export declare function startSpan(name: string, options?: BlaxelSpanOptions): BlaxelSpan;
|
|
60
|
-
export declare function withSpan<T>(name: string, fn: () =>
|
|
61
|
-
export declare function flush(): Promise<void>;
|
|
58
|
+
export declare function withSpan<T>(name: string, fn: () => T, options?: BlaxelSpanOptions): T;
|
|
62
59
|
export {};
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.telemetryRegistry = void 0;
|
|
5
5
|
exports.startSpan = startSpan;
|
|
6
6
|
exports.withSpan = withSpan;
|
|
7
|
-
exports.flush = flush;
|
|
8
7
|
/**
|
|
9
8
|
* No-operation implementation of Span
|
|
10
9
|
*/
|
|
@@ -23,9 +22,6 @@ class NoopTelemetryProvider {
|
|
|
23
22
|
startSpan() {
|
|
24
23
|
return new NoopSpan();
|
|
25
24
|
}
|
|
26
|
-
flush() {
|
|
27
|
-
return Promise.resolve();
|
|
28
|
-
}
|
|
29
25
|
}
|
|
30
26
|
/**
|
|
31
27
|
* Registry for managing the global telemetry provider
|
|
@@ -62,10 +58,10 @@ exports.telemetryRegistry = TelemetryRegistry.getInstance();
|
|
|
62
58
|
function startSpan(name, options) {
|
|
63
59
|
return exports.telemetryRegistry.getProvider().startSpan(name, options);
|
|
64
60
|
}
|
|
65
|
-
|
|
61
|
+
function withSpan(name, fn, options) {
|
|
66
62
|
const span = startSpan(name, options);
|
|
67
63
|
try {
|
|
68
|
-
const result =
|
|
64
|
+
const result = fn();
|
|
69
65
|
span.end();
|
|
70
66
|
return result;
|
|
71
67
|
}
|
|
@@ -75,6 +71,3 @@ async function withSpan(name, fn, options) {
|
|
|
75
71
|
throw error;
|
|
76
72
|
}
|
|
77
73
|
}
|
|
78
|
-
async function flush() {
|
|
79
|
-
await exports.telemetryRegistry.getProvider().flush();
|
|
80
|
-
}
|
package/package.json
CHANGED
package/dist/jobs/start.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const blStartJob: (func: (args: any) => Promise<void>) => void;
|
package/dist/jobs/start.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.blStartJob = void 0;
|
|
4
|
-
const autoload_js_1 = require("../common/autoload.js");
|
|
5
|
-
const env_js_1 = require("../common/env.js");
|
|
6
|
-
const telemetry_js_1 = require("../telemetry/telemetry.js");
|
|
7
|
-
class BlJobWrapper {
|
|
8
|
-
async getArguments() {
|
|
9
|
-
if (!env_js_1.env.BL_EXECUTION_DATA_URL) {
|
|
10
|
-
const args = this.parseCommandLineArgs();
|
|
11
|
-
return args;
|
|
12
|
-
}
|
|
13
|
-
const response = await fetch(env_js_1.env.BL_EXECUTION_DATA_URL);
|
|
14
|
-
const data = await response.json();
|
|
15
|
-
return data.tasks[this.index] ?? {};
|
|
16
|
-
}
|
|
17
|
-
parseCommandLineArgs() {
|
|
18
|
-
const args = process.argv.slice(2);
|
|
19
|
-
const result = {};
|
|
20
|
-
for (let i = 0; i < args.length; i++) {
|
|
21
|
-
const arg = args[i];
|
|
22
|
-
if (arg.startsWith('--')) {
|
|
23
|
-
const key = arg.slice(2);
|
|
24
|
-
const value = args[i + 1];
|
|
25
|
-
if (value && !value.startsWith('--')) {
|
|
26
|
-
result[key] = value;
|
|
27
|
-
i++;
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
result[key] = 'true';
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return result;
|
|
35
|
-
}
|
|
36
|
-
get indexKey() {
|
|
37
|
-
return env_js_1.env.BL_TASK_KEY ?? "TASK_INDEX";
|
|
38
|
-
}
|
|
39
|
-
get index() {
|
|
40
|
-
return env_js_1.env[this.indexKey] ? Number(env_js_1.env[this.indexKey]) ?? 0 : 0;
|
|
41
|
-
}
|
|
42
|
-
/*
|
|
43
|
-
Run a job defined in a function, it's run in the current process
|
|
44
|
-
*/
|
|
45
|
-
async start(func) {
|
|
46
|
-
await (0, autoload_js_1.authenticate)();
|
|
47
|
-
let span = (0, telemetry_js_1.startSpan)(`blStartJob-${func.name}`, {
|
|
48
|
-
attributes: {
|
|
49
|
-
'job.name': func.name,
|
|
50
|
-
'job.index': this.index,
|
|
51
|
-
'job.args': JSON.stringify(this.getArguments()),
|
|
52
|
-
},
|
|
53
|
-
isRoot: true,
|
|
54
|
-
});
|
|
55
|
-
try {
|
|
56
|
-
const parsedArgs = await this.getArguments();
|
|
57
|
-
await func(parsedArgs);
|
|
58
|
-
span.setStatus('ok');
|
|
59
|
-
span.end();
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
span.recordException(error);
|
|
63
|
-
span.setStatus('error', 'Job execution failed');
|
|
64
|
-
span.end();
|
|
65
|
-
throw error;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
const blStartJob = (func) => {
|
|
70
|
-
const job = new BlJobWrapper();
|
|
71
|
-
job.start(func).then(async () => {
|
|
72
|
-
try {
|
|
73
|
-
await (0, telemetry_js_1.flush)();
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
console.error('Error flushing telemetry:', error);
|
|
77
|
-
}
|
|
78
|
-
}).catch((error) => {
|
|
79
|
-
console.error('Job execution failed:', error);
|
|
80
|
-
process.exit(1);
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
exports.blStartJob = blStartJob;
|
package/dist/jobs/types.d.ts
DELETED
package/dist/jobs/types.js
DELETED