Socket
Socket
Sign inDemoInstall

@sajari/sdk-node

Package Overview
Dependencies
Maintainers
5
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sajari/sdk-node - npm Package Compare versions

Comparing version 2.0.0-beta.7 to 4.0.0-alpha.1

build/src/client.d.ts

63

package.json
{
"name": "@sajari/sdk-node",
"version": "2.0.0-beta.7",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"author": "Ben Hinchley <bhinchley@sajari.com>",
"version": "4.0.0-alpha.1",
"repository": "git@github.com:github.com/sajari/sdk-node.git",
"author": "Sajari Pty Ltd",
"license": "MIT",
"main": "./build/src/index.js",
"types": "./build/src/index.d.ts",
"files": [
"README.md",
"LICENSE",
"dist/",
"generated/"
"build/src",
"!build/src/**/*.map"
],
"engines": {
"node": ">= 10.0.0"
},
"scripts": {
"prebuild": "npm-run-all gen:useragent lint test",
"build": "tsc",
"fmt": "prettier --write --config .prettierrc.js \"{src/**/*,*.config,*.d,.*,package}.{js,ts,json}\"",
"lint": "tslint --fix -p tsconfig.json",
"type-check": "tsc --noEmit",
"pretest": "npm-run-all type-check",
"test": "jest",
"test:watch": "jest --watch",
"coverage": "jest --coverage",
"gen:proto": "node scripts/genproto",
"gen:useragent": "node scripts/genuseragent",
"docs": "typedoc ./src/index.ts --mode file --out ./docs --exclude \"**/*+(.test).ts\"",
"prepublishOnly": "npm-run-all build"
},
"dependencies": {
"debug": "^4.1.1",
"deepmerge": "^4.0.0",
"grpc": "^1.22.2",
"protobufjs": "^6.8.8"
"request": "2.88.2",
"ts-node": "8.10.2"
},
"devDependencies": {
"@types/debug": "^4.1.4",
"@types/jest": "^24.0.15",
"globby": "^10.0.1",
"grpc-tools": "^1.8.0",
"jest": "^24.8.0",
"make-dir": "^3.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^1.18.2",
"ts-jest": "^24.0.2",
"tslint": "^5.18.0",
"tslint-config-prettier": "^1.18.0",
"typedoc": "^0.14.2",
"typescript": "^3.5.3"
"@types/node": "14.0.12",
"@types/request": "2.48.5",
"csv-parser": "^2.3.3",
"prettier": "2.0.5",
"rimraf": "^3.0.2",
"typescript": "3.9.5"
},
"scripts": {
"clean": "rimraf ./build",
"build": "tsc -p .",
"format": "prettier --write \"**/*.{js,json,md,ts,yaml}\"",
"setup-examples": "npm link && cd examples && npm install && npm link ../ && cd ../",
"test-examples": "cd examples && npm test && cd ../"
}
}

@@ -1,95 +0,52 @@

# @sajari/sdk-node
# sajari-sdk-node
> Node.js SDK for Sajari APIs <br/>
> NOTE: THIS IS STILL IN ALPHA
**Table of contents:**
## Getting Started
- [Quickstart](#quickstart)
- [Before you begin](#before-you-begin)
- [Install the SDK](#install-the-sdk)
- [Use the SDK](#use-the-sdk)
- [Samples](#samples)
- [Contributing](#contributing)
### Installation
## Quickstart
This is a [Node.js](https://nodejs.org/) module available through the
[npm registry](https://www.npmjs.com/). It can be installed using the
[`npm`](https://docs.npmjs.com/getting-started/installing-npm-packages-locally)
or [`yarn`](https://yarnpkg.com/en/) command line tools.
### Before you begin
```sh
npm install @sajari/sdk-node --save # yarn add @sajari/sdk-node
```
1. [Create a Sajari account](http://sajari.com/console)
1. [Retrieve your account credentials](https://www.sajari.com/console/project/credentials)
### Tests
### Install the SDK
```sh
npm install
npm test
```bash
npm install @sajari/sdk-node
```
## Examples
### Use the SDK
**Creating a schema**
```js
const { Client, FieldMode, schema } = require("@sajari/sdk-node");
```javascript
// Import the Sajari SDK.
const { CollectionsClient, withKeyCredentials } = require("@sajari/sdk-node");
// create client
const client = new Client("<project>", "<collection>", {
key: "<key from console>",
secret: "<secret from console>"
});
// Create a client for working with collections from the account ID and key
// credentials.
const client = new CollectionsClient(
"account-id",
withKeyCredentials("key-id", "key-secret")
);
const fields = [
schema.field.boolean("my-boolean-field", {
// Set this field to be required.
// FieldMode options are defined here,
// https://sajari-sdk-node.netlify.com/enums/fieldmode.html
mode: FieldMode.Required
}),
schema.field.string("text")
]
async function createCollection() {
// Create a new collection.
const collection = await client.createCollection({ id, displayName });
console.log(`Collection ${collection.displayName} created.`);
client.schema().add(...fields).catch(error => {/* handle error ... */})
```
**Adding a record**
```js
const { Client } = require("@sajari/sdk-node");
// create client
const client = new Client("<project>", "<collection>", {
key: "<key from console>",
secret: "<secret from console>"
});
// get the pipeline client
const pipeline = client.pipeline({name: "<your pipeline name>", version: "<your pipeline version>"});
const record = {
"my-boolean-field": true,
"text": "hello"
// Clean up.
await client.deleteCollection(collection.id);
}
pipeline.add({}, record)
.then(key => {/* handle key ... */})
.catch(error => {/* handle error ... */})
createCollection().catch(console.error);
```
**Performing a search**
```js
const { Client, DefaultSession, TrackingType } = require("@sajari/sdk-node");
## Contributing
const client = new Client("<project>", "<collection>", {
key: "<key from console>",
secret: "<secret from console>"
});
const session = new DefaultSession(TrackingType.None);
const pipeline = client.pipeline({name: "<your pipeline name>", version: "<your pipeline version>"});
const values = { q: "hello" };
pipeline.search(values, session.next(values))
.then(response => {/* handle response ... */})
.catch(error => {/* handle error ... */})
```
## License
[MIT](LICENSE)
Contributions are welcome. See the [Contributing](CONTRIBUTING.md) guide.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc