@salesforce/plugin-devops-center 1.2.27 → 1.3.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.
- package/LICENSE.txt +200 -6
- package/README.md +515 -19
- package/bin/dev.js +15 -0
- package/bin/run.js +5 -0
- package/lib/commands/devops/pipeline/activate.d.ts +14 -0
- package/lib/commands/devops/pipeline/activate.js +82 -0
- package/lib/commands/devops/pipeline/activate.js.map +1 -0
- package/lib/commands/devops/pipeline/attach-project.d.ts +15 -0
- package/lib/commands/devops/pipeline/attach-project.js +82 -0
- package/lib/commands/devops/pipeline/attach-project.js.map +1 -0
- package/lib/commands/devops/pipeline/create.d.ts +23 -0
- package/lib/commands/devops/pipeline/create.js +136 -0
- package/lib/commands/devops/pipeline/create.js.map +1 -0
- package/lib/commands/devops/pipeline/stage/add.d.ts +16 -0
- package/lib/commands/devops/pipeline/stage/add.js +94 -0
- package/lib/commands/devops/pipeline/stage/add.js.map +1 -0
- package/lib/commands/devops/project/create.d.ts +15 -0
- package/lib/commands/devops/project/create.js +72 -0
- package/lib/commands/devops/project/create.js.map +1 -0
- package/lib/commands/devops/project/list.d.ts +20 -0
- package/lib/commands/devops/project/list.js +59 -0
- package/lib/commands/devops/project/list.js.map +1 -0
- package/lib/commands/devops/pull-request/create.d.ts +17 -0
- package/lib/commands/devops/pull-request/create.js +104 -0
- package/lib/commands/devops/pull-request/create.js.map +1 -0
- package/lib/commands/devops/stage/add-branch.d.ts +17 -0
- package/lib/commands/devops/stage/add-branch.js +110 -0
- package/lib/commands/devops/stage/add-branch.js.map +1 -0
- package/lib/commands/devops/stage/add-environment.d.ts +18 -0
- package/lib/commands/devops/stage/add-environment.js +136 -0
- package/lib/commands/devops/stage/add-environment.js.map +1 -0
- package/lib/commands/devops/work-item/create.d.ts +16 -0
- package/lib/commands/devops/work-item/create.js +76 -0
- package/lib/commands/devops/work-item/create.js.map +1 -0
- package/lib/commands/devops/work-item/list.d.ts +17 -0
- package/lib/commands/devops/work-item/list.js +72 -0
- package/lib/commands/devops/work-item/list.js.map +1 -0
- package/lib/commands/devops/work-item/status/update.d.ts +16 -0
- package/lib/commands/devops/work-item/status/update.js +90 -0
- package/lib/commands/devops/work-item/status/update.js.map +1 -0
- package/lib/commands/project/deploy/pipeline/quick.d.ts +2 -2
- package/lib/commands/project/deploy/pipeline/quick.js +24 -21
- package/lib/commands/project/deploy/pipeline/quick.js.map +1 -1
- package/lib/commands/project/deploy/pipeline/report.d.ts +4 -4
- package/lib/commands/project/deploy/pipeline/report.js +38 -35
- package/lib/commands/project/deploy/pipeline/report.js.map +1 -1
- package/lib/commands/project/deploy/pipeline/resume.d.ts +2 -2
- package/lib/commands/project/deploy/pipeline/resume.js +24 -21
- package/lib/commands/project/deploy/pipeline/resume.js.map +1 -1
- package/lib/commands/project/deploy/pipeline/start.d.ts +3 -3
- package/lib/commands/project/deploy/pipeline/start.js +26 -23
- package/lib/commands/project/deploy/pipeline/start.js.map +1 -1
- package/lib/commands/project/deploy/pipeline/validate.d.ts +3 -3
- package/lib/commands/project/deploy/pipeline/validate.js +24 -21
- package/lib/commands/project/deploy/pipeline/validate.js.map +1 -1
- package/lib/common/base/abstractAsyncOperation.d.ts +3 -3
- package/lib/common/base/abstractAsyncOperation.js +31 -23
- package/lib/common/base/abstractAsyncOperation.js.map +1 -1
- package/lib/common/base/abstractPromote.d.ts +5 -4
- package/lib/common/base/abstractPromote.js +52 -38
- package/lib/common/base/abstractPromote.js.map +1 -1
- package/lib/common/base/abstractQuick.d.ts +4 -3
- package/lib/common/base/abstractQuick.js +44 -43
- package/lib/common/base/abstractQuick.js.map +1 -1
- package/lib/common/base/abstractReportOnPromote.d.ts +2 -1
- package/lib/common/base/abstractReportOnPromote.js +31 -24
- package/lib/common/base/abstractReportOnPromote.js.map +1 -1
- package/lib/common/base/abstractResume.d.ts +3 -2
- package/lib/common/base/abstractResume.js +40 -33
- package/lib/common/base/abstractResume.js.map +1 -1
- package/lib/common/constants.js +19 -13
- package/lib/common/constants.js.map +1 -1
- package/lib/common/deployPipelineCache.js +20 -15
- package/lib/common/deployPipelineCache.js.map +1 -1
- package/lib/common/flags/flags.d.ts +2 -2
- package/lib/common/flags/flags.js +34 -29
- package/lib/common/flags/flags.js.map +1 -1
- package/lib/common/flags/promote/promoteFlags.d.ts +3 -3
- package/lib/common/flags/promote/promoteFlags.js +26 -20
- package/lib/common/flags/promote/promoteFlags.js.map +1 -1
- package/lib/common/index.d.ts +3 -2
- package/lib/common/index.js +2 -17
- package/lib/common/index.js.map +1 -1
- package/lib/common/outputColumns.d.ts +3 -13
- package/lib/common/outputColumns.js +23 -19
- package/lib/common/outputColumns.js.map +1 -1
- package/lib/common/outputService/aorOutputService.d.ts +4 -4
- package/lib/common/outputService/aorOutputService.js +27 -20
- package/lib/common/outputService/aorOutputService.js.map +1 -1
- package/lib/common/outputService/deployCommandOutputService.d.ts +2 -2
- package/lib/common/outputService/deployCommandOutputService.js +17 -12
- package/lib/common/outputService/deployCommandOutputService.js.map +1 -1
- package/lib/common/outputService/deploySummaryBuilder.d.ts +1 -1
- package/lib/common/outputService/deploySummaryBuilder.js +45 -31
- package/lib/common/outputService/deploySummaryBuilder.js.map +1 -1
- package/lib/common/outputService/deploymentResultOutputService.d.ts +4 -4
- package/lib/common/outputService/deploymentResultOutputService.js +16 -10
- package/lib/common/outputService/deploymentResultOutputService.js.map +1 -1
- package/lib/common/outputService/index.d.ts +8 -6
- package/lib/common/outputService/index.js +5 -19
- package/lib/common/outputService/index.js.map +1 -1
- package/lib/common/outputService/outputService.d.ts +6 -4
- package/lib/common/outputService/outputService.js +20 -14
- package/lib/common/outputService/outputService.js.map +1 -1
- package/lib/common/outputService/outputServiceFactory.d.ts +8 -8
- package/lib/common/outputService/outputServiceFactory.js +21 -16
- package/lib/common/outputService/outputServiceFactory.js.map +1 -1
- package/lib/common/outputService/outputUtils.d.ts +1 -1
- package/lib/common/outputService/outputUtils.js +24 -19
- package/lib/common/outputService/outputUtils.js.map +1 -1
- package/lib/common/outputService/promoteOutputService.d.ts +4 -5
- package/lib/common/outputService/promoteOutputService.js +19 -13
- package/lib/common/outputService/promoteOutputService.js.map +1 -1
- package/lib/common/outputService/reportOutputService.d.ts +5 -6
- package/lib/common/outputService/reportOutputService.js +32 -27
- package/lib/common/outputService/reportOutputService.js.map +1 -1
- package/lib/common/outputService/resumeCommandOutputService.d.ts +3 -3
- package/lib/common/outputService/resumeCommandOutputService.js +19 -13
- package/lib/common/outputService/resumeCommandOutputService.js.map +1 -1
- package/lib/common/outputService/resumeOutputService.d.ts +3 -3
- package/lib/common/outputService/resumeOutputService.js +23 -17
- package/lib/common/outputService/resumeOutputService.js.map +1 -1
- package/lib/common/selectors/asyncOperationResultsSelector.d.ts +1 -1
- package/lib/common/selectors/asyncOperationResultsSelector.js +16 -10
- package/lib/common/selectors/asyncOperationResultsSelector.js.map +1 -1
- package/lib/common/selectors/deployComponentsSelector.d.ts +1 -1
- package/lib/common/selectors/deployComponentsSelector.js +18 -13
- package/lib/common/selectors/deployComponentsSelector.js.map +1 -1
- package/lib/common/selectors/deployProgressSummarySelector.d.ts +2 -2
- package/lib/common/selectors/deployProgressSummarySelector.js +16 -10
- package/lib/common/selectors/deployProgressSummarySelector.js.map +1 -1
- package/lib/common/selectors/deploymentResultsSelector.d.ts +2 -2
- package/lib/common/selectors/deploymentResultsSelector.js +20 -16
- package/lib/common/selectors/deploymentResultsSelector.js.map +1 -1
- package/lib/common/selectors/environmentSelector.d.ts +2 -2
- package/lib/common/selectors/environmentSelector.js +16 -10
- package/lib/common/selectors/environmentSelector.js.map +1 -1
- package/lib/common/selectors/namedCredentialSelector.d.ts +1 -1
- package/lib/common/selectors/namedCredentialSelector.js +16 -10
- package/lib/common/selectors/namedCredentialSelector.js.map +1 -1
- package/lib/common/selectors/pipelineStageSelector.d.ts +1 -1
- package/lib/common/selectors/pipelineStageSelector.js +18 -13
- package/lib/common/selectors/pipelineStageSelector.js.map +1 -1
- package/lib/common/selectors/selectorUtils.d.ts +1 -1
- package/lib/common/selectors/selectorUtils.js +17 -11
- package/lib/common/selectors/selectorUtils.js.map +1 -1
- package/lib/common/selectors/validateDeploySelector.d.ts +1 -1
- package/lib/common/selectors/validateDeploySelector.js +16 -10
- package/lib/common/selectors/validateDeploySelector.js.map +1 -1
- package/lib/common/selectors/workItemSelector.d.ts +2 -2
- package/lib/common/selectors/workItemSelector.js +16 -10
- package/lib/common/selectors/workItemSelector.js.map +1 -1
- package/lib/common/types.d.ts +4 -4
- package/lib/common/types.js +4 -7
- package/lib/common/types.js.map +1 -1
- package/lib/common/utils.d.ts +4 -4
- package/lib/common/utils.js +42 -43
- package/lib/common/utils.js.map +1 -1
- package/lib/configMeta.js +21 -15
- package/lib/configMeta.js.map +1 -1
- package/lib/streamer/doceMonitor.d.ts +3 -2
- package/lib/streamer/doceMonitor.js +14 -6
- package/lib/streamer/doceMonitor.js.map +1 -1
- package/lib/streamer/doceStream.d.ts +1 -1
- package/lib/streamer/doceStream.js +19 -11
- package/lib/streamer/doceStream.js.map +1 -1
- package/lib/streamer/processors/asyncOpStream.d.ts +2 -2
- package/lib/streamer/processors/asyncOpStream.js +22 -15
- package/lib/streamer/processors/asyncOpStream.js.map +1 -1
- package/lib/streamer/sObjectStream.d.ts +1 -1
- package/lib/streamer/sObjectStream.js +9 -10
- package/lib/streamer/sObjectStream.js.map +1 -1
- package/lib/utils/activatePipeline.d.ts +17 -0
- package/lib/utils/activatePipeline.js +35 -0
- package/lib/utils/activatePipeline.js.map +1 -0
- package/lib/utils/addPipelineStage.d.ts +20 -0
- package/lib/utils/addPipelineStage.js +43 -0
- package/lib/utils/addPipelineStage.js.map +1 -0
- package/lib/utils/addStageBranch.d.ts +22 -0
- package/lib/utils/addStageBranch.js +48 -0
- package/lib/utils/addStageBranch.js.map +1 -0
- package/lib/utils/addStageEnvironment.d.ts +92 -0
- package/lib/utils/addStageEnvironment.js +120 -0
- package/lib/utils/addStageEnvironment.js.map +1 -0
- package/lib/utils/attachProject.d.ts +21 -0
- package/lib/utils/attachProject.js +44 -0
- package/lib/utils/attachProject.js.map +1 -0
- package/lib/utils/createPipeline.d.ts +34 -0
- package/lib/utils/createPipeline.js +77 -0
- package/lib/utils/createPipeline.js.map +1 -0
- package/lib/utils/createProject.d.ts +17 -0
- package/lib/utils/createProject.js +39 -0
- package/lib/utils/createProject.js.map +1 -0
- package/lib/utils/createPullRequest.d.ts +49 -0
- package/lib/utils/createPullRequest.js +204 -0
- package/lib/utils/createPullRequest.js.map +1 -0
- package/lib/utils/createWorkItem.d.ts +19 -0
- package/lib/utils/createWorkItem.js +58 -0
- package/lib/utils/createWorkItem.js.map +1 -0
- package/lib/utils/pipelineUtils.d.ts +8 -0
- package/lib/utils/pipelineUtils.js +51 -0
- package/lib/utils/pipelineUtils.js.map +1 -0
- package/lib/utils/types.d.ts +57 -0
- package/lib/utils/types.js +17 -0
- package/lib/utils/types.js.map +1 -0
- package/lib/utils/updateWorkItemStatus.d.ts +34 -0
- package/lib/utils/updateWorkItemStatus.js +71 -0
- package/lib/utils/updateWorkItemStatus.js.map +1 -0
- package/lib/utils/workItems.d.ts +3 -0
- package/lib/utils/workItems.js +181 -0
- package/lib/utils/workItems.js.map +1 -0
- package/messages/commonErrors.md +5 -1
- package/messages/devops.pipeline.activate.md +29 -0
- package/messages/devops.pipeline.attach-project.md +29 -0
- package/messages/devops.pipeline.create.md +81 -0
- package/messages/devops.pipeline.stage.add.md +37 -0
- package/messages/devops.project.create.md +29 -0
- package/messages/devops.project.list.md +17 -0
- package/messages/devops.pull-request.create.md +57 -0
- package/messages/devops.stage.add-branch.md +46 -0
- package/messages/devops.stage.add-environment.md +61 -0
- package/messages/devops.work-item.create.md +29 -0
- package/messages/devops.work-item.list.md +21 -0
- package/messages/devops.work-item.status.update.md +29 -0
- package/npm-shrinkwrap.json +4197 -4471
- package/oclif.lock +3380 -3272
- package/oclif.manifest.json +1056 -11
- package/package.json +53 -23
- package/schemas/devops-pipeline-activate.json +28 -0
- package/schemas/devops-pipeline-attach__project.json +25 -0
- package/schemas/devops-pipeline-create.json +50 -0
- package/schemas/devops-pipeline-stage-add.json +31 -0
- package/schemas/devops-project-create.json +28 -0
- package/schemas/devops-project-list.json +35 -0
- package/schemas/devops-pull__request-create.json +34 -0
- package/schemas/devops-stage-add__branch.json +34 -0
- package/schemas/devops-stage-add__environment.json +47 -0
- package/schemas/devops-work__item-create.json +28 -0
- package/schemas/devops-work__item-list.json +75 -0
- package/schemas/devops-work__item-status-update.json +28 -0
- package/schemas/project-deploy-pipeline-report.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addPipelineStage.js","sourceRoot":"","sources":["../../src/utils/addPipelineStage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA0BH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,MAA8B;IACnE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IAE7D,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,MAAM,CAAC;QACpE,IAAI,EAAE,IAAI;QACV,gBAAgB,EAAE,UAAU;QAC5B,WAAW,EAAE,WAAW;KACzB,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,MAAwC,CAAC;IAE9D,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAC1B,MAAM,QAAQ,GAAG,YAAY,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,eAAe,CAAC;QAC1F,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,QAAQ;SAChB,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,YAAY,CAAC,EAAE;QACxB,IAAI;QACJ,WAAW;QACX,UAAU;KACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Connection } from '@salesforce/core';
|
|
2
|
+
export type AddStageBranchParams = {
|
|
3
|
+
connection: Connection;
|
|
4
|
+
pipelineId: string;
|
|
5
|
+
stageId: string;
|
|
6
|
+
branchName: string;
|
|
7
|
+
createVcsBranch: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type AddStageBranchResult = {
|
|
10
|
+
success: boolean;
|
|
11
|
+
stageId: string;
|
|
12
|
+
branchName?: string;
|
|
13
|
+
branchCreated?: boolean;
|
|
14
|
+
repoBranchId?: string;
|
|
15
|
+
pipelineId?: string;
|
|
16
|
+
error?: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Associates a branch with a pipeline stage via the Connect API.
|
|
20
|
+
* PATCH /services/data/v{version}/connect/devops/pipelines/{pipelineId}/stages/{stageId}
|
|
21
|
+
*/
|
|
22
|
+
export declare function addStageBranch(params: AddStageBranchParams): Promise<AddStageBranchResult>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Associates a branch with a pipeline stage via the Connect API.
|
|
18
|
+
* PATCH /services/data/v{version}/connect/devops/pipelines/{pipelineId}/stages/{stageId}
|
|
19
|
+
*/
|
|
20
|
+
export async function addStageBranch(params) {
|
|
21
|
+
const { connection, pipelineId, stageId, branchName, createVcsBranch } = params;
|
|
22
|
+
const path = `/services/data/v${connection.getApiVersion()}/connect/devops/pipelines/${pipelineId}/stages/${stageId}`;
|
|
23
|
+
const data = await connection.request({
|
|
24
|
+
method: 'PATCH',
|
|
25
|
+
url: path,
|
|
26
|
+
body: JSON.stringify({
|
|
27
|
+
vcsBranch: branchName,
|
|
28
|
+
createVcsBranch: String(createVcsBranch),
|
|
29
|
+
}),
|
|
30
|
+
headers: { 'Content-Type': 'application/json' },
|
|
31
|
+
});
|
|
32
|
+
if (data.status === 'FAILED') {
|
|
33
|
+
return {
|
|
34
|
+
success: false,
|
|
35
|
+
stageId,
|
|
36
|
+
error: data.message ?? 'Failed to associate branch with stage',
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
success: true,
|
|
41
|
+
stageId,
|
|
42
|
+
branchName,
|
|
43
|
+
branchCreated: createVcsBranch,
|
|
44
|
+
repoBranchId: data.repoBranchId,
|
|
45
|
+
pipelineId,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=addStageBranch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addStageBranch.js","sourceRoot":"","sources":["../../src/utils/addStageBranch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA6BH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAA4B;IAC/D,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,MAAM,CAAC;IAEhF,MAAM,IAAI,GAAG,mBAAmB,UAAU,CAAC,aAAa,EAAE,6BAA6B,UAAU,WAAW,OAAO,EAAE,CAAC;IAEtH,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,OAAO,CAA6B;QAChE,MAAM,EAAE,OAAO;QACf,GAAG,EAAE,IAAI;QACT,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,SAAS,EAAE,UAAU;YACrB,eAAe,EAAE,MAAM,CAAC,eAAe,CAAC;SACzC,CAAC;QACF,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;KAChD,CAAC,CAAC;IAEH,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO;YACP,KAAK,EAAE,IAAI,CAAC,OAAO,IAAI,uCAAuC;SAC/D,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO;QACP,UAAU;QACV,aAAa,EAAE,eAAe;QAC9B,YAAY,EAAE,IAAI,CAAC,YAAY;QAC/B,UAAU;KACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Connection } from '@salesforce/core';
|
|
2
|
+
export type OrgType = 'Production' | 'Sandbox';
|
|
3
|
+
export declare const POLL_INTERVAL_MS = 3000;
|
|
4
|
+
export declare const POLL_TIMEOUT_MS: number;
|
|
5
|
+
export type AddStageEnvironmentParams = {
|
|
6
|
+
connection: Connection;
|
|
7
|
+
pipelineId: string;
|
|
8
|
+
stageId: string;
|
|
9
|
+
environmentName: string;
|
|
10
|
+
orgType: OrgType;
|
|
11
|
+
};
|
|
12
|
+
export type AddStageEnvironmentResult = {
|
|
13
|
+
success: boolean;
|
|
14
|
+
stageId: string;
|
|
15
|
+
environmentId?: string;
|
|
16
|
+
environmentName?: string;
|
|
17
|
+
orgType?: OrgType;
|
|
18
|
+
pipelineId?: string;
|
|
19
|
+
redirectUrl?: string;
|
|
20
|
+
namedCredential?: string;
|
|
21
|
+
organizationId?: string;
|
|
22
|
+
error?: string;
|
|
23
|
+
};
|
|
24
|
+
type EnvironmentCreateResponse = {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
redirectUrl: string;
|
|
28
|
+
namedCredential: string;
|
|
29
|
+
externalCredential: string;
|
|
30
|
+
pipelineId?: string;
|
|
31
|
+
};
|
|
32
|
+
export type EnvironmentGetResponse = {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
organizationId?: string;
|
|
36
|
+
orgType?: string;
|
|
37
|
+
namedCredential?: string;
|
|
38
|
+
redirectUrl?: string;
|
|
39
|
+
};
|
|
40
|
+
type EnvironmentValidateResponse = {
|
|
41
|
+
id: string;
|
|
42
|
+
name: string;
|
|
43
|
+
organizationId?: string;
|
|
44
|
+
orgType?: string;
|
|
45
|
+
namedCredential?: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Creates an environment and associates it with a pipeline stage via the Connect API.
|
|
49
|
+
* POST /services/data/v{version}/connect/devops/environment
|
|
50
|
+
*/
|
|
51
|
+
export declare function createEnvironment(connection: Connection, params: {
|
|
52
|
+
pipelineId: string;
|
|
53
|
+
stageId: string;
|
|
54
|
+
environmentName: string;
|
|
55
|
+
orgType: OrgType;
|
|
56
|
+
}): Promise<EnvironmentCreateResponse>;
|
|
57
|
+
/**
|
|
58
|
+
* Fetches the current state of an environment.
|
|
59
|
+
* GET /services/data/v{version}/connect/devops/environment/{environmentId}
|
|
60
|
+
*/
|
|
61
|
+
export declare function getEnvironment(connection: Connection, environmentId: string): Promise<EnvironmentGetResponse>;
|
|
62
|
+
/**
|
|
63
|
+
* Validates an authenticated environment by triggering server-side org extraction.
|
|
64
|
+
* PATCH /services/data/v{version}/connect/devops/environment/{environmentId}
|
|
65
|
+
*/
|
|
66
|
+
export declare function validateEnvironment(connection: Connection, environmentId: string): Promise<EnvironmentValidateResponse>;
|
|
67
|
+
/**
|
|
68
|
+
* Polls until authentication is complete by attempting PATCH validation.
|
|
69
|
+
* The PATCH call triggers server-side org extraction; if the user has
|
|
70
|
+
* completed OAuth, it returns a response with organizationId populated.
|
|
71
|
+
* If auth isn't done yet, the PATCH throws — we catch and retry.
|
|
72
|
+
* Falls back to GET polling as a secondary check.
|
|
73
|
+
* Throws on timeout.
|
|
74
|
+
*/
|
|
75
|
+
export declare function pollForAuthentication(connection: Connection, environmentId: string, timeoutMs?: number, intervalMs?: number): Promise<EnvironmentValidateResponse>;
|
|
76
|
+
/**
|
|
77
|
+
* Full orchestration: create environment -> poll for auth -> validate.
|
|
78
|
+
* Returns the final result including organizationId.
|
|
79
|
+
*
|
|
80
|
+
* The caller is responsible for opening the browser at the returned redirectUrl
|
|
81
|
+
* and displaying progress to the user. Use `onCreated` to receive the redirect URL
|
|
82
|
+
* before polling begins.
|
|
83
|
+
*/
|
|
84
|
+
export declare function addStageEnvironment(params: AddStageEnvironmentParams & {
|
|
85
|
+
onCreated?: (data: {
|
|
86
|
+
environmentId: string;
|
|
87
|
+
redirectUrl: string;
|
|
88
|
+
}) => void;
|
|
89
|
+
pollTimeoutMs?: number;
|
|
90
|
+
pollIntervalMs?: number;
|
|
91
|
+
}): Promise<AddStageEnvironmentResult>;
|
|
92
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
const ORG_TYPE_API_MAP = {
|
|
17
|
+
Production: 'PRODUCTION',
|
|
18
|
+
Sandbox: 'SANDBOX',
|
|
19
|
+
};
|
|
20
|
+
export const POLL_INTERVAL_MS = 3000;
|
|
21
|
+
export const POLL_TIMEOUT_MS = 5 * 60 * 1000;
|
|
22
|
+
/**
|
|
23
|
+
* Creates an environment and associates it with a pipeline stage via the Connect API.
|
|
24
|
+
* POST /services/data/v{version}/connect/devops/environment
|
|
25
|
+
*/
|
|
26
|
+
export async function createEnvironment(connection, params) {
|
|
27
|
+
const path = `/services/data/v${connection.getApiVersion()}/connect/devops/environment`;
|
|
28
|
+
return connection.request({
|
|
29
|
+
method: 'POST',
|
|
30
|
+
url: path,
|
|
31
|
+
body: JSON.stringify({
|
|
32
|
+
envName: params.environmentName,
|
|
33
|
+
orgType: ORG_TYPE_API_MAP[params.orgType],
|
|
34
|
+
pipelineStageId: params.stageId,
|
|
35
|
+
pipelineId: params.pipelineId,
|
|
36
|
+
}),
|
|
37
|
+
headers: { 'Content-Type': 'application/json' },
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Fetches the current state of an environment.
|
|
42
|
+
* GET /services/data/v{version}/connect/devops/environment/{environmentId}
|
|
43
|
+
*/
|
|
44
|
+
export async function getEnvironment(connection, environmentId) {
|
|
45
|
+
const path = `/services/data/v${connection.getApiVersion()}/connect/devops/environment/${environmentId}`;
|
|
46
|
+
return connection.request({ method: 'GET', url: path });
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Validates an authenticated environment by triggering server-side org extraction.
|
|
50
|
+
* PATCH /services/data/v{version}/connect/devops/environment/{environmentId}
|
|
51
|
+
*/
|
|
52
|
+
export async function validateEnvironment(connection, environmentId) {
|
|
53
|
+
const path = `/services/data/v${connection.getApiVersion()}/connect/devops/environment/${environmentId}`;
|
|
54
|
+
return connection.request({
|
|
55
|
+
method: 'PATCH',
|
|
56
|
+
url: path,
|
|
57
|
+
body: JSON.stringify({}),
|
|
58
|
+
headers: { 'Content-Type': 'application/json' },
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function sleep(ms) {
|
|
62
|
+
return new Promise((resolve) => {
|
|
63
|
+
setTimeout(resolve, ms);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Polls until authentication is complete by attempting PATCH validation.
|
|
68
|
+
* The PATCH call triggers server-side org extraction; if the user has
|
|
69
|
+
* completed OAuth, it returns a response with organizationId populated.
|
|
70
|
+
* If auth isn't done yet, the PATCH throws — we catch and retry.
|
|
71
|
+
* Falls back to GET polling as a secondary check.
|
|
72
|
+
* Throws on timeout.
|
|
73
|
+
*/
|
|
74
|
+
// eslint-disable-next-line no-await-in-loop -- polling requires sequential awaits by design
|
|
75
|
+
export async function pollForAuthentication(connection, environmentId, timeoutMs = POLL_TIMEOUT_MS, intervalMs = POLL_INTERVAL_MS) {
|
|
76
|
+
const deadline = Date.now() + timeoutMs;
|
|
77
|
+
while (Date.now() < deadline) {
|
|
78
|
+
try {
|
|
79
|
+
// eslint-disable-next-line no-await-in-loop
|
|
80
|
+
const validated = await validateEnvironment(connection, environmentId);
|
|
81
|
+
if (validated.organizationId) {
|
|
82
|
+
return validated;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
// PATCH failed — auth likely not yet complete, continue polling
|
|
87
|
+
}
|
|
88
|
+
// eslint-disable-next-line no-await-in-loop
|
|
89
|
+
await sleep(intervalMs);
|
|
90
|
+
}
|
|
91
|
+
throw new Error(`Authentication timed out after ${timeoutMs / 1000} seconds. Re-run the command or authenticate manually.`);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Full orchestration: create environment -> poll for auth -> validate.
|
|
95
|
+
* Returns the final result including organizationId.
|
|
96
|
+
*
|
|
97
|
+
* The caller is responsible for opening the browser at the returned redirectUrl
|
|
98
|
+
* and displaying progress to the user. Use `onCreated` to receive the redirect URL
|
|
99
|
+
* before polling begins.
|
|
100
|
+
*/
|
|
101
|
+
export async function addStageEnvironment(params) {
|
|
102
|
+
const { connection, pipelineId, stageId, environmentName, orgType, onCreated, pollTimeoutMs, pollIntervalMs } = params;
|
|
103
|
+
const createData = await createEnvironment(connection, { pipelineId, stageId, environmentName, orgType });
|
|
104
|
+
if (onCreated) {
|
|
105
|
+
onCreated({ environmentId: createData.id, redirectUrl: createData.redirectUrl });
|
|
106
|
+
}
|
|
107
|
+
const validated = await pollForAuthentication(connection, createData.id, pollTimeoutMs, pollIntervalMs);
|
|
108
|
+
return {
|
|
109
|
+
success: true,
|
|
110
|
+
stageId,
|
|
111
|
+
environmentId: createData.id,
|
|
112
|
+
environmentName: createData.name,
|
|
113
|
+
orgType,
|
|
114
|
+
pipelineId,
|
|
115
|
+
redirectUrl: createData.redirectUrl,
|
|
116
|
+
namedCredential: createData.namedCredential ?? validated.namedCredential,
|
|
117
|
+
organizationId: validated.organizationId,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=addStageEnvironment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addStageEnvironment.js","sourceRoot":"","sources":["../../src/utils/addStageEnvironment.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Connection } from '@salesforce/core';
|
|
2
|
+
export type AttachProjectParams = {
|
|
3
|
+
connection: Connection;
|
|
4
|
+
projectId: string;
|
|
5
|
+
pipelineId: string;
|
|
6
|
+
};
|
|
7
|
+
export type AttachProjectResult = {
|
|
8
|
+
success: boolean;
|
|
9
|
+
projectId: string;
|
|
10
|
+
pipelineId: string;
|
|
11
|
+
error?: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Checks if a project is already attached to a pipeline.
|
|
15
|
+
* Returns the existing pipeline ID if found, undefined otherwise.
|
|
16
|
+
*/
|
|
17
|
+
export declare function findExistingAttachment(connection: Connection, projectId: string): Promise<string | undefined>;
|
|
18
|
+
/**
|
|
19
|
+
* Attaches a DevOps Center project to a pipeline by creating a DevopsProjectPipeline junction record.
|
|
20
|
+
*/
|
|
21
|
+
export declare function attachProject(params: AttachProjectParams): Promise<AttachProjectResult>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Checks if a project is already attached to a pipeline.
|
|
18
|
+
* Returns the existing pipeline ID if found, undefined otherwise.
|
|
19
|
+
*/
|
|
20
|
+
export async function findExistingAttachment(connection, projectId) {
|
|
21
|
+
const result = await connection.query(`SELECT DevopsPipelineId FROM DevopsProjectPipeline WHERE DevopsProjectId = '${projectId}' LIMIT 1`);
|
|
22
|
+
return (result.records ?? [])[0]?.DevopsPipelineId;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Attaches a DevOps Center project to a pipeline by creating a DevopsProjectPipeline junction record.
|
|
26
|
+
*/
|
|
27
|
+
export async function attachProject(params) {
|
|
28
|
+
const { connection, projectId, pipelineId } = params;
|
|
29
|
+
const result = await connection.sobject('DevopsProjectPipeline').create({
|
|
30
|
+
DevopsProjectId: projectId,
|
|
31
|
+
DevopsPipelineId: pipelineId,
|
|
32
|
+
});
|
|
33
|
+
if (result.success) {
|
|
34
|
+
return { success: true, projectId, pipelineId };
|
|
35
|
+
}
|
|
36
|
+
const errorMessages = result.errors?.map((e) => (typeof e === 'string' ? e : JSON.stringify(e))).join('; ');
|
|
37
|
+
return {
|
|
38
|
+
success: false,
|
|
39
|
+
projectId,
|
|
40
|
+
pipelineId,
|
|
41
|
+
error: errorMessages ?? 'Unknown error',
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=attachProject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachProject.js","sourceRoot":"","sources":["../../src/utils/attachProject.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAiBH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,UAAsB,EAAE,SAAiB;IACpF,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,KAAK,CACnC,+EAA+E,SAAS,WAAW,CACpG,CAAC;IACF,OAAO,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC;AACrD,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAA2B;IAC7D,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAErD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC,MAAM,CAAC;QACtE,eAAe,EAAE,SAAS;QAC1B,gBAAgB,EAAE,UAAU;KAC7B,CAAC,CAAC;IAEH,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;IAClD,CAAC;IAED,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5G,OAAO;QACL,OAAO,EAAE,KAAK;QACd,SAAS;QACT,UAAU;QACV,KAAK,EAAE,aAAa,IAAI,eAAe;KACxC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Connection } from '@salesforce/core';
|
|
2
|
+
export type RepoInfo = {
|
|
3
|
+
repoUrl: string;
|
|
4
|
+
repoType: string;
|
|
5
|
+
created: boolean;
|
|
6
|
+
};
|
|
7
|
+
export type CreatePipelineParams = {
|
|
8
|
+
connection: Connection;
|
|
9
|
+
name: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
repo: string;
|
|
12
|
+
repoType: string;
|
|
13
|
+
createRepo?: boolean;
|
|
14
|
+
repoOwner?: string;
|
|
15
|
+
bitbucketProject?: string;
|
|
16
|
+
};
|
|
17
|
+
export type CreatePipelineResult = {
|
|
18
|
+
success: boolean;
|
|
19
|
+
pipelineId?: string;
|
|
20
|
+
name?: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
status?: string;
|
|
23
|
+
repository?: RepoInfo;
|
|
24
|
+
error?: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Detects repo type from a URL. Returns 'github' or 'bitbucket', or undefined.
|
|
28
|
+
*/
|
|
29
|
+
export declare function detectRepoType(repoUrl: string): string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new DevOps Center pipeline via the Connect API.
|
|
32
|
+
* POST /services/data/v{version}/connect/devops/pipelines
|
|
33
|
+
*/
|
|
34
|
+
export declare function createPipeline(params: CreatePipelineParams): Promise<CreatePipelineResult>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
const DEFAULT_STAGES = [{ name: 'Integration' }, { name: 'UAT' }, { name: 'Staging' }, { name: 'Production' }];
|
|
17
|
+
/**
|
|
18
|
+
* Detects repo type from a URL. Returns 'github' or 'bitbucket', or undefined.
|
|
19
|
+
*/
|
|
20
|
+
export function detectRepoType(repoUrl) {
|
|
21
|
+
const lower = repoUrl.toLowerCase();
|
|
22
|
+
if (lower.includes('github.com'))
|
|
23
|
+
return 'github';
|
|
24
|
+
if (lower.includes('bitbucket.org'))
|
|
25
|
+
return 'bitbucket';
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new DevOps Center pipeline via the Connect API.
|
|
30
|
+
* POST /services/data/v{version}/connect/devops/pipelines
|
|
31
|
+
*/
|
|
32
|
+
export async function createPipeline(params) {
|
|
33
|
+
const { connection, name, description, repo, repoType, createRepo, repoOwner, bitbucketProject } = params;
|
|
34
|
+
const path = `/services/data/v${connection.getApiVersion()}/connect/devops/pipelines`;
|
|
35
|
+
const payload = {
|
|
36
|
+
name,
|
|
37
|
+
vcsType: repoType,
|
|
38
|
+
stages: DEFAULT_STAGES,
|
|
39
|
+
};
|
|
40
|
+
if (createRepo) {
|
|
41
|
+
payload.createVcsRepo = true;
|
|
42
|
+
payload.vcsRepoName = repo;
|
|
43
|
+
payload.vcsRepoOwner = repoOwner;
|
|
44
|
+
if (repoType === 'bitbucket' && repoOwner) {
|
|
45
|
+
const providerInfo = { bitbucketWorkspace: repoOwner };
|
|
46
|
+
if (bitbucketProject) {
|
|
47
|
+
providerInfo.bitbucketProject = bitbucketProject;
|
|
48
|
+
}
|
|
49
|
+
payload.repoProviderInfo = JSON.stringify(providerInfo);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
payload.vcsRepoUrl = repo;
|
|
54
|
+
}
|
|
55
|
+
if (description) {
|
|
56
|
+
payload.description = description;
|
|
57
|
+
}
|
|
58
|
+
const data = await connection.request({
|
|
59
|
+
method: 'POST',
|
|
60
|
+
url: path,
|
|
61
|
+
body: JSON.stringify(payload),
|
|
62
|
+
headers: { 'Content-Type': 'application/json' },
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
success: true,
|
|
66
|
+
pipelineId: data.id,
|
|
67
|
+
name,
|
|
68
|
+
description,
|
|
69
|
+
status: data.status ?? 'Inactive',
|
|
70
|
+
repository: {
|
|
71
|
+
repoUrl: repo,
|
|
72
|
+
repoType,
|
|
73
|
+
created: createRepo ?? false,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=createPipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPipeline.js","sourceRoot":"","sources":["../../src/utils/createPipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAqCH,MAAM,cAAc,GAAG,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;AAE/G;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IACpC,IAAI,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC;QAAE,OAAO,QAAQ,CAAC;IAClD,IAAI,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC;QAAE,OAAO,WAAW,CAAC;IACxD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAA4B;IAC/D,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAAC;IAE1G,MAAM,IAAI,GAAG,mBAAmB,UAAU,CAAC,aAAa,EAAE,2BAA2B,CAAC;IAEtF,MAAM,OAAO,GAA4B;QACvC,IAAI;QACJ,OAAO,EAAE,QAAQ;QACjB,MAAM,EAAE,cAAc;KACvB,CAAC;IAEF,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;QAC7B,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;QAC3B,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;QAEjC,IAAI,QAAQ,KAAK,WAAW,IAAI,SAAS,EAAE,CAAC;YAC1C,MAAM,YAAY,GAA2B,EAAE,kBAAkB,EAAE,SAAS,EAAE,CAAC;YAC/E,IAAI,gBAAgB,EAAE,CAAC;gBACrB,YAAY,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;YACnD,CAAC;YACD,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAC5B,CAAC;IAED,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,CAAC,WAAW,GAAG,WAAW,CAAC;IACpC,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,OAAO,CAA0B;QAC7D,MAAM,EAAE,MAAM;QACd,GAAG,EAAE,IAAI;QACT,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;QAC7B,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;KAChD,CAAC,CAAC;IAEH,OAAO;QACL,OAAO,EAAE,IAAI;QACb,UAAU,EAAE,IAAI,CAAC,EAAE;QACnB,IAAI;QACJ,WAAW;QACX,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,UAAU;QACjC,UAAU,EAAE;YACV,OAAO,EAAE,IAAI;YACb,QAAQ;YACR,OAAO,EAAE,UAAU,IAAI,KAAK;SAC7B;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Connection } from '@salesforce/core';
|
|
2
|
+
export type CreateProjectParams = {
|
|
3
|
+
connection: Connection;
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
};
|
|
7
|
+
export type CreateProjectResult = {
|
|
8
|
+
success: boolean;
|
|
9
|
+
projectId?: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
error?: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new DevOps Center project via sObject create on DevopsProject.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createProject(params: CreateProjectParams): Promise<CreateProjectResult>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new DevOps Center project via sObject create on DevopsProject.
|
|
18
|
+
*/
|
|
19
|
+
export async function createProject(params) {
|
|
20
|
+
const { connection, name, description } = params;
|
|
21
|
+
const result = await connection.sobject('DevopsProject').create({
|
|
22
|
+
Name: name,
|
|
23
|
+
Description: description || null,
|
|
24
|
+
});
|
|
25
|
+
if (result.success) {
|
|
26
|
+
return {
|
|
27
|
+
success: true,
|
|
28
|
+
projectId: result.id,
|
|
29
|
+
name,
|
|
30
|
+
description: description || undefined,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const errorMessages = result.errors?.map((e) => (typeof e === 'string' ? e : JSON.stringify(e))).join('; ');
|
|
34
|
+
return {
|
|
35
|
+
success: false,
|
|
36
|
+
error: errorMessages ?? 'Unknown error',
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=createProject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createProject.js","sourceRoot":"","sources":["../../src/utils/createProject.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAkBH;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAA2B;IAC7D,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IAEjD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC;QAC9D,IAAI,EAAE,IAAI;QACV,WAAW,EAAE,WAAW,IAAI,IAAI;KACjC,CAAC,CAAC;IAEH,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO;YACL,OAAO,EAAE,IAAI;YACb,SAAS,EAAE,MAAM,CAAC,EAAE;YACpB,IAAI;YACJ,WAAW,EAAE,WAAW,IAAI,SAAS;SACtC,CAAC;IACJ,CAAC;IAED,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5G,OAAO;QACL,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,aAAa,IAAI,eAAe;KACxC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Connection } from '@salesforce/core';
|
|
2
|
+
export type WorkItemDetail = {
|
|
3
|
+
workItemId: string;
|
|
4
|
+
workItemName: string;
|
|
5
|
+
subject: string;
|
|
6
|
+
branchName?: string;
|
|
7
|
+
targetBranch?: string;
|
|
8
|
+
projectId: string;
|
|
9
|
+
repoOwner?: string;
|
|
10
|
+
repoName?: string;
|
|
11
|
+
provider?: string;
|
|
12
|
+
};
|
|
13
|
+
export type CreatePullRequestParams = {
|
|
14
|
+
owner: string;
|
|
15
|
+
repo: string;
|
|
16
|
+
head: string;
|
|
17
|
+
base: string;
|
|
18
|
+
title: string;
|
|
19
|
+
body?: string;
|
|
20
|
+
provider: string;
|
|
21
|
+
token: string;
|
|
22
|
+
};
|
|
23
|
+
export type CreatePullRequestResult = {
|
|
24
|
+
success: boolean;
|
|
25
|
+
workItemName?: string;
|
|
26
|
+
title?: string;
|
|
27
|
+
url?: string;
|
|
28
|
+
sourceBranch?: string;
|
|
29
|
+
targetBranch?: string;
|
|
30
|
+
error?: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Queries a work item (by Name or Id) and resolves all info needed
|
|
34
|
+
* to create a pull request: branch, repo, owner, provider, and target branch.
|
|
35
|
+
*/
|
|
36
|
+
export declare function fetchWorkItemDetail(connection: Connection, filter: {
|
|
37
|
+
name: string;
|
|
38
|
+
} | {
|
|
39
|
+
id: string;
|
|
40
|
+
}): Promise<WorkItemDetail>;
|
|
41
|
+
/**
|
|
42
|
+
* Creates a pull request on GitHub or Bitbucket using their REST APIs.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createPullRequest(params: CreatePullRequestParams): Promise<CreatePullRequestResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Attempts to resolve a VCS authentication token from the environment
|
|
47
|
+
* or the `gh` CLI (for GitHub).
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveGitHubToken(): Promise<string | undefined>;
|