From 609b909c193fbe096a3e03abffdfd20a388de4a7 Mon Sep 17 00:00:00 2001 From: Michele Riva Date: Tue, 10 Sep 2024 14:39:38 -0700 Subject: [PATCH] style: formats code --- packages/docs/astro.config.mjs | 968 ++++++++++-------- packages/docs/biome.json | 2 +- packages/docs/scripts/postbuild.ts | 34 +- packages/docs/src/components/Head.astro | 5 +- .../docs/src/components/Search/Search.jsx | 23 +- packages/docs/src/components/Search/index.ts | 4 +- .../docs/src/components/Search/suggestions.ts | 6 +- packages/docs/src/components/Search/utils.ts | 24 +- packages/docs/src/components/Sidebar.astro | 12 +- packages/docs/src/global.d.ts | 2 +- packages/docs/src/pages/index.astro | 4 +- packages/docs/src/pages/og/[...slug].ts | 6 +- packages/docs/tailwind.config.mjs | 10 +- packages/docs/tsconfig.json | 2 +- packages/orama/tests/boosting.test.ts | 2 +- packages/orama/tests/search.test.ts | 2 +- packages/plugin-docusaurus-v3/src/index.ts | 101 +- packages/plugin-docusaurus-v3/src/utils.ts | 19 +- packages/plugin-nextra/package.json | 9 +- .../src/components/OramaFoter.tsx | 19 +- .../plugin-nextra/src/components/Result.tsx | 29 +- packages/plugin-nextra/src/index.tsx | 111 +- .../plugin-nextra/src/utils/classNames.ts | 23 +- .../src/utils/useCreateOramaIndex.ts | 42 +- packages/plugin-nextra/src/utils/useFocus.ts | 42 +- packages/plugin-vitepress/src/index.ts | 2 +- packages/stemmers/package.json | 15 +- packages/stopwords/package.json | 6 +- packages/switch/package.json | 9 +- packages/switch/src/index.ts | 6 +- packages/switch/tsup.config.ts | 4 +- 31 files changed, 803 insertions(+), 740 deletions(-) diff --git a/packages/docs/astro.config.mjs b/packages/docs/astro.config.mjs index 5531afa10..2f0cd4886 100644 --- a/packages/docs/astro.config.mjs +++ b/packages/docs/astro.config.mjs @@ -1,443 +1,561 @@ -import { defineConfig } from "astro/config"; -import starlight from "@astrojs/starlight"; -import react from "@astrojs/react"; -import starlightImageZoom from "starlight-image-zoom"; -import tailwind from "@astrojs/tailwind"; -import cookieconsent from "@jop-software/astro-cookieconsent"; +import { defineConfig } from 'astro/config' +import starlight from '@astrojs/starlight' +import react from '@astrojs/react' +import starlightImageZoom from 'starlight-image-zoom' +import tailwind from '@astrojs/tailwind' +import cookieconsent from '@jop-software/astro-cookieconsent' // https://astro.build/config export default defineConfig({ - site: "https://docs.orama.com", + site: 'https://docs.orama.com', vite: { ssr: { noExternal: ['nanoid'] } }, - integrations: [starlight({ - pagefind: false, - plugins: [starlightImageZoom()], - title: "Orama", - description: "Your product answer engine.", - favicon: "/favicon.png", - head: [{ - tag: "link", - attrs: { - rel: "apple-touch-icon", - sizes: "180x180", - href: "/apple-touch-icon.png" - } - }, { - tag: "link", - attrs: { - rel: "icon", - type: "image/png", - sizes: "32x32", - href: "/favicon-32x32.png" - } - }, { - tag: "link", - attrs: { - rel: "icon", - type: "image/png", - sizes: "16x16", - href: "/favicon-16x16.png" - } - }, { - tag: "link", - attrs: { - rel: "mask-icon", - href: "/safari-pinned-tab.svg", - color: "#3a0839" - } - }, { - tag: "meta", - attrs: { - name: "theme-color", - content: "#000" - } - }, - { - tag: "script", - content: `!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys getNextSurveyStep onSessionId".split(" "),n=0;ncontact us' - } - ] + items: [ + { + label: 'Introduction', + link: '/cloud/audience-management/introduction.html' + }, + { + label: 'User Segmentation', + link: '/cloud/audience-management/user-segmentation.html' + }, + { + label: 'Triggers', + link: '/cloud/audience-management/triggers.html' + } + ] + }, + { + label: 'Integrating Orama Cloud', + collapsed: true, + items: [ + { + label: 'JavaScript SDK', + link: '/cloud/integrating-orama-cloud/javascript-sdk.html' + }, + { + label: 'React SDK', + link: '/cloud/integrating-orama-cloud/react-sdk.html' + }, + { + label: 'Vue SDK', + link: '/cloud/integrating-orama-cloud/vue-sdk.html' + } + ] + } + ] + } + ], + editLink: { + baseUrl: 'https://github.com/askorama/orama/edit/main/packages/docs' + } + }), + react(), + tailwind({ + applyBaseStyles: false + }), + cookieconsent({ + guiOptions: { + consentModal: { + layout: 'box', + position: 'bottom right', + equalWeightButtons: true, + flipButtons: false + }, + preferencesModal: { + layout: 'box', + position: 'right', + equalWeightButtons: true, + flipButtons: false + } + }, + categories: { + necessary: { + enabled: true, + readOnly: true + }, + analytics: { + enabled: true + } + }, + language: { + default: 'en', + translations: { + en: { + consentModal: { + title: 'We use cookies 🍪 ', + description: + 'We use cookies to ensure you get the best experience on our website. You can manage your preferences below.', + acceptAllBtn: 'Accept all', + acceptNecessaryBtn: 'Reject all', + showPreferencesBtn: 'Manage preferences' + }, + preferencesModal: { + title: 'Manage cookie preferences', + acceptAllBtn: 'Accept all', + acceptNecessaryBtn: 'Reject all', + savePreferencesBtn: 'Accept current selection', + closeIconLabel: 'Close modal', + sections: [ + { + title: 'Somebody said ... cookies? 🍪 ', + description: 'You can enable or disable different types of cookies: ' + }, + { + title: 'Strictly Necessary cookies', + description: + 'These cookies are essential for the proper functioning of the website and cannot be disabled.', + + //this field will generate a toggle linked to the 'necessary' category + linkedCategory: 'necessary' + }, + { + title: 'Performance and Analytics', + description: + 'These cookies collect information about how you use our website. All of the data is anonymized and cannot be used to identify you.', + linkedCategory: 'analytics' + }, + { + title: 'More information', + description: + 'For any queries in relation to our policy on cookies and your choices, please contact us' + } + ] + } } } } - } - })] -}); \ No newline at end of file + }) + ] +}) diff --git a/packages/docs/biome.json b/packages/docs/biome.json index 9834ac1dc..9063e7b40 100644 --- a/packages/docs/biome.json +++ b/packages/docs/biome.json @@ -41,4 +41,4 @@ "attributePosition": "auto" } } -} \ No newline at end of file +} diff --git a/packages/docs/scripts/postbuild.ts b/packages/docs/scripts/postbuild.ts index 9d61cbcd1..4b7f466b3 100644 --- a/packages/docs/scripts/postbuild.ts +++ b/packages/docs/scripts/postbuild.ts @@ -20,14 +20,12 @@ function unslugify(slug: string) { return slug .toLowerCase() .split(/[-_.\s]/) - .map((w) => `${w.charAt(0).toUpperCase()}${w.substring(1)}`).join(' '); + .map((w) => `${w.charAt(0).toUpperCase()}${w.substring(1)}`) + .join(' ') } async function getAllRenderedDocs() { - const [cloud, oss] = await Promise.all([ - globby(docsCloud), - globby(docsOSS) - ]) + const [cloud, oss] = await Promise.all([globby(docsCloud), globby(docsOSS)]) return { cloud, @@ -36,23 +34,31 @@ async function getAllRenderedDocs() { } function parseDoc(path: string) { - const content = readFileSync(path, 'utf-8') + const content = readFileSync(path, 'utf-8') const isCloud = path.replace(baseURL, '').startsWith('/cloud') - const fullPath = `http://localhost:3000${path.replace(baseURL, '').replace(/^\/(open-source|cloud)/, '').replace('.html', '').replace(/\/index$/, '')}` + const fullPath = `http://localhost:3000${path + .replace(baseURL, '') + .replace(/^\/(open-source|cloud)/, '') + .replace('.html', '') + .replace(/\/index$/, '')}` return generalPurposeCrawler(fullPath, content, { - parseCodeBlocks: true, + parseCodeBlocks: true }).map((doc) => ({ ...doc, - path: `/${isCloud ? 'cloud' : 'open-source'}${doc.path}`, + path: `/${isCloud ? 'cloud' : 'open-source'}${doc.path}` })) } async function getAllParsedDocuments() { const { cloud, oss } = await getAllRenderedDocs() - const cloudDocs = (await Promise.all(cloud.map(parseDoc))).flat().map((doc) => ({ ...doc, category: 'Cloud', section: unslugify(doc.section) })) - const ossDocs = (await Promise.all(oss.map(parseDoc))).flat().map((doc) => ({ ...doc, category: 'Open Source', section: unslugify(doc.section) })) - + const cloudDocs = (await Promise.all(cloud.map(parseDoc))) + .flat() + .map((doc) => ({ ...doc, category: 'Cloud', section: unslugify(doc.section) })) + const ossDocs = (await Promise.all(oss.map(parseDoc))) + .flat() + .map((doc) => ({ ...doc, category: 'Open Source', section: unslugify(doc.section) })) + return [...cloudDocs, ...ossDocs] } @@ -62,7 +68,7 @@ async function updateOramaCloud(docs: GeneralPurposeCrawlerResult[]) { return } const oramaCloudManager = new CloudManager({ - api_key: process.env.ORAMA_CLOUD_PRIVATE_API_KEY, + api_key: process.env.ORAMA_CLOUD_PRIVATE_API_KEY }) const docsIndex = oramaCloudManager.index(process.env.ORAMA_CLOUD_INDEX_ID) @@ -76,4 +82,4 @@ async function updateOramaCloud(docs: GeneralPurposeCrawlerResult[]) { const docs = await getAllParsedDocuments() -await updateOramaCloud(docs) \ No newline at end of file +await updateOramaCloud(docs) diff --git a/packages/docs/src/components/Head.astro b/packages/docs/src/components/Head.astro index 499b09909..c705f8bc6 100644 --- a/packages/docs/src/components/Head.astro +++ b/packages/docs/src/components/Head.astro @@ -2,10 +2,7 @@ import type { Props } from '@astrojs/starlight/props' import Default from '@astrojs/starlight/components/Head.astro' -const ogImageUrl = new URL( - `/og/${Astro.props.id.replace(/\.\w+$/, '.png')}`, - Astro.site, -) +const ogImageUrl = new URL(`/og/${Astro.props.id.replace(/\.\w+$/, '.png')}`, Astro.site) --- diff --git a/packages/docs/src/components/Search/Search.jsx b/packages/docs/src/components/Search/Search.jsx index 845e23e0b..3ed40cd85 100644 --- a/packages/docs/src/components/Search/Search.jsx +++ b/packages/docs/src/components/Search/Search.jsx @@ -1,13 +1,13 @@ import { useEffect, useState } from 'react' -import { OramaClient } from '@oramacloud/client'; +import { OramaClient } from '@oramacloud/client' import { OramaSearchBox, OramaSearchButton } from '@orama/react-components' -import { ossSuggestions, cloudSuggestions } from './suggestions'; -import { getCurrentCategory, getOramaUserId, searchSessionTracking, userSessionRefresh } from './utils'; +import { ossSuggestions, cloudSuggestions } from './suggestions' +import { getCurrentCategory, getOramaUserId, searchSessionTracking, userSessionRefresh } from './utils' const client = new OramaClient({ api_key: 'NKiqTJnwnKsQCdxN7RyOBJgeoW5hJ594', endpoint: 'https://cloud.orama.run/v1/indexes/orama-docs-bzo330' -}) +}) function useCmdK(callback) { const [isCmdKPressed, setIsCmdKPressed] = useState(false) @@ -21,13 +21,13 @@ function useCmdK(callback) { callback() } } - }; + } const handleKeyUp = (event) => { if ((event.metaKey || event.ctrlKey) && event.key === 'k') { - setIsCmdKPressed(false); + setIsCmdKPressed(false) } - }; + } window.addEventListener('keydown', handleKeyDown) window.addEventListener('keyup', handleKeyUp) @@ -44,7 +44,7 @@ function useCmdK(callback) { export function Search() { const [theme, setTheme] = useState() const [currentCategory, setCurrentCategory] = useState(null) - const [userId, setUserId] = useState(getOramaUserId()); + const [userId, setUserId] = useState(getOramaUserId()) // TODO: Remove when fully integrated const [isOpen, setIsOpen] = useState(false) @@ -65,7 +65,6 @@ export function Search() { const intervalId = setInterval(() => userSessionRefresh(client, userId, setUserId), 5000) return () => clearInterval(intervalId) }, [userId]) - useEffect(() => { function callback(mutationList) { @@ -103,7 +102,7 @@ export function Search() { const facetProperty = ['Cloud', 'Open Source'].includes(currentCategory) ? 'section' : 'category' const suggestions = currentCategory === 'Open Source' ? ossSuggestions : cloudSuggestions - + if (!theme) return null return ( @@ -115,10 +114,10 @@ export function Search() { setIsOpen(false) }} sourcesMap={{ - description: 'content', + description: 'content' }} resultsMap={{ - description: 'content', + description: 'content' }} searchParams={{ where: oramaWhere diff --git a/packages/docs/src/components/Search/index.ts b/packages/docs/src/components/Search/index.ts index 4f723cf21..94805d4e4 100644 --- a/packages/docs/src/components/Search/index.ts +++ b/packages/docs/src/components/Search/index.ts @@ -1,3 +1,3 @@ -import { Search } from "./Search"; +import { Search } from './Search' -export { Search }; \ No newline at end of file +export { Search } diff --git a/packages/docs/src/components/Search/suggestions.ts b/packages/docs/src/components/Search/suggestions.ts index 6340c11cd..8e676fa9b 100644 --- a/packages/docs/src/components/Search/suggestions.ts +++ b/packages/docs/src/components/Search/suggestions.ts @@ -1,11 +1,11 @@ export const ossSuggestions = [ 'What languages are supported?', 'How do I write an Orama plugin?', - 'How do I perform vector search with OSS Orama?', + 'How do I perform vector search with OSS Orama?' ] export const cloudSuggestions = [ 'What is an Orama index?', 'How do I perform vector search with Orama Cloud?', - 'What is an answer session?', -] \ No newline at end of file + 'What is an answer session?' +] diff --git a/packages/docs/src/components/Search/utils.ts b/packages/docs/src/components/Search/utils.ts index 32cef262f..f07ac6e8d 100644 --- a/packages/docs/src/components/Search/utils.ts +++ b/packages/docs/src/components/Search/utils.ts @@ -1,4 +1,4 @@ -import type { OramaClient } from "@oramacloud/client" +import type { OramaClient } from '@oramacloud/client' export function getCurrentCategory() { const url = new URL(window.location.href).pathname @@ -11,23 +11,23 @@ export function getCurrentCategory() { export function getOramaUserId() { if (typeof document === 'undefined' || typeof window === 'undefined') return - + const cookies = document.cookie.split(';') - const oid = cookies.find(cookie => cookie.startsWith('oid=')) - + const oid = cookies.find((cookie) => cookie.startsWith('oid=')) + if (oid) { return oid.split('=')[1] } - + return undefined } export function userSessionRefresh(client: OramaClient, userId: string, updateCallback: (userId: string) => void) { - const currentUserId = getOramaUserId(); + const currentUserId = getOramaUserId() if (currentUserId !== userId) { - console.log('User ID changed:', currentUserId); - client.reset(); - updateCallback(currentUserId); + console.log('User ID changed:', currentUserId) + client.reset() + updateCallback(currentUserId) } } @@ -37,13 +37,13 @@ export function searchSessionTracking(client: OramaClient, userId: string) { if (userId) { // TODO: remove this console.log console.log('Identifying user with Cookie ID:', userId) - client.identify(userId); + client.identify(userId) } else { // TODO: remove this console.log console.log('Identifying session with PostHog:', window.posthog.get_distinct_id()) - client.alias(window.posthog.get_distinct_id()); + client.alias(window.posthog.get_distinct_id()) } } catch (error) { - console.log(`Error setting identity: ${error}`); + console.log(`Error setting identity: ${error}`) } } diff --git a/packages/docs/src/components/Sidebar.astro b/packages/docs/src/components/Sidebar.astro index f09589cc7..2db98ad30 100644 --- a/packages/docs/src/components/Sidebar.astro +++ b/packages/docs/src/components/Sidebar.astro @@ -1,16 +1,14 @@ --- -import type { Props } from "@astrojs/starlight/props"; +import type { Props } from '@astrojs/starlight/props' -import MobileMenuFooter from "@astrojs/starlight/components/MobileMenuFooter.astro"; -import SidebarSublist from "@astrojs/starlight/components/SidebarSublist.astro"; +import MobileMenuFooter from '@astrojs/starlight/components/MobileMenuFooter.astro' +import SidebarSublist from '@astrojs/starlight/components/SidebarSublist.astro' const sidebar = ( Astro.props.sidebar.filter((k) => - Astro.props.slug.startsWith("open-source") - ? k.label === "open-source" - : k.label === "cloud" + Astro.props.slug.startsWith('open-source') ? k.label === 'open-source' : k.label === 'cloud' )[0] as any -).entries; +).entries --- diff --git a/packages/docs/src/global.d.ts b/packages/docs/src/global.d.ts index 54c92c2f8..e34812ebb 100644 --- a/packages/docs/src/global.d.ts +++ b/packages/docs/src/global.d.ts @@ -4,4 +4,4 @@ interface Window { get_distinct_id: () => string capture: (event: string, properties?: any) => void } -} \ No newline at end of file +} diff --git a/packages/docs/src/pages/index.astro b/packages/docs/src/pages/index.astro index 0c8ea3db4..d82328ffc 100644 --- a/packages/docs/src/pages/index.astro +++ b/packages/docs/src/pages/index.astro @@ -1,6 +1,6 @@ --- -import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro'; -import { YouTube } from 'astro-embed'; +import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro' +import { YouTube } from 'astro-embed' --- { const { hits: hits1 } = await search(db, { term: 'computer for browsing and movies', - threshold: 1, + threshold: 1 }) const { hits: hits2 } = await search(db, { diff --git a/packages/orama/tests/search.test.ts b/packages/orama/tests/search.test.ts index eb6b35a9b..d71bb46cc 100644 --- a/packages/orama/tests/search.test.ts +++ b/packages/orama/tests/search.test.ts @@ -55,7 +55,7 @@ t.test('search method', (t) => { const result = await search(db, { term: 'coffee', - threshold: 1, + threshold: 1 }) const matchedIds = result.hits.map((d) => d.id) diff --git a/packages/plugin-docusaurus-v3/src/index.ts b/packages/plugin-docusaurus-v3/src/index.ts index a7de26fe0..be5f343c2 100644 --- a/packages/plugin-docusaurus-v3/src/index.ts +++ b/packages/plugin-docusaurus-v3/src/index.ts @@ -1,20 +1,20 @@ -import { readFileSync, writeFileSync } from "node:fs" -import type { Plugin } from "@docusaurus/types" -import { cp } from "node:fs/promises" -import { gzip } from "pako" -import { resolve } from "node:path" +import { readFileSync, writeFileSync } from 'node:fs' +import type { Plugin } from '@docusaurus/types' +import { cp } from 'node:fs/promises' +import { gzip } from 'pako' +import { resolve } from 'node:path' // @ts-ignore -import { presets } from "@orama/searchbox" -import { create, insertMultiple, save } from "@orama/orama" -import { JSDOM } from "jsdom" -import MarkdownIt from "markdown-it" -import matter from "gray-matter" -import { createSnapshot, deployIndex, fetchEndpointConfig } from "./utils" -import { parseMarkdownHeadingId, writeMarkdownHeadingId } from "@docusaurus/utils" +import { presets } from '@orama/searchbox' +import { create, insertMultiple, save } from '@orama/orama' +import { JSDOM } from 'jsdom' +import MarkdownIt from 'markdown-it' +import matter from 'gray-matter' +import { createSnapshot, deployIndex, fetchEndpointConfig } from './utils' +import { parseMarkdownHeadingId, writeMarkdownHeadingId } from '@docusaurus/utils' enum DeployType { - SNAPSHOT_ONLY = "snapshot-only", - DEFAULT = "default" + SNAPSHOT_ONLY = 'snapshot-only', + DEFAULT = 'default' } type CloudConfig = { @@ -44,33 +44,34 @@ export default function OramaPluginDocusaurus( let versions: any[] = [] return { - name: "@orama/plugin-docusaurus-v3", + name: '@orama/plugin-docusaurus-v3', getThemePath() { - return "../dist/theme" + return '../dist/theme' }, getTypeScriptThemePath() { - return "../src/theme" + return '../src/theme' }, getClientModules() { - return ["../dist/theme/SearchBar/index.css"] + return ['../dist/theme/SearchBar/index.css'] }, async allContentLoaded({ actions, allContent }) { - const isDevelopment = process.env.NODE_ENV === 'development' || (options.cloud && !options.cloud?.oramaCloudAPIKey) + const isDevelopment = + process.env.NODE_ENV === 'development' || (options.cloud && !options.cloud?.oramaCloudAPIKey) const docsInstances: string[] = [] const oramaCloudAPIKey = options.cloud?.oramaCloudAPIKey const searchDataConfig = [ { - docs: allContent["docusaurus-plugin-content-docs"] + docs: allContent['docusaurus-plugin-content-docs'] }, { - blogs: allContent["docusaurus-plugin-content-blog"] + blogs: allContent['docusaurus-plugin-content-blog'] }, { - pages: allContent["docusaurus-plugin-content-pages"] + pages: allContent['docusaurus-plugin-content-pages'] } ] const allOramaDocsPromises: Promise[] = [] @@ -78,7 +79,7 @@ export default function OramaPluginDocusaurus( searchDataConfig.forEach((config) => { const [key, value] = Object.entries(config)[0] switch (key) { - case "docs": + case 'docs': if (!value) break Object.keys(value).forEach((docsInstance: any) => { const loadedVersions = value?.[docsInstance]?.loadedVersions @@ -99,7 +100,7 @@ export default function OramaPluginDocusaurus( }) }) break - case "blogs": + case 'blogs': if (!value) break Object.keys(value).forEach(async (instance) => { const loadedInstance = value[instance] @@ -107,15 +108,15 @@ export default function OramaPluginDocusaurus( ...loadedInstance.blogPosts.map(({ metadata }: any) => { return generateDocs({ siteDir: ctx.siteDir, - version: "current", - category: "blogs", + version: 'current', + category: 'blogs', data: metadata }) }) ) }) break - case "pages": + case 'pages': if (!value) break Object.keys(value).forEach(async (instance) => { const loadedInstance = value[instance] @@ -123,8 +124,8 @@ export default function OramaPluginDocusaurus( ...loadedInstance.map((data: any) => generateDocs({ siteDir: ctx.siteDir, - version: "current", - category: "pages", + version: 'current', + category: 'pages', data }) ) @@ -152,7 +153,7 @@ export default function OramaPluginDocusaurus( if (isDevelopment) { actions.setGlobalData({ - searchData: Object.fromEntries([["current", readFileSync(indexPath(ctx.generatedFilesDir, "current"))]]), + searchData: Object.fromEntries([['current', readFileSync(indexPath(ctx.generatedFilesDir, 'current'))]]), docsInstances, availableVersions: versions }) @@ -166,7 +167,7 @@ export default function OramaPluginDocusaurus( const endpointConfig = await deployData({ oramaDocs, generatedFilesDir: ctx.generatedFilesDir, - version: "current", + version: 'current', deployConfig }) @@ -183,7 +184,7 @@ export default function OramaPluginDocusaurus( }, async postBuild({ outDir }) { - !options.cloud && (await cp(indexPath(ctx.generatedFilesDir, "current"), indexPath(outDir, "current"))) + !options.cloud && (await cp(indexPath(ctx.generatedFilesDir, 'current'), indexPath(outDir, 'current'))) } } } @@ -200,7 +201,7 @@ async function generateDocs({ data: Record }) { const { title, permalink, source } = data - const fileContent = readFileSync(source.replace("@site", siteDir), "utf-8") + const fileContent = readFileSync(source.replace('@site', siteDir), 'utf-8') const contentWithoutFrontMatter = matter(fileContent).content const contentWithIds = writeMarkdownHeadingId(contentWithoutFrontMatter) @@ -238,12 +239,12 @@ function parseHTMLContent({ path: any }[] = [] - const headers = document.querySelectorAll("h1, h2, h3, h4, h5, h6") + const headers = document.querySelectorAll('h1, h2, h3, h4, h5, h6') if (!headers.length) { sections.push({ originalTitle, title: originalTitle, - header: "h1", + header: 'h1', content: html, version, category, @@ -251,23 +252,23 @@ function parseHTMLContent({ }) } headers.forEach((header) => { - const headerText = header.textContent?.trim() ?? "" + const headerText = header.textContent?.trim() ?? '' const headerTag = header.tagName.toLowerCase() // Use parseMarkdownHeadingId to extract clean title and section ID - const { text: sectionTitle, id: sectionId } = parseMarkdownHeadingId(headerText); + const { text: sectionTitle, id: sectionId } = parseMarkdownHeadingId(headerText) - let sectionContent = "" + let sectionContent = '' let sibling = header.nextElementSibling - while (sibling && !["H1", "H2", "H3", "H4", "H5", "H6"].includes(sibling.tagName)) { - sectionContent += sibling.textContent?.trim() + "\n" + while (sibling && !['H1', 'H2', 'H3', 'H4', 'H5', 'H6'].includes(sibling.tagName)) { + sectionContent += sibling.textContent?.trim() + '\n' sibling = sibling.nextElementSibling } sections.push({ originalTitle, - title: sectionTitle ?? "", + title: sectionTitle ?? '', header: headerTag, content: sectionContent, version, @@ -280,11 +281,11 @@ function parseHTMLContent({ } function removeTrailingSlash(str: string): string { - return str.endsWith('/') ? str.slice(0, -1) : str; + return str.endsWith('/') ? str.slice(0, -1) : str } function indexPath(outDir: string, version: string) { - return resolve(outDir, "orama-search-index-@VERSION@.json.gz".replace("@VERSION@", version)) + return resolve(outDir, 'orama-search-index-@VERSION@.json.gz'.replace('@VERSION@', version)) } async function deployData({ @@ -298,14 +299,14 @@ async function deployData({ version: string deployConfig: | { - indexId: string - oramaCloudAPIKey: string | undefined - type: DeployType | false - } + indexId: string + oramaCloudAPIKey: string | undefined + type: DeployType | false + } | undefined }) { const { ORAMA_CLOUD_BASE_URL } = process.env - const baseUrl = ORAMA_CLOUD_BASE_URL || "https://cloud.orama.com" + const baseUrl = ORAMA_CLOUD_BASE_URL || 'https://cloud.orama.com' if (deployConfig?.type) { if (deployConfig.type === DeployType.DEFAULT || deployConfig.type === DeployType.SNAPSHOT_ONLY) { @@ -318,11 +319,11 @@ async function deployData({ } return endpointConfig } else { - throw new Error("Invalid deploy type") + throw new Error('Invalid deploy type') } } else { const db = await create({ - schema: { ...presets.docs.schema, version: "enum" } + schema: { ...presets.docs.schema, version: 'enum' } }) await insertMultiple(db, oramaDocs as any) diff --git a/packages/plugin-docusaurus-v3/src/utils.ts b/packages/plugin-docusaurus-v3/src/utils.ts index f4ec1ba84..618006c64 100644 --- a/packages/plugin-docusaurus-v3/src/utils.ts +++ b/packages/plugin-docusaurus-v3/src/utils.ts @@ -5,7 +5,6 @@ export const restFetcher = async (url: string, options?: any): Prom throw new Error(`Request failed (network error): ${await response.text()}`) } else if (response.status >= 400) { const error = new Error(`Request failed (HTTP error ${response.status})}`) - ;(error as any).response = response throw error @@ -46,14 +45,12 @@ export async function loggedOperation(preMessage: string, fn: () => Promise export async function fetchEndpointConfig(baseUrl: string, APIKey: string, indexId: string) { const result = await loggedOperation( 'Start: Fetch index endpoint config', - async () => await restFetcher( - `${baseUrl}/api/v1/indexes/get-index?id=${indexId}`, - { + async () => + await restFetcher(`${baseUrl}/api/v1/indexes/get-index?id=${indexId}`, { headers: { Authorization: `Bearer ${APIKey}` } - } - ), + }), 'End: Fetch index endpoint config (success)' ) @@ -64,13 +61,9 @@ export async function createSnapshot(baseUrl: string, APIKey: string, indexId: s await loggedOperation( 'Start: Create snapshot', async () => - await postFetcher( - `${baseUrl}/api/v1/webhooks/${indexId}/snapshot`, - documents, - { - Authorization: `Bearer ${APIKey}` - } - ), + await postFetcher(`${baseUrl}/api/v1/webhooks/${indexId}/snapshot`, documents, { + Authorization: `Bearer ${APIKey}` + }), 'End: Create snapshot (success)' ) } diff --git a/packages/plugin-nextra/package.json b/packages/plugin-nextra/package.json index a7feab85d..3c671af55 100644 --- a/packages/plugin-nextra/package.json +++ b/packages/plugin-nextra/package.json @@ -2,10 +2,7 @@ "name": "@orama/plugin-nextra", "version": "2.1.0", "description": "Nextra plugin for local search powered by orama", - "keywords": [ - "orama", - "nextra" - ], + "keywords": ["orama", "nextra"], "license": "Apache-2.0", "main": "./dist/index.js", "type": "module", @@ -19,9 +16,7 @@ }, "sideEffects": false, "types": "./dist/index.d.ts", - "files": [ - "dist" - ], + "files": ["dist"], "scripts": { "build": "swc --delete-dir-on-start --extensions .ts,.tsx,.cts -d dist src", "lint": "eslint src --ext .js,.ts,.cts" diff --git a/packages/plugin-nextra/src/components/OramaFoter.tsx b/packages/plugin-nextra/src/components/OramaFoter.tsx index 66dadef8f..5c94519a3 100644 --- a/packages/plugin-nextra/src/components/OramaFoter.tsx +++ b/packages/plugin-nextra/src/components/OramaFoter.tsx @@ -1,20 +1,15 @@ -import React from "react"; -import { attributionLi, attributionP } from "../utils/classNames.js"; +import React from 'react' +import { attributionLi, attributionP } from '../utils/classNames.js' export const OramaFooter = ({ results }) => { return ( -
  • +
  • - {results.count} result{results.count > 1 && "s"} found in{" "} - {results.elapsed.formatted}. Powered by{" "} - + {results.count} result{results.count > 1 && 's'} found in {results.elapsed.formatted}. Powered by{' '} + Orama

  • - ); -}; + ) +} diff --git a/packages/plugin-nextra/src/components/Result.tsx b/packages/plugin-nextra/src/components/Result.tsx index c47b81b2a..b268157b9 100644 --- a/packages/plugin-nextra/src/components/Result.tsx +++ b/packages/plugin-nextra/src/components/Result.tsx @@ -1,34 +1,31 @@ -import React, { useState } from "react"; -import { listItem, resultText } from "../utils/classNames.js"; -import NextLink from "next/link.js"; -import { HighlightedDocument } from "./HighlightedDocument.js"; -import { Result, TypedDocument } from "@orama/orama"; -import { NextraOrama } from "../utils/index.js"; -import { Position } from "@orama/plugin-match-highlight"; +import React, { useState } from 'react' +import { listItem, resultText } from '../utils/classNames.js' +import NextLink from 'next/link.js' +import { HighlightedDocument } from './HighlightedDocument.js' +import { Result, TypedDocument } from '@orama/orama' +import { NextraOrama } from '../utils/index.js' +import { Position } from '@orama/plugin-match-highlight' export const SearchResult = ({ document, positions }) => { - const [hovered, setHovered] = useState(false); + const [hovered, setHovered] = useState(false) return (
  • setHovered(true)} onMouseOut={() => setHovered(false)} > - +
    > & { - positions: Record>; + positions: Record> } } />
  • - ); -}; + ) +} diff --git a/packages/plugin-nextra/src/index.tsx b/packages/plugin-nextra/src/index.tsx index dc5111e97..183cb86a8 100644 --- a/packages/plugin-nextra/src/index.tsx +++ b/packages/plugin-nextra/src/index.tsx @@ -1,81 +1,71 @@ -import type { TypedDocument } from "@orama/orama"; -import type { SearchResultWithHighlight } from "@orama/plugin-match-highlight"; -import { searchWithHighlight } from "@orama/plugin-match-highlight"; -import { useRouter } from "next/compat/router.js"; -import React, { useEffect, useRef, useState } from "react"; -import { NextraOrama, groupDocumentsBy } from "./utils/index.js"; -import { - inputStyles, - inputWrapper, - kbdStyles, - titleDiv, - wrapperDiv, - wrapperUl, -} from "./utils/classNames.js"; -import { OramaFooter } from "./components/OramaFoter.js"; -import { SearchResult } from "./components/Result.js"; -import { useCreateOramaIndex } from "./utils/useCreateOramaIndex.js"; -import { useFocus } from "./utils/useFocus.js"; +import type { TypedDocument } from '@orama/orama' +import type { SearchResultWithHighlight } from '@orama/plugin-match-highlight' +import { searchWithHighlight } from '@orama/plugin-match-highlight' +import { useRouter } from 'next/compat/router.js' +import React, { useEffect, useRef, useState } from 'react' +import { NextraOrama, groupDocumentsBy } from './utils/index.js' +import { inputStyles, inputWrapper, kbdStyles, titleDiv, wrapperDiv, wrapperUl } from './utils/classNames.js' +import { OramaFooter } from './components/OramaFoter.js' +import { SearchResult } from './components/Result.js' +import { useCreateOramaIndex } from './utils/useCreateOramaIndex.js' +import { useFocus } from './utils/useFocus.js' export type OramaSearchProps = { - limitResults: number; + limitResults: number boost: { - title: number; - description: number; - content: number; - }; -}; + title: number + description: number + content: number + } +} const defaultProps: OramaSearchProps = { limitResults: 30, boost: { title: 2, description: 1, - content: 1, - }, -}; + content: 1 + } +} export function OramaSearch(props = defaultProps) { - const router = useRouter(); + const router = useRouter() - return router?.isReady ? ( - - ) : null; + return router?.isReady ? : null } function OramaSearchPlugin({ router, ...props }) { - const inputRef = useRef(null); - const wrapperRef = useRef(null); - const { indexes } = useCreateOramaIndex(); + const inputRef = useRef(null) + const wrapperRef = useRef(null) + const { indexes } = useCreateOramaIndex() const { hasFocus, setHasFocus } = useFocus({ - inputRef, - }); - const [searchTerm, setSearchTerm] = useState(""); - const [results, setResults] = - useState>>(); - const [groupedResults, setGroupedResults] = useState({}); + inputRef + }) + const [searchTerm, setSearchTerm] = useState('') + const [results, setResults] = useState>>() + const [groupedResults, setGroupedResults] = useState({}) - const { locale = "en-US", asPath } = router; + const { locale = 'en-US', asPath } = router // If the path changes, we close the search box useEffect(() => { - setSearchTerm(""); - }, [asPath]); + setSearchTerm('') + }, [asPath]) // If the user types something, we search for it useEffect(() => { if (searchTerm) { searchWithHighlight(indexes[locale], { term: searchTerm, - mode: "fulltext", + mode: 'fulltext', limit: props.limitResults, - boost: props.boost, + boost: props.boost }).then((results) => { - setResults(results); - setGroupedResults(groupDocumentsBy(results.hits, "title")); - }); + setResults(results) + setGroupedResults(groupDocumentsBy(results.hits, 'title')) + }) } - }, [searchTerm]); + }, [searchTerm]) return (
    @@ -90,13 +80,13 @@ function OramaSearchPlugin({ router, ...props }) { value={searchTerm} onFocus={() => setHasFocus(true)} onBlur={() => { - setHasFocus(false); + setHasFocus(false) }} /> {hasFocus ? ( - "ESC" + 'ESC' ) : ( <> K @@ -114,25 +104,16 @@ function OramaSearchPlugin({ router, ...props }) { {results.count > 0 && ( <>
    -
      +
        {Object.keys(groupedResults).map((title) => ( <>
        {title}
        - {groupedResults[title].map( - ({ document, positions }, i) => ( - - ) - )} + {groupedResults[title].map(({ document, positions }, i) => ( + + ))} ))} @@ -143,5 +124,5 @@ function OramaSearchPlugin({ router, ...props }) { )}
    - ); + ) } diff --git a/packages/plugin-nextra/src/utils/classNames.ts b/packages/plugin-nextra/src/utils/classNames.ts index d80d49097..a037f8c61 100644 --- a/packages/plugin-nextra/src/utils/classNames.ts +++ b/packages/plugin-nextra/src/utils/classNames.ts @@ -1,28 +1,25 @@ export const wrapperUl = - "nextra-scrollbar nx-border nx-border-gray-200 nx-bg-white nx-text-gray-100 dark:nx-border-neutral-800 dark:nx-bg-neutral-900 nx-absolute nx-top-full nx-z-20 nx-mt-2 nx-overflow-auto nx-overscroll-contain nx-rounded-xl nx-py-2.5 nx-shadow-xl nx-max-h-[min(calc(50vh-11rem-env(safe-area-inset-bottom)),400px)] md:nx-max-h-[min(calc(100vh-5rem-env(safe-area-inset-bottom)),400px)] nx-inset-x-0 ltr:md:nx-left-auto rtl:md:nx-right-auto contrast-more:nx-border contrast-more:nx-border-gray-900 contrast-more:dark:nx-border-gray-50 nx-w-screen nx-min-h-[100px] nx-max-w-[min(calc(100vw-2rem),calc(100%+20rem))]"; + 'nextra-scrollbar nx-border nx-border-gray-200 nx-bg-white nx-text-gray-100 dark:nx-border-neutral-800 dark:nx-bg-neutral-900 nx-absolute nx-top-full nx-z-20 nx-mt-2 nx-overflow-auto nx-overscroll-contain nx-rounded-xl nx-py-2.5 nx-shadow-xl nx-max-h-[min(calc(50vh-11rem-env(safe-area-inset-bottom)),400px)] md:nx-max-h-[min(calc(100vh-5rem-env(safe-area-inset-bottom)),400px)] nx-inset-x-0 ltr:md:nx-left-auto rtl:md:nx-right-auto contrast-more:nx-border contrast-more:nx-border-gray-900 contrast-more:dark:nx-border-gray-50 nx-w-screen nx-min-h-[100px] nx-max-w-[min(calc(100vw-2rem),calc(100%+20rem))]' export const titleDiv = - "nx-mx-2.5 nx-mb-2 nx-mt-6 nx-select-none nx-border-b nx-border-black/10 nx-px-2.5 nx-pb-1.5 nx-text-xs nx-font-semibold nx-uppercase nx-text-gray-500 first:nx-mt-0 dark:nx-border-white/20 dark:nx-text-gray-300 contrast-more:nx-border-gray-600 contrast-more:nx-text-gray-900 contrast-more:dark:nx-border-gray-50 contrast-more:dark:nx-text-gray-50"; + 'nx-mx-2.5 nx-mb-2 nx-mt-6 nx-select-none nx-border-b nx-border-black/10 nx-px-2.5 nx-pb-1.5 nx-text-xs nx-font-semibold nx-uppercase nx-text-gray-500 first:nx-mt-0 dark:nx-border-white/20 dark:nx-text-gray-300 contrast-more:nx-border-gray-600 contrast-more:nx-text-gray-900 contrast-more:dark:nx-border-gray-50 contrast-more:dark:nx-text-gray-50' export const listItem = - "nx-mx-2.5 nx-break-words nx-rounded-md contrast-more:nx-border nx-text-primary-600 contrast-more:nx-border-primary-500"; + 'nx-mx-2.5 nx-break-words nx-rounded-md contrast-more:nx-border nx-text-primary-600 contrast-more:nx-border-primary-500' export const resultText = - "excerpt nx-mt-1 nx-text-sm nx-leading-[1.35rem] nx-text-gray-600 dark:nx-text-gray-400 contrast-more:dark:nx-text-gray-50"; + 'excerpt nx-mt-1 nx-text-sm nx-leading-[1.35rem] nx-text-gray-600 dark:nx-text-gray-400 contrast-more:dark:nx-text-gray-50' -export const wrapperDiv = - "nextra-search nx-relative md:nx-w-64 nx-hidden md:nx-inline-block mx-min-w-[200px]"; +export const wrapperDiv = 'nextra-search nx-relative md:nx-w-64 nx-hidden md:nx-inline-block mx-min-w-[200px]' export const inputWrapper = - "nx-relative nx-flex nx-items-center nx-text-gray-900 contrast-more:nx-text-gray-800 dark:nx-text-gray-300 contrast-more:dark:nx-text-gray-300"; + 'nx-relative nx-flex nx-items-center nx-text-gray-900 contrast-more:nx-text-gray-800 dark:nx-text-gray-300 contrast-more:dark:nx-text-gray-300' export const inputStyles = - "nx-block nx-w-full nx-appearance-none nx-rounded-lg nx-px-3 nx-py-2 nx-transition-colors nx-text-base nx-leading-tight md:nx-text-sm nx-bg-black/[.05] dark:nx-bg-gray-50/10 focus:nx-bg-white dark:focus:nx-bg-dark placeholder:nx-text-gray-500 dark:placeholder:nx-text-gray-400 contrast-more:nx-border contrast-more:nx-border-current"; + 'nx-block nx-w-full nx-appearance-none nx-rounded-lg nx-px-3 nx-py-2 nx-transition-colors nx-text-base nx-leading-tight md:nx-text-sm nx-bg-black/[.05] dark:nx-bg-gray-50/10 focus:nx-bg-white dark:focus:nx-bg-dark placeholder:nx-text-gray-500 dark:placeholder:nx-text-gray-400 contrast-more:nx-border contrast-more:nx-border-current' export const kbdStyles = - "nx-absolute nx-my-1.5 nx-select-none ltr:nx-right-1.5 rtl:nx-left-1.5 nx-h-5 nx-rounded nx-bg-white nx-px-1.5 nx-font-mono nx-text-[10px] nx-font-medium nx-text-gray-500 nx-border dark:nx-border-gray-100/20 dark:nx-bg-dark/50 contrast-more:nx-border-current contrast-more:nx-text-current contrast-more:dark:nx-border-current nx-items-center nx-gap-1 nx-transition-opacity nx-z-20 nx-flex nx-cursor-pointer hover:nx-opacity-70"; + 'nx-absolute nx-my-1.5 nx-select-none ltr:nx-right-1.5 rtl:nx-left-1.5 nx-h-5 nx-rounded nx-bg-white nx-px-1.5 nx-font-mono nx-text-[10px] nx-font-medium nx-text-gray-500 nx-border dark:nx-border-gray-100/20 dark:nx-bg-dark/50 contrast-more:nx-border-current contrast-more:nx-text-current contrast-more:dark:nx-border-current nx-items-center nx-gap-1 nx-transition-opacity nx-z-20 nx-flex nx-cursor-pointer hover:nx-opacity-70' -export const attributionLi = - "nx-sticky nx-p-4 nx-text-sm nx-bottom-0 nx-bg-gray-100 dark:nx-bg-neutral-900"; +export const attributionLi = 'nx-sticky nx-p-4 nx-text-sm nx-bottom-0 nx-bg-gray-100 dark:nx-bg-neutral-900' -export const attributionP = - "nx-text-center nx-text-gray-600 contrast-more:dark:nx-bg-neutral-100"; +export const attributionP = 'nx-text-center nx-text-gray-600 contrast-more:dark:nx-bg-neutral-100' diff --git a/packages/plugin-nextra/src/utils/useCreateOramaIndex.ts b/packages/plugin-nextra/src/utils/useCreateOramaIndex.ts index b815a3cb9..4cea86712 100644 --- a/packages/plugin-nextra/src/utils/useCreateOramaIndex.ts +++ b/packages/plugin-nextra/src/utils/useCreateOramaIndex.ts @@ -1,39 +1,39 @@ -import { useEffect, useState } from "react"; -import { createOramaIndex } from "./index.js"; -import { useRouter } from "next/router.js"; +import { useEffect, useState } from 'react' +import { createOramaIndex } from './index.js' +import { useRouter } from 'next/router.js' export const useCreateOramaIndex = () => { - const [, setIndexing] = useState(false); - const [indexes, setIndexes] = useState({}); - const router = useRouter(); - const { basePath, locale = "en-US" } = router; + const [, setIndexing] = useState(false) + const [indexes, setIndexes] = useState({}) + const router = useRouter() + const { basePath, locale = 'en-US' } = router // As soon as the page loads, we create the index on the client-side useEffect(() => { - setIndexing(true); + setIndexing(true) createOramaIndex(basePath, locale).then((index) => { setIndexes((i) => ({ ...i, - [locale]: index, - })); - setIndexing(false); - }); - }, []); + [locale]: index + })) + setIndexing(false) + }) + }, []) // If the locale changes, we create the index on the client-side useEffect(() => { if (!(locale in indexes)) { - setIndexing(true); + setIndexing(true) createOramaIndex(basePath, locale).then((index) => { setIndexes((i) => ({ ...i, - [locale]: index, - })); - setIndexing(false); - }); + [locale]: index + })) + setIndexing(false) + }) } - }, [basePath, locale]); + }, [basePath, locale]) - return { indexes }; -}; + return { indexes } +} diff --git a/packages/plugin-nextra/src/utils/useFocus.ts b/packages/plugin-nextra/src/utils/useFocus.ts index 4f7c29a3f..65d6fbeb6 100644 --- a/packages/plugin-nextra/src/utils/useFocus.ts +++ b/packages/plugin-nextra/src/utils/useFocus.ts @@ -1,41 +1,41 @@ -import { useRouter } from "next/router.js"; -import { useEffect, useState } from "react"; +import { useRouter } from 'next/router.js' +import { useEffect, useState } from 'react' export const useFocus = ({ inputRef }) => { - const { asPath } = useRouter(); - const [hasFocus, setHasFocus] = useState(false); + const { asPath } = useRouter() + const [hasFocus, setHasFocus] = useState(false) // If the user presses ESC, we close the search box useEffect(() => { if (document.activeElement === inputRef.current) { - setHasFocus(true); + setHasFocus(true) } else { - setHasFocus(false); + setHasFocus(false) } - }, []); + }, []) useEffect(() => { const onKeyDownHandler = (event: KeyboardEvent) => { - if (event.key.toLowerCase() === "k" && (event.metaKey || event.ctrlKey)) { - event.preventDefault(); - inputRef.current?.focus(); - setHasFocus(true); + if (event.key.toLowerCase() === 'k' && (event.metaKey || event.ctrlKey)) { + event.preventDefault() + inputRef.current?.focus() + setHasFocus(true) } - }; - window.addEventListener("keydown", onKeyDownHandler); + } + window.addEventListener('keydown', onKeyDownHandler) return () => { - window.removeEventListener("keydown", onKeyDownHandler); - }; - }, []); + window.removeEventListener('keydown', onKeyDownHandler) + } + }, []) // If the path changes, we close the search box useEffect(() => { - setHasFocus(false); - }, [asPath]); + setHasFocus(false) + }, [asPath]) return { hasFocus, - setHasFocus, - }; -}; + setHasFocus + } +} diff --git a/packages/plugin-vitepress/src/index.ts b/packages/plugin-vitepress/src/index.ts index 1456f5aa2..fa8c92116 100644 --- a/packages/plugin-vitepress/src/index.ts +++ b/packages/plugin-vitepress/src/index.ts @@ -90,7 +90,7 @@ function formatForOrama(data: Array, base: string): Array ({ title: res.title, content: res.content, - section: (firstH1Header?.title || "").replace(/\s$/, ""), + section: (firstH1Header?.title || '').replace(/\s$/, ''), path: base + res?.path + '#' + slugify.default(res.title, { lower: true }), category: '' })) diff --git a/packages/stemmers/package.json b/packages/stemmers/package.json index d67a7ded5..6b7c0b19f 100644 --- a/packages/stemmers/package.json +++ b/packages/stemmers/package.json @@ -153,9 +153,7 @@ "require": "./dist/sk.cjs" } }, - "files": [ - "dist" - ], + "files": ["dist"], "repository": { "type": "git", "url": "https://github.com/askorama/orama" @@ -169,14 +167,7 @@ "test": "exit 0;", "ci": "npm run test" }, - "keywords": [ - "full-text search", - "search", - "fuzzy search", - "typo-tolerant search", - "full-text", - "stemming" - ], + "keywords": ["full-text search", "search", "fuzzy search", "typo-tolerant search", "full-text", "stemming"], "author": { "name": "Michele Riva", "email": "michele.riva@oramasearch.com", @@ -190,4 +181,4 @@ "engines": { "node": ">= 16.0.0" } -} \ No newline at end of file +} diff --git a/packages/stopwords/package.json b/packages/stopwords/package.json index 551294807..1615b4a4a 100644 --- a/packages/stopwords/package.json +++ b/packages/stopwords/package.json @@ -163,9 +163,7 @@ "require": "./dist/sk.cjs" } }, - "files": [ - "dist" - ], + "files": ["dist"], "repository": { "type": "git", "url": "https://github.com/askorama/orama" @@ -201,4 +199,4 @@ "engines": { "node": ">= 16.0.0" } -} \ No newline at end of file +} diff --git a/packages/switch/package.json b/packages/switch/package.json index c4cac8791..49837acb9 100644 --- a/packages/switch/package.json +++ b/packages/switch/package.json @@ -13,16 +13,11 @@ "types": "./dist/index.d.ts" } }, - "files": [ - "dist" - ], + "files": ["dist"], "scripts": { "build": "tsup" }, - "keywords": [ - "orama", - "orama cloud" - ], + "keywords": ["orama", "orama cloud"], "type": "module", "author": { "name": "Michele Riva", diff --git a/packages/switch/src/index.ts b/packages/switch/src/index.ts index 493312e61..01c81bf37 100644 --- a/packages/switch/src/index.ts +++ b/packages/switch/src/index.ts @@ -11,7 +11,7 @@ export class Switch { clientType: ClientType isCloud: boolean = false isOSS: boolean = false - + constructor(client: OramaSwitchClient) { this.client = client @@ -26,7 +26,9 @@ export class Switch { } } - async search(params: T extends OramaClient ? ClientSearchParams : SearchParams): Promise>> { + async search( + params: T extends OramaClient ? ClientSearchParams : SearchParams + ): Promise>> { if (this.isCloud) { return (this.client as OramaClient).search(params as T extends OramaClient ? ClientSearchParams : never) } else { diff --git a/packages/switch/tsup.config.ts b/packages/switch/tsup.config.ts index 6c2664873..d0e324188 100644 --- a/packages/switch/tsup.config.ts +++ b/packages/switch/tsup.config.ts @@ -8,5 +8,5 @@ export default defineConfig({ bundle: true, dts: true, minify: false, - format: ['cjs', 'esm', 'iife'], -}) \ No newline at end of file + format: ['cjs', 'esm', 'iife'] +})