Skip to content

Commit

Permalink
feat(specs): add composition API (generated)
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#4056

Co-authored-by: algolia-bot <[email protected]>
Co-authored-by: Emmanuel Krebs <[email protected]>
Co-authored-by: shortcuts <[email protected]>
Co-authored-by: Pierre Millot <[email protected]>
  • Loading branch information
4 people committed Nov 6, 2024
1 parent 76b5b03 commit 61a0077
Show file tree
Hide file tree
Showing 120 changed files with 3,668 additions and 1 deletion.
4 changes: 4 additions & 0 deletions bundlesize.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
"path": "packages/client-analytics/dist/builds/browser.umd.js",
"maxSize": "4.85KB"
},
{
"path": "packages/client-composition/dist/builds/browser.umd.js",
"maxSize": "4.05KB"
},
{
"path": "packages/client-insights/dist/builds/browser.umd.js",
"maxSize": "3.90KB"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"packages/*"
],
"scripts": {
"build": "lerna run build --scope '@algolia/requester-testing' --scope '@algolia/logger-console' --scope 'algoliasearch' --include-dependencies",
"build": "lerna run build --scope '@algolia/requester-testing' --scope '@algolia/logger-console' --scope 'algoliasearch' --scope '@algolia/client-composition' --include-dependencies",
"clean": "lerna run clean",
"release:bump": "lerna version ${0:-patch} --no-changelog --no-git-tag-version --no-push --exact --force-publish --yes",
"release:publish": "tsc --project scripts/tsconfig.json && node scripts/dist/scripts/publish.js",
Expand Down
21 changes: 21 additions & 0 deletions packages/client-composition/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2013-Present Algolia

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
77 changes: 77 additions & 0 deletions packages/client-composition/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<p align="center">
<a href="https://www.algolia.com">
<img alt="Algolia for JavaScript" src="https://raw.githubusercontent.com/algolia/algoliasearch-client-common/master/banners/javascript.png" >
</a>

<h4 align="center">The perfect starting point to integrate <a href="https://algolia.com" target="_blank">Algolia</a> within your JavaScript project</h4>

<p align="center">
<a href="https://npmjs.org/package/@algolia/client-composition"><img src="https://img.shields.io/npm/v/@algolia/client-composition.svg?style=flat-square" alt="NPM version"></img></a>
<a href="http://npm-stat.com/charts.html?package=@algolia/client-composition"><img src="https://img.shields.io/npm/dm/@algolia/client-composition.svg?style=flat-square" alt="NPM downloads"></a>
<a href="https://www.jsdelivr.com/package/npm/@algolia/client-composition"><img src="https://data.jsdelivr.com/v1/package/npm/@algolia/client-composition/badge" alt="jsDelivr Downloads"></img></a>
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg?style=flat-square" alt="License"></a>
</p>
</p>

<p align="center">
<a href="https://www.algolia.com/doc/libraries/javascript/" target="_blank">Documentation</a> •
<a href="https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/" target="_blank">InstantSearch</a> •
<a href="https://discourse.algolia.com" target="_blank">Community Forum</a> •
<a href="http://stackoverflow.com/questions/tagged/algolia" target="_blank">Stack Overflow</a> •
<a href="https://github.com/algolia/algoliasearch-client-javascript/issues" target="_blank">Report a bug</a> •
<a href="https://www.algolia.com/doc/libraries/javascript/v5/" target="_blank">FAQ</a> •
<a href="https://alg.li/support" target="_blank">Support</a>
</p>

## ✨ Features

- Thin & **minimal low-level HTTP client** to interact with Algolia's API
- Works both on the **browser** and **node.js**
- **UMD and ESM compatible**, you can use it with any module loader
- Built with TypeScript

## 💡 Getting Started

> [!TIP]
> This API client is already a dependency of [the algoliasearch client](https://www.npmjs.com/package/algoliasearch), you don't need to manually install `@algolia/client-composition` if you already have `algoliasearch` installed.
To get started, you first need to install @algolia/client-composition (or any other available API client package).
All of our clients comes with type definition, and are available for both browser and node environments.

### With a package manager

```bash
yarn add @algolia/[email protected]
# or
npm install @algolia/[email protected]
# or
pnpm add @algolia/[email protected]
```

### Without a package manager

Add the following JavaScript snippet to the <head> of your website:

```html
<script src="https://cdn.jsdelivr.net/npm/@algolia/[email protected]/dist/builds/browser.umd.js"></script>
```

### Usage

You can now import the Algolia API client in your project and play with it.

```js
import { compositionClient } from '@algolia/client-composition';

const client = compositionClient('YOUR_APP_ID', 'YOUR_API_KEY');
```

For full documentation, visit the **[Algolia JavaScript API Client](https://www.algolia.com/doc/libraries/javascript/v5/methods/composition/)**.

## ❓ Troubleshooting

Encountering an issue? Before reaching out to support, we recommend heading to our [FAQ](https://www.algolia.com/doc/libraries/javascript/v5/) where you will find answers for the most common issues and gotchas with the client. You can also open [a GitHub issue](https://github.com/algolia/api-clients-automation/issues/new?assignees=&labels=&projects=&template=Bug_report.md)

## 📄 License

The Algolia JavaScript API Client is an open-sourced software licensed under the [MIT license](LICENSE).
53 changes: 53 additions & 0 deletions packages/client-composition/builds/browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

import { createXhrRequester } from '@algolia/requester-browser-xhr';

import {
createBrowserLocalStorageCache,
createFallbackableCache,
createMemoryCache,
createNullLogger,
DEFAULT_CONNECT_TIMEOUT_BROWSER,
DEFAULT_READ_TIMEOUT_BROWSER,
DEFAULT_WRITE_TIMEOUT_BROWSER,
} from '@algolia/client-common';

import type { ClientOptions } from '@algolia/client-common';

import { apiClientVersion, createCompositionClient } from '../src/compositionClient';

export { apiClientVersion } from '../src/compositionClient';

export * from '../model';

export function compositionClient(appId: string, apiKey: string, options?: ClientOptions): CompositionClient {
if (!appId || typeof appId !== 'string') {
throw new Error('`appId` is missing.');
}

if (!apiKey || typeof apiKey !== 'string') {
throw new Error('`apiKey` is missing.');
}

return createCompositionClient({
appId,
apiKey,
timeouts: {
connect: DEFAULT_CONNECT_TIMEOUT_BROWSER,
read: DEFAULT_READ_TIMEOUT_BROWSER,
write: DEFAULT_WRITE_TIMEOUT_BROWSER,
},
logger: createNullLogger(),
requester: createXhrRequester(),
algoliaAgents: [{ segment: 'Browser' }],
authMode: 'WithinQueryParameters',
responsesCache: createMemoryCache(),
requestsCache: createMemoryCache({ serializable: false }),
hostsCache: createFallbackableCache({
caches: [createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }), createMemoryCache()],
}),
...options,
});
}

export type CompositionClient = ReturnType<typeof createCompositionClient>;
50 changes: 50 additions & 0 deletions packages/client-composition/builds/fetch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

export type CompositionClient = ReturnType<typeof createCompositionClient>;

import {
createMemoryCache,
createNullCache,
createNullLogger,
DEFAULT_CONNECT_TIMEOUT_NODE,
DEFAULT_READ_TIMEOUT_NODE,
DEFAULT_WRITE_TIMEOUT_NODE,
} from '@algolia/client-common';
import { createFetchRequester } from '@algolia/requester-fetch';

import type { ClientOptions } from '@algolia/client-common';

import { createCompositionClient } from '../src/compositionClient';

export { apiClientVersion } from '../src/compositionClient';

export * from '../model';

export function compositionClient(appId: string, apiKey: string, options?: ClientOptions): CompositionClient {
if (!appId || typeof appId !== 'string') {
throw new Error('`appId` is missing.');
}

if (!apiKey || typeof apiKey !== 'string') {
throw new Error('`apiKey` is missing.');
}

return {
...createCompositionClient({
appId,
apiKey,
timeouts: {
connect: DEFAULT_CONNECT_TIMEOUT_NODE,
read: DEFAULT_READ_TIMEOUT_NODE,
write: DEFAULT_WRITE_TIMEOUT_NODE,
},
logger: createNullLogger(),
algoliaAgents: [{ segment: 'Fetch' }],
requester: createFetchRequester(),
responsesCache: createNullCache(),
requestsCache: createNullCache(),
hostsCache: createMemoryCache(),
...options,
}),
};
}
51 changes: 51 additions & 0 deletions packages/client-composition/builds/node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

export type CompositionClient = ReturnType<typeof createCompositionClient>;

import { createHttpRequester } from '@algolia/requester-node-http';

import {
createMemoryCache,
createNullCache,
createNullLogger,
DEFAULT_CONNECT_TIMEOUT_NODE,
DEFAULT_READ_TIMEOUT_NODE,
DEFAULT_WRITE_TIMEOUT_NODE,
} from '@algolia/client-common';

import type { ClientOptions } from '@algolia/client-common';

import { createCompositionClient } from '../src/compositionClient';

export { apiClientVersion } from '../src/compositionClient';

export * from '../model';

export function compositionClient(appId: string, apiKey: string, options?: ClientOptions): CompositionClient {
if (!appId || typeof appId !== 'string') {
throw new Error('`appId` is missing.');
}

if (!apiKey || typeof apiKey !== 'string') {
throw new Error('`apiKey` is missing.');
}

return {
...createCompositionClient({
appId,
apiKey,
timeouts: {
connect: DEFAULT_CONNECT_TIMEOUT_NODE,
read: DEFAULT_READ_TIMEOUT_NODE,
write: DEFAULT_WRITE_TIMEOUT_NODE,
},
logger: createNullLogger(),
requester: createHttpRequester(),
algoliaAgents: [{ segment: 'Node.js', version: process.versions.node }],
responsesCache: createNullCache(),
requestsCache: createNullCache(),
hostsCache: createMemoryCache(),
...options,
}),
};
}
1 change: 1 addition & 0 deletions packages/client-composition/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './dist/node';
1 change: 1 addition & 0 deletions packages/client-composition/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./dist/builds/node.cjs');
6 changes: 6 additions & 0 deletions packages/client-composition/model/action.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

/**
* Type of Composition Batch operation.
*/
export type Action = 'upsert' | 'delete';
3 changes: 3 additions & 0 deletions packages/client-composition/model/advancedSyntaxFeatures.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

export type AdvancedSyntaxFeatures = 'exactPhrase' | 'excludeWords';
3 changes: 3 additions & 0 deletions packages/client-composition/model/alternativesAsExact.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

export type AlternativesAsExact = 'ignorePlurals' | 'singleWordSynonym' | 'multiWordsSynonym';
6 changes: 6 additions & 0 deletions packages/client-composition/model/anchoring.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

/**
* Which part of the search query the pattern should match: - `startsWith`. The pattern must match the beginning of the query. - `endsWith`. The pattern must match the end of the query. - `is`. The pattern must match the query exactly. - `contains`. The pattern must match anywhere in the query. Empty queries are only allowed as patterns with `anchoring: is`.
*/
export type Anchoring = 'is' | 'startsWith' | 'endsWith' | 'contains';
8 changes: 8 additions & 0 deletions packages/client-composition/model/aroundPrecision.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

import type { Range } from './range';

/**
* Precision of a coordinate-based search in meters to group results with similar distances. The Geo ranking criterion considers all matches within the same range of distances to be equal.
*/
export type AroundPrecision = number | Array<Range>;
8 changes: 8 additions & 0 deletions packages/client-composition/model/aroundRadius.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

import type { AroundRadiusAll } from './aroundRadiusAll';

/**
* Maximum radius for a search around a central location. This parameter works in combination with the `aroundLatLng` and `aroundLatLngViaIP` parameters. By default, the search radius is determined automatically from the density of hits around the central location. The search radius is small if there are many hits close to the central coordinates.
*/
export type AroundRadius = number | AroundRadiusAll;
6 changes: 6 additions & 0 deletions packages/client-composition/model/aroundRadiusAll.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

/**
* Return all records with a valid `_geoloc` attribute. Don\'t filter by distance.
*/
export type AroundRadiusAll = 'all';
13 changes: 13 additions & 0 deletions packages/client-composition/model/banner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

import type { BannerImage } from './bannerImage';
import type { BannerLink } from './bannerLink';

/**
* a search banner with image and url.
*/
export type Banner = {
image?: BannerImage;

link?: BannerLink;
};
12 changes: 12 additions & 0 deletions packages/client-composition/model/bannerImage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

import type { BannerImageUrl } from './bannerImageUrl';

/**
* image of a search banner.
*/
export type BannerImage = {
urls?: Array<BannerImageUrl>;

title?: string;
};
8 changes: 8 additions & 0 deletions packages/client-composition/model/bannerImageUrl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

/**
* url for a search banner image.
*/
export type BannerImageUrl = {
url?: string;
};
8 changes: 8 additions & 0 deletions packages/client-composition/model/bannerLink.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

/**
* link for a banner defined in merchandising studio.
*/
export type BannerLink = {
url?: string;
};
6 changes: 6 additions & 0 deletions packages/client-composition/model/baseSearchParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

import type { BaseSearchParamsWithoutQuery } from './baseSearchParamsWithoutQuery';
import type { SearchParamsQuery } from './searchParamsQuery';

export type BaseSearchParams = SearchParamsQuery & BaseSearchParamsWithoutQuery;
Loading

0 comments on commit 61a0077

Please sign in to comment.