@uniformdev/canvas-algolia
Advanced tools
Comparing version 14.0.0 to 14.0.1-alpha.94
@@ -36,2 +36,16 @@ import { LimitPolicy, ComponentParameterEnhancer } from '@uniformdev/canvas'; | ||
declare const CANVAS_ALGOLIA_RECORD_PARAMETER_TYPES: readonly string[]; | ||
declare type AlgoliaRecordParameterValue = { | ||
source: string; | ||
objectIDs: string[]; | ||
} | null | undefined; | ||
/** The default shape of the result value of the Algolia Record enhancer. Note that this can change if the record is altered. */ | ||
declare type AlgoliaRecordEnhancerResult<TFields> = (Hit<TFields> | null)[] | null; | ||
declare type CreateAlgoliaRecordEnhancerOptions = { | ||
/** Either a list of Algolia clients for use with multi-index-enabled Canvas projects. */ | ||
clients: AlgoliaClientList; | ||
limitPolicy?: LimitPolicy; | ||
}; | ||
declare function createAlgoliaRecordEnhancer({ clients, limitPolicy, }: CreateAlgoliaRecordEnhancerOptions): ComponentParameterEnhancer<AlgoliaRecordParameterValue, AlgoliaRecordEnhancerResult<unknown>>; | ||
declare const CANVAS_ALGOLIA_QUERY_PARAMETER_TYPES: readonly string[]; | ||
@@ -53,2 +67,2 @@ declare type AlgoliaQueryParameterValue = { | ||
export { AddClientArgs, AlgoliaClientList, AlgoliaQueryEnhancerResult, AlgoliaQueryParameterValue, CANVAS_ALGOLIA_QUERY_PARAMETER_TYPES, CreateAlgoliaQueryEnhancerOptions, createAlgoliaQueryEnhancer }; | ||
export { AddClientArgs, AlgoliaClientList, AlgoliaQueryEnhancerResult, AlgoliaQueryParameterValue, AlgoliaRecordEnhancerResult, AlgoliaRecordParameterValue, CANVAS_ALGOLIA_QUERY_PARAMETER_TYPES, CANVAS_ALGOLIA_RECORD_PARAMETER_TYPES, CreateAlgoliaQueryEnhancerOptions, CreateAlgoliaRecordEnhancerOptions, createAlgoliaQueryEnhancer, createAlgoliaRecordEnhancer }; |
@@ -1,1 +0,1 @@ | ||
import{createLimitPolicy as P}from"@uniformdev/canvas";var h=P({throttle:{limit:55,interval:1e3}});function y(e){return typeof e=="string"?e:typeof e=="object"&&e&&"error"in e?e.error:e instanceof Error?e.toString():JSON.stringify(e,null,2)}function A({clients:e,parameterValue:r,parameterName:t,component:n,context:a}){let{source:l="default"}=r,s=e.getClient({source:l,isPreviewClient:a.preview});if(!s)throw new Error(`No Algolia client could be resolved for source key '${l}' referenced in parameter '${t} in component '${n.type}'. Ensure that the 'clients' property you are passing to the enhancer has a client instance registered for the source key.`);return s}var x=Object.freeze(["algoliaQuery"]);function T({clients:e,limitPolicy:r}){if(!e)throw new Error("No Algolia clients were provided to the enhancer. You must provide at least one client via the AlgoliaClientList.");return{enhanceOne:async function({parameter:a,parameterName:l,component:s,context:C}){var g;if(w(a)){if(!v(a.value))return null;let E=A({clients:e,parameterName:l,parameterValue:a.value,component:s,context:C}),i=a.value,d=L(i.count),c=Object.getOwnPropertyNames(i.facetsValues).filter(o=>Array.isArray(i.facetsValues[o])).map(o=>i.facetsValues[o].map(u=>`${o}:${u}`)),p=`fetch query: ${d} entries with '${i.searchText}' query and '${JSON.stringify(c)}' facets`;try{return console.time(p),(await E.search(i.searchText,{facetFilters:c,offset:0,length:d})).hits}catch(o){let u=y(o);throw new Error(`Failed loading Algolia entries with '${i.searchText}' query and '${JSON.stringify(c)}' facets from source '${(g=i.source)!=null?g:"default"}' referenced in parameter '${l}': ${u}`)}finally{console.timeEnd(p)}}},limitPolicy:r||h}}function w(e){return e.type===x[0]}function v(e){return!(!e||!e.source||typeof e.searchText=="undefined"||typeof e.count=="undefined")}function L(e){return!e||e<1?1:e>1e3?1e3:e}var Q=class{constructor(r){this._clients={},Array.isArray(r)?r.forEach(t=>this.addClient(t)):r&&this.addClient(r)}addClient({source:r="default",client:t,previewClient:n}){if(this._clients[r])throw new Error(`The source ${r} is always registered`);if(!t)throw new Error("You must provide an Algolia client for the AlgoliaClientList");this._clients[r]={client:t,previewClient:n||t}}getClient({source:r="default",isPreviewClient:t}){let n=this._clients[r];if(!!n)return t?n.previewClient:n.client}};export{Q as AlgoliaClientList,x as CANVAS_ALGOLIA_QUERY_PARAMETER_TYPES,T as createAlgoliaQueryEnhancer}; | ||
import{createLimitPolicy as E}from"@uniformdev/canvas";var p=E({throttle:{limit:55,interval:1e3}});function h(e){return typeof e=="string"?e:typeof e=="object"&&e&&"error"in e?e.error:e instanceof Error?e.toString():JSON.stringify(e,null,2)}function y({clients:e,parameterValue:r,parameterName:n,component:o,context:t}){let{source:l="default"}=r,s=e.getClient({source:l,isPreviewClient:t.preview});if(!s)throw new Error(`No Algolia client could be resolved for source key '${l}' referenced in parameter '${n} in component '${o.type}'. Ensure that the 'clients' property you are passing to the enhancer has a client instance registered for the source key.`);return s}var w=Object.freeze(["algoliaRecord"]);function S({clients:e,limitPolicy:r}){if(!e)throw new Error("No Algolia clients were provided to the enhancer. You must provide at least one client via the AlgoliaClientList.");return{enhanceOne:async function({parameter:t,parameterName:l,component:s,context:A}){var u;if(x(t)){if(!v(t.value))return null;let C=y({clients:e,parameterName:l,parameterValue:t.value,component:s,context:A}),i=t.value,f=`fetch record: ${t.value.objectIDs.length} entries`;try{return console.time(f),(await C.getObjects(t.value.objectIDs)).results}catch(c){let m=h(c);throw new Error(`Failed loading Algolia ${t.value.objectIDs.length} entries from source '${(u=i.source)!=null?u:"default"}' referenced in parameter '${l}': ${m}`)}finally{console.timeEnd(f)}}},limitPolicy:r||p}}function x(e){return e.type===w[0]}function v(e){return!(!e||!e.objectIDs||e.objectIDs.length<1)}var L=Object.freeze(["algoliaQuery"]);function j({clients:e,limitPolicy:r}){if(!e)throw new Error("No Algolia clients were provided to the enhancer. You must provide at least one client via the AlgoliaClientList.");return{enhanceOne:async function({parameter:t,parameterName:l,component:s,context:A}){var u;if(R(t)){if(!b(t.value))return null;let C=y({clients:e,parameterName:l,parameterValue:t.value,component:s,context:A}),i=t.value,f=V(i.count),c=Object.getOwnPropertyNames(i.facetsValues).filter(a=>Array.isArray(i.facetsValues[a])).map(a=>i.facetsValues[a].map(P=>`${a}:${P}`)),m=`fetch query: ${f} entries with '${i.searchText}' query and '${JSON.stringify(c)}' facets`;try{return console.time(m),(await C.search(i.searchText,{facetFilters:c,offset:0,length:f})).hits}catch(a){let P=h(a);throw new Error(`Failed loading Algolia entries with '${i.searchText}' query and '${JSON.stringify(c)}' facets from source '${(u=i.source)!=null?u:"default"}' referenced in parameter '${l}': ${P}`)}finally{console.timeEnd(m)}}},limitPolicy:r||p}}function R(e){return e.type===L[0]}function b(e){return!(!e||!e.source||typeof e.searchText=="undefined"||typeof e.count=="undefined")}function V(e){return!e||e<1?1:e>1e3?1e3:e}var $=class{constructor(r){this._clients={},Array.isArray(r)?r.forEach(n=>this.addClient(n)):r&&this.addClient(r)}addClient({source:r="default",client:n,previewClient:o}){if(this._clients[r])throw new Error(`The source ${r} is always registered`);if(!n)throw new Error("You must provide an Algolia client for the AlgoliaClientList");this._clients[r]={client:n,previewClient:o||n}}getClient({source:r="default",isPreviewClient:n}){let o=this._clients[r];if(!!o)return n?o.previewClient:o.client}};export{$ as AlgoliaClientList,L as CANVAS_ALGOLIA_QUERY_PARAMETER_TYPES,w as CANVAS_ALGOLIA_RECORD_PARAMETER_TYPES,j as createAlgoliaQueryEnhancer,S as createAlgoliaRecordEnhancer}; |
@@ -1,1 +0,1 @@ | ||
var L=Object.create;var c=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var $=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var h=e=>c(e,"__esModule",{value:!0});var S=(e,r)=>{h(e);for(var t in r)c(e,t,{get:r[t],enumerable:!0})},N=(e,r,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of V(r))!b.call(e,n)&&n!=="default"&&c(e,n,{get:()=>r[n],enumerable:!(t=Q(r,n))||t.enumerable});return e},T=e=>N(h(c(e!=null?L($(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);S(exports,{AlgoliaClientList:()=>x,CANVAS_ALGOLIA_QUERY_PARAMETER_TYPES:()=>P,createAlgoliaQueryEnhancer:()=>I});var y=T(require("@uniformdev/canvas")),A=(0,y.createLimitPolicy)({throttle:{limit:55,interval:1e3}});function C(e){return typeof e=="string"?e:typeof e=="object"&&e&&"error"in e?e.error:e instanceof Error?e.toString():JSON.stringify(e,null,2)}function E({clients:e,parameterValue:r,parameterName:t,component:n,context:a}){let{source:l="default"}=r,s=e.getClient({source:l,isPreviewClient:a.preview});if(!s)throw new Error(`No Algolia client could be resolved for source key '${l}' referenced in parameter '${t} in component '${n.type}'. Ensure that the 'clients' property you are passing to the enhancer has a client instance registered for the source key.`);return s}var P=Object.freeze(["algoliaQuery"]);function I({clients:e,limitPolicy:r}){if(!e)throw new Error("No Algolia clients were provided to the enhancer. You must provide at least one client via the AlgoliaClientList.");return{enhanceOne:async function({parameter:a,parameterName:l,component:s,context:w}){var g;if(O(a)){if(!F(a.value))return null;let v=E({clients:e,parameterName:l,parameterValue:a.value,component:s,context:w}),i=a.value,d=_(i.count),u=Object.getOwnPropertyNames(i.facetsValues).filter(o=>Array.isArray(i.facetsValues[o])).map(o=>i.facetsValues[o].map(f=>`${o}:${f}`)),p=`fetch query: ${d} entries with '${i.searchText}' query and '${JSON.stringify(u)}' facets`;try{return console.time(p),(await v.search(i.searchText,{facetFilters:u,offset:0,length:d})).hits}catch(o){let f=C(o);throw new Error(`Failed loading Algolia entries with '${i.searchText}' query and '${JSON.stringify(u)}' facets from source '${(g=i.source)!=null?g:"default"}' referenced in parameter '${l}': ${f}`)}finally{console.timeEnd(p)}}},limitPolicy:r||A}}function O(e){return e.type===P[0]}function F(e){return!(!e||!e.source||typeof e.searchText=="undefined"||typeof e.count=="undefined")}function _(e){return!e||e<1?1:e>1e3?1e3:e}var x=class{constructor(r){this._clients={},Array.isArray(r)?r.forEach(t=>this.addClient(t)):r&&this.addClient(r)}addClient({source:r="default",client:t,previewClient:n}){if(this._clients[r])throw new Error(`The source ${r} is always registered`);if(!t)throw new Error("You must provide an Algolia client for the AlgoliaClientList");this._clients[r]={client:t,previewClient:n||t}}getClient({source:r="default",isPreviewClient:t}){let n=this._clients[r];if(!!n)return t?n.previewClient:n.client}};0&&(module.exports={AlgoliaClientList,CANVAS_ALGOLIA_QUERY_PARAMETER_TYPES,createAlgoliaQueryEnhancer}); | ||
var P=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var V=e=>P(e,"__esModule",{value:!0});var $=(e,r)=>{for(var t in r)P(e,t,{get:r[t],enumerable:!0})},I=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of R(r))!b.call(e,n)&&(t||n!=="default")&&P(e,n,{get:()=>r[n],enumerable:!(i=L(r,n))||i.enumerable});return e};var O=(e=>(r,t)=>e&&e.get(r)||(t=I(V({}),r,1),e&&e.set(r,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var D={};$(D,{AlgoliaClientList:()=>v,CANVAS_ALGOLIA_QUERY_PARAMETER_TYPES:()=>x,CANVAS_ALGOLIA_RECORD_PARAMETER_TYPES:()=>w,createAlgoliaQueryEnhancer:()=>S,createAlgoliaRecordEnhancer:()=>F});var E=require("@uniformdev/canvas"),d=(0,E.createLimitPolicy)({throttle:{limit:55,interval:1e3}});function p(e){return typeof e=="string"?e:typeof e=="object"&&e&&"error"in e?e.error:e instanceof Error?e.toString():JSON.stringify(e,null,2)}function h({clients:e,parameterValue:r,parameterName:t,component:i,context:n}){let{source:l="default"}=r,s=e.getClient({source:l,isPreviewClient:n.preview});if(!s)throw new Error(`No Algolia client could be resolved for source key '${l}' referenced in parameter '${t} in component '${i.type}'. Ensure that the 'clients' property you are passing to the enhancer has a client instance registered for the source key.`);return s}var w=Object.freeze(["algoliaRecord"]);function F({clients:e,limitPolicy:r}){if(!e)throw new Error("No Algolia clients were provided to the enhancer. You must provide at least one client via the AlgoliaClientList.");return{enhanceOne:async function({parameter:n,parameterName:l,component:s,context:y}){var u;if(N(n)){if(!Q(n.value))return null;let A=h({clients:e,parameterName:l,parameterValue:n.value,component:s,context:y}),o=n.value,f=`fetch record: ${n.value.objectIDs.length} entries`;try{return console.time(f),(await A.getObjects(n.value.objectIDs)).results}catch(c){let m=p(c);throw new Error(`Failed loading Algolia ${n.value.objectIDs.length} entries from source '${(u=o.source)!=null?u:"default"}' referenced in parameter '${l}': ${m}`)}finally{console.timeEnd(f)}}},limitPolicy:r||d}}function N(e){return e.type===w[0]}function Q(e){return!(!e||!e.objectIDs||e.objectIDs.length<1)}var x=Object.freeze(["algoliaQuery"]);function S({clients:e,limitPolicy:r}){if(!e)throw new Error("No Algolia clients were provided to the enhancer. You must provide at least one client via the AlgoliaClientList.");return{enhanceOne:async function({parameter:n,parameterName:l,component:s,context:y}){var u;if(T(n)){if(!_(n.value))return null;let A=h({clients:e,parameterName:l,parameterValue:n.value,component:s,context:y}),o=n.value,f=j(o.count),c=Object.getOwnPropertyNames(o.facetsValues).filter(a=>Array.isArray(o.facetsValues[a])).map(a=>o.facetsValues[a].map(C=>`${a}:${C}`)),m=`fetch query: ${f} entries with '${o.searchText}' query and '${JSON.stringify(c)}' facets`;try{return console.time(m),(await A.search(o.searchText,{facetFilters:c,offset:0,length:f})).hits}catch(a){let C=p(a);throw new Error(`Failed loading Algolia entries with '${o.searchText}' query and '${JSON.stringify(c)}' facets from source '${(u=o.source)!=null?u:"default"}' referenced in parameter '${l}': ${C}`)}finally{console.timeEnd(m)}}},limitPolicy:r||d}}function T(e){return e.type===x[0]}function _(e){return!(!e||!e.source||typeof e.searchText=="undefined"||typeof e.count=="undefined")}function j(e){return!e||e<1?1:e>1e3?1e3:e}var v=class{constructor(r){this._clients={},Array.isArray(r)?r.forEach(t=>this.addClient(t)):r&&this.addClient(r)}addClient({source:r="default",client:t,previewClient:i}){if(this._clients[r])throw new Error(`The source ${r} is always registered`);if(!t)throw new Error("You must provide an Algolia client for the AlgoliaClientList");this._clients[r]={client:t,previewClient:i||t}}getClient({source:r="default",isPreviewClient:t}){let i=this._clients[r];if(!!i)return t?i.previewClient:i.client}};module.exports=O(D);0&&(module.exports={AlgoliaClientList,CANVAS_ALGOLIA_QUERY_PARAMETER_TYPES,CANVAS_ALGOLIA_RECORD_PARAMETER_TYPES,createAlgoliaQueryEnhancer,createAlgoliaRecordEnhancer}); |
{ | ||
"name": "@uniformdev/canvas-algolia", | ||
"version": "14.0.0", | ||
"version": "14.0.1-alpha.94+f04d6359", | ||
"description": "Algolia data enhancers for Uniform Canvas", | ||
@@ -28,3 +28,3 @@ "license": "SEE LICENSE IN LICENSE.txt", | ||
"dependencies": { | ||
"@uniformdev/canvas": "^14.0.0" | ||
"@uniformdev/canvas": "^14.0.1-alpha.94+f04d6359" | ||
}, | ||
@@ -35,13 +35,13 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"@types/jest": "27.0.3", | ||
"@types/node": "16.11.12", | ||
"algoliasearch": "^4.11.0", | ||
"eslint": "8.4.1", | ||
"eslint-plugin-react": "7.27.1", | ||
"@types/jest": "27.4.0", | ||
"@types/node": "16.11.21", | ||
"algoliasearch": "4.12.0", | ||
"eslint": "8.7.0", | ||
"eslint-plugin-react": "7.28.0", | ||
"eslint-plugin-react-hooks": "4.3.0", | ||
"jest": "27.4.5", | ||
"jest": "27.4.7", | ||
"npm-run-all": "4.1.5", | ||
"rimraf": "3.0.2", | ||
"ts-jest": "27.1.1", | ||
"tsup": "5.11.1" | ||
"ts-jest": "27.1.3", | ||
"tsup": "5.11.11" | ||
}, | ||
@@ -54,3 +54,3 @@ "files": [ | ||
}, | ||
"gitHead": "5f7b1abf0fe161630b53bde4c5530f8b12a1c775" | ||
"gitHead": "f04d63590168a9c7dbbfbf2b2425c72c07f1ce84" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16169
104
3
1