Skip to content

hlquery/type-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 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, SAM+, 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);

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors