diff --git a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/MapValueImpl.java b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/MapValueImpl.java index 48d6e4cb9461..46a617c46545 100644 --- a/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/MapValueImpl.java +++ b/bvm/ballerina-runtime/src/main/java/io/ballerina/runtime/internal/values/MapValueImpl.java @@ -315,9 +315,8 @@ public void setTypeForcefully(Type type) { protected void populateInitialValues(BMapInitialValueEntry[] initialValues) { Map defaultValues = new HashMap<>(); - Type impliedType = TypeUtils.getImpliedType(type); - if (impliedType.getTag() == TypeTags.RECORD_TYPE_TAG) { - defaultValues.putAll(((BRecordType) impliedType).getDefaultValues()); + if (referredType.getTag() == TypeTags.RECORD_TYPE_TAG) { + defaultValues.putAll(((BRecordType) referredType).getDefaultValues()); } for (BMapInitialValueEntry initialValue : initialValues) { diff --git a/cli/central-client/src/main/java/org/ballerinalang/central/client/CentralAPIClient.java b/cli/central-client/src/main/java/org/ballerinalang/central/client/CentralAPIClient.java index 0e4b688ec97c..f791bd71cee0 100644 --- a/cli/central-client/src/main/java/org/ballerinalang/central/client/CentralAPIClient.java +++ b/cli/central-client/src/main/java/org/ballerinalang/central/client/CentralAPIClient.java @@ -54,6 +54,7 @@ import java.io.IOException; import java.io.PrintStream; import java.net.Proxy; +import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; @@ -140,6 +141,8 @@ public class CentralAPIClient { private static final String ERR_PACKAGE_UN_DEPRECATE = "error: failed to undo deprecation of the package: "; private static final String ERR_PACKAGE_RESOLUTION = "error: while connecting to central: "; private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8"); + private static final MediaType JSON_CONTENT_TYPE = MediaType.parse("application/json"); + // System property name for enabling central verbose public static final String SYS_PROP_CENTRAL_VERBOSE_ENABLED = "CENTRAL_VERBOSE_ENABLED"; private static final int DEFAULT_CONNECT_TIMEOUT = 60; @@ -1346,20 +1349,19 @@ public void deprecatePackage(String packageInfo, String deprecationMsg, String s } /** - * Get packages from central. + * Get packages information using graphql API. * - * @param params Search query param map. - * @param supportedPlatform The supported platform. - * @param ballerinaVersion The ballerina version. - * @return Package list - * @throws CentralClientException Central client exception. + * @param query payload query + * @param supportedPlatform supported platform + * @param ballerinaVersion ballerina version + * @return {@link JsonElement} Json Response */ - public JsonElement getPackages(Map params, String supportedPlatform, String ballerinaVersion) + public JsonElement getCentralPackagesUsingGraphQL(String query, String supportedPlatform, String ballerinaVersion) throws CentralClientException { Optional body = Optional.empty(); OkHttpClient client = new OkHttpClient.Builder() .followRedirects(false) - .connectTimeout(connectTimeout, TimeUnit.SECONDS) + .connectTimeout(callTimeout, TimeUnit.SECONDS) .readTimeout(readTimeout, TimeUnit.SECONDS) .writeTimeout(writeTimeout, TimeUnit.SECONDS) .callTimeout(callTimeout, TimeUnit.SECONDS) @@ -1367,31 +1369,25 @@ public JsonElement getPackages(Map params, String supportedPlatf .build(); try { - HttpUrl.Builder httpBuilder = Objects.requireNonNull(HttpUrl.parse(this.baseUrl)) - .newBuilder().addPathSegment(PACKAGES); - for (Map.Entry param : params.entrySet()) { - httpBuilder.addQueryParameter(param.getKey(), param.getValue()); - } - - Request searchReq = getNewRequest(supportedPlatform, ballerinaVersion) - .get() - .url(httpBuilder.build()) + HttpUrl.Builder httpUrl = Objects.requireNonNull(HttpUrl.parse(this.baseUrl)).newBuilder(); + Request request = getNewRequest(supportedPlatform, ballerinaVersion) + .url(httpUrl.build()) + .post(RequestBody.create(JSON_CONTENT_TYPE, query.getBytes(StandardCharsets.UTF_8))) .build(); - Call httpRequestCall = client.newCall(searchReq); - Response searchResponse = httpRequestCall.execute(); - - ResponseBody responseBody = searchResponse.body(); + Call httpRequest = client.newCall(request); + Response response = httpRequest.execute(); + ResponseBody responseBody = response.body(); body = responseBody != null ? Optional.of(responseBody) : Optional.empty(); if (body.isPresent()) { MediaType contentType = body.get().contentType(); if (contentType != null && isApplicationJsonContentType(contentType.toString()) && - searchResponse.code() == HttpsURLConnection.HTTP_OK) { + response.code() == HttpsURLConnection.HTTP_OK) { return new Gson().toJsonTree(body.get().string()); } } - handleResponseErrors(searchResponse, ERR_CANNOT_SEARCH); - return new JsonArray(); + handleResponseErrors(response, ERR_CANNOT_SEARCH); + return new JsonObject(); } catch (IOException e) { throw new CentralClientException(ERR_CANNOT_SEARCH + "'. Reason: " + e.getMessage()); } finally { diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ManifestBuilder.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ManifestBuilder.java index 6b7ea29c3105..39399a550de6 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ManifestBuilder.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/ManifestBuilder.java @@ -128,7 +128,6 @@ public class ManifestBuilder { private static final String TARGETMODULE = "targetModule"; private static final String OPTIONS = "options"; private static final String TOOL = "tool"; - private static final String DESCRIPTION = "description"; private static final String README = "readme"; @@ -235,16 +234,25 @@ private PackageManifest parseAsPackageManifest() { description = getStringValueFromTomlTableNode(pkgNode, DESCRIPTION, ""); moduleEntries = getModuleEntries(pkgNode, customReadmeVal, packageDescriptor.name()); + if (!exported.isEmpty()) { + reportDiagnostic(pkgNode.entries().get(EXPORT), + "'export' under [package] is deprecated. " + + "Add the exports using the 'export' field under '[[package.modules]]'", + ProjectDiagnosticErrorCode.DEPRECATED_BALLERINA_TOML_ENTRY, DiagnosticSeverity.WARNING); + } if (!isOldStructure) { - if (!exported.isEmpty()) { - reportDiagnostic(pkgNode.entries().get(EXPORT), - "'export' under [package] is deprecated. " + - "Add the exports using the 'export' field under '[[package.modules]]'", - ProjectDiagnosticErrorCode.DEPRECATED_BALLERINA_TOML_ENTRY, DiagnosticSeverity.WARNING); + if (!exported.contains(packageDescriptor.name().toString())) { + exported.add(packageDescriptor.name().toString()); // default module is always exported + } + for (PackageManifest.Module moduleEntry : moduleEntries) { + if (!moduleEntry.export()) { + continue; + } + String name = moduleEntry.name(); + if (!exported.contains(name)) { + exported.add(name); + } } - exported.add(packageDescriptor.name().toString()); // default module is always exported - exported.addAll(moduleEntries.stream().filter( - PackageManifest.Module::export).map(PackageManifest.Module::name).toList()); } } } @@ -346,7 +354,8 @@ private List getModuleEntries( TomlTableArrayNode dependencyTableArray = (TomlTableArrayNode) dependencyEntries; for (TomlTableNode modulesNode : dependencyTableArray.children()) { String moduleName = getStringValueFromTomlTableNode(modulesNode, NAME, null); - if (moduleName == null) { + if (moduleName == null + || !moduleName.contains(DOT)) { // The invalid module name is already handled continue; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/util/RepoUtils.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/util/RepoUtils.java index 856c37f6c42c..10c25b14c997 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/util/RepoUtils.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/util/RepoUtils.java @@ -57,6 +57,9 @@ public final class RepoUtils { private static final String PRODUCTION_URL = "https://api.central.ballerina.io/2.0/registry"; private static final String STAGING_URL = "https://api.staging-central.ballerina.io/2.0/registry"; private static final String DEV_URL = "https://api.dev-central.ballerina.io/2.0/registry"; + private static final String PRODUCTION_GRAPHQL_URL = "https://api.central.ballerina.io/2.0/graphql"; + private static final String STAGING_GRAPHQL_URL = "https://api.staging-central.ballerina.io/2.0/graphql"; + private static final String DEV_GRAPHQL_URL = "https://api.dev-central.ballerina.io/2.0/graphql"; private static final String BALLERINA_ORG = "ballerina"; private static final String BALLERINAX_ORG = "ballerinax"; @@ -158,6 +161,20 @@ public static String getRemoteRepoURL() { return PRODUCTION_URL; } + /** + * Get the graphQL remote repo URL. + * + * @return URL of the remote repository + */ + public static String getRemoteRepoGraphQLURL() { + if (SET_BALLERINA_STAGE_CENTRAL) { + return STAGING_GRAPHQL_URL; + } else if (SET_BALLERINA_DEV_CENTRAL) { + return DEV_GRAPHQL_URL; + } + return PRODUCTION_GRAPHQL_URL; + } + /** * Get the staging URL. * diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/CentralPackageDescriptorLoader.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/CentralPackageDescriptorLoader.java index 4cdb3a22d3df..bb32d525e42a 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/CentralPackageDescriptorLoader.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/CentralPackageDescriptorLoader.java @@ -17,21 +17,15 @@ import com.google.gson.Gson; import com.google.gson.JsonElement; -import io.ballerina.projects.PackageName; -import io.ballerina.projects.PackageOrg; -import io.ballerina.projects.PackageVersion; import io.ballerina.projects.Settings; import io.ballerina.projects.util.ProjectUtils; import org.ballerinalang.central.client.CentralAPIClient; -import org.ballerinalang.central.client.model.Package; import org.ballerinalang.langserver.commons.LanguageServerContext; -import org.ballerinalang.langserver.extensions.ballerina.connector.CentralPackageListResult; import org.wso2.ballerinalang.util.RepoUtils; import java.util.ArrayList; -import java.util.HashMap; +import java.util.Collections; import java.util.List; -import java.util.Map; import java.util.concurrent.CompletableFuture; /** @@ -43,6 +37,8 @@ public class CentralPackageDescriptorLoader { public static final LanguageServerContext.Key CENTRAL_PACKAGE_HOLDER_KEY = new LanguageServerContext.Key<>(); private final List centralPackages = new ArrayList<>(); + private static final String GET_PACKAGES_QUERY = + "{\"query\": \"{packages(orgName:\\\"%s\\\" limit: %s) {packages {name version organization}}}\"}"; private boolean isLoaded = false; private final LSClientLogger clientLogger; @@ -65,12 +61,7 @@ public CompletableFuture> getCentralPackages() if (!isLoaded) { //Load packages from central clientLogger.logTrace("Loading packages from Ballerina Central"); - this.getPackagesFromCentral().forEach(packageInfo -> { - PackageOrg packageOrg = PackageOrg.from(packageInfo.getOrganization()); - PackageName packageName = PackageName.from(packageInfo.getName()); - PackageVersion packageVersion = PackageVersion.from(packageInfo.getVersion()); - centralPackages.add(new LSPackageLoader.ModuleInfo(packageOrg, packageName, packageVersion, null)); - }); + centralPackages.addAll(this.getCentralGraphQLPackages()); clientLogger.logTrace("Successfully loaded packages from Ballerina Central"); } isLoaded = true; @@ -78,90 +69,30 @@ public CompletableFuture> getCentralPackages() }); } - private List getPackagesFromCentral() { - List packageList = new ArrayList<>(); + private List getCentralGraphQLPackages() { try { - for (int page = 0;; page++) { - Settings settings = RepoUtils.readSettings(); - - CentralAPIClient centralAPIClient = new CentralAPIClient(RepoUtils.getRemoteRepoURL(), - ProjectUtils.initializeProxy(settings.getProxy()), ProjectUtils.getAccessTokenOfCLI(settings)); - CentralPackageDescriptor descriptor = new CentralPackageDescriptor("ballerinax", 10, page * 10); - - JsonElement newClientConnectors = centralAPIClient.getPackages(descriptor.getQueryMap(), - "any", RepoUtils.getBallerinaVersion()); - - CentralPackageListResult packageListResult = new Gson().fromJson(newClientConnectors.getAsString(), - CentralPackageListResult.class); - packageList.addAll(packageListResult.getPackages()); - int listResultCount = packageListResult.getCount(); - - if (packageList.size() == listResultCount || descriptor.getOffset() >= listResultCount) { - break; - } - } + Settings settings = RepoUtils.readSettings(); + CentralAPIClient centralAPIClient = new CentralAPIClient(RepoUtils.getRemoteRepoGraphQLURL(), + ProjectUtils.initializeProxy(settings.getProxy()), ProjectUtils.getAccessTokenOfCLI(settings)); + String query = String.format(GET_PACKAGES_QUERY, "ballerinax", 800); + JsonElement allPackagesResponse = centralAPIClient.getCentralPackagesUsingGraphQL(query, "any", + RepoUtils.getBallerinaVersion()); + CentralPackageGraphQLResponse response = new Gson().fromJson(allPackagesResponse.getAsString(), + CentralPackageGraphQLResponse.class); + return response.data.packages.packages; } catch (Exception e) { // ignore } - return packageList; + return Collections.emptyList(); } - /** - * Central package descriptor. - */ - public static class CentralPackageDescriptor { - private String organization; - private int limit; - private int offset; - - public CentralPackageDescriptor(String organization, int limit, int offset) { - this.organization = organization; - this.limit = limit; - this.offset = offset; - } - - public String getOrganization() { - return organization; - } - - public void setOrganization(String organization) { - this.organization = organization; - } - - public int getLimit() { - return limit; - } - - public void setLimit(int limit) { - this.limit = limit; - } - - public int getOffset() { - return offset; - } - - public void setOffset(int offset) { - this.offset = offset; - } - - public Map getQueryMap() { - Map params = new HashMap<>(); - params.put("readme", "false"); - - if (getOrganization() != null) { - params.put("org", getOrganization()); - } - - if (getLimit() != 0) { - params.put("limit", Integer.toString(getLimit())); - } + public record CentralPackageGraphQLResponse(Packages data) { + } - if (getOffset() != 0) { - params.put("offset", Integer.toString(getOffset())); - } + public record Packages(PackageList packages) { + } - return params; - } + public record PackageList(List packages) { } } diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/LSPackageLoader.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/LSPackageLoader.java index 73ef8ab0c2e0..bc0814c9f029 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/LSPackageLoader.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/LSPackageLoader.java @@ -15,6 +15,8 @@ */ package org.ballerinalang.langserver; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; import io.ballerina.compiler.api.ModuleID; import io.ballerina.compiler.api.SemanticModel; import io.ballerina.projects.Module; @@ -263,16 +265,16 @@ public List getAllVisiblePackages(DocumentServiceContext ctx) { packageInstance.packageVersion(), packageInstance.project().sourceRoot()); moduleInfo.setModuleFromCurrentPackage(true); Optional currentModule = ctx.currentModule(); - String packageName = moduleInfo.packageName().value(); + String packageName = moduleInfo.packageName(); String moduleName = module.descriptor().name().moduleNamePart(); String qualifiedModName = packageName + Names.DOT + moduleName; if (currentModule.isEmpty() || module.isDefaultModule() || module.equals(currentModule.get()) || ModuleUtil.matchingImportedModule(ctx, "", qualifiedModName).isPresent()) { return; } else { - moduleInfo.packageName = PackageName.from(packageName + "." + moduleName); + moduleInfo.packageName = packageName + "." + moduleName; } - packagesList.put(moduleInfo.packageName.value(), moduleInfo); + packagesList.put(moduleInfo.packageName, moduleInfo); }); return new ArrayList<>(packagesList.values()); } @@ -350,35 +352,59 @@ public List updatePackageMap(DocumentServiceContext context) { return moduleInfos; } + /** + * A light-weight package information holder. + */ /** * A light-weight package information holder. */ public static class ModuleInfo { - private final PackageOrg packageOrg; - private PackageName packageName; - private final PackageVersion packageVersion; + private static final String JSON_PROPERTY_ORGANIZATION = "organization"; + @SerializedName(JSON_PROPERTY_ORGANIZATION) + private final String packageOrg; + + private static final String JSON_PROPERTY_NAME = "name"; + @SerializedName(JSON_PROPERTY_NAME) + private String packageName; + + private static final String JSON_PROPERTY_VERSION = "version"; + @SerializedName(JSON_PROPERTY_VERSION) + private final String packageVersion; + + @Expose(deserialize = false) private final Path sourceRoot; + @Expose(deserialize = false) private final String moduleIdentifier; + @Expose(deserialize = false) private boolean isModuleFromCurrentPackage = false; + @Expose(deserialize = false) private final List listenerMetaData = new ArrayList<>(); - public ModuleInfo(PackageOrg packageOrg, PackageName packageName, PackageVersion version, Path path) { + public ModuleInfo(String packageOrg, String packageName, String packageVersion) { this.packageOrg = packageOrg; this.packageName = packageName; - this.packageVersion = version; + this.packageVersion = packageVersion; + this.sourceRoot = null; + this.moduleIdentifier = packageOrg + "/" + packageName; + } + + public ModuleInfo(PackageOrg packageOrg, PackageName packageName, PackageVersion version, Path path) { + this.packageOrg = packageOrg.value(); + this.packageName = packageName.value(); + this.packageVersion = version.value().toString(); this.sourceRoot = path; this.moduleIdentifier = packageOrg.toString().isEmpty() ? packageName.toString() : - packageOrg + "/" + packageName.toString(); + packageOrg + "/" + packageName; } public ModuleInfo(Package pkg) { - this.packageOrg = pkg.packageOrg(); - this.packageName = pkg.packageName(); - this.packageVersion = pkg.packageVersion(); + this.packageOrg = pkg.packageOrg().value(); + this.packageName = pkg.packageName().value(); + this.packageVersion = pkg.packageVersion().value().toString(); this.sourceRoot = pkg.project().sourceRoot(); this.moduleIdentifier = packageOrg.toString() + "/" + packageName.toString(); addServiceTemplateMetaData(); @@ -400,15 +426,15 @@ public void setModuleFromCurrentPackage(boolean moduleFromCurrentPackage) { isModuleFromCurrentPackage = moduleFromCurrentPackage; } - public PackageName packageName() { + public String packageName() { return packageName; } - public PackageOrg packageOrg() { + public String packageOrg() { return packageOrg; } - public PackageVersion packageVersion() { + public String packageVersion() { return packageVersion; } @@ -421,7 +447,7 @@ public String packageIdentifier() { } private void addServiceTemplateMetaData() { - String orgName = ModuleUtil.escapeModuleName(this.packageOrg().value()); + String orgName = ModuleUtil.escapeModuleName(this.packageOrg()); Project project = ProjectLoader.loadProject(this.sourceRoot()); //May take some time as we are compiling projects. PackageCompilation packageCompilation = project.currentPackage().getCompilation(); diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/imports/AddModuleToBallerinaTomlCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/imports/AddModuleToBallerinaTomlCodeAction.java index f9307b3d5e17..1a1142f1f4e2 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/imports/AddModuleToBallerinaTomlCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/imports/AddModuleToBallerinaTomlCodeAction.java @@ -133,8 +133,8 @@ private List getAvailablePackageVersionsFromLocalRepo( List modules = lsPackageLoader.getLocalRepoModules(); List versions = new ArrayList<>(); for (ModuleInfo mod : modules) { - if (mod.packageOrg().value().equals(orgName) && mod.packageName().value().equals(pkgName)) { - versions.add(mod.packageVersion()); + if (mod.packageOrg().equals(orgName) && mod.packageName().equals(pkgName)) { + versions.add(PackageVersion.from(mod.packageVersion())); } } return versions; diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/imports/ImportModuleCodeAction.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/imports/ImportModuleCodeAction.java index 4e68ed1ef22c..f54be85fc837 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/imports/ImportModuleCodeAction.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/codeaction/providers/imports/ImportModuleCodeAction.java @@ -135,16 +135,16 @@ public List getCodeActions(Diagnostic diagnostic, // Here we filter out the already imported packages moduleList.stream() .filter(pkgEntry -> existingModules.stream() - .noneMatch(moduleSymbol -> moduleSymbol.id().orgName().equals(pkgEntry.packageOrg().value()) && - moduleSymbol.id().moduleName().equals(pkgEntry.packageName().value())) + .noneMatch(moduleSymbol -> moduleSymbol.id().orgName().equals(pkgEntry.packageOrg()) && + moduleSymbol.id().moduleName().equals(pkgEntry.packageName())) ) .filter(pkgEntry -> { - String pkgName = pkgEntry.packageName().value(); + String pkgName = pkgEntry.packageName(); return pkgName.endsWith("." + modulePrefix) || pkgName.equals(modulePrefix); }) .forEach(pkgEntry -> { - String orgName = pkgEntry.packageOrg().value(); - String pkgName = pkgEntry.packageName().value(); + String orgName = pkgEntry.packageOrg(); + String pkgName = pkgEntry.packageName(); String moduleName = ModuleUtil.escapeModuleName(pkgName); Position insertPos = CommonUtil.getImportPosition(context); String importText = orgName.isEmpty() ? diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/CommonUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/CommonUtil.java index ada3125d1115..028c9024b511 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/CommonUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/CommonUtil.java @@ -427,11 +427,11 @@ public static boolean isUnionOfType(TypeSymbol typeSymbol, TypeDescKind typeDesc */ public static String getPackageLabel(LSPackageLoader.ModuleInfo module) { String orgName = ""; - if (!module.packageOrg().value().isEmpty() && !module.packageOrg().value().equals(Names.ANON_ORG.getValue())) { - orgName = module.packageOrg().value() + "/"; + if (!module.packageOrg().isEmpty() && !module.packageOrg().equals(Names.ANON_ORG.getValue())) { + orgName = module.packageOrg() + "/"; } - return orgName + module.packageName().value(); + return orgName + module.packageName(); } /** diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/ModuleUtil.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/ModuleUtil.java index adc66e30fab5..7f7069807021 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/ModuleUtil.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/common/utils/ModuleUtil.java @@ -228,8 +228,8 @@ public static String escapeModuleName(String qualifiedModuleName) { */ public static Optional matchingImportedModule(CompletionContext context, LSPackageLoader.ModuleInfo module) { - String name = module.packageName().value(); - String orgName = module.packageOrg().value(); + String name = module.packageName(); + String orgName = module.packageOrg(); Map currentDocImports = context.currentDocImportsMap(); return currentDocImports.keySet().stream() .filter(importPkg -> importPkg.orgName().isPresent() diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/AbstractCompletionProvider.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/AbstractCompletionProvider.java index c20fb9e5e50b..94c539bc00c6 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/AbstractCompletionProvider.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/AbstractCompletionProvider.java @@ -373,8 +373,8 @@ protected List getModuleCompletionItems(BallerinaCompletionCon List modules = LSPackageLoader.getInstance(ctx.languageServercontext()).getAllVisiblePackages(ctx); modules.forEach(pkg -> { - String name = pkg.packageName().value(); - String orgName = ModuleUtil.escapeModuleName(pkg.packageOrg().value()); + String name = pkg.packageName(); + String orgName = ModuleUtil.escapeModuleName(pkg.packageOrg()); if (ModuleUtil.matchingImportedModule(ctx, pkg).isEmpty() && !processedList.contains(orgName + CommonKeys.SLASH_KEYWORD_KEY + name) && !CommonUtil.PRE_DECLARED_LANG_LIBS.contains(name)) { @@ -382,7 +382,7 @@ protected List getModuleCompletionItems(BallerinaCompletionCon .map(ModuleUtil::escapeModuleName) .map(CommonUtil::escapeReservedKeyword) .toList(); - String label = pkg.packageOrg().value().isEmpty() ? String.join(".", pkgNameComps) + String label = pkg.packageOrg().isEmpty() ? String.join(".", pkgNameComps) : CommonUtil.getPackageLabel(pkg); String aliasComponent = pkgNameComps.get(pkgNameComps.size() - 1); // TODO: 2021-04-23 This has to be revamped with completion/resolve request for faster responses diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportDeclarationNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportDeclarationNodeContext.java index 2032609a213a..b80eb28f7a43 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportDeclarationNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportDeclarationNodeContext.java @@ -220,8 +220,8 @@ private ArrayList orgNameContextCompletions(BallerinaCompletio List moduleList = LSPackageLoader.getInstance(ctx.languageServercontext()).getAllVisiblePackages(ctx); moduleList.forEach(pkg -> { - String orgName = pkg.packageOrg().value(); - String pkgName = pkg.packageName().value(); + String orgName = pkg.packageOrg(); + String pkgName = pkg.packageName(); if (orgName.equals(Names.BALLERINA_INTERNAL_ORG.getValue()) || ModuleUtil.matchingImportedModule(ctx, pkg).isPresent()) { // Avoid suggesting the ballerinai org name @@ -231,7 +231,7 @@ private ArrayList orgNameContextCompletions(BallerinaCompletio .map(ModuleUtil::escapeModuleName) .map(CommonUtil::escapeReservedKeyword) .toList(); - String label = pkg.packageOrg().value().isEmpty() ? String.join(".", pkgNameComps) + String label = pkg.packageOrg().isEmpty() ? String.join(".", pkgNameComps) : CommonUtil.getPackageLabel(pkg); String insertText = orgName.isEmpty() ? "" : orgName + Names.ORG_NAME_SEPARATOR.getValue(); @@ -328,7 +328,7 @@ private ArrayList moduleNameContextCompletions(BallerinaComple .collect(Collectors.joining(".")); moduleList = LSPackageLoader.getInstance(serverContext).getCentralPackages(); - moduleList.forEach(ballerinaPackage -> packageList.add(ballerinaPackage.packageName().value())); + moduleList.forEach(ballerinaPackage -> packageList.add(ballerinaPackage.packageName())); List filteredPackageNames = getFilteredPackages(packageList, prefix, context); for (String filteredPackage : filteredPackageNames) { LSCompletionItem completionItem = getImportCompletion(context, filteredPackage, filteredPackage); @@ -339,9 +339,9 @@ private ArrayList moduleNameContextCompletions(BallerinaComple } moduleList = LSPackageLoader.getInstance(serverContext).getAllVisiblePackages(context); moduleList.forEach(ballerinaPackage -> { - String packageName = ballerinaPackage.packageName().value(); + String packageName = ballerinaPackage.packageName(); String insertText; - if (orgName.equals(ballerinaPackage.packageOrg().value()) && !addedPkgNames.contains(packageName) + if (orgName.equals(ballerinaPackage.packageOrg()) && !addedPkgNames.contains(packageName) && ModuleUtil.matchingImportedModule(context, ballerinaPackage).isEmpty()) { if (orgName.equals(Names.BALLERINA_ORG.value) && packageName.startsWith(Names.LANG.getValue() + Names.DOT.getValue())) { diff --git a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportOrgNameNodeContext.java b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportOrgNameNodeContext.java index 0c7e7727efe3..4230467f05fc 100644 --- a/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportOrgNameNodeContext.java +++ b/language-server/modules/langserver-core/src/main/java/org/ballerinalang/langserver/completions/providers/context/ImportOrgNameNodeContext.java @@ -74,9 +74,9 @@ private ArrayList moduleNameContextCompletions(BallerinaComple List pkgNameLabels = new ArrayList<>(); moduleList.forEach(ballerinaPackage -> { - String packageName = ballerinaPackage.packageName().value(); + String packageName = ballerinaPackage.packageName(); String insertText; - if (orgName.equals(ballerinaPackage.packageOrg().value()) && !pkgNameLabels.contains(packageName) + if (orgName.equals(ballerinaPackage.packageOrg()) && !pkgNameLabels.contains(packageName) && ModuleUtil.matchingImportedModule(context, ballerinaPackage).isEmpty()) { if (orgName.equals(Names.BALLERINA_ORG.value) && packageName.startsWith(Names.LANG.value + ".")) { @@ -85,7 +85,7 @@ private ArrayList moduleNameContextCompletions(BallerinaComple insertText = packageName; } pkgNameLabels.add(packageName); - // Do not add the semi colon at the end of the insert text since the user might type the as keyword + // Do not add the semicolon at the end of the insert text since the user might type the as keyword completionItems.add(ImportDeclarationContextUtil.getImportCompletion(context, packageName, insertText)); } }); diff --git a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/AbstractLSTest.java b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/AbstractLSTest.java index 7e74fc954b27..34365fe514d1 100644 --- a/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/AbstractLSTest.java +++ b/language-server/modules/langserver-core/src/test/java/org/ballerinalang/langserver/AbstractLSTest.java @@ -19,9 +19,6 @@ import com.google.gson.Gson; import io.ballerina.projects.Package; -import io.ballerina.projects.PackageName; -import io.ballerina.projects.PackageOrg; -import io.ballerina.projects.PackageVersion; import io.ballerina.projects.environment.Environment; import io.ballerina.projects.environment.EnvironmentBuilder; import io.ballerina.projects.environment.PackageRepository; @@ -30,7 +27,6 @@ import org.ballerinalang.langserver.commons.workspace.WorkspaceDocumentException; import org.ballerinalang.langserver.commons.workspace.WorkspaceManager; import org.ballerinalang.langserver.contexts.LanguageServerContextImpl; -import org.ballerinalang.langserver.extensions.ballerina.connector.CentralPackageListResult; import org.ballerinalang.langserver.util.FileUtils; import org.ballerinalang.langserver.util.TestUtil; import org.eclipse.lsp4j.jsonrpc.Endpoint; @@ -93,15 +89,11 @@ public abstract class AbstractLSTest { private static void mockCentralPackages() { try { - FileReader fileReader = new FileReader(FileUtils.RES_DIR.resolve("central/centralPackages.json").toFile()); - List packages = - GSON.fromJson(fileReader, CentralPackageListResult.class).getPackages(); - packages.forEach(packageInfo -> { - PackageOrg packageOrg = PackageOrg.from(packageInfo.getOrganization()); - PackageName packageName = PackageName.from(packageInfo.getName()); - PackageVersion packageVersion = PackageVersion.from(packageInfo.getVersion()); - CENTRAL_PACKAGES.add(new LSPackageLoader.ModuleInfo(packageOrg, packageName, packageVersion, null)); - }); + FileReader fileReader = new FileReader(FileUtils.RES_DIR.resolve("central/centralPackages.json") + .toFile()); + List packages = GSON.fromJson(fileReader, + CentralPackageDescriptorLoader.CentralPackageGraphQLResponse.class).data().packages().packages(); + CENTRAL_PACKAGES.addAll(packages); } catch (Exception e) { //ignore } diff --git a/language-server/modules/langserver-core/src/test/resources/central/centralPackages.json b/language-server/modules/langserver-core/src/test/resources/central/centralPackages.json index b05023258fdd..1daede54ac6b 100644 --- a/language-server/modules/langserver-core/src/test/resources/central/centralPackages.json +++ b/language-server/modules/langserver-core/src/test/resources/central/centralPackages.json @@ -1,440 +1,133 @@ { - "packages": [ - { - "organization": "ballerinax", - "name": "azure.ad", - "version": "2.4.0", - "platform": "java21", - "languageSpecificationVersion": "2022R4", - "isDeprecated": false, - "deprecateMessage": "", - "URL": "/ballerinax/azure.ad/2.4.0", - "balaVersion": "2.0.0", - "balaURL": "https://fileserver.central.ballerina.io/2.0/ballerinax/azure.ad/2.4.0/ballerinax-azure.ad-java21-2.4.0.bala?md5=aIH2wpk96Rkml7A2VBDT5Q&expires=1686819192", - "digest": "sha-256=28dfc001c646c151017d208bd1abac3beab2e2b76ac56e0c8ae49a8c8cc82e27", - "summary": "Connects to Azure AD from Ballerina", - "readme": "Connects to Azure AD from Ballerina\n\n## Package overview\nThe `azure.ad` is a [Ballerina](https:\/\/ballerina.io\/) connector for Azure AD.\n\n### Compatibility\n| | Version |\n|-----------------------|------------------------------|\n| Ballerina Language | Ballerina Swan Lake 2201.4.1 |\n| Microsoft Graph API | v1.0 |\n\n\n## Report issues\nTo report bugs, request new features, start new discussions, view project boards, etc., go to the [Ballerina Extended Library repository](https:\/\/github.com\/ballerina-platform\/ballerina-extended-library)\n\n## Useful links\n- Discuss code changes of the Ballerina project via [ballerina-dev@googlegroups.com](mailto:ballerina-dev@googlegroups.com).\n- Chat live with us via our [Discord server](https:\/\/discord.gg\/ballerinalang).\n- Post all technical questions on Stack Overflow with the [#ballerina](https:\/\/stackoverflow.com\/questions\/tagged\/ballerina) tag", - "template": false, - "licenses": [ - "Apache-2.0" - ], - "authors": [ - "Ballerina" - ], - "sourceCodeLocation": "https://github.com/ballerina-platform/module-ballerinax-azure.ad", - "keywords": [ - "IT Operations/Security & Identity Tools", - "Cost/Freemium", - "Vendor/Microsoft" - ], - "ballerinaVersion": "2201.4.1", - "icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_azure.ad_2.4.0.png", - "ownerUUID": "9712bf21-e852-48ba-83f0-2c7c5262cb6d", - "createdDate": 1685093006000, - "pullCount": 0, - "visibility": "public", - "modules": [ + "data": { + "packages": { + "packages": [ { - "packageURL": "/ballerinax/azure.ad/2.4.0", - "apiDocURL": "https://lib.ballerina.io/ballerinax/azure.ad/2.4.0", - "name": "azure.ad", - "summary": "Ballerina connector for Azure Active Directory (AD) is connecting the Azure AD REST API in Microsoft Graph v1.0 via Ballerina language. ", - "readme": "## Overview\nBallerina connector for Azure Active Directory (AD) is connecting the Azure AD REST API in Microsoft Graph v1.0 via Ballerina language. \nIt provides capability to perform management operations on user and group resources in an Azure AD tenent \n(Organization).\n\nThe connector uses the Microsoft Graph REST web API that provides the capability to access Microsoft Cloud service resources. This version of the connector only supports the operations on users and groups in an Azure AD.\n \nThis module supports [Microsoft Graph API](https:\/\/docs.microsoft.com\/en-us\/graph\/overview) `v1.0`. \n\n## Prerequisites\nBefore using this connector in your Ballerina application, complete the following:\n\n* Create a [Microsoft 365 Work and School account](https:\/\/www.office.com\/)\n* Create an [Azure account](https:\/\/azure.microsoft.com\/en-us\/) to register an application in the Azure portal\n* Obtain tokens\n - Use [this](https:\/\/docs.microsoft.com\/en-us\/graph\/auth-register-app-v2) guide to register an application with the Microsoft identity platform\n - The necessary scopes for this connector are shown below\n\n | Permissions name | Type | Description |\n |:-----------------------------:|:---------:|:-----------------------------------------:|\n | User.ReadWrite.All | Delegated | Create channels |\n | Group.ReadWrite.All | Delegated | Read and write all users' full profiles |\n\n## Quickstart\nTo use the Azure AD connector in your Ballerina application, update the .bal file as follows:\n### Step 1 - Import connector\nImport the ballerinax\/aad module into the Ballerina project.\n```ballerina\nimport ballerinax\/azure.aad;\n```\n### Step 2 - Create a new connector instance\nYou can now make the connection configuration using the OAuth2 refresh token grant config.\n```ballerina\naad:ConnectionConfig configuration = {\n auth: {\n refreshUrl: ,\n refreshToken : ,\n clientId : ,\n clientSecret : \n }\n};\n\naad:Client aadClient = check new (config);\n```\n### Step 3 - Invoke connector operation\n\n1. Create an Azure AD User\n```ballerina\nad:NewUser info = {\n accountEnabled: true,\n displayName: \"\",\n userPrincipalName: \"\",\n mailNickname: \"\",\n passwordProfile: {\n password: \"\",\n forceChangePasswordNextSignIn: true\n },\n surname: \"\"\n};\n\nad:User|error userInfo = aadClient->createUser(info);\nif (userInfo is ad:User) {\n log:printInfo(\"User succesfully created \" + userInfo?.id.toString());\n} else {\n log:printError(userInfo.message());\n}\n```\n2. Use `bal run` command to compile and run the Ballerina program.\n\n**[You can find a list of samples here](https:\/\/github.com\/ballerina-platform\/module-ballerinax-azure.ad\/tree\/master\/aad\/samples)**" - } - ], - "balToolId": "" - }, - { - "organization": "ballerinax", - "name": "hubspot.crm.quote", - "version": "2.3.1", - "platform": "any", - "languageSpecificationVersion": "2022R4", - "isDeprecated": false, - "deprecateMessage": "", - "URL": "/ballerinax/hubspot.crm.quote/2.3.1", - "balaVersion": "2.0.0", - "balaURL": "https://fileserver.central.ballerina.io/2.0/ballerinax/hubspot.crm.quote/2.3.1/ballerinax-hubspot.crm.quote-any-2.3.1.bala?md5=ssFN0xLpssrAwGcDSiFJRA&expires=1686819192", - "digest": "sha-256=49ef2be87293507491d8d07e3a8eed1a0188638c85b8436fb096ee58d4d8aab2", - "summary": "Connects to [HubSpot CRM API](https://developers.hubspot.com/docs/api/overview) from Ballerina", - "readme": "Connects to [HubSpot CRM API](https:\/\/developers.hubspot.com\/docs\/api\/overview) from Ballerina\n\n## Package overview\nThe `ballerinax\/hubspot.crm` is a [Ballerina](https:\/\/ballerina.io\/) connector for connecting to HubSpot CRM.\n\n### Compatibility\n| | Version |\n|----------------------|----------------------------|\n| Ballerina Language | Ballerina Swan Lake 2201.4.1 |\n| HubSpot REST API | V3 | \n\n## Report issues\nTo report bugs, request new features, start new discussions, view project boards, etc., go to the [Ballerina Extended Library repository](https:\/\/github.com\/ballerina-platform\/ballerina-extended-library)\n\n## Useful links\n- Discuss code changes of the Ballerina project in [ballerina-dev@googlegroups.com](mailto:ballerina-dev@googlegroups.com).\n- Chat live with us via our [Discord server](https:\/\/discord.gg\/ballerinalang).\n- Post all technical questions on Stack Overflow with the [#ballerina](https:\/\/stackoverflow.com\/questions\/tagged\/ballerina) tag", - "template": false, - "licenses": [ - "Apache-2.0" - ], - "authors": [ - "Ballerina" - ], - "sourceCodeLocation": "https://github.com/ballerina-platform/openapi-connectors/tree/main/openapi/hubspot.crm.quote", - "keywords": [ - "Sales & CRM/Customer Relationship Management", - "Cost/Freemium" - ], - "ballerinaVersion": "2201.4.1", - "icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_hubspot.crm.quote_2.3.1.png", - "ownerUUID": "9712bf21-e852-48ba-83f0-2c7c5262cb6d", - "createdDate": 1683811460000, - "pullCount": 0, - "visibility": "public", - "modules": [ + "name": "azure_storage_service", + "version": "4.3.0", + "organization": "ballerinax" + }, { - "packageURL": "/ballerinax/hubspot.crm.quote/2.3.1", - "apiDocURL": "https://lib.ballerina.io/ballerinax/hubspot.crm.quote/2.3.1", - "name": "hubspot.crm.quote", - "summary": "This is a generated connector from [HubSpot](https://www.hubspot.com/) OpenAPI specification. ", - "readme": "## Overview\nThis is a generated connector from [HubSpot](https:\/\/www.hubspot.com\/) OpenAPI specification. \n\nThis API provides access to collections of CRM objects, which return a map of property names to values. Each object type has its own set of default properties, which can be found by exploring the [CRM Object Properties API](https:\/\/developers.hubspot.com\/docs\/methods\/crm-properties\/crm-properties-overview).\n \n## Prerequisites\nBefore using this connector in your Ballerina application, complete the following:\n* Create a [HubSpot developer](https:\/\/developers.hubspot.com\/) account\n* Obtain tokens\n - Use [this](https:\/\/knowledge.hubspot.com\/integrations\/how-do-i-get-my-hubspot-api-key?_ga=2.57958890.1140639136.1626730652-1097354510.1626409334) guide to obtain the API keys related to your account.\n\n## Quickstart\nTo use the HubSpot CRM Quotes connector in your Ballerina application, update the .bal file as follows:\n### Step 1 - Import connector\nFirst, import the ballerinax\/hubspot.crm.quote module into the Ballerina project.\n```ballerina\nimport ballerinax\/hubspot.crm.quote;\n```\n\n### Step 2 - Create a new connector instance\nYou can now make the connection configuration using the access token.\n```ballerina\nquote:ApiKeysConfig config = {\n hapikey : \"\"\n};\n\nquote:Client baseClient = check new Client(clientConfig);\n\n```\n\n### Step 3 - Invoke connector operation\n\n1. List quotes\n\n```\nquote:SimplePublicObjectWithAssociationsArray|error bEvent = baseClient->getPage();\n\nif (bEvent is quote:SimplePublicObjectWithAssociationsArray) {\n log:printInfo(\"Quote list\" + bEvent.toString());\n} else {\n log:printError(msg = bEvent.message());\n}\n```\n\n3. Use `bal run` command to compile and run the Ballerina program" - } - ], - "balToolId": "" - }, - { - "organization": "ballerinax", - "name": "powertoolsdeveloper.datetime", - "version": "1.5.1", - "platform": "any", - "languageSpecificationVersion": "2022R4", - "isDeprecated": false, - "deprecateMessage": "", - "URL": "/ballerinax/powertoolsdeveloper.datetime/1.5.1", - "balaVersion": "2.0.0", - "balaURL": "https://fileserver.central.ballerina.io/2.0/ballerinax/powertoolsdeveloper.datetime/1.5.1/ballerinax-powertoolsdeveloper.datetime-any-1.5.1.bala?md5=eJEMTjr03ZudsyS3MUxq_g&expires=1686819192", - "digest": "sha-256=74959dd74c5df55f679f7d250bc9160e1d48f6f4c3f7c31559194f4583d7c291", - "summary": "Connects to [Apptigent Powertools Developer DataTime API](https://portal.apptigent.com/node/612) from Ballerina", - "readme": "Connects to [Apptigent Powertools Developer DataTime API](https:\/\/portal.apptigent.com\/node\/612) from Ballerina\n\n## Package overview\nThe `ballerinax\/powertoolsdeveloper.datetime` is a [Ballerina](https:\/\/ballerina.io\/) connector for Apptigent Powertools Developer DataTime API.\nThis package provides the capability to access Apptigent Powertools Developer DataTime API.\n\n### Compatibility\n| | Version |\n|-------------------------------------|---------------------------------|\n| Ballerina Language | Ballerina Swan Lake 2201.4.1 | \n| Apptigent Powertools Developer API | 2021.1.01 |\n\n## Report issues\nTo report bugs, request new features, start new discussions, view project boards, etc., go to the [Ballerina Extended Library repository](https:\/\/github.com\/ballerina-platform\/ballerina-extended-library)\n\n## Useful links\n- Discuss code changes of the Ballerina project in [ballerina-dev@googlegroups.com](mailto:ballerina-dev@googlegroups.com).\n- Chat live with us via our [Discord server](https:\/\/discord.gg\/ballerinalang).\n- Post all technical questions on Stack Overflow with the [#ballerina](https:\/\/stackoverflow.com\/questions\/tagged\/ballerina) tag", - "template": false, - "licenses": [ - "Apache-2.0" - ], - "authors": [ - "Ballerina" - ], - "sourceCodeLocation": "https://github.com/ballerina-platform/openapi-connectors/tree/main/openapi/powertoolsdeveloper.datetime", - "keywords": [ - "Website & App Building/App Builders", - "Cost/Freemium" - ], - "ballerinaVersion": "2201.4.1", - "icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_powertoolsdeveloper.datetime_1.5.1.png", - "ownerUUID": "9712bf21-e852-48ba-83f0-2c7c5262cb6d", - "createdDate": 1683811457000, - "pullCount": 0, - "visibility": "public", - "modules": [ + "name": "azure_eventhub", + "version": "3.1.0", + "organization": "ballerinax" + }, { - "packageURL": "/ballerinax/powertoolsdeveloper.datetime/1.5.1", - "apiDocURL": "https://lib.ballerina.io/ballerinax/powertoolsdeveloper.datetime/1.5.1", - "name": "powertoolsdeveloper.datetime", - "summary": "This is a generated connector for [Apptigent PowerTools Developer API v2021.1.01](https://portal.apptigent.com/node/612) OpenAPI specification. ", - "readme": "## Overview\n\nThis is a generated connector for [Apptigent PowerTools Developer API v2021.1.01](https:\/\/portal.apptigent.com\/node\/612) OpenAPI specification. \nApptigent PowerTools Developer Edition is a powerful suite of API endpoints for custom applications running on any stack. \nManipulate text, modify collections, format dates and times, convert currency, perform advanced mathematical calculations, shorten URL's, encode strings, convert text to speech, translate content into multiple languages, process images, and more. \nPowerTools is the ultimate developer toolkit. \nThis connector provides the capability for date and time operations.\n\n## Prerequisites\n\nBefore using this connector in your Ballerina application, complete the following:\n\n* Create [Apptigent](https:\/\/portal.apptigent.com\/user\/register) account\n* Obtain tokens\n 1. Log into Apptigent Developer Portal by visiting https:\/\/portal.apptigent.com\n 2. Create an app and obtain the `Client ID` which will be used as the `API Key` by following the guidelines described [here]((https:\/\/portal.apptigent.com\/start)).\n \n## Quickstart\n\nTo use the Apptigent PowerTools Developer connector in your Ballerina application, update the .bal file as follows:\n\n### Step 1: Import connector\nImport the `ballerinax\/powertoolsdeveloper.datetime` module into the Ballerina project.\n```ballerina\nimport ballerinax\/powertoolsdeveloper.datetime as pd;\n```\n\n### Step 2: Create a new connector instance\nCreate a `datetime:ApiKeysConfig` with the Client ID obtained, and initialize the connector with it. \n```ballerina\npd:ApiKeysConfig config = {\n xIbmClientId: \"\"\n}\npd:Client baseClient = check new Client(config);\n```\n\n### Step 3: Invoke connector operation\n1. Now you can use the operations available within the connector. Note that they are in the form of remote operations.\n\n Following is an example on how to calculate the difference between two dates using the connector by providing the `InputDateTimeDifference` record with date\/time values to compare.\n\n Calculate the difference between two dates\n\n ```ballerina\n public function main() {\n pd:InputDateTimeDifference inputDateTimeDifference = {\n dateTime1: \"1\/1\/2010 12:37:19\",\n dateTime2: \"3\/15\/2011 14:27:49\"\n };\n pd:OutputDateDifference|error response = baseClient->dateTimeDifference(inputDateTimeDifference);\n if (response is pd:OutputDateDifference) {\n log:printInfo(response.toString());\n } else {\n log:printError(response.message());\n }\n }\n ``` \n\n2. Use `bal run` command to compile and run the Ballerina program. " - } - ], - "balToolId": "" - }, - { - "organization": "ballerinax", - "name": "azure.qnamaker", - "version": "1.5.1", - "platform": "any", - "languageSpecificationVersion": "2022R4", - "isDeprecated": false, - "deprecateMessage": "", - "URL": "/ballerinax/azure.qnamaker/1.5.1", - "balaVersion": "2.0.0", - "balaURL": "https://fileserver.central.ballerina.io/2.0/ballerinax/azure.qnamaker/1.5.1/ballerinax-azure.qnamaker-any-1.5.1.bala?md5=c_f2e6W7skwwWNti9cXEWg&expires=1686819192", - "digest": "sha-256=cc69ab77bb6d23e9c2122cf018e243a58fdf9f4d528a1c02cf30edf1a3893a13", - "summary": "Connects to [Azure QnA Maker API](https://docs.microsoft.com/en-us/rest/api/cognitiveservices-qnamaker/QnAMaker4.0/) from Ballerina", - "readme": "Connects to [Azure QnA Maker API](https:\/\/docs.microsoft.com\/en-us\/rest\/api\/cognitiveservices-qnamaker\/QnAMaker4.0\/) from Ballerina\n\n### Package overview\n\nThe `azure.qnamaker` is a [Ballerina](https:\/\/ballerina.io\/) connector for connecting to Azure QnA Maker API. This package allows you to create a natural conversational layer over your data.\n\n#### Compatibility\n| | Version |\n|----------------------------|-------------------|\n| Ballerina Language | Swan Lake 2201.4.1 |\n| Azure QnA Maker API | v4 |\n\n## Report issues\nTo report bugs, request new features, start new discussions, view project boards, etc., go to the [Ballerina Extended Library repository](https:\/\/github.com\/ballerina-platform\/ballerina-extended-library)\n\n## Useful links\n- Discuss code changes of the Ballerina project in [ballerina-dev@googlegroups.com](mailto:ballerina-dev@googlegroups.com).\n- Chat live with us via our [Discord server](https:\/\/discord.gg\/ballerinalang).\n- Post all technical questions on Stack Overflow with the [#ballerina](https:\/\/stackoverflow.com\/questions\/tagged\/ballerina) tag", - "template": false, - "licenses": [ - "Apache-2.0" - ], - "authors": [ - "Ballerina" - ], - "sourceCodeLocation": "https://github.com/ballerina-platform/openapi-connectors/tree/main/openapi/azure.qnamaker", - "keywords": [ - "IT Operations/Cloud Services", - "Cost/Freemium", - "Vendor/Microsoft" - ], - "ballerinaVersion": "2201.4.1", - "icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_azure.qnamaker_1.5.1.png", - "ownerUUID": "9712bf21-e852-48ba-83f0-2c7c5262cb6d", - "createdDate": 1683811454000, - "pullCount": 0, - "visibility": "public", - "modules": [ + "name": "prometheus", + "version": "0.3.1", + "organization": "ballerinax" + }, { - "packageURL": "/ballerinax/azure.qnamaker/1.5.1", - "apiDocURL": "https://lib.ballerina.io/ballerinax/azure.qnamaker/1.5.1", - "name": "azure.qnamaker", - "summary": "This is a generated connector for [Azure QnA Maker API v4](https://docs.microsoft.com/en-us/rest/api/cognitiveservices-qnamaker/QnAMaker4.0/) OpenAPI specification.", - "readme": "## Overview\n\nThis is a generated connector for [Azure QnA Maker API v4](https:\/\/docs.microsoft.com\/en-us\/rest\/api\/cognitiveservices-qnamaker\/QnAMaker4.0\/) OpenAPI specification.\nThe Azure QnA Maker API is a cloud-based Natural Language Processing (NLP) service that allows you to create a natural conversational layer over your data. It is used to find the most appropriate answer for any input from your custom knowledge base (KB) of information. QnA Maker is commonly used to build conversational client applications, which include social media applications, chat bots, and speech-enabled desktop applications.\n\nThis module supports [Azure QnA Maker API v4](https:\/\/docs.microsoft.com\/en-us\/rest\/api\/cognitiveservices-qnamaker\/QnAMaker4.0\/).\n\n## Prerequisites\n\nBefore using this connector in your Ballerina application, complete the following:\n\n* Create an [Azure account](https:\/\/docs.microsoft.com\/en-us\/learn\/modules\/create-an-azure-account\/)\n\n* Create a [resource](https:\/\/portal.azure.com\/#blade\/Microsoft_Azure_ProjectOxford\/CognitiveServicesHub\/QnAMaker)\n\n* Obtain tokens by following [this guide](https:\/\/docs.microsoft.com\/en-us\/azure\/cognitive-services\/qnamaker\/how-to\/set-up-qnamaker-service-azure?tabs=v1)\n\n## Quickstart\n\nTo use this connector in your Ballerina application, update the .bal file as follows:\n\n### Step 1: Import connector\nImport the `ballerinax\/azure.qnamaker` module into the Ballerina project.\n```ballerina\nimport ballerinax\/azure.qnamaker;\n```\n\n### Step 2: Create a new connector instance\nYou can now make the connection configuration using `Ocp-Apim-Subscription-Key`.\n\nYou can do this step in two ways. You can use any one of this.\n\n- Option 1 :\n Configure API Keys in ballerina file directly. \n\n ```ballerina\n \n qnamaker:ApiKeysConfig apiKeyConfig = {\n ocpApimSubscriptionKey:\"\"\n subscriptionKey: \"\"\n };\n\n qnamaker:Client myClient = check new Client(apiKeyConfig, serviceUrl = \"https:\/\/.api.cognitive.microsoft.com\/qnamaker\/v4.0\");\n\n ```\n\n- Option 2 :\n Configure API Keys in `Config.toml` file and configure it in ballerina file, using configurables. \n\n 1. Set up API Keys in `Config.toml` as shown below.\n ```\n [apiKeyConfig]\n ocpApimSubscriptionKey = \"\"\n subscriptionKey = \"\"\n ```\n\n 2. Configure the client in ballerina file as shown below.\n ```ballerina\n configurable ApiKeysConfig & readonly apiKeyConfig = ?;\n\n qnamaker:Client myClient = check new Client(apiKeyConfig, serviceUrl = \"https:\/\/.api.cognitive.microsoft.com\/qnamaker\/v4.0\");\n ```\n\n### Step 3: Invoke connector operation\n1. Now you can use the operations available within the connector. Note that they are in the form of remote operations.\n\n Following is an example on how to get Knowledgebase Details from API.\n\n Get Knowledgebase Details\n\n ```ballerina\n public function main() returns error? {\n\n qnamaker:KnowledgebaseDTO res = check baseClient->getKnowledgebaseDetail(kID);\n\n }\n ```\n\n2. Use `bal run` command to compile and run the Ballerina program." - } - ], - "balToolId": "" - }, - { - "organization": "ballerinax", - "name": "godaddy.aftermarket", - "version": "1.5.1", - "platform": "any", - "languageSpecificationVersion": "2022R4", - "isDeprecated": false, - "deprecateMessage": "", - "URL": "/ballerinax/godaddy.aftermarket/1.5.1", - "balaVersion": "2.0.0", - "balaURL": "https://fileserver.central.ballerina.io/2.0/ballerinax/godaddy.aftermarket/1.5.1/ballerinax-godaddy.aftermarket-any-1.5.1.bala?md5=IiMQOAN-JY6KYjRd_vsKXg&expires=1686819192", - "digest": "sha-256=33e493a3f292edb325cbe8c7484e5205ae5b996ce551d79f569653a0f009c5fa", - "summary": "Connects to [GoDaddy Aftermarket](https://developer.godaddy.com/doc/endpoint/aftermarket) from Ballerina", - "readme": "Connects to [GoDaddy Aftermarket](https:\/\/developer.godaddy.com\/doc\/endpoint\/aftermarket) from Ballerina\n## Package overview\nThe GoDaddy Aftermarket is a [Ballerina](https:\/\/ballerina.io\/) connector for GoDaddy Aftermarket API. This package provides capabilities of adding and removing GoDaddy auctions.\n\n### Compatibility\n| | Version |\n|------------------------------|---------------------------|\n| Ballerina Language | Ballerina Swan Lake 2201.4.1|\n| GoDaddy Aftermarket API | v1 |\n\n## Report issues\nTo report bugs, request new features, start new discussions, view project boards, etc., go to the [Ballerina Extended Library repository](https:\/\/github.com\/ballerina-platform\/ballerina-extended-library)\n\n## Useful links\n- Discuss code changes of the Ballerina project in [ballerina-dev@googlegroups.com](mailto:ballerina-dev@googlegroups.com).\n- Chat live with us via our [Discord server](https:\/\/discord.gg\/ballerinalang).\n- Post all technical questions on Stack Overflow with the [#ballerina](https:\/\/stackoverflow.com\/questions\/tagged\/ballerina) tag", - "template": false, - "licenses": [ - "Apache-2.0" - ], - "authors": [ - "Ballerina" - ], - "sourceCodeLocation": "https://github.com/ballerina-platform/openapi-connectors/tree/main/openapi/godaddy.aftermarket", - "keywords": [ - "Website & App Building/Website Builders", - "Cost/Paid" - ], - "ballerinaVersion": "2201.4.1", - "icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_godaddy.aftermarket_1.5.1.png", - "ownerUUID": "9712bf21-e852-48ba-83f0-2c7c5262cb6d", - "createdDate": 1683811450000, - "pullCount": 0, - "visibility": "public", - "modules": [ + "name": "asana", + "version": "2.0.0", + "organization": "ballerinax" + }, { - "packageURL": "/ballerinax/godaddy.aftermarket/1.5.1", - "apiDocURL": "https://lib.ballerina.io/ballerinax/godaddy.aftermarket/1.5.1", - "name": "godaddy.aftermarket", - "summary": "This is a generated connector for [GoDaddy Aftermarket API v1](https://developer.godaddy.com/doc/endpoint/aftermarkets) OpenAPI specification.", - "readme": "## Overview\nThis is a generated connector for [GoDaddy Aftermarket API v1](https:\/\/developer.godaddy.com\/doc\/endpoint\/aftermarkets) OpenAPI specification.\n\nThe GoDaddy Aftermarkets API provides capability to access GoDaddy operations related to auctions.\n\n## Prerequisites\nBefore using this connector in your Ballerina application, complete the following:\n\n* Create an GoDaddy account\n* Obtain tokens\n 1. Follow [this link](https:\/\/developer.godaddy.com\/getstarted) to obtain tokens" - } - ], - "balToolId": "" - }, - { - "organization": "ballerinax", - "name": "googleapis.manufacturercenter", - "version": "1.5.1", - "platform": "any", - "languageSpecificationVersion": "2022R4", - "isDeprecated": false, - "deprecateMessage": "", - "URL": "/ballerinax/googleapis.manufacturercenter/1.5.1", - "balaVersion": "2.0.0", - "balaURL": "https://fileserver.central.ballerina.io/2.0/ballerinax/googleapis.manufacturercenter/1.5.1/ballerinax-googleapis.manufacturercenter-any-1.5.1.bala?md5=q8KgAUJ5kBKscXTqW5R87g&expires=1686819192", - "digest": "sha-256=807b5293ed34276f8bac46e82528ef5b1518b6a234746ce86f0df8a57a7c3c1a", - "summary": "Connects to [Google Manufacturer Center API](https://developers.google.com/manufacturers/) from Ballerina", - "readme": "Connects to [Google Manufacturer Center API](https:\/\/developers.google.com\/manufacturers\/) from Ballerina\n\n## Package overview\nThe `ballerinax\/googleapis.manufacturercenter` is a [Ballerina](https:\/\/ballerina.io\/) connector for Google Manufacturer Center API.\nThis package provides the capability to access Google Manufacturer Center API.\n\n### Compatibility\n| | Version |\n|-----------------------------------|---------------------------------|\n| Ballerina Language | Ballerina Swan Lake 2201.4.1 | \n| Google Manufacturer Center API | v1 |\n\n## Report issues\nTo report bugs, request new features, start new discussions, view project boards, etc., go to the [Ballerina Extended Library repository](https:\/\/github.com\/ballerina-platform\/ballerina-extended-library)\n\n## Useful links\n- Discuss code changes of the Ballerina project in [ballerina-dev@googlegroups.com](mailto:ballerina-dev@googlegroups.com).\n- Chat live with us via our [Discord server](https:\/\/discord.gg\/ballerinalang).\n- Post all technical questions on Stack Overflow with the [#ballerina](https:\/\/stackoverflow.com\/questions\/tagged\/ballerina) tag", - "template": false, - "licenses": [ - "Apache-2.0" - ], - "authors": [ - "Ballerina" - ], - "sourceCodeLocation": "https://github.com/ballerina-platform/openapi-connectors/tree/main/openapi/googleapis.manufacturercenter", - "keywords": [ - "Commerce/eCommerce", - "Cost/Free", - "Vendor/Google" - ], - "ballerinaVersion": "2201.4.1", - "icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_googleapis.manufacturercenter_1.5.1.png", - "ownerUUID": "9712bf21-e852-48ba-83f0-2c7c5262cb6d", - "createdDate": 1683811442000, - "pullCount": 0, - "visibility": "public", - "modules": [ + "name": "trigger.asb", + "version": "1.2.0", + "organization": "ballerinax" + }, { - "packageURL": "/ballerinax/googleapis.manufacturercenter/1.5.1", - "apiDocURL": "https://lib.ballerina.io/ballerinax/googleapis.manufacturercenter/1.5.1", - "name": "googleapis.manufacturercenter", - "summary": "This is a generated connector for [Google Manufacturer Center API v1](https://developers.google.com/manufacturers/) OpenAPI specification.", - "readme": "## Overview\nThis is a generated connector for [Google Manufacturer Center API v1](https:\/\/developers.google.com\/manufacturers\/) OpenAPI specification.\nPublic API for managing Manufacturer Center related data.\n\n## Prerequisites\n\nBefore using this connector in your Ballerina application, complete the following:\n\n* Create a [Google account](https:\/\/accounts.google.com\/signup)\n* Obtain tokens - Follow [this link](https:\/\/developers.google.com\/identity\/protocols\/oauth2)\n \n## Quickstart\n\nTo use the Google Manufacturer Center connector in your Ballerina application, update the .bal file as follows:\n\n### Step 1: Import connector\nFirst, import the `ballerinax\/googleapis.manufacturercenter` module into the Ballerina project.\n```ballerina\nimport ballerinax\/googleapis.manufacturercenter;\n```\n\n### Step 2: Create a new connector instance\nCreate a `manufacturercenter:ClientConfig` with the OAuth2 tokens obtained, and initialize the connector with it. \n```ballerina\nmanufacturercenter:ClientConfig clientConfig = {\n auth: {\n clientId: ,\n clientSecret: ,\n refreshUrl: ,\n refreshToken: \n }\n};\n\nmanufacturercenter:Client baseClient = check new Client(clientConfig);\n```\n\n### Step 3: Invoke connector operation\n1. Now you can use the operations available within the connector. Note that they are in the form of remote operations.\n\n Following is an example on how to list all the products in a Manufacturer Center account using the connector. \n\n Lists all the products in a Manufacturer Center account\n\n ```ballerina\n public function main() {\n manufacturercenter:ListProductsResponse|error response = baseClient->listAccountsProducts(\"accounts\/\");\n if (response is manufacturercenter:ListProductsResponse) {\n log:printInfo(response.toString());\n } else {\n log:printError(response.message());\n }\n }\n ``` \n\n2. Use `bal run` command to compile and run the Ballerina program." - } - ], - "balToolId": "" - }, - { - "organization": "ballerinax", - "name": "cloudmersive.barcode", - "version": "1.5.1", - "platform": "any", - "languageSpecificationVersion": "2022R4", - "isDeprecated": false, - "deprecateMessage": "", - "URL": "/ballerinax/cloudmersive.barcode/1.5.1", - "balaVersion": "2.0.0", - "balaURL": "https://fileserver.central.ballerina.io/2.0/ballerinax/cloudmersive.barcode/1.5.1/ballerinax-cloudmersive.barcode-any-1.5.1.bala?md5=3x7z7AmxehjEOYh_cfQ8EQ&expires=1686819192", - "digest": "sha-256=fab075f7556a5baf3c11816c1d462aa09c4fa97e436b6902b09aa186723e30f6", - "summary": "Connects to [Cloudmersive Barcode API](https://api.cloudmersive.com/docs/barcode.asp) from Ballerina", - "readme": "Connects to [Cloudmersive Barcode API](https:\/\/api.cloudmersive.com\/docs\/barcode.asp) from Ballerina\n\n## Package overview\n\nThe `ballerinax\/cloudmersive.barcode` is a [Ballerina](https:\/\/ballerina.io\/) connector for connecting to Cloudmersive Barcode API.\n\n### Compatibility\n| | Version |\n|--------------------------|----------------------------|\n| Ballerina Language | Ballerina Swan Lake 2201.4.1 |\n| Cloudmersive API | v1 |\n\n## Report issues\nTo report bugs, request new features, start new discussions, view project boards, etc., go to the [Ballerina Extended Library repository](https:\/\/github.com\/ballerina-platform\/ballerina-extended-library)\n\n## Useful links\n- Discuss code changes of the Ballerina project in [ballerina-dev@googlegroups.com](mailto:ballerina-dev@googlegroups.com).\n- Chat live with us via our [Discord server](https:\/\/discord.gg\/ballerinalang).\n- Post all technical questions on Stack Overflow with the [#ballerina](https:\/\/stackoverflow.com\/questions\/tagged\/ballerina) tag", - "template": false, - "licenses": [ - "Apache-2.0" - ], - "authors": [ - "Ballerina" - ], - "sourceCodeLocation": "https://github.com/ballerina-platform/openapi-connectors/tree/main/openapi/cloudmersive.barcode", - "keywords": [ - "IT Operations/Security & Identity Tools", - "Cost/Freemium" - ], - "ballerinaVersion": "2201.4.1", - "icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_cloudmersive.barcode_1.5.1.png", - "ownerUUID": "9712bf21-e852-48ba-83f0-2c7c5262cb6d", - "createdDate": 1683811438000, - "pullCount": 0, - "visibility": "public", - "modules": [ + "name": "shopify.admin", + "version": "2.5.0", + "organization": "ballerinax" + }, { - "packageURL": "/ballerinax/cloudmersive.barcode/1.5.1", - "apiDocURL": "https://lib.ballerina.io/ballerinax/cloudmersive.barcode/1.5.1", - "name": "cloudmersive.barcode", - "summary": "This is a generated connector from [Cloudmersive](https://account.cloudmersive.com) OpenAPI specification.", - "readme": "## Overview\nThis is a generated connector from [Cloudmersive](https:\/\/account.cloudmersive.com) OpenAPI specification.\n\nThe Cloudmersive Barcode APIs let you generate barcode images, and recognize values from images of barcodes.\n \n### Prerequisites\n* Create a [Cloudmersive](https:\/\/account.cloudmersive.com) account\n* Obtain tokens\n - Use [this](https:\/\/account.cloudmersive.com\/keys) guide to obtain the API key related to your account.\n\n## Quickstart\n\nTo use the Cloudmersive Barcode connector in your Ballerina application, update the .bal file as follows:\n### Step 1 - Import connector\nFirst, import the ballerinax\/cloudmersive.barcode module into the Ballerina project.\n```ballerina\nimport ballerinax\/cloudmersive.barcode;\n```\n### Step 2 - Create a new connector instance\nYou can now make the connection configuration using the access token.\n```ballerina\nbarcode:ApiKeysConfig config = {\n apikey : \"\"\n};\n\nbarcode:Client baseClient = check new Client(clientConfig);\n```\n### Step 3 - Invoke connector operation\n\n1. Lookup EAN barcode\n\n```ballerina\nbarcode:BarcodeLookupResponse|error bEvent = baseClient->barcodeEanLookup(\"4 605664 00005\");\n\nif (bEvent is barcode:BarcodeLookupResponse) {\n log:printInfo(\"Product data: \" + bEvent.toString());\n} else {\n log:printError(msg = bEvent.toString());\n}\n``` \n2. Use `bal run` command to compile and run the Ballerina program" - } - ], - "balToolId": "" - }, - { - "organization": "ballerinax", - "name": "saps4hana.wls.screeninghits", - "version": "1.4.1", - "platform": "any", - "languageSpecificationVersion": "2022R4", - "isDeprecated": false, - "deprecateMessage": "", - "URL": "/ballerinax/saps4hana.wls.screeninghits/1.4.1", - "balaVersion": "2.0.0", - "balaURL": "https://fileserver.central.ballerina.io/2.0/ballerinax/saps4hana.wls.screeninghits/1.4.1/ballerinax-saps4hana.wls.screeninghits-any-1.4.1.bala?md5=uf4Pd0ezJOblXWNMCyjQhw&expires=1686819192", - "digest": "sha-256=d3a98e0d731444f172e2be56b97e511a52fcd4fd4ddc935b53427bc3f68ae341", - "summary": "Connects to [SAPS4HANA SAP Watch List Screening Hits API v1.7](https://api.sap.com/api/ScreeningHits/resource) from Ballerina", - "readme": "Connects to [SAPS4HANA SAP Watch List Screening Hits API v1.7](https:\/\/api.sap.com\/api\/ScreeningHits\/resource) from Ballerina\n\n## Package overview\nThe `ballerinax\/saps4hana.wls.screeninghits` is a [Ballerina](https:\/\/ballerina.io\/) connector for managing Screening Hits created by the Screening microservice and enabling users to decide whether they are true matches or false positives\n\n### Compatibility\n| | Version |\n|-----------------------------------|------------------------------|\n| Ballerina Language | Ballerina Swan Lake 2201.4.1 |\n| SAPS4HANA WLS Screening Hits API | 1.7 |\n \n## Report issues\nTo report bugs, request new features, start new discussions, view project boards, etc., go to the [Ballerina Extended Library repository](https:\/\/github.com\/ballerina-platform\/ballerina-extended-library)\n\n## Useful links\n- Discuss code changes of the Ballerina project in [ballerina-dev@googlegroups.com](mailto:ballerina-dev@googlegroups.com).\n- Chat live with us via our [Discord server](https:\/\/discord.gg\/ballerinalang).\n- Post all technical questions on Stack Overflow with the [#ballerina](https:\/\/stackoverflow.com\/questions\/tagged\/ballerina) tag", - "template": false, - "licenses": [ - "Apache-2.0" - ], - "authors": [ - "Ballerina" - ], - "sourceCodeLocation": "https://github.com/ballerina-platform/openapi-connectors/tree/main/openapi/saps4hana.wls.screeninghits", - "keywords": [ - "Business Management/ERP", - "Cost/Paid" - ], - "ballerinaVersion": "2201.4.1", - "icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_saps4hana.wls.screeninghits_1.4.1.png", - "ownerUUID": "9712bf21-e852-48ba-83f0-2c7c5262cb6d", - "createdDate": 1683811435000, - "pullCount": 0, - "visibility": "public", - "modules": [ + "name": "newsapi", + "version": "1.5.1", + "organization": "ballerinax" + }, { - "packageURL": "/ballerinax/saps4hana.wls.screeninghits/1.4.1", - "apiDocURL": "https://lib.ballerina.io/ballerinax/saps4hana.wls.screeninghits/1.4.1", - "name": "saps4hana.wls.screeninghits", - "summary": "This is a generated connector for [SAPS4HANA SAP Watch List Screening Hits API v1.7](https://api.sap.com/api/ScreeningHits/resource) OpenAPI specification. ", - "readme": "## Overview\nThis is a generated connector for [SAPS4HANA SAP Watch List Screening Hits API v1.7](https:\/\/api.sap.com\/api\/ScreeningHits\/resource) OpenAPI specification. \n\nThis microservice manages Screening Hits created by the Screening microservice and enables users to decide whether they are true matches or false positives. The Screening Hits are grouped in Screening Hit Collections. The Screening Hit Collection refers to a Business Context e.g. a Sales Order and contains one or more Screened Addresses.\n\n## Prerequisites\n\nBefore using this connector in your Ballerina application, complete the following:\n\n* Create and configure an OAuth2 client credentials by following [this guide](https:\/\/help.sap.com\/viewer\/b865ed651e414196b39f8922db2122c7\/LATEST\/en-US\/7aefa21a65f94b25b7e639c3931b6f83.html)." - } - ], - "balToolId": "" - }, - { - "organization": "ballerinax", - "name": "hubspot.crm.pipeline", - "version": "2.3.1", - "platform": "any", - "languageSpecificationVersion": "2022R4", - "isDeprecated": false, - "deprecateMessage": "", - "URL": "/ballerinax/hubspot.crm.pipeline/2.3.1", - "balaVersion": "2.0.0", - "balaURL": "https://fileserver.central.ballerina.io/2.0/ballerinax/hubspot.crm.pipeline/2.3.1/ballerinax-hubspot.crm.pipeline-any-2.3.1.bala?md5=rWq7tvrs2i5b_NLdj8PXyQ&expires=1686819192", - "digest": "sha-256=9108e153832abc8f75b225fd6c72cd7d0977b658594235e8b6439728298564d0", - "summary": "Connects to [HubSpot CRM API](https://developers.hubspot.com/docs/api/overview) from Ballerina", - "readme": "Connects to [HubSpot CRM API](https:\/\/developers.hubspot.com\/docs\/api\/overview) from Ballerina\n\n## Package overview\nThe `ballerinax\/hubspot.crm` is a [Ballerina](https:\/\/ballerina.io\/) connector for connecting to HubSpot CRM.\n\n### Compatibility\n| | Version |\n|----------------------|----------------------------|\n| Ballerina Language | Ballerina Swan Lake 2201.4.1 |\n| HubSpot REST API | V3 | \n\n## Report issues\nTo report bugs, request new features, start new discussions, view project boards, etc., go to the [Ballerina Extended Library repository](https:\/\/github.com\/ballerina-platform\/ballerina-extended-library)\n\n## Useful links\n- Discuss code changes of the Ballerina project in [ballerina-dev@googlegroups.com](mailto:ballerina-dev@googlegroups.com).\n- Chat live with us via our [Discord server](https:\/\/discord.gg\/ballerinalang).\n- Post all technical questions on Stack Overflow with the [#ballerina](https:\/\/stackoverflow.com\/questions\/tagged\/ballerina) tag", - "template": false, - "licenses": [ - "Apache-2.0" - ], - "authors": [ - "Ballerina" - ], - "sourceCodeLocation": "https://github.com/ballerina-platform/openapi-connectors/tree/main/openapi/hubspot.crm.pipeline", - "keywords": [ - "Sales & CRM/Customer Relationship Management", - "Cost/Freemium" - ], - "ballerinaVersion": "2201.4.1", - "icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_hubspot.crm.pipeline_2.3.1.png", - "ownerUUID": "9712bf21-e852-48ba-83f0-2c7c5262cb6d", - "createdDate": 1683811431000, - "pullCount": 0, - "visibility": "public", - "modules": [ + "name": "hubspot.crm.company", + "version": "2.3.1", + "organization": "ballerinax" + }, { - "packageURL": "/ballerinax/hubspot.crm.pipeline/2.3.1", - "apiDocURL": "https://lib.ballerina.io/ballerinax/hubspot.crm.pipeline/2.3.1", - "name": "hubspot.crm.pipeline", - "summary": "This is a generated connector from [HubSpot](https://www.hubspot.com/) OpenAPI specification. ", - "readme": "## Overview\nThis is a generated connector from [HubSpot](https:\/\/www.hubspot.com\/) OpenAPI specification. \n\nThis API provides access to pipelines. Pipelines represent distinct stages in a workflow, like closing a deal or servicing a support ticket. These endpoints provide access to read and modify pipelines in HubSpot. They support `deals` and `tickets` object types.\n \n## Prerequisites\nBefore using this connector in your Ballerina application, complete the following:\n* Create a [HubSpot developer](https:\/\/developers.hubspot.com\/) account\n* Obtain tokens\n - Use [this](https:\/\/developers.hubspot.com\/docs\/api\/working-with-oauth4) guide to obtain the credentials which are needed to create the and \n\n## Quickstart\nTo use the HubSpot CRM Pipelines connector in your Ballerina application, update the .bal file as follows:\n### Step 1 - Import connector\nFirst, import the ballerinax\/hubspot.crm.pipeline module into the Ballerina project.\n```ballerina\nimport ballerinax\/hubspot.crm.pipeline;\n```\n\n### Step 2 - Create a new connector instance\nYou can now make the connection configuration using the access token.\n```ballerina\npipeline:ClientConfig clientConfig = {\n auth : {\n token: \n }\n};\n\npipeline:Client baseClient = check new Client(clientConfig);\n\n```\n\n### Step 3 - Invoke connector operation\n1. Create a pipeline instance\n\n```ballerina\npipeline:PipelineInput event = {\n stages: [\n {\n label: \"In progress\",\n displayOrder: 0,\n metadata: {\n \"ticketState\": \"OPEN\",\n \"probability\": 0.5\n }\n }\n ],\n label: \"My replaced pipeline\",\n displayOrder: 0\n};\n\npipeline:PipelineInput|error bEvent = baseClient->create(\"deals\", event);\n\nif (bEvent is pipeline:PipelineInput) {\n log:printInfo(\"Created the pipeline\" + bEvent.toString());\n} else {\n log:printError(msg = bEvent.toString());\n}\n```\n\n2. List pipelines\n\n```ballerina\npipeline:CollectionResponsePipeline|error bEvent = baseClient->getAll(\"deals\");\n\nif (bEvent is pipeline:CollectionResponsePipeline) {\n log:printInfo(\"Pipeline list\" + bEvent.toString());\n} else {\n log:printError(msg = bEvent.message());\n}\n```\n\n3. Use `bal run` command to compile and run the Ballerina program" - } - ], - "balToolId": "" - }, - { - "organization": "ballerinax", - "name": "workday.absencemanagement", - "version": "1.5.1", - "platform": "any", - "languageSpecificationVersion": "2022R4", - "isDeprecated": false, - "deprecateMessage": "", - "URL": "/ballerinax/workday.absencemanagement/1.5.1", - "balaVersion": "2.0.0", - "balaURL": "https://fileserver.central.ballerina.io/2.0/ballerinax/workday.absencemanagement/1.5.1/ballerinax-workday.absencemanagement-any-1.5.1.bala?md5=Hge9ZSwRJlNzYfoxKlpKZQ&expires=1686819192", - "digest": "sha-256=3d941ad90502c62d6ec2d475e20af6977be7f9fbd36470d3b64b76d69cb64bbe", - "summary": "Connects to [Workday Absence Management API v1](https://community.workday.com/sites/default/files/file-hosting/restapi/index.html) from Ballerina.", - "readme": "Connects to [Workday Absence Management API v1](https:\/\/community.workday.com\/sites\/default\/files\/file-hosting\/restapi\/index.html) from Ballerina.\n\n### Package Overview\n\nThe `ballerinax\/workday.absencemanagement` is a [Ballerina](https:\/\/ballerina.io\/) connector for Workday Absence Management API. \n\nThis package provides the capability to easily access Workday Absence Management related endpoints.\n\n#### Compatibility\n| | Version |\n|-------------------------------|----------------------------|\n| Ballerina Language Version | Ballerina Swan Lake 2201.4.1 |\n| API Version | v1 |\n\n## Report issues\nTo report bugs, request new features, start new discussions, view project boards, etc., go to the [Ballerina Extended Library repository](https:\/\/github.com\/ballerina-platform\/ballerina-extended-library)\n\n## Useful links\n- Discuss code changes of the Ballerina project in [ballerina-dev@googlegroups.com](mailto:ballerina-dev@googlegroups.com).\n- Chat live with us via our [Discord server](https:\/\/discord.gg\/ballerinalang).\n- Post all technical questions on Stack Overflow with the [#ballerina](https:\/\/stackoverflow.com\/questions\/tagged\/ballerina) tag", - "template": false, - "licenses": [ - "Apache-2.0" - ], - "authors": [ - "Ballerina" - ], - "sourceCodeLocation": "https://github.com/ballerina-platform/openapi-connectors/tree/main/openapi/workday.absencemanagement", - "keywords": [ - "Human Resources/HRMS", - "Cost/Paid" - ], - "ballerinaVersion": "2201.4.1", - "icon": "https://bcentral-packageicons.azureedge.net/images/ballerinax_workday.absencemanagement_1.5.1.png", - "ownerUUID": "9712bf21-e852-48ba-83f0-2c7c5262cb6d", - "createdDate": 1683811427000, - "pullCount": 0, - "visibility": "public", - "modules": [ + "name": "hubspot.marketing", + "version": "2.3.1", + "organization": "ballerinax" + }, + { + "name": "hubspot.crm.import", + "version": "2.3.1", + "organization": "ballerinax" + }, + { + "name": "hubspot.crm.ticket", + "version": "2.3.1", + "organization": "ballerinax" + }, + { + "name": "hubspot.crm.product", + "version": "2.3.1", + "organization": "ballerinax" + }, + { + "name": "hubspot.files", + "version": "2.3.1", + "organization": "ballerinax" + }, + { + "name": "hubspot.analytics", + "version": "2.3.1", + "organization": "ballerinax" + }, + { + "name": "googleapis.vision", + "version": "1.6.1", + "organization": "ballerinax" + }, + { + "name": "azure.datalake", + "version": "1.5.1", + "organization": "ballerinax" + }, + { + "name": "azure.keyvault", + "version": "1.6.0", + "organization": "ballerinax" + }, + { + "name": "azure.sqldb", + "version": "1.5.1", + "organization": "ballerinax" + }, + { + "name": "ebay.browse", + "version": "1.5.1", + "organization": "ballerinax" + }, + { + "name": "azure.iothub", + "version": "1.5.1", + "organization": "ballerinax" + }, + { + "name": "flatapi", + "version": "1.5.1", + "organization": "ballerinax" + }, + { + "name": "confluent.cavroserdes", + "version": "0.1.0", + "organization": "ballerinax" + }, + { + "name": "ellucian.studentcharges", + "version": "1.0.0", + "organization": "ballerinax" + }, + { + "name": "interzoid.currencyexchange", + "version": "0.1.0", + "organization": "ballerinax" + }, { - "packageURL": "/ballerinax/workday.absencemanagement/1.5.1", - "apiDocURL": "https://lib.ballerina.io/ballerinax/workday.absencemanagement/1.5.1", - "name": "workday.absencemanagement", - "summary": "This is a generated connector for [WorkDay AbsenceManagement REST API v1](https://community.workday.com/sites/default/files/file-hosting/restapi/index.html) OpenAPI specification.", - "readme": "## Overview\nThis is a generated connector for [WorkDay AbsenceManagement REST API v1](https:\/\/community.workday.com\/sites\/default\/files\/file-hosting\/restapi\/index.html) OpenAPI specification.\n\nThe Absence Management service enables applications to access worker information about leaves of absence and time off details.\n \n \n## Prerequisites\n \nBefore using this connector in your Ballerina application, complete the following:\n \n* Create a workday application in the [Credential Administrator console](https:\/\/credentials.workday.com\/docs\/cred-admin)\n* Obtain tokens by following [this guide](https:\/\/credentials.workday.com\/docs\/getting-started\/)" + "name": "Apache", + "version": "0.1.0", + "organization": "ballerinax" } - ], - "balToolId": "" + ] } - ], - "count": 488, - "offset": 150, - "limit": 10 + } } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_ballerinax_org.json b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_ballerinax_org.json index e25fe8bb39b7..ab3e4feaa413 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_ballerinax_org.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_ballerinax_org.json @@ -7,73 +7,178 @@ "description": "Test completions for ballerinax packages", "items": [ { - "label": "azure.ad", + "label": "azure_storage_service", "kind": "Module", "detail": "Module", - "insertText": "azure.ad", + "insertText": "azure_storage_service", "insertTextFormat": "Snippet" }, { - "label": "hubspot.crm.quote", + "label": "azure_eventhub", "kind": "Module", "detail": "Module", - "insertText": "hubspot.crm.quote", + "insertText": "azure_eventhub", "insertTextFormat": "Snippet" }, { - "label": "powertoolsdeveloper.datetime", + "label": "prometheus", "kind": "Module", "detail": "Module", - "insertText": "powertoolsdeveloper.datetime", + "insertText": "prometheus", "insertTextFormat": "Snippet" }, { - "label": "azure.qnamaker", + "label": "asana", "kind": "Module", "detail": "Module", - "insertText": "azure.qnamaker", + "insertText": "asana", "insertTextFormat": "Snippet" }, { - "label": "godaddy.aftermarket", + "label": "trigger.asb", "kind": "Module", "detail": "Module", - "insertText": "godaddy.aftermarket", + "insertText": "trigger.asb", "insertTextFormat": "Snippet" }, { - "label": "googleapis.manufacturercenter", + "label": "shopify.admin", "kind": "Module", "detail": "Module", - "insertText": "googleapis.manufacturercenter", + "insertText": "shopify.admin", "insertTextFormat": "Snippet" }, { - "label": "cloudmersive.barcode", + "label": "newsapi", "kind": "Module", "detail": "Module", - "insertText": "cloudmersive.barcode", + "insertText": "newsapi", "insertTextFormat": "Snippet" }, { - "label": "saps4hana.wls.screeninghits", + "label": "hubspot.crm.company", "kind": "Module", "detail": "Module", - "insertText": "saps4hana.wls.screeninghits", + "insertText": "hubspot.crm.company", "insertTextFormat": "Snippet" }, { - "label": "hubspot.crm.pipeline", + "label": "hubspot.marketing", "kind": "Module", "detail": "Module", - "insertText": "hubspot.crm.pipeline", + "insertText": "hubspot.marketing", "insertTextFormat": "Snippet" }, { - "label": "workday.absencemanagement", + "label": "hubspot.crm.import", "kind": "Module", "detail": "Module", - "insertText": "workday.absencemanagement", + "insertText": "hubspot.crm.import", + "insertTextFormat": "Snippet" + }, + { + "label": "hubspot.crm.ticket", + "kind": "Module", + "detail": "Module", + "insertText": "hubspot.crm.ticket", + "insertTextFormat": "Snippet" + }, + { + "label": "hubspot.crm.product", + "kind": "Module", + "detail": "Module", + "insertText": "hubspot.crm.product", + "insertTextFormat": "Snippet" + }, + { + "label": "hubspot.files", + "kind": "Module", + "detail": "Module", + "insertText": "hubspot.files", + "insertTextFormat": "Snippet" + }, + { + "label": "hubspot.analytics", + "kind": "Module", + "detail": "Module", + "insertText": "hubspot.analytics", + "insertTextFormat": "Snippet" + }, + { + "label": "googleapis.vision", + "kind": "Module", + "detail": "Module", + "insertText": "googleapis.vision", + "insertTextFormat": "Snippet" + }, + { + "label": "azure.datalake", + "kind": "Module", + "detail": "Module", + "insertText": "azure.datalake", + "insertTextFormat": "Snippet" + }, + { + "label": "azure.keyvault", + "kind": "Module", + "detail": "Module", + "insertText": "azure.keyvault", + "insertTextFormat": "Snippet" + }, + { + "label": "azure.sqldb", + "kind": "Module", + "detail": "Module", + "insertText": "azure.sqldb", + "insertTextFormat": "Snippet" + }, + { + "label": "ebay.browse", + "kind": "Module", + "detail": "Module", + "insertText": "ebay.browse", + "insertTextFormat": "Snippet" + }, + { + "label": "azure.iothub", + "kind": "Module", + "detail": "Module", + "insertText": "azure.iothub", + "insertTextFormat": "Snippet" + }, + { + "label": "flatapi", + "kind": "Module", + "detail": "Module", + "insertText": "flatapi", + "insertTextFormat": "Snippet" + }, + { + "label": "confluent.cavroserdes", + "kind": "Module", + "detail": "Module", + "insertText": "confluent.cavroserdes", + "insertTextFormat": "Snippet" + }, + { + "label": "ellucian.studentcharges", + "kind": "Module", + "detail": "Module", + "insertText": "ellucian.studentcharges", + "insertTextFormat": "Snippet" + }, + { + "label": "interzoid.currencyexchange", + "kind": "Module", + "detail": "Module", + "insertText": "interzoid.currencyexchange", + "insertTextFormat": "Snippet" + }, + { + "label": "Apache", + "kind": "Module", + "detail": "Module", + "insertText": "Apache", "insertTextFormat": "Snippet" } ] diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_ballerinax_org2.json b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_ballerinax_org2.json index 1459ef4ee62f..33501c399f13 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_ballerinax_org2.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_ballerinax_org2.json @@ -7,20 +7,58 @@ "description": "Test completions for ballerinax packages", "items": [ { - "label": "azure.ad", + "label": "azure.sqldb", "kind": "Module", "detail": "Module", "sortText": "D", - "insertText": "azure.ad", - "insertTextFormat": "Snippet" + "insertText": "azure.sqldb", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] }, { - "label": "azure.qnamaker", + "label": "azure.datalake", "kind": "Module", "detail": "Module", "sortText": "D", - "insertText": "azure.qnamaker", - "insertTextFormat": "Snippet" + "insertText": "azure.datalake", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "azure.iothub", + "kind": "Module", + "detail": "Module", + "sortText": "D", + "insertText": "azure.iothub", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "azure.keyvault", + "kind": "Module", + "detail": "Module", + "sortText": "D", + "insertText": "azure.keyvault", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "azure_storage_service", + "kind": "Module", + "detail": "Module", + "sortText": "D", + "insertText": "azure_storage_service", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] + }, + { + "label": "azure_eventhub", + "kind": "Module", + "detail": "Module", + "sortText": "D", + "insertText": "azure_eventhub", + "insertTextFormat": "Snippet", + "additionalTextEdits": [] } ] } diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_ballerinax_org3.json b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_ballerinax_org3.json index 51944bd5a5e1..9fc377ae5bf2 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_ballerinax_org3.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_ballerinax_org3.json @@ -7,11 +7,11 @@ "description": "Test completions for ballerinax packages", "items": [ { - "label": "azure.ad", + "label": "azure.sqldb", "kind": "Module", "detail": "Module", "sortText": "A", - "insertText": "azure.ad", + "insertText": "azure.sqldb", "insertTextFormat": "Snippet", "additionalTextEdits": [ { @@ -30,11 +30,103 @@ ] }, { - "label": "azure.qnamaker", + "label": "azure.datalake", "kind": "Module", "detail": "Module", "sortText": "A", - "insertText": "azure.qnamaker", + "insertText": "azure.datalake", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 18 + }, + "end": { + "line": 1, + "character": 0 + } + }, + "newText": "" + } + ] + }, + { + "label": "azure.iothub", + "kind": "Module", + "detail": "Module", + "sortText": "A", + "insertText": "azure.iothub", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 18 + }, + "end": { + "line": 1, + "character": 0 + } + }, + "newText": "" + } + ] + }, + { + "label": "azure.keyvault", + "kind": "Module", + "detail": "Module", + "sortText": "A", + "insertText": "azure.keyvault", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 18 + }, + "end": { + "line": 1, + "character": 0 + } + }, + "newText": "" + } + ] + }, + { + "label": "azure_storage_service", + "kind": "Module", + "detail": "Module", + "sortText": "D", + "insertText": "azure_storage_service", + "insertTextFormat": "Snippet", + "additionalTextEdits": [ + { + "range": { + "start": { + "line": 0, + "character": 18 + }, + "end": { + "line": 1, + "character": 0 + } + }, + "newText": "" + } + ] + }, + { + "label": "azure_eventhub", + "kind": "Module", + "detail": "Module", + "sortText": "D", + "insertText": "azure_eventhub", "insertTextFormat": "Snippet", "additionalTextEdits": [ { diff --git a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_ballerinax_org4.json b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_ballerinax_org4.json index 9409a3f7e94e..d72125da4e49 100644 --- a/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_ballerinax_org4.json +++ b/language-server/modules/langserver-core/src/test/resources/completion/import_decl/config/import_decl_with_ballerinax_org4.json @@ -5,29 +5,5 @@ }, "source": "import_decl/source/import_decl_with_ballerinax_org4.bal", "description": "Test completions for ballerinax packages", - "items": [ - { - "label": "azure.ad", - "kind": "Module", - "detail": "Module", - "sortText": "A", - "insertText": "azure.ad", - "insertTextFormat": "Snippet", - "additionalTextEdits": [ - { - "range": { - "start": { - "line": 0, - "character": 18 - }, - "end": { - "line": 0, - "character": 24 - } - }, - "newText": "" - } - ] - } - ] + "items": [] } diff --git a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/variables/VariableVisibilityTest.java b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/variables/VariableVisibilityTest.java index 9db72a68f1fb..e9835ebd76fe 100644 --- a/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/variables/VariableVisibilityTest.java +++ b/tests/jballerina-debugger-integration-test/src/test/java/org/ballerinalang/debugger/test/adapter/variables/VariableVisibilityTest.java @@ -35,6 +35,7 @@ import java.util.Map; import static org.ballerinalang.debugger.test.utils.DebugTestRunner.VariableScope; + /** * Test class for variable visibility. */ @@ -48,13 +49,14 @@ public class VariableVisibilityTest extends BaseTestCase { @Override @BeforeClass public void setup() { - String testProjectName = "variable-tests"; - String testModuleFileName = "main.bal"; - debugTestRunner = new DebugTestRunner(testProjectName, testModuleFileName, true); } @Test(description = "Variable visibility test at the beginning(first line) of the main() method") public void initialVariableVisibilityTest() throws BallerinaTestException { + String testProjectName = "variable-tests"; + String testModuleFileName = "main.bal"; + debugTestRunner = new DebugTestRunner(testProjectName, testModuleFileName, true); + debugTestRunner.addBreakPoint(new BallerinaTestDebugPoint(debugTestRunner.testEntryFilePath, 123)); debugTestRunner.initDebugSession(DebugUtils.DebuggeeExecutionKind.RUN); debugHitInfo = debugTestRunner.waitForDebugHit(25000); @@ -70,6 +72,10 @@ public void initialVariableVisibilityTest() throws BallerinaTestException { @Test(description = "Variable visibility test in the middle of the main() method for a new variable") public void newVariableVisibilityTest() throws BallerinaTestException { + String testProjectName = "variable-tests"; + String testModuleFileName = "main.bal"; + debugTestRunner = new DebugTestRunner(testProjectName, testModuleFileName, true); + debugTestRunner.addBreakPoint(new BallerinaTestDebugPoint(debugTestRunner.testEntryFilePath, 245)); debugTestRunner.addBreakPoint(new BallerinaTestDebugPoint(debugTestRunner.testEntryFilePath, 316)); debugTestRunner.initDebugSession(DebugUtils.DebuggeeExecutionKind.RUN); @@ -105,6 +111,10 @@ public void newVariableVisibilityTest() throws BallerinaTestException { @Test(description = "Variable visibility test in control flows") public void controlFlowVariableVisibilityTest() throws BallerinaTestException { + String testProjectName = "variable-tests"; + String testModuleFileName = "main.bal"; + debugTestRunner = new DebugTestRunner(testProjectName, testModuleFileName, true); + debugTestRunner.addBreakPoint(new BallerinaTestDebugPoint(debugTestRunner.testEntryFilePath, 266)); debugTestRunner.addBreakPoint(new BallerinaTestDebugPoint(debugTestRunner.testEntryFilePath, 270)); debugTestRunner.addBreakPoint(new BallerinaTestDebugPoint(debugTestRunner.testEntryFilePath, 277)); @@ -177,6 +187,10 @@ public void controlFlowVariableVisibilityTest() throws BallerinaTestException { @Test(description = "Variable visibility test for global variables") public void globalVariableVisibilityTest() throws BallerinaTestException { + String testProjectName = "variable-tests"; + String testModuleFileName = "main.bal"; + debugTestRunner = new DebugTestRunner(testProjectName, testModuleFileName, true); + debugTestRunner.addBreakPoint(new BallerinaTestDebugPoint(debugTestRunner.testEntryFilePath, 352)); debugTestRunner.addBreakPoint(new BallerinaTestDebugPoint(debugTestRunner.testEntryFilePath, 327)); debugTestRunner.initDebugSession(DebugUtils.DebuggeeExecutionKind.RUN); @@ -215,6 +229,10 @@ public void globalVariableVisibilityTest() throws BallerinaTestException { @Test(description = "Variable visibility test for local variables at the last line of main() method") public void localVariableVisibilityTest() throws BallerinaTestException { + String testProjectName = "variable-tests"; + String testModuleFileName = "main.bal"; + debugTestRunner = new DebugTestRunner(testProjectName, testModuleFileName, true); + debugTestRunner.addBreakPoint(new BallerinaTestDebugPoint(debugTestRunner.testEntryFilePath, 327)); debugTestRunner.addBreakPoint(new BallerinaTestDebugPoint(debugTestRunner.testEntryFilePath, 360)); debugTestRunner.initDebugSession(DebugUtils.DebuggeeExecutionKind.RUN); @@ -339,6 +357,10 @@ public void localVariableVisibilityTest() throws BallerinaTestException { @Test(enabled = false, description = "Child variable visibility test for local variables at the last line of main" + "() method") public void localVariableChildrenVisibilityTest() throws BallerinaTestException { + String testProjectName = "variable-tests"; + String testModuleFileName = "main.bal"; + debugTestRunner = new DebugTestRunner(testProjectName, testModuleFileName, true); + debugTestRunner.addBreakPoint(new BallerinaTestDebugPoint(debugTestRunner.testEntryFilePath, 327)); debugTestRunner.initDebugSession(DebugUtils.DebuggeeExecutionKind.RUN); debugHitInfo = debugTestRunner.waitForDebugHit(25000); @@ -352,18 +374,18 @@ public void localVariableChildrenVisibilityTest() throws BallerinaTestException // xml attributes child variable visibility test Map xmlAttributesChildVariables = - debugTestRunner.fetchChildVariables(xmlChildVariables.get("attributes")); + debugTestRunner.fetchChildVariables(xmlChildVariables.get("attributes")); debugTestRunner.assertVariable(xmlAttributesChildVariables, "gender", "\"male\"", "string"); // xml children variable visibility test Map xmlChildrenVariables = - debugTestRunner.fetchChildVariables(xmlChildVariables.get("children")); + debugTestRunner.fetchChildVariables(xmlChildVariables.get("children")); debugTestRunner.assertVariable(xmlChildrenVariables, "[0]", "XMLElement", "xml"); debugTestRunner.assertVariable(xmlChildrenVariables, "[1]", "XMLElement", "xml"); // xml grand children variable visibility test Map xmlGrandChildrenVariables = - debugTestRunner.fetchChildVariables(xmlChildrenVariables.get("[0]")); + debugTestRunner.fetchChildVariables(xmlChildrenVariables.get("[0]")); debugTestRunner.assertVariable(xmlGrandChildrenVariables, "children", "XMLSequence (size = 1)", "xml"); // array child variable visibility test @@ -391,7 +413,7 @@ public void localVariableChildrenVisibilityTest() throws BallerinaTestException // record child variable visibility test (Student record) Map studentRecordChildVariables = - debugTestRunner.fetchChildVariables(localVariables.get("recordVar")); + debugTestRunner.fetchChildVariables(localVariables.get("recordVar")); debugTestRunner.assertVariable(studentRecordChildVariables, "1st_name", "\"John Doe\"", "string"); debugTestRunner.assertVariable(studentRecordChildVariables, "grades", "Grades", "record"); debugTestRunner.assertVariable(studentRecordChildVariables, "Ȧɢέ_ /:@[`{~π", "20", "int"); @@ -399,7 +421,7 @@ public void localVariableChildrenVisibilityTest() throws BallerinaTestException // record child variable visibility test (Grades record) Map gradesChildVariables = - debugTestRunner.fetchChildVariables(studentRecordChildVariables.get("grades")); + debugTestRunner.fetchChildVariables(studentRecordChildVariables.get("grades")); debugTestRunner.assertVariable(gradesChildVariables, "chemistry", "65", "int"); debugTestRunner.assertVariable(gradesChildVariables, "maths", "80", "int"); debugTestRunner.assertVariable(gradesChildVariables, "physics", "75", "int"); @@ -407,7 +429,7 @@ public void localVariableChildrenVisibilityTest() throws BallerinaTestException // anonymous record child variable visibility test Map recordChildVariables = - debugTestRunner.fetchChildVariables(localVariables.get("anonRecord")); + debugTestRunner.fetchChildVariables(localVariables.get("anonRecord")); debugTestRunner.assertVariable(recordChildVariables, "city", "\"London\"", "string"); debugTestRunner.assertVariable(recordChildVariables, "country", "\"UK\"", "string"); @@ -418,18 +440,18 @@ public void localVariableChildrenVisibilityTest() throws BallerinaTestException // error details child variable visibility test Map errorDetailsChildVariables = - debugTestRunner.fetchChildVariables(errorChildVariables.get("details")); + debugTestRunner.fetchChildVariables(errorChildVariables.get("details")); debugTestRunner.assertVariable(errorDetailsChildVariables, "message", "\"Simple error occurred\"", "string"); // future child variable visibility test Map futureChildVariables = - debugTestRunner.fetchChildVariables(localVariables.get("futureVar")); + debugTestRunner.fetchChildVariables(localVariables.get("futureVar")); debugTestRunner.assertVariable(futureChildVariables, "isDone", "true", "boolean"); debugTestRunner.assertVariable(futureChildVariables, "result", "90", "int"); // object child variable visibility test (Person object) Map personObjectChildVariables = - debugTestRunner.fetchChildVariables(localVariables.get("objectVar")); + debugTestRunner.fetchChildVariables(localVariables.get("objectVar")); debugTestRunner.assertVariable(personObjectChildVariables, "1st_name", "\"John\"", "string"); debugTestRunner.assertVariable(personObjectChildVariables, "address", "\"No 20, Palm grove\"", "string"); debugTestRunner.assertVariable(personObjectChildVariables, "parent", "()", "nil"); @@ -438,7 +460,7 @@ public void localVariableChildrenVisibilityTest() throws BallerinaTestException // anonymous object child variable visibility test (AnonPerson object) Map anonObjectChildVariables = - debugTestRunner.fetchChildVariables(localVariables.get("anonObjectVar")); + debugTestRunner.fetchChildVariables(localVariables.get("anonObjectVar")); debugTestRunner.assertVariable(anonObjectChildVariables, "1st_name", "\"John\"", "string"); debugTestRunner.assertVariable(anonObjectChildVariables, "address", "\"No 20, Palm grove\"", "string"); debugTestRunner.assertVariable(anonObjectChildVariables, "parent", "()", "nil"); @@ -459,21 +481,21 @@ public void localVariableChildrenVisibilityTest() throws BallerinaTestException // table with key child variable visibility test Map tableWithKeyChildVariables = - debugTestRunner.fetchChildVariables(localVariables.get("tableWithKeyVar")); + debugTestRunner.fetchChildVariables(localVariables.get("tableWithKeyVar")); debugTestRunner.assertVariable(tableWithKeyChildVariables, "[0]", "Employee", "record"); debugTestRunner.assertVariable(tableWithKeyChildVariables, "[1]", "Employee", "record"); debugTestRunner.assertVariable(tableWithKeyChildVariables, "[2]", "Employee", "record"); // table without key child variable visibility test Map tableWithoutKeyChildVariables = - debugTestRunner.fetchChildVariables(localVariables.get("tableWithoutKeyVar")); + debugTestRunner.fetchChildVariables(localVariables.get("tableWithoutKeyVar")); debugTestRunner.assertVariable(tableWithoutKeyChildVariables, "[0]", "Employee", "record"); debugTestRunner.assertVariable(tableWithoutKeyChildVariables, "[1]", "Employee", "record"); debugTestRunner.assertVariable(tableWithoutKeyChildVariables, "[2]", "Employee", "record"); // service child variable visibility test Map serviceChildVariables = - debugTestRunner.fetchChildVariables(localVariables.get("serviceVar")); + debugTestRunner.fetchChildVariables(localVariables.get("serviceVar")); debugTestRunner.assertVariable(serviceChildVariables, "i", "5", "int"); } @@ -550,6 +572,68 @@ public void workerVariableVisibilityTest() throws BallerinaTestException { } } + @Test(description = "Binding pattern variables related visibility test") + public void bindingPatternVariableVisibilityTest() throws BallerinaTestException { + String testProjectName = "variable-tests-2"; + String testModuleFileName = "main.bal"; + debugTestRunner = new DebugTestRunner(testProjectName, testModuleFileName, true); + + debugTestRunner.addBreakPoint(new BallerinaTestDebugPoint(debugTestRunner.testEntryFilePath, 35)); + debugTestRunner.addBreakPoint(new BallerinaTestDebugPoint(debugTestRunner.testEntryFilePath, 40)); + debugTestRunner.addBreakPoint(new BallerinaTestDebugPoint(debugTestRunner.testEntryFilePath, 43)); + debugTestRunner.addBreakPoint(new BallerinaTestDebugPoint(debugTestRunner.testEntryFilePath, 46)); + debugTestRunner.addBreakPoint(new BallerinaTestDebugPoint(debugTestRunner.testEntryFilePath, 49)); + debugTestRunner.addBreakPoint(new BallerinaTestDebugPoint(debugTestRunner.testEntryFilePath, 80)); + + debugTestRunner.initDebugSession(DebugUtils.DebuggeeExecutionKind.RUN); + Pair debugHitInfo = debugTestRunner.waitForDebugHit(25000); + + // simple binding pattern variables + localVariables = debugTestRunner.fetchVariables(debugHitInfo.getRight(), DebugTestRunner.VariableScope.LOCAL); + debugTestRunner.assertVariable(localVariables, "profession", "\"Software Engineer\"", "string"); + + // list binding pattern variables + debugTestRunner.resumeProgram(debugHitInfo.getRight(), DebugTestRunner.DebugResumeKind.NEXT_BREAKPOINT); + debugHitInfo = debugTestRunner.waitForDebugHit(10000); + // TODO: enable after fixing runtime issue https://github.com/ballerina-platform/ballerina-lang/issues/43623 +// localVariables = debugTestRunner.fetchVariables(debugHitInfo.getRight(), DebugTestRunner.VariableScope.LOCAL); +// debugTestRunner.assertVariable(localVariables, "id", "1234", "int"); +// debugTestRunner.assertVariable(localVariables, "firstName", "\"John Doe\"", "string"); + + // mapping binding pattern variables + debugTestRunner.resumeProgram(debugHitInfo.getRight(), DebugTestRunner.DebugResumeKind.NEXT_BREAKPOINT); + debugHitInfo = debugTestRunner.waitForDebugHit(10000); + // TODO: enable after fixing runtime issue https://github.com/ballerina-platform/ballerina-lang/issues/43623 +// localVariables = debugTestRunner.fetchVariables(debugHitInfo.getRight(), DebugTestRunner.VariableScope.LOCAL); +// debugTestRunner.assertVariable(localVariables, "givenName", "\"Anne\"", "string"); +// debugTestRunner.assertVariable(localVariables, "surName", "\"Frank\"", "string"); + + // error binding pattern variables + debugTestRunner.resumeProgram(debugHitInfo.getRight(), DebugTestRunner.DebugResumeKind.NEXT_BREAKPOINT); + debugHitInfo = debugTestRunner.waitForDebugHit(10000); + // TODO: enable after fixing runtime issue https://github.com/ballerina-platform/ballerina-lang/issues/43623 +// localVariables = debugTestRunner.fetchVariables(debugHitInfo.getRight(), DebugTestRunner.VariableScope.LOCAL); +// debugTestRunner.assertVariable(localVariables, "cause", "\"Database Error\"", "error"); +// debugTestRunner.assertVariable(localVariables, "code", "20", "int"); +// debugTestRunner.assertVariable(localVariables, "reason", "\"deadlock condition\"", "string"); + + // list binding pattern inside foreach statement + debugTestRunner.resumeProgram(debugHitInfo.getRight(), DebugTestRunner.DebugResumeKind.NEXT_BREAKPOINT); + debugHitInfo = debugTestRunner.waitForDebugHit(10000); + localVariables = debugTestRunner.fetchVariables(debugHitInfo.getRight(), DebugTestRunner.VariableScope.LOCAL); + debugTestRunner.assertVariable(localVariables, "name", "\"John\"", "string"); + debugTestRunner.assertVariable(localVariables, "age", "30", "int"); + + // list binding patterns inside match statement + debugTestRunner.resumeProgram(debugHitInfo.getRight(), DebugTestRunner.DebugResumeKind.NEXT_BREAKPOINT); + debugHitInfo = debugTestRunner.waitForDebugHit(10000); + // TODO: enable after fixing runtime issue https://github.com/ballerina-platform/ballerina-lang/issues/43623 +// localVariables = debugTestRunner.fetchVariables(debugHitInfo.getRight(), DebugTestRunner.VariableScope.LOCAL); +// debugTestRunner.assertVariable(localVariables, "remove", "Remove", "string"); +// debugTestRunner.assertVariable(localVariables, "all", "*", "string"); +// debugTestRunner.assertVariable(localVariables, "isDir", "true", "boolean"); + } + @Override @AfterMethod(alwaysRun = true) public void cleanUp() { diff --git a/tests/jballerina-debugger-integration-test/src/test/resources/project-based-tests/variable-tests-2/Ballerina.toml b/tests/jballerina-debugger-integration-test/src/test/resources/project-based-tests/variable-tests-2/Ballerina.toml new file mode 100644 index 000000000000..7352e4440b5f --- /dev/null +++ b/tests/jballerina-debugger-integration-test/src/test/resources/project-based-tests/variable-tests-2/Ballerina.toml @@ -0,0 +1,4 @@ +[package] +org = "debug_test_resources" +name = "variable_tests_2" +version = "0.1.0" diff --git a/tests/jballerina-debugger-integration-test/src/test/resources/project-based-tests/variable-tests-2/main.bal b/tests/jballerina-debugger-integration-test/src/test/resources/project-based-tests/variable-tests-2/main.bal new file mode 100644 index 000000000000..12fefe845eb4 --- /dev/null +++ b/tests/jballerina-debugger-integration-test/src/test/resources/project-based-tests/variable-tests-2/main.bal @@ -0,0 +1,99 @@ +// Copyright (c) 2024 WSO2 LLC. (http://www.wso2.org). +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +type Person record {| + int id; + string fname; + string lname; +|}; + +type SampleErrorData record {| + int code; + string reason; +|}; + +type SampleError error; + +public function main() { + // 1. simple binding pattern + var profession = "Software Engineer"; + + // 2. list binding pattern + [int, [string, string]] [id, [firstName, _]] = getDetails(); + + // 3. mapping binding pattern + string givenName; + string surname; + {fname: givenName, lname: surname} = getPerson(); + + // 4. error binding pattern + var error(_, cause, code = code, reason = reason) = getSampleError(); + + // 5. binding patterns inside a foreach statement + string names = ""; + [string, int][] personInfoList = getPersonInfo(); + foreach [string, int] [name, age] in personInfoList { + names += " " + name; + } + + // 6. binding patterns inside a match statement + matchCommand(["Remove", "*", true]); +} + +function getDetails() returns [int, [string, string]] { + return [ + 1234, + ["John", "Doe"] + ]; +} + +function getPerson() returns Person { + Person person = {id: 1001, fname: "Anne", lname: "Frank"}; + return person; +} + +function getSampleError() returns SampleError { + return error("Transaction Failure", error("Database Error"), code = 20, reason = "deadlock condition"); +} + +function matchCommand(any commands) { + match commands { + var [show] => { + string name = "show"; + } + // The list binding pattern below binds lists that contain three list items + // where the third element in the list is the boolean value `true`. + var [remove, all, isDir] if isDir is true => { + string name = "remove"; + } + // The list binding pattern below binds lists that contain three list items. + var [remove, all, _] => { + string name = "remove"; + } + // The list binding pattern below binds lists that contain two list items, + // in which the second list item is also a list of two items. + var [copy, [file1, file2]] => { + string name = "copy"; + } + _ => { + string name = "unknown"; + } + } +} + +function getPersonInfo() returns [string, int][] { + return [["John", 30]]; +} diff --git a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/mappingconstructor/MappingConstructorExprTest.java b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/mappingconstructor/MappingConstructorExprTest.java index 9a2c6b1f7a23..2716d4a63c97 100644 --- a/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/mappingconstructor/MappingConstructorExprTest.java +++ b/tests/jballerina-unit-test/src/test/java/org/ballerinalang/test/expressions/mappingconstructor/MappingConstructorExprTest.java @@ -318,7 +318,8 @@ public Object[][] spreadOpFieldTests() { { "testSpreadOpInGlobalMap" }, { "testMappingConstrExprAsSpreadExpr" }, { "testSpreadFieldWithRecordTypeHavingNeverField" }, - { "testSpreadFieldWithRecordTypeHavingRestDescriptor" } + { "testSpreadFieldWithRecordTypeHavingRestDescriptor" }, + { "testSpreadFieldWithRecordTypeReference" } }; } diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/expressions/mappingconstructor/spread_op_field.bal b/tests/jballerina-unit-test/src/test/resources/test-src/expressions/mappingconstructor/spread_op_field.bal index ad1e89a00c3c..e36531597120 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/expressions/mappingconstructor/spread_op_field.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/expressions/mappingconstructor/spread_op_field.bal @@ -298,6 +298,32 @@ function testSpreadFieldWithRecordTypeHavingRestDescriptor() { assertEquality("s", r4.s); } +type RetryConfig record {| + int count; + decimal interval; + float backOffFactor; +|}; + +public type RetryConfigClone record {| + int count = 0; + decimal interval = 0; + float backOffFactor = 0.0; + decimal maxWaitInterval = 0; + int[] statusCodes = []; +|}; + +type RetryTyperef RetryConfigClone; + +function testSpreadFieldWithRecordTypeReference() { + RetryConfig rc = {count: 3, interval: 0.5, backOffFactor: 0.5}; + RetryTyperef re = {...rc}; + assertEquality(3, re.count); + assertEquality(0.5d, re.interval); + assertEquality(0.5, re.backOffFactor); + assertEquality(0d, re.maxWaitInterval); + assertEquality(0, re.statusCodes.length()); +} + function assertEquality(any|error expected, any|error actual) { if expected is anydata && actual is anydata && expected == actual { return;