Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Publish to NPM

on:
push:
branches:
- main

permissions:
id-token: write # Required for npm provenance (OIDC)
contents: read

jobs:
publish:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'

- name: Update npm
run: npm install -g npm@latest

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test

- name: Build
run: npm run build

- name: Check if version exists on npm
id: version-check
run: |
PACKAGE_NAME=$(node -p "require('./package.json').name")
LOCAL_VERSION=$(node -p "require('./package.json').version")

# Check if this version already exists on npm
if npm view "${PACKAGE_NAME}@${LOCAL_VERSION}" version 2>/dev/null; then
echo "Version ${LOCAL_VERSION} already exists on npm. Skipping publish."
echo "should_publish=false" >> $GITHUB_OUTPUT
else
echo "Version ${LOCAL_VERSION} is new. Will publish."
echo "should_publish=true" >> $GITHUB_OUTPUT
fi

- name: Publish to NPM
if: steps.version-check.outputs.should_publish == 'true'
run: npm publish --access=public --provenance
28 changes: 25 additions & 3 deletions DEPLOY.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
# Deployment Commands
# Deployment

- `npm run build`
- `npm publish --access public`
This package is automatically published to npm on every push to the `main` branch via GitHub Actions.

## How to Deploy

1. Update the version in `package.json`
2. Push/merge your changes to `main`
3. GitHub Actions will automatically:
- Run tests
- Build the package
- Publish to npm

## Required Setup

Add an `NPM_TOKEN` secret to your GitHub repository:
1. Create an access token at https://www.npmjs.com/settings/tokens
2. Go to your GitHub repo → Settings → Secrets and variables → Actions
3. Add a new secret named `NPM_TOKEN` with your npm token

## Manual Deployment (if needed)

```bash
npm run build
npm publish --access=public
```
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# SPARQ.AI Search Client

