Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

search-sdk

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

search-sdk - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

134

lib/search.js
(function() {
var AzureSearch, Promise, Search, _;
var AzureSearch, Promise, Search, _,
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
slice = [].slice;

@@ -10,16 +12,15 @@ _ = require("lodash");

module.exports = Search = class Search {
constructor({
url,
key,
index,
facets: facets1
}) {
this.save = this.save.bind(this);
this.remove = this.remove.bind(this);
this.find = this.find.bind(this);
this.suggest = this.suggest.bind(this);
this.index = index;
this.facets = facets1;
this.client = Promise.promisifyAll(new AzureSearch({url, key}), {
module.exports = Search = (function() {
function Search(arg) {
var key, url;
url = arg.url, key = arg.key, this.index = arg.index, this.facets = arg.facets;
this.reverseStream = bind(this.reverseStream, this);
this.suggest = bind(this.suggest, this);
this.find = bind(this.find, this);
this.remove = bind(this.remove, this);
this.save = bind(this.save, this);
this.client = Promise.promisifyAll(new AzureSearch({
url: url,
key: key
}), {
multiArgs: true

@@ -29,36 +30,99 @@ });

save(...docs) {
Search.prototype.save = function() {
var docs;
docs = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return this.client.updateOrUploadDocumentsAsync(this.index, docs);
}
};
remove(...ids) {
Search.prototype.remove = function() {
var ids;
ids = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return this.client.deleteDocumentsAsync(this.index, ids);
}
};
find(query = {}) {
Search.prototype.find = function(query) {
if (query == null) {
query = {};
}
return this.client.searchAsync(this.index, _.merge({
facets: this.facets,
count: true
}, query)).spread((items, response) => {
var __ignoreType, count, facets, next;
__ignoreType = (value, key) => {
return _.endsWith(key, "@odata.type");
}, query)).spread((function(_this) {
return function(items, response) {
var __ignoreType, count, facets, next;
__ignoreType = function(value, key) {
return _.endsWith(key, "@odata.type");
};
next = _(response["@search.nextPageParameters"]).omit(__ignoreType).value();
facets = _(response["@search.facets"]).omitBy(__ignoreType).entries().map(function(arg) {
var key, value;
key = arg[0], value = arg[1];
return {
key: key,
value: value
};
}).value();
count = response["@odata.count"];
return {
items: items,
facets: facets,
next: next,
count: count
};
};
next = _(response["@search.nextPageParameters"]).omit(__ignoreType).value();
facets = _(response["@search.facets"]).omitBy(__ignoreType).entries().map(([key, value]) => {
return {key, value};
}).value();
count = response["@odata.count"];
return {items, facets, next, count};
});
}
})(this));
};
suggest(query = {}) {
Search.prototype.suggest = function(query) {
if (query == null) {
query = {};
}
return this.client.suggestAsync(this.index, _.merge({
suggesterName: "sg"
}, query)).get("0");
}
};
};
Search.prototype.reverseStream = function(query) {
if (query == null) {
query = {};
}
return this.find(_.assign(query, {
top: 0
})).then((function(_this) {
return function(arg) {
var _requestPage, count;
count = arg.count;
_requestPage = function(skip) {
var top;
if (skip == null) {
skip = count - pageSize;
}
top = Math.min(pageSize, pageSize + skip);
skip = Math.max(0, skip);
return _this.find(_.merge({
skip: skip,
top: top
}, query)).then(function(arg1) {
var items, ref;
items = arg1.items;
return {
items: items,
nextToken: (ref = items.length === pageSize && skip > 0) != null ? ref : skip - {
pageSize: null
}
};
});
};
return {
stream: new HighlandPagination(_requestPage).stream(),
count: count
};
};
})(this));
};
return Search;
})();
}).call(this);
{
"name": "search-sdk",
"version": "0.4.0",
"version": "0.5.0",
"description": "search-sdk",

@@ -15,17 +15,17 @@ "main": "index.js",

"dependencies": {
"azure-search": "^0.0.21",
"lodash": "^4.17.10"
"azure-search": "0.0.16",
"lodash": "4.17.4"
},
"devDependencies": {
"async": "^2.5.0",
"bluebird": "^3.5.1",
"coffee-script": "^1.12.7",
"grunt": "^1.0.3",
"grunt-bump": "^0.8.0",
"grunt-contrib-clean": "^1.1.0",
"grunt-contrib-coffee": "^2.0.0",
"grunt-mocha-test": "^0.13.3",
"mocha": "^5.2.0",
"bluebird": "3.5.0",
"coffee-script": "1.12.4",
"grunt": "1.0.1",
"grunt-bump": "0.8.0",
"grunt-contrib-clean": "1.0.0",
"grunt-contrib-coffee": "1.0.0",
"grunt-mocha-test": "0.13.2",
"mocha": "3.2.0",
"request": "^2.81.0",
"should": "^13.2.1"
"should": "11.2.1"
},

@@ -32,0 +32,0 @@ "author": "Parsimotion",

@@ -7,19 +7,23 @@ # search-sdk

# Publish instructions
# Examples
``` Console
> grunt bump:[major|minor|patch]
#If you'd like to test it in your local environment
> npm install . -g
or
> cd path/to/project/that/uses/this/package
> npm install path/to/this/package
```
Test your package in some project and make sure it works.
When you are absolutely sure
``` javascript
const search = new AzureSearch({
url :: String,
key :: String,
index :: String,
facets :: [String]
})
``` Console
> git push origin master
> git push origin master --tags
> npm publish
search.find({
skip :: Int,
top :: Int,
select :: String,
filter: String // field1 eq 'something'
}) :: {
items :: [Object],
count :: Int,
facets :: [{ key: String, value: Int }]
}
```
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