feat(medusa-plugin-algolia): Revamp Algolia search plugin (#3510)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
export * as CommonTypes from "./common"
|
||||
export * as EventBusTypes from "./event-bus"
|
||||
export * as SearchTypes from "./search"
|
||||
export * as TransactionBaseTypes from "./transaction-base"
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
export * from "./bundles"
|
||||
export * from "./common"
|
||||
export * from "./event-bus"
|
||||
export * from "./search"
|
||||
export * from "./shared-context"
|
||||
export * from "./transaction-base"
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
export const indexTypes = {
|
||||
PRODUCTS: "products"
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
export * from "./index-types"
|
||||
export * from "./interface"
|
||||
export * from "./settings"
|
||||
export * from "./variant-keys"
|
||||
|
||||
export type IndexSettings = {
|
||||
/**
|
||||
* Settings specific to the provider. E.g. `searchableAttributes`.
|
||||
*/
|
||||
indexSettings: Record<string, unknown>
|
||||
/**
|
||||
* Primary key for the index. Used to enforce unique documents in an index. See more in Meilisearch' https://docs.meilisearch.com/learn/core_concepts/primary_key.html.
|
||||
*/
|
||||
primaryKey?: string
|
||||
/**
|
||||
* Document transformer. Used to transform documents before they are added to the index.
|
||||
*/
|
||||
transformer?: (document: any) => any
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
export interface ISearchService {
|
||||
options: Record<string, unknown>
|
||||
|
||||
/**
|
||||
* Used to create an index
|
||||
* @param indexName the index name
|
||||
* @param options the options
|
||||
* @return returns response from search engine provider
|
||||
*/
|
||||
createIndex(indexName: string, options: unknown): unknown
|
||||
|
||||
/**
|
||||
* Used to get an index
|
||||
* @param indexName - the index name.
|
||||
* @return returns response from search engine provider
|
||||
*/
|
||||
getIndex(indexName: string): unknown
|
||||
|
||||
/**
|
||||
* Used to index documents by the search engine provider
|
||||
* @param indexName the index name
|
||||
* @param documents documents array to be indexed
|
||||
* @param type of documents to be added (e.g: products, regions, orders, etc)
|
||||
* @return returns response from search engine provider
|
||||
*/
|
||||
addDocuments(indexName: string, documents: unknown, type: string): unknown
|
||||
|
||||
/**
|
||||
* Used to replace documents
|
||||
* @param indexName the index name.
|
||||
* @param documents array of document objects that will replace existing documents
|
||||
* @param type type of documents to be replaced (e.g: products, regions, orders, etc)
|
||||
* @return returns response from search engine provider
|
||||
*/
|
||||
replaceDocuments(indexName: string, documents: unknown, type: string): unknown
|
||||
|
||||
/**
|
||||
* Used to delete document
|
||||
* @param indexName the index name
|
||||
* @param document_id the id of the document
|
||||
* @return returns response from search engine provider
|
||||
*/
|
||||
deleteDocument(indexName: string, document_id: string | number): unknown
|
||||
|
||||
/**
|
||||
* Used to delete all documents
|
||||
* @param indexName the index name
|
||||
* @return returns response from search engine provider
|
||||
*/
|
||||
deleteAllDocuments(indexName: string): unknown
|
||||
|
||||
/**
|
||||
* Used to search for a document in an index
|
||||
* @param indexName the index name
|
||||
* @param query the search query
|
||||
* @param options
|
||||
* - any options passed to the request object other than the query and indexName
|
||||
* - additionalOptions contain any provider specific options
|
||||
* @return returns response from search engine provider
|
||||
*/
|
||||
search(indexName: string, query: string | null, options: unknown): unknown
|
||||
|
||||
/**
|
||||
* Used to update the settings of an index
|
||||
* @param indexName the index name
|
||||
* @param settings settings object
|
||||
* @return returns response from search engine provider
|
||||
*/
|
||||
updateSettings(indexName: string, settings: unknown): unknown
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
export type IndexSettings = {
|
||||
/**
|
||||
* Settings specific to the provider. E.g. `searchableAttributes`.
|
||||
*/
|
||||
indexSettings: Record<string, unknown>
|
||||
/**
|
||||
* Primary key for the index. Used to enforce unique documents in an index. See more in Meilisearch' https://docs.meilisearch.com/learn/core_concepts/primary_key.html.
|
||||
*/
|
||||
primaryKey?: string
|
||||
/**
|
||||
* Document transformer. Used to transform documents before they are added to the index.
|
||||
*/
|
||||
transformer?: (document: any) => any
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
export const variantKeys = [
|
||||
"sku",
|
||||
"title",
|
||||
"upc",
|
||||
"ean",
|
||||
"mid_code",
|
||||
"hs_code",
|
||||
"options",
|
||||
]
|
||||
Reference in New Issue
Block a user