[![Codacy Badge](https://api.codacy.com/project/badge/Grade/7b750a903df8454bbe0747aa74b23d54)](https://www.codacy.com/app/naveensky/search-client-js?utm_source=github.com&utm_medium=referral&utm_content=searchtap/search-client-js&utm_campaign=Badge_Grade)
[![Build Status](https://travis-ci.org/searchtap/search-client-js.svg?branch=master)](https://travis-ci.org/searchtap/search-client-js)
[![npm](https://img.shields.io/npm/dm/@searchtap/search-client.svg)](https://www.npmjs.com/package/@searchtap/search-client)
[![NpmVersion](https://img.shields.io/npm/v/@searchtap/search-client.svg)](https://www.npmjs.com/package/@searchtap/search-client)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/7b750a903df8454bbe0747aa74b23d54)](https://www.codacy.com/app/naveensky/search-client-js?utm_source=github.com&utm_medium=referral&utm_content=sparq/search-client-js&utm_campaign=Badge_Grade)
[![Build Status](https://travis-ci.org/sparq/search-client-js.svg?branch=master)](https://travis-ci.org/sparq/search-client-js)
[![npm](https://img.shields.io/npm/dm/@sparq/search-client.svg)](https://www.npmjs.com/package/@sparq/search-client)
[![NpmVersion](https://img.shields.io/npm/v/@sparq/search-client.svg)](https://www.npmjs.com/package/@sparq/search-client)


[SearchTap](https://www.searchtap.io/) is a subscription based hosted search solution for websites (eCommerce, Media and Publishing), mobile applications and enterprise software that delivers relevant results instantly.
[Sparq](https://www.sparq.ai/) is a subscription based hosted search solution for websites (eCommerce, Media and Publishing), mobile applications and enterprise software that delivers relevant results instantly.

Search Client is a lightweight search-only client that handles only the searches. It can be used in applications that require search access to their data and don't require the full blown client `@searchtap/client`. The Search Client library makes it easy to send requests and retrieve search results from the server for you.
Search Client is a lightweight search-only client that handles only the searches. It can be used in applications that require search access to their data and don't require the full blown client `@sparq/client`. The Search Client library makes it easy to send requests and retrieve search results from the server for you.


## Table of Contents
Expand Down Expand Up @@ -50,26 +50,26 @@ Search Client is a lightweight search-only client that handles only the searches

##### Browser

`<script src='https://cdn.jsdelivr.net/npm/@searchtap/search-client/lib/index.min.js'></script>`
`<script src='https://cdn.jsdelivr.net/npm/@sparq/search-client/lib/index.min.js'></script>`

##### NPM

`npm install @searchtap/search-client --save`
`npm install @sparq/search-client --save`

##### YARN

`yarn add @searchtap/search-client`
`yarn add @sparq/search-client`

## Quick Start

### Initialize the Search Client

To initiate, you will have to create a new search client which would require an **Application ID** and a **Search Token**. You can find both on your [SearchTap account](https://dashboard.searchtap.io/login).
To initiate, you will have to create a new search client which would require an **Application ID** and a **Search Token**. You can find both on your [Sparq account](https://app.sparq.ai/login).

> Always use your search-only tokens to make search operations from public clients like browser or mobile apps. Do not use your admin tokens on public facing clients.

```
import SearchClient from "@searchtap/search-client";
import SearchClient from "@sparq/search-client";
var searchClient = new SearchClient(<app-id>, <search-token>)
```

Expand All @@ -88,7 +88,7 @@ Look at the complete definitions for all methods available [here](#options)

### Search

You can initiate search by defining a text query and the collection id in the syntax below. Collection id can be found on your SearchTap account, every collection id is associated with a specific application.
You can initiate search by defining a text query and the collection id in the syntax below. Collection id can be found on your Sparq account, every collection id is associated with a specific application.

```
searchClient.search(<text-query>, <collection-id>)
Expand Down Expand Up @@ -151,7 +151,7 @@ The default behaviour is to search on all fields.

`.textFacets(...)` `[array, optional]` : Text facets to be retrieved. For each of the retrieved facets (eg. color; size; brand), the response will contain a list of facet values (red, blue; small, large; zara…) and associated count of records for that facet value.

> You would be require to configure facets on the SearchTap dashboard for the collection before fetching its data. If not configured, you would receive an error.
> You would be require to configure facets on the Sparq dashboard for the collection before fetching its data. If not configured, you would receive an error.

The default behaviour is to not fetch any facet values.

Expand All @@ -173,7 +173,7 @@ searchClient.textFacetFilters('Brand',['zara','tommy hilfiger'])

`.numericFacets(...)` `[optional]`: Numeric facets as the name suggests, are facets with numeric values (eg. price, age). `.numericFacets` let's you define the ranges you want to show to the end user along with count of records in that range. You can use the same to create a histogram slider for your front-end UI.

> You would be require to configure facets on the SearchTap dashboard for the collection before fetching its data. If not configured, you would receive an error.
> You would be require to configure facets on the Sparq dashboard for the collection before fetching its data. If not configured, you would receive an error.

The default behavior is to not fetch any numeric facet value.

Expand Down Expand Up @@ -333,4 +333,4 @@ searchClient.typoTolerance(1)

## Getting Help

- **Need help?** Ask a question [here](https://github.com/searchtap/search-client-js/issues/new)
- **Need help?** Ask a question [here](https://github.com/sparq-ai/search-client-js/issues/new)
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"name": "@searchtap/search-client",
"version": "2.0.0",
"name": "@sparq/search-client",
"version": "2.0.5",
"keywords": [
"search",
"search as you type",
"searchtap",
"sparq",
"search client"
],
"description": "Search Client is a lightweight search-only client that handles searches at SearchTap platform.",
"description": "Search Client is a lightweight search-only client that handles searches at Sparq platform.",
"main": "lib/index.min.js",
"types": "lib/SearchClient.d.ts",
"scripts": {
"build": "rm -rf lib && NODE_OPTIONS=--openssl-legacy-provider NODE_ENV=production ./node_modules/.bin/webpack --mode=production && tsc --emitDeclarationOnly",
"test": "NODE_ENV=test ./node_modules/mocha/bin/_mocha --full-trace --require ts-node/register --exit ./tests/**/*.spec.ts",
"code-coverage": "NODE_ENV=test nyc --reporter=lcov --reporter=text ./node_modules/mocha/bin/_mocha --full-trace --require ts-node/register --exit ./tests/**/*.spec.ts && cat ./coverage/lcov.info | codacy-coverage && rm -rf ./coverage ./.nyc_output"
},
"author": "tech@searchtap.io",
"repository": "https://github.com/searchtap/search-client-js",
"author": "tech@sparq.ai",
"repository": "https://github.com/sparq-ai/search-client-js",
"license": "MIT",
"dependencies": {
"axios": "^0.18.0"
Expand Down