@ironcode/vas-lib 3.0.0-alpha.2 → 3.0.0-alpha.3

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 (96) hide show
  1. package/cjs/lib/control-value/vas-camera-control-value.model.d.ts +4 -2
  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.map +1 -1
  4. package/cjs/lib/entity/vas-field.dto.d.ts +3 -4
  5. package/cjs/lib/entity/vas-field.dto.d.ts.map +1 -1
  6. package/cjs/lib/entity/vas-field.dto.js.map +1 -1
  7. package/cjs/lib/model/estimate-control/estimate-control-value.dto.d.ts +14 -0
  8. package/cjs/lib/model/estimate-control/estimate-control-value.dto.d.ts.map +1 -0
  9. package/cjs/lib/model/estimate-control/estimate-control-value.dto.js +3 -0
  10. package/cjs/lib/model/estimate-control/estimate-control-value.dto.js.map +1 -0
  11. package/cjs/lib/model/estimate-control/estimate-control-value.model.d.ts +11 -0
  12. package/cjs/lib/model/estimate-control/estimate-control-value.model.d.ts.map +1 -0
  13. package/cjs/lib/model/estimate-control/estimate-control-value.model.js +84 -0
  14. package/cjs/lib/model/estimate-control/estimate-control-value.model.js.map +1 -0
  15. package/cjs/lib/model/estimate-control/estimate-item.dto.d.ts +16 -0
  16. package/cjs/lib/model/estimate-control/estimate-item.dto.d.ts.map +1 -0
  17. package/cjs/lib/model/estimate-control/estimate-item.dto.js +3 -0
  18. package/cjs/lib/model/estimate-control/estimate-item.dto.js.map +1 -0
  19. package/cjs/lib/model/estimate-control/estimate-item.model.d.ts +24 -0
  20. package/cjs/lib/model/estimate-control/estimate-item.model.d.ts.map +1 -0
  21. package/cjs/lib/model/estimate-control/estimate-item.model.js +121 -0
  22. package/cjs/lib/model/estimate-control/estimate-item.model.js.map +1 -0
  23. package/cjs/lib/model/estimate-control/estimate.dto.d.ts +37 -0
  24. package/cjs/lib/model/estimate-control/estimate.dto.d.ts.map +1 -0
  25. package/cjs/lib/model/estimate-control/estimate.dto.js +3 -0
  26. package/cjs/lib/model/estimate-control/estimate.dto.js.map +1 -0
  27. package/cjs/lib/model/estimate-control/estimate.model.d.ts +55 -0
  28. package/cjs/lib/model/estimate-control/estimate.model.d.ts.map +1 -0
  29. package/cjs/lib/model/estimate-control/estimate.model.js +265 -0
  30. package/cjs/lib/model/estimate-control/estimate.model.js.map +1 -0
  31. package/cjs/lib/model/estimate-control/estimate.types.d.ts +3 -0
  32. package/cjs/lib/model/estimate-control/estimate.types.d.ts.map +1 -0
  33. package/cjs/lib/model/estimate-control/estimate.types.js +3 -0
  34. package/cjs/lib/model/estimate-control/estimate.types.js.map +1 -0
  35. package/cjs/lib/model/estimate-control/index.d.ts +8 -0
  36. package/cjs/lib/model/estimate-control/index.d.ts.map +1 -0
  37. package/cjs/lib/model/estimate-control/index.js +11 -0
  38. package/cjs/lib/model/estimate-control/index.js.map +1 -0
  39. package/cjs/lib/model/index.d.ts +2 -0
  40. package/cjs/lib/model/index.d.ts.map +1 -1
  41. package/cjs/lib/model/index.js +2 -0
  42. package/cjs/lib/model/index.js.map +1 -1
  43. package/cjs/lib/model/report-invocation.d.ts +40 -0
  44. package/cjs/lib/model/report-invocation.d.ts.map +1 -0
  45. package/cjs/lib/model/report-invocation.js +3 -0
  46. package/cjs/lib/model/report-invocation.js.map +1 -0
  47. package/cjs/lib/utils/get-value-by-path.d.ts +5 -15
  48. package/cjs/lib/utils/get-value-by-path.d.ts.map +1 -1
  49. package/cjs/lib/utils/get-value-by-path.js +49 -60
  50. package/cjs/lib/utils/get-value-by-path.js.map +1 -1
  51. package/cjs/lib/utils/index.d.ts +8 -0
  52. package/cjs/lib/utils/index.d.ts.map +1 -0
  53. package/cjs/lib/utils/index.js +11 -0
  54. package/cjs/lib/utils/index.js.map +1 -0
  55. package/cjs/lib/utils/is-array-string.d.ts +3 -0
  56. package/cjs/lib/utils/is-array-string.d.ts.map +1 -1
  57. package/cjs/lib/utils/is-array-string.js +3 -0
  58. package/cjs/lib/utils/is-array-string.js.map +1 -1
  59. package/cjs/lib/utils/is-numeric.d.ts +2 -0
  60. package/cjs/lib/utils/is-numeric.d.ts.map +1 -0
  61. package/cjs/lib/utils/is-numeric.js +10 -0
  62. package/cjs/lib/utils/is-numeric.js.map +1 -0
  63. package/cjs/lib/utils/is-plain-object.d.ts +3 -0
  64. package/cjs/lib/utils/is-plain-object.d.ts.map +1 -1
  65. package/cjs/lib/utils/is-plain-object.js +3 -0
  66. package/cjs/lib/utils/is-plain-object.js.map +1 -1
  67. package/cjs/lib/utils/try-json.d.ts +2 -2
  68. package/cjs/lib/utils/try-json.js +2 -2
  69. package/cjs/lib/utils/try-json.js.map +1 -1
  70. package/cjs/public-api.d.ts +1 -0
  71. package/cjs/public-api.d.ts.map +1 -1
  72. package/cjs/public-api.js +1 -0
  73. package/cjs/public-api.js.map +1 -1
  74. package/fesm2022/ironcode-vas-lib.mjs +547 -55
  75. package/fesm2022/ironcode-vas-lib.mjs.map +1 -1
  76. package/lib/control-value/vas-camera-control-value.model.d.ts +4 -2
  77. package/lib/entity/vas-field.dto.d.ts +3 -4
  78. package/lib/model/estimate-control/estimate-control-value.dto.d.ts +13 -0
  79. package/lib/model/estimate-control/estimate-control-value.model.d.ts +10 -0
  80. package/lib/model/estimate-control/estimate-item.dto.d.ts +15 -0
  81. package/lib/model/estimate-control/estimate-item.model.d.ts +23 -0
  82. package/lib/model/estimate-control/estimate.dto.d.ts +36 -0
  83. package/lib/model/estimate-control/estimate.model.d.ts +54 -0
  84. package/lib/model/estimate-control/estimate.types.d.ts +2 -0
  85. package/lib/model/estimate-control/index.d.ts +7 -0
  86. package/lib/model/index.d.ts +2 -0
  87. package/lib/model/report-invocation.d.ts +39 -0
  88. package/lib/utils/get-value-by-path.d.ts +5 -15
  89. package/lib/utils/index.d.ts +7 -0
  90. package/lib/utils/is-array-string.d.ts +4 -0
  91. package/lib/utils/is-numeric.d.ts +1 -0
  92. package/lib/utils/is-plain-object.d.ts +3 -0
  93. package/lib/utils/omit.d.ts +7 -0
  94. package/lib/utils/try-json.d.ts +2 -2
  95. package/package.json +3 -2
  96. package/public-api.d.ts +1 -0
