Skip to content

Commit

Permalink
chore: types running with v4 locally, but also v4 and v3 (#6271)
Browse files Browse the repository at this point in the history
* chore: change type

* WIP: expand search parameters

doesn't work as there still are v4 v5 differences of course

* do it correctly

* use regular client

* not sure if this should stay

* WIP

* changes rule

* fix dependency

* change order to make script work

* almost all types fixed

* improve test

* fix(types): accepts client with wrong types

will be fixed once algolia/api-clients-automation#3357 is done

* tests

* chore(helper): compatibility

* chore(legacy): correct replacement

* don't remove v5 fully

* fix errors

* safer (or less safe lol)

* correct import

* fix fake type

* v5 only works

* tests

* script for examples too

* script for examples too

* chore(answers): bleh get rid of this!

* stuff

* simplify
  • Loading branch information
Haroenv authored Jul 16, 2024
1 parent 41b74e5 commit de8ef70
Show file tree
Hide file tree
Showing 124 changed files with 892 additions and 463 deletions.
2 changes: 1 addition & 1 deletion examples/js/calendar-widget/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* global moment Calendar $ */
import { liteClient as algoliasearch } from 'algoliasearch-v5/lite';
import { liteClient as algoliasearch } from 'algoliasearch/lite';
import instantsearch from 'instantsearch.js';
import { connectRange } from 'instantsearch.js/es/connectors';
import { searchBox, hits } from 'instantsearch.js/es/widgets';
Expand Down
2 changes: 1 addition & 1 deletion examples/js/calendar-widget/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"website:examples": "BABEL_ENV=parcel parcel build index.html --public-url . --dist-dir=../../../website/examples/js/calendar-widget"
},
"dependencies": {
"algoliasearch-v5": "npm:algoliasearch@5.0.0-beta.8",
"algoliasearch": "npm:algoliasearch@5.0.0-beta.9",
"instantsearch.js": "4.73.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/js/e-commerce-umd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"browserslist": "firefox 68, chrome 78, IE 11",
"dependencies": {
"algoliasearch-v5": "npm:algoliasearch@5.0.0-beta.8",
"algoliasearch": "npm:algoliasearch@5.0.0-beta.9",
"instantsearch.js": "4.73.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/js/e-commerce-umd/src/search.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { liteClient as algoliasearch } from 'algoliasearch-v5/lite';
import { liteClient as algoliasearch } from 'algoliasearch/lite';

import getRouting from './routing';
import {
Expand Down
2 changes: 1 addition & 1 deletion examples/js/e-commerce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"browserslist": "firefox 68, chrome 78, IE 11",
"dependencies": {
"algoliasearch-v5": "npm:algoliasearch@5.0.0-beta.8",
"algoliasearch": "npm:algoliasearch@5.0.0-beta.9",
"instantsearch.js": "4.73.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/js/e-commerce/src/search.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { liteClient as algoliasearch } from 'algoliasearch-v5/lite';
import { liteClient as algoliasearch } from 'algoliasearch/lite';
import instantsearch from 'instantsearch.js';

import getRouting from './routing';
Expand Down
2 changes: 1 addition & 1 deletion examples/js/getting-started/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lint:fix": "npm run lint -- --fix"
},
"dependencies": {
"algoliasearch-v5": "npm:algoliasearch@5.0.0-beta.8",
"algoliasearch": "npm:algoliasearch@5.0.0-beta.9",
"instantsearch.js": "4.73.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/js/getting-started/products.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ <h1 class="header-title">
<div id="related-products"></div>
</div>

<script type="module" src="./src/products.js"></script>
<script type="module" src="./src/products.ts"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion examples/js/getting-started/src/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { liteClient as algoliasearch } from 'algoliasearch-v5/lite';
import { liteClient as algoliasearch } from 'algoliasearch/lite';
import instantsearch from 'instantsearch.js';
import {
configure,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { liteClient as algoliasearch } from 'algoliasearch-v5/lite';
import { liteClient as algoliasearch } from 'algoliasearch/lite';
import instantsearch from 'instantsearch.js';
import { configure, hits, relatedProducts } from 'instantsearch.js/es/widgets';

const searchParams = new URLSearchParams(document.location.search);

const pid = searchParams.get('pid');

if (!pid) {
throw new Error('No product ID provided');
}

const searchClient = algoliasearch(
'latency',
'6be0576ff61c053d5f9a3225e2a90f76'
Expand Down
2 changes: 1 addition & 1 deletion examples/js/media/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"website:examples": "BABEL_ENV=parcel parcel build index.html --public-url . --dist-dir=../../../website/examples/js/media"
},
"dependencies": {
"algoliasearch-v5": "npm:algoliasearch@5.0.0-beta.8",
"algoliasearch": "npm:algoliasearch@5.0.0-beta.9",
"date-fns": "2.25.0",
"instantsearch.js": "4.73.0"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/js/media/src/search.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { liteClient as algoliasearch } from 'algoliasearch-v5/lite';
import { liteClient as algoliasearch } from 'algoliasearch/lite';
import instantsearch from 'instantsearch.js';
import { singleIndex } from 'instantsearch.js/es/lib/stateMappings';

Expand Down
2 changes: 1 addition & 1 deletion examples/js/tourism/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"website:examples": "BABEL_ENV=parcel parcel build index.html --public-url . --dist-dir=../../../website/examples/js/tourism"
},
"dependencies": {
"algoliasearch-v5": "npm:algoliasearch@5.0.0-beta.8",
"algoliasearch": "npm:algoliasearch@5.0.0-beta.9",
"instantsearch.js": "4.73.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/js/tourism/search.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { liteClient as algoliasearch } from 'algoliasearch-v5/lite';
import { liteClient as algoliasearch } from 'algoliasearch/lite';
import instantsearch from 'instantsearch.js';
import {
configure,
Expand Down
2 changes: 1 addition & 1 deletion examples/react/default-theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"start": "BABEL_ENV=parcel parcel index.html"
},
"dependencies": {
"algoliasearch-v5": "npm:algoliasearch@5.0.0-beta.8",
"algoliasearch": "npm:algoliasearch@5.0.0-beta.9",
"instantsearch.js": "4.73.0",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/react/default-theme/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { liteClient as algoliasearch } from 'algoliasearch-v5/lite';
import { liteClient as algoliasearch } from 'algoliasearch/lite';
import { Hit as AlgoliaHit } from 'instantsearch.js';
import React from 'react';
import {
Expand Down
2 changes: 1 addition & 1 deletion examples/react/e-commerce/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { liteClient as algoliasearch } from 'algoliasearch-v5/lite';
import { liteClient as algoliasearch } from 'algoliasearch/lite';
import React, { useRef } from 'react';
import {
Configure,
Expand Down
2 changes: 1 addition & 1 deletion examples/react/e-commerce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"browserslist": "firefox 68, chrome 78, IE 11",
"dependencies": {
"algoliasearch-v5": "npm:algoliasearch@5.0.0-beta.8",
"algoliasearch": "npm:algoliasearch@5.0.0-beta.9",
"instantsearch.js": "4.73.0",
"react": "18.2.0",
"react-compound-slider": "3.4.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/react/getting-started/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"start": "BABEL_ENV=parcel parcel index.html products.html --port 3000"
},
"dependencies": {
"algoliasearch-v5": "npm:algoliasearch@5.0.0-beta.8",
"algoliasearch": "npm:algoliasearch@5.0.0-beta.9",
"instantsearch.js": "4.73.0",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/react/getting-started/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { liteClient as algoliasearch } from 'algoliasearch-v5/lite';
import { liteClient as algoliasearch } from 'algoliasearch/lite';
import { Hit } from 'instantsearch.js';
import React from 'react';
import {
Expand Down
2 changes: 1 addition & 1 deletion examples/react/getting-started/src/Product.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { liteClient as algoliasearch } from 'algoliasearch-v5/lite';
import { liteClient as algoliasearch } from 'algoliasearch/lite';
import { type Hit } from 'instantsearch.js';
import React from 'react';
import {
Expand Down
2 changes: 1 addition & 1 deletion examples/react/next-app-router/app/Search.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import { liteClient as algoliasearch } from 'algoliasearch-v5/lite';
import { liteClient as algoliasearch } from 'algoliasearch/lite';
import { Hit as AlgoliaHit } from 'instantsearch.js';
import React from 'react';
import {
Expand Down
2 changes: 1 addition & 1 deletion examples/react/next-app-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"algoliasearch-v5": "npm:algoliasearch@5.0.0-beta.8",
"algoliasearch": "npm:algoliasearch@5.0.0-beta.9",
"instantsearch.css": "8.3.0",
"next": "13.5.1",
"react": "18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/react/next-routing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"algoliasearch-v5": "npm:algoliasearch@5.0.0-beta.8",
"algoliasearch": "npm:algoliasearch@5.0.0-beta.9",
"instantsearch.css": "8.3.0",
"next": "13.5.1",
"react": "18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/react/next-routing/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { liteClient as algoliasearch } from 'algoliasearch-v5/lite';
import { liteClient as algoliasearch } from 'algoliasearch/lite';
import { Hit as AlgoliaHit } from 'instantsearch.js';
import { GetServerSideProps } from 'next';
import Head from 'next/head';
Expand Down
2 changes: 1 addition & 1 deletion examples/react/next-routing/pages/test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This is only to test `onStateChange` does not get called twice
import { liteClient as algoliasearch } from 'algoliasearch-v5/lite';
import { liteClient as algoliasearch } from 'algoliasearch/lite';
import { GetServerSideProps } from 'next';
import Head from 'next/head';
import Link from 'next/link';
Expand Down
2 changes: 1 addition & 1 deletion examples/react/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"algoliasearch-v5": "npm:algoliasearch@5.0.0-beta.8",
"algoliasearch": "npm:algoliasearch@5.0.0-beta.9",
"instantsearch.css": "8.3.0",
"next": "13.5.1",
"react": "18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/react/next/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { liteClient as algoliasearch } from 'algoliasearch-v5/lite';
import { liteClient as algoliasearch } from 'algoliasearch/lite';
import { Hit as AlgoliaHit } from 'instantsearch.js';
import { GetServerSideProps } from 'next';
import Head from 'next/head';
Expand Down
2 changes: 1 addition & 1 deletion examples/react/react-native/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useRef } from 'react';
import { FlatList, SafeAreaView, StyleSheet, Text, View } from 'react-native';
import { StatusBar } from 'expo-status-bar';
import { liteClient as algoliasearch } from 'algoliasearch-v5/lite';
import { liteClient as algoliasearch } from 'algoliasearch/lite';
import { InstantSearch } from 'react-instantsearch-core';

import { InfiniteHits } from './src/InfiniteHits';
Expand Down
2 changes: 1 addition & 1 deletion examples/react/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"eject": "expo eject"
},
"dependencies": {
"algoliasearch-v5": "npm:algoliasearch@5.0.0-beta.8",
"algoliasearch": "npm:algoliasearch@5.0.0-beta.9",
"expo": "~44.0.0",
"expo-status-bar": "~1.2.0",
"instantsearch.js": "4.73.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/react-native/src/Highlight.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Fragment } from 'react';
import { StyleSheet, Text } from 'react-native';
import { Hit as AlgoliaHit } from '@algolia/client-search';
import { Hit as AlgoliaHit } from 'instantsearch.js';
import {
getHighlightedParts,
getPropertyByPath,
Expand All @@ -26,7 +26,7 @@ type HighlightProps<THit> = {
separator?: string;
};

export function Highlight<THit extends AlgoliaHit<Record<string, unknown>>>({
export function Highlight<THit extends AlgoliaHit>({
hit,
attribute,
separator = ', ',
Expand Down
2 changes: 1 addition & 1 deletion examples/react/react-native/src/InfiniteHits.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { forwardRef } from 'react';
import { StyleSheet, View, FlatList } from 'react-native';
import { Hit as AlgoliaHit } from '@algolia/client-search';
import { Hit as AlgoliaHit } from 'instantsearch.js';
import {
useInfiniteHits,
UseInfiniteHitsProps,
Expand Down
2 changes: 1 addition & 1 deletion examples/react/react-native/types/ProductHit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Hit as AlgoliaHit } from '@algolia/client-search';
import { Hit as AlgoliaHit } from 'instantsearch.js';

export type ProductHit = AlgoliaHit<{
brand: string;
Expand Down
2 changes: 1 addition & 1 deletion examples/react/ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"webpack-node-externals": "1.7.2"
},
"dependencies": {
"algoliasearch-v5": "npm:algoliasearch@5.0.0-beta.8",
"algoliasearch": "npm:algoliasearch@5.0.0-beta.9",
"express": "4.17.1",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/react/ssr/src/searchClient.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { liteClient as algoliasearch } from 'algoliasearch-v5/lite';
import { liteClient as algoliasearch } from 'algoliasearch/lite';

export const searchClient = algoliasearch(
'latency',
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/default-theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"website:examples": "NODE_OPTIONS=--openssl-legacy-provider vue-cli-service build --dest ../../../website/examples/vue/default-theme"
},
"dependencies": {
"algoliasearch-v5": "npm:algoliasearch@5.0.0-beta.8",
"algoliasearch": "npm:algoliasearch@5.0.0-beta.9",
"core-js": "2",
"instantsearch.js": "4.73.0",
"vue": "2.7.14",
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/default-theme/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
</template>

<script>
import { liteClient as algoliasearch } from 'algoliasearch-v5/lite';
import { liteClient as algoliasearch } from 'algoliasearch/lite';
import { history as historyRouter } from 'instantsearch.js/es/lib/routers';
import { simple as simpleMapping } from 'instantsearch.js/es/lib/stateMappings';
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/e-commerce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"website:examples": "NODE_OPTIONS=--openssl-legacy-provider vue-cli-service build --dest ../../../website/examples/vue/e-commerce"
},
"dependencies": {
"algoliasearch-v5": "npm:algoliasearch@5.0.0-beta.8",
"algoliasearch": "npm:algoliasearch@5.0.0-beta.9",
"core-js": "2",
"instantsearch.js": "4.73.0",
"vue": "2.7.14",
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/e-commerce/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@
</template>

<script>
import { liteClient as algoliasearch } from 'algoliasearch-v5/lite';
import { liteClient as algoliasearch } from 'algoliasearch/lite';
import VueSlider from 'vue-slider-component';
import getRouting from './routing';
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/getting-started/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"build": "NODE_OPTIONS=--openssl-legacy-provider vue-cli-service build"
},
"dependencies": {
"algoliasearch-v5": "npm:algoliasearch@5.0.0-beta.8",
"algoliasearch": "npm:algoliasearch@5.0.0-beta.9",
"core-js": "2",
"instantsearch.js": "4.73.0",
"vue": "2.7.14",
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/getting-started/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
</template>

<script>
import { liteClient as algoliasearch } from 'algoliasearch-v5/lite';
import { liteClient as algoliasearch } from 'algoliasearch/lite';
export default {
data() {
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/media/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"website:examples": "NODE_OPTIONS=--openssl-legacy-provider vue-cli-service build --dest ../../../website/examples/vue/media"
},
"dependencies": {
"algoliasearch-v5": "npm:algoliasearch@5.0.0-beta.8",
"algoliasearch": "npm:algoliasearch@5.0.0-beta.9",
"core-js": "2",
"instantsearch.js": "4.73.0",
"vue": "2.7.14",
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/media/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
</template>

<script>
import { liteClient as algoliasearch } from 'algoliasearch-v5/lite';
import { liteClient as algoliasearch } from 'algoliasearch/lite';
import { history as historyRouter } from 'instantsearch.js/es/lib/routers';
import { simple as simpleMapping } from 'instantsearch.js/es/lib/stateMappings';
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"generate": "nuxt generate"
},
"dependencies": {
"algoliasearch-v5": "npm:algoliasearch@5.0.0-beta.8",
"algoliasearch": "npm:algoliasearch@5.0.0-beta.9",
"cross-env": "^5.2.0",
"css-loader": "^4.3.0",
"nuxt": "^2.4.5",
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/nuxt/pages/search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</template>

<script>
import { liteClient as algoliasearch } from 'algoliasearch-v5/lite';
import { liteClient as algoliasearch } from 'algoliasearch/lite';
import {
AisInstantSearchSsr,
AisIndex,
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"start": "NODE_ENV=production NODE_OPTIONS=--openssl-legacy-provider vue-cli-service ssr:serve --mode production"
},
"dependencies": {
"algoliasearch-v5": "npm:algoliasearch@5.0.0-beta.8",
"algoliasearch": "npm:algoliasearch@5.0.0-beta.9",
"core-js": "2",
"instantsearch.css": "8.3.0",
"qs": "6.9.7",
Expand Down
2 changes: 1 addition & 1 deletion examples/vue/ssr/src/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-nested-ternary */
import { liteClient as algoliasearch } from 'algoliasearch-v5/lite';
import { liteClient as algoliasearch } from 'algoliasearch/lite';
import qs from 'qs';
import Vue from 'vue';
import { createServerRootMixin } from 'vue-instantsearch';
Expand Down
Loading

0 comments on commit de8ef70

Please sign in to comment.