feat(index): Add http/module api to interact with the index engine (#13869)
* feat(index): Add support to trigger sync manually * feat(index): Add API route to interact with * feat(index): Add API route to interact with * feat(index): Add API route to interact with * test(): Add http integration tests * Create weak-elephants-reply.md
This commit is contained in:
committed by
GitHub
parent
540ae996ff
commit
85b1f3d43a
@@ -12,6 +12,7 @@ import {
|
||||
IEventBusModuleService,
|
||||
IFileModuleService,
|
||||
IFulfillmentModuleService,
|
||||
IIndexService,
|
||||
IInventoryService,
|
||||
ILockingModule,
|
||||
INotificationModuleService,
|
||||
@@ -78,6 +79,7 @@ declare module "@medusajs/types" {
|
||||
[Modules.LOCKING]: ILockingModule
|
||||
[Modules.SETTINGS]: ISettingsModuleService
|
||||
[Modules.CACHING]: ICachingModuleService
|
||||
[Modules.INDEX]: IIndexService
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,3 +46,4 @@ export * from "./tax-region"
|
||||
export * from "./user"
|
||||
export * from "./view-configuration"
|
||||
export * from "./workflow-execution"
|
||||
export * from "./index/index"
|
||||
|
||||
3
packages/core/types/src/http/index/admin/payload.ts
Normal file
3
packages/core/types/src/http/index/admin/payload.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export interface AdminIndexSyncPayload {
|
||||
strategy: "full" | "reset"
|
||||
}
|
||||
5
packages/core/types/src/http/index/admin/responses.ts
Normal file
5
packages/core/types/src/http/index/admin/responses.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { IndexInfo } from "../../../index-data"
|
||||
|
||||
export interface AdminIndexDetailsResponse {
|
||||
metadata: IndexInfo[]
|
||||
}
|
||||
2
packages/core/types/src/http/index/index.ts
Normal file
2
packages/core/types/src/http/index/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./admin/payload"
|
||||
export * from "./admin/responses"
|
||||
@@ -13,8 +13,33 @@ export interface IndexModuleOptions {
|
||||
schema: string
|
||||
}
|
||||
|
||||
export interface IndexInfo {
|
||||
id: string
|
||||
entity: string
|
||||
status: "pending" | "processing" | "done" | "error"
|
||||
fields: string[]
|
||||
updated_at: Date
|
||||
last_synced_key: string | null
|
||||
}
|
||||
|
||||
export interface IIndexService extends IModuleService {
|
||||
query<const TEntry extends string>(
|
||||
config: IndexQueryConfig<TEntry>
|
||||
): Promise<QueryResultSet<TEntry>>
|
||||
|
||||
/**
|
||||
* Sync the index
|
||||
* The sync strategy can be "full" meaning it will re sync the entire index, "reset" meaning it
|
||||
* will reset the index data and start from scratch, or if not specified, it will continue the
|
||||
* sync from the last sync point.
|
||||
*
|
||||
* @param strategy The sync strategy
|
||||
*/
|
||||
sync({ strategy }?: { strategy?: "full" | "reset" }): Promise<void>
|
||||
|
||||
/**
|
||||
* Get the index information
|
||||
* @returns The index information
|
||||
*/
|
||||
getInfo(): Promise<IndexInfo[]>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user