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

@algolia/recommend-core

Package Overview
Dependencies
Maintainers
68
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algolia/recommend-core - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

2

dist/esm/getFrequentlyBoughtTogether.d.ts
import { FrequentlyBoughtTogetherQuery } from '@algolia/recommend';
import { RecommendationsProps } from './getRecommendations';
export declare type GetFrequentlyBoughtTogetherProps<TObject> = RecommendationsProps<TObject> & Omit<FrequentlyBoughtTogetherQuery, 'objectID'>;
export declare function getFrequentlyBoughtTogether<TObject>(userProps: GetFrequentlyBoughtTogetherProps<TObject>): Promise<{
export declare function getFrequentlyBoughtTogether<TObject>({ objectIDs, recommendClient, transformItems, indexName, maxRecommendations, queryParameters, threshold, }: GetFrequentlyBoughtTogetherProps<TObject>): Promise<{
recommendations: import("./types").ProductRecord<TObject>[];
}>;

@@ -1,24 +0,22 @@

import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["objectIDs", "recommendClient", "transformItems"];
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
import { mapToRecommendations } from './utils';
import { version } from './version';
export function getFrequentlyBoughtTogether(userProps) {
var objectIDs = userProps.objectIDs,
recommendClient = userProps.recommendClient,
_userProps$transformI = userProps.transformItems,
transformItems = _userProps$transformI === void 0 ? function (x) {
export function getFrequentlyBoughtTogether(_ref) {
var objectIDs = _ref.objectIDs,
recommendClient = _ref.recommendClient,
_ref$transformItems = _ref.transformItems,
transformItems = _ref$transformItems === void 0 ? function (x) {
return x;
} : _userProps$transformI,
props = _objectWithoutProperties(userProps, _excluded);
} : _ref$transformItems,
indexName = _ref.indexName,
maxRecommendations = _ref.maxRecommendations,
queryParameters = _ref.queryParameters,
threshold = _ref.threshold;
var queries = objectIDs.map(function (objectID) {
return _objectSpread(_objectSpread({}, props), {}, {
objectID: objectID
});
return {
indexName: indexName,
maxRecommendations: maxRecommendations,
objectID: objectID,
queryParameters: queryParameters,
threshold: threshold
};
});

@@ -28,4 +26,4 @@ recommendClient.addAlgoliaAgent('recommend-core', version);

return mapToRecommendations({
response: response,
maxRecommendations: props.maxRecommendations
maxRecommendations: maxRecommendations,
response: response
});

@@ -32,0 +30,0 @@ }).then(function (hits) {

@@ -12,2 +12,2 @@ import type { RecommendClient, RecommendationsQuery } from '@algolia/recommend';

};
export declare function getRecommendations<TObject>(userProps: GetRecommendationsProps<TObject>): Promise<GetRecommendationsResult<TObject>>;
export declare function getRecommendations<TObject>({ objectIDs, recommendClient, transformItems, fallbackParameters, indexName, maxRecommendations, model, queryParameters, threshold, }: GetRecommendationsProps<TObject>): Promise<GetRecommendationsResult<TObject>>;

@@ -1,24 +0,26 @@

import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["objectIDs", "recommendClient", "transformItems"];
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
import { mapToRecommendations } from './utils';
import { version } from './version';
export function getRecommendations(userProps) {
var objectIDs = userProps.objectIDs,
recommendClient = userProps.recommendClient,
_userProps$transformI = userProps.transformItems,
transformItems = _userProps$transformI === void 0 ? function (x) {
export function getRecommendations(_ref) {
var objectIDs = _ref.objectIDs,
recommendClient = _ref.recommendClient,
_ref$transformItems = _ref.transformItems,
transformItems = _ref$transformItems === void 0 ? function (x) {
return x;
} : _userProps$transformI,
props = _objectWithoutProperties(userProps, _excluded);
} : _ref$transformItems,
fallbackParameters = _ref.fallbackParameters,
indexName = _ref.indexName,
maxRecommendations = _ref.maxRecommendations,
model = _ref.model,
queryParameters = _ref.queryParameters,
threshold = _ref.threshold;
var queries = objectIDs.map(function (objectID) {
return _objectSpread(_objectSpread({}, props), {}, {
objectID: objectID
});
return {
fallbackParameters: fallbackParameters,
indexName: indexName,
maxRecommendations: maxRecommendations,
model: model,
objectID: objectID,
queryParameters: queryParameters,
threshold: threshold
};
});

@@ -28,4 +30,4 @@ recommendClient.addAlgoliaAgent('recommend-core', version);

return mapToRecommendations({
response: response,
maxRecommendations: props.maxRecommendations
maxRecommendations: maxRecommendations,
response: response
});

@@ -32,0 +34,0 @@ }).then(function (hits) {

import { RelatedProductsQuery } from '@algolia/recommend';
import { RecommendationsProps } from './getRecommendations';
export declare type GetRelatedProductsProps<TObject> = RecommendationsProps<TObject> & Omit<RelatedProductsQuery, 'objectID'>;
export declare function getRelatedProducts<TObject>(userProps: GetRelatedProductsProps<TObject>): Promise<{
export declare function getRelatedProducts<TObject>({ objectIDs, recommendClient, transformItems, fallbackParameters, indexName, maxRecommendations, queryParameters, threshold, }: GetRelatedProductsProps<TObject>): Promise<{
recommendations: import("./types").ProductRecord<TObject>[];
}>;

@@ -1,24 +0,24 @@

import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["objectIDs", "recommendClient", "transformItems"];
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
import { mapToRecommendations } from './utils';
import { version } from './version';
export function getRelatedProducts(userProps) {
var objectIDs = userProps.objectIDs,
recommendClient = userProps.recommendClient,
_userProps$transformI = userProps.transformItems,
transformItems = _userProps$transformI === void 0 ? function (x) {
export function getRelatedProducts(_ref) {
var objectIDs = _ref.objectIDs,
recommendClient = _ref.recommendClient,
_ref$transformItems = _ref.transformItems,
transformItems = _ref$transformItems === void 0 ? function (x) {
return x;
} : _userProps$transformI,
props = _objectWithoutProperties(userProps, _excluded);
} : _ref$transformItems,
fallbackParameters = _ref.fallbackParameters,
indexName = _ref.indexName,
maxRecommendations = _ref.maxRecommendations,
queryParameters = _ref.queryParameters,
threshold = _ref.threshold;
var queries = objectIDs.map(function (objectID) {
return _objectSpread(_objectSpread({}, props), {}, {
objectID: objectID
});
return {
fallbackParameters: fallbackParameters,
indexName: indexName,
maxRecommendations: maxRecommendations,
objectID: objectID,
queryParameters: queryParameters,
threshold: threshold
};
});

@@ -28,4 +28,4 @@ recommendClient.addAlgoliaAgent('recommend-core', version);

return mapToRecommendations({
response: response,
maxRecommendations: props.maxRecommendations
maxRecommendations: maxRecommendations,
response: response
});

@@ -32,0 +32,0 @@ }).then(function (hits) {

@@ -1,1 +0,1 @@

export declare const version = "1.0.0";
export declare const version = "1.1.0";

@@ -1,1 +0,1 @@

export var version = '1.0.0';
export var version = '1.1.0';

@@ -1,3 +0,3 @@

/*! @algolia/recommend-core 1.0.0 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/ui-components */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/recommend-core"]={})}(this,(function(e){"use strict";function t(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},c=Object.keys(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n<c.length;n++)r=c[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function o(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e){var t,r,n=e.response,c=e.maxRecommendations;return function(e,t){var r=o(t);return r.sort(e),r}((function(e,t){return(e._score||0)>(t._score||0)?-1:1}),(t="objectID",r=n.results.map((function(e){return e.hits})).flat(),o(new Map(r.map((function(e){return[e[t],e]}))).values()))).slice(0,c&&c>0?c:void 0)}var i="1.0.0",u=["objectIDs","recommendClient","transformItems"];function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?a(Object(n),!0).forEach((function(r){t(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var f=["objectIDs","recommendClient","transformItems"];function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?m(Object(n),!0).forEach((function(r){t(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):m(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var p=["objectIDs","recommendClient","transformItems"];function b(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function d(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?b(Object(n),!0).forEach((function(r){t(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):b(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}e.getFrequentlyBoughtTogether=function(e){var t=e.objectIDs,n=e.recommendClient,o=e.transformItems,a=void 0===o?function(e){return e}:o,f=r(e,u),m=t.map((function(e){return s(s({},f),{},{objectID:e})}));return n.addAlgoliaAgent("recommend-core",i),n.getFrequentlyBoughtTogether(m).then((function(e){return c({response:e,maxRecommendations:f.maxRecommendations})})).then((function(e){return{recommendations:a(e)}}))},e.getRecommendations=function(e){var t=e.objectIDs,n=e.recommendClient,o=e.transformItems,u=void 0===o?function(e){return e}:o,a=r(e,f),s=t.map((function(e){return l(l({},a),{},{objectID:e})}));return n.addAlgoliaAgent("recommend-core",i),n.getRecommendations(s).then((function(e){return c({response:e,maxRecommendations:a.maxRecommendations})})).then((function(e){return{recommendations:u(e)}}))},e.getRelatedProducts=function(e){var t=e.objectIDs,n=e.recommendClient,o=e.transformItems,u=void 0===o?function(e){return e}:o,a=r(e,p),s=t.map((function(e){return d(d({},a),{},{objectID:e})}));return n.addAlgoliaAgent("recommend-core",i),n.getRelatedProducts(s).then((function(e){return c({response:e,maxRecommendations:a.maxRecommendations})})).then((function(e){return{recommendations:u(e)}}))},Object.defineProperty(e,"__esModule",{value:!0})}));
/*! @algolia/recommend-core 1.1.0 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/recommend */
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/recommend-core"]={})}(this,(function(e){"use strict";function n(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function t(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e){var n,r,o=e.response,a=e.maxRecommendations;return function(e,n){var r=t(n);return r.sort(e),r}((function(e,n){return(e._score||0)>(n._score||0)?-1:1}),(n="objectID",r=o.results.map((function(e){return e.hits})).flat(),t(new Map(r.map((function(e){return[e[n],e]}))).values()))).slice(0,a&&a>0?a:void 0)}var o="1.1.0";e.getFrequentlyBoughtTogether=function(e){var n=e.objectIDs,t=e.recommendClient,a=e.transformItems,m=void 0===a?function(e){return e}:a,i=e.indexName,c=e.maxRecommendations,u=e.queryParameters,s=e.threshold,d=n.map((function(e){return{indexName:i,maxRecommendations:c,objectID:e,queryParameters:u,threshold:s}}));return t.addAlgoliaAgent("recommend-core",o),t.getFrequentlyBoughtTogether(d).then((function(e){return r({maxRecommendations:c,response:e})})).then((function(e){return{recommendations:m(e)}}))},e.getRecommendations=function(e){var n=e.objectIDs,t=e.recommendClient,a=e.transformItems,m=void 0===a?function(e){return e}:a,i=e.fallbackParameters,c=e.indexName,u=e.maxRecommendations,s=e.model,d=e.queryParameters,l=e.threshold,f=n.map((function(e){return{fallbackParameters:i,indexName:c,maxRecommendations:u,model:s,objectID:e,queryParameters:d,threshold:l}}));return t.addAlgoliaAgent("recommend-core",o),t.getRecommendations(f).then((function(e){return r({maxRecommendations:u,response:e})})).then((function(e){return{recommendations:m(e)}}))},e.getRelatedProducts=function(e){var n=e.objectIDs,t=e.recommendClient,a=e.transformItems,m=void 0===a?function(e){return e}:a,i=e.fallbackParameters,c=e.indexName,u=e.maxRecommendations,s=e.queryParameters,d=e.threshold,l=n.map((function(e){return{fallbackParameters:i,indexName:c,maxRecommendations:u,objectID:e,queryParameters:s,threshold:d}}));return t.addAlgoliaAgent("recommend-core",o),t.getRelatedProducts(l).then((function(e){return r({maxRecommendations:u,response:e})})).then((function(e){return{recommendations:m(e)}}))},Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.js.map
{
"name": "@algolia/recommend-core",
"version": "1.0.0",
"version": "1.1.0",
"license": "MIT",
"homepage": "https://github.com/algolia/ui-components",
"repository": "algolia/ui-components",
"homepage": "https://github.com/algolia/recommend",
"repository": "algolia/recommend",
"author": {

@@ -31,3 +31,3 @@ "name": "Algolia, Inc.",

"peerDependencies": {
"@algolia/recommend": "4.10.2"
"@algolia/recommend": "^4.10.5"
},

@@ -34,0 +34,0 @@ "devDependencies": {

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