[Manager] Add registry search fallback with gateway pattern (#4187)

This commit is contained in:
Christian Byrne
2025-06-15 17:22:05 -07:00
committed by GitHub
parent d5ecfb2c99
commit 75077fe9ed
14 changed files with 1687 additions and 260 deletions

View File

@@ -12,11 +12,20 @@ type SafeNestedProperty<
> = T[K1] extends undefined | null ? undefined : NonNullable<T[K1]>[K2]
type RegistryNodePack = components['schemas']['Node']
/**
* Result of searching the Algolia index.
* Represents the entire result of a search query.
*/
export type SearchPacksResult = {
nodePacks: Hit<AlgoliaNodePack>[]
querySuggestions: Hit<NodesIndexSuggestion>[]
}
/**
* Node pack record after it has been mapped to Algolia index format.
* @see https://github.com/Comfy-Org/comfy-api/blob/main/mapper/algolia.go
*/
export interface AlgoliaNodePack {
objectID: RegistryNodePack['id']
name: RegistryNodePack['name']
@@ -52,7 +61,14 @@ export interface AlgoliaNodePack {
icon_url: RegistryNodePack['icon']
}
/**
* An attribute that can be used to search the Algolia index by.
*/
export type SearchAttribute = keyof AlgoliaNodePack
/**
* Suggestion for a search query (autocomplete).
*/
export interface NodesIndexSuggestion {
nb_words: number
nodes_index: {
@@ -67,8 +83,11 @@ export interface NodesIndexSuggestion {
query: string
}
/**
* Parameters for searching the Algolia index.
*/
export type SearchNodePacksParams = BaseSearchParamsWithoutQuery & {
pageSize: number
pageNumber: number
restrictSearchableAttributes: SearchAttribute[]
restrictSearchableAttributes?: SearchAttribute[]
}

View File

@@ -3,6 +3,7 @@ import type { InjectionKey, Ref } from 'vue'
import type { ComfyWorkflowJSON } from '@/schemas/comfyWorkflowSchema'
import type { AlgoliaNodePack } from '@/types/algoliaTypes'
import type { components } from '@/types/comfyRegistryTypes'
import type { SearchMode } from '@/types/searchServiceTypes'
type WorkflowNodeProperties = ComfyWorkflowJSON['nodes'][0]['properties']
@@ -238,6 +239,6 @@ export interface UpdateAllPacksParams {
export interface ManagerState {
selectedTabId: ManagerTab
searchQuery: string
searchMode: 'nodes' | 'packs'
sortField: SortableAlgoliaField
searchMode: SearchMode
sortField: string
}

View File

@@ -0,0 +1,49 @@
import type { SearchNodePacksParams } from '@/types/algoliaTypes'
import type { components } from '@/types/comfyRegistryTypes'
type RegistryNodePack = components['schemas']['Node']
/**
* Search mode for filtering results
*/
export type SearchMode = 'nodes' | 'packs'
export type QuerySuggestion = {
query: string
popularity: number
}
export interface SearchPacksResult {
nodePacks: RegistryNodePack[]
querySuggestions: QuerySuggestion[]
}
export interface SortableField<T = string> {
id: T
label: string
direction: 'asc' | 'desc'
}
export interface NodePackSearchProvider {
/**
* Search for node packs
*/
searchPacks(
query: string,
params: SearchNodePacksParams
): Promise<SearchPacksResult>
/**
* Clear the search cache
*/
clearSearchCache(): void
/**
* Get the sort value for a pack based on the sort field
*/
getSortValue(pack: RegistryNodePack, sortField: string): string | number
/**
* Get the list of sortable fields supported by this provider
*/
getSortableFields(): SortableField[]
}