Before making ANY changes, verify you're in the correct repository:
git remote -v- ✅ CORRECT:
origin .../algolia/api-clients-automation.git→ You may proceed - ❌ WRONG:
origin .../algolia/algoliasearch-client-javascript.git→ STOP! This is the PUBLIC repository
If you're in algoliasearch-client-javascript: Do NOT make changes here. All changes must go through api-clients-automation. PRs and commits made directly to the public repo will be discarded on next release.
Before editing ANY file, verify it's hand-written by checking config/generation.config.mjs:
// In generation.config.mjs - patterns WITHOUT '!' are GENERATED (do not edit)
'clients/algoliasearch-client-javascript/packages/**/package.json', // Generated
'!clients/algoliasearch-client-javascript/packages/client-common/**', // Hand-written ✓Hand-written (safe to edit):
packages/client-common/**- Core transport, types, utilitiespackages/requester-*/**- HTTP requesters (browser-xhr, node-http, fetch)packages/logger-console/**- Logging utilitiespackages/algoliasearch/__tests__/**- Testsscripts/**- Build scripts
Generated (DO NOT EDIT):
packages/*/model/**- API modelspackages/*/src/**(except client-common) - API clientspackages/**/package.json- Package configs
- Files:
camelCase.tsfor source,camelCase.test.tsfor tests - Variables/Functions:
camelCase - Types/Interfaces:
PascalCase - Constants:
UPPER_SNAKE_CASEorcamelCasedepending on scope
- Prettier with project config (
.prettierrc) - 120 char line width
- Single quotes, trailing commas
- Run:
yarn cli format javascript clients/algoliasearch-client-javascript
- Strict mode enabled
- No
any- useunknownor proper types - No
@ts-ignoreor@ts-expect-error - Prefer
typeoverinterfacefor object shapes - Use
readonlyfor immutable properties
- HTTP: Custom requesters (not axios/fetch directly)
- Build: tsup for bundling
- Test: Vitest
- Monorepo: Yarn workspaces + Lerna
// Core transport in packages/client-common/src/transporter/
createTransporter({
hosts, // Host[] - API hosts with failover
hostsCache, // Cache for host state
requester, // Pluggable HTTP implementation
requestsCache, // Request deduplication
responsesCache, // Response caching
});- Hosts tracked as
up,down, ortimedOut - Automatic failover to next host on failure
- Timeout increases with retry count
- Network errors are retryable, 4xx errors are not
createMemoryCache()- In-memory, serializablecreateBrowserLocalStorageCache()- Browser persistencecreateNullCache()- No-op for serverscreateFallbackableCache()- Chain caches
- Different requesters for each environment
- Use
requester-browser-xhrfor browsers - Use
requester-node-httpfor Node.js - Check bundle targets in
tsup.config.ts
- All API methods return Promises
- No callback-style APIs
- Use
async/await, avoid.then()chains in new code
// Use 'import type' for type-only imports
import type { SearchResponse } from './types';// Avoid direct process/window checks
// Use requester abstraction instead# From repo root (api-clients-automation)
yarn cli build clients javascript # Build all JS packages
yarn cli cts generate javascript # Generate CTS tests
yarn cli cts run javascript # Run CTS tests
yarn cli playground javascript node search # Interactive playground
yarn cli format javascript clients/algoliasearch-client-javascript
# From client directory (for package-specific work)
cd clients/algoliasearch-client-javascript
yarn build # Build packages
yarn test # Run tests