Skip to content

Commit e8232d1

Browse files
algolia-botmillotp
andcommitted
feat(spec): eslint with custom rules APIC-387
algolia/api-clients-automation#304 Co-authored-by: Pierre Millot <[email protected]>
1 parent 42ec9f9 commit e8232d1

File tree

366 files changed

+17151
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

366 files changed

+17151
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release packages
2+
3+
on:
4+
push:
5+
branches:
6+
- next
7+
8+
jobs:
9+
release:
10+
name: Publish
11+
runs-on: ubuntu-20.04
12+
if: "startsWith(github.event.head_commit.message, 'chore: release v')"
13+
steps:
14+
- uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Install Node
19+
uses: actions/setup-node@v2
20+
with:
21+
node-version-file: .nvmrc
22+
cache: yarn
23+
24+
- name: Install JavaScript dependencies
25+
shell: bash
26+
run: yarn install
27+
28+
- name: Build clients
29+
shell: bash
30+
run: yarn build
31+
32+
- name: Publish to NPM
33+
shell: bash
34+
run: yarn release:publish
35+
env:
36+
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
**dist
2+
**.openapi-generator
3+
4+
yarn-error.log
5+
6+
.yarn/*
7+
!.yarn/releases
8+
!.yarn/plugins
9+
10+
node_modules
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
16.13.1

algoliasearch-client-javascript/.yarn/releases/yarn-3.1.1.cjs

Lines changed: 768 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
nodeLinker: node-modules
2+
3+
yarnPath: .yarn/releases/yarn-3.1.1.cjs
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
....
2+
3+
<p align="center">
4+
<a href="https://www.algolia.com">
5+
<img alt="Algolia for JavaScript" src="https://raw.githubusercontent.com/algolia/algoliasearch-client-common/master/banners/javascript.png" >
6+
</a>
7+
8+
<h4 align="center">The perfect starting point to integrate <a href="https://algolia.com" target="_blank">Algolia</a> within your JavaScript project</h4>
9+
10+
<p align="center">
11+
<a href="https://npmjs.org/package/algoliasearch"><img src="https://img.shields.io/npm/v/algoliasearch.svg?style=flat-square" alt="NPM version"></img></a>
12+
<a href="http://npm-stat.com/charts.html?package=algoliasearch"><img src="https://img.shields.io/npm/dm/algoliasearch.svg?style=flat-square" alt="NPM downloads"></a>
13+
<a href="https://www.jsdelivr.com/package/npm/algoliasearch"><img src="https://data.jsdelivr.com/v1/package/npm/algoliasearch/badge" alt="jsDelivr Downloads"></img></a>
14+
<a href="LICENSE.md"><img src="https://img.shields.io/badge/license-MIT-green.svg?style=flat-square" alt="License"></a>
15+
</p>
16+
</p>
17+
18+
<p align="center">
19+
<a href="https://www.algolia.com/doc/api-client/getting-started/install/javascript/" target="_blank">Documentation</a> •
20+
<a href="https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/" target="_blank">InstantSearch</a> •
21+
<a href="https://discourse.algolia.com" target="_blank">Community Forum</a> •
22+
<a href="http://stackoverflow.com/questions/tagged/algolia" target="_blank">Stack Overflow</a> •
23+
<a href="https://github.com/algolia/algoliasearch-client-javascript/issues" target="_blank">Report a bug</a> •
24+
<a href="https://www.algolia.com/doc/api-client/troubleshooting/faq/javascript/" target="_blank">FAQ</a> •
25+
<a href="https://www.algolia.com/support" target="_blank">Support</a>
26+
</p>
27+
28+
# Contributing to this repository
29+
30+
The Algolia API clients are automatically generated, you can find everything here https://github.com/algolia/api-clients-automation
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"files": [
3+
{
4+
"path": "packages/algoliasearch/dist/algoliasearch.umd.browser.js",
5+
"maxSize": "7.05KB"
6+
},
7+
{
8+
"path": "packages/client-abtesting/dist/client-abtesting.umd.browser.js",
9+
"maxSize": "3.85KB"
10+
},
11+
{
12+
"path": "packages/client-analytics/dist/client-analytics.umd.browser.js",
13+
"maxSize": "4.45KB"
14+
},
15+
{
16+
"path": "packages/client-insights/dist/client-insights.umd.browser.js",
17+
"maxSize": "3.70KB"
18+
},
19+
{
20+
"path": "packages/client-personalization/dist/client-personalization.umd.browser.js",
21+
"maxSize": "3.85KB"
22+
},
23+
{
24+
"path": "packages/client-query-suggestions/dist/client-query-suggestions.umd.browser.js",
25+
"maxSize": "3.90KB"
26+
},
27+
{
28+
"path": "packages/client-search/dist/client-search.umd.browser.js",
29+
"maxSize": "5.85KB"
30+
},
31+
{
32+
"path": "packages/client-sources/dist/client-sources.umd.browser.js",
33+
"maxSize": "3.70KB"
34+
},
35+
{
36+
"path": "packages/recommend/dist/recommend.umd.browser.js",
37+
"maxSize": "3.80KB"
38+
},
39+
{
40+
"path": "packages/client-common/dist/client-common.esm.node.js",
41+
"maxSize": "5.25KB"
42+
},
43+
{
44+
"path": "packages/requester-browser-xhr/dist/requester-browser-xhr.esm.node.js",
45+
"maxSize": "900B"
46+
},
47+
{
48+
"path": "packages/requester-node-http/dist/requester-node-http.esm.node.js",
49+
"maxSize": "1.15KB"
50+
}
51+
]
52+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"packages": ["packages/*"],
3+
"version": "independent"
4+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "algoliasearch-client-javascript",
3+
"workspaces": [
4+
"packages/*"
5+
],
6+
"private": true,
7+
"scripts": {
8+
"build:utils": "yarn build client-common && yarn build requester-browser-xhr && yarn build requester-node-http",
9+
"build": "CLIENT=${0:-all} yarn rollup -c rollup.config.js",
10+
"clean:utils": "yarn workspace @experimental-api-clients-automation/client-common clean && yarn workspace @experimental-api-clients-automation/requester-node-http clean && yarn workspace @experimental-api-clients-automation/requester-browser-xhr clean",
11+
"clean": "rm -rf packages/*/dist",
12+
"release": "shipjs prepare",
13+
"test:size": "bundlesize",
14+
"test:lint": "eslint . --ext .js,.ts",
15+
"test:types": "yarn tsc --noEmit",
16+
"release:bump": "lerna version ${0:-patch} --no-changelog --no-git-tag-version --no-push --yes",
17+
"release:publish": "ts-node scripts/publish.ts"
18+
},
19+
"devDependencies": {
20+
"@babel/core": "7.17.8",
21+
"@babel/plugin-proposal-class-properties": "7.16.7",
22+
"@babel/plugin-transform-runtime": "7.17.0",
23+
"@babel/preset-env": "7.16.11",
24+
"@babel/runtime": "7.17.8",
25+
"@rollup/plugin-babel": "5.3.1",
26+
"@rollup/plugin-node-resolve": "13.1.3",
27+
"@types/rollup-plugin-node-globals": "1.4.1",
28+
"bundlesize2": "0.0.31",
29+
"execa": "6.1.0",
30+
"lerna": "4.0.0",
31+
"rollup": "2.67.1",
32+
"rollup-plugin-filesize": "9.1.2",
33+
"rollup-plugin-node-globals": "1.4.0",
34+
"rollup-plugin-terser": "7.0.2",
35+
"rollup-plugin-typescript2": "0.31.2",
36+
"semver": "7.3.5",
37+
"ts-node": "10.7.0",
38+
"typescript": "4.6.3"
39+
},
40+
"engines": {
41+
"node": ">= 14.0.0",
42+
"yarn": "^3.0.0"
43+
}
44+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import type {
2+
AnalyticsApi,
3+
Region as AnalyticsRegion,
4+
} from '@experimental-api-clients-automation/client-analytics/src/analyticsApi';
5+
import { createAnalyticsApi } from '@experimental-api-clients-automation/client-analytics/src/analyticsApi';
6+
import type {
7+
CreateClientOptions,
8+
Host,
9+
Requester,
10+
} from '@experimental-api-clients-automation/client-common';
11+
import {
12+
createMemoryCache,
13+
createFallbackableCache,
14+
createBrowserLocalStorageCache,
15+
} from '@experimental-api-clients-automation/client-common';
16+
import type {
17+
PersonalizationApi,
18+
Region as PersonalizationRegion,
19+
} from '@experimental-api-clients-automation/client-personalization/src/personalizationApi';
20+
import { createPersonalizationApi } from '@experimental-api-clients-automation/client-personalization/src/personalizationApi';
21+
import {
22+
createSearchApi,
23+
apiClientVersion,
24+
} from '@experimental-api-clients-automation/client-search/src/searchApi';
25+
import { createXhrRequester } from '@experimental-api-clients-automation/requester-browser-xhr';
26+
27+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
28+
export function algoliasearch(
29+
appId: string,
30+
apiKey: string,
31+
options?: { requester?: Requester; hosts?: Host[] }
32+
) {
33+
if (!appId) {
34+
throw new Error('`appId` is missing.');
35+
}
36+
37+
if (!apiKey) {
38+
throw new Error('`apiKey` is missing.');
39+
}
40+
41+
const commonOptions: Omit<CreateClientOptions, 'apiKey' | 'appId'> = {
42+
timeouts: {
43+
connect: 1,
44+
read: 2,
45+
write: 30,
46+
},
47+
requester: options?.requester ?? createXhrRequester(),
48+
userAgents: [{ segment: 'Browser' }],
49+
authMode: 'WithinQueryParameters',
50+
responsesCache: createMemoryCache(),
51+
requestsCache: createMemoryCache({ serializable: false }),
52+
hostsCache: createFallbackableCache({
53+
caches: [
54+
createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }),
55+
createMemoryCache(),
56+
],
57+
}),
58+
...options,
59+
};
60+
61+
function initAnalytics(
62+
analyticsAppId: string,
63+
analyticsApiKey: string,
64+
region?: AnalyticsRegion,
65+
analyticsOptions?: { requester?: Requester; hosts?: Host[] }
66+
): AnalyticsApi {
67+
return createAnalyticsApi({
68+
appId: analyticsAppId,
69+
apiKey: analyticsApiKey,
70+
region,
71+
...analyticsOptions,
72+
...commonOptions,
73+
});
74+
}
75+
76+
function initPersonalization(
77+
personalizationAppId: string,
78+
personalizationApiKey: string,
79+
region: PersonalizationRegion,
80+
personalizationOptions?: { requester?: Requester; hosts?: Host[] }
81+
): PersonalizationApi {
82+
if (!region) {
83+
throw new Error('`region` is missing.');
84+
}
85+
86+
return createPersonalizationApi({
87+
appId: personalizationAppId,
88+
apiKey: personalizationApiKey,
89+
region,
90+
...personalizationOptions,
91+
...commonOptions,
92+
});
93+
}
94+
95+
return {
96+
...createSearchApi({ appId, apiKey, ...commonOptions }),
97+
initAnalytics,
98+
initPersonalization,
99+
};
100+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import type {
2+
AnalyticsApi,
3+
Region as AnalyticsRegion,
4+
} from '@experimental-api-clients-automation/client-analytics/src/analyticsApi';
5+
import { createAnalyticsApi } from '@experimental-api-clients-automation/client-analytics/src/analyticsApi';
6+
import type {
7+
CreateClientOptions,
8+
Host,
9+
Requester,
10+
} from '@experimental-api-clients-automation/client-common';
11+
import {
12+
createMemoryCache,
13+
createNullCache,
14+
} from '@experimental-api-clients-automation/client-common';
15+
import type {
16+
PersonalizationApi,
17+
Region as PersonalizationRegion,
18+
} from '@experimental-api-clients-automation/client-personalization/src/personalizationApi';
19+
import { createPersonalizationApi } from '@experimental-api-clients-automation/client-personalization/src/personalizationApi';
20+
import { createSearchApi } from '@experimental-api-clients-automation/client-search/src/searchApi';
21+
import { createHttpRequester } from '@experimental-api-clients-automation/requester-node-http';
22+
23+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
24+
export function algoliasearch(
25+
appId: string,
26+
apiKey: string,
27+
options?: { requester?: Requester; hosts?: Host[] }
28+
) {
29+
if (!appId) {
30+
throw new Error('`appId` is missing.');
31+
}
32+
33+
if (!apiKey) {
34+
throw new Error('`apiKey` is missing.');
35+
}
36+
37+
const commonOptions: Omit<CreateClientOptions, 'apiKey' | 'appId'> = {
38+
timeouts: {
39+
connect: 2,
40+
read: 5,
41+
write: 30,
42+
},
43+
requester: options?.requester ?? createHttpRequester(),
44+
userAgents: [{ segment: 'Node.js', version: process.versions.node }],
45+
responsesCache: createNullCache(),
46+
requestsCache: createNullCache(),
47+
hostsCache: createMemoryCache(),
48+
...options,
49+
};
50+
51+
function initAnalytics(
52+
analyticsAppId: string,
53+
analyticsApiKey: string,
54+
region?: AnalyticsRegion,
55+
analyticsOptions?: { requester?: Requester; hosts?: Host[] }
56+
): AnalyticsApi {
57+
return createAnalyticsApi({
58+
appId: analyticsAppId,
59+
apiKey: analyticsApiKey,
60+
region,
61+
...analyticsOptions,
62+
...commonOptions,
63+
});
64+
}
65+
66+
function initPersonalization(
67+
personalizationAppId: string,
68+
personalizationApiKey: string,
69+
region: PersonalizationRegion,
70+
personalizationOptions?: { requester?: Requester; hosts?: Host[] }
71+
): PersonalizationApi {
72+
if (!region) {
73+
throw new Error('`region` is missing.');
74+
}
75+
76+
return createPersonalizationApi({
77+
appId: personalizationAppId,
78+
apiKey: personalizationApiKey,
79+
region,
80+
...personalizationOptions,
81+
...commonOptions,
82+
});
83+
}
84+
85+
return {
86+
...createSearchApi({ appId, apiKey, ...commonOptions }),
87+
initAnalytics,
88+
initPersonalization,
89+
};
90+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// eslint-disable-next-line import/no-unresolved
2+
export * from './dist/algoliasearch/builds/node';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// eslint-disable-next-line import/no-commonjs,import/extensions
2+
module.exports = require('./dist/algoliasearch.cjs.node.js');

0 commit comments

Comments
 (0)