Skip to content

Commit

Permalink
fix(javascript): keep comments and jsdoc in build
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#307

Co-authored-by: Clément Vannicatte <[email protected]>
  • Loading branch information
algolia-bot and shortcuts committed Mar 31, 2022
1 parent 7efb344 commit fb83950
Show file tree
Hide file tree
Showing 366 changed files with 17,151 additions and 0 deletions.
36 changes: 36 additions & 0 deletions algoliasearch-client-javascript/.github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Release packages

on:
push:
branches:
- next

jobs:
release:
name: Publish
runs-on: ubuntu-20.04
if: "startsWith(github.event.head_commit.message, 'chore: release v')"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Install Node
uses: actions/setup-node@v2
with:
node-version-file: .nvmrc
cache: yarn

- name: Install JavaScript dependencies
shell: bash
run: yarn install

- name: Build clients
shell: bash
run: yarn build

- name: Publish to NPM
shell: bash
run: yarn release:publish
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
10 changes: 10 additions & 0 deletions algoliasearch-client-javascript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**dist
**.openapi-generator

yarn-error.log

.yarn/*
!.yarn/releases
!.yarn/plugins

node_modules
1 change: 1 addition & 0 deletions algoliasearch-client-javascript/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}
1 change: 1 addition & 0 deletions algoliasearch-client-javascript/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16.13.1
768 changes: 768 additions & 0 deletions algoliasearch-client-javascript/.yarn/releases/yarn-3.1.1.cjs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions algoliasearch-client-javascript/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.1.1.cjs
30 changes: 30 additions & 0 deletions algoliasearch-client-javascript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
....

<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/algoliasearch"><img src="https://img.shields.io/npm/v/algoliasearch.svg?style=flat-square" alt="NPM version"></img></a>
<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>
<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>
<a href="LICENSE.md"><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/api-client/getting-started/install/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/api-client/troubleshooting/faq/javascript/" target="_blank">FAQ</a> •
<a href="https://www.algolia.com/support" target="_blank">Support</a>
</p>

# Contributing to this repository

The Algolia API clients are automatically generated, you can find everything here https://github.com/algolia/api-clients-automation
52 changes: 52 additions & 0 deletions algoliasearch-client-javascript/bundlesize.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"files": [
{
"path": "packages/algoliasearch/dist/algoliasearch.umd.browser.js",
"maxSize": "7.05KB"
},
{
"path": "packages/client-abtesting/dist/client-abtesting.umd.browser.js",
"maxSize": "3.85KB"
},
{
"path": "packages/client-analytics/dist/client-analytics.umd.browser.js",
"maxSize": "4.45KB"
},
{
"path": "packages/client-insights/dist/client-insights.umd.browser.js",
"maxSize": "3.70KB"
},
{
"path": "packages/client-personalization/dist/client-personalization.umd.browser.js",
"maxSize": "3.85KB"
},
{
"path": "packages/client-query-suggestions/dist/client-query-suggestions.umd.browser.js",
"maxSize": "3.90KB"
},
{
"path": "packages/client-search/dist/client-search.umd.browser.js",
"maxSize": "5.85KB"
},
{
"path": "packages/client-sources/dist/client-sources.umd.browser.js",
"maxSize": "3.70KB"
},
{
"path": "packages/recommend/dist/recommend.umd.browser.js",
"maxSize": "3.80KB"
},
{
"path": "packages/client-common/dist/client-common.esm.node.js",
"maxSize": "5.25KB"
},
{
"path": "packages/requester-browser-xhr/dist/requester-browser-xhr.esm.node.js",
"maxSize": "900B"
},
{
"path": "packages/requester-node-http/dist/requester-node-http.esm.node.js",
"maxSize": "1.15KB"
}
]
}
4 changes: 4 additions & 0 deletions algoliasearch-client-javascript/lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"packages": ["packages/*"],
"version": "independent"
}
44 changes: 44 additions & 0 deletions algoliasearch-client-javascript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "algoliasearch-client-javascript",
"workspaces": [
"packages/*"
],
"private": true,
"scripts": {
"build:utils": "yarn build client-common && yarn build requester-browser-xhr && yarn build requester-node-http",
"build": "CLIENT=${0:-all} yarn rollup -c rollup.config.js",
"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",
"clean": "rm -rf packages/*/dist",
"release": "shipjs prepare",
"test:size": "bundlesize",
"test:lint": "eslint . --ext .js,.ts",
"test:types": "yarn tsc --noEmit",
"release:bump": "lerna version ${0:-patch} --no-changelog --no-git-tag-version --no-push --yes",
"release:publish": "ts-node scripts/publish.ts"
},
"devDependencies": {
"@babel/core": "7.17.8",
"@babel/plugin-proposal-class-properties": "7.16.7",
"@babel/plugin-transform-runtime": "7.17.0",
"@babel/preset-env": "7.16.11",
"@babel/runtime": "7.17.8",
"@rollup/plugin-babel": "5.3.1",
"@rollup/plugin-node-resolve": "13.1.3",
"@types/rollup-plugin-node-globals": "1.4.1",
"bundlesize2": "0.0.31",
"execa": "6.1.0",
"lerna": "4.0.0",
"rollup": "2.67.1",
"rollup-plugin-filesize": "9.1.2",
"rollup-plugin-node-globals": "1.4.0",
"rollup-plugin-terser": "7.0.2",
"rollup-plugin-typescript2": "0.31.2",
"semver": "7.3.5",
"ts-node": "10.7.0",
"typescript": "4.6.3"
},
"engines": {
"node": ">= 14.0.0",
"yarn": "^3.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import type {
AnalyticsApi,
Region as AnalyticsRegion,
} from '@experimental-api-clients-automation/client-analytics/src/analyticsApi';
import { createAnalyticsApi } from '@experimental-api-clients-automation/client-analytics/src/analyticsApi';
import type {
CreateClientOptions,
Host,
Requester,
} from '@experimental-api-clients-automation/client-common';
import {
createMemoryCache,
createFallbackableCache,
createBrowserLocalStorageCache,
} from '@experimental-api-clients-automation/client-common';
import type {
PersonalizationApi,
Region as PersonalizationRegion,
} from '@experimental-api-clients-automation/client-personalization/src/personalizationApi';
import { createPersonalizationApi } from '@experimental-api-clients-automation/client-personalization/src/personalizationApi';
import {
createSearchApi,
apiClientVersion,
} from '@experimental-api-clients-automation/client-search/src/searchApi';
import { createXhrRequester } from '@experimental-api-clients-automation/requester-browser-xhr';

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export function algoliasearch(
appId: string,
apiKey: string,
options?: { requester?: Requester; hosts?: Host[] }
) {
if (!appId) {
throw new Error('`appId` is missing.');
}

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

const commonOptions: Omit<CreateClientOptions, 'apiKey' | 'appId'> = {
timeouts: {
connect: 1,
read: 2,
write: 30,
},
requester: options?.requester ?? createXhrRequester(),
userAgents: [{ segment: 'Browser' }],
authMode: 'WithinQueryParameters',
responsesCache: createMemoryCache(),
requestsCache: createMemoryCache({ serializable: false }),
hostsCache: createFallbackableCache({
caches: [
createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }),
createMemoryCache(),
],
}),
...options,
};

