feat(medusa-plugin-algolia): Revamp Algolia search plugin (#3510)

This commit is contained in:
Oliver Windall Juhl
2023-03-22 12:55:26 +01:00
committed by GitHub
parent ef5ef9f5a2
commit 74bc4b16a0
43 changed files with 518 additions and 454 deletions
+1
View File
@@ -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"
+2
View File
@@ -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"
+3
View File
@@ -0,0 +1,3 @@
export const indexTypes = {
PRODUCTS: "products"
};
+20
View File
@@ -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
}
+70
View File
@@ -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
}
+16
View File
@@ -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",
]