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:
Adrien de Peretti
2025-10-28 20:31:39 +01:00
committed by GitHub
parent 540ae996ff
commit 85b1f3d43a
19 changed files with 1061 additions and 7 deletions

View File

@@ -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
}
}

View File

@@ -46,3 +46,4 @@ export * from "./tax-region"
export * from "./user"
export * from "./view-configuration"
export * from "./workflow-execution"
export * from "./index/index"

View File

@@ -0,0 +1,3 @@
export interface AdminIndexSyncPayload {
strategy: "full" | "reset"
}

View File

@@ -0,0 +1,5 @@
import { IndexInfo } from "../../../index-data"
export interface AdminIndexDetailsResponse {
metadata: IndexInfo[]
}

View File

@@ -0,0 +1,2 @@
export * from "./admin/payload"
export * from "./admin/responses"

View File

@@ -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[]>
}