Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const CommandIds = {
CreateComponentDependency: "wso2.wso2-platform.component.create.dependency",
ViewDependency: "wso2.wso2-platform.component.view.dependency",
OpenCompSrcDir: "wso2.wso2-platform.open.component.src",
CommitAndPushToGit: "wso2.wso2-platform.push-to-git",
// TODO: add command & code lens to delete dependency
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ import type {
DeploymentLogsData,
DeploymentTrack,
Environment,
GitRepoMetadata,
GithubOrganization,
MarketplaceItem,
Pagination,
Project,
ProjectBuildLogsData,
ProxyDeploymentInfo,
SubscriptionItem,
} from "./common.types";
import type { InboundConfig } from "./config-file.types";

Expand All @@ -53,6 +56,11 @@ export interface GetCredentialsReq {
orgId: string;
orgUuid: string;
}
export interface GetCredentialDetailsReq {
orgId: string;
orgUuid: string;
credentialId: string;
}
export interface IsRepoAuthorizedReq {
orgId: string;
repoUrl: string;
Expand Down Expand Up @@ -385,6 +393,10 @@ export interface GetBuildLogsReq {
displayType: string;
projectId: string;
buildId: number;
orgUuid: string;
buildRef: string;
deploymentTrackId: string;
clusterId: string;
}

export interface GetBuildLogsForTypeReq {
Expand All @@ -394,6 +406,76 @@ export interface GetBuildLogsForTypeReq {
buildId: number;
}

export interface GetSubscriptionsReq {
orgId: string;
cloudType?: string;
}

export interface UpdateCodeServerReq {
orgId: string;
orgUuid: string;
orgHandle: string;
projectId: string;
componentId: string;
sourceCommitHash: string;
}

export interface GetGitTokenForRepositoryReq {
orgId: string;
gitOrg: string;
gitRepo: string;
secretRef: string;
}

export interface GetGitTokenForRepositoryResp {
token: string;
gitOrganization: string;
gitRepository: string;
vendor: string;
username: string;
serverUrl: string;
}

export interface GetGitMetadataReq {
orgId: string;
gitOrgName: string;
gitRepoName: string;
branch: string;
relativePath: string;
secretRef: string;
}

export interface GetGitMetadataResp {
metadata: GitRepoMetadata;
}

export interface SubscriptionsResp {
count: number;
list: SubscriptionItem[];
cloudType: string;
emailType: string;
}

export interface GetAuthorizedGitOrgsReq {
orgId: string;
credRef: string;
}

export interface GetAuthorizedGitOrgsResp {
gitOrgs: GithubOrganization[];
}

export interface GetCliRpcResp {
billingConsoleUrl: string;
choreoConsoleUrl: string;
devantConsoleUrl: string;
ghApp: {
installUrl: string;
authUrl: string;
clientId: string;
};
}

export interface IChoreoRPCClient {
getComponentItem(params: GetComponentItemReq): Promise<ComponentKind>;
getDeploymentTracks(params: GetDeploymentTracksReq): Promise<DeploymentTrack[]>;
Expand All @@ -405,7 +487,9 @@ export interface IChoreoRPCClient {
getBuildPacks(params: BuildPackReq): Promise<Buildpack[]>;
getRepoBranches(params: GetBranchesReq): Promise<string[]>;
isRepoAuthorized(params: IsRepoAuthorizedReq): Promise<IsRepoAuthorizedResp>;
getAuthorizedGitOrgs(params: GetAuthorizedGitOrgsReq): Promise<GetAuthorizedGitOrgsResp>;
getCredentials(params: GetCredentialsReq): Promise<CredentialItem[]>;
getCredentialDetails(params: GetCredentialDetailsReq): Promise<CredentialItem>;
deleteComponent(params: DeleteCompReq): Promise<void>;
getBuilds(params: GetBuildsReq): Promise<BuildKind[]>;
createBuild(params: CreateBuildReq): Promise<BuildKind>;
Expand Down Expand Up @@ -433,6 +517,9 @@ export interface IChoreoRPCClient {
cancelApprovalRequest(params: CancelApprovalReq): Promise<void>;
requestPromoteApproval(params: RequestPromoteApprovalReq): Promise<void>;
promoteProxyDeployment(params: PromoteProxyDeploymentReq): Promise<void>;
getSubscriptions(params: GetSubscriptionsReq): Promise<SubscriptionsResp>;
getGitTokenForRepository(params: GetGitTokenForRepositoryReq): Promise<GetGitTokenForRepositoryResp>;
getGitRepoMetadata(params: GetGitMetadataReq): Promise<GetGitMetadataResp>;
}

export class ChoreoRpcWebview implements IChoreoRPCClient {
Expand Down Expand Up @@ -462,9 +549,15 @@ export class ChoreoRpcWebview implements IChoreoRPCClient {
isRepoAuthorized(params: IsRepoAuthorizedReq): Promise<IsRepoAuthorizedResp> {
return this._messenger.sendRequest(ChoreoRpcIsRepoAuthorizedRequest, HOST_EXTENSION, params);
}
getAuthorizedGitOrgs(params: GetAuthorizedGitOrgsReq): Promise<GetAuthorizedGitOrgsResp> {
return this._messenger.sendRequest(ChoreoRpcGetAuthorizedGitOrgsRequest, HOST_EXTENSION, params);
}
getCredentials(params: GetCredentialsReq): Promise<CredentialItem[]> {
return this._messenger.sendRequest(ChoreoRpcGetCredentialsRequest, HOST_EXTENSION, params);
}
getCredentialDetails(params: GetCredentialDetailsReq): Promise<CredentialItem> {
return this._messenger.sendRequest(ChoreoRpcGetCredentialDetailsRequest, HOST_EXTENSION, params);
}
deleteComponent(params: DeleteCompReq): Promise<void> {
return this._messenger.sendRequest(ChoreoRpcDeleteComponentRequest, HOST_EXTENSION, params);
}
Expand Down Expand Up @@ -549,6 +642,15 @@ export class ChoreoRpcWebview implements IChoreoRPCClient {
promoteProxyDeployment(params: PromoteProxyDeploymentReq): Promise<void> {
return this._messenger.sendRequest(ChoreoRpcPromoteProxyDeployment, HOST_EXTENSION, params);
}
getSubscriptions(params: GetSubscriptionsReq): Promise<SubscriptionsResp> {
return this._messenger.sendRequest(ChoreoRpcGetSubscriptions, HOST_EXTENSION, params);
}
getGitTokenForRepository(params: GetGitTokenForRepositoryReq): Promise<GetGitTokenForRepositoryResp> {
return this._messenger.sendRequest(ChoreoRpcGetGitTokenForRepository, HOST_EXTENSION, params);
}
getGitRepoMetadata(params: GetGitMetadataReq): Promise<GetGitMetadataResp> {
return this._messenger.sendRequest(ChoreoRpcGetGitRepoMetadata, HOST_EXTENSION, params);
}
}

export const ChoreoRpcGetProjectsRequest: RequestType<string, Project[]> = { method: "rpc/project/getProjects" };
Expand All @@ -559,7 +661,11 @@ export const ChoreoRpcCreateComponentRequest: RequestType<CreateComponentReq, Co
export const ChoreoRpcGetBuildPacksRequest: RequestType<BuildPackReq, Buildpack[]> = { method: "rpc/component/getBuildPacks" };
export const ChoreoRpcGetBranchesRequest: RequestType<GetBranchesReq, string[]> = { method: "rpc/repo/getBranches" };
export const ChoreoRpcIsRepoAuthorizedRequest: RequestType<IsRepoAuthorizedReq, IsRepoAuthorizedResp> = { method: "rpc/repo/isRepoAuthorized" };
export const ChoreoRpcGetAuthorizedGitOrgsRequest: RequestType<GetAuthorizedGitOrgsReq, GetAuthorizedGitOrgsResp> = {
method: "rpc/repo/getAuthorizedGitOrgs",
};
export const ChoreoRpcGetCredentialsRequest: RequestType<GetCredentialsReq, CredentialItem[]> = { method: "rpc/repo/getCredentials" };
export const ChoreoRpcGetCredentialDetailsRequest: RequestType<GetCredentialDetailsReq, CredentialItem> = { method: "rpc/repo/getCredentialDetails" };
export const ChoreoRpcDeleteComponentRequest: RequestType<DeleteCompReq, void> = { method: "rpc/component/delete" };
export const ChoreoRpcCreateBuildRequest: RequestType<CreateBuildReq, BuildKind> = { method: "rpc/build/create" };
export const ChoreoRpcGetDeploymentTracksRequest: RequestType<GetDeploymentTracksReq, DeploymentTrack[]> = {
Expand Down Expand Up @@ -612,3 +718,12 @@ export const ChoreoRpcRequestPromoteApproval: RequestType<RequestPromoteApproval
export const ChoreoRpcPromoteProxyDeployment: RequestType<PromoteProxyDeploymentReq, void> = {
method: "rpc/deployment/promoteProxy",
};
export const ChoreoRpcGetSubscriptions: RequestType<GetSubscriptionsReq, SubscriptionsResp> = {
method: "rpc/auth/getSubscriptions",
};
export const ChoreoRpcGetGitTokenForRepository: RequestType<GetGitTokenForRepositoryReq, GetGitTokenForRepositoryResp> = {
method: "rpc/repo/gitTokenForRepository",
};
export const ChoreoRpcGetGitRepoMetadata: RequestType<GetGitMetadataReq, GetGitMetadataResp> = {
method: "rpc/repo/getRepoMetadata",
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export interface ICloneProjectCmdParams extends ICmdParamsBase {
integrationDisplayType: string;
}

export interface ICommitAndPuhCmdParams extends ICmdParamsBase {
componentPath: string;
}

export interface ICreateDependencyParams extends ICmdParamsBase {
componentFsPath?: string;
isCodeLens?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface IWso2PlatformExtensionAPI {
getWebviewStateStore(): WebviewState;
getContextStateStore(): ContextStoreState;
openClonedDir(params: openClonedDirReq): Promise<void>;
getStsToken(): Promise<string>;
}

export interface openClonedDirReq {
Expand Down Expand Up @@ -67,6 +68,7 @@ export interface ComponentKindSource {
bitbucket?: ComponentKindGitProviderSource;
github?: ComponentKindGitProviderSource;
gitlab?: ComponentKindGitProviderSource;
secretRef?: string;
}

export interface ComponentKindBuildDocker {
Expand Down Expand Up @@ -172,6 +174,8 @@ export interface BuildKind {
completedAt: string;
images: { id: string; createdAt: string; updatedAt: string }[];
gitCommit: { message: string; author: string; date: string; email: string };
clusterId: string;
buildRef: string;
};
}

Expand Down Expand Up @@ -548,4 +552,45 @@ export interface CredentialItem {
organizationUuid: string;
type: string;
referenceToken: string;
serverUrl: string;
}

export interface SubscriptionItem {
subscriptionId: string;
tierId: string;
supportPlanId: string;
cloudType: string;
subscriptionType: string;
subscriptionBillingProvider: string;
subscriptionBillingProviderStatus: string;
}

export interface GithubRepository {
name: string;
}

export interface GithubOrganization {
orgName: string;
orgHandler: string;
repositories: GithubRepository[];
}

export interface GitRepoMetadata {
isBareRepo: boolean;
isSubPathEmpty: boolean;
isSubPathValid: boolean;
isValidRepo: boolean;
hasBallerinaTomlInPath: boolean;
hasBallerinaTomlInRoot: boolean;
isDockerfilePathValid: boolean;
hasDockerfileInPath: boolean;
isDockerContextPathValid: boolean;
isOpenApiFilePathValid: boolean;
hasOpenApiFileInPath: boolean;
hasPomXmlInPath: boolean;
hasPomXmlInRoot: boolean;
isBuildpackPathValid: boolean;
isTestRunnerPathValid: boolean;
isProcfileExists: boolean;
isEndpointYamlExists: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export const CreateLocalEndpointsConfig: RequestType<CreateLocalEndpointsConfigR
export const CreateLocalProxyConfig: RequestType<CreateLocalProxyConfigReq, void> = { method: "createLocalProxyConfig" };
export const CreateLocalConnectionsConfig: RequestType<CreateLocalConnectionsConfigReq, void> = { method: "createLocalConnectionsConfig" };
export const DeleteLocalConnectionsConfig: RequestType<DeleteLocalConnectionsConfigReq, void> = { method: "deleteLocalConnectionsConfig" };
export const CloneRepositoryIntoCompDir: RequestType<CloneRepositoryIntoCompDirReq, string> = { method: "cloneRepositoryIntoCompDir" };
export const PushEverythingToRemoteRepo: RequestType<PushEverythingToRemoteRepoReq, void> = { method: "pushEverythingToRemoteRepo" };

const NotificationMethods = {
onAuthStateChanged: "onAuthStateChanged",
Expand Down Expand Up @@ -103,6 +105,28 @@ export interface OpenTestViewReq {
endpoints: ComponentEP[];
}

export interface PushEverythingToRemoteRepoReq {
dirPath: string;
componentName: string;
}

export interface CloneRepositoryIntoCompDirReq {
cwd: string;
subpath: string;
org: Organization;
componentName: string;
repo: {
provider: string;
orgName: string;
orgHandler: string;
repo: string;
serverUrl?: string;
branch: string;
secretRef: string;
isBareRepo: boolean;
};
}

export interface SubmitComponentCreateReq {
org: Organization;
project: Project;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type { CommitHistory, ComponentKind, Environment, ExtensionName, Organiza

export interface DataCacheState {
orgs?: {
[orgHandle: string]: {
[orgRegionHandle: string]: {
projects?: {
[projectHandle: string]: {
data?: Project;
Expand All @@ -41,6 +41,7 @@ export interface DataCacheState {

export interface AuthState {
userInfo: UserInfo | null;
region: "US" | "EU";
}

export interface WebviewState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface NewComponentWebviewProps {
existingComponents: ComponentKind[];
initialValues?: { type?: string; subType?: string; buildPackLang?: string; name?: string };
extensionName?: string;
isNewCodeServerComp?: boolean;
}

export interface ComponentsDetailsWebviewProps {
Expand All @@ -39,6 +40,7 @@ export interface ComponentsDetailsWebviewProps {
component: ComponentKind;
directoryFsPath?: string;
initialEnvs: Environment[];
isNewComponent?: boolean;
}

export interface ComponentsListActivityViewProps {
Expand Down
17 changes: 17 additions & 0 deletions workspaces/wso2-platform/wso2-platform-core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,23 @@ export const parseGitURL = (url?: string): null | [string, string, string] => {
return [org, repoName, provider];
};

export const buildGitURL = (org: string, repoName: string, provider: string, withDotGitSuffix?: boolean, serverUrl?: string): string | null => {
switch (provider) {
case GitProvider.GITHUB:
return `https://github.com/${org}/${repoName}${withDotGitSuffix ? ".git" : ""}`;
case GitProvider.BITBUCKET:
return serverUrl
? `${serverUrl}/${org}/${repoName}${withDotGitSuffix ? ".git" : ""}`
: `https://bitbucket.org/${org}/${repoName}${withDotGitSuffix ? ".git" : ""}`;
case GitProvider.GITLAB_SERVER:
return serverUrl
? `${serverUrl}/${org}/${repoName}${withDotGitSuffix ? ".git" : ""}`
: `https://gitlab.com/${org}/${repoName}${withDotGitSuffix ? ".git" : ""}`;
default:
return null;
}
};

export const getComponentKindRepoSource = (source: ComponentKindSource) => {
return {
repo: source?.github?.repository || source?.bitbucket?.repository || source?.gitlab?.repository || "",
Expand Down
Loading
Loading