@ironcode/vas-lib 2.2.0 → 3.0.0-alpha.1

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.
Files changed (114) hide show
  1. package/cjs/lib/control-value/vas-camera-control-value.model.d.ts +2 -0
  2. package/cjs/lib/control-value/vas-camera-control-value.model.d.ts.map +1 -1
  3. package/cjs/lib/control-value/vas-camera-control-value.model.js +10 -0
  4. package/cjs/lib/control-value/vas-camera-control-value.model.js.map +1 -1
  5. package/cjs/lib/entity/index.d.ts +5 -0
  6. package/cjs/lib/entity/index.d.ts.map +1 -1
  7. package/cjs/lib/entity/index.js +5 -0
  8. package/cjs/lib/entity/index.js.map +1 -1
  9. package/cjs/lib/entity/vas-access-group.model.d.ts +27 -0
  10. package/cjs/lib/entity/vas-access-group.model.d.ts.map +1 -0
  11. package/cjs/lib/entity/vas-access-group.model.js +68 -0
  12. package/cjs/lib/entity/vas-access-group.model.js.map +1 -0
  13. package/cjs/lib/entity/vas-contact-type.model.d.ts +27 -0
  14. package/cjs/lib/entity/vas-contact-type.model.d.ts.map +1 -0
  15. package/cjs/lib/entity/vas-contact-type.model.js +68 -0
  16. package/cjs/lib/entity/vas-contact-type.model.js.map +1 -0
  17. package/cjs/lib/entity/vas-control.model.d.ts +4 -4
  18. package/cjs/lib/entity/vas-control.model.d.ts.map +1 -1
  19. package/cjs/lib/entity/vas-control.model.js +1 -1
  20. package/cjs/lib/entity/vas-control.model.js.map +1 -1
  21. package/cjs/lib/entity/vas-field.dto.d.ts +3 -5
  22. package/cjs/lib/entity/vas-field.dto.d.ts.map +1 -1
  23. package/cjs/lib/entity/vas-field.dto.js.map +1 -1
  24. package/cjs/lib/entity/vas-field.model.d.ts +4 -4
  25. package/cjs/lib/entity/vas-field.model.d.ts.map +1 -1
  26. package/cjs/lib/entity/vas-field.model.js.map +1 -1
  27. package/cjs/lib/entity/vas-form.model.d.ts +3 -3
  28. package/cjs/lib/entity/vas-form.model.d.ts.map +1 -1
  29. package/cjs/lib/entity/vas-form.model.js +1 -1
  30. package/cjs/lib/entity/vas-form.model.js.map +1 -1
  31. package/cjs/lib/entity/vas-group.model.d.ts +2 -2
  32. package/cjs/lib/entity/vas-group.model.d.ts.map +1 -1
  33. package/cjs/lib/entity/vas-group.model.js.map +1 -1
  34. package/cjs/lib/entity/vas-job-status.d.ts +2 -0
  35. package/cjs/lib/entity/vas-job-status.d.ts.map +1 -1
  36. package/cjs/lib/entity/vas-job-status.js +18 -0
  37. package/cjs/lib/entity/vas-job-status.js.map +1 -1
  38. package/cjs/lib/entity/vas-job-type.model.d.ts +23 -0
  39. package/cjs/lib/entity/vas-job-type.model.d.ts.map +1 -0
  40. package/cjs/lib/entity/vas-job-type.model.js +62 -0
  41. package/cjs/lib/entity/vas-job-type.model.js.map +1 -0
  42. package/cjs/lib/entity/vas-job.dto.d.ts +3 -6
  43. package/cjs/lib/entity/vas-job.dto.d.ts.map +1 -1
  44. package/cjs/lib/entity/vas-job.dto.js.map +1 -1
  45. package/cjs/lib/entity/vas-job.model.d.ts +10 -133
  46. package/cjs/lib/entity/vas-job.model.d.ts.map +1 -1
  47. package/cjs/lib/entity/vas-job.model.js +97 -324
  48. package/cjs/lib/entity/vas-job.model.js.map +1 -1
  49. package/cjs/lib/entity/vas-lookup-type.model.d.ts +23 -0
  50. package/cjs/lib/entity/vas-lookup-type.model.d.ts.map +1 -0
  51. package/cjs/lib/entity/vas-lookup-type.model.js +62 -0
  52. package/cjs/lib/entity/vas-lookup-type.model.js.map +1 -0
  53. package/cjs/lib/entity/vas-membership.model.d.ts +2 -0
  54. package/cjs/lib/entity/vas-membership.model.d.ts.map +1 -1
  55. package/cjs/lib/entity/vas-membership.model.js +29 -0
  56. package/cjs/lib/entity/vas-membership.model.js.map +1 -1
  57. package/cjs/lib/entity/vas-task-type.model.d.ts +23 -0
  58. package/cjs/lib/entity/vas-task-type.model.d.ts.map +1 -0
  59. package/cjs/lib/entity/vas-task-type.model.js +62 -0
  60. package/cjs/lib/entity/vas-task-type.model.js.map +1 -0
  61. package/cjs/lib/entity/vas-user.model.d.ts +1 -0
  62. package/cjs/lib/entity/vas-user.model.d.ts.map +1 -1
  63. package/cjs/lib/entity/vas-user.model.js +8 -0
  64. package/cjs/lib/entity/vas-user.model.js.map +1 -1
  65. package/cjs/lib/model/firebase-document-meta.interface.d.ts +6 -0
  66. package/cjs/lib/model/firebase-document-meta.interface.d.ts.map +1 -0
  67. package/cjs/lib/model/firebase-document-meta.interface.js +3 -0
  68. package/cjs/lib/model/firebase-document-meta.interface.js.map +1 -0
  69. package/cjs/lib/model/index.d.ts +1 -0
  70. package/cjs/lib/model/index.d.ts.map +1 -1
  71. package/cjs/lib/model/index.js +1 -0
  72. package/cjs/lib/model/index.js.map +1 -1
  73. package/cjs/lib/utils/get-value-by-path.d.ts +2 -3
  74. package/cjs/lib/utils/get-value-by-path.d.ts.map +1 -1
  75. package/cjs/lib/utils/get-value-by-path.js +1 -1
  76. package/cjs/lib/utils/get-value-by-path.js.map +1 -1
  77. package/cjs/lib/utils/is-plain-object.d.ts +2 -0
  78. package/cjs/lib/utils/is-plain-object.d.ts.map +1 -0
  79. package/cjs/lib/utils/is-plain-object.js +7 -0
  80. package/cjs/lib/utils/is-plain-object.js.map +1 -0
  81. package/cjs/lib/utils/try-json.d.ts +6 -0
  82. package/cjs/lib/utils/try-json.d.ts.map +1 -0
  83. package/cjs/lib/utils/try-json.js +20 -0
  84. package/cjs/lib/utils/try-json.js.map +1 -0
  85. package/fesm2022/ironcode-vas-lib.mjs +556 -349
  86. package/fesm2022/ironcode-vas-lib.mjs.map +1 -1
  87. package/lib/control-value/vas-camera-control-value.model.d.ts +2 -0
  88. package/lib/entity/index.d.ts +5 -0
  89. package/lib/entity/vas-access-group.model.d.ts +26 -0
  90. package/lib/entity/vas-contact-type.model.d.ts +26 -0
  91. package/lib/entity/vas-control.model.d.ts +4 -4
  92. package/lib/entity/vas-field.dto.d.ts +3 -5
  93. package/lib/entity/vas-field.model.d.ts +4 -4
  94. package/lib/entity/vas-form.model.d.ts +3 -3
  95. package/lib/entity/vas-group.model.d.ts +2 -2
  96. package/lib/entity/vas-job-status.d.ts +2 -0
  97. package/lib/entity/vas-job-type.model.d.ts +22 -0
  98. package/lib/entity/vas-job.dto.d.ts +3 -6
  99. package/lib/entity/vas-job.model.d.ts +10 -133
  100. package/lib/entity/vas-lookup-type.model.d.ts +22 -0
  101. package/lib/entity/vas-membership.model.d.ts +2 -0
  102. package/lib/entity/vas-task-type.model.d.ts +22 -0
  103. package/lib/entity/vas-user.model.d.ts +1 -0
  104. package/lib/model/firebase-document-meta.interface.d.ts +5 -0
  105. package/lib/model/index.d.ts +1 -0
  106. package/lib/utils/get-value-by-path.d.ts +2 -3
  107. package/lib/utils/is-plain-object.d.ts +1 -0
  108. package/lib/utils/try-json.d.ts +5 -0
  109. package/package.json +1 -1
  110. package/cjs/lib/entity/vas-job.model.spec-data.d.ts +0 -2
  111. package/cjs/lib/entity/vas-job.model.spec-data.d.ts.map +0 -1
  112. package/cjs/lib/entity/vas-job.model.spec-data.js +0 -29
  113. package/cjs/lib/entity/vas-job.model.spec-data.js.map +0 -1
  114. package/lib/utils/is-array-string.d.ts +0 -1
