Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hlquery logo

A typed TypeScript client library for hlquery, designed with a familiar modular API structure.

Follow hlquery TypeScript build type-api hlquery License

What is the hlquery TypeScript API?

The hlquery TypeScript API is the official TypeScript client for hlquery. It wraps the HTTP/JSON interface in typed classes so TypeScript and Node.js applications can work with hlquery without manually assembling URLs, request bodies, auth headers, and response parsing.

The library follows the same modular service layout as the JavaScript client: collections, documents, search, SQL, aliases, synonyms, stopwords, overrides, keys, and raw request access.

Why use it?

Use the TypeScript API when you want hlquery integration to be explicit, typed, and easy to refactor. The client keeps common operations readable, centralizes auth handling, and gives editors and build tools useful method signatures for the hlquery API surface.

Install

$ npm install hlquery-typescript-client

For local development inside this repository:

$ npm install
$ npm run build
$ npm test

Quick Start

import Client from 'hlquery-typescript-client';

const client = new Client(process.env.HLQ_BASE_URL || 'http://localhost:9200', {
  token: process.env.HLQ_TOKEN,
  auth_method: 'bearer',
});

const health = await client.health();
const collections = await client.collections().list(0, 10);

console.log(health.getStatusCode());
console.log(collections.getBody());

Example: Index and Search

import Client from 'hlquery-typescript-client';

async function main(): Promise<void> {
  const client = new Client('http://localhost:9200');

  await client.collections().create('products', {
    fields: [
      { name: 'id', type: 'string' },
      { name: 'title', type: 'string' },
      { name: 'content', type: 'string' },
      { name: 'price', type: 'float' },
    ],
    searchable_fields: ['title', 'content'],
    filterable_fields: ['price'],
    sortable_fields: ['price'],
  });

  await client.documents().add('products', {
    id: 'product1',
    title: 'Laptop Computer',
    content: 'High-performance laptop with 16GB RAM',
    price: 1299.99,
  });

  const results = await client.search('products', {
    q: 'laptop',
    query_by: ['title', 'content'],
    limit: 10,
  });

  console.log(results.getBody());
}

main().catch(console.error);

Contributing

We welcome contributions from the community! All contributions must be released under the BSD 3-Clause license.

How to Contribute

  • Check existing TypeScript API issues or create new ones
  • Contribute TypeScript client changes to hlquery/type-api
  • Contribute shared server/API changes to hlquery/hlquery
  • Test and report bugs against the TypeScript client
  • Improve TypeScript-specific documentation and examples

Search all collections

const result = await client.searchAll({ q: 'research', limit: 20 });
const selected = await client.searchAll({ body: { q: 'research', collections: ['universities', 'science'] } });

globalSearch remains available as an equivalent name. Results are globally merged and each hit includes document._collection.

Community

License

The hlquery TypeScript API is licensed under the BSD 3-Clause License.

About

TypeScript client library for hlquery with modular APIs, auth support, and type- safe responses.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages