@autofleet/sadot 0.5.5-beta.19 → 0.5.5-beta.20

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,5 +1,6 @@
1
- import { WhereOptions, BindOrReplacements, DataType as SequelizeDataTypes } from 'sequelize';
1
+ import { WhereOptions, BindOrReplacements } from 'sequelize';
2
2
  import { ModelStatic } from 'sequelize-typescript';
3
+ import { CustomFieldDefinitionType } from '../validations/type';
3
4
  /**
4
5
  * Builds a WHERE clause and replacements for free-text search by custom fields.
5
6
  *
@@ -18,5 +19,5 @@ interface CustomFieldsSearchPayload {
18
19
  where: WhereOptions;
19
20
  replacements: BindOrReplacements;
20
21
  }
21
- export declare const generateCustomFieldSearchQueryPayload: (searchTerm: string, model: ModelStatic, entityId: string, excludedCustomFieldsTypes?: SequelizeDataTypes[]) => CustomFieldsSearchPayload;
22
+ export declare const generateCustomFieldSearchQueryPayload: (searchTerm: string, model: ModelStatic, entityId: string, excludedCustomFieldsTypes?: CustomFieldDefinitionType[]) => CustomFieldsSearchPayload;
22
23
  export {};
@@ -4,15 +4,16 @@ exports.generateCustomFieldSearchQueryPayload = void 0;
4
4
  /* eslint-disable import/prefer-default-export */
5
5
  const sequelize_1 = require("sequelize");
6
6
  const sequelize_typescript_1 = require("sequelize-typescript");
7
- const generateCustomFieldSearchQueryPayload = (searchTerm, model, entityId, excludedCustomFieldsTypes = [sequelize_typescript_1.DataType.DATE]) => {
7
+ const type_1 = require("../validations/type");
8
+ const generateCustomFieldSearchQueryPayload = (searchTerm, model, entityId, excludedCustomFieldsTypes = [type_1.CustomFieldDefinitionType.DATETIME]) => {
8
9
  const subQuery = 'EXISTS ('
9
10
  + ' SELECT 1'
10
11
  + ' FROM "custom_field_values" AS "cv"'
11
12
  + ' INNER JOIN custom_field_definitions AS cd '
12
13
  + ` ON cd.entity_id = '${entityId}'`
13
- + ' AND cv.custom_field_definition_id = cd.id '
14
- + ` AND cd.model_type = '${model.name}' `
15
- + ' AND cd.field_type NOT IN (\'datetime\')'
14
+ + ' AND cv.custom_field_definition_id = cd.id'
15
+ + ` AND cd.model_type = '${model.name}'`
16
+ + ` AND cd.field_type NOT IN (${excludedCustomFieldsTypes})`
16
17
  + ' WHERE'
17
18
  + ' "cv"."deleted_at" IS NULL'
18
19
  + ` AND "cv"."model_id" = "${model.name}"."id"`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/sadot",
3
- "version": "0.5.5-beta.19",
3
+ "version": "0.5.5-beta.20",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -1,8 +1,7 @@
1
1
  /* eslint-disable import/prefer-default-export */
2
- import {
3
- WhereOptions, Op, BindOrReplacements, DataType as SequelizeDataTypes,
4
- } from 'sequelize';
5
- import { DataType, ModelStatic, Sequelize } from 'sequelize-typescript';
2
+ import { WhereOptions, Op, BindOrReplacements } from 'sequelize';
3
+ import { ModelStatic, Sequelize } from 'sequelize-typescript';
4
+ import { CustomFieldDefinitionType } from '../validations/type';
6
5
 
7
6
  /**
8
7
  * Builds a WHERE clause and replacements for free-text search by custom fields.
@@ -28,16 +27,16 @@ export const generateCustomFieldSearchQueryPayload = (
28
27
  searchTerm: string,
29
28
  model: ModelStatic,
30
29
  entityId : string,
31
- excludedCustomFieldsTypes : SequelizeDataTypes[] = [DataType.DATE],
30
+ excludedCustomFieldsTypes : CustomFieldDefinitionType[] = [CustomFieldDefinitionType.DATETIME],
32
31
  ): CustomFieldsSearchPayload => {
33
32
  const subQuery = 'EXISTS ('
34
33
  + ' SELECT 1'
35
34
  + ' FROM "custom_field_values" AS "cv"'
36
35
  + ' INNER JOIN custom_field_definitions AS cd '
37
36
  + ` ON cd.entity_id = '${entityId}'`
38
- + ' AND cv.custom_field_definition_id = cd.id '
39
- + ` AND cd.model_type = '${model.name}' `
40
- + ' AND cd.field_type NOT IN (\'datetime\')'
37
+ + ' AND cv.custom_field_definition_id = cd.id'
38
+ + ` AND cd.model_type = '${model.name}'`
39
+ + ` AND cd.field_type NOT IN (${excludedCustomFieldsTypes})`
41
40
  + ' WHERE'
42
41
  + ' "cv"."deleted_at" IS NULL'
43
42
  + ` AND "cv"."model_id" = "${model.name}"."id"`