function initAnalytics(
analyticsAppId: string,
analyticsApiKey: string,
region?: AnalyticsRegion,
analyticsOptions?: { requester?: Requester; hosts?: Host[] }
): AnalyticsApi {
return createAnalyticsApi({
appId: analyticsAppId,
apiKey: analyticsApiKey,
region,
...analyticsOptions,
...commonOptions,
});
}

function initPersonalization(
personalizationAppId: string,
personalizationApiKey: string,
region: PersonalizationRegion,
personalizationOptions?: { requester?: Requester; hosts?: Host[] }
): PersonalizationApi {
if (!region) {
throw new Error('`region` is missing.');
}

return createPersonalizationApi({
appId: personalizationAppId,
apiKey: personalizationApiKey,
region,
...personalizationOptions,
...commonOptions,
});
}

return {
...createSearchApi({ appId, apiKey, ...commonOptions }),
initAnalytics,
initPersonalization,
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import type {
AnalyticsApi,
Region as AnalyticsRegion,
} from '@experimental-api-clients-automation/client-analytics/src/analyticsApi';
import { createAnalyticsApi } from '@experimental-api-clients-automation/client-analytics/src/analyticsApi';
import type {
CreateClientOptions,
Host,
Requester,
} from '@experimental-api-clients-automation/client-common';
import {
createMemoryCache,
createNullCache,
} from '@experimental-api-clients-automation/client-common';
import type {
PersonalizationApi,
Region as PersonalizationRegion,
} from '@experimental-api-clients-automation/client-personalization/src/personalizationApi';
import { createPersonalizationApi } from '@experimental-api-clients-automation/client-personalization/src/personalizationApi';
import { createSearchApi } from '@experimental-api-clients-automation/client-search/src/searchApi';
import { createHttpRequester } from '@experimental-api-clients-automation/requester-node-http';

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export function algoliasearch(
appId: string,
apiKey: string,
options?: { requester?: Requester; hosts?: Host[] }
) {
if (!appId) {
throw new Error('`appId` is missing.');
}

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

const commonOptions: Omit<CreateClientOptions, 'apiKey' | 'appId'> = {
timeouts: {
connect: 2,
read: 5,
write: 30,
},
requester: options?.requester ?? createHttpRequester(),
userAgents: [{ segment: 'Node.js', version: process.versions.node }],
responsesCache: createNullCache(),
requestsCache: createNullCache(),
hostsCache: createMemoryCache(),
...options,
};

function initAnalytics(
analyticsAppId: string,
analyticsApiKey: string,
region?: AnalyticsRegion,
analyticsOptions?: { requester?: Requester; hosts?: Host[] }
): AnalyticsApi {
return createAnalyticsApi({
appId: analyticsAppId,
apiKey: analyticsApiKey,
region,
...analyticsOptions,
...commonOptions,
});
}

function initPersonalization(
personalizationAppId: string,
personalizationApiKey: string,
region: PersonalizationRegion,
personalizationOptions?: { requester?: Requester; hosts?: Host[] }
): PersonalizationApi {
if (!region) {
throw new Error('`region` is missing.');
}

return createPersonalizationApi({
appId: personalizationAppId,
apiKey: personalizationApiKey,
region,
...personalizationOptions,
...commonOptions,
});
}

return {
...createSearchApi({ appId, apiKey, ...commonOptions }),
initAnalytics,
initPersonalization,
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line import/no-unresolved
export * from './dist/algoliasearch/builds/node';
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line import/no-commonjs,import/extensions
module.exports = require('./dist/algoliasearch.cjs.node.js');
Loading

0 comments on commit fb83950

Please sign in to comment.