@molochko-dev/data 1.4.112 → 1.4.122
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/CLAUDE.md +427 -0
- package/dist/easy-query/enums.js +10 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/notification/enums.d.ts +10 -0
- package/dist/notification/enums.js +15 -0
- package/dist/notification/index.d.ts +2 -0
- package/dist/notification/index.js +28 -0
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
- package/src/easy-query/enums.ts +11 -2
- package/src/easy-query/models.ts +16 -16
- package/src/event/animal-event-filter.ts +1 -1
- package/src/index.ts +2 -0
- package/src/milk/enums.ts +1 -1
- package/src/milk/index.ts +1 -1
- package/src/notification/enums.ts +11 -0
- package/src/notification/index.ts +3 -0
- package/src/org/const.ts +17 -18
- package/src/types.ts +1 -1
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
## 1. Project Overview
|
|
2
|
+
|
|
3
|
+
Shared package `@molochko-dev/data` (v1.4.112) — provides enums, types, constants, and utility functions used by both **molochko-crm** (backend, Node.js) and **molochko-front** (frontend, Angular).
|
|
4
|
+
|
|
5
|
+
Published to npm: `https://registry.npmjs.org/@molochko-dev/data`
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 2. Tech Stack
|
|
10
|
+
|
|
11
|
+
| Component | Technology |
|
|
12
|
+
|-----------|-----------|
|
|
13
|
+
| **Language** | TypeScript 4.8 |
|
|
14
|
+
| **Output** | CommonJS (`dist/`) with `.d.ts` declarations |
|
|
15
|
+
| **Testing** | Jest + ts-jest |
|
|
16
|
+
| **Linting** | ESLint + Prettier |
|
|
17
|
+
| **Runtime deps** | `moment` (date helpers) |
|
|
18
|
+
|
|
19
|
+
### 2.1 Code Style
|
|
20
|
+
- **Semicolons**: yes
|
|
21
|
+
- **Single quotes**: yes
|
|
22
|
+
- **Print width**: 100
|
|
23
|
+
- **Trailing commas**: ES5
|
|
24
|
+
- **Arrow parens**: avoid (`x => x`, not `(x) => x`)
|
|
25
|
+
|
|
26
|
+
### 2.2 Commands
|
|
27
|
+
```bash
|
|
28
|
+
npm run build # rm -rf dist/ && tsc (compile to dist/)
|
|
29
|
+
npm test # jest
|
|
30
|
+
npm run lint:fix # eslint auto-fix
|
|
31
|
+
npm run pub # lint:fix → test → patch-version → build → npm publish
|
|
32
|
+
npm run patch-version # npm version patch --no-git-tag-version
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 3. Project Structure
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
molochko-data/
|
|
41
|
+
├── package.json
|
|
42
|
+
├── tsconfig.json
|
|
43
|
+
├── jest.config.js
|
|
44
|
+
├── typings/
|
|
45
|
+
│ └── index.d.ts # Ambient declaration: declare module '@molochko-dev/data'
|
|
46
|
+
├── src/
|
|
47
|
+
│ ├── index.ts # Main barrel export (namespaced)
|
|
48
|
+
│ ├── enums.ts # Root enums (TOKEN_TYPE, SEED_*, USER_*, etc. + DEPRECATED duplicates)
|
|
49
|
+
│ ├── types.ts # Core interfaces (IAnimal, IRolePermissionItem, etc.)
|
|
50
|
+
│ ├── helpers.ts # asObject(), enumToObject()
|
|
51
|
+
│ ├── breed.ts # BREED array (~120 cattle breeds) + BREED_AS_OBJECT
|
|
52
|
+
│ ├── role-permissions.ts # ROOT_PERMISSIONS, USER_PERMISSIONS (RBAC config)
|
|
53
|
+
│ ├── helpers/
|
|
54
|
+
│ │ └── date.ts # getMonthFromDate(), datestrToDate()
|
|
55
|
+
│ ├── animals/
|
|
56
|
+
│ │ ├── enums.ts # ANIMAL_GENDER_ENUM, ANIMAL_STATUS_ENUM, BULL_STATUS_ENUM, COW_STATUS_ENUM
|
|
57
|
+
│ │ └── index.ts
|
|
58
|
+
│ ├── animal-tag/
|
|
59
|
+
│ │ ├── enums.ts # TAG_TYPE_ENUM
|
|
60
|
+
│ │ └── index.ts
|
|
61
|
+
│ ├── custom-list/
|
|
62
|
+
│ │ ├── enums.ts # CLIST_* enums (operators, types, conditions, datasources, etc.)
|
|
63
|
+
│ │ └── index.ts
|
|
64
|
+
│ ├── easy-query/
|
|
65
|
+
│ │ ├── enums.ts # EQ_PROFILE, EQ_STATUS_ENUM, EQ_CATEGORY_TYPE_ENUM, EQ_FORBIDDEN_WORDS
|
|
66
|
+
│ │ ├── models.ts # IEQField, IEQEventField, IEQItem, IEQResponse
|
|
67
|
+
│ │ └── index.ts
|
|
68
|
+
│ ├── event/
|
|
69
|
+
│ │ ├── enums.ts # EVENT_TYPES_ENUM, EVENT_ERROR_REASON_ENUM, DISEASES_ENUM, MEDMETHOD_ENUM, etc.
|
|
70
|
+
│ │ ├── animal-event-filter.ts # AnimalEventFilter class (business logic)
|
|
71
|
+
│ │ └── index.ts
|
|
72
|
+
│ ├── import-data/
|
|
73
|
+
│ │ ├── enums.ts # IMPDATA_SOURCES_ENUM, IMPDATA_STATUS_ENUM
|
|
74
|
+
│ │ └── index.ts
|
|
75
|
+
│ ├── milk/
|
|
76
|
+
│ │ ├── enums.ts # MILK_PROVIDER_ENUM
|
|
77
|
+
│ │ └── index.ts
|
|
78
|
+
│ └── org/
|
|
79
|
+
│ ├── const.ts # CDefaultOrgSettings (event periods, report settings)
|
|
80
|
+
│ └── index.ts
|
|
81
|
+
└── test/
|
|
82
|
+
├── index.test.ts
|
|
83
|
+
└── event/
|
|
84
|
+
└── animal-event-filter.spec.ts
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 4. Export Structure (src/index.ts)
|
|
90
|
+
|
|
91
|
+
The main barrel exports everything as **namespaced objects**:
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
export const enums = { ...dataEnums, BREED, BREED_AS_OBJECT } // root enums + breeds
|
|
95
|
+
export const rolePermissions = { ROOT_PERMISSIONS, USER_PERMISSIONS }
|
|
96
|
+
export const types = { /* IAnimal, IRolePermissionItem, etc. */ }
|
|
97
|
+
export const customListEnums = { CLIST_* enums }
|
|
98
|
+
export const animalTagEnums = { TAG_TYPE_ENUM }
|
|
99
|
+
export const importEnums = { IMPDATA_* enums }
|
|
100
|
+
export const animalForEventFilters = { filter, EVENT_ERROR_REASON_ENUM, ... }
|
|
101
|
+
export const animalEnums = { ANIMAL_GENDER_ENUM, ANIMAL_STATUS_ENUM, BULL_STATUS_ENUM, COW_STATUS_ENUM }
|
|
102
|
+
export const eventEnums = { EVENT_TYPES_ENUM, DISEASES_ENUM, MEDMETHOD_ENUM, ... }
|
|
103
|
+
export const eqEnums = { EQ_PROFILE, EQ_STATUS_ENUM, ... }
|
|
104
|
+
export const orgConstants = { CDefaultOrgSettings }
|
|
105
|
+
export const milkEnums = { MILK_PROVIDER_ENUM }
|
|
106
|
+
export const dateHelpers = { getMonthFromDate, datestrToDate }
|
|
107
|
+
export * as event from './event'
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 5. How Consumers Import
|
|
113
|
+
|
|
114
|
+
### Backend (CommonJS `require`, via main entry):
|
|
115
|
+
```javascript
|
|
116
|
+
const { EVENT_TYPES_ENUM } = require('@molochko-dev/data').eventEnums
|
|
117
|
+
const { COW_STATUS_ENUM } = require('@molochko-dev/data').animalEnums
|
|
118
|
+
const { TOKEN_TYPE_ENUM } = require('@molochko-dev/data').enums
|
|
119
|
+
const { MILK_PROVIDER_ENUM } = require('@molochko-dev/data').milkEnums
|
|
120
|
+
const { EQ_STATUS_ENUM } = require('@molochko-dev/data').eqEnums
|
|
121
|
+
const { TAG_TYPE_ENUM } = require('@molochko-dev/data').animalTagEnums
|
|
122
|
+
const { CLIST_AFUNCTIONS_ENUM } = require('@molochko-dev/data').enums
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Frontend (TypeScript ES import, deep dist/ paths):
|
|
126
|
+
```typescript
|
|
127
|
+
import { SUPPORTED_LANG_ENUM } from '@molochko-dev/data/dist/enums'
|
|
128
|
+
import { ANIMAL_GENDER_ENUM, BULL_STATUS_ENUM } from '@molochko-dev/data/dist/animals/enums'
|
|
129
|
+
import { EVENT_TYPES_ENUM } from '@molochko-dev/data/dist/event/enums'
|
|
130
|
+
import { AnimalStatus, IAnimal } from '@molochko-dev/data/dist/types'
|
|
131
|
+
import { CDefaultOrgSettings } from '@molochko-dev/data/dist/org/const'
|
|
132
|
+
import { enumToObject } from '@molochko-dev/data/dist/helpers'
|
|
133
|
+
import { MILK_PROVIDER_ENUM } from '@molochko-dev/data/dist/milk/enums'
|
|
134
|
+
import { EQ_FORBIDDEN_WORDS } from '@molochko-dev/data/dist/easy-query/enums'
|
|
135
|
+
import { dateHelpers } from '@molochko-dev/data'
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Consumers & Versions
|
|
139
|
+
| Consumer | Version |
|
|
140
|
+
|----------|---------|
|
|
141
|
+
| molochko-crm/packages/backend | ^1.4.109 |
|
|
142
|
+
| molochko-crm/packages/scheduler | ^1.4.108 |
|
|
143
|
+
| molochko-crm/packages/shared | ^1.4.108 |
|
|
144
|
+
| molochko-front | ^1.4.112 |
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 6. Enums Reference
|
|
149
|
+
|
|
150
|
+
### 6.1 IMPORTANT: Enum Duplication
|
|
151
|
+
|
|
152
|
+
Many enums exist in TWO places — root `src/enums.ts` (DEPRECATED, marked `TODO removeme`) and domain subdirectories (CANONICAL). **Always use the canonical versions from subdirectories:**
|
|
153
|
+
|
|
154
|
+
| Enum | DEPRECATED location | CANONICAL location |
|
|
155
|
+
|------|--------------------|--------------------|
|
|
156
|
+
| `ANIMAL_GENDER_ENUM` | `src/enums.ts` | `src/animals/enums.ts` |
|
|
157
|
+
| `ANIMAL_STATUS_ENUM` | `src/enums.ts` | `src/animals/enums.ts` |
|
|
158
|
+
| `COW_STATUS_ENUM` | `src/enums.ts` (as `COW_STATUS`) | `src/animals/enums.ts` (as `COW_STATUS_ENUM`) |
|
|
159
|
+
| `BULL_STATUS_ENUM` | `src/enums.ts` (as `BULL_STATUS`) | `src/animals/enums.ts` (as `BULL_STATUS_ENUM`) |
|
|
160
|
+
| `EVENT_TYPES_ENUM` | `src/enums.ts` | `src/event/enums.ts` |
|
|
161
|
+
| `EVENT_ERROR_REASON_ENUM` | `src/enums.ts` | `src/event/enums.ts` |
|
|
162
|
+
| `DISEASES_ENUM` | `src/enums.ts` | `src/event/enums.ts` |
|
|
163
|
+
| `MEDMETHOD_ENUM` | `src/enums.ts` | `src/event/enums.ts` |
|
|
164
|
+
| `CLIST_*` enums | `src/enums.ts` | `src/custom-list/enums.ts` |
|
|
165
|
+
|
|
166
|
+
The canonical versions may have additional values (e.g., `lateDry`, `estrous`, `calving`) not present in the deprecated root versions.
|
|
167
|
+
|
|
168
|
+
### 6.2 Root Enums (src/enums.ts) — Non-duplicated
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
BCRYPT_SALT = 12
|
|
172
|
+
|
|
173
|
+
SYSTEM_USER_ROLES_ENUM { user, admin, root }
|
|
174
|
+
USER_STATUSES_ENUM { waiting, ready, blocked, deleted }
|
|
175
|
+
ORG_TYPE_ENUM { org, location }
|
|
176
|
+
TOKEN_TYPE_ENUM { confirm, auth, refresh, resetPassword, invite }
|
|
177
|
+
SEED_TYPE_ENUM { traditional, sexytelka, sexybull, meat, meatSexyTelka, meatSexyBull }
|
|
178
|
+
SEED_STATUS_ENUM { active, notActive }
|
|
179
|
+
SEED_CODES_ENUM { DOUBLE_OVSYNC, PRESYNC, RESYNC, OVSYNC, HEAT, ACTIVITY_SENSOR, PRID_DELTA, G6G }
|
|
180
|
+
COMMON_SIMPLE_STATUS_ENUM { failed, success }
|
|
181
|
+
USER_PERMISSION_ENUM { view, create, update, delete, deleteAll, attach, detach }
|
|
182
|
+
USER_PERMISSION_METHOD_ENUM { post, put, delete, get, patch }
|
|
183
|
+
ACCESS_ENUM { read, write }
|
|
184
|
+
SUPPORTED_LANG_ENUM { ru = 'ru', en = 'en' }
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### 6.3 Animal Enums (src/animals/enums.ts)
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
ANIMAL_GENDER_ENUM { cow = 'cow', bull = 'bull' }
|
|
191
|
+
|
|
192
|
+
ANIMAL_STATUS_ENUM { heifer, bred, pregnant, open, fresh, dry, lateDry, dnb, sold, died, theft, transferout }
|
|
193
|
+
|
|
194
|
+
COW_STATUS_ENUM { heifer, bred, pregnant, open, fresh, dry, lateDry, dnb, sold, died, theft, transferout, estrous }
|
|
195
|
+
|
|
196
|
+
BULL_STATUS_ENUM { sold, bull, died }
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### 6.4 Event Enums (src/event/enums.ts)
|
|
200
|
+
|
|
201
|
+
```typescript
|
|
202
|
+
EVENT_TYPES_ENUM {
|
|
203
|
+
otel, calving, recheck, ohota, insemenation, stelnaya, yalovaya,
|
|
204
|
+
stelneotpos, perevod, kbiku, suhostoi, abort, neosem, prodazha,
|
|
205
|
+
pala, zamenaNomera, obrKopit, pozSuhostoi, ves, rost, biometry,
|
|
206
|
+
upitannost, zaboi, sinchronizatsia, transferOut, treatment
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
EVENT_EXEC_STATUS_ENUM { waiting, done, cancel, block }
|
|
210
|
+
|
|
211
|
+
EVENT_ERROR_REASON_ENUM {
|
|
212
|
+
animalMustBeACow, animalTooYoung, animalInsemenatedAtEventDate,
|
|
213
|
+
animalInVWPForEventDate, animalInDryForEventDate,
|
|
214
|
+
eventsBeforeShouldBeInsemOrRecheck, tooEarlyToRecheckAfterInsemenation,
|
|
215
|
+
recheckMustbeBefore, recheckMustbePregnant, tooEarlyToDry,
|
|
216
|
+
noDryAfterFirstInsemenation, dryMustBeBefore, tooEarlyLateToDry,
|
|
217
|
+
noLateDryAfterFirstInsemenation, lateDryMustBeBeforeCalving,
|
|
218
|
+
dryMustBeBeforeLateDryForCalving, animalNotInCalvingPeriod
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
TRANSFEROUT_TYPES_ENUM { transferOut, died }
|
|
222
|
+
TRANSFEROUT_REASON_ENUM { leikoz, tuberkulez, klostirikoz, nekrobacilez, aktinomikoz, ginekologic, metabolicDisorders, Infertility, udderDiseases, lameness, breedingSales, salesToThePublic, theft, dead }
|
|
223
|
+
|
|
224
|
+
DISEASES_ENUM { PREVENTION, VACCTINATION, MASTITIS, METRITIS, PARESIS, TEMPERATURE, ABOMASUM_DISPLACEMENT, LAMENESS, INJURY, DEHORNING, METABOLIC_DISEASE, DIARRHEA, ATONY, PNEUMONIA, TYMPANY, HEALTHY, KETOSIS, CONJUNCTEVITIS, DIPEPSIA, SYNCHRONIZATION, OTHER }
|
|
225
|
+
|
|
226
|
+
MEDMETHOD_ENUM { SUBCUTANEOUSLY, NASALLY, INTRAMUSCULARLY, INTRACISTERNALLY, ORALLY, INTRAVENOUSLY, INTRAUTERINE, INTRAVAGINALLY }
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### 6.5 Custom List Enums (src/custom-list/enums.ts)
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
CLIST_NUMBER_OPERATOR_ENUM { eq, gte, lte, lt, gt }
|
|
233
|
+
CLIST_STRING_OPERATOR_ENUM { eq, consists }
|
|
234
|
+
CLIST_DATE_OPERATOR_ENUM { eq, between }
|
|
235
|
+
CLIST_TYPE_ENUM { string, number, date }
|
|
236
|
+
CLIST_CONDITION_ENUM { and, or, not }
|
|
237
|
+
CLIST_MODELS_ENUM { animals, events, seedBank, employee, org, protocol, treatment, animalMetrics }
|
|
238
|
+
CLIST_DATASOURCE_ENUM { animals, animalMetrics, seedBank, events, employee }
|
|
239
|
+
CLIST_STATUS_ENUM { working, published }
|
|
240
|
+
CLIST_AFUNCTIONS_ENUM { count, min, max, avg, sum }
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### 6.6 Other Enums
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
// src/animal-tag/enums.ts
|
|
247
|
+
TAG_TYPE_ENUM { user, system, event }
|
|
248
|
+
|
|
249
|
+
// src/easy-query/enums.ts
|
|
250
|
+
EQ_PROFILE { animal, animalReport }
|
|
251
|
+
EQ_STATUS_ENUM { working, published }
|
|
252
|
+
EQ_CATEGORY_TYPE_ENUM { system, user }
|
|
253
|
+
EQ_FORBIDDEN_WORDS ['*','insert','update','delete','drop','create','alter','change']
|
|
254
|
+
|
|
255
|
+
// src/import-data/enums.ts
|
|
256
|
+
IMPDATA_SOURCES_ENUM { dairyComp }
|
|
257
|
+
IMPDATA_STATUS_ENUM { waiting, working, ready, error }
|
|
258
|
+
|
|
259
|
+
// src/milk/enums.ts
|
|
260
|
+
MILK_PROVIDER_ENUM { vestfallia }
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## 7. Types / Interfaces (src/types.ts)
|
|
266
|
+
|
|
267
|
+
```typescript
|
|
268
|
+
export interface EnumItem {
|
|
269
|
+
readonly id: string
|
|
270
|
+
readonly label: string
|
|
271
|
+
readonly color?: string
|
|
272
|
+
}
|
|
273
|
+
export type EnumArrayAsObject = { [key: string]: string }
|
|
274
|
+
|
|
275
|
+
export interface IAnimal {
|
|
276
|
+
id: string; orgId: string; name: string; animalId: string;
|
|
277
|
+
isoId: string; regId: string; activometrId: string;
|
|
278
|
+
status: AnimalStatus; gender: ANIMAL_GENDER_ENUM; dob: Date;
|
|
279
|
+
breed?: string; tags?: number[]; searchTag?: string;
|
|
280
|
+
animalEventRelation?: IAnimalEventRelation[];
|
|
281
|
+
}
|
|
282
|
+
export type AnimalStatus = COW_STATUS | BULL_STATUS
|
|
283
|
+
export type BaseAnimal = {
|
|
284
|
+
id: string; dob: Date; gender: ANIMAL_GENDER_ENUM;
|
|
285
|
+
status: AnimalStatus; animalEventRelation?: IAnimalEventRelation[];
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export interface IAnimalEventRelation { eventDetail: IEventDetail }
|
|
289
|
+
export interface IEventDetail { type: EVENT_TYPES_ENUM }
|
|
290
|
+
|
|
291
|
+
export interface IBackendRolePermissionItem {
|
|
292
|
+
active: boolean;
|
|
293
|
+
permission: USER_PERMISSION_ENUM;
|
|
294
|
+
method: USER_PERMISSION_METHOD_ENUM;
|
|
295
|
+
paths: string[];
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export interface IRolePermissionItem {
|
|
299
|
+
name: string;
|
|
300
|
+
frontend?: { active: boolean; path: string };
|
|
301
|
+
backend?: IBackendRolePermissionItem[];
|
|
302
|
+
}
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### Easy Query Interfaces (src/easy-query/models.ts)
|
|
306
|
+
|
|
307
|
+
```typescript
|
|
308
|
+
export interface IEQField { field: string; value: string; label: string; type: string; visible: boolean }
|
|
309
|
+
export interface IEQEventField extends IEQField {
|
|
310
|
+
treatment?: IEQField; protocol?: IEQField; seedBank?: IEQField; employee?: IEQField
|
|
311
|
+
}
|
|
312
|
+
export interface IEQItem { animal: Record<string, IEQField>; metrics: Record<string, IEQField>; events: Record<string, IEQEventField>[] }
|
|
313
|
+
export interface IEQResponse { count: number; data: IEQItem[] }
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## 8. Constants
|
|
319
|
+
|
|
320
|
+
### 8.1 Default Org Settings (src/org/const.ts)
|
|
321
|
+
```typescript
|
|
322
|
+
export const CDefaultOrgSettings = {
|
|
323
|
+
events: {
|
|
324
|
+
minInsemenationAgeDays: 540,
|
|
325
|
+
periodForRecheckAfterInsemenation: [30, 220],
|
|
326
|
+
periodInsemenationAfterLastCalving: [40, 60],
|
|
327
|
+
periodForDryAfterInsemenation: [220, 250],
|
|
328
|
+
periodForLateDryAfterInsemenation: [250, 275],
|
|
329
|
+
periodCalvingAfterInsemenation: [275, 310],
|
|
330
|
+
periodGuessCalving: [365, 410],
|
|
331
|
+
},
|
|
332
|
+
reports: {
|
|
333
|
+
pagingPeriod: 21,
|
|
334
|
+
vwp: { heifer: 360, firstHeifer: 70, mature: 60 },
|
|
335
|
+
},
|
|
336
|
+
}
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### 8.2 Breed Data (src/breed.ts)
|
|
340
|
+
`BREED: EnumItem[]` — array of ~120 cattle breeds with `id` (code) and `label` (name).
|
|
341
|
+
`BREED_AS_OBJECT` — same data as `{ id: id }` map.
|
|
342
|
+
|
|
343
|
+
### 8.3 Role Permissions (src/role-permissions.ts)
|
|
344
|
+
- `ROOT_PERMISSIONS` — wildcard `*` access
|
|
345
|
+
- `USER_PERMISSIONS` — detailed RBAC: maps module names (org, employees, seed-bank, animal-tag, animal, event, role-permissions) to frontend paths and backend API endpoint permissions
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## 9. Utility Functions
|
|
350
|
+
|
|
351
|
+
### helpers.ts
|
|
352
|
+
```typescript
|
|
353
|
+
// Convert EnumItem[] to { [id]: id } map
|
|
354
|
+
asObject(arrayOfObjects: EnumItem[]): EnumArrayAsObject
|
|
355
|
+
|
|
356
|
+
// Convert TypeScript enum to { key: value } plain object (skips numeric reverse-mappings)
|
|
357
|
+
enumToObject(e: object): { [key: string]: string }
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### helpers/date.ts
|
|
361
|
+
```typescript
|
|
362
|
+
// Months between now and dateString
|
|
363
|
+
getMonthFromDate(dateString: string): number
|
|
364
|
+
|
|
365
|
+
// Parse 6-digit "YYMMDD" string (e.g. "251201") into Date, null if invalid
|
|
366
|
+
datestrToDate(dateStr: string): Date | null
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### event/animal-event-filter.ts
|
|
370
|
+
`AnimalEventFilter` class — filters arrays of animals based on event type, checking gender, status, and age constraints. Exported as `filter()` function. Used to determine which animals are eligible for a given event type.
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
## 10. Adding New Enums / Types
|
|
375
|
+
|
|
376
|
+
### 10.1 Add to Existing Domain
|
|
377
|
+
1. Add the enum/type to the relevant `src/<domain>/enums.ts` or `src/<domain>/models.ts`
|
|
378
|
+
2. Re-export from `src/<domain>/index.ts`
|
|
379
|
+
3. If needed for main entry consumers, add to the namespace export in `src/index.ts`
|
|
380
|
+
|
|
381
|
+
### 10.2 Add a New Domain
|
|
382
|
+
1. Create `src/<domain>/enums.ts` (and/or `models.ts`)
|
|
383
|
+
2. Create `src/<domain>/index.ts` with re-exports
|
|
384
|
+
3. Add namespace export in `src/index.ts`:
|
|
385
|
+
```typescript
|
|
386
|
+
import * as _newDomain from './<domain>'
|
|
387
|
+
export const newDomainEnums = _newDomain.enums
|
|
388
|
+
```
|
|
389
|
+
4. Write tests in `test/<domain>/`
|
|
390
|
+
|
|
391
|
+
### 10.3 Publishing
|
|
392
|
+
```bash
|
|
393
|
+
npm run pub # lint → test → version patch → build → publish
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
**IMPORTANT**: After publishing, update the version in all consumer `package.json` files:
|
|
397
|
+
- `molochko-crm/packages/backend/package.json`
|
|
398
|
+
- `molochko-crm/packages/scheduler/package.json`
|
|
399
|
+
- `molochko-crm/packages/shared/package.json`
|
|
400
|
+
- `molochko-front/package.json`
|
|
401
|
+
|
|
402
|
+
Then run `npm install` / `yarn install` in each consumer.
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
## 11. Domain Terms (Russian → English)
|
|
407
|
+
|
|
408
|
+
Event type enum values use transliterated Russian:
|
|
409
|
+
- `otel` / `calving` — calving (birth)
|
|
410
|
+
- `ohota` — estrus / heat
|
|
411
|
+
- `suhostoi` — dry period
|
|
412
|
+
- `pozSuhostoi` — late dry period
|
|
413
|
+
- `stelnaya` — pregnant
|
|
414
|
+
- `yalovaya` — barren
|
|
415
|
+
- `neosem` — failed insemination
|
|
416
|
+
- `perevod` — transfer between groups
|
|
417
|
+
- `prodazha` — sale
|
|
418
|
+
- `pala` — death
|
|
419
|
+
- `zaboi` — slaughter
|
|
420
|
+
- `sinchronizatsia` — synchronization protocol
|
|
421
|
+
- `transferOut` — disposal/removal
|
|
422
|
+
- `upitannost` — body condition score
|
|
423
|
+
- `ves` — weight
|
|
424
|
+
- `rost` — height
|
|
425
|
+
- `obrKopit` — hoof trimming
|
|
426
|
+
- `zamenaNomera` — tag replacement
|
|
427
|
+
- `kbiku` — bull breeding
|
package/dist/easy-query/enums.js
CHANGED
|
@@ -16,4 +16,13 @@ var EQ_CATEGORY_TYPE_ENUM;
|
|
|
16
16
|
EQ_CATEGORY_TYPE_ENUM["system"] = "system";
|
|
17
17
|
EQ_CATEGORY_TYPE_ENUM["user"] = "user";
|
|
18
18
|
})(EQ_CATEGORY_TYPE_ENUM = exports.EQ_CATEGORY_TYPE_ENUM || (exports.EQ_CATEGORY_TYPE_ENUM = {}));
|
|
19
|
-
exports.EQ_FORBIDDEN_WORDS = [
|
|
19
|
+
exports.EQ_FORBIDDEN_WORDS = [
|
|
20
|
+
'*',
|
|
21
|
+
'insert',
|
|
22
|
+
'update',
|
|
23
|
+
'delete',
|
|
24
|
+
'drop',
|
|
25
|
+
'create',
|
|
26
|
+
'alter',
|
|
27
|
+
'change',
|
|
28
|
+
];
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import * as _animalEnums from './animals';
|
|
|
9
9
|
import * as _eqEnums from './easy-query';
|
|
10
10
|
import * as _orgConstants from './org';
|
|
11
11
|
import * as _milkEnums from './milk';
|
|
12
|
+
import * as _notificationEnums from './notification';
|
|
12
13
|
import * as _dateHelpers from './helpers/date';
|
|
13
14
|
export declare const enums: {
|
|
14
15
|
BREED: typeDefinitions.EnumItem[];
|
|
@@ -58,5 +59,6 @@ export declare const eventEnums: typeof _animalForEventFilters.enums;
|
|
|
58
59
|
export declare const eqEnums: typeof _eqEnums.enums;
|
|
59
60
|
export declare const orgConstants: typeof _orgConstants.constants;
|
|
60
61
|
export declare const milkEnums: typeof _milkEnums.enums;
|
|
62
|
+
export declare const notificationEnums: typeof _notificationEnums.enums;
|
|
61
63
|
export declare const dateHelpers: typeof _dateHelpers;
|
|
62
64
|
export * as event from './event';
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.event = exports.dateHelpers = exports.milkEnums = exports.orgConstants = exports.eqEnums = exports.eventEnums = exports.animalEnums = exports.animalForEventFilters = exports.importEnums = exports.animalTagEnums = exports.customListEnums = exports.types = exports.rolePermissions = exports.enums = void 0;
|
|
26
|
+
exports.event = exports.dateHelpers = exports.notificationEnums = exports.milkEnums = exports.orgConstants = exports.eqEnums = exports.eventEnums = exports.animalEnums = exports.animalForEventFilters = exports.importEnums = exports.animalTagEnums = exports.customListEnums = exports.types = exports.rolePermissions = exports.enums = void 0;
|
|
27
27
|
const dataEnums = __importStar(require("./enums"));
|
|
28
28
|
const breed_1 = require("./breed");
|
|
29
29
|
const typeDefinitions = __importStar(require("./types"));
|
|
@@ -37,6 +37,7 @@ const _eventEnums = __importStar(require("./event"));
|
|
|
37
37
|
const _eqEnums = __importStar(require("./easy-query"));
|
|
38
38
|
const _orgConstants = __importStar(require("./org"));
|
|
39
39
|
const _milkEnums = __importStar(require("./milk"));
|
|
40
|
+
const _notificationEnums = __importStar(require("./notification"));
|
|
40
41
|
const _dateHelpers = __importStar(require("./helpers/date"));
|
|
41
42
|
exports.enums = Object.assign(Object.assign({}, dataEnums), { BREED: breed_1.BREED, BREED_AS_OBJECT: breed_1.BREED_AS_OBJECT });
|
|
42
43
|
exports.rolePermissions = _rolePermissions;
|
|
@@ -50,6 +51,7 @@ exports.eventEnums = _eventEnums.enums;
|
|
|
50
51
|
exports.eqEnums = _eqEnums.enums;
|
|
51
52
|
exports.orgConstants = _orgConstants.constants;
|
|
52
53
|
exports.milkEnums = _milkEnums.enums;
|
|
54
|
+
exports.notificationEnums = _notificationEnums.enums;
|
|
53
55
|
exports.dateHelpers = _dateHelpers;
|
|
54
56
|
// export { events } from './event';
|
|
55
57
|
// export type { events as EventType } from './event';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare enum ALERT_TYPE_ENUM {
|
|
2
|
+
calvingApproaching = "calvingApproaching",
|
|
3
|
+
recheckOverdue = "recheckOverdue",
|
|
4
|
+
vwpExceeded = "vwpExceeded"
|
|
5
|
+
}
|
|
6
|
+
export declare enum NOTIFICATION_CHANNEL_ENUM {
|
|
7
|
+
inApp = "inApp",
|
|
8
|
+
email = "email",
|
|
9
|
+
telegram = "telegram"
|
|
10
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NOTIFICATION_CHANNEL_ENUM = exports.ALERT_TYPE_ENUM = void 0;
|
|
4
|
+
var ALERT_TYPE_ENUM;
|
|
5
|
+
(function (ALERT_TYPE_ENUM) {
|
|
6
|
+
ALERT_TYPE_ENUM["calvingApproaching"] = "calvingApproaching";
|
|
7
|
+
ALERT_TYPE_ENUM["recheckOverdue"] = "recheckOverdue";
|
|
8
|
+
ALERT_TYPE_ENUM["vwpExceeded"] = "vwpExceeded";
|
|
9
|
+
})(ALERT_TYPE_ENUM = exports.ALERT_TYPE_ENUM || (exports.ALERT_TYPE_ENUM = {}));
|
|
10
|
+
var NOTIFICATION_CHANNEL_ENUM;
|
|
11
|
+
(function (NOTIFICATION_CHANNEL_ENUM) {
|
|
12
|
+
NOTIFICATION_CHANNEL_ENUM["inApp"] = "inApp";
|
|
13
|
+
NOTIFICATION_CHANNEL_ENUM["email"] = "email";
|
|
14
|
+
NOTIFICATION_CHANNEL_ENUM["telegram"] = "telegram";
|
|
15
|
+
})(NOTIFICATION_CHANNEL_ENUM = exports.NOTIFICATION_CHANNEL_ENUM || (exports.NOTIFICATION_CHANNEL_ENUM = {}));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.enums = void 0;
|
|
27
|
+
const _enums = __importStar(require("./enums"));
|
|
28
|
+
exports.enums = _enums;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { USER_PERMISSION_ENUM, USER_PERMISSION_METHOD_ENUM, ANIMAL_GENDER_ENUM, COW_STATUS, BULL_STATUS } from './enums';
|
|
2
|
-
import { EVENT_TYPES_ENUM } from
|
|
2
|
+
import { EVENT_TYPES_ENUM } from './event';
|
|
3
3
|
export interface EnumItem {
|
|
4
4
|
readonly id: string;
|
|
5
5
|
readonly label: string;
|
package/package.json
CHANGED
package/src/easy-query/enums.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export enum EQ_PROFILE {
|
|
2
2
|
animal = 'animal',
|
|
3
|
-
animalReport = 'animalReport'
|
|
3
|
+
animalReport = 'animalReport',
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
export enum EQ_STATUS_ENUM {
|
|
@@ -13,4 +13,13 @@ export enum EQ_CATEGORY_TYPE_ENUM {
|
|
|
13
13
|
user = 'user',
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const EQ_FORBIDDEN_WORDS =
|
|
16
|
+
export const EQ_FORBIDDEN_WORDS = [
|
|
17
|
+
'*',
|
|
18
|
+
'insert',
|
|
19
|
+
'update',
|
|
20
|
+
'delete',
|
|
21
|
+
'drop',
|
|
22
|
+
'create',
|
|
23
|
+
'alter',
|
|
24
|
+
'change',
|
|
25
|
+
];
|
package/src/easy-query/models.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
export interface IEQField {
|
|
2
|
-
field: string
|
|
3
|
-
value: string
|
|
4
|
-
label: string
|
|
5
|
-
type: string
|
|
6
|
-
visible: boolean
|
|
2
|
+
field: string;
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
type: string;
|
|
6
|
+
visible: boolean;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export interface IEQEventField extends IEQField{
|
|
10
|
-
treatment?: IEQField
|
|
11
|
-
protocol?: IEQField
|
|
12
|
-
seedBank?: IEQField
|
|
13
|
-
employee?: IEQField
|
|
9
|
+
export interface IEQEventField extends IEQField {
|
|
10
|
+
treatment?: IEQField;
|
|
11
|
+
protocol?: IEQField;
|
|
12
|
+
seedBank?: IEQField;
|
|
13
|
+
employee?: IEQField;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export interface IEQItem {
|
|
17
|
-
animal: Record<string, IEQField
|
|
18
|
-
metrics: Record<string, IEQField
|
|
19
|
-
events: Record<string, IEQEventField>[]
|
|
17
|
+
animal: Record<string, IEQField>;
|
|
18
|
+
metrics: Record<string, IEQField>;
|
|
19
|
+
events: Record<string, IEQEventField>[];
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export interface IEQResponse {
|
|
23
|
-
count: number
|
|
24
|
-
data: IEQItem[]
|
|
25
|
-
}
|
|
23
|
+
count: number;
|
|
24
|
+
data: IEQItem[];
|
|
25
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnimalStatus, BaseAnimal } from '../types';
|
|
2
2
|
import { ANIMAL_GENDER_ENUM, COW_STATUS } from '../enums';
|
|
3
3
|
import { getMonthFromDate } from '../helpers/date';
|
|
4
|
-
import { EVENT_TYPES_ENUM } from '../event'
|
|
4
|
+
import { EVENT_TYPES_ENUM } from '../event';
|
|
5
5
|
/*
|
|
6
6
|
|
|
7
7
|
const filtered = filter(animals, eventType)
|
package/src/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ import * as _eventEnums from './event';
|
|
|
11
11
|
import * as _eqEnums from './easy-query';
|
|
12
12
|
import * as _orgConstants from './org';
|
|
13
13
|
import * as _milkEnums from './milk';
|
|
14
|
+
import * as _notificationEnums from './notification';
|
|
14
15
|
import * as _dateHelpers from './helpers/date';
|
|
15
16
|
export const enums = { ...dataEnums, BREED, BREED_AS_OBJECT };
|
|
16
17
|
export const rolePermissions = _rolePermissions;
|
|
@@ -24,6 +25,7 @@ export const eventEnums = _eventEnums.enums;
|
|
|
24
25
|
export const eqEnums = _eqEnums.enums;
|
|
25
26
|
export const orgConstants = _orgConstants.constants;
|
|
26
27
|
export const milkEnums = _milkEnums.enums;
|
|
28
|
+
export const notificationEnums = _notificationEnums.enums;
|
|
27
29
|
export const dateHelpers = _dateHelpers;
|
|
28
30
|
|
|
29
31
|
// export { events } from './event';
|
package/src/milk/enums.ts
CHANGED
package/src/milk/index.ts
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export enum ALERT_TYPE_ENUM {
|
|
2
|
+
calvingApproaching = 'calvingApproaching',
|
|
3
|
+
recheckOverdue = 'recheckOverdue',
|
|
4
|
+
vwpExceeded = 'vwpExceeded',
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export enum NOTIFICATION_CHANNEL_ENUM {
|
|
8
|
+
inApp = 'inApp',
|
|
9
|
+
email = 'email',
|
|
10
|
+
telegram = 'telegram',
|
|
11
|
+
}
|
package/src/org/const.ts
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
export const CDefaultOrgSettings = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
events: {
|
|
3
|
+
minInsemenationAgeDays: 540,
|
|
4
|
+
periodForRecheckAfterInsemenation: [30, 220],
|
|
5
|
+
periodInsemenationAfterLastCalving: [40, 60],
|
|
6
|
+
periodForDryAfterInsemenation: [220, 250],
|
|
7
|
+
periodForLateDryAfterInsemenation: [250, 275],
|
|
8
|
+
periodCalvingAfterInsemenation: [275, 310],
|
|
9
|
+
periodGuessCalving: [365, 410],
|
|
10
|
+
},
|
|
11
|
+
reports: {
|
|
12
|
+
pagingPeriod: 21, // days
|
|
13
|
+
vwp: {
|
|
14
|
+
heifer: 360, // days
|
|
15
|
+
firstHeifer: 70, // days
|
|
16
|
+
mature: 60, // days
|
|
10
17
|
},
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
vwp: {
|
|
14
|
-
heifer: 360, // days
|
|
15
|
-
firstHeifer: 70, // days
|
|
16
|
-
mature: 60, // days
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
}
|
|
20
|
-
|
|
18
|
+
},
|
|
19
|
+
};
|