Get NPM Component from Name & version

I need to get the NPM component by using the name and the version. What is the method that I can use here? For maven, I’ve used the below method.

    HashMap<String, String> filter = new HashMap<>(1);
    filter.put("version", coords.getVersion());
            context.getRepository(), coords.getGroupId(), coords.getArtifactId(), filter)

@mpiggott @dsawa Do you have any idea about this? I need to get Component or Asset object using the repository, name & version.

Ex: “logback”: “1.0.16”

The typical format for npm is:

npm install logback@1.0.16 --save

,or for a dev dependency

npm install logback@1.0.16 --save-dev

I need to get component or asset by using repository, artifact name and version. Below method is for Maven. Is there any method for NPM as npm doesn’t have group Id.

        context.getRepository(), coords.getGroupId(), coords.getArtifactId(), filter)

We can write a custom query method to get components by name & version.

    private List<Component> getAllMatchingComponents(Repository repository, String name, Map<String, String> formatAttributes) {
    List<Component> filteredComponents;
    try (StorageTx storageTx = repository.facet(StorageFacet.class).txSupplier().get()) {
        Query.Builder query = Query.builder().where("name").eq(name).suffix("order by version desc");
        Iterable<Component> unfilteredComponents = storageTx.findComponents(, Collections.singletonList(repository));
        Stream<Component> filteredStream =, false).filter(
                component -> formatAttributes.entrySet().stream().allMatch(
                        entry -> Objects.equals(entry.getValue(), component.version())));
        filteredComponents = ImmutableList.copyOf(filteredStream.iterator());

    return filteredComponents;