Socket
Socket
Sign inDemoInstall

@algolia/client-common

Package Overview
Dependencies
Maintainers
3
Versions
221
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algolia/client-common - npm Package Compare versions

Comparing version 5.3.2 to 5.4.0

dist/common.js

13

dist/common.d.ts

@@ -158,7 +158,2 @@ type Cache = {

};
type EchoResponse = Omit<EndRequest, 'data'> & Pick<Request, 'data' | 'path'> & {
host: string;
algoliaAgent: string;
searchParams?: Record<string, string>;
};

@@ -341,8 +336,2 @@ type Headers = Record<string, string>;

type EchoRequesterParams = {
getURL: (url: string) => URL;
status?: number;
};
declare function createEchoRequester({ getURL, status }: EchoRequesterParams): Requester;
/**

@@ -440,2 +429,2 @@ * Helper: Returns the promise of a given `func` to iterate on, based on a given `validate` condition.

export { type AlgoliaAgent, type AlgoliaAgentOptions, AlgoliaError, ApiError, type AuthMode, type BrowserLocalStorageCacheItem, type BrowserLocalStorageOptions, type Cache, type CacheEvents, type ClientOptions, type CreateClientOptions, type CreateIterablePromise, DEFAULT_CONNECT_TIMEOUT_BROWSER, DEFAULT_CONNECT_TIMEOUT_NODE, DEFAULT_READ_TIMEOUT_BROWSER, DEFAULT_READ_TIMEOUT_NODE, DEFAULT_WRITE_TIMEOUT_BROWSER, DEFAULT_WRITE_TIMEOUT_NODE, DeserializationError, DetailedApiError, type DetailedError, type DetailedErrorWithMessage, type DetailedErrorWithTypeID, type EchoRequesterParams, type EchoResponse, type EndRequest, ErrorWithStackTrace, type FallbackableCacheOptions, type GetAlgoliaAgent, type Headers, type Host, type IterableOptions, type MemoryCacheOptions, type Method, type QueryParameters, type Request, type RequestOptions, type Requester, type Response, RetryError, type StackFrame, type StatefulHost, type Timeouts, type Transporter, type TransporterOptions, createAlgoliaAgent, createAuth, createBrowserLocalStorageCache, createEchoRequester, createFallbackableCache, createIterablePromise, createMemoryCache, createNullCache, createStatefulHost, createTransporter, deserializeFailure, deserializeSuccess, getAlgoliaAgent, isNetworkError, isRetryable, isSuccess, serializeData, serializeHeaders, serializeQueryParameters, serializeUrl, shuffle, stackFrameWithoutCredentials, stackTraceWithoutCredentials };
export { type AlgoliaAgent, type AlgoliaAgentOptions, AlgoliaError, ApiError, type AuthMode, type BrowserLocalStorageCacheItem, type BrowserLocalStorageOptions, type Cache, type CacheEvents, type ClientOptions, type CreateClientOptions, type CreateIterablePromise, DEFAULT_CONNECT_TIMEOUT_BROWSER, DEFAULT_CONNECT_TIMEOUT_NODE, DEFAULT_READ_TIMEOUT_BROWSER, DEFAULT_READ_TIMEOUT_NODE, DEFAULT_WRITE_TIMEOUT_BROWSER, DEFAULT_WRITE_TIMEOUT_NODE, DeserializationError, DetailedApiError, type DetailedError, type DetailedErrorWithMessage, type DetailedErrorWithTypeID, type EndRequest, ErrorWithStackTrace, type FallbackableCacheOptions, type GetAlgoliaAgent, type Headers, type Host, type IterableOptions, type MemoryCacheOptions, type Method, type QueryParameters, type Request, type RequestOptions, type Requester, type Response, RetryError, type StackFrame, type StatefulHost, type Timeouts, type Transporter, type TransporterOptions, createAlgoliaAgent, createAuth, createBrowserLocalStorageCache, createFallbackableCache, createIterablePromise, createMemoryCache, createNullCache, createStatefulHost, createTransporter, deserializeFailure, deserializeSuccess, getAlgoliaAgent, isNetworkError, isRetryable, isSuccess, serializeData, serializeHeaders, serializeQueryParameters, serializeUrl, shuffle, stackFrameWithoutCredentials, stackTraceWithoutCredentials };
export * from './src/createAuth';
export * from './src/createEchoRequester';
export * from './src/createIterablePromise';

@@ -4,0 +3,0 @@ export * from './src/cache';

{
"name": "@algolia/client-common",
"version": "5.3.2",
"version": "5.4.0",
"description": "Common package for the Algolia JavaScript API client.",

@@ -24,4 +24,4 @@ "repository": {

},
"import": "./dist/common.esm.js",
"module": "./dist/common.esm.js",
"import": "./dist/common.js",
"module": "./dist/common.js",
"require": "./dist/common.cjs"

@@ -34,3 +34,3 @@ },

"clean": "rm -rf ./dist || true",
"test": "jest",
"test": "vitest --run",
"test:bundle": "publint . && attw --pack ."

@@ -40,12 +40,9 @@ },

"@arethetypeswrong/cli": "0.16.1",
"@babel/preset-env": "7.25.4",
"@babel/preset-typescript": "7.24.7",
"@types/jest": "29.5.12",
"@types/node": "22.5.1",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"jsdom": "25.0.0",
"publint": "0.2.10",
"ts-jest": "29.2.5",
"ts-node": "10.9.2",
"tsup": "8.2.4",
"typescript": "5.5.4"
"typescript": "5.5.4",
"vitest": "2.0.5"
},

@@ -52,0 +49,0 @@ "engines": {

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

import { vi, describe, test, beforeEach, expect } from 'vitest';
import { createBrowserLocalStorageCache } from '../../cache';

@@ -15,3 +17,3 @@

describe('browser local storage cache', () => {
const missMock = jest.fn();
const missMock = vi.fn();
const events = {

@@ -23,6 +25,6 @@ miss: (): Promise<any> => Promise.resolve(missMock()),

window.localStorage.clear();
jest.clearAllMocks();
vi.clearAllMocks();
});
it('sets/gets values', async () => {
test('sets/gets values', async () => {
const cache = createBrowserLocalStorageCache({ key: version });

@@ -40,3 +42,3 @@ const defaultValue = (): DefaultValue => Promise.resolve({ bar: 1 });

it('reads unexpired timeToLive keys', async () => {
test('reads unexpired timeToLive keys', async () => {
const cache = createBrowserLocalStorageCache({

@@ -59,3 +61,3 @@ key: version,

it('deletes keys', async () => {
test('deletes keys', async () => {
const cache = createBrowserLocalStorageCache({ key: version });

@@ -72,3 +74,3 @@

it('deletes expired keys', async () => {
test('deletes expired keys', async () => {
const cache = createBrowserLocalStorageCache({

@@ -91,3 +93,3 @@ key: version,

it('can be cleared', async () => {
test('can be cleared', async () => {
const cache = createBrowserLocalStorageCache({ key: version });

@@ -113,3 +115,3 @@ await cache.set({ key: 'foo' }, { bar: 1 });

it('do throws localstorage exceptions on access', async () => {
test('do throws localstorage exceptions on access', async () => {
const message = "Failed to read the 'localStorage' property from 'Window': Access is denied for this document.";

@@ -140,3 +142,3 @@ const cache = createBrowserLocalStorageCache(

it('do throws localstorage exceptions after access', async () => {
test('do throws localstorage exceptions after access', async () => {
const cache = createBrowserLocalStorageCache({

@@ -156,3 +158,3 @@ key: version,

it('creates a namespace within local storage', async () => {
test('creates a namespace within local storage', async () => {
const cache = createBrowserLocalStorageCache({

@@ -159,0 +161,0 @@ key: version,

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

import { describe, test, expect } from 'vitest';
import {

@@ -24,3 +26,3 @@ createBrowserLocalStorageCache,

it('always fallback in null cache', async () => {
test('always fallback in null cache', async () => {
const cache = createFallbackableCache({ caches: [] });

@@ -35,3 +37,3 @@

describe('order', () => {
it('use memory cache', async () => {
test('use memory cache', async () => {
const cache = createFallbackableCache({

@@ -48,3 +50,3 @@ caches: [createMemoryCache()],

it('use null cache first', async () => {
test('use null cache first', async () => {
const cache = createFallbackableCache({

@@ -62,69 +64,67 @@ caches: [createNullCache(), createMemoryCache()],

describe('fallbacks', () => {
it('to memory cache', async () => {
const cache = createFallbackableCache({
caches: [
createBrowserLocalStorageCache({
key: version,
// @ts-expect-error this will make the cache fail, and normally we fallback on memory cache
localStorage: {},
}),
createMemoryCache(),
],
});
test('fallback to to memory cache', async () => {
const cache = createFallbackableCache({
caches: [
createBrowserLocalStorageCache({
key: version,
// @ts-expect-error this will make the cache fail, and normally we fallback on memory cache
localStorage: {},
}),
createMemoryCache(),
],
});
await cache.set(key, value);
await cache.set(key, value);
expect(await cache.get(key, defaultValue)).toEqual({
3: 4,
});
expect(await cache.get(key, defaultValue)).toEqual({
3: 4,
});
});
it('to null cache', async () => {
const cache = createFallbackableCache({
caches: [
createBrowserLocalStorageCache({
key: version,
// @ts-expect-error this will make the cache fail, and normally we fallback on memory cache
localStorage: {},
}),
],
});
test('fallback to null cache', async () => {
const cache = createFallbackableCache({
caches: [
createBrowserLocalStorageCache({
key: version,
// @ts-expect-error this will make the cache fail, and normally we fallback on memory cache
localStorage: {},
}),
],
});
await cache.set(key, value);
await cache.set(key, value);
expect(await cache.get(key, defaultValue)).toEqual({
5: 6,
});
expect(await cache.get(key, defaultValue)).toEqual({
5: 6,
});
});
it('to memory cache', async () => {
const cache = createFallbackableCache({
caches: [
createBrowserLocalStorageCache({
key: version,
// @ts-expect-error this will make the cache fail
localStorage: {},
}),
createBrowserLocalStorageCache({
key: version,
localStorage: notAvailableStorage, // this will make the cache fail due localStorage not available
}),
createMemoryCache(),
],
});
test('fallback to memory cache', async () => {
const cache = createFallbackableCache({
caches: [
createBrowserLocalStorageCache({
key: version,
// @ts-expect-error this will make the cache fail
localStorage: {},
}),
createBrowserLocalStorageCache({
key: version,
localStorage: notAvailableStorage, // this will make the cache fail due localStorage not available
}),
createMemoryCache(),
],
});
await cache.set(key, value);
await cache.set(key, value);
expect(await cache.get(key, defaultValue)).toEqual({
3: 4,
});
expect(await cache.get(key, defaultValue)).toEqual({
3: 4,
});
await cache.clear();
await cache.clear();
expect(await cache.get(key, defaultValue)).toEqual({
5: 6,
});
expect(await cache.get(key, defaultValue)).toEqual({
5: 6,
});
});
});

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

import { vi, describe, test, beforeEach, expect } from 'vitest';
import { createMemoryCache } from '../../cache';

@@ -6,3 +8,3 @@

describe('memory cache', () => {
const missMock = jest.fn();
const missMock = vi.fn();
const events = {

@@ -13,6 +15,6 @@ miss: (): Promise<any> => Promise.resolve(missMock()),

beforeEach(() => {
jest.clearAllMocks();
vi.clearAllMocks();
});
it('sets/gets values', async () => {
test('sets/gets values', async () => {
const cache = createMemoryCache();

@@ -32,3 +34,3 @@ const defaultValue = (): DefaultValue => Promise.resolve({ bar: 1 });

it('getted values do not have references to the value on cache', async () => {
test('getted values do not have references to the value on cache', async () => {
const cache = createMemoryCache();

@@ -48,3 +50,3 @@ const key = { foo: 'bar' };

it('deletes keys', async () => {
test('deletes keys', async () => {
const cache = createMemoryCache();

@@ -61,3 +63,3 @@

it('can be cleared', async () => {
test('can be cleared', async () => {
const cache = createMemoryCache();

@@ -74,3 +76,3 @@

it('do not force promise based api for clearing cache', async () => {
test('do not force promise based api for clearing cache', async () => {
const cache = createMemoryCache();

@@ -77,0 +79,0 @@

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

import { vi, describe, test, beforeEach, expect } from 'vitest';
import { createNullCache } from '../../cache';

@@ -7,3 +9,3 @@

const cache = createNullCache();
const missMock = jest.fn();
const missMock = vi.fn();
const events = {

@@ -14,6 +16,6 @@ miss: (): Promise<any> => Promise.resolve(missMock()),

beforeEach(() => {
jest.clearAllMocks();
vi.clearAllMocks();
});
it('does not set value', async () => {
test('does not set value', async () => {
const defaultValue = (): DefaultValue => Promise.resolve({ bar: 12 });

@@ -30,3 +32,3 @@

it('returns default value', async () => {
test('returns default value', async () => {
const defaultValue = (): DefaultValue => Promise.resolve({ bar: 12 });

@@ -41,9 +43,9 @@

it('can be deleted', async () => {
await cache.delete('foo');
test('can be deleted', () => {
expect(async () => await cache.delete('foo')).not.toThrowError();
});
it('can be cleared', async () => {
await cache.clear();
test('can be cleared', () => {
expect(async () => await cache.clear()).not.toThrowError();
});
});

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

import { describe, test, expect } from 'vitest';
import { createIterablePromise } from '../createIterablePromise';

@@ -5,3 +7,3 @@

describe('func', () => {
it('provides the `previousResponse` parameter', async () => {
test('provides the `previousResponse` parameter', async () => {
const responses: Array<string | undefined> = [];

@@ -24,3 +26,3 @@ const promise = createIterablePromise<string | undefined>({

describe('validate', () => {
it('iterates on a `func` until `validate` is met', async () => {
test('iterates on a `func` until `validate` is met', async () => {
let calls = 0;

@@ -41,3 +43,3 @@ const promise = createIterablePromise({

it('forward the response of the `func`', async () => {
test('forward the response of the `func`', async () => {
let calls = 0;

@@ -60,3 +62,3 @@ const promise = createIterablePromise<number>({

describe('aggregator', () => {
it('is called before iterating', async () => {
test('is called before iterating', async () => {
let calls = 0;

@@ -80,3 +82,3 @@ let count = 0;

it('forward the response of the `func`', async () => {
test('forward the response of the `func`', async () => {
let calls = 0;

@@ -104,3 +106,3 @@ const responses: string[] = [];

describe('timeout', () => {
it('defaults to no timeout (0)', async () => {
test('defaults to no timeout (0)', async () => {
let calls = 0;

@@ -125,3 +127,3 @@ const before = Date.now();

it('waits before calling the `func` again', async () => {
test('waits before calling the `func` again', async () => {
let calls = 0;

@@ -149,3 +151,3 @@ const before = Date.now();

describe('error', () => {
it('gets the rejection of the given promise via reject', async () => {
test('gets the rejection of the given promise via reject', async () => {
let calls = 0;

@@ -170,3 +172,3 @@

it('gets the rejection of the given promise via throw', async () => {
test('gets the rejection of the given promise via throw', async () => {
let calls = 0;

@@ -191,3 +193,3 @@

it('rejects with the given `message` when `validate` hits', async () => {
test('rejects with the given `message` when `validate` hits', async () => {
const MAX_RETRIES = 3;

@@ -218,3 +220,3 @@ let calls = 0;

it('forward the response of the `func`', async () => {
test('forward the response of the `func`', async () => {
const MAX_RETRIES = 3;

@@ -221,0 +223,0 @@ let calls = 0;

@@ -66,8 +66,1 @@ import type { Headers, QueryParameters } from './transporter';

};
export type EchoResponse = Omit<EndRequest, 'data'> &
Pick<Request, 'data' | 'path'> & {
host: string;
algoliaAgent: string;
searchParams?: Record<string, string>;
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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