@@ -1,3 +1,4 @@
1
+ import { VasFileDto } from '../entity';
1
2
  export interface VasCameraControlValueModel {
2
3
  webPath: string;
3
4
  path: string;
@@ -5,3 +6,4 @@ export interface VasCameraControlValueModel {
5
6
  id?: string;
6
7
  }
7
8
  export declare function isCameraControlValueV1(object: any): object is VasCameraControlValueModel;
9
+ export declare function isCameraControlValueV2(object: any): object is VasFileDto;
@@ -1,5 +1,6 @@
1
1
  export * from './step-model.factory';
2
2
  export * from './vas-access-group.dto';
3
+ export * from './vas-access-group.model';
3
4
  export * from './vas-account-config.dto';
4
5
  export * from './vas-account-object.dto';
5
6
  export * from './vas-account-object.model';
@@ -8,6 +9,7 @@ export * from './vas-base.dto';
8
9
  export * from './vas-base.model';
9
10
  export * from './vas-branch.dto';
10
11
  export * from './vas-branch.model';
12
+ export * from './vas-contact-type.model';
11
13
  export * from './vas-contact-type.dto';
12
14
  export * from './vas-contact.dto';
13
15
  export * from './vas-contact.model';
@@ -53,9 +55,11 @@ export * from './vas-job-email.dto';
53
55
  export * from './vas-job-email.model';
54
56
  export * from './vas-job-status';
55
57
  export * from './vas-job-type.dto';
58
+ export * from './vas-job-type.model';
56
59
  export * from './vas-job.dto';
57
60
  export * from './vas-job.model';
58
61
  export * from './vas-lookup-type.dto';
62
+ export * from './vas-lookup-type.model';
59
63
  export * from './vas-lookup.dto';
60
64
  export * from './vas-lookup.model';
61
65
  export * from './vas-membership.dto';
@@ -71,6 +75,7 @@ export * from './vas-report.model';
71
75
  export * from './vas-restricted-account-object.dto';
72
76
  export * from './vas-restricted-account-object.model';
73
77
  export * from './vas-task-type.dto';
78
+ export * from './vas-task-type.model';
74
79
  export * from './vas-task.dto';
75
80
  export * from './vas-task.model';
76
81
  export * from './vas-user.dto';
@@ -0,0 +1,26 @@
1
+ import { VasAccountObjectModel } from './vas-account-object.model';
2
+ import { VasAccessGroupDto } from './vas-access-group.dto';
3
+ /**
4
+ * VasAccessGroupModel
5
+ */
6
+ export declare class VasAccessGroupModel extends VasAccountObjectModel {
7
+ id: string;
8
+ created: string;
9
+ serverCreated: string;
10
+ createdBy: string;
11
+ modified: string;
12
+ serverModified: string;
13
+ modifiedBy: string;
14
+ createdByName: string;
15
+ modifiedByName: string;
16
+ account: string;
17
+ title: string;
18
+ sequence: number;
19
+ categoryGroups: Array<string>;
20
+ constructor(id: string, created: string, serverCreated: string, createdBy: string, modified: string, serverModified: string, modifiedBy: string, createdByName: string, modifiedByName: string, account: string, title: string, sequence: number, categoryGroups: Array<string>);
21
+ static empty(): VasAccessGroupModel;
22
+ toDto(): VasAccessGroupDto;
23
+ static fromDto(dto: Partial<VasAccessGroupDto>): VasAccessGroupModel;
24
+ static toApiCreateDto(dto: Partial<VasAccessGroupDto>): Partial<VasAccessGroupDto>;
25
+ static toApiUpdateDto(dto: Partial<VasAccessGroupDto>): Partial<VasAccessGroupDto>;
26
+ }
@@ -0,0 +1,26 @@
1
+ import { VasAccountObjectModel } from './vas-account-object.model';
2
+ import { VasContactTypeDto } from './vas-contact-type.dto';
3
+ /**
4
+ * VasContactTypeModel
5
+ */
6
+ export declare class VasContactTypeModel extends VasAccountObjectModel {
7
+ id: string;
8
+ created: string;
9
+ serverCreated: string;
10
+ createdBy: string;
11
+ modified: string;
12
+ serverModified: string;
13
+ modifiedBy: string;
14
+ createdByName: string;
15
+ modifiedByName: string;
16
+ account: string;
17
+ title: string;
18
+ sequence: number;
19
+ categoryGroups: Array<string>;
20
+ constructor(id: string, created: string, serverCreated: string, createdBy: string, modified: string, serverModified: string, modifiedBy: string, createdByName: string, modifiedByName: string, account: string, title: string, sequence: number, categoryGroups: Array<string>);
21
+ static empty(): VasContactTypeModel;
22
+ toDto(): VasContactTypeDto;
23
+ static fromDto(dto: Partial<VasContactTypeDto>): VasContactTypeModel;
24
+ static toApiCreateDto(dto: Partial<VasContactTypeDto>): Partial<VasContactTypeDto>;
25
+ static toApiUpdateDto(dto: Partial<VasContactTypeDto>): Partial<VasContactTypeDto>;
26
+ }
@@ -1,7 +1,7 @@
1
1
  import { VasControlTypeModel } from './vas-control-type.model';
2
2
  import { VasControlDto } from './vas-control.dto';
3
3
  import { VasRestrictedAccountObjectModel } from './vas-restricted-account-object.model';
4
- import { VasFieldDtoValue } from './vas-field.dto';
4
+ import { FieldValueType } from './vas-field.dto';
5
5
  export declare type VasControlModelDefaultValueType = string | number | object;
6
6
  /**
7
7
  * ControlModel
@@ -39,7 +39,7 @@ export declare class VasControlModel extends VasRestrictedAccountObjectModel {
39
39
  * in the case of string, it maybe a json. This getter will return an
40
40
  * object if the value is a json string
41
41
  */
42
- get defaultValueDecoded(): VasFieldDtoValue;
42
+ get defaultValueDecoded(): FieldValueType;
43
43
  /**
44
44
  * Returns the name of this control to be used in the report templates
45
45
  * i.e. fields.foo -> foo
@@ -61,9 +61,9 @@ export declare class VasControlModel extends VasRestrictedAccountObjectModel {
61
61
  static fromDto(dto: Partial<VasControlDto>): VasControlModel;
62
62
  /**
63
63
  * @param {any} value the value to be parsed
64
- * @return {VasFieldDtoValue} the parsed value
64
+ * @return {FieldValueType} the parsed value
65
65
  */
66
- protected parseMaybeJson(value: any): VasFieldDtoValue;
66
+ protected parseMaybeJson(value: any): FieldValueType;
67
67
  /**
68
68
  * @return {VasControlDto}
69
69
  */
@@ -1,17 +1,15 @@
1
1
  import { VasJobDataDto } from './vas-job-data.dto';
2
2
  import { VasFileDto } from './vas-file.dto';
3
- import { GeoLocation } from '../model/geo-location';
3
+ import { GeoLocation } from '../model';
4
4
  import { VasFunctionControlValueDto } from '../control-value';
5
5
  import { VasCameraControlValueModel } from '../control-value';
6
- declare type FieldValueType = string | number | boolean | null | GeoLocation | Array<object | string | number | boolean | VasFileDto> | Record<string, any> | VasCameraControlValueModel | VasFunctionControlValueDto;
7
- export declare type VasFieldDtoValue = FieldValueType | Record<string, FieldValueType>;
6
+ export declare type FieldValueType = string | number | boolean | null | GeoLocation | Array<object | string | number | boolean | VasFileDto> | Record<string, any> | VasCameraControlValueModel | VasFunctionControlValueDto;
8
7
  export interface VasFieldDto extends VasJobDataDto {
9
8
  control: string;
10
9
  fieldJobPointers: Array<string>;
11
- value: VasFieldDtoValue;
10
+ value: FieldValueType;
12
11
  version: number;
13
12
  controlName: string;
14
13
  controlTitle: string;
15
14
  controlTypeName: string;
16
15
  }
17
- export {};
@@ -1,4 +1,4 @@
1
- import { VasFieldDto, VasFieldDtoValue } from './vas-field.dto';
1
+ import { VasFieldDto, FieldValueType } from './vas-field.dto';
2
2
  import { VasJobDataModel } from './vas-job-data.model';
3
3
  /**
4
4
  * Prepares the value to be sent to the API. The api will only accept strings,
@@ -8,7 +8,7 @@ import { VasJobDataModel } from './vas-job-data.model';
8
8
  * @return {string | number | boolean}
9
9
  * @protected
10
10
  */
11
- export declare const prepareFieldApiValue: (value: VasFieldDtoValue) => string | number | boolean;
11
+ export declare const prepareFieldApiValue: (value: FieldValueType) => string | number | boolean;
12
12
  /**
13
13
  * VasFieldModel
14
14
  */
@@ -26,12 +26,12 @@ export declare class VasFieldModel extends VasJobDataModel {
26
26
  job: string;
27
27
  control: string;
28
28
  fieldJobPointers: Array<string>;
29
- value: VasFieldDtoValue;
29
+ value: FieldValueType;
30
30
  version: number;
31
31
  controlName: string;
32
32
  controlTitle: string;
33
33
  controlTypeName: string;
34
- constructor(id: string, created: string, serverCreated: string, createdBy: string, modified: string, serverModified: string, modifiedBy: string, createdByName: string, modifiedByName: string, account: string, job: string, control: string, fieldJobPointers: Array<string>, value: VasFieldDtoValue, version: number, controlName: string, controlTitle: string, controlTypeName: string);
34
+ constructor(id: string, created: string, serverCreated: string, createdBy: string, modified: string, serverModified: string, modifiedBy: string, createdByName: string, modifiedByName: string, account: string, job: string, control: string, fieldJobPointers: Array<string>, value: FieldValueType, version: number, controlName: string, controlTitle: string, controlTypeName: string);
35
35
  /**
36
36
  * @param {VasFieldDto} fieldDto
37
37
  * @return {VasFieldModel}
@@ -1,7 +1,7 @@
1
1
  import { VasRestrictedAccountObjectModel } from './vas-restricted-account-object.model';
2
2
  import { VasControlTypeDto } from './vas-control-type.dto';
3
3
  import { VasControlModel } from './vas-control.model';
4
- import { VasFieldDtoValue } from './vas-field.dto';
4
+ import { FieldValueType } from './vas-field.dto';
5
5
  import { VasFormDto } from './vas-form.dto';
6
6
  import { VasGroupModel } from './vas-group.model';
7
7
  import { VasJobModel } from './vas-job.model';
@@ -78,11 +78,11 @@ export declare class VasFormModel extends VasRestrictedAccountObjectModel {
78
78
  getControls(): Array<VasControlModel>;
79
79
  /**
80
80
  * @param {VasJobModel} jobModel
81
- * @return {Array<{id: string, value: VasFieldDtoValue}>}
81
+ * @return {Array<{id: string, value: FieldValueType}>}
82
82
  */
83
83
  getValuesByControlId(jobModel: VasJobModel): Array<{
84
84
  id: string;
85
- value: VasFieldDtoValue | undefined;
85
+ value: FieldValueType | undefined;
86
86
  }>;
87
87
  /**
88
88
  * @return {VasFormDto}
@@ -1,6 +1,6 @@
1
1
  import { VasControlModel } from './vas-control.model';
2
2
  import { VasGroupDto } from './vas-group.dto';
3
- import { VasFieldDtoValue } from './vas-field.dto';
3
+ import { FieldValueType } from './vas-field.dto';
4
4
  import { VasRestrictedAccountObjectModel } from './vas-restricted-account-object.model';
5
5
  /**
6
6
  * GroupModel
@@ -39,7 +39,7 @@ export declare class VasGroupModel extends VasRestrictedAccountObjectModel {
39
39
  */
40
40
  isVisible(valuesByControlId: Array<{
41
41
  id: string;
42
- value: VasFieldDtoValue | undefined;
42
+ value: FieldValueType | undefined;
43
43
  }>): boolean;
44
44
  /**
45
45
  * @return {VasGroupDto}
@@ -24,4 +24,6 @@ export declare class VasJobStatusModel extends VasAccountObjectModel {
24
24
  constructor(id: string, created: string, serverCreated: string, createdBy: string, modified: string, serverModified: string, modifiedBy: string, createdByName: string, modifiedByName: string, account: string, title: string, sequence: number, categoryGroups: Array<string>, closed: boolean);
25
25
  static fromDto(dto: Partial<VasJobStatusDto>): VasJobStatusModel;
26
26
  toDto(): VasJobStatusDto;
27
+ static toApiCreateDto(dto: Partial<VasJobStatusDto>): Partial<VasJobStatusDto>;
28
+ static toApiUpdateDto(dto: Partial<VasJobStatusDto>): Partial<VasJobStatusDto>;
27
29
  }
@@ -0,0 +1,22 @@
1
+ import { VasAccountObjectModel } from './vas-account-object.model';
2
+ import { VasJobTypeDto } from './vas-job-type.dto';
3
+ export declare class VasJobTypeModel extends VasAccountObjectModel {
4
+ id: string;
5
+ created: string;
6
+ serverCreated: string;
7
+ createdBy: string;
8
+ modified: string;
9
+ serverModified: string;
10
+ modifiedBy: string;
11
+ createdByName: string;
12
+ modifiedByName: string;
13
+ account: string;
14
+ title: string;
15
+ sequence: number;
16
+ categoryGroups: Array<string>;
17
+ constructor(id: string, created: string, serverCreated: string, createdBy: string, modified: string, serverModified: string, modifiedBy: string, createdByName: string, modifiedByName: string, account: string, title: string, sequence: number, categoryGroups: Array<string>);
18
+ static fromDto(dto: Partial<VasJobTypeDto>): VasJobTypeModel;
19
+ toDto(): VasJobTypeDto;
20
+ static toApiCreateDto(dto: Partial<VasJobTypeDto>): Partial<VasJobTypeDto>;
21
+ static toApiUpdateDto(dto: Partial<VasJobTypeDto>): Partial<VasJobTypeDto>;
22
+ }
@@ -1,13 +1,13 @@
1
1
  import { VasFileDto } from './vas-file.dto';
2
2
  import { VasRestrictedAccountObjectDto } from './vas-restricted-account-object.dto';
3
- import { VasFieldDto, VasFieldDtoValue } from './vas-field.dto';
3
+ import { FieldValueType } from './vas-field.dto';
4
4
  import { GeoLocation } from '../model';
5
5
  import { VasReportDto } from './vas-report.dto';
6
6
  import { VasTaskDto } from './vas-task.dto';
7
7
  import { VasNoteDto } from './vas-note.dto';
8
8
  import { VasJobEmailDto } from './vas-job-email.dto';
9
9
  import { VasInstructionDto } from './vas-instruction.dto';
10
- export interface VasJobStaticDto extends VasRestrictedAccountObjectDto {
10
+ export interface VasJobDto extends VasRestrictedAccountObjectDto {
11
11
  reference: string;
12
12
  jobDate: string;
13
13
  jobStatus: string;
@@ -18,15 +18,12 @@ export interface VasJobStaticDto extends VasRestrictedAccountObjectDto {
18
18
  pendingFields: number;
19
19
  childModified: string;
20
20
  version: number;
21
- createdByDisplayName: string;
22
- modifiedByDisplayName: string;
23
21
  geoLocation: GeoLocation;
24
22
  files: Array<VasFileDto>;
25
- fields: Array<VasFieldDto>;
23
+ fields: Record<string, FieldValueType>;
26
24
  jobEmails: Array<VasJobEmailDto>;
27
25
  notes: Array<VasNoteDto>;
28
26
  reports: Array<VasReportDto>;
29
27
  tasks: Array<VasTaskDto>;
30
28
  instruction: null | VasInstructionDto;
31
29
  }
32
- export declare type VasJobDto = VasJobStaticDto & Record<string, VasFieldDtoValue>;
@@ -1,22 +1,18 @@
1
1
  import { VasFileDto } from './vas-file.dto';
2
2
  import { VasBaseDto } from './vas-base.dto';
3
- import { VasFieldDto, VasFieldDtoValue } from './vas-field.dto';
3
+ import { FieldValueType } from './vas-field.dto';
4
4
  import { VasFormModel } from './vas-form.model';
5
5
  import { VasJobDto } from './vas-job.dto';
6
6
  import { VasRestrictedAccountObjectModel } from './vas-restricted-account-object.model';
7
7
  import { GeoLocation } from '../model';
8
- import { VasFormDto } from './vas-form.dto';
9
8
  import { VasReportDto } from './vas-report.dto';
10
9
  import { VasTaskDto } from './vas-task.dto';
11
10
  import { VasNoteDto } from './vas-note.dto';
12
11
  import { VasJobEmailDto } from './vas-job-email.dto';
13
12
  import { VasInstructionDto } from './vas-instruction.dto';
14
- export declare interface VasJobModelDynamicInterface {
15
- [s: string]: string | number | Record<string, VasFieldDtoValue>;
16
- }
17
13
  export interface ParseSyntaxOptions {
18
14
  timeZoneOffset: number;
19
- objects?: Record<string, Partial<VasBaseDto> | Record<string, VasFieldDtoValue>>;
15
+ objects?: Record<string, Partial<VasBaseDto> | Record<string, FieldValueType>>;
20
16
  }
21
17
  /**
22
18
  * JobModel
@@ -43,58 +39,26 @@ export declare class VasJobModel extends VasRestrictedAccountObjectModel {
43
39
  pendingFields: number;
44
40
  childModified: string;
45
41
  version: number;
46
- createdByDisplayName: string;
47
- modifiedByDisplayName: string;
48
42
  geoLocation: GeoLocation;
49
43
  files: Array<VasFileDto>;
50
- fields: Array<VasFieldDto>;
44
+ fields: Record<string, FieldValueType>;
51
45
  jobEmails: Array<VasJobEmailDto>;
52
46
  notes: Array<VasNoteDto>;
53
47
  reports: Array<VasReportDto>;
54
48
  tasks: Array<VasTaskDto>;
55
49
  instruction: VasInstructionDto | null;
56
- constructor(id: string, created: string, serverCreated: string, createdBy: string, modified: string, serverModified: string, modifiedBy: string, createdByName: string, modifiedByName: string, account: string, accessGroup: string, reference: string, jobDate: string, jobStatus: string, jobType: string, assigneeId: string, formId: string, timeZoneOffset: number, pendingFields: number, childModified: string, version: number, createdByDisplayName: string, modifiedByDisplayName: string, geoLocation: GeoLocation, files: Array<VasFileDto>, fields: Array<VasFieldDto>, jobEmails: Array<VasJobEmailDto>, notes: Array<VasNoteDto>, reports: Array<VasReportDto>, tasks: Array<VasTaskDto>, instruction: VasInstructionDto | null);
57
- /**
58
- * Returns this with the dynamic interface
59
- * @return {VasJobModelDynamicInterface}
60
- */
61
- get $this(): VasJobModelDynamicInterface;
50
+ constructor(id: string, created: string, serverCreated: string, createdBy: string, modified: string, serverModified: string, modifiedBy: string, createdByName: string, modifiedByName: string, account: string, accessGroup: string, reference: string, jobDate: string, jobStatus: string, jobType: string, assigneeId: string, formId: string, timeZoneOffset: number, pendingFields: number, childModified: string, version: number, geoLocation: GeoLocation, files: Array<VasFileDto>, fields: Record<string, FieldValueType>, jobEmails: Array<VasJobEmailDto>, notes: Array<VasNoteDto>, reports: Array<VasReportDto>, tasks: Array<VasTaskDto>, instruction: VasInstructionDto | null);
51
+ get createdByDisplayName(): string;
52
+ get modifiedByDisplayName(): string;
62
53
  /**
63
- * Returns a list of Job dynamic properties i.e. those that are added by the
64
- * dynamic forms
54
+ * Return the list of Job properties
65
55
  */
66
- get dynamicProperties(): Array<string>;
67
- /**
68
- * Returns the list of properties of the Job type
69
- */
70
- get staticProperties(): Array<string>;
56
+ get staticProperties(): Set<string>;
71
57
  /**
72
58
  * @return {VasJobModel}
73
59
  */
74
60
  static empty(): VasJobModel;
75
61
  static fromDto(dto: Partial<VasJobDto>): VasJobModel;
76
- /**
77
- * This method will instantiate a new JobModel. The difference with this
78
- * method of instantiation is that we are coming from a relation frame i.e.
79
- * the job has a list of {@link VasFieldDto} instead of a Job document.
80
- *
81
- */
82
- static fromRelational(dto: Partial<VasJobDto>, form: VasFormDto): VasJobModel;
83
- /**
84
- * @param {VasFormModel} formModel
85
- * @return {Record<string, VasFieldDtoValue>}
86
- */
87
- getFields(formModel: VasFormModel): Record<string, VasFieldDtoValue>;
88
- /**
89
- * Will return an object whose keys are the names of all fields in the job.
90
- * This method is similar to `getFields` except that this method will only
91
- * return values where a value was set, as opposed to `getFields` which will
92
- * return a value for every control even if no value was set, because it uses
93
- * the form to drive the logic. Note also this method will return values for
94
- * any Fields in the fields array.
95
- * @return {Record<string, VasFieldDtoValue>}
96
- */
97
- getFields2(): Record<string, VasFieldDtoValue>;
98
62
  /**
99
63
  * Returns an object describing how many attachments were added to this job
100
64
  * (camera controls and files), and how many have not been uploaded yet.
@@ -107,97 +71,10 @@ export declare class VasJobModel extends VasRestrictedAccountObjectModel {
107
71
  total: number;
108
72
  };
109
73
  /**
110
- * This method will return the dynamic property from the JobModel that
111
- * represent a group (from a form).
112
- *
113
- * @param name the name of the group
114
- * @param init if true (default) and group is not found, initialise an empty
115
- * group, otherwise throw an error
116
- */
117
- getGroup(name: string, init?: boolean): Record<string, VasFieldDtoValue>;
118
- /**
119
- * @param path path segments
120
- */
121
- getValueByPath<T extends VasFieldDtoValue>(path?: string[]): T | undefined;
122
- /**
123
- * In order to understand why we need this method it is important to
124
- * understand that within the system, Jobs can be represented in one of two
125
- * ways, document and relational.
126
- *
127
- * The important distinction is how values submitted by a form are stored.
128
- *
129
- * Jobs stored as documents (JSON objects) will store user values, as dynamic
130
- * properties of the document.
131
- *
132
- * Whereas, Jobs stored as relational, will store user values in an array of
133
- * {@link VasFieldDto} objects.
134
- *
135
- * Depending on where we are in the system, either one of these approaches can
136
- * be more useful than the other.
137
- *
138
- * This method, assumes that the JobModel has been instantiated from a
139
- * document representation, and serves to hydrate the fields array. In order
140
- * to achieve this, knowledge of the {@link VasFormDto} that created the job
141
- * is required.
142
- *
143
- *
144
- * Job in document representation
145
- * {
146
- * id: <guid>,
147
- * reference: "something"
148
- * <other static job properties>...
149
- * foo: {
150
- * bar: "value"
151
- * }
152
- * }
153
- *
154
- * Job in relational representation
155
- * {
156
- * id: <guid>,
157
- * reference: "something"
158
- * <other static job properties>...
159
- * <will not have dynamic properties>...
160
- * fields: [
161
- * {
162
- * id: <guid>,
163
- * <other field properties>,
164
- * value: "value"
165
- * }
166
- * ]
167
- * }
168
- *
169
- *
170
- * @param formModel the VasFormModel that was used to create the job
171
- * @param controlFieldIdMap This is used to determine the id each field.
172
- * Either one will be found in the map, or a new one is generated.
173
- * @param controlNames if a value is provided, it will be used
174
- * to filter the fields that are returned.
175
- * @return {Array<VasFieldDto>}
176
- */
177
- hydrateFields(formModel: VasFormModel, controlFieldIdMap?: Map<string, string>, controlNames?: Array<string>): void;
178
- /**
179
- * A very non sophisticated way to set values in the job via paths
180
- *
181
- * For example:
182
- *
183
- * setValueByPath('value', ['foo', 'bar']);
184
- *
185
- * will make results in job
186
- * {
187
- * foo: {
188
- * bar: 'value'
189
- * }
190
- * }
191
- *
192
- * @param value the value to set
193
74
  * @param path path segments
194
75
  */
195
- setValueByPath(value: VasFieldDtoValue, path?: string[]): void;
196
- /**
197
- * @param staticOnly if true, will only output values for the static
198
- * properties in the dto
199
- */
200
- toDto(staticOnly?: boolean): VasJobDto;
76
+ getValueByPath<T>(path?: string | string[]): T | undefined;
77
+ toDto(): VasJobDto;
201
78
  /**
202
79
  * This method will parse a syntax that allows us to build strings from the
203
80
  * values of from the job model. For example if the job model was:
@@ -0,0 +1,22 @@
1
+ import { VasAccountObjectModel } from './vas-account-object.model';
2
+ import { VasLookupTypeDto } from './vas-lookup-type.dto';
3
+ export declare class VasLookupTypeModel extends VasAccountObjectModel {
4
+ id: string;
5
+ created: string;
6
+ serverCreated: string;
7
+ createdBy: string;
8
+ modified: string;
9
+ serverModified: string;
10
+ modifiedBy: string;
11
+ createdByName: string;
12
+ modifiedByName: string;
13
+ account: string;
14
+ title: string;
15
+ sequence: number;
16
+ categoryGroups: Array<string>;
17
+ constructor(id: string, created: string, serverCreated: string, createdBy: string, modified: string, serverModified: string, modifiedBy: string, createdByName: string, modifiedByName: string, account: string, title: string, sequence: number, categoryGroups: Array<string>);
18
+ static fromDto(dto: Partial<VasLookupTypeDto>): VasLookupTypeModel;
19
+ toDto(): VasLookupTypeDto;
20
+ static toApiCreateDto(dto: Partial<VasLookupTypeDto>): Partial<VasLookupTypeDto>;
21
+ static toApiUpdateDto(dto: Partial<VasLookupTypeDto>): Partial<VasLookupTypeDto>;
22
+ }
@@ -26,4 +26,6 @@ export declare class VasMembershipModel extends VasAccountObjectModel {
26
26
  static empty(): VasMembershipModel;
27
27
  static fromDto(dto: Partial<VasMembershipDto>): VasMembershipModel;
28
28
  toDto(): VasMembershipDto;
29
+ static toApiCreateDto(dto: Partial<VasMembershipDto>): Partial<VasMembershipDto>;
30
+ static toApiUpdateDto(dto: Partial<VasMembershipDto>): Partial<VasMembershipDto>;
29
31
  }
@@ -0,0 +1,22 @@
1
+ import { VasAccountObjectModel } from './vas-account-object.model';
2
+ import { VasTaskTypeDto } from './vas-task-type.dto';
3
+ export declare class VasTaskTypeModel extends VasAccountObjectModel {
4
+ id: string;
5
+ created: string;
6
+ serverCreated: string;
7
+ createdBy: string;
8
+ modified: string;
9
+ serverModified: string;
10
+ modifiedBy: string;
11
+ createdByName: string;
12
+ modifiedByName: string;
13
+ account: string;
14
+ title: string;
15
+ sequence: number;
16
+ categoryGroups: Array<string>;
17
+ constructor(id: string, created: string, serverCreated: string, createdBy: string, modified: string, serverModified: string, modifiedBy: string, createdByName: string, modifiedByName: string, account: string, title: string, sequence: number, categoryGroups: Array<string>);
18
+ static fromDto(dto: Partial<VasTaskTypeDto>): VasTaskTypeModel;
19
+ toDto(): VasTaskTypeDto;
20
+ static toApiCreateDto(dto: Partial<VasTaskTypeDto>): Partial<VasTaskTypeDto>;
21
+ static toApiUpdateDto(dto: Partial<VasTaskTypeDto>): Partial<VasTaskTypeDto>;
22
+ }
@@ -18,4 +18,5 @@ export declare class VasUserModel extends VasBaseModel implements VasUserDto {
18
18
  constructor(id: string, created: string | undefined, serverCreated: string | undefined, createdBy: string | undefined, modified: string | undefined, serverModified: string | undefined, modifiedBy: string | undefined, createdByName: string, modifiedByName: string, email: string, name: string, username: string, memberships: Array<string>, instructionProviders: Array<string>);
19
19
  static fromDto(dto: Partial<VasUserDto>): VasUserModel;
20
20
  toDto(): VasUserDto;
21
+ static toApiPatchDto(dto: Partial<VasUserDto>): Partial<VasUserDto>;
21
22
  }
@@ -0,0 +1,5 @@
1
+ export interface FirebaseDocumentMetaInterface {
2
+ _meta: {
3
+ source: 'client' | 'server';
4
+ };
5
+ }
@@ -1,2 +1,3 @@
1
+ export * from './firebase-document-meta.interface';
1
2
  export * from './geo-location';
2
3
  export * from './vas-time-range.model';
@@ -1,4 +1,3 @@
1
- import { VasFieldDtoValue } from '../entity/vas-field.dto';
2
1
  /**
3
2
  * A non sophisticated way to get values from the job via paths. For example:
4
3
  *
@@ -13,7 +12,7 @@ import { VasFieldDtoValue } from '../entity/vas-field.dto';
13
12
  *
14
13
  * will return "value"
15
14
  * @param {string[]} path
16
- * @param {Record<string, VasFieldDtoValue>} object
15
+ * @param {Record<string, FieldValueType>} object
17
16
  * @return {T | undefined}
18
17
  */
19
- export declare const getValueByPath: <T extends VasFieldDtoValue>(path: string[], object: Record<string, VasFieldDtoValue | Record<string, VasFieldDtoValue>>) => T | undefined;
18
+ export declare const getValueByPath: <T>(path: string[], object: Record<string, any>) => T | undefined;
@@ -0,0 +1 @@
1
+ export declare function isPlainObject<T>(value: any): value is T;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Try to parse the value as JSON if it looks like a JSON encoded string
3
+ * @param value
4
+ */
5
+ export declare const tryJson: <T>(value: T) => Record<string, any> | T;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ironcode/vas-lib",
3
- "version": "2.2.0",
3
+ "version": "3.0.0-alpha.1",
4
4
  "peerDependencies": {
5
5
  "angular2-uuid": "^1.1.1",
6
6
  "moment": "^2.0.0"
@@ -1,2 +0,0 @@
1
- export declare const formDto1Group1Control: import("@ironcode/vas-lib").VasFormDto;
2
- //# sourceMappingURL=vas-job.model.spec-data.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vas-job.model.spec-data.d.ts","sourceRoot":"","sources":["../../../../../projects/vas-lib/src/lib/entity/vas-job.model.spec-data.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,qBAAqB,wCAsBxB,CAAC"}
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formDto1Group1Control = void 0;
4
- const vas_lib_1 = require("@ironcode/vas-lib");
5
- const vas_lib_2 = require("@ironcode/vas-lib");
6
- const vas_lib_3 = require("@ironcode/vas-lib");
7
- const vas_lib_4 = require("@ironcode/vas-lib");
8
- exports.formDto1Group1Control = vas_lib_3.VasFormModel.fromDto({
9
- id: 'form',
10
- geoLocationEnabled: false,
11
- groups: [
12
- vas_lib_2.VasGroupModel.fromDto({
13
- id: 'group',
14
- name: 'groupa',
15
- title: 'Group A',
16
- scoreWeight: 1,
17
- controls: [
18
- vas_lib_4.VasControlModel.fromDto({
19
- id: 'control',
20
- controlType: vas_lib_1.VasControlTypeModel.fromDto({
21
- name: 'text'
22
- }).toDto(),
23
- name: 'fields.foo'
24
- }).toDto()
25
- ],
26
- }).toDto()
27
- ],
28
- }).toDto();
29
- //# sourceMappingURL=vas-job.model.spec-data.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vas-job.model.spec-data.js","sourceRoot":"","sources":["../../../../../projects/vas-lib/src/lib/entity/vas-job.model.spec-data.ts"],"names":[],"mappings":";;;AAAA,+CAAwD;AACxD,+CAAkD;AAClD,+CAAiD;AACjD,+CAAoD;AAEvC,QAAA,qBAAqB,GAAG,sBAAY,CAAC,OAAO,CAAC;IACxD,EAAE,EAAE,MAAM;IACV,kBAAkB,EAAE,KAAK;IACzB,MAAM,EAAE;QACN,uBAAa,CAAC,OAAO,CACnB;YACE,EAAE,EAAE,OAAO;YACX,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,SAAS;YAChB,WAAW,EAAE,CAAC;YACd,QAAQ,EAAE;gBACR,yBAAe,CAAC,OAAO,CAAC;oBACtB,EAAE,EAAE,SAAS;oBACb,WAAW,EAAE,6BAAmB,CAAC,OAAO,CAAC;wBACvC,IAAI,EAAE,MAAM;qBACb,CAAC,CAAC,KAAK,EAAE;oBACV,IAAI,EAAE,YAAY;iBACnB,CAAC,CAAC,KAAK,EAAE;aACX;SACF,CACF,CAAC,KAAK,EAAE;KACV;CACF,CAAC,CAAC,KAAK,EAAE,CAAC","sourcesContent":["import { VasControlTypeModel } from '@ironcode/vas-lib';\nimport { VasGroupModel } from '@ironcode/vas-lib';\nimport { VasFormModel } from '@ironcode/vas-lib';\nimport { VasControlModel } from '@ironcode/vas-lib';\n\nexport const formDto1Group1Control = VasFormModel.fromDto({\n id: 'form',\n geoLocationEnabled: false,\n groups: [\n VasGroupModel.fromDto(\n {\n id: 'group',\n name: 'groupa',\n title: 'Group A',\n scoreWeight: 1,\n controls: [\n VasControlModel.fromDto({\n id: 'control',\n controlType: VasControlTypeModel.fromDto({\n name: 'text'\n }).toDto(),\n name: 'fields.foo'\n }).toDto()\n ],\n }\n ).toDto()\n ],\n}).toDto();\n"]}
@@ -1 +0,0 @@
1
- export declare const isArrayString: (value: any) => value is Array<string>;