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

@algolia/recommend-core

Package Overview
Dependencies
Maintainers
84
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.9.0 to 1.10.0

dist/esm/getBatchRecommendations.d.ts

1

dist/esm/index.d.ts

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

export * from './getBatchRecommendations';
export * from './getFrequentlyBoughtTogether';

@@ -2,0 +3,0 @@ export * from './getRecommendations';

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

export * from './getBatchRecommendations';
export * from './getFrequentlyBoughtTogether';

@@ -2,0 +3,0 @@ export * from './getRecommendations';

9

dist/esm/utils/mapByScoreToRecommendations.d.ts

@@ -0,10 +1,7 @@

import { ProductRecord } from '../types';
type MapToRecommendations<TObject> = {
hits: Array<TObject & {
_score?: number;
}>;
hits: Array<ProductRecord<TObject>>;
maxRecommendations?: number;
};
export declare function mapByScoreToRecommendations<TObject>({ hits, maxRecommendations, }: MapToRecommendations<TObject>): (TObject & {
_score?: number | undefined;
})[];
export declare function mapByScoreToRecommendations<TObject>({ hits, maxRecommendations, }: MapToRecommendations<TObject>): Array<ProductRecord<TObject>>;
export {};

@@ -14,3 +14,3 @@ import { ProductRecord } from '../types';

};
export declare function mapToRecommendations<TObject>({ hits, maxRecommendations, nrOfObjs, }: MapToRecommendations<TObject>): ProductRecord<TObject>[];
export declare function mapToRecommendations<TObject>({ hits, maxRecommendations, nrOfObjs, }: MapToRecommendations<TObject>): Array<ProductRecord<TObject>>;
export {};

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

export declare const version = "1.9.0";
export declare const version = "1.10.0";

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

export const version = '1.9.0';
export const version = '1.10.0';

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

/*! @algolia/recommend-core 1.9.0 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/recommend */
!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({hits:e,maxRecommendations:t,nrOfObjs:n}){const o={};e.forEach((e=>{e.forEach(((e,t)=>{o[e.objectID]?o[e.objectID]={indexSum:o[e.objectID].indexSum+t,nr:o[e.objectID].nr+1}:o[e.objectID]={indexSum:t,nr:1}}))}));const a=((e,t)=>{const n=[];for(const o of Object.keys(e))e[o].nr<2&&(e[o].indexSum+=100),n.push({objectID:o,avgOfIndices:e[o].indexSum/t});return n.sort(((e,t)=>e.avgOfIndices>t.avgOfIndices?1:-1))})(o,n);return a.reduce(((t,n)=>{const o=e.flat().find((e=>e.objectID===n.objectID));return o?t.concat(o):t}),[]).slice(0,t&&t>0?t:void 0)}function n({hits:e,maxRecommendations:t}){return function(e,t){const n=[...t];return n.sort(e),n}(((e,t)=>(e._score||0)>(t._score||0)?-1:1),e).slice(0,t&&t>0?t:void 0)}const o="1.9.0";e.getFrequentlyBoughtTogether=function({objectIDs:e,recommendClient:n,transformItems:a=(e=>e),indexName:m,maxRecommendations:r,queryParameters:s,threshold:c}){const i=e.map((e=>({indexName:m,maxRecommendations:r,objectID:e,queryParameters:s,threshold:c})));return n.addAlgoliaAgent("recommend-core",o),n.getFrequentlyBoughtTogether(i).then((n=>t({maxRecommendations:r,hits:n.results.map((e=>e.hits)),nrOfObjs:e.length}))).then((e=>({recommendations:a(e)})))},e.getLookingSimilar=function({objectIDs:e,recommendClient:n,transformItems:a=(e=>e),fallbackParameters:m,indexName:r,maxRecommendations:s,queryParameters:c,threshold:i}){const d=e.map((e=>({fallbackParameters:m,indexName:r,maxRecommendations:s,objectID:e,queryParameters:c,threshold:i})));return n.addAlgoliaAgent("recommend-core",o),n.getLookingSimilar(d).then((n=>t({maxRecommendations:s,hits:n.results.map((e=>e.hits)),nrOfObjs:e.length}))).then((e=>({recommendations:a(e)})))},e.getRecommendations=function({objectIDs:e,recommendClient:n,transformItems:a=(e=>e),fallbackParameters:m,indexName:r,maxRecommendations:s,model:c,queryParameters:i,threshold:d}){const l=e.map((e=>({fallbackParameters:m,indexName:r,maxRecommendations:s,model:c,objectID:e,queryParameters:i,threshold:d})));return n.addAlgoliaAgent("recommend-core",o),n.getRecommendations(l).then((n=>t({maxRecommendations:s,hits:n.results.map((e=>e.hits)),nrOfObjs:e.length}))).then((e=>({recommendations:a(e)})))},e.getRelatedProducts=function({objectIDs:e,recommendClient:n,transformItems:a=(e=>e),fallbackParameters:m,indexName:r,maxRecommendations:s,queryParameters:c,threshold:i}){const d=e.map((e=>({fallbackParameters:m,indexName:r,maxRecommendations:s,objectID:e,queryParameters:c,threshold:i})));return n.addAlgoliaAgent("recommend-core",o),n.getRelatedProducts(d).then((n=>t({maxRecommendations:s,hits:n.results.map((e=>e.hits)),nrOfObjs:e.length}))).then((e=>({recommendations:a(e)})))},e.getTrendingFacets=function({recommendClient:e,transformItems:t=(e=>e),indexName:a,maxRecommendations:m,threshold:r,facetName:s}){const c={indexName:a,maxRecommendations:m,threshold:r,facetName:s};return e.addAlgoliaAgent("recommend-core",o),e.getTrendingFacets([c]).then((e=>n({maxRecommendations:m,hits:e.results.map((e=>e.hits)).flat()}))).then((e=>({recommendations:t(e)})))},e.getTrendingItems=function({recommendClient:e,transformItems:t=(e=>e),fallbackParameters:a,indexName:m,maxRecommendations:r,queryParameters:s,threshold:c,facetName:i,facetValue:d}){const l={fallbackParameters:a,indexName:m,maxRecommendations:r,queryParameters:s,threshold:c,facetName:i,facetValue:d};return e.addAlgoliaAgent("recommend-core",o),e.getTrendingItems([l]).then((e=>{return n({maxRecommendations:r,hits:(t="objectID",o=e.results.map((e=>e.hits)).flat(),[...new Map(o.map((e=>[e[t],e]))).values()])});var t,o})).then((e=>({recommendations:t(e)})))}}));
/*! @algolia/recommend-core 1.10.0 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/recommend */
!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({hits:e,maxRecommendations:t,nrOfObjs:n}){const a={};e.forEach((e=>{e.forEach(((e,t)=>{a[e.objectID]?a[e.objectID]={indexSum:a[e.objectID].indexSum+t,nr:a[e.objectID].nr+1}:a[e.objectID]={indexSum:t,nr:1}}))}));const o=((e,t)=>{const n=[];for(const a of Object.keys(e))e[a].nr<2&&(e[a].indexSum+=100),n.push({objectID:a,avgOfIndices:e[a].indexSum/t});return n.sort(((e,t)=>e.avgOfIndices>t.avgOfIndices?1:-1))})(a,n);return o.reduce(((t,n)=>{const a=e.flat().find((e=>e.objectID===n.objectID));return a?t.concat(a):t}),[]).slice(0,t&&t>0?t:void 0)}function n({hits:e,maxRecommendations:t}){return function(e,t){const n=[...t];return n.sort(e),n}(((e,t)=>(e._score||0)>(t._score||0)?-1:1),e).slice(0,t&&t>0?t:void 0)}const a="1.10.0";e.getBatchRecommendations=async function({keys:e,queries:o,recommendClient:m}){m.addAlgoliaAgent("recommend-core",a);const r=await m.getRecommendations(o);let s=0,c=0;const i={};return e.forEach((e=>{const{model:a}=JSON.parse(e.key);c+=e.value;const{maxRecommendations:m,transformItems:d=(e=>e)}=o[s],l=r?.results?.slice(s,c);let h;s+=e.value,h="trending-facets"===a||"trending-items"===a?n({maxRecommendations:m,hits:l.map((e=>e.hits)).flat()}):t({maxRecommendations:m,hits:l.map((e=>e.hits)),nrOfObjs:e.value}),h=d(h),i[e.key]={recommendations:h}})),i},e.getFrequentlyBoughtTogether=function({objectIDs:e,recommendClient:n,transformItems:o=(e=>e),indexName:m,maxRecommendations:r,queryParameters:s,threshold:c}){const i=e.map((e=>({indexName:m,maxRecommendations:r,objectID:e,queryParameters:s,threshold:c})));return n.addAlgoliaAgent("recommend-core",a),n.getFrequentlyBoughtTogether(i).then((n=>t({maxRecommendations:r,hits:n.results.map((e=>e.hits)),nrOfObjs:e.length}))).then((e=>({recommendations:o(e)})))},e.getLookingSimilar=function({objectIDs:e,recommendClient:n,transformItems:o=(e=>e),fallbackParameters:m,indexName:r,maxRecommendations:s,queryParameters:c,threshold:i}){const d=e.map((e=>({fallbackParameters:m,indexName:r,maxRecommendations:s,objectID:e,queryParameters:c,threshold:i})));return n.addAlgoliaAgent("recommend-core",a),n.getLookingSimilar(d).then((n=>t({maxRecommendations:s,hits:n.results.map((e=>e.hits)),nrOfObjs:e.length}))).then((e=>({recommendations:o(e)})))},e.getRecommendations=function({objectIDs:e,recommendClient:n,transformItems:o=(e=>e),fallbackParameters:m,indexName:r,maxRecommendations:s,model:c,queryParameters:i,threshold:d}){const l=e.map((e=>({fallbackParameters:m,indexName:r,maxRecommendations:s,model:c,objectID:e,queryParameters:i,threshold:d})));return n.addAlgoliaAgent("recommend-core",a),n.getRecommendations(l).then((n=>t({maxRecommendations:s,hits:n.results.map((e=>e.hits)),nrOfObjs:e.length}))).then((e=>({recommendations:o(e)})))},e.getRelatedProducts=function({objectIDs:e,recommendClient:n,transformItems:o=(e=>e),fallbackParameters:m,indexName:r,maxRecommendations:s,queryParameters:c,threshold:i}){const d=e.map((e=>({fallbackParameters:m,indexName:r,maxRecommendations:s,objectID:e,queryParameters:c,threshold:i})));return n.addAlgoliaAgent("recommend-core",a),n.getRelatedProducts(d).then((n=>t({maxRecommendations:s,hits:n.results.map((e=>e.hits)),nrOfObjs:e.length}))).then((e=>({recommendations:o(e)})))},e.getTrendingFacets=function({recommendClient:e,transformItems:t=(e=>e),indexName:o,maxRecommendations:m,threshold:r,facetName:s}){const c={indexName:o,maxRecommendations:m,threshold:r,facetName:s};return e.addAlgoliaAgent("recommend-core",a),e.getTrendingFacets([c]).then((e=>n({maxRecommendations:m,hits:e.results.map((e=>e.hits)).flat()}))).then((e=>({recommendations:t(e)})))},e.getTrendingItems=function({recommendClient:e,transformItems:t=(e=>e),fallbackParameters:o,indexName:m,maxRecommendations:r,queryParameters:s,threshold:c,facetName:i,facetValue:d}){const l={fallbackParameters:o,indexName:m,maxRecommendations:r,queryParameters:s,threshold:c,facetName:i,facetValue:d};return e.addAlgoliaAgent("recommend-core",a),e.getTrendingItems([l]).then((e=>{return n({maxRecommendations:r,hits:(t="objectID",a=e.results.map((e=>e.hits)).flat(),[...new Map(a.map((e=>[e[t],e]))).values()])});var t,a})).then((e=>({recommendations:t(e)})))}}));
//# sourceMappingURL=index.js.map
{
"name": "@algolia/recommend-core",
"version": "1.9.0",
"version": "1.10.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/algolia/recommend",

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