sowell-models 1.6.0 → 1.8.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
|
import { Model, Attr } from "spraypaint"
|
|
2
|
-
import { ApplicationRecord } from "../ApplicationRecord"
|
|
3
2
|
import { ICompany } from "../Company"
|
|
3
|
+
import { SPUserItem } from "../User"
|
|
4
4
|
|
|
5
5
|
export interface Author {
|
|
6
6
|
_id?: string
|
|
@@ -10,7 +10,12 @@ export interface Author {
|
|
|
10
10
|
company?: ICompany
|
|
11
11
|
}
|
|
12
12
|
@Model()
|
|
13
|
-
export class SPAuthor extends
|
|
13
|
+
export class SPAuthor extends SPUserItem {
|
|
14
14
|
static jsonapiType = "authors"
|
|
15
15
|
@Attr() name!: string
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
@Model()
|
|
19
|
+
export class SPAssignee extends SPUserItem {
|
|
20
|
+
static jsonapiType = "assignees"
|
|
21
|
+
}
|
|
@@ -9,7 +9,6 @@ import { ICheckpoint, SPCheckpointItem } from "../Checkpoint"
|
|
|
9
9
|
import { CollectionFindOptions, IClearable } from "../interfaces"
|
|
10
10
|
import { IArea, SPAreaItem } from "../AreaItem"
|
|
11
11
|
import { IFamily, SPFamily } from "../Family"
|
|
12
|
-
import { CleanerType } from "../VisitProp"
|
|
13
12
|
export interface IChecklist extends IModel {
|
|
14
13
|
_id?: string
|
|
15
14
|
id?: string
|
|
@@ -21,7 +20,7 @@ export interface IChecklist extends IModel {
|
|
|
21
20
|
area?: IArea
|
|
22
21
|
checkpoints?: ICheckpoint[]
|
|
23
22
|
family?: IFamily
|
|
24
|
-
|
|
23
|
+
allowedAgents?: string[]
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
export class ChecklistCollection
|
|
@@ -39,7 +38,7 @@ export class ChecklistCollection
|
|
|
39
38
|
async find(
|
|
40
39
|
selector?: Record<string, any> | Partial<IChecklist> | undefined,
|
|
41
40
|
opts?: CollectionFindOptions
|
|
42
|
-
) {
|
|
41
|
+
): Promise<IChecklist[]> {
|
|
43
42
|
const result = await super.find(selector, opts)
|
|
44
43
|
return orderBy(result, ["name"], ["asc"])
|
|
45
44
|
}
|
|
@@ -51,7 +50,7 @@ export class SPChecklistItem extends ApplicationRecord implements IChecklist {
|
|
|
51
50
|
@Attr() isPlanned!: boolean
|
|
52
51
|
@Attr() iconUrl!: string
|
|
53
52
|
@Attr({ persist: false }) updatedAt!: Date
|
|
54
|
-
@Attr()
|
|
53
|
+
@Attr() allowedAgents!: string[]
|
|
55
54
|
@BelongsTo() company!: SPCompany
|
|
56
55
|
@BelongsTo() family!: SPFamily
|
|
57
56
|
@HasOne() area!: SPAreaItem
|
|
@@ -11,14 +11,14 @@ export interface ICompany extends IModel {
|
|
|
11
11
|
id?: string
|
|
12
12
|
_id?: string
|
|
13
13
|
name?: string
|
|
14
|
-
config?: string
|
|
14
|
+
config?: Record<string, any>
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
@Model()
|
|
18
18
|
export class SPCompany extends ApplicationRecord implements ICompany {
|
|
19
19
|
static jsonapiType = "companies"
|
|
20
20
|
@Attr() name!: string
|
|
21
|
-
@Attr() config!: string
|
|
21
|
+
@Attr() config!: Record<string, any>
|
|
22
22
|
@HasMany("areas") spAreaItems!: SPAreaItem[]
|
|
23
23
|
@HasMany("agencies") spAgencyItems!: SPAgencyItem[]
|
|
24
24
|
@HasMany("residences") spResidenceItems!: SPResidenceItem[]
|
|
@@ -18,6 +18,7 @@ import arrayDiffBy from "../types"
|
|
|
18
18
|
import { IReason, SPReasonItem } from "../Reason"
|
|
19
19
|
import { IOrigin, SPOriginItem } from "../Origin"
|
|
20
20
|
import { SPUnseenIssue } from "../UnseenIssue"
|
|
21
|
+
import { SPAssignee } from "../Author"
|
|
21
22
|
export interface IssueReportPayload {
|
|
22
23
|
category?: string
|
|
23
24
|
agency?: string
|
|
@@ -33,6 +34,7 @@ export interface IssueReportPayload {
|
|
|
33
34
|
isTenantRequest?: boolean
|
|
34
35
|
reason?: string
|
|
35
36
|
origin?: string
|
|
37
|
+
assignee?: string
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
export type Tab = "mySector" | "others"
|
|
@@ -76,6 +78,7 @@ export interface IIssueReport extends IModel {
|
|
|
76
78
|
isTenantRequest?:boolean
|
|
77
79
|
reason?: IReason
|
|
78
80
|
origin?: IOrigin
|
|
81
|
+
assignee?: IUser
|
|
79
82
|
seen?: boolean
|
|
80
83
|
validate?: () => string
|
|
81
84
|
}
|
|
@@ -94,7 +97,7 @@ export class IssueCollection
|
|
|
94
97
|
async find(
|
|
95
98
|
selector?: Record<string, any> | Partial<IIssueReport> | undefined,
|
|
96
99
|
opts?: CollectionFindOptions
|
|
97
|
-
) {
|
|
100
|
+
): Promise<IIssueReport[]> {
|
|
98
101
|
const result = await super.find(selector, opts)
|
|
99
102
|
return orderBy(result, ["name"], ["asc"])
|
|
100
103
|
}
|
|
@@ -136,9 +139,10 @@ export class SPIssueReportItem
|
|
|
136
139
|
@BelongsTo() checkpoint!: SPCheckpointItem
|
|
137
140
|
@BelongsTo() reason!: SPReasonItem
|
|
138
141
|
@BelongsTo() origin?: SPOriginItem | undefined
|
|
142
|
+
@BelongsTo() assignee?: SPAssignee
|
|
139
143
|
@HasMany() unseenIssues!: SPUnseenIssue[]
|
|
140
144
|
|
|
141
|
-
static async validate(payload: IssueReportPayload) {
|
|
145
|
+
static async validate(payload: IssueReportPayload): Promise<string> {
|
|
142
146
|
const schema = yup
|
|
143
147
|
.object()
|
|
144
148
|
.required()
|
|
@@ -7,7 +7,6 @@ import { ICheckpoint, SPCheckpointItem } from "../Checkpoint"
|
|
|
7
7
|
import { IResidence, SPResidenceItem } from "../Residence"
|
|
8
8
|
import { ISpot, SPSpotItem } from "../Spot"
|
|
9
9
|
|
|
10
|
-
export type CleanerType = "reporter" | "tenant" | "provider" | "others"
|
|
11
10
|
export interface IVisitProp extends IModel {
|
|
12
11
|
_id?: string
|
|
13
12
|
status?: "pending" | "missing"
|
|
@@ -19,14 +18,12 @@ export interface IVisitProp extends IModel {
|
|
|
19
18
|
residenceId?: number
|
|
20
19
|
spot?: ISpot
|
|
21
20
|
spotId?: number
|
|
22
|
-
cleaner?: CleanerType
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
@Model()
|
|
26
24
|
export class SPVisitPropItem extends ApplicationRecord implements IVisitProp {
|
|
27
25
|
static jsonapiType = "visit_props"
|
|
28
26
|
@Attr() status!: "pending" | "missing"
|
|
29
|
-
@Attr() cleaner!: CleanerType
|
|
30
27
|
@Attr() placeId!: number
|
|
31
28
|
@Attr() checkpointId!: number
|
|
32
29
|
@Attr() residenceId!: number
|
|
@@ -5,7 +5,6 @@ import { IUser, SPUserItem } from "../User"
|
|
|
5
5
|
import { IIssueReport, SPIssueReportItem } from "../IssueReport"
|
|
6
6
|
import { ApplicationRecord } from "../ApplicationRecord"
|
|
7
7
|
import { IVisitSchedule, SPVisitSchedule } from "../VisitSchedule"
|
|
8
|
-
import { ICheckpoint } from "../Checkpoint"
|
|
9
8
|
import * as yup from "yup"
|
|
10
9
|
import { IChecklist, SPChecklistItem } from "../Checklist"
|
|
11
10
|
import { IPlace, SPPlaceItem } from "../Place"
|
|
@@ -35,6 +34,7 @@ export interface VisitReportPayload {
|
|
|
35
34
|
comment?: string
|
|
36
35
|
isMissingProvider?: boolean
|
|
37
36
|
validate?: (payload: VisitReportPayload) => string
|
|
37
|
+
agent?: string
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export interface CheckpointProps {
|
|
@@ -51,14 +51,13 @@ export interface CheckpointProps {
|
|
|
51
51
|
}
|
|
52
52
|
category?: number
|
|
53
53
|
comment?: string
|
|
54
|
-
cleaner?: "tenant" | "provider" | "reporter" | "others"
|
|
55
54
|
coefficient?: number
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
export interface IVisitReport extends IModel {
|
|
59
58
|
id?: string
|
|
60
59
|
createdAt?: Date
|
|
61
|
-
checkpoints:
|
|
60
|
+
checkpoints: CheckpointProps[]
|
|
62
61
|
visitSchedule?: IVisitSchedule
|
|
63
62
|
checklist?: IChecklist
|
|
64
63
|
residence?: IResidence
|
|
@@ -73,6 +72,7 @@ export interface IVisitReport extends IModel {
|
|
|
73
72
|
}
|
|
74
73
|
score?: number
|
|
75
74
|
isMissingProvider?: boolean
|
|
75
|
+
agent?: string
|
|
76
76
|
validate?: (payload: VisitReportPayload) => string
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -90,6 +90,7 @@ export class SPVisitReport extends ApplicationRecord implements IVisitReport {
|
|
|
90
90
|
@Attr() comment!: string
|
|
91
91
|
@Attr() imgs!: string[]
|
|
92
92
|
@Attr() isMissingProvider!: boolean
|
|
93
|
+
@Attr() agent!: string
|
|
93
94
|
@BelongsTo() author!: SPUserItem
|
|
94
95
|
@BelongsTo() visitSchedule!: SPVisitSchedule
|
|
95
96
|
@BelongsTo() checklist!: SPChecklistItem
|