@ironcode/vas-lib 1.1.0 → 1.3.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/cjs/lib/entity/index.d.ts +2 -0
- package/cjs/lib/entity/index.d.ts.map +1 -1
- package/cjs/lib/entity/index.js +2 -0
- package/cjs/lib/entity/index.js.map +1 -1
- package/cjs/lib/entity/vas-job.model.d.ts +55 -66
- package/cjs/lib/entity/vas-job.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-job.model.js +92 -69
- package/cjs/lib/entity/vas-job.model.js.map +1 -1
- package/cjs/lib/entity/vas-vehicle.dto.d.ts +7 -0
- package/cjs/lib/entity/vas-vehicle.dto.d.ts.map +1 -0
- package/cjs/lib/entity/vas-vehicle.dto.js +3 -0
- package/cjs/lib/entity/vas-vehicle.dto.js.map +1 -0
- package/cjs/lib/entity/vas-vehicle.model.d.ts +22 -0
- package/cjs/lib/entity/vas-vehicle.model.d.ts.map +1 -0
- package/cjs/lib/entity/vas-vehicle.model.js +55 -0
- package/cjs/lib/entity/vas-vehicle.model.js.map +1 -0
- package/cjs/package.json +16 -6
- package/esm2020/lib/entity/index.mjs +3 -1
- package/esm2020/lib/entity/vas-job.model.mjs +92 -70
- package/esm2020/lib/entity/vas-vehicle.dto.mjs +2 -0
- package/esm2020/lib/entity/vas-vehicle.model.mjs +51 -0
- package/fesm2015/ironcode-vas-lib.mjs +143 -70
- package/fesm2015/ironcode-vas-lib.mjs.map +1 -1
- package/fesm2020/ironcode-vas-lib.mjs +142 -70
- package/fesm2020/ironcode-vas-lib.mjs.map +1 -1
- package/lib/entity/index.d.ts +2 -0
- package/lib/entity/vas-job.model.d.ts +55 -66
- package/lib/entity/vas-vehicle.dto.d.ts +6 -0
- package/lib/entity/vas-vehicle.model.d.ts +21 -0
- package/package.json +1 -1
package/lib/entity/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ 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/geo-location';
|
|
8
|
+
import { VasFormDto } from './vas-form.dto';
|
|
8
9
|
export declare interface VasJobModelDynamicInterface {
|
|
9
10
|
[s: string]: string | number | Record<string, VasFieldDtoValue>;
|
|
10
11
|
}
|
|
@@ -54,8 +55,7 @@ export declare class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
54
55
|
*/
|
|
55
56
|
get dynamicProperties(): Array<string>;
|
|
56
57
|
/**
|
|
57
|
-
* Returns
|
|
58
|
-
* the type
|
|
58
|
+
* Returns the list of properties of the Job type
|
|
59
59
|
*/
|
|
60
60
|
get staticProperties(): Array<string>;
|
|
61
61
|
/**
|
|
@@ -63,6 +63,13 @@ export declare class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
63
63
|
*/
|
|
64
64
|
static empty(): VasJobModel;
|
|
65
65
|
static fromDto(dto: Partial<VasJobDto>): VasJobModel;
|
|
66
|
+
/**
|
|
67
|
+
* This method will instantiate a new JobModel. The difference with this
|
|
68
|
+
* method of instantiation is that we are coming from a relation frame i.e.
|
|
69
|
+
* the job has a list of {@link VasFieldDto} instead of a Job document.
|
|
70
|
+
*
|
|
71
|
+
*/
|
|
72
|
+
static fromRelational(dto: Partial<VasJobDto>, form: VasFormDto): VasJobModel;
|
|
66
73
|
/**
|
|
67
74
|
* @param {VasFormModel} formModel
|
|
68
75
|
* @return {Record<string, VasFieldDtoValue>}
|
|
@@ -75,7 +82,7 @@ export declare class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
75
82
|
* return a property regardless (because it uses the form to drive the logic)
|
|
76
83
|
* @return {Record<string, VasFieldDtoValue>}
|
|
77
84
|
*/
|
|
78
|
-
getFields2(): Record<string, VasFieldDtoValue>;
|
|
85
|
+
protected getFields2(): Record<string, VasFieldDtoValue>;
|
|
79
86
|
/**
|
|
80
87
|
* Returns an object describing how many attachments were added to this job
|
|
81
88
|
* (camera controls and files), and how many have not been uploaded yet.
|
|
@@ -88,18 +95,41 @@ export declare class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
88
95
|
total: number;
|
|
89
96
|
};
|
|
90
97
|
/**
|
|
91
|
-
* This method will
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
*
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
* This method will return the dynamic property from the JobModel that
|
|
99
|
+
* represent a group (from a form).
|
|
100
|
+
*
|
|
101
|
+
* @param name the name of the group
|
|
102
|
+
* @param init if true (default) and group is not found, initialise an empty
|
|
103
|
+
* group, otherwise throw an error
|
|
104
|
+
*/
|
|
105
|
+
getGroup(name: string, init?: boolean): Record<string, VasFieldDtoValue>;
|
|
106
|
+
/**
|
|
107
|
+
* @param path path segments
|
|
108
|
+
*/
|
|
109
|
+
getValueByPath<T extends VasFieldDtoValue>(path?: string[]): T | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* In order to understand why we need this method it is important to
|
|
112
|
+
* understand that within the system, Jobs can be represented in one of two
|
|
113
|
+
* ways, document and relational.
|
|
114
|
+
*
|
|
115
|
+
* The important distinction is how values submitted by a form are stored.
|
|
116
|
+
*
|
|
117
|
+
* Jobs stored as documents (JSON objects) will store user values, as dynamic
|
|
118
|
+
* properties of the document.
|
|
119
|
+
*
|
|
120
|
+
* Whereas, Jobs stored as relational, will store user values in an array of
|
|
121
|
+
* {@link VasFieldDto} objects.
|
|
122
|
+
*
|
|
123
|
+
* Depending on where we are in the system, either one of these approaches can
|
|
124
|
+
* be more useful than the other.
|
|
125
|
+
*
|
|
126
|
+
* This method, assumes that the JobModel has been instantiated from a
|
|
127
|
+
* document representation, and serves to hydrate the fields array. In order
|
|
128
|
+
* to achieve this, knowledge of the {@link VasFormDto} that created the job
|
|
129
|
+
* is required.
|
|
130
|
+
*
|
|
131
|
+
*
|
|
132
|
+
* Job in document representation
|
|
103
133
|
* {
|
|
104
134
|
* id: <guid>,
|
|
105
135
|
* reference: "something"
|
|
@@ -109,7 +139,7 @@ export declare class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
109
139
|
* }
|
|
110
140
|
* }
|
|
111
141
|
*
|
|
112
|
-
*
|
|
142
|
+
* Job in relational representation
|
|
113
143
|
* {
|
|
114
144
|
* id: <guid>,
|
|
115
145
|
* reference: "something"
|
|
@@ -124,55 +154,15 @@ export declare class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
124
154
|
* ]
|
|
125
155
|
* }
|
|
126
156
|
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* and the Field that was created in the Job to store the value for that
|
|
133
|
-
* Control. This is useful, if for example you want to compare a Job in form A
|
|
134
|
-
* with a Job in form B, for example if you want to update the Job on the API
|
|
135
|
-
* with a Job that was saved by a client in form A.
|
|
136
|
-
*
|
|
137
|
-
* E.g.
|
|
138
|
-
* Client -> API: client requests form
|
|
139
|
-
* User -> Client: user fills in the form and submits
|
|
140
|
-
* Client -> Firestore: client saves the Job in form A i.e. dynamic props
|
|
141
|
-
* Firestore -> Function: A function is triggered to sync the job to the API
|
|
142
|
-
* Function -> API: Function checks if job already exists, it receives 404
|
|
143
|
-
* Function -> Function: The function calls `hydrateFields(...)`
|
|
144
|
-
* Function -> API: The function POST the Job to /jobs
|
|
145
|
-
* Function -> API: The function POST each field to /fields
|
|
146
|
-
*
|
|
147
|
-
* Similarly, if the user updates the job
|
|
148
|
-
* Client -> API: client requests form
|
|
149
|
-
* User -> Client: user fills in the form and submits an update
|
|
150
|
-
* Client -> Firestore: client saves the Job in form A i.e. dynamic props
|
|
151
|
-
* Firestore -> Function: A function is triggered to sync the job to the API
|
|
152
|
-
* Function -> API: Function checks if job already exists, it receives 200
|
|
153
|
-
* Function -> Function: The function calls `hydrateFields(...)` passing in
|
|
154
|
-
* the map is made by iterating over the fields it
|
|
155
|
-
* received from the API and storing the mappings
|
|
156
|
-
* between controlId and fieldId for each field
|
|
157
|
-
* Function -> API: The function PATCH the Job to /jobs
|
|
158
|
-
* Function -> API: The function POST/PATCH each field to /fields
|
|
159
|
-
* treated as new
|
|
160
|
-
*
|
|
161
|
-
* @param {VasFormModel} formModel the VasFormModel that was used to create
|
|
162
|
-
* the job
|
|
163
|
-
* @param {Map<string, string>} controlFieldIdMap a mapping of control to
|
|
164
|
-
* field ids. This is used to determine whether a new id for the field should
|
|
165
|
-
* be generated, or to reuse an existing one from the map.
|
|
166
|
-
* @param {Array<string>} controlNames if a value is provided, it will be used
|
|
157
|
+
*
|
|
158
|
+
* @param formModel the VasFormModel that was used to create the job
|
|
159
|
+
* @param controlFieldIdMap This is used to determine the id each field.
|
|
160
|
+
* Either one will be found in the map, or a new one is generated.
|
|
161
|
+
* @param controlNames if a value is provided, it will be used
|
|
167
162
|
* to filter the fields that are returned.
|
|
168
163
|
* @return {Array<VasFieldDto>}
|
|
169
164
|
*/
|
|
170
165
|
hydrateFields(formModel: VasFormModel, controlFieldIdMap?: Map<string, string>, controlNames?: Array<string>): void;
|
|
171
|
-
/**
|
|
172
|
-
* @param {string[]} path path segments
|
|
173
|
-
* @return {void}
|
|
174
|
-
*/
|
|
175
|
-
getValueByPath<T extends VasFieldDtoValue>(path?: string[]): T | undefined;
|
|
176
166
|
/**
|
|
177
167
|
* A very non sophisticated way to set values in the job via paths
|
|
178
168
|
*
|
|
@@ -187,14 +177,13 @@ export declare class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
187
177
|
* }
|
|
188
178
|
* }
|
|
189
179
|
*
|
|
190
|
-
* @param
|
|
191
|
-
* @param
|
|
180
|
+
* @param value the value to set
|
|
181
|
+
* @param path path segments
|
|
192
182
|
*/
|
|
193
183
|
setValueByPath(value: VasFieldDtoValue, path?: string[]): void;
|
|
194
184
|
/**
|
|
195
|
-
* @param
|
|
185
|
+
* @param staticOnly if true, will only output values for the static
|
|
196
186
|
* properties in the dto
|
|
197
|
-
* @return {VasJobDto}
|
|
198
187
|
*/
|
|
199
188
|
toDto(staticOnly?: boolean): VasJobDto;
|
|
200
189
|
/**
|
|
@@ -221,7 +210,7 @@ export declare class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
|
221
210
|
*
|
|
222
211
|
* @param {string} value a string with the syntax
|
|
223
212
|
* @param {ParseSyntaxOptions} options
|
|
224
|
-
* @return
|
|
213
|
+
* @return the results of parsing the syntax on this job
|
|
225
214
|
*/
|
|
226
215
|
parseSyntax(value: string, options?: ParseSyntaxOptions): string;
|
|
227
216
|
/**
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { VasAccountObjectModel } from './vas-account-object.model';
|
|
2
|
+
import { VasVehicleDto } from './vas-vehicle.dto';
|
|
3
|
+
export declare class VasVehicleModel 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
|
+
registration: string;
|
|
15
|
+
make: string;
|
|
16
|
+
model: string;
|
|
17
|
+
constructor(id: string, created: string, serverCreated: string, createdBy: string, modified: string, serverModified: string, modifiedBy: string, createdByName: string, modifiedByName: string, account: string, registration: string, make: string, model: string);
|
|
18
|
+
static fromDto(dto: Partial<VasVehicleDto>): VasVehicleModel;
|
|
19
|
+
toDto(): VasVehicleDto;
|
|
20
|
+
toApiDto(options?: any): Record<string, string | number | boolean>;
|
|
21
|
+
}
|