sowell-models 1.22.2 → 1.24.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.22.2",
3
+ "version": "1.24.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
@@ -41,7 +40,7 @@ export class AreaCollection
41
40
  async find(
42
41
  selector?: Record<string, any> | Partial<IArea> | undefined,
43
42
  opts?: CollectionFindOptions
44
- ) {
43
+ ): Promise<IArea[]> {
45
44
  const result = await super.find(selector, opts)
46
45
  return orderBy(result, ["name"], ["asc"])
47
46
  }
@@ -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
  }
@@ -14,6 +14,7 @@ export interface IChecklist extends IModel {
14
14
  id?: string
15
15
  name: string
16
16
  isPlanned?: boolean
17
+ isActive?: boolean
17
18
  iconUrl?: string
18
19
  updatedAt?: Date
19
20
  company?: ICompany
@@ -51,6 +52,7 @@ export class SPChecklistItem extends ApplicationRecord implements IChecklist {
51
52
  static jsonapiType = "checklists"
52
53
  @Attr() name!: string
53
54
  @Attr() isPlanned!: boolean
55
+ @Attr() isActive!: boolean
54
56
  @Attr() iconUrl!: string
55
57
  @Attr({ persist: false }) updatedAt!: Date
56
58
  @Attr() periodicity!: string
@@ -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
@@ -4,19 +4,28 @@ import { orderBy } from "lodash"
4
4
 
5
5
  import { ApplicationRecord } from "../ApplicationRecord"
6
6
  import { ICompany, SPCompany } from "../Company"
7
- import { IArea, SPAreaItem } from "../AreaItem"
7
+ import { IAreaType, SPAreaType } from "../AreaItem"
8
8
  import { SPCheckpointItem } from "../Checkpoint"
9
9
  import { CollectionFindOptions, IClearable } from "../interfaces"
10
10
  import { IReason, SPReasonItem } from "../Reason"
11
+ import { SPFamily } from "../Family"
11
12
 
13
+
14
+ export interface ICategoryType extends IModel {
15
+ _id?: string;
16
+ name: string;
17
+ code?: string;
18
+ areaType?: IAreaType;
19
+ }
12
20
  export interface ICategory extends IModel {
13
21
  _id?: string
14
22
  name: string
23
+ code?: string
15
24
  order?: number
16
25
  iconUrl?: string
26
+ categoryTypeId?: string
27
+ categoryType?: ICategoryType
17
28
  company?: ICompany
18
- areaId?: string
19
- area?: IArea
20
29
  reasons?: IReason[]
21
30
  }
22
31
 
@@ -40,14 +49,32 @@ export class CategoryCollection
40
49
  }
41
50
  }
42
51
 
52
+ @Model()
53
+ export class SPCategoryTypeItem
54
+ extends ApplicationRecord
55
+ implements ICategoryType
56
+ {
57
+ static jsonapiType = 'category_types';
58
+ @Attr() name!: string;
59
+ @Attr() code?: string;
60
+ @BelongsTo() areaType!: SPAreaType;
61
+ @BelongsTo() family!: SPFamily[];
62
+ @HasMany() categories!: SPCategoryItem[];
63
+ get _id(): string | undefined {
64
+ return this.id;
65
+ }
66
+ }
67
+
43
68
  @Model()
44
69
  export class SPCategoryItem extends ApplicationRecord implements ICategory {
45
70
  static jsonapiType = "categories"
46
71
  @Attr() name!: string
47
72
  @Attr() order!: number
73
+ @Attr() code?: string
48
74
  @Attr() iconUrl!: string
75
+ @Attr() areaName!: string
49
76
  @BelongsTo() company!: SPCompany
50
- @BelongsTo() area!: SPAreaItem
77
+ @BelongsTo() categoryType!: SPCategoryTypeItem
51
78
  get _id(): string | undefined {
52
79
  return this.id
53
80
  }