@dalencatt/strapi-plugin-fuzzy-search-private 0.0.0-development
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/LICENSE +21 -0
- package/README.md +579 -0
- package/dist/server/index.js +695 -0
- package/dist/server/index.mjs +677 -0
- package/dist/server/src/bootstrap.d.ts +2 -0
- package/dist/server/src/config/config.schema.d.ts +19 -0
- package/dist/server/src/config/index.d.ts +8 -0
- package/dist/server/src/config/query.schema.d.ts +34 -0
- package/dist/server/src/controllers/index.d.ts +8 -0
- package/dist/server/src/controllers/search-controller.d.ts +7 -0
- package/dist/server/src/graphql/index.d.ts +3 -0
- package/dist/server/src/graphql/resolvers-config.d.ts +8 -0
- package/dist/server/src/graphql/types.d.ts +3 -0
- package/dist/server/src/index.d.ts +33 -0
- package/dist/server/src/interfaces/interfaces.d.ts +98 -0
- package/dist/server/src/register.d.ts +5 -0
- package/dist/server/src/routes/index.d.ts +11 -0
- package/dist/server/src/routes/search-routes.d.ts +6 -0
- package/dist/server/src/services/fuzzySearch-service.d.ts +23 -0
- package/dist/server/src/services/index.d.ts +4 -0
- package/dist/server/src/services/pagination-service.d.ts +9 -0
- package/dist/server/src/services/response-transformation-service.d.ts +7 -0
- package/dist/server/src/services/settings-service.d.ts +8 -0
- package/dist/server/src/services/validation-service.d.ts +4 -0
- package/dist/server/src/utils/pluginId.d.ts +2 -0
- package/package.json +114 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { InferType } from 'yup';
|
|
2
|
+
export declare const paginationSchema: import("yup").ObjectSchema<{
|
|
3
|
+
pageSize: string;
|
|
4
|
+
page: string;
|
|
5
|
+
withCount: string;
|
|
6
|
+
}, import("yup").AnyObject, {
|
|
7
|
+
pageSize: undefined;
|
|
8
|
+
page: undefined;
|
|
9
|
+
withCount: undefined;
|
|
10
|
+
}, "">;
|
|
11
|
+
export declare const populationSchema: import("yup").StringSchema<string, import("yup").AnyObject, undefined, "">;
|
|
12
|
+
export declare const querySchema: import("yup").ObjectSchema<{
|
|
13
|
+
query: string;
|
|
14
|
+
locale: string;
|
|
15
|
+
filters: {
|
|
16
|
+
contentTypes?: string;
|
|
17
|
+
};
|
|
18
|
+
}, import("yup").AnyObject, {
|
|
19
|
+
query: undefined;
|
|
20
|
+
locale: undefined;
|
|
21
|
+
filters: {
|
|
22
|
+
contentTypes: undefined;
|
|
23
|
+
};
|
|
24
|
+
}, "">;
|
|
25
|
+
export type PaginationBaseQuery = InferType<typeof paginationSchema>;
|
|
26
|
+
export type PopulationSchema = InferType<typeof populationSchema>;
|
|
27
|
+
type QuerySchema = InferType<typeof querySchema>;
|
|
28
|
+
export type SearchQuery = Omit<QuerySchema, 'filters'> & {
|
|
29
|
+
pagination?: Record<string, PaginationBaseQuery>;
|
|
30
|
+
populate?: Record<string, PopulationSchema>;
|
|
31
|
+
filters?: QuerySchema['filters'] & Record<string, any>;
|
|
32
|
+
status?: 'published' | 'draft';
|
|
33
|
+
};
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
searchController: () => {
|
|
3
|
+
search(ctx: import("../interfaces/interfaces").Context): Promise<void | {
|
|
4
|
+
[x: string]: Record<string, unknown>[] | import("../interfaces/interfaces").PaginatedModelResponse<import("../interfaces/interfaces").RESTPaginationMeta>;
|
|
5
|
+
}>;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Context } from '../interfaces/interfaces';
|
|
2
|
+
declare const _default: () => {
|
|
3
|
+
search(ctx: Context): Promise<void | {
|
|
4
|
+
[x: string]: Record<string, unknown>[] | import("../interfaces/interfaces").PaginatedModelResponse<import("../interfaces/interfaces").RESTPaginationMeta>;
|
|
5
|
+
}>;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
bootstrap: () => void;
|
|
3
|
+
register: ({ strapi }: {
|
|
4
|
+
strapi: import("@strapi/types/dist/core").Strapi;
|
|
5
|
+
}) => void;
|
|
6
|
+
config: {
|
|
7
|
+
default(): {
|
|
8
|
+
contentTypes: {};
|
|
9
|
+
};
|
|
10
|
+
validator(config: import("./interfaces/interfaces").Config): Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
controllers: {
|
|
13
|
+
searchController: () => {
|
|
14
|
+
search(ctx: import("./interfaces/interfaces").Context): Promise<void | {
|
|
15
|
+
[x: string]: Record<string, unknown>[] | import("./interfaces/interfaces").PaginatedModelResponse<import("./interfaces/interfaces").RESTPaginationMeta>;
|
|
16
|
+
}>;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
routes: {
|
|
20
|
+
'content-api': {
|
|
21
|
+
type: string;
|
|
22
|
+
routes: {
|
|
23
|
+
method: string;
|
|
24
|
+
path: string;
|
|
25
|
+
handler: string;
|
|
26
|
+
}[];
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
services: {
|
|
30
|
+
settingsService: () => import("./services/settings-service").SettingsService;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export default _default;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Schema } from '@strapi/strapi';
|
|
2
|
+
import { SearchQuery } from '../config/query.schema';
|
|
3
|
+
export type Mutable<T> = {
|
|
4
|
+
-readonly [P in keyof T]: T[P];
|
|
5
|
+
};
|
|
6
|
+
export interface Config {
|
|
7
|
+
contentTypes: ContentType[];
|
|
8
|
+
}
|
|
9
|
+
export interface FuzzySortOptions {
|
|
10
|
+
threshold?: number;
|
|
11
|
+
limit?: number;
|
|
12
|
+
characterLimit?: number;
|
|
13
|
+
keys: {
|
|
14
|
+
name: string;
|
|
15
|
+
weight?: number;
|
|
16
|
+
}[];
|
|
17
|
+
}
|
|
18
|
+
export interface ContentType extends Schema.ContentType {
|
|
19
|
+
transliterate?: boolean;
|
|
20
|
+
fuzzysortOptions: FuzzySortOptions;
|
|
21
|
+
}
|
|
22
|
+
export interface QueryResult extends ContentType {
|
|
23
|
+
entries: Entry[];
|
|
24
|
+
}
|
|
25
|
+
export interface Result {
|
|
26
|
+
fuzzysortResults: Fuzzysort.KeysResults<Entry>;
|
|
27
|
+
schema: Schema.ContentType;
|
|
28
|
+
}
|
|
29
|
+
export interface Entry {
|
|
30
|
+
id: string | number;
|
|
31
|
+
[x: string]: any;
|
|
32
|
+
}
|
|
33
|
+
export interface PaginationMeta {
|
|
34
|
+
start: number;
|
|
35
|
+
limit: number;
|
|
36
|
+
}
|
|
37
|
+
export interface RESTPaginationMeta {
|
|
38
|
+
pagination: {
|
|
39
|
+
page: number;
|
|
40
|
+
pageSize: number;
|
|
41
|
+
pageCount?: number;
|
|
42
|
+
total?: number;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export interface PaginatedModelResponse<Meta = PaginationMeta> {
|
|
46
|
+
meta: Meta;
|
|
47
|
+
data: unknown[];
|
|
48
|
+
}
|
|
49
|
+
export type ResultsResponse = Record<string, Record<string, unknown>[]>;
|
|
50
|
+
export type PaginatedResultsResponse<Meta = PaginationMeta> = Record<string, PaginatedModelResponse<Meta>>;
|
|
51
|
+
export interface SearchResponseArgs {
|
|
52
|
+
query: string;
|
|
53
|
+
locale?: string;
|
|
54
|
+
}
|
|
55
|
+
export type SearchResponseReturnType = SearchResponseArgs & {
|
|
56
|
+
auth: Record<string, unknown>;
|
|
57
|
+
};
|
|
58
|
+
export type PaginationParams = Record<string, {
|
|
59
|
+
pageSize?: string;
|
|
60
|
+
page?: string;
|
|
61
|
+
withCount?: string;
|
|
62
|
+
}>;
|
|
63
|
+
export interface PaginationArgs {
|
|
64
|
+
page?: number;
|
|
65
|
+
pageSize?: number;
|
|
66
|
+
limit?: number;
|
|
67
|
+
start?: number;
|
|
68
|
+
}
|
|
69
|
+
export interface TransformedPagination {
|
|
70
|
+
limit: number;
|
|
71
|
+
start: number;
|
|
72
|
+
}
|
|
73
|
+
export interface Context {
|
|
74
|
+
state: {
|
|
75
|
+
auth: unknown;
|
|
76
|
+
};
|
|
77
|
+
query: SearchQuery;
|
|
78
|
+
badRequest: (prefix: string, message: string) => void;
|
|
79
|
+
}
|
|
80
|
+
export interface Attribute {
|
|
81
|
+
type: string;
|
|
82
|
+
writable?: boolean;
|
|
83
|
+
relation?: string;
|
|
84
|
+
[key: string]: unknown;
|
|
85
|
+
}
|
|
86
|
+
export interface Model {
|
|
87
|
+
uid?: string;
|
|
88
|
+
kind: 'singleType' | 'collectionType';
|
|
89
|
+
info: {
|
|
90
|
+
singularName: string;
|
|
91
|
+
pluralName: string;
|
|
92
|
+
};
|
|
93
|
+
options: {
|
|
94
|
+
populateCreatorFields: boolean;
|
|
95
|
+
};
|
|
96
|
+
privateAttributes?: string[];
|
|
97
|
+
attributes: Record<string, Attribute>;
|
|
98
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { WhereQuery } from '@strapi/utils/dist/convert-query-params';
|
|
2
|
+
import { ContentType, Entry, FuzzySortOptions, Result } from '../interfaces/interfaces';
|
|
3
|
+
export declare const buildResult: ({ entries, fuzzysortOptions, keys, query, }: {
|
|
4
|
+
entries: Entry[];
|
|
5
|
+
fuzzysortOptions: FuzzySortOptions;
|
|
6
|
+
keys: string[];
|
|
7
|
+
query: string;
|
|
8
|
+
}) => Fuzzysort.KeysResults<Entry>;
|
|
9
|
+
export declare const buildTransliteratedResult: ({ entries, fuzzysortOptions, keys, query, result, }: {
|
|
10
|
+
entries: Entry[];
|
|
11
|
+
fuzzysortOptions: FuzzySortOptions;
|
|
12
|
+
keys: string[];
|
|
13
|
+
query: string;
|
|
14
|
+
result: Fuzzysort.KeysResults<Entry>;
|
|
15
|
+
}) => Fuzzysort.KeysResults<Entry>;
|
|
16
|
+
export default function getResult({ contentType, query, filters, populate, locale, status, }: {
|
|
17
|
+
contentType: ContentType;
|
|
18
|
+
query: string;
|
|
19
|
+
filters?: WhereQuery;
|
|
20
|
+
populate?: string;
|
|
21
|
+
locale?: string;
|
|
22
|
+
status?: 'published' | 'draft';
|
|
23
|
+
}): Promise<Result>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PaginationBaseQuery } from '../config/query.schema';
|
|
2
|
+
import { PaginatedModelResponse, RESTPaginationMeta, ResultsResponse } from '../interfaces/interfaces';
|
|
3
|
+
export declare const paginateRestResults: (pagination: Record<string, PaginationBaseQuery>, pluralNames: string[], resultsResponse: ResultsResponse) => Promise<{
|
|
4
|
+
[x: string]: Record<string, unknown>[] | PaginatedModelResponse<RESTPaginationMeta>;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const paginateGraphQlResults: (results: unknown[], { limit, start }: {
|
|
7
|
+
limit: number;
|
|
8
|
+
start: number;
|
|
9
|
+
}) => PaginatedModelResponse;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PaginationBaseQuery } from '../config/query.schema';
|
|
2
|
+
import { ContentType, Entry, Result, TransformedPagination } from '../interfaces/interfaces';
|
|
3
|
+
export declare const buildGraphqlResponse: (searchResult: Fuzzysort.KeysResults<Entry>, schema: ContentType, auth: Record<string, unknown>, pagination: TransformedPagination) => Promise<any>;
|
|
4
|
+
export declare const buildRestResponse: (searchResults: Result[], auth: unknown, pagination?: Record<string, PaginationBaseQuery>, queriedContentTypes?: string[]) => Promise<{
|
|
5
|
+
[x: string]: Record<string, unknown>[] | import("../interfaces/interfaces").PaginatedModelResponse<import("../interfaces/interfaces").RESTPaginationMeta>;
|
|
6
|
+
}>;
|
|
7
|
+
export default buildRestResponse;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Config } from '../interfaces/interfaces';
|
|
2
|
+
export interface SettingsService {
|
|
3
|
+
get(): Config;
|
|
4
|
+
set(settings: Config): unknown;
|
|
5
|
+
build(settings: Config): Config;
|
|
6
|
+
}
|
|
7
|
+
declare const settingsService: () => SettingsService;
|
|
8
|
+
export default settingsService;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PopulationSchema, SearchQuery } from '../config/query.schema';
|
|
2
|
+
import { ContentType, PaginationParams } from '../interfaces/interfaces';
|
|
3
|
+
export declare const validateQueryParams: (query: SearchQuery, contentTypes: ContentType[], pagination: PaginationParams | undefined, populate: Record<string, PopulationSchema> | undefined, filteredContentTypes: string[] | null | undefined) => Promise<void>;
|
|
4
|
+
export declare const validateQuery: (contentType: ContentType, locale?: string) => Promise<void>;
|
package/package.json
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dalencatt/strapi-plugin-fuzzy-search-private",
|
|
3
|
+
"version": "0.0.0-development",
|
|
4
|
+
"description": "Register a weighted fuzzy search endpoint for Strapi Headless CMS you can add your content types to in no time.",
|
|
5
|
+
"strapi": {
|
|
6
|
+
"displayName": "Fuzzy Search",
|
|
7
|
+
"name": "fuzzy-search",
|
|
8
|
+
"description": "Register a weighted fuzzy search endpoint to your content types in no time.",
|
|
9
|
+
"kind": "plugin"
|
|
10
|
+
},
|
|
11
|
+
"type": "commonjs",
|
|
12
|
+
"exports": {
|
|
13
|
+
"./package.json": "./package.json",
|
|
14
|
+
"./strapi-server": {
|
|
15
|
+
"types": "./dist/server/src/index.d.ts",
|
|
16
|
+
"source": "./server/src/index.ts",
|
|
17
|
+
"import": "./dist/server/index.mjs",
|
|
18
|
+
"require": "./dist/server/index.js",
|
|
19
|
+
"default": "./dist/server/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"semantic-release": "semantic-release",
|
|
27
|
+
"build": "strapi-plugin build",
|
|
28
|
+
"watch": "strapi-plugin watch",
|
|
29
|
+
"watch:link": "strapi-plugin watch:link",
|
|
30
|
+
"verify": "strapi-plugin verify",
|
|
31
|
+
"test:ts:back": "run -T tsc -p server/tsconfig.json",
|
|
32
|
+
"typecheck": "tsc --noEmit -p server/tsconfig.json",
|
|
33
|
+
"test": "vitest",
|
|
34
|
+
"test:coverage": "vitest run --coverage",
|
|
35
|
+
"test:coverage:json": "vitest run --coverage.enabled --coverage.reporter=json-summary",
|
|
36
|
+
"lint": "eslint .",
|
|
37
|
+
"prettier:check": "prettier --check ./server ./tests",
|
|
38
|
+
"prettier:write": "prettier --write ./server ./tests"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"registry": "https://registry.npmjs.org/",
|
|
42
|
+
"tag": "latest"
|
|
43
|
+
},
|
|
44
|
+
"release": {
|
|
45
|
+
"branches": [
|
|
46
|
+
"main",
|
|
47
|
+
{
|
|
48
|
+
"name": "beta",
|
|
49
|
+
"prerelease": true
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"name": "beta-private",
|
|
53
|
+
"prerelease": true
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"fuzzysort": "3.1.0",
|
|
59
|
+
"transliteration": "2.3.5"
|
|
60
|
+
},
|
|
61
|
+
"peerDependencies": {
|
|
62
|
+
"@strapi/sdk-plugin": "^5.2.7",
|
|
63
|
+
"@strapi/strapi": "^5.1.1",
|
|
64
|
+
"@strapi/utils": "^5.1.1",
|
|
65
|
+
"yup": "1.4.0"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@eslint/compat": "^1.2.2",
|
|
69
|
+
"@eslint/eslintrc": "^3.1.0",
|
|
70
|
+
"@eslint/js": "^9.13.0",
|
|
71
|
+
"@strapi/sdk-plugin": "^5.2.7",
|
|
72
|
+
"@strapi/strapi": "^5.1.1",
|
|
73
|
+
"@strapi/typescript-utils": "^5.1.1",
|
|
74
|
+
"@typescript-eslint/eslint-plugin": "8.12.1",
|
|
75
|
+
"@typescript-eslint/parser": "8.12.1",
|
|
76
|
+
"@vitest/coverage-v8": "2.1.4",
|
|
77
|
+
"all-contributors-cli": "^6.20.0",
|
|
78
|
+
"eslint": "^9.13.0",
|
|
79
|
+
"eslint-config-prettier": "9.1.0",
|
|
80
|
+
"eslint-plugin-import": "2.31.0",
|
|
81
|
+
"eslint-plugin-prettier": "5.2.1",
|
|
82
|
+
"eslint-plugin-promise": "7.1.0",
|
|
83
|
+
"globals": "^15.11.0",
|
|
84
|
+
"prettier": "3.3.3",
|
|
85
|
+
"semantic-release": "^24.0.0",
|
|
86
|
+
"typescript": "^5.6.3",
|
|
87
|
+
"typescript-eslint": "^8.12.1",
|
|
88
|
+
"vitest": "2.1.4"
|
|
89
|
+
},
|
|
90
|
+
"author": "@DomDew (https://github.com/DomDew)",
|
|
91
|
+
"maintainers": [
|
|
92
|
+
"@DomDew (https://github.com/DomDew)",
|
|
93
|
+
"@wfproductions (https://github.com/wfproductions)"
|
|
94
|
+
],
|
|
95
|
+
"engines": {
|
|
96
|
+
"node": ">=18.x.x <=20.x.x",
|
|
97
|
+
"npm": ">=6.0.0"
|
|
98
|
+
},
|
|
99
|
+
"license": "MIT",
|
|
100
|
+
"repository": {
|
|
101
|
+
"type": "git",
|
|
102
|
+
"url": "https://github.com/Moonlight63/strapi-plugin-fuzzy-search.git"
|
|
103
|
+
},
|
|
104
|
+
"keywords": [
|
|
105
|
+
"strapi",
|
|
106
|
+
"fuzzysort",
|
|
107
|
+
"fuzzysearch",
|
|
108
|
+
"search"
|
|
109
|
+
],
|
|
110
|
+
"bugs": {
|
|
111
|
+
"url": "https://github.com/DomDew/strapi-plugin-fuzzy-search/issues"
|
|
112
|
+
},
|
|
113
|
+
"homepage": "https://github.com/DomDew/strapi-plugin-fuzzy-search#readme"
|
|
114
|
+
}
|