@86d-app/search 0.0.21 → 0.0.23
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.
- package/dist/service.d.ts +20 -20
- package/dist/service.d.ts.map +1 -1
- package/dist/store/endpoints/index.d.ts +1 -1
- package/dist/store/endpoints/store-search.d.ts +1 -1
- package/dist/store/endpoints/store-search.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/service.ts +20 -20
- package/src/store/endpoints/store-search.ts +2 -2
package/dist/service.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ModuleController } from "@86d-app/core";
|
|
2
|
-
export
|
|
2
|
+
export type SearchIndexItem = {
|
|
3
3
|
id: string;
|
|
4
4
|
entityType: string;
|
|
5
5
|
entityId: string;
|
|
@@ -10,22 +10,22 @@ export interface SearchIndexItem {
|
|
|
10
10
|
image?: string | undefined;
|
|
11
11
|
metadata: Record<string, unknown>;
|
|
12
12
|
indexedAt: Date;
|
|
13
|
-
}
|
|
14
|
-
export
|
|
13
|
+
};
|
|
14
|
+
export type SearchQuery = {
|
|
15
15
|
id: string;
|
|
16
16
|
term: string;
|
|
17
17
|
normalizedTerm: string;
|
|
18
18
|
resultCount: number;
|
|
19
19
|
sessionId?: string | undefined;
|
|
20
20
|
searchedAt: Date;
|
|
21
|
-
}
|
|
22
|
-
export
|
|
21
|
+
};
|
|
22
|
+
export type SearchSynonym = {
|
|
23
23
|
id: string;
|
|
24
24
|
term: string;
|
|
25
25
|
synonyms: string[];
|
|
26
26
|
createdAt: Date;
|
|
27
|
-
}
|
|
28
|
-
export
|
|
27
|
+
};
|
|
28
|
+
export type SearchClick = {
|
|
29
29
|
id: string;
|
|
30
30
|
queryId: string;
|
|
31
31
|
term: string;
|
|
@@ -33,9 +33,9 @@ export interface SearchClick {
|
|
|
33
33
|
entityId: string;
|
|
34
34
|
position: number;
|
|
35
35
|
clickedAt: Date;
|
|
36
|
-
}
|
|
36
|
+
};
|
|
37
37
|
export type SearchSortField = "relevance" | "newest" | "oldest" | "title_asc" | "title_desc";
|
|
38
|
-
export
|
|
38
|
+
export type SearchFacets = {
|
|
39
39
|
entityTypes: Array<{
|
|
40
40
|
type: string;
|
|
41
41
|
count: number;
|
|
@@ -44,17 +44,17 @@ export interface SearchFacets {
|
|
|
44
44
|
tag: string;
|
|
45
45
|
count: number;
|
|
46
46
|
}>;
|
|
47
|
-
}
|
|
48
|
-
export
|
|
47
|
+
};
|
|
48
|
+
export type SearchResult = {
|
|
49
49
|
item: SearchIndexItem;
|
|
50
50
|
score: number;
|
|
51
51
|
highlights?: SearchHighlight | undefined;
|
|
52
|
-
}
|
|
53
|
-
export
|
|
52
|
+
};
|
|
53
|
+
export type SearchHighlight = {
|
|
54
54
|
title?: string | undefined;
|
|
55
55
|
body?: string | undefined;
|
|
56
|
-
}
|
|
57
|
-
export
|
|
56
|
+
};
|
|
57
|
+
export type SearchAnalyticsSummary = {
|
|
58
58
|
totalQueries: number;
|
|
59
59
|
uniqueTerms: number;
|
|
60
60
|
avgResultCount: number;
|
|
@@ -62,13 +62,13 @@ export interface SearchAnalyticsSummary {
|
|
|
62
62
|
zeroResultRate: number;
|
|
63
63
|
clickThroughRate: number;
|
|
64
64
|
avgClickPosition: number;
|
|
65
|
-
}
|
|
66
|
-
export
|
|
65
|
+
};
|
|
66
|
+
export type PopularTerm = {
|
|
67
67
|
term: string;
|
|
68
68
|
count: number;
|
|
69
69
|
avgResultCount: number;
|
|
70
|
-
}
|
|
71
|
-
export
|
|
70
|
+
};
|
|
71
|
+
export type SearchController = ModuleController & {
|
|
72
72
|
indexItem(params: {
|
|
73
73
|
entityType: string;
|
|
74
74
|
entityId: string;
|
|
@@ -123,5 +123,5 @@ export interface SearchController extends ModuleController {
|
|
|
123
123
|
removeSynonym(id: string): Promise<boolean>;
|
|
124
124
|
listSynonyms(): Promise<SearchSynonym[]>;
|
|
125
125
|
getIndexCount(): Promise<number>;
|
|
126
|
-
}
|
|
126
|
+
};
|
|
127
127
|
//# sourceMappingURL=service.d.ts.map
|
package/dist/service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,MAAM,eAAe,GAAG;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,SAAS,EAAE,IAAI,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,UAAU,EAAE,IAAI,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,IAAI,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACzB,EAAE,EAAE,MA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AAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAErE,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE5C,YAAY,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAEzC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CACjC,CAAC"}
|
|
@@ -2,7 +2,7 @@ export declare const storeEndpoints: {
|
|
|
2
2
|
"/search/store-search": import("better-call").StrictEndpoint<"/search/store-search", {
|
|
3
3
|
method: "GET";
|
|
4
4
|
query: import("zod").ZodObject<{
|
|
5
|
-
q: import("zod").ZodString
|
|
5
|
+
q: import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<string, string>>;
|
|
6
6
|
limit: import("zod").ZodOptional<import("zod").ZodString>;
|
|
7
7
|
}, import("zod/v4/core").$strip>;
|
|
8
8
|
}, {
|
|
@@ -2,7 +2,7 @@ import { z } from "@86d-app/core";
|
|
|
2
2
|
export declare const storeSearch: import("better-call").StrictEndpoint<"/search/store-search", {
|
|
3
3
|
method: "GET";
|
|
4
4
|
query: z.ZodObject<{
|
|
5
|
-
q: z.ZodString
|
|
5
|
+
q: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
6
6
|
limit: z.ZodOptional<z.ZodString>;
|
|
7
7
|
}, z.core.$strip>;
|
|
8
8
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store-search.d.ts","sourceRoot":"","sources":["../../../src/store/endpoints/store-search.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"store-search.d.ts","sourceRoot":"","sources":["../../../src/store/endpoints/store-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,CAAC,EAAE,MAAM,eAAe,CAAC;AAGrE,eAAO,MAAM,WAAW;;;;;;;;;;;;;EAqCvB,CAAC"}
|
package/package.json
CHANGED
package/src/service.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ModuleController } from "@86d-app/core";
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export type SearchIndexItem = {
|
|
4
4
|
id: string;
|
|
5
5
|
entityType: string;
|
|
6
6
|
entityId: string;
|
|
@@ -11,25 +11,25 @@ export interface SearchIndexItem {
|
|
|
11
11
|
image?: string | undefined;
|
|
12
12
|
metadata: Record<string, unknown>;
|
|
13
13
|
indexedAt: Date;
|
|
14
|
-
}
|
|
14
|
+
};
|
|
15
15
|
|
|
16
|
-
export
|
|
16
|
+
export type SearchQuery = {
|
|
17
17
|
id: string;
|
|
18
18
|
term: string;
|
|
19
19
|
normalizedTerm: string;
|
|
20
20
|
resultCount: number;
|
|
21
21
|
sessionId?: string | undefined;
|
|
22
22
|
searchedAt: Date;
|
|
23
|
-
}
|
|
23
|
+
};
|
|
24
24
|
|
|
25
|
-
export
|
|
25
|
+
export type SearchSynonym = {
|
|
26
26
|
id: string;
|
|
27
27
|
term: string;
|
|
28
28
|
synonyms: string[];
|
|
29
29
|
createdAt: Date;
|
|
30
|
-
}
|
|
30
|
+
};
|
|
31
31
|
|
|
32
|
-
export
|
|
32
|
+
export type SearchClick = {
|
|
33
33
|
id: string;
|
|
34
34
|
queryId: string;
|
|
35
35
|
term: string;
|
|
@@ -37,7 +37,7 @@ export interface SearchClick {
|
|
|
37
37
|
entityId: string;
|
|
38
38
|
position: number;
|
|
39
39
|
clickedAt: Date;
|
|
40
|
-
}
|
|
40
|
+
};
|
|
41
41
|
|
|
42
42
|
export type SearchSortField =
|
|
43
43
|
| "relevance"
|
|
@@ -46,23 +46,23 @@ export type SearchSortField =
|
|
|
46
46
|
| "title_asc"
|
|
47
47
|
| "title_desc";
|
|
48
48
|
|
|
49
|
-
export
|
|
49
|
+
export type SearchFacets = {
|
|
50
50
|
entityTypes: Array<{ type: string; count: number }>;
|
|
51
51
|
tags: Array<{ tag: string; count: number }>;
|
|
52
|
-
}
|
|
52
|
+
};
|
|
53
53
|
|
|
54
|
-
export
|
|
54
|
+
export type SearchResult = {
|
|
55
55
|
item: SearchIndexItem;
|
|
56
56
|
score: number;
|
|
57
57
|
highlights?: SearchHighlight | undefined;
|
|
58
|
-
}
|
|
58
|
+
};
|
|
59
59
|
|
|
60
|
-
export
|
|
60
|
+
export type SearchHighlight = {
|
|
61
61
|
title?: string | undefined;
|
|
62
62
|
body?: string | undefined;
|
|
63
|
-
}
|
|
63
|
+
};
|
|
64
64
|
|
|
65
|
-
export
|
|
65
|
+
export type SearchAnalyticsSummary = {
|
|
66
66
|
totalQueries: number;
|
|
67
67
|
uniqueTerms: number;
|
|
68
68
|
avgResultCount: number;
|
|
@@ -70,15 +70,15 @@ export interface SearchAnalyticsSummary {
|
|
|
70
70
|
zeroResultRate: number;
|
|
71
71
|
clickThroughRate: number;
|
|
72
72
|
avgClickPosition: number;
|
|
73
|
-
}
|
|
73
|
+
};
|
|
74
74
|
|
|
75
|
-
export
|
|
75
|
+
export type PopularTerm = {
|
|
76
76
|
term: string;
|
|
77
77
|
count: number;
|
|
78
78
|
avgResultCount: number;
|
|
79
|
-
}
|
|
79
|
+
};
|
|
80
80
|
|
|
81
|
-
export
|
|
81
|
+
export type SearchController = ModuleController & {
|
|
82
82
|
indexItem(params: {
|
|
83
83
|
entityType: string;
|
|
84
84
|
entityId: string;
|
|
@@ -153,4 +153,4 @@ export interface SearchController extends ModuleController {
|
|
|
153
153
|
listSynonyms(): Promise<SearchSynonym[]>;
|
|
154
154
|
|
|
155
155
|
getIndexCount(): Promise<number>;
|
|
156
|
-
}
|
|
156
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createStoreEndpoint, z } from "@86d-app/core";
|
|
1
|
+
import { createStoreEndpoint, sanitizeText, z } from "@86d-app/core";
|
|
2
2
|
import type { SearchController } from "../../service";
|
|
3
3
|
|
|
4
4
|
export const storeSearch = createStoreEndpoint(
|
|
@@ -6,7 +6,7 @@ export const storeSearch = createStoreEndpoint(
|
|
|
6
6
|
{
|
|
7
7
|
method: "GET",
|
|
8
8
|
query: z.object({
|
|
9
|
-
q: z.string().min(0).max(500),
|
|
9
|
+
q: z.string().min(0).max(500).transform(sanitizeText),
|
|
10
10
|
limit: z.string().max(10).optional(),
|
|
11
11
|
}),
|
|
12
12
|
},
|