sowell-models 1.20.0 → 1.22.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sowell-models",
3
- "version": "1.20.0",
3
+ "version": "1.22.0",
4
4
  "description": "SoWell models",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -4,11 +4,10 @@ import { orderBy } from "lodash"
4
4
 
5
5
  import { ICompany, SPCompany } from "../Company"
6
6
  import { ApplicationRecord } from "../ApplicationRecord"
7
- import { SPCategoryItem } from "../category"
8
7
  import { CollectionFindOptions, IClearable } from "../interfaces"
9
- import { SPSpotItem } from "../Spot"
10
8
  import { SPChecklistItem } from "../Checklist"
11
9
  import { ILocation, SPLocationItem } from "../Location"
10
+ import { SPIssueReportItem } from "../IssueReport"
12
11
 
13
12
  export interface IAreaType extends IModel {
14
13
  _id?: string
@@ -72,8 +71,7 @@ export class SPAreaItem extends ApplicationRecord implements IArea {
72
71
  @BelongsTo() company!: SPCompany
73
72
  @HasOne() areaType!: SPAreaType
74
73
  @HasMany() checklists!: SPChecklistItem[]
75
- @HasMany() spcategoryItems!: SPCategoryItem[]
76
- @HasMany() spSpots!: SPSpotItem[]
74
+ @HasMany() spIssueReports!: SPIssueReportItem[]
77
75
  get _id(): string | undefined {
78
76
  return this.id
79
77
  }
@@ -21,6 +21,7 @@ export interface IChecklist extends IModel {
21
21
  checkpoints?: ICheckpoint[]
22
22
  family?: IFamily
23
23
  periodicity?: string
24
+ defaultAgent?: string
24
25
  allowedAgents?: string[]
25
26
  }
26
27
 
@@ -53,6 +54,7 @@ export class SPChecklistItem extends ApplicationRecord implements IChecklist {
53
54
  @Attr({ persist: false }) updatedAt!: Date
54
55
  @Attr() periodicity!: string
55
56
  @Attr() allowedAgents!: string[]
57
+ @Attr() defaultAgent!: string
56
58
  @BelongsTo() company!: SPCompany
57
59
  @BelongsTo() family!: SPFamily
58
60
  @HasOne() area!: SPAreaItem
@@ -11,7 +11,7 @@ import { IUser, SPUserItem } from "../User"
11
11
  import { ICheckpoint, SPCheckpointItem } from "../Checkpoint"
12
12
  import { SPVisitReport } from "../VisitReport"
13
13
  import { IResidence } from "../Residence"
14
- import { IArea } from "../AreaItem"
14
+ import { IArea, SPAreaItem } from "../AreaItem"
15
15
  import { CollectionFindOptions, IClearable } from "../interfaces"
16
16
  import { ISpot, SPSpotItem } from "./../Spot"
17
17
  import arrayDiffBy from "../types"
@@ -92,6 +92,7 @@ export interface IIssueReport extends IModel {
92
92
  origin?: IOrigin
93
93
  assignee?: IUser
94
94
  seen?: boolean
95
+ areaId?: number
95
96
  validate?: () => string
96
97
  }
97
98
 
@@ -163,6 +164,7 @@ export class SPIssueReportItem
163
164
  @BelongsTo() reason!: SPReasonItem
164
165
  @BelongsTo() origin?: SPOriginItem | undefined
165
166
  @BelongsTo() assignee?: SPAssignee
167
+ @BelongsTo() area!: SPAreaItem
166
168
  @HasMany() unseenIssues!: SPUnseenIssue[]
167
169
  @HasMany() activities!: SPActivity[]
168
170
 
@@ -1,4 +1,3 @@
1
- import { SPAreaItem, IArea } from "../AreaItem/index"
2
1
  import { Model, Attr, BelongsTo } from "spraypaint"
3
2
  import { orderBy } from "lodash"
4
3
  import { PouchCollection, PouchORM } from "pouchorm"
@@ -12,7 +11,6 @@ export interface ISpot extends IModel {
12
11
  name: string
13
12
  placeId?: string
14
13
  place?: IPlace
15
- area?: IArea
16
14
  company?: ICompany
17
15
  }
18
16
 
@@ -41,7 +39,6 @@ export class SPSpotItem extends ApplicationRecord implements ISpot {
41
39
  static jsonapiType = "spots"
42
40
  @Attr() name!: string
43
41
  @BelongsTo() place!: SPPlaceItem
44
- @BelongsTo() area!: SPAreaItem
45
42
  @BelongsTo() company!: SPCompany
46
43
  get _id(): string | undefined {
47
44
  return this.id
@@ -1,56 +1,85 @@
1
- import { Model, Attr, BelongsTo, HasMany } from "spraypaint"
2
- import { IModel, PouchCollection, PouchORM } from "pouchorm"
3
- import { orderBy } from "lodash"
1
+ import { Model, Attr, BelongsTo, HasMany } from 'spraypaint';
2
+ import { IModel, PouchCollection, PouchORM } from 'pouchorm';
3
+ import { orderBy } from 'lodash';
4
4
 
5
- import { ApplicationRecord } from "../ApplicationRecord"
6
- import { ICompany, SPCompany } from "../Company"
7
- import { IArea, SPAreaItem } from "../AreaItem"
8
- import { SPCheckpointItem } from "../Checkpoint"
9
- import { CollectionFindOptions, IClearable } from "../interfaces"
10
- import { IReason, SPReasonItem } from "../Reason"
5
+ import { ApplicationRecord } from '../ApplicationRecord';
6
+ import { ICompany, SPCompany } from '../Company';
7
+ import { SPCheckpointItem } from '../Checkpoint';
8
+ import { CollectionFindOptions, IClearable } from '../interfaces';
9
+ import { IReason, SPReasonItem } from '../Reason';
10
+ import { IAreaType, SPAreaType } from '../AreaItem';
11
+ import { SPFamily } from '../Family';
12
+
13
+ export interface ICategoryType extends IModel {
14
+ _id?: string;
15
+ name: string;
16
+ code?: string;
17
+ areaType?: IAreaType;
18
+ }
11
19
 
12
20
  export interface ICategory extends IModel {
13
- _id?: string
14
- name: string
15
- order?: number
16
- iconUrl?: string
17
- company?: ICompany
18
- areaId?: string
19
- area?: IArea
20
- reasons?: IReason[]
21
+ _id?: string;
22
+ name: string;
23
+ code?: string;
24
+ order?: number;
25
+ iconUrl?: string;
26
+ categoryTypeId?: string;
27
+ categoryType?: ICategoryType;
28
+ company?: ICompany;
29
+ reasons?: IReason[];
21
30
  }
22
31
 
23
32
  export class CategoryCollection
24
33
  extends PouchCollection<ICategory>
25
- implements IClearable {
34
+ implements IClearable
35
+ {
26
36
  async beforeInit(): Promise<void> {
27
37
  // NOTE: none
28
38
  }
29
39
 
30
40
  async clear(): Promise<void> {
31
- await PouchORM.clearDatabase("categories")
41
+ await PouchORM.clearDatabase('categories');
32
42
  }
33
43
 
34
44
  async find(
35
45
  selector?: Record<string, any> | Partial<ICategory> | undefined,
36
- opts?: CollectionFindOptions
46
+ opts?: CollectionFindOptions,
37
47
  ): Promise<ICategory[]> {
38
- const result = await super.find(selector, opts)
39
- return orderBy(result, ["order"], ["asc"])
48
+ const result = await super.find(selector, opts);
49
+ return orderBy(result, ['order'], ['asc']);
50
+ }
51
+ }
52
+
53
+ @Model()
54
+ export class SPCategoryTypeItem
55
+ extends ApplicationRecord
56
+ implements ICategoryType
57
+ {
58
+ static jsonapiType = 'category_types';
59
+ @Attr() name!: string;
60
+ @Attr() code?: string;
61
+ @BelongsTo() areaType!: SPAreaType;
62
+ @BelongsTo() family!: SPFamily[];
63
+ @HasMany() categories!: SPCategoryItem[];
64
+ get _id(): string | undefined {
65
+ return this.id;
40
66
  }
41
67
  }
42
68
 
43
69
  @Model()
44
70
  export class SPCategoryItem extends ApplicationRecord implements ICategory {
45
- static jsonapiType = "categories"
46
- @Attr() name!: string
47
- @Attr() order!: number
48
- @Attr() iconUrl!: string
49
- @BelongsTo() company!: SPCompany
50
- @BelongsTo() area!: SPAreaItem
71
+ static jsonapiType = 'categories';
72
+ @Attr() name!: string;
73
+ @Attr() order!: number;
74
+ @Attr() code?: string;
75
+ @Attr() iconUrl!: string;
76
+ @Attr() areaName!: string;
77
+ @BelongsTo() company!: SPCompany;
78
+ @BelongsTo() categoryType!: SPCategoryTypeItem;
79
+ @BelongsTo() areaType!: SPAreaType;
51
80
  get _id(): string | undefined {
52
- return this.id
81
+ return this.id;
53
82
  }
54
- @HasMany() checkpoints!: SPCheckpointItem[]
55
- @HasMany() reasons!: SPReasonItem[]
83
+ @HasMany() checkpoints!: SPCheckpointItem[];
84
+ @HasMany() reasons!: SPReasonItem[];
56
85
  }