sowell-models 1.1.0 → 1.2.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.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "SoWell models",
5
5
  "type": "module",
6
6
  "engines": {
@@ -7,6 +7,7 @@ import { ICheckpoint, SPCheckpointItem } from "../Checkpoint"
7
7
 
8
8
  export interface ILocation extends IModel {
9
9
  _id?: string
10
+ id?: string
10
11
  name?: string
11
12
  areaType?: IAreaType
12
13
  areaTypeId?: number
@@ -20,4 +21,4 @@ export class SPLocationItem extends ApplicationRecord implements ILocation {
20
21
  @Attr() areaTypeId!: number
21
22
  @BelongsTo() areaType!: SPAreaType
22
23
  @HasMany() checkpoints?: SPCheckpointItem[] | undefined
23
- }
24
+ }
@@ -1,41 +1,42 @@
1
- import { Model, Attr, BelongsTo } from "spraypaint"
2
- import { IModel, PouchCollection, PouchORM } from "pouchorm"
3
- import { orderBy } from "lodash"
1
+ import { Model, Attr, BelongsTo } from 'spraypaint';
2
+ import { IModel, PouchCollection, PouchORM } from 'pouchorm';
3
+ import { orderBy } from 'lodash';
4
4
 
5
- import { ApplicationRecord } from "../ApplicationRecord"
6
- import { CollectionFindOptions, IClearable } from "../interfaces"
7
- import { SPCategoryItem } from "../category"
5
+ import { ApplicationRecord } from '../ApplicationRecord';
6
+ import { CollectionFindOptions, IClearable } from '../interfaces';
7
+ import { SPCategoryItem } from '../category';
8
8
 
9
9
  export interface IReason extends IModel {
10
- _id?: string
11
- name: string
10
+ _id?: string;
11
+ name: string;
12
+ iconUrl?: string;
12
13
  }
13
14
 
14
15
  export class ReasonCollection
15
16
  extends PouchCollection<IReason>
16
- implements IClearable {
17
+ implements IClearable
18
+ {
17
19
  async beforeInit(): Promise<void> {
18
20
  // NOTE: none
19
21
  }
20
22
 
21
23
  async clear(): Promise<void> {
22
- await PouchORM.clearDatabase("reasons")
24
+ await PouchORM.clearDatabase('reasons');
23
25
  }
24
26
 
25
27
  async find(
26
28
  selector?: Record<string, any> | Partial<IReason> | undefined,
27
- opts?: CollectionFindOptions
28
- ) {
29
- const result = await super.find(selector, opts)
30
- return orderBy(result, ["name"], ["asc"])
29
+ opts?: CollectionFindOptions,
30
+ ): Promise<IReason[]> {
31
+ const result = await super.find(selector, opts);
32
+ return orderBy(result, ['name'], ['asc']);
31
33
  }
32
34
  }
33
35
 
34
36
  @Model()
35
- export class SPReasonItem
36
- extends ApplicationRecord
37
- implements IReason {
38
- static jsonapiType = "reasons"
39
- @Attr() name!: string
40
- @BelongsTo() category!: SPCategoryItem
37
+ export class SPReasonItem extends ApplicationRecord implements IReason {
38
+ static jsonapiType = 'reasons';
39
+ @Attr() name!: string;
40
+ @Attr() iconUrl?: string;
41
+ @BelongsTo() category!: SPCategoryItem;
41
42
  }