npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@marklogic-community/grove-core-api

v1.0.0

Published

core OpenAPI 3.0 specifications for Grove-compliant middle-tiers

Downloads

3

Readme

grove-core-api

This project provides OpenAPI v3 specifications for Grove-compliant middle-tier implementations. It concerns the public-facing REST endpoints.

Principles

Design principles:

  1. Separation of concerns. In other words, the endpoints are divided into smaller distinct segments that can operate independently.
  2. Consistency. One single supported input and output format for all endpoints, being application/json.
  3. Simplicity. Tasks are broken into small pieces to avoid duplication of work.

Endpoints Overview

The baseline for Grove middle-tiers consists of 4 sets of endpoints:

  1. /api/auth: Authentication
  2. /api/{type}/id: CRUD for a specific type
  3. /api/search/{type}: Search for a specific type

By convention, Grove middle-tier implementations include CRUD and Search for the (pseudo-)type 'all'.

Endpoints Detail

/auth

Authentication is specified in spec/auth-api.json.

CRUD

CRUD is specified in spec/crud-api.json.

/search

Search is specified in spec/search-api.json.

Three endpoints are specified for /search, allowing the consumer to request results-only, facets-only, or the combination of the two:

/search/{type}/results
/search/{type}/facets
/search/{type}

The type parameter allows several different searches to be mounted. By convention, Grove middle-tiers, out-of-the-box, will support an all pseudo-type that implements generic search-and-discovery against documents stored in the database (potentially within a "data" collection). Particular applications can modify the search or mount additional search endpoints, perhaps changing the type to entities like "patients" or concepts like "raw" or "harmonized". The exact meaning of those types (and implementation of typed searches) will be up to the middle-tier implementation.

All requests against these endpoints are POST requests, allowing the search filters and options to be arbitrarily large in the request body. The request and response bodies are very similar for each of the three endpoints.

Search Request

A search request includes two top-level properties: options and filters.

options includes start and pageLength for pagination, and can be arbitrarily expanded to cover other concepts understood by both the UI and the middle-tier.

filters specify the search query.

In the Grove search API, "filters" refer to values applied, typically by a user through the UI, against "constraints", which are filter capabilities known to the middle-tier.

In Grove, "filter" and "constraint" are broad terms which do not specify how a particular constraint operates. They could be backed by a MarkLogic Search API constraint, a MarkLogic REST extension using cts queries, or even some Elasticsearch implementation.

In this spec, we aim to strike a balance between expressive power and convenience for UI developers. Most filter interfaces will be fairly simple, such as a search bar or selectable list of facets. Authors of such components should not be burdened with complicated filter structures. Advanced search interfaces, however, are possible within the Grove search spec as recursive combinations of simpler filters.

The basic filter types described by this spec include:

  1. QueryTextFilter. Yes, even qtext is treated as a filter value matched against a search constraint. This is typically a simple string for full-text searching, though it can optionally include a "constraint" name. A middle-tier implmentation could use that "constraint" name to handle the queryText in a special way, such as searching against a field in MarkLogic that is narrower than full-text search.

  2. SelectionFilter. This filter allows for individual values to be ANDed or ORed (but not both) together against a search constraint. The values can optionally be negated. A SelectionFilter is only one level deep, which corresponds to simple facet UIs. More complicated selections can be modeled using the CombinedFilter described below.

  3. RangeFilter. This filter allows ranges of values to be matched against a search constraint. It is designed to support most types of dynamic inequalities, like date or number ranges, mins or maxes. Like SelectionFilter, it is intentionally simple and tailored for ease of use in creating range-selection UI components.

These three basic filter types can be combined recursively using AND, OR, NOT, and NEAR in order to populate the "filters" field (called "CombinedFilter" in the spec document). The UI thus has control over how individual filters should be combined and can encode advanced queries. CombinedFilter uses the expressiveness of MarkLogic's REST API search grammar as a model.

Additional filter types can easily be plugged into a Grove Project as needed. These could be highly specialized or very generic like the ones above.

Search Response

The specified SearchResponse is mostly a subset of the response from the MarkLogic Search API. (The one addition is an "id" field, which may differ from document URI, allowing the application to express search over higher-level concepts or entities, rather than individual documents.) Results from other sources could be marshalled into the same structure. It covers some metadata, such as total and pagination properties, as well as facets and results.

We only specified certain properties used in out-of-the-box Grove UI implementations. The response can be expanded with additional properties by middle-tier implementations.

Testing an implementation

This project comes with a small VueJS page that can be used to run a quick test against your middle-tier of choice. It may require CORS to be disabled on that middle-tier.

Contributing

Validating specs

You can validate changes to spec/auth-api.json, spec/crud-api.json, and spec/search-api.json by running npm test. This will use the swagger-cli to validate changes.

If you add new spec files, you need to add them to the test script in package.json.