@autofleet/sadot 0.5.2 → 0.5.3

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.
@@ -4,7 +4,8 @@ exports.scopeName = exports.customFieldsFilterScope = 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 constants_1 = require("../utils/constants");
7
+ const common_types_1 = require("@autofleet/common-types");
8
+ const { CUSTOM_FIELDS_FILTER_SCOPE } = common_types_1.customFields;
8
9
  /**
9
10
  * A Sequelize scope for filtering models by custom fields.
10
11
  * This scope builds a WHERE clause to be applied on the main query.
@@ -51,4 +52,4 @@ const customFieldsFilterScope = (name) => (conditions) => {
51
52
  };
52
53
  };
53
54
  exports.customFieldsFilterScope = customFieldsFilterScope;
54
- exports.scopeName = constants_1.CUSTOM_FIELDS_FILTER_SCOPE;
55
+ exports.scopeName = CUSTOM_FIELDS_FILTER_SCOPE;
@@ -1,2 +1,5 @@
1
+ declare const CUSTOM_FIELDS_FILTER_SCOPE: string;
1
2
  export declare const supportedEntities: string[];
2
- export declare const CUSTOM_FIELDS_FILTER_SCOPE = "filterByCustomFields";
3
+ export {
4
+ /** @deprecated Use the value from `@autofleet/common-types` instead */
5
+ CUSTOM_FIELDS_FILTER_SCOPE, };
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CUSTOM_FIELDS_FILTER_SCOPE = exports.supportedEntities = void 0;
4
+ const common_types_1 = require("@autofleet/common-types");
5
+ const { CUSTOM_FIELDS_FILTER_SCOPE } = common_types_1.customFields;
6
+ exports.CUSTOM_FIELDS_FILTER_SCOPE = CUSTOM_FIELDS_FILTER_SCOPE;
4
7
  // eslint-disable-next-line import/prefer-default-export
5
8
  exports.supportedEntities = ['businessModelId', 'fleetId', 'demandSourceId'];
6
- exports.CUSTOM_FIELDS_FILTER_SCOPE = 'filterByCustomFields';
@@ -5,11 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.addScopes = exports.removeHooks = exports.addHooks = void 0;
7
7
  const sequelize_1 = require("sequelize");
8
+ const common_types_1 = require("@autofleet/common-types");
8
9
  const models_1 = require("../models");
9
10
  const hooks_1 = require("../hooks");
10
11
  const scopes_1 = require("../scopes");
11
12
  const logger_1 = __importDefault(require("./logger"));
12
- const constants_1 = require("./constants");
13
+ const { CUSTOM_FIELDS_FILTER_SCOPE } = common_types_1.customFields;
13
14
  const addHooks = (models, getModel) => {
14
15
  models.forEach(async ({ name, scopeAttributes }) => {
15
16
  try {
@@ -89,7 +90,7 @@ const addScopes = (models, getModel) => {
89
90
  // Necessary associations for the filtering scope
90
91
  addAssociations(model, name);
91
92
  // Add filter scope
92
- model.addScope(constants_1.CUSTOM_FIELDS_FILTER_SCOPE, (0, scopes_1.customFieldsFilterScope)(name));
93
+ model.addScope(CUSTOM_FIELDS_FILTER_SCOPE, (0, scopes_1.customFieldsFilterScope)(name));
93
94
  }
94
95
  catch (e) {
95
96
  logger_1.default.error(`Could not add custom fields scopes to model ${name}. `, e);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/sadot",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -12,6 +12,7 @@
12
12
  "dev": "nodemon"
13
13
  },
14
14
  "dependencies": {
15
+ "@autofleet/common-types": "^1.7.29",
15
16
  "@autofleet/errors": "^1.0.10",
16
17
  "@autofleet/events": "^2.0.0",
17
18
  "@autofleet/logger": "^2.0.5",
@@ -1,7 +1,9 @@
1
1
  /* eslint-disable import/prefer-default-export */
2
2
  import { Op, WhereOptions } from 'sequelize';
3
3
  import { Sequelize } from 'sequelize-typescript';
4
- import { CUSTOM_FIELDS_FILTER_SCOPE } from '../utils/constants';
4
+ import { customFields } from '@autofleet/common-types';
5
+
6
+ const { CUSTOM_FIELDS_FILTER_SCOPE } = customFields;
5
7
 
6
8
  /**
7
9
  * Type representing possible condition values.
@@ -1,4 +1,11 @@
1
+ import { customFields } from '@autofleet/common-types';
2
+
3
+ const { CUSTOM_FIELDS_FILTER_SCOPE } = customFields;
4
+
1
5
  // eslint-disable-next-line import/prefer-default-export
2
6
  export const supportedEntities = ['businessModelId', 'fleetId', 'demandSourceId'];
3
7
 
4
- export const CUSTOM_FIELDS_FILTER_SCOPE = 'filterByCustomFields';
8
+ export {
9
+ /** @deprecated Use the value from `@autofleet/common-types` instead */
10
+ CUSTOM_FIELDS_FILTER_SCOPE,
11
+ };
package/src/utils/init.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { DataTypes } from 'sequelize';
2
2
  import { ModelCtor } from 'sequelize-typescript';
3
+ import { customFields } from '@autofleet/common-types';
3
4
  import {
4
5
  CustomFieldValue,
5
6
  } from '../models';
@@ -14,7 +15,8 @@ import {
14
15
  import { customFieldsFilterScope } from '../scopes';
15
16
  import logger from './logger';
16
17
  import type { ModelFetcher, ModelOptions } from '../types';
17
- import { CUSTOM_FIELDS_FILTER_SCOPE } from './constants';
18
+
19
+ const { CUSTOM_FIELDS_FILTER_SCOPE } = customFields;
18
20
 
19
21
  export const addHooks = (models: ModelOptions[], getModel: ModelFetcher): void => {
20
22
  models.forEach(async ({ name, scopeAttributes }) => {