@molochko-dev/data 1.4.30 → 1.4.32

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/enums.d.ts CHANGED
@@ -109,7 +109,8 @@ export declare enum ANIMAL_STATUS_ENUM {
109
109
  dnb = "dnb",
110
110
  sold = "sold",
111
111
  died = "died",
112
- theft = "theft"
112
+ theft = "theft",
113
+ transferout = "transferout"
113
114
  }
114
115
  export declare const ANIMAL_STATUS_AS_OBJECT: {
115
116
  [key: string]: string;
@@ -186,7 +187,7 @@ export declare const TRANSFEROUT_TYPES_AS_OBJECT: {
186
187
  export declare enum TRANSFEROUT_REASON_ENUM {
187
188
  leikoz = "leikoz",
188
189
  tuberkulez = "tuberkulez",
189
- klostirokoz = "klostirikoz",
190
+ klostirikoz = "klostirikoz",
190
191
  nekrobacilez = "nekrobacilez",
191
192
  aktinomikoz = "aktinomikoz",
192
193
  ginekologic = "ginekologic",
package/dist/enums.js CHANGED
@@ -105,7 +105,8 @@ var ANIMAL_STATUS_ENUM;
105
105
  ANIMAL_STATUS_ENUM["dnb"] = "dnb";
106
106
  ANIMAL_STATUS_ENUM["sold"] = "sold";
107
107
  ANIMAL_STATUS_ENUM["died"] = "died";
108
- ANIMAL_STATUS_ENUM["theft"] = "theft"; // Кража
108
+ ANIMAL_STATUS_ENUM["theft"] = "theft";
109
+ ANIMAL_STATUS_ENUM["transferout"] = "transferout"; // выбыла
109
110
  })(ANIMAL_STATUS_ENUM = exports.ANIMAL_STATUS_ENUM || (exports.ANIMAL_STATUS_ENUM = {}));
110
111
  exports.ANIMAL_STATUS_AS_OBJECT = (0, helpers_1.enumToObject)(ANIMAL_STATUS_ENUM);
111
112
  // heifer, bred, open, fresh
@@ -175,7 +176,7 @@ var TRANSFEROUT_REASON_ENUM;
175
176
  (function (TRANSFEROUT_REASON_ENUM) {
176
177
  TRANSFEROUT_REASON_ENUM["leikoz"] = "leikoz";
177
178
  TRANSFEROUT_REASON_ENUM["tuberkulez"] = "tuberkulez";
178
- TRANSFEROUT_REASON_ENUM["klostirokoz"] = "klostirikoz";
179
+ TRANSFEROUT_REASON_ENUM["klostirikoz"] = "klostirikoz";
179
180
  TRANSFEROUT_REASON_ENUM["nekrobacilez"] = "nekrobacilez";
180
181
  TRANSFEROUT_REASON_ENUM["aktinomikoz"] = "aktinomikoz";
181
182
  TRANSFEROUT_REASON_ENUM["ginekologic"] = "ginekologic";
@@ -1,3 +1,3 @@
1
- import { IAnimal } from '../types';
1
+ import { IAbstractAnimal } from '../types';
2
2
  import { EVENT_TYPES_ENUM } from '../enums';
3
- export declare function filter(animals: IAnimal[], eventType: EVENT_TYPES_ENUM): IAnimal[];
3
+ export declare function filter<T extends IAbstractAnimal>(animals: T[], eventType: EVENT_TYPES_ENUM): T[];
@@ -10,9 +10,6 @@ const defaultCowAge = 12;
10
10
  const filtered = filter(animals, eventType)
11
11
 
12
12
  */
13
- function genderFilter(animal, availableGender) {
14
- return animal.gender === availableGender;
15
- }
16
13
  function ageFilter(animal, availableMinAge /*month*/) {
17
14
  const months = (0, date_1.getMonthFromDate)(animal.dob.toISOString());
18
15
  return months > availableMinAge;
@@ -20,6 +17,9 @@ function ageFilter(animal, availableMinAge /*month*/) {
20
17
  function statusFilter(animal, availableStatuses) {
21
18
  return availableStatuses.includes(animal.status);
22
19
  }
20
+ function genderFilter(animal, availableGender) {
21
+ return animal.gender === availableGender;
22
+ }
23
23
  function abortFilter(animals) {
24
24
  const result = animals.filter(animal => genderFilter(animal, enums_1.ANIMAL_GENDER_ENUM.cow));
25
25
  return result;
@@ -61,7 +61,6 @@ function recheckFilter(animals) {
61
61
  const statusOk = statusFilter(animal, availableStatus);
62
62
  return genderOk && statusOk && ageOk && animal;
63
63
  });
64
- console.info('result', result);
65
64
  return result;
66
65
  }
67
66
  function suhostoiFilter(animals) {
package/dist/types.d.ts CHANGED
@@ -43,3 +43,10 @@ export interface IAnimalEventRelation {
43
43
  export interface IEventDetail {
44
44
  type: EVENT_TYPES_ENUM;
45
45
  }
46
+ export declare type IAbstractAnimal = {
47
+ id: string;
48
+ dob: Date;
49
+ gender: ANIMAL_GENDER_ENUM;
50
+ status: ANIMAL_STATUS_ENUM;
51
+ animalEventRelation?: IAnimalEventRelation[];
52
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molochko-dev/data",
3
- "version": "1.4.30",
3
+ "version": "1.4.32",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "typings/index.d.ts",
@@ -11,7 +11,7 @@
11
11
  "build": "rm -rf dist/ && tsc",
12
12
  "test": "jest --config=jest.config.js",
13
13
  "format": "prettier --write \"src/**/*.ts\"",
14
- "pub": "npm run build && npm publish"
14
+ "pub": "npm tes && npm run build && npm publish"
15
15
  },
16
16
  "keywords": [
17
17
  "molochko-data"
package/src/enums.ts CHANGED
@@ -113,7 +113,8 @@ export enum ANIMAL_STATUS_ENUM {
113
113
  dnb = 'dnb', // Брак
114
114
  sold = 'sold', // Продана
115
115
  died = 'died', // Сдохла
116
- theft = 'theft' // Кража
116
+ theft = 'theft', // Кража
117
+ transferout = 'transferout' // выбыла
117
118
  }
118
119
 
119
120
  export const ANIMAL_STATUS_AS_OBJECT = enumToObject(ANIMAL_STATUS_ENUM);
@@ -191,7 +192,7 @@ export const TRANSFEROUT_TYPES_AS_OBJECT = enumToObject(TRANSFEROUT_TYPES_ENUM);
191
192
  export enum TRANSFEROUT_REASON_ENUM {
192
193
  leikoz = 'leikoz', // Лейкоз
193
194
  tuberkulez = 'tuberkulez', // Туберкулез
194
- klostirokoz = 'klostirikoz', // Клостридиоз
195
+ klostirikoz = 'klostirikoz', // Клостридиоз
195
196
  nekrobacilez = 'nekrobacilez', // Некробациллез
196
197
  aktinomikoz = 'aktinomikoz', // Актиномикоз)
197
198
  ginekologic = 'ginekologic', // Гинекологические заболевания
@@ -1,4 +1,4 @@
1
- import { IAnimal } from '../types';
1
+ import { IAbstractAnimal, IAnimal } from '../types';
2
2
  import { ANIMAL_GENDER_ENUM, ANIMAL_STATUS_ENUM, EVENT_TYPES_ENUM } from '../enums';
3
3
  import { getMonthFromDate } from '../helpers/date';
4
4
 
@@ -12,30 +12,30 @@ const filtered = filter(animals, eventType)
12
12
 
13
13
  */
14
14
 
15
- function genderFilter (animal: IAnimal, availableGender: ANIMAL_GENDER_ENUM): Boolean {
16
- return animal.gender === availableGender
17
- }
18
-
19
- function ageFilter (animal: IAnimal, availableMinAge: number /*month*/): Boolean {
15
+ function ageFilter<T extends IAbstractAnimal> (animal: T, availableMinAge: number /*month*/): Boolean {
20
16
  const months = getMonthFromDate(animal.dob.toISOString())
21
17
  return months > availableMinAge
22
18
  }
23
19
 
24
- function statusFilter (animal: IAnimal, availableStatuses: ANIMAL_STATUS_ENUM[]): Boolean {
20
+ function statusFilter<T extends IAbstractAnimal> (animal: T, availableStatuses: ANIMAL_STATUS_ENUM[]): Boolean {
25
21
  return availableStatuses.includes(animal.status)
26
22
  }
27
23
 
28
- function abortFilter (animals: IAnimal[]): IAnimal[] {
29
- const result: IAnimal[] = animals.filter(animal => genderFilter(animal, ANIMAL_GENDER_ENUM.cow))
24
+ function genderFilter<T extends IAbstractAnimal> (animal: T, availableGender: ANIMAL_GENDER_ENUM): Boolean {
25
+ return animal.gender === availableGender
26
+ }
27
+
28
+ function abortFilter<T extends IAbstractAnimal> (animals: T[]): T[] {
29
+ const result: T[] = animals.filter(animal => genderFilter<T>(animal, ANIMAL_GENDER_ENUM.cow))
30
30
  return result
31
31
  }
32
32
 
33
- function neosemFilter (animals: IAnimal[]): IAnimal[] {
33
+ function neosemFilter<T extends IAbstractAnimal> (animals: T[]): T[] {
34
34
  return abortFilter(animals)
35
35
  }
36
36
 
37
- function osemenenieFilter(animals: IAnimal[]): IAnimal[] {
38
- const result: IAnimal[] = animals.filter(animal => {
37
+ function osemenenieFilter<T extends IAbstractAnimal>(animals: T[]): T[] {
38
+ const result = animals.filter(animal => {
39
39
  const genderOk = genderFilter(animal, ANIMAL_GENDER_ENUM.cow)
40
40
  const statusOk = statusFilter(animal, [status.heifer, status.bred, status.open, status.fresh])
41
41
  const ageOk = ageFilter(animal, defaultCowAge)
@@ -46,8 +46,8 @@ function osemenenieFilter(animals: IAnimal[]): IAnimal[] {
46
46
  return result
47
47
  }
48
48
 
49
- function otelFilter (animals: IAnimal[]): IAnimal[] {
50
- const result: IAnimal[] = animals.filter(animal => {
49
+ function otelFilter<T extends IAbstractAnimal> (animals: T[]): T[] {
50
+ const result = animals.filter(animal => {
51
51
  const genderOk = genderFilter(animal, ANIMAL_GENDER_ENUM.cow)
52
52
  const statusOk = statusFilter(animal, [status.dry, status.pregnant])
53
53
  const ageOk = ageFilter(animal, defaultCowAge)
@@ -57,8 +57,8 @@ function otelFilter (animals: IAnimal[]): IAnimal[] {
57
57
  return result
58
58
  }
59
59
 
60
- function recheckFilter (animals: IAnimal[]): IAnimal[] {
61
- const result: IAnimal[] = animals.filter(animal => {
60
+ function recheckFilter<T extends IAbstractAnimal> (animals: T[]): T[] {
61
+ const result = animals.filter(animal => {
62
62
  const genderOk = genderFilter(animal, ANIMAL_GENDER_ENUM.cow)
63
63
  const ageOk = ageFilter(animal, defaultCowAge)
64
64
 
@@ -75,16 +75,15 @@ function recheckFilter (animals: IAnimal[]): IAnimal[] {
75
75
 
76
76
  return genderOk && statusOk && ageOk && animal
77
77
  })
78
- console.info('result', result)
79
78
  return result
80
79
  }
81
80
 
82
- function suhostoiFilter (animals: IAnimal[]): IAnimal[] {
81
+ function suhostoiFilter<T extends IAbstractAnimal> (animals: T[]): T[] {
83
82
  return abortFilter(animals)
84
83
  }
85
84
 
86
- function pozSuhostoiFilter (animals: IAnimal[]): IAnimal[] {
87
- const result: IAnimal[] = animals.filter(animal => {
85
+ function pozSuhostoiFilter<T extends IAbstractAnimal> (animals: T[]): T[] {
86
+ const result = animals.filter(animal => {
88
87
  const genderOk = genderFilter(animal, ANIMAL_GENDER_ENUM.cow)
89
88
  const statusOk = statusFilter(animal, [status.dry])
90
89
  const ageOk = ageFilter(animal, defaultCowAge)
@@ -94,20 +93,20 @@ function pozSuhostoiFilter (animals: IAnimal[]): IAnimal[] {
94
93
  return result
95
94
  }
96
95
 
97
- function transferOutFilter (animals: IAnimal[]): IAnimal[] {
96
+ function transferOutFilter<T extends IAbstractAnimal> (animals: T[]): T[] {
98
97
  return animals
99
98
  }
100
99
 
101
- function perevodFilter (animals: IAnimal[]) {
100
+ function perevodFilter<T extends IAbstractAnimal> (animals: T[]) {
102
101
  return animals
103
102
  }
104
103
 
105
- interface IFilters {
106
- [key: string]: (animals: IAnimal[]) => IAnimal[]
104
+ interface IFilters<T extends IAbstractAnimal> {
105
+ [key: string]: (animals: T[]) => T[]
107
106
  }
108
107
 
109
- export function filter (animals: IAnimal[], eventType: EVENT_TYPES_ENUM) {
110
- const filters: IFilters = {
108
+ export function filter<T extends IAbstractAnimal>(animals: T[], eventType: EVENT_TYPES_ENUM) {
109
+ const filters: IFilters<T> = {
111
110
  [EVENT_TYPES_ENUM.abort]: abortFilter,
112
111
  [EVENT_TYPES_ENUM.neosem]: neosemFilter,
113
112
  [EVENT_TYPES_ENUM.osemenenie]: osemenenieFilter,
package/src/types.ts CHANGED
@@ -54,3 +54,11 @@ export interface IEventDetail {
54
54
  type: EVENT_TYPES_ENUM
55
55
  }
56
56
 
57
+ export type IAbstractAnimal = {
58
+ id: string
59
+ dob: Date
60
+ gender: ANIMAL_GENDER_ENUM
61
+ status: ANIMAL_STATUS_ENUM
62
+ animalEventRelation?: IAnimalEventRelation[]
63
+ }
64
+