@mframework/layer-search 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ import { SearchQuery } from "./query";
2
+ import { SearchResult } from "./result";
3
+
4
+ export interface SearchAdapter {
5
+ search(query: SearchQuery): Promise<SearchResult>
6
+ }
@@ -0,0 +1,9 @@
1
+ export interface FacetValue {
2
+ value: string
3
+ count: number
4
+ }
5
+
6
+ export interface Facet {
7
+ field: string
8
+ values: FacetValue[]
9
+ }
@@ -0,0 +1,19 @@
1
+ export interface OpenSearchHit<T = unknown> {
2
+ _source: T
3
+ }
4
+
5
+ export interface OpenSearchHits<T = unknown> {
6
+ total: { value: number }
7
+ hits: Array<OpenSearchHit<T>>
8
+ }
9
+
10
+ export interface OpenSearchAggregations {
11
+ [key: string]: {
12
+ buckets: Array<{ key: string; doc_count: number }>
13
+ }
14
+ }
15
+
16
+ export interface OpenSearchResponse<T = unknown> {
17
+ hits: OpenSearchHits<T>
18
+ aggregations?: OpenSearchAggregations
19
+ }
@@ -0,0 +1,19 @@
1
+ export interface SearchFilter {
2
+ field: string
3
+ value: string | number | boolean
4
+ }
5
+
6
+ export interface SortOption {
7
+ field: string
8
+ direction: 'asc' | 'desc'
9
+ }
10
+
11
+ export interface SearchQuery {
12
+ q: string
13
+ filters?: SearchFilter[]
14
+ sort?: SortOption[]
15
+ page?: number
16
+ limit?: number
17
+ offset?: number
18
+ pageSize?: number
19
+ }
@@ -0,0 +1,18 @@
1
+ export interface SearchResultItem {
2
+ id: string
3
+ type: 'product' | 'category' | 'content' | string
4
+ title: string
5
+ description?: string
6
+ image?: string
7
+ url?: string
8
+ }
9
+
10
+ export interface SearchResultBase {
11
+ items: SearchResultItem[]
12
+ total: number
13
+ }
14
+
15
+ export type SearchResult<T = SearchResultItem> = {
16
+ items: T[]
17
+ total: number
18
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mframework/layer-search",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Powerful search module for the M Framework.",
5
5
  "keywords": [
6
6
  "meeovi",