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

@algolia/client-personalization

Package Overview
Dependencies
Maintainers
67
Versions
194
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algolia/client-personalization - npm Package Compare versions

Comparing version 4.14.1 to 5.0.0-alpha.1

dist/builds/browser.d.ts

304

dist/client-personalization.cjs.js

@@ -6,45 +6,281 @@ 'use strict';

var clientCommon = require('@algolia/client-common');
var transporter = require('@algolia/transporter');
var requesterCommon = require('@algolia/requester-common');
var requesterNodeHttp = require('@algolia/requester-node-http');
const createPersonalizationClient = options => {
const region = options.region || 'us';
const auth = clientCommon.createAuth(clientCommon.AuthMode.WithinHeaders, options.appId, options.apiKey);
const transporter$1 = transporter.createTransporter({
hosts: [{ url: `personalization.${region}.algolia.com` }],
// This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
const apiClientVersion = '5.0.0-alpha.1';
const REGIONS = ['eu', 'us'];
function getDefaultHosts(region) {
const url = 'personalization.{region}.algolia.com'.replace('{region}', region);
return [{ url, accept: 'readWrite', protocol: 'https' }];
}
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
function createPersonalizationClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }) {
const auth = clientCommon.createAuth(appIdOption, apiKeyOption, authMode);
const transporter = clientCommon.createTransporter({
hosts: getDefaultHosts(regionOption),
...options,
headers: {
algoliaAgent: clientCommon.getAlgoliaAgent({
algoliaAgents,
client: 'Personalization',
version: apiClientVersion,
}),
baseHeaders: {
'content-type': 'text/plain',
...auth.headers(),
...{ 'content-type': 'application/json' },
...options.headers,
...options.baseHeaders,
},
queryParameters: {
baseQueryParameters: {
...auth.queryParameters(),
...options.queryParameters,
...options.baseQueryParameters,
},
});
return clientCommon.addMethods({ appId: options.appId, transporter: transporter$1 }, options.methods);
};
const getPersonalizationStrategy = (base) => {
return (requestOptions) => {
return base.transporter.read({
method: requesterCommon.MethodEnum.Get,
path: '1/strategies/personalization',
}, requestOptions);
return {
transporter,
/**
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
*/
get _ua() {
return transporter.algoliaAgent.value;
},
/**
* Adds a `segment` to the `x-algolia-agent` sent with every requests.
*
* @param segment - The algolia agent (user-agent) segment to add.
* @param version - The version of the agent.
*/
addAlgoliaAgent(segment, version) {
transporter.algoliaAgent.add({ segment, version });
},
/**
* This method allow you to send requests to the Algolia REST API.
*
* @summary Send requests to the Algolia REST API.
* @param del - The del object.
* @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
* @param del.parameters - Query parameters to be applied to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
del({ path, parameters }, requestOptions) {
if (!path) {
throw new Error('Parameter `path` is required when calling `del`.');
}
const requestPath = '/1{path}'.replace('{path}', path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: 'DELETE',
path: requestPath,
queryParameters,
headers,
};
return transporter.request(request, requestOptions);
},
/**
* Delete the user profile and all its associated data. Returns, as part of the response, a date until which the data can safely be considered as deleted for the given user. This means if you send events for the given user before this date, they will be ignored. Any data received after the deletedUntil date will start building a new user profile. It might take a couple hours for the deletion request to be fully processed.
*
* @summary Delete a user profile.
* @param deleteUserProfile - The deleteUserProfile object.
* @param deleteUserProfile.userToken - UserToken representing the user for which to fetch the Personalization profile.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
deleteUserProfile({ userToken }, requestOptions) {
if (!userToken) {
throw new Error('Parameter `userToken` is required when calling `deleteUserProfile`.');
}
const requestPath = '/1/profiles/{userToken}'.replace('{userToken}', encodeURIComponent(userToken));
const headers = {};
const queryParameters = {};
const request = {
method: 'DELETE',
path: requestPath,
queryParameters,
headers,
};
return transporter.request(request, requestOptions);
},
/**
* This method allow you to send requests to the Algolia REST API.
*
* @summary Send requests to the Algolia REST API.
* @param get - The get object.
* @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
* @param get.parameters - Query parameters to be applied to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
get({ path, parameters }, requestOptions) {
if (!path) {
throw new Error('Parameter `path` is required when calling `get`.');
}
const requestPath = '/1{path}'.replace('{path}', path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: 'GET',
path: requestPath,
queryParameters,
headers,
};
return transporter.request(request, requestOptions);
},
/**
* The strategy contains information on the events and facets that impact user profiles and personalized search results.
*
* @summary Get the current strategy.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getPersonalizationStrategy(requestOptions) {
const requestPath = '/1/strategies/personalization';
const headers = {};
const queryParameters = {};
const request = {
method: 'GET',
path: requestPath,
queryParameters,
headers,
};
return transporter.request(request, requestOptions);
},
/**
* Get the user profile built from Personalization strategy. The profile is structured by facet name used in the strategy. Each facet value is mapped to its score. Each score represents the user affinity for a specific facet value given the userToken past events and the Personalization strategy defined. Scores are bounded to 20. The last processed event timestamp is provided using the ISO 8601 format for debugging purposes.
*
* @summary Get a user profile.
* @param getUserTokenProfile - The getUserTokenProfile object.
* @param getUserTokenProfile.userToken - UserToken representing the user for which to fetch the Personalization profile.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getUserTokenProfile({ userToken }, requestOptions) {
if (!userToken) {
throw new Error('Parameter `userToken` is required when calling `getUserTokenProfile`.');
}
const requestPath = '/1/profiles/personalization/{userToken}'.replace('{userToken}', encodeURIComponent(userToken));
const headers = {};
const queryParameters = {};
const request = {
method: 'GET',
path: requestPath,
queryParameters,
headers,
};
return transporter.request(request, requestOptions);
},
/**
* This method allow you to send requests to the Algolia REST API.
*
* @summary Send requests to the Algolia REST API.
* @param post - The post object.
* @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
* @param post.parameters - Query parameters to be applied to the current query.
* @param post.body - The parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
post({ path, parameters, body }, requestOptions) {
if (!path) {
throw new Error('Parameter `path` is required when calling `post`.');
}
const requestPath = '/1{path}'.replace('{path}', path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: 'POST',
path: requestPath,
queryParameters,
headers,
data: body ? body : {},
};
return transporter.request(request, requestOptions);
},
/**
* This method allow you to send requests to the Algolia REST API.
*
* @summary Send requests to the Algolia REST API.
* @param put - The put object.
* @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
* @param put.parameters - Query parameters to be applied to the current query.
* @param put.body - The parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
put({ path, parameters, body }, requestOptions) {
if (!path) {
throw new Error('Parameter `path` is required when calling `put`.');
}
const requestPath = '/1{path}'.replace('{path}', path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: 'PUT',
path: requestPath,
queryParameters,
headers,
data: body ? body : {},
};
return transporter.request(request, requestOptions);
},
/**
* A strategy defines the events and facets that impact user profiles and personalized search results.
*
* @summary Set a new strategy.
* @param personalizationStrategyParams - The personalizationStrategyParams object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
setPersonalizationStrategy(personalizationStrategyParams, requestOptions) {
if (!personalizationStrategyParams) {
throw new Error('Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`.');
}
if (!personalizationStrategyParams.eventScoring) {
throw new Error('Parameter `personalizationStrategyParams.eventScoring` is required when calling `setPersonalizationStrategy`.');
}
if (!personalizationStrategyParams.facetScoring) {
throw new Error('Parameter `personalizationStrategyParams.facetScoring` is required when calling `setPersonalizationStrategy`.');
}
if (!personalizationStrategyParams.personalizationImpact) {
throw new Error('Parameter `personalizationStrategyParams.personalizationImpact` is required when calling `setPersonalizationStrategy`.');
}
const requestPath = '/1/strategies/personalization';
const headers = {};
const queryParameters = {};
const request = {
method: 'POST',
path: requestPath,
queryParameters,
headers,
data: personalizationStrategyParams,
};
return transporter.request(request, requestOptions);
},
};
};
}
const setPersonalizationStrategy = (base) => {
return (personalizationStrategy, requestOptions) => {
return base.transporter.write({
method: requesterCommon.MethodEnum.Post,
path: '1/strategies/personalization',
data: personalizationStrategy,
}, requestOptions);
};
};
// This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
function personalizationClient(appId, apiKey, region, options) {
if (!appId || typeof appId !== 'string') {
throw new Error('`appId` is missing.');
}
if (!apiKey || typeof apiKey !== 'string') {
throw new Error('`apiKey` is missing.');
}
if (!region) {
throw new Error('`region` is missing.');
}
if (region && (typeof region !== 'string' || !REGIONS.includes(region))) {
throw new Error(`\`region\` must be one of the following: ${REGIONS.join(', ')}`);
}
return createPersonalizationClient({
appId,
apiKey,
region,
timeouts: {
connect: clientCommon.DEFAULT_CONNECT_TIMEOUT_NODE,
read: clientCommon.DEFAULT_READ_TIMEOUT_NODE,
write: clientCommon.DEFAULT_WRITE_TIMEOUT_NODE,
},
requester: requesterNodeHttp.createHttpRequester(),
algoliaAgents: [{ segment: 'Node.js', version: process.versions.node }],
responsesCache: clientCommon.createNullCache(),
requestsCache: clientCommon.createNullCache(),
hostsCache: clientCommon.createMemoryCache(),
...options,
});
}
exports.createPersonalizationClient = createPersonalizationClient;
exports.getPersonalizationStrategy = getPersonalizationStrategy;
exports.setPersonalizationStrategy = setPersonalizationStrategy;
exports.apiClientVersion = apiClientVersion;
exports.personalizationClient = personalizationClient;

2

index.js

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

// eslint-disable-next-line functional/immutable-data, import/no-commonjs
// eslint-disable-next-line import/no-commonjs,import/extensions
module.exports = require('./dist/client-personalization.cjs.js');
{
"name": "@algolia/client-personalization",
"version": "4.14.1",
"private": false,
"repository": {
"type": "git",
"url": "git://github.com/algolia/algoliasearch-client-javascript.git"
},
"version": "5.0.0-alpha.1",
"description": "JavaScript client for client-personalization",
"repository": "algolia/algoliasearch-client-javascript",
"license": "MIT",
"sideEffects": false,
"author": "Algolia",
"main": "index.js",
"module": "dist/client-personalization.esm.js",
"types": "dist/client-personalization.d.ts",
"jsdelivr": "dist/client-personalization.umd.js",
"unpkg": "dist/client-personalization.umd.js",
"module": "dist/client-personalization.esm.node.js",
"browser": "dist/client-personalization.umd.js",
"types": "index.d.ts",
"files": [
"dist",
"model",
"index.js",
"dist"
"index.d.ts"
],
"scripts": {
"clean": "rm -rf ./dist"
},
"dependencies": {
"@algolia/client-common": "4.14.1",
"@algolia/requester-common": "4.14.1",
"@algolia/transporter": "4.14.1"
"@algolia/client-common": "5.0.0-alpha.1",
"@algolia/requester-browser-xhr": "5.0.0-alpha.1",
"@algolia/requester-node-http": "5.0.0-alpha.1"
},
"devDependencies": {
"@types/node": "16.11.45",
"typescript": "4.7.4"
},
"engines": {
"node": ">= 14.0.0"
}
}
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