feat(medusa-plugin-algolia): Revamp Algolia search plugin (#3510)
This commit is contained in:
committed by
GitHub
parent
ef5ef9f5a2
commit
74bc4b16a0
@@ -1,3 +1,4 @@
|
||||
export * as DecoratorUtils from "./decorators";
|
||||
export * as EventBusUtils from "./event-bus";
|
||||
export * as SearchUtils from "./search";
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export * from "./bundles"
|
||||
export * from "./decorators"
|
||||
export * from "./event-bus"
|
||||
export * from "./search"
|
||||
|
||||
|
||||
47
packages/utils/src/search/abstract-service.ts
Normal file
47
packages/utils/src/search/abstract-service.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { SearchTypes } from "@medusajs/types"
|
||||
|
||||
export abstract class AbstractSearchService
|
||||
implements SearchTypes.ISearchService
|
||||
{
|
||||
abstract readonly isDefault
|
||||
protected readonly options_: Record<string, unknown>
|
||||
|
||||
get options(): Record<string, unknown> {
|
||||
return this.options_
|
||||
}
|
||||
|
||||
protected constructor(container, options) {
|
||||
this.options_ = options
|
||||
}
|
||||
|
||||
abstract createIndex(indexName: string, options: unknown): unknown
|
||||
|
||||
abstract getIndex(indexName: string): unknown
|
||||
|
||||
abstract addDocuments(
|
||||
indexName: string,
|
||||
documents: unknown,
|
||||
type: string
|
||||
): unknown
|
||||
|
||||
abstract replaceDocuments(
|
||||
indexName: string,
|
||||
documents: unknown,
|
||||
type: string
|
||||
): unknown
|
||||
|
||||
abstract deleteDocument(
|
||||
indexName: string,
|
||||
document_id: string | number
|
||||
): unknown
|
||||
|
||||
abstract deleteAllDocuments(indexName: string): unknown
|
||||
|
||||
abstract search(
|
||||
indexName: string,
|
||||
query: string | null,
|
||||
options: unknown
|
||||
): unknown
|
||||
|
||||
abstract updateSettings(indexName: string, settings: unknown): unknown
|
||||
}
|
||||
3
packages/utils/src/search/index.ts
Normal file
3
packages/utils/src/search/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from "./abstract-service"
|
||||
export * from "./is-search-service"
|
||||
|
||||
5
packages/utils/src/search/is-search-service.ts
Normal file
5
packages/utils/src/search/is-search-service.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { AbstractSearchService } from "./abstract-service"
|
||||
|
||||
export function isSearchService(obj: unknown): boolean {
|
||||
return obj instanceof AbstractSearchService
|
||||
}
|
||||
Reference in New Issue
Block a user