@fabriktor/fx 0.0.83 → 0.0.84
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/dist/src/jobs/jobs.d.ts +7 -1
- package/dist/src/jobs/jobs.js +40 -19
- package/package.json +1 -1
package/dist/src/jobs/jobs.d.ts
CHANGED
|
@@ -75,12 +75,16 @@ export type SetLocationMembersOptions = {
|
|
|
75
75
|
location: Location;
|
|
76
76
|
current_members: string[];
|
|
77
77
|
};
|
|
78
|
-
|
|
78
|
+
type JobMembershipOptions = {
|
|
79
79
|
job: Job;
|
|
80
80
|
location: Location;
|
|
81
81
|
current_members: string[];
|
|
82
82
|
foremen: string[];
|
|
83
83
|
};
|
|
84
|
+
export type SetJobMembersOptions = JobMembershipOptions;
|
|
85
|
+
export type UpdateJobOptions = JobMembershipOptions & {
|
|
86
|
+
description: string;
|
|
87
|
+
};
|
|
84
88
|
export type JobLifecycleOptions = {
|
|
85
89
|
job: Job;
|
|
86
90
|
};
|
|
@@ -107,6 +111,7 @@ export interface JobsFXOperator {
|
|
|
107
111
|
removeJobMember(opts: RemoveJobMemberOptions): Promise<Job>;
|
|
108
112
|
setLocationMembers(opts: SetLocationMembersOptions): Promise<Location>;
|
|
109
113
|
setJobMembers(opts: SetJobMembersOptions): Promise<Job>;
|
|
114
|
+
updateJob(opts: UpdateJobOptions): Promise<Job>;
|
|
110
115
|
jobLifecycleControls(opts: JobLifecycleControlsOptions): JobLifecycleControls;
|
|
111
116
|
startJob(opts: JobLifecycleOptions): Promise<Job>;
|
|
112
117
|
completeJob(opts: JobLifecycleOptions): Promise<Job>;
|
|
@@ -130,6 +135,7 @@ export declare class JobsFX implements JobsFXOperator {
|
|
|
130
135
|
removeJobMember(opts: RemoveJobMemberOptions): Promise<Job>;
|
|
131
136
|
setLocationMembers(opts: SetLocationMembersOptions): Promise<Location>;
|
|
132
137
|
setJobMembers(opts: SetJobMembersOptions): Promise<Job>;
|
|
138
|
+
updateJob(opts: UpdateJobOptions): Promise<Job>;
|
|
133
139
|
jobLifecycleControls(opts: JobLifecycleControlsOptions): JobLifecycleControls;
|
|
134
140
|
startJob(opts: JobLifecycleOptions): Promise<Job>;
|
|
135
141
|
completeJob(opts: JobLifecycleOptions): Promise<Job>;
|
package/dist/src/jobs/jobs.js
CHANGED
|
@@ -282,28 +282,29 @@ export class JobsFX {
|
|
|
282
282
|
});
|
|
283
283
|
}
|
|
284
284
|
async setJobMembers(opts) {
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
field: "current_members",
|
|
294
|
-
msg: msgJobMembersOutsideLocation,
|
|
295
|
-
});
|
|
296
|
-
validateForemen({
|
|
297
|
-
foremen,
|
|
298
|
-
members: current_members,
|
|
299
|
-
field: "foremen",
|
|
300
|
-
msg: msgForemenOutsideJob,
|
|
285
|
+
const input = jobMembershipInput(opts);
|
|
286
|
+
await this.jobs.replaceOneJob({
|
|
287
|
+
id: input.id,
|
|
288
|
+
in: {
|
|
289
|
+
location_id: input.location_id,
|
|
290
|
+
current_members: input.current_members,
|
|
291
|
+
foremen: input.foremen,
|
|
292
|
+
},
|
|
301
293
|
});
|
|
294
|
+
return await this.findJob(input.id);
|
|
295
|
+
}
|
|
296
|
+
async updateJob(opts) {
|
|
297
|
+
const input = jobMembershipInput(opts);
|
|
302
298
|
await this.jobs.replaceOneJob({
|
|
303
|
-
id,
|
|
304
|
-
in: {
|
|
299
|
+
id: input.id,
|
|
300
|
+
in: {
|
|
301
|
+
description: opts.description,
|
|
302
|
+
location_id: input.location_id,
|
|
303
|
+
current_members: input.current_members,
|
|
304
|
+
foremen: input.foremen,
|
|
305
|
+
},
|
|
305
306
|
});
|
|
306
|
-
return await this.findJob(id);
|
|
307
|
+
return await this.findJob(input.id);
|
|
307
308
|
}
|
|
308
309
|
jobLifecycleControls(opts) {
|
|
309
310
|
const actor_id = requiredID(opts.actor_id, "actor_id", msgMemberIDRequired);
|
|
@@ -435,6 +436,26 @@ export class JobsFX {
|
|
|
435
436
|
return job;
|
|
436
437
|
}
|
|
437
438
|
}
|
|
439
|
+
function jobMembershipInput(opts) {
|
|
440
|
+
const id = requiredID(opts.job.id, "job", msgJobIDRequired);
|
|
441
|
+
const location_id = locationID(opts.location, opts.job.location_id, "job", msgJobLocationMismatch);
|
|
442
|
+
validateLocationAvailable(opts.location, "location");
|
|
443
|
+
const current_members = normalizeIDs(opts.current_members);
|
|
444
|
+
const foremen = normalizeIDs(opts.foremen);
|
|
445
|
+
validateLocationMembers({
|
|
446
|
+
members: current_members,
|
|
447
|
+
location: opts.location,
|
|
448
|
+
field: "current_members",
|
|
449
|
+
msg: msgJobMembersOutsideLocation,
|
|
450
|
+
});
|
|
451
|
+
validateForemen({
|
|
452
|
+
foremen,
|
|
453
|
+
members: current_members,
|
|
454
|
+
field: "foremen",
|
|
455
|
+
msg: msgForemenOutsideJob,
|
|
456
|
+
});
|
|
457
|
+
return { id, location_id, current_members, foremen };
|
|
458
|
+
}
|
|
438
459
|
export function newJobsFX(opts) {
|
|
439
460
|
return new JobsFX(opts);
|
|
440
461
|
}
|