@tachybase/plugin-full-text-search 0.23.48 → 1.0.6

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.
@@ -1,9 +1,9 @@
1
1
  module.exports = {
2
- "@tachybase/client": "0.23.48",
2
+ "@tachybase/client": "1.0.6",
3
3
  "antd": "5.22.5",
4
4
  "lodash": "4.17.21",
5
- "@tachybase/server": "0.23.48",
6
- "@tachybase/database": "0.23.48",
7
- "@tachybase/actions": "0.23.48",
5
+ "@tachybase/server": "1.0.6",
6
+ "@tachybase/database": "1.0.6",
7
+ "@tachybase/actions": "1.0.6",
8
8
  "sequelize": "6.37.5"
9
9
  };
@@ -44,7 +44,7 @@ class FieldPostgres extends import_FieldBase.FieldBase {
44
44
  return formatStr;
45
45
  }
46
46
  date(params) {
47
- const { field, keyword, dateStr, timezone } = params;
47
+ const { field, keyword, dateStr, timezone, collectionName } = params;
48
48
  return {
49
49
  [import_database.Op.and]: [
50
50
  (0, import_database.where)(
@@ -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", (0, import_sequelize.col)(field))
57
+ (0, import_database.fn)("TIMEZONE", "UTC", (0, import_sequelize.col)(`"${collectionName}"."${field}"`))
58
58
  // 参数2:UTC 转换后的字段
59
59
  ),
60
60
  dateStr
@@ -76,14 +76,14 @@ class FieldPostgres extends import_FieldBase.FieldBase {
76
76
  });
77
77
  }
78
78
  number(params) {
79
- const { field, keyword } = params;
79
+ const { field, keyword, collectionName } = params;
80
80
  if (isNaN(Number(keyword))) {
81
81
  return null;
82
82
  }
83
83
  return {
84
84
  [import_database.Op.and]: [
85
85
  (0, import_database.where)(
86
- (0, import_sequelize.literal)(`CAST("${field}" AS TEXT)`),
86
+ (0, import_sequelize.literal)(`CAST("${collectionName}"."${field}" AS TEXT)`),
87
87
  // 确保不加引号,直接插入 SQL 表达式
88
88
  {
89
89
  [import_database.Op.like]: `%${(0, import_utils.escapeLike)(keyword)}%`
@@ -3,5 +3,6 @@ import { ProcessFieldParams } from './types';
3
3
  export declare function handleField(handler: FieldBase, func: Function, field: string, fields: Map<string, any>, keywords: string[], extraParams?: {
4
4
  timezone?: string;
5
5
  dateStr?: string;
6
+ collectionName?: string;
6
7
  }): any[];
7
8
  export declare function processField({ field, handler, collection, ctx, search, timezone }: ProcessFieldParams): any[];
@@ -22,8 +22,8 @@ __export(searchField_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(searchField_exports);
24
24
  const fieldTypes = {
25
- string: ["string", "text", "sequence", "uid", "integer", "float"],
26
- number: ["bigInt", "double"],
25
+ string: ["string", "text", "sequence", "uid"],
26
+ number: ["bigInt", "double", "integer", "float"],
27
27
  date: ["date", "datetime", "timestamp"],
28
28
  json: ["json", "jsonb"],
29
29
  array: ["array"]
@@ -57,7 +57,8 @@ function handleField(handler, func, field, fields, keywords, extraParams = {}) {
57
57
  fields,
58
58
  keyword,
59
59
  timezone: extraParams.timezone,
60
- dateStr: extraParams.dateStr
60
+ dateStr: extraParams.dateStr,
61
+ collectionName: extraParams.collectionName
61
62
  };
62
63
  const condition = func.call(handler, params);
63
64
  if (condition) {
@@ -85,14 +86,17 @@ function processField({ field, handler, collection, ctx, search, timezone }) {
85
86
  return handleField(handler, handler.string, field, fields, search.keywords);
86
87
  } else if (isFieldType(type, "number")) {
87
88
  if (!field.includes(".")) {
88
- return handleField(handler, handler.number, field, fields, search.keywords);
89
+ return handleField(handler, handler.number, field, fields, search.keywords, {
90
+ collectionName: collection.name
91
+ });
89
92
  }
90
93
  } else if (isFieldType(type, "date")) {
91
94
  if (!field.includes(".")) {
92
95
  const dateStr = handler.getFormateDateStr(field, fields);
93
96
  return handleField(handler, handler.date, field, fields, search.keywords, {
94
97
  timezone,
95
- dateStr
98
+ dateStr,
99
+ collectionName: collection.name
96
100
  });
97
101
  }
98
102
  } else if (isFieldType(type, "json")) {
@@ -16,6 +16,7 @@ export interface ProcessFieldParams {
16
16
  timezone: string;
17
17
  }
18
18
  export type handleFieldParams = {
19
+ collectionName?: string;
19
20
  field: string;
20
21
  keyword: string;
21
22
  fields: Map<string, any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tachybase/plugin-full-text-search",
3
- "version": "0.23.48",
3
+ "version": "1.0.6",
4
4
  "description": "Provides full text search capability",
5
5
  "main": "dist/server/index.js",
6
6
  "devDependencies": {
@@ -10,11 +10,11 @@
10
10
  "sequelize": "^6.37.5"
11
11
  },
12
12
  "peerDependencies": {
13
- "@tachybase/actions": "0.23.48",
14
- "@tachybase/client": "0.23.48",
15
- "@tachybase/database": "0.23.48",
16
- "@tachybase/server": "0.23.48",
17
- "@tachybase/test": "0.23.48"
13
+ "@tachybase/actions": "1.0.6",
14
+ "@tachybase/client": "1.0.6",
15
+ "@tachybase/database": "1.0.6",
16
+ "@tachybase/server": "1.0.6",
17
+ "@tachybase/test": "1.0.6"
18
18
  },
19
19
  "description.zh-CN": "提供全字段搜索能力",
20
20
  "displayName.zh-CN": "全文搜索"