@@ -1,9 +1,11 @@
1
1
  import { VasFileDto } from '../entity';
2
- export interface VasCameraControlValueModel {
2
+ export interface VasCameraControlValueValue {
3
3
  webPath: string;
4
4
  path: string;
5
5
  url?: string;
6
6
  id?: string;
7
7
  }
8
- export declare function isCameraControlValueV1(object: any): object is VasCameraControlValueModel;
8
+ /** @deprecated */
9
+ export type VasCameraControlValueModel = VasCameraControlValueValue;
10
+ export declare function isCameraControlValueV1(object: any): object is VasCameraControlValueValue;
9
11
  export declare function isCameraControlValueV2(object: any): object is VasFileDto;
@@ -1,9 +1,8 @@
1
1
  import { VasJobDataDto } from './vas-job-data.dto';
2
2
  import { VasFileDto } from './vas-file.dto';
3
- import { GeoLocation } from '../model';
4
- import { VasFunctionControlValueDto } from '../control-value';
5
- import { VasCameraControlValueModel } from '../control-value';
6
- export declare type FieldValueType = string | number | boolean | null | GeoLocation | Array<object | string | number | boolean | VasFileDto> | Record<string, any> | VasCameraControlValueModel | VasFunctionControlValueDto;
3
+ import { EstimateControlValueDto, GeoLocation } from '../model';
4
+ import { VasCameraControlValueValue, VasFunctionControlValueDto } from '../control-value';
5
+ export declare type FieldValueType = string | number | boolean | null | GeoLocation | Array<object | string | number | boolean | VasFileDto> | Record<string, any> | VasCameraControlValueValue | EstimateControlValueDto | VasFunctionControlValueDto;
7
6
  export interface VasFieldDto extends VasJobDataDto {
8
7
  control: string;
9
8
  fieldJobPointers: Array<string>;
@@ -0,0 +1,13 @@
1
+ import { EstimateDto, EstimateSummaryDto } from './estimate.dto';
2
+ export interface EstimateControlValueSummaryDto {
3
+ original: EstimateSummaryDto;
4
+ latest: EstimateSummaryDto;
5
+ savings: EstimateSummaryDto;
6
+ }
7
+ /**
8
+ * Describes the value of the estimate control
9
+ */
10
+ export interface EstimateControlValueDto {
11
+ estimates: Array<EstimateDto>;
12
+ summary: EstimateControlValueSummaryDto;
13
+ }
@@ -0,0 +1,10 @@
1
+ import { EstimateControlValueSummaryDto } from './estimate-control-value.dto';
2
+ import { EstimateModel } from './estimate.model';
3
+ /**
4
+ * Utility class for computing the summary value for an estimate control given
5
+ * the first and last estimates
6
+ */
7
+ export declare class EstimateControlValueModel {
8
+ static calculateSummary(original: EstimateModel, latest: EstimateModel): EstimateControlValueSummaryDto;
9
+ static getEmptySummary(): EstimateControlValueSummaryDto;
10
+ }
@@ -0,0 +1,15 @@
1
+ import { EstimateCostCategory, EstimateWorkCategory } from './estimate.types';
2
+ export interface EstimateItemDto {
3
+ id: string;
4
+ description: string;
5
+ type: string;
6
+ quantity: number;
7
+ units: number;
8
+ price: string;
9
+ workCategory: EstimateWorkCategory;
10
+ costCategory: EstimateCostCategory;
11
+ comment: string;
12
+ quantityAdjusted: number;
13
+ unitsAdjusted: number;
14
+ priceAdjusted: string;
15
+ }
@@ -0,0 +1,23 @@
1
+ import { EstimateItemDto } from './estimate-item.dto';
2
+ import { EstimateCostCategory, EstimateWorkCategory } from './estimate.types';
3
+ export declare class EstimateItemModel {
4
+ id: string;
5
+ description: string;
6
+ type: string;
7
+ quantity: number;
8
+ quantityAdjusted: number;
9
+ units: number;
10
+ unitsAdjusted: number;
11
+ price: string;
12
+ priceAdjusted: string;
13
+ workCategory: EstimateWorkCategory;
14
+ costCategory: EstimateCostCategory;
15
+ comment: string;
16
+ constructor(id: string, description: string, type: string, quantity: number, quantityAdjusted: number, units: number, unitsAdjusted: number, price: string, priceAdjusted: string, workCategory: EstimateWorkCategory, costCategory: EstimateCostCategory, comment: string);
17
+ getTotalUnits(adjusted?: boolean): string;
18
+ getLineValue(labourRate?: string, timeBasis?: string, adjusted?: boolean): string;
19
+ toDto(): EstimateItemDto;
20
+ static create(): EstimateItemModel;
21
+ static fromDto(dto: Partial<EstimateItemDto>): EstimateItemModel;
22
+ static equal(a: EstimateItemDto | undefined, b: EstimateItemDto | undefined): boolean;
23
+ }
@@ -0,0 +1,36 @@
1
+ import { EstimateItemDto } from './estimate-item.dto';
2
+ import { EstimateSource, EstimateSundryMethod } from './estimate.model';
3
+ import { EstimateCostCategory } from './estimate.types';
4
+ export type CostCategorySummary = Record<EstimateCostCategory, string>;
5
+ export interface CostCategorySummaryTotals {
6
+ net: string;
7
+ vat: string;
8
+ gross: string;
9
+ hours: string;
10
+ labourRate: string;
11
+ }
12
+ export type EstimateSummaryDto = CostCategorySummary & CostCategorySummaryTotals;
13
+ export interface EstimateDto {
14
+ id: string;
15
+ source: EstimateSource;
16
+ label: string;
17
+ comment: string;
18
+ timestamp: string;
19
+ version: number;
20
+ net: string;
21
+ vat: string;
22
+ gross: string;
23
+ labourRate: string;
24
+ vatRate: string;
25
+ sundryRate: string;
26
+ sundryMax: string;
27
+ sundryFixed: string;
28
+ sundryMethod: EstimateSundryMethod;
29
+ partsDiscount: string;
30
+ paintDiscount: string;
31
+ timeBasis: string;
32
+ adjusted: boolean;
33
+ items: Array<EstimateItemDto>;
34
+ summary: EstimateSummaryDto;
35
+ summaryAdjusted: EstimateSummaryDto | null;
36
+ }
@@ -0,0 +1,54 @@
1
+ import { EstimateItemModel } from './estimate-item.model';
2
+ import { EstimateDto, EstimateSummaryDto } from './estimate.dto';
3
+ import { EstimateItemDto } from './estimate-item.dto';
4
+ export declare type EstimateSundryMethod = 'percentage' | 'percentage-with-max' | 'fixed';
5
+ export declare type EstimateSource = 'audatex' | 'glassmatix' | 'manual' | 'ibody';
6
+ export declare class EstimateModel {
7
+ id: string;
8
+ source: EstimateSource;
9
+ label: string;
10
+ comment: string;
11
+ timestamp: string;
12
+ version: number;
13
+ net: string;
14
+ vat: string;
15
+ gross: string;
16
+ labourRate: string;
17
+ vatRate: string;
18
+ sundryRate: string;
19
+ sundryMax: string;
20
+ sundryFixed: string;
21
+ sundryMethod: EstimateSundryMethod;
22
+ partsDiscount: string;
23
+ paintDiscount: string;
24
+ timeBasis: string;
25
+ adjusted: boolean;
26
+ items: Array<EstimateItemModel>;
27
+ summaryNet: EstimateSummaryDto;
28
+ summary: EstimateSummaryDto;
29
+ summaryAdjusted: EstimateSummaryDto;
30
+ static create(source?: EstimateSource): EstimateModel;
31
+ static fromDto(dto: Partial<EstimateDto>): EstimateModel;
32
+ addItem(modelOrDto: EstimateItemModel | Partial<EstimateItemDto>, opts?: {
33
+ calculate?: boolean;
34
+ }): void;
35
+ addItems(items: Array<EstimateItemModel>, opts?: {
36
+ calculate?: boolean;
37
+ }): void;
38
+ calculate(): void;
39
+ /**
40
+ * Returns the net summary (before sundries and discounts) of the estimate.
41
+ * By summary, we mean grouping the costs by cost category.
42
+ *
43
+ * @param adjusted if the values should be calculated using the original or
44
+ * adjusted values
45
+ */
46
+ getSummaryNet(adjusted?: boolean): EstimateSummaryDto;
47
+ /**
48
+ * Applies the sundry and discount values to the net summary.
49
+
50
+ */
51
+ getSummary(summaryNet: EstimateDto['summary'], sundryRate: string, sundryMax: string, sundryFixed: string, sundryMethod: EstimateSundryMethod, partsDiscount: string, paintDiscount: string, adjusted: boolean): EstimateDto['summary'];
52
+ toDto(): EstimateDto;
53
+ getTotalHours(adjusted?: boolean): string;
54
+ }
@@ -0,0 +1,2 @@
1
+ export declare type EstimateWorkCategory = 'none' | 'blend' | 'check' | 'new' | 'paint' | 'rr' | 'removed' | 'repair' | 'specialist';
2
+ export declare type EstimateCostCategory = 'labour' | 'none' | 'pm' | 'pl' | 'parts' | 'other' | 'specialist';
@@ -0,0 +1,7 @@
1
+ export * from './estimate.dto';
2
+ export * from './estimate.model';
3
+ export * from './estimate.types';
4
+ export * from './estimate-control-value.dto';
5
+ export * from './estimate-control-value.model';
6
+ export * from './estimate-item.dto';
7
+ export * from './estimate-item.model';
@@ -1,3 +1,5 @@
1
+ export * from './estimate-control';
1
2
  export * from './firebase-document-meta.interface';
2
3
  export * from './geo-location';
4
+ export * from './report-invocation';
3
5
  export * from './vas-time-range.model';
@@ -0,0 +1,39 @@
1
+ import { FieldValueType } from '../entity';
2
+ export interface ReportInvocationFile {
3
+ id: string;
4
+ name: string;
5
+ sequence: number;
6
+ fileSize: number;
7
+ mimeType: string;
8
+ url: string;
9
+ embedLink: boolean;
10
+ rotation: number;
11
+ description: string;
12
+ displayAs: string;
13
+ displayedName: string;
14
+ group: string;
15
+ index: number;
16
+ }
17
+ export interface ReportInvocation {
18
+ id: string;
19
+ reportLayout: string;
20
+ data: {
21
+ id: string;
22
+ account: string;
23
+ reference: string;
24
+ jobDate: string;
25
+ assigneeId: string;
26
+ assigneeName: string;
27
+ jobStatus: string;
28
+ jobType: string;
29
+ /** @deprecated */
30
+ timeZoneOffset?: number;
31
+ files: {
32
+ photo: Array<ReportInvocationFile>;
33
+ documents: Array<ReportInvocationFile>;
34
+ other: Array<ReportInvocationFile>;
35
+ pdf: Array<ReportInvocationFile>;
36
+ };
37
+ fields: Record<string, FieldValueType>;
38
+ };
39
+ }
@@ -1,18 +1,8 @@
1
1
  /**
2
- * A non sophisticated way to get values from the job via paths. For example:
2
+ * Get a value from an object by path.
3
3
  *
4
- * getValueByPath(
5
- * ['foo', 'bar'],
6
- * {
7
- * foo: {
8
- * bar: 'value'
9
- * }
10
- * }
11
- * );
12
- *
13
- * will return "value"
14
- * @param {string[]} path
15
- * @param {Record<string, FieldValueType>} object
16
- * @return {T | undefined}
4
+ * Path can be an array of strings or numbers.
5
+ * Path can be a string using dot notation, which can include square brackets to
6
+ * access array positions e.g. foo.bar[0].baz
17
7
  */
18
- export declare const getValueByPath: <T>(path: string[], object: Record<string, any>) => T | undefined;
8
+ export declare function getValueByPath<T>(path: string | number | Array<string | number>, object: null | Record<string, any>): T | undefined;
@@ -0,0 +1,7 @@
1
+ export * from './get-value-by-path';
2
+ export * from './is-array-string';
3
+ export * from './is-numeric';
4
+ export * from './is-plain-object';
5
+ export * from './omit';
6
+ export * from './only';
7
+ export * from './try-json';
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Return true IFF the array contains only strings
3
+ */
4
+ export declare const isArrayString: (value: any) => value is Array<string>;
@@ -0,0 +1 @@
1
+ export declare function isNumeric(value: string | number): value is number;
@@ -1 +1,4 @@
1
+ /**
2
+ * Return true if the argument is a plain object {}, i.e. not an array, null.
3
+ */
1
4
  export declare function isPlainObject<T>(value: any): value is T;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Return an object omitting properties specified by key(s)
3
+ *
4
+ * @param obj object to be processed
5
+ * @param omitKey key or array of keys to be omitted
6
+ */
7
+ export declare const omit: <T extends Record<string, any>>(obj: T, omitKey: string | Array<string>) => Partial<T>;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Try to parse the value as JSON if it looks like a JSON encoded string
3
- * @param value
2
+ * Try to parse the value as JSON if it looks like a JSON encoded string, return
3
+ * the original value if it's not a JSON string or parsing fails.
4
4
  */
5
5
  export declare const tryJson: <T>(value: T) => Record<string, any> | T;
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@ironcode/vas-lib",
3
- "version": "3.0.0-alpha.2",
3
+ "version": "3.0.0-alpha.3",
4
4
  "peerDependencies": {
5
5
  "angular2-uuid": "^1.1.1",
6
- "moment": "^2.0.0"
6
+ "moment": "^2.0.0",
7
+ "uuid": "^9.0.1"
7
8
  },
8
9
  "dependencies": {
9
10
  "tslib": "^2.3.0"
package/public-api.d.ts CHANGED
@@ -3,3 +3,4 @@ export * from './lib/controls-config/index';
3
3
  export * from './lib/elastic/index';
4
4
  export * from './lib/entity/index';
5
5
  export * from './lib/model/index';
6
+ export * from './lib/utils';