semanticdb-core 1.1.43 → 1.1.44

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.
@@ -38,6 +38,7 @@ const stringifyJson = (value) => {
38
38
  const stringified = JSON.stringify(value);
39
39
  return stringified === undefined ? String(value) : stringified;
40
40
  };
41
+ const formatExplainKey = (key) => key.split('_').join('.');
41
42
  const isCompareOperatorObject = (value) => {
42
43
  if (!value || typeof value !== 'object' || Array.isArray(value)) {
43
44
  return false;
@@ -182,7 +183,7 @@ const explainFilterLikeQuery = (query, prefix = '筛选', includeValue = false,
182
183
  const values = Object.entries(query)
183
184
  .filter(([k]) => includeValue || k !== 'entity_id')
184
185
  .map(([k, v]) => {
185
- const key = k.split('_').pop() || '';
186
+ const key = formatExplainKey(k);
186
187
  if (includeValue) {
187
188
  if (k === 'entity_id') {
188
189
  return `ID为${stringifyJson(v)}`;
@@ -1,6 +1,6 @@
1
1
  import { LogicformType } from '../logicform';
2
2
  import { DateValue } from './date';
3
- export declare type CompareOperator = '$eq' | '$gt' | '$gte' | '$lt' | '$lte' | '$ne' | '$in' | '$nin' | '$exists' | '$regex' | '$options' | '$and' | '$or';
3
+ export declare type CompareOperator = '$eq' | '$gt' | '$gte' | '$lt' | '$lte' | '$ne' | '$in' | '$nin' | '$exists' | '$regex' | '$contains' | '$options' | '$and' | '$or';
4
4
  export declare type QueryValueType = null | string | number | boolean | DateValue | LogicformType | string[] | number[] | boolean[] | DateValue[] | LogicformType[];
5
5
  export declare type QueryValueTypeWithCompareOperator = Partial<{
6
6
  [K in CompareOperator]: QueryValueType;
@@ -239,6 +239,27 @@ const formatWithNumeralSafely = (value, format) => {
239
239
  const formattedValue = (0, numeral_1.default)(value).format(format);
240
240
  return formattedValue === 'NaN' ? `${value}` : formattedValue;
241
241
  };
242
+ const formatObjectValue = (schema, value) => {
243
+ var _a, _b;
244
+ const nameProperty = getNameProperty(schema);
245
+ if (Array.isArray(value)) {
246
+ return value
247
+ .map((item) => {
248
+ var _a, _b;
249
+ if (item === null || item === undefined)
250
+ return '';
251
+ if (typeof item !== 'object')
252
+ return `${item}`;
253
+ return (_b = (_a = item[nameProperty.name]) !== null && _a !== void 0 ? _a : item._id) !== null && _b !== void 0 ? _b : JSON.stringify(item);
254
+ })
255
+ .filter((item) => item !== '')
256
+ .join('、');
257
+ }
258
+ if (value && typeof value === 'object') {
259
+ return (_b = (_a = value[nameProperty.name]) !== null && _a !== void 0 ? _a : value._id) !== null && _b !== void 0 ? _b : JSON.stringify(value);
260
+ }
261
+ return `${value}`;
262
+ };
242
263
  /**
243
264
  *
244
265
  * @param schema
@@ -256,8 +277,7 @@ const formatWithProperty = (schema, property, value, withUnit = false) => {
256
277
  const formatter = (0, exports.getFormatter)(property);
257
278
  let finalValue = `${value}`;
258
279
  if (property.type === 'object' && typeof value === 'object') {
259
- const nameProperty = getNameProperty(schema);
260
- finalValue = value[nameProperty.name];
280
+ finalValue = formatObjectValue(schema, value);
261
281
  }
262
282
  else if (property.primal_type === 'date') {
263
283
  if (formatter) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "semanticdb-core",
3
- "version": "1.1.43",
3
+ "version": "1.1.44",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [