@tachybase/plugin-full-text-search 1.3.8 → 1.3.10
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/externalVersion.js +4 -4
- package/dist/server/dialects/FieldBase.d.ts +2 -0
- package/dist/server/dialects/FieldBase.js +13 -4
- package/dist/server/dialects/FieldMariadb.js +16 -10
- package/dist/server/dialects/FieldPostgres.js +2 -2
- package/dist/server/dialects/FieldSqlite.js +14 -8
- package/package.json +6 -6
package/dist/externalVersion.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
"@tachybase/client": "1.3.
|
|
2
|
+
"@tachybase/client": "1.3.10",
|
|
3
3
|
"antd": "5.22.5",
|
|
4
4
|
"lodash": "4.17.21",
|
|
5
|
-
"@tachybase/server": "1.3.
|
|
6
|
-
"@tachybase/database": "1.3.
|
|
7
|
-
"@tachybase/actions": "1.3.
|
|
5
|
+
"@tachybase/server": "1.3.10",
|
|
6
|
+
"@tachybase/database": "1.3.10",
|
|
7
|
+
"@tachybase/actions": "1.3.10",
|
|
8
8
|
"sequelize": "6.37.5"
|
|
9
9
|
};
|
|
@@ -19,5 +19,7 @@ export declare class FieldBase {
|
|
|
19
19
|
getMultiSelectFilter(field: string, matchEnum: string[]): WhereOptions<any>;
|
|
20
20
|
array(params: handleFieldParams): WhereOptions<any>;
|
|
21
21
|
private getMatchEnum;
|
|
22
|
+
protected getCollectionField(fieldName: string, collectionName?: string): import("sequelize/lib/utils").Col;
|
|
23
|
+
protected getCollectionFieldColName(fieldName: string, collectionName?: string): string;
|
|
22
24
|
}
|
|
23
25
|
export {};
|
|
@@ -49,14 +49,14 @@ class FieldBase {
|
|
|
49
49
|
return this.convertToObj(field, { [this.like]: `%${(0, import_utils.escapeLike)(keyword)}%` });
|
|
50
50
|
}
|
|
51
51
|
number(params) {
|
|
52
|
-
const { field, keyword } = params;
|
|
52
|
+
const { field, keyword, collectionName } = params;
|
|
53
53
|
if (isNaN(Number(keyword))) {
|
|
54
54
|
return null;
|
|
55
55
|
}
|
|
56
56
|
return {
|
|
57
57
|
[import_database.Op.and]: [
|
|
58
58
|
(0, import_database.where)(
|
|
59
|
-
(0, import_database.literal)(`CAST(${(
|
|
59
|
+
(0, import_database.literal)(`CAST(${this.getCollectionFieldColName(field, collectionName)} AS TEXT)`),
|
|
60
60
|
// 确保不加引号,直接插入 SQL 表达式
|
|
61
61
|
{
|
|
62
62
|
[import_database.Op.like]: `%${(0, import_utils.escapeLike)(keyword)}%`
|
|
@@ -90,14 +90,14 @@ class FieldBase {
|
|
|
90
90
|
}
|
|
91
91
|
array(params) {
|
|
92
92
|
var _a, _b;
|
|
93
|
-
const { field, keyword, fields } = params;
|
|
93
|
+
const { field, keyword, fields, collectionName } = params;
|
|
94
94
|
const fieldInfo = fields.get(field);
|
|
95
95
|
if (((_b = (_a = fieldInfo == null ? void 0 : fieldInfo.options) == null ? void 0 : _a.uiSchema) == null ? void 0 : _b["x-component"]) === "Select") {
|
|
96
96
|
const matchEnum = this.getMatchEnum(fieldInfo, keyword);
|
|
97
97
|
if (!matchEnum.length) {
|
|
98
98
|
return null;
|
|
99
99
|
}
|
|
100
|
-
return this.getMultiSelectFilter(field, matchEnum);
|
|
100
|
+
return this.getMultiSelectFilter(this.getCollectionFieldColName(field, collectionName), matchEnum);
|
|
101
101
|
}
|
|
102
102
|
return null;
|
|
103
103
|
}
|
|
@@ -112,6 +112,15 @@ class FieldBase {
|
|
|
112
112
|
}
|
|
113
113
|
return matchEnum;
|
|
114
114
|
}
|
|
115
|
+
getCollectionField(fieldName, collectionName) {
|
|
116
|
+
if (!collectionName) {
|
|
117
|
+
return (0, import_sequelize.col)(fieldName);
|
|
118
|
+
}
|
|
119
|
+
return (0, import_sequelize.col)(`${collectionName}.${fieldName}`);
|
|
120
|
+
}
|
|
121
|
+
getCollectionFieldColName(fieldName, collectionName) {
|
|
122
|
+
return this.getCollectionField(fieldName, collectionName).col;
|
|
123
|
+
}
|
|
115
124
|
}
|
|
116
125
|
// Annotate the CommonJS export names for ESM import in node:
|
|
117
126
|
0 && (module.exports = {
|
|
@@ -21,7 +21,6 @@ __export(FieldMariadb_exports, {
|
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(FieldMariadb_exports);
|
|
23
23
|
var import_database = require("@tachybase/database");
|
|
24
|
-
var import_sequelize = require("sequelize");
|
|
25
24
|
var import_utils = require("../utils");
|
|
26
25
|
var import_FieldBase = require("./FieldBase");
|
|
27
26
|
class FieldMariadb extends import_FieldBase.FieldBase {
|
|
@@ -46,11 +45,11 @@ class FieldMariadb extends import_FieldBase.FieldBase {
|
|
|
46
45
|
return formatStr;
|
|
47
46
|
}
|
|
48
47
|
number(params) {
|
|
49
|
-
const { field, keyword } = params;
|
|
48
|
+
const { field, keyword, collectionName } = params;
|
|
50
49
|
return {
|
|
51
50
|
[import_database.Op.and]: [
|
|
52
51
|
(0, import_database.where)(
|
|
53
|
-
(0, import_database.literal)(`CAST(${(
|
|
52
|
+
(0, import_database.literal)(`CAST(${this.getCollectionFieldColName(field, collectionName)} AS CHAR)`),
|
|
54
53
|
// 确保不加引号,直接插入 SQL 表达式
|
|
55
54
|
{
|
|
56
55
|
[import_database.Op.like]: `%${(0, import_utils.escapeLike)(keyword)}%`
|
|
@@ -60,20 +59,27 @@ class FieldMariadb extends import_FieldBase.FieldBase {
|
|
|
60
59
|
};
|
|
61
60
|
}
|
|
62
61
|
date(params) {
|
|
63
|
-
const { field, keyword, dateStr, timezone } = params;
|
|
62
|
+
const { field, keyword, dateStr, timezone, collectionName } = params;
|
|
64
63
|
return {
|
|
65
64
|
[import_database.Op.and]: [
|
|
66
|
-
(0, import_database.where)(
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
(0, import_database.where)(
|
|
66
|
+
(0, import_database.fn)(
|
|
67
|
+
"DATE_FORMAT",
|
|
68
|
+
(0, import_database.fn)("CONVERT_TZ", this.getCollectionField(field, collectionName), "+00:00", timezone),
|
|
69
|
+
dateStr
|
|
70
|
+
),
|
|
71
|
+
{
|
|
72
|
+
[this.like]: `%${(0, import_utils.escapeLike)(keyword)}%`
|
|
73
|
+
}
|
|
74
|
+
)
|
|
69
75
|
]
|
|
70
76
|
};
|
|
71
77
|
}
|
|
72
78
|
json(params) {
|
|
73
|
-
const { field, keyword } = params;
|
|
79
|
+
const { field, keyword, collectionName } = params;
|
|
74
80
|
return {
|
|
75
81
|
[import_database.Op.and]: [
|
|
76
|
-
(0, import_database.where)((0, import_database.literal)(`JSON_UNQUOTE(JSON_EXTRACT(${field}, '$'))`), {
|
|
82
|
+
(0, import_database.where)((0, import_database.literal)(`JSON_UNQUOTE(JSON_EXTRACT(${this.getCollectionFieldColName(field, collectionName)}, '$'))`), {
|
|
77
83
|
[import_database.Op.like]: `%${(0, import_utils.escapeLike)(keyword)}%`
|
|
78
84
|
})
|
|
79
85
|
]
|
|
@@ -81,7 +87,7 @@ class FieldMariadb extends import_FieldBase.FieldBase {
|
|
|
81
87
|
}
|
|
82
88
|
getMultiSelectFilter(field, matchEnum) {
|
|
83
89
|
return {
|
|
84
|
-
[import_database.Op.and]: [(0, import_database.literal)(`JSON_CONTAINS(${
|
|
90
|
+
[import_database.Op.and]: [(0, import_database.literal)(`JSON_CONTAINS(${this.getCollectionFieldColName(field)}, '${JSON.stringify(matchEnum)}')`)]
|
|
85
91
|
};
|
|
86
92
|
}
|
|
87
93
|
}
|
|
@@ -54,7 +54,7 @@ class FieldPostgres extends import_FieldBase.FieldBase {
|
|
|
54
54
|
"TIMEZONE",
|
|
55
55
|
timezone,
|
|
56
56
|
// 参数1:目标时区
|
|
57
|
-
(0, import_database.fn)("TIMEZONE", "UTC", (
|
|
57
|
+
(0, import_database.fn)("TIMEZONE", "UTC", this.getCollectionField(field, collectionName))
|
|
58
58
|
// 参数2:UTC 转换后的字段
|
|
59
59
|
),
|
|
60
60
|
dateStr
|
|
@@ -83,7 +83,7 @@ class FieldPostgres extends import_FieldBase.FieldBase {
|
|
|
83
83
|
return {
|
|
84
84
|
[import_database.Op.and]: [
|
|
85
85
|
(0, import_database.where)(
|
|
86
|
-
(0, import_sequelize.literal)(`CAST(
|
|
86
|
+
(0, import_sequelize.literal)(`CAST(${this.getCollectionFieldColName(field, collectionName)} AS TEXT)`),
|
|
87
87
|
// 确保不加引号,直接插入 SQL 表达式
|
|
88
88
|
{
|
|
89
89
|
[import_database.Op.like]: `%${(0, import_utils.escapeLike)(keyword)}%`
|
|
@@ -21,7 +21,6 @@ __export(FieldSqlite_exports, {
|
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(FieldSqlite_exports);
|
|
23
23
|
var import_database = require("@tachybase/database");
|
|
24
|
-
var import_sequelize = require("sequelize");
|
|
25
24
|
var import_utils = require("../utils");
|
|
26
25
|
var import_FieldBase = require("./FieldBase");
|
|
27
26
|
class FieldSqlite extends import_FieldBase.FieldBase {
|
|
@@ -46,20 +45,27 @@ class FieldSqlite extends import_FieldBase.FieldBase {
|
|
|
46
45
|
return formatStr;
|
|
47
46
|
}
|
|
48
47
|
date(params) {
|
|
49
|
-
const { field, keyword, dateStr, timezone } = params;
|
|
48
|
+
const { field, keyword, dateStr, timezone, collectionName } = params;
|
|
50
49
|
return {
|
|
51
50
|
[import_database.Op.and]: [
|
|
52
|
-
(0, import_database.where)(
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
(0, import_database.where)(
|
|
52
|
+
(0, import_database.fn)(
|
|
53
|
+
"strftime",
|
|
54
|
+
dateStr,
|
|
55
|
+
(0, import_database.fn)("datetime", this.getCollectionField(field, collectionName), (0, import_utils.convertTimezoneOffset)(timezone))
|
|
56
|
+
),
|
|
57
|
+
{
|
|
58
|
+
[this.like]: `%${(0, import_utils.escapeLike)(keyword)}%`
|
|
59
|
+
}
|
|
60
|
+
)
|
|
55
61
|
]
|
|
56
62
|
};
|
|
57
63
|
}
|
|
58
64
|
json(params) {
|
|
59
|
-
const { field, keyword } = params;
|
|
65
|
+
const { field, keyword, collectionName } = params;
|
|
60
66
|
return {
|
|
61
67
|
[import_database.Op.and]: [
|
|
62
|
-
(0, import_database.where)((0, import_database.literal)(`json_extract(${field}, '$')`), {
|
|
68
|
+
(0, import_database.where)((0, import_database.literal)(`json_extract(${this.getCollectionFieldColName(field, collectionName)}, '$')`), {
|
|
63
69
|
[this.like]: `%${(0, import_utils.escapeLike)(keyword)}%`
|
|
64
70
|
})
|
|
65
71
|
]
|
|
@@ -72,7 +78,7 @@ class FieldSqlite extends import_FieldBase.FieldBase {
|
|
|
72
78
|
(0, import_database.literal)(`
|
|
73
79
|
EXISTS (
|
|
74
80
|
SELECT 1
|
|
75
|
-
FROM json_each(${
|
|
81
|
+
FROM json_each(${this.getCollectionFieldColName(field)})
|
|
76
82
|
WHERE json_each.value IN (${matchList})
|
|
77
83
|
)
|
|
78
84
|
`)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/plugin-full-text-search",
|
|
3
3
|
"displayName": "Full-text Search",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.10",
|
|
5
5
|
"description": "Provides full text search capability",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"System management"
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
"sequelize": "^6.37.5"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@tachybase/actions": "1.3.
|
|
18
|
-
"@tachybase/client": "1.3.
|
|
19
|
-
"@tachybase/database": "1.3.
|
|
20
|
-
"@tachybase/test": "1.3.
|
|
21
|
-
"@tachybase/server": "1.3.
|
|
17
|
+
"@tachybase/actions": "1.3.10",
|
|
18
|
+
"@tachybase/client": "1.3.10",
|
|
19
|
+
"@tachybase/database": "1.3.10",
|
|
20
|
+
"@tachybase/test": "1.3.10",
|
|
21
|
+
"@tachybase/server": "1.3.10"
|
|
22
22
|
},
|
|
23
23
|
"description.zh-CN": "提供全字段搜索能力",
|
|
24
24
|
"displayName.zh-CN": "全文搜索"
|