@fabriktor/fx 0.0.194 → 0.0.195
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.
|
@@ -5,3 +5,13 @@ export type TimesheetDate = InDate & {
|
|
|
5
5
|
export declare function timesheetDateChoices(value: InDate): SchemaDate[];
|
|
6
6
|
export declare function timesheetDate(value: TimesheetDate): SchemaDate;
|
|
7
7
|
export declare function timesheetDateTime(value: TimesheetDate): number;
|
|
8
|
+
export declare function timesheetPunchDeadline(start: TimesheetDate): number;
|
|
9
|
+
export declare function timesheetPunchWindow(opts: {
|
|
10
|
+
start: TimesheetDate;
|
|
11
|
+
now: Date;
|
|
12
|
+
minimum?: TimesheetDate;
|
|
13
|
+
allow_equal?: boolean;
|
|
14
|
+
}): {
|
|
15
|
+
minimum: number;
|
|
16
|
+
maximum: number;
|
|
17
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TimesheetMaxPunchHours } from "@fabriktor/schema";
|
|
1
2
|
import { inDateAtTimestamp, isValidInputDate, isZeroDateTime, } from "../core/date.js";
|
|
2
3
|
import { PreActionBlocked } from "../core/pre-action.js";
|
|
3
4
|
const minuteMS = 60_000;
|
|
@@ -36,3 +37,13 @@ export function timesheetDate(value) {
|
|
|
36
37
|
export function timesheetDateTime(value) {
|
|
37
38
|
return Date.parse(timesheetDate(value).utc);
|
|
38
39
|
}
|
|
40
|
+
export function timesheetPunchDeadline(start) {
|
|
41
|
+
return timesheetDateTime(start) + TimesheetMaxPunchHours * hourMS;
|
|
42
|
+
}
|
|
43
|
+
export function timesheetPunchWindow(opts) {
|
|
44
|
+
const start = timesheetDateTime(opts.start);
|
|
45
|
+
return {
|
|
46
|
+
minimum: Math.max(start + (opts.allow_equal ? 0 : minuteMS), opts.minimum ? timesheetDateTime(opts.minimum) : start),
|
|
47
|
+
maximum: Math.min(opts.now.getTime(), timesheetPunchDeadline(opts.start)),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -54,6 +54,8 @@ export declare const TimesheetsBlock: {
|
|
|
54
54
|
readonly Active: "timesheets_active";
|
|
55
55
|
readonly InvalidDay: "timesheets_invalid_day";
|
|
56
56
|
readonly FinishRequired: "timesheets_finish_required";
|
|
57
|
+
readonly Duration: "timesheets_duration";
|
|
58
|
+
readonly TimeUnavailable: "timesheets_time_unavailable";
|
|
57
59
|
readonly InvalidSync: "timesheets_invalid_sync";
|
|
58
60
|
readonly Unconfirmed: "timesheets_unconfirmed";
|
|
59
61
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mergeQueryOptions, queryNestedParam, queryParams, } from "@fabriktor/client";
|
|
2
2
|
import { PunchStatusApproved, PunchStatusPending, PunchStatusWorking, PunchTypeIn, PunchTypeOut, PunchTypeRideIn, PunchTypeRideOut, } from "@fabriktor/schema";
|
|
3
3
|
import { inDateAtTimestamp } from "../core/date.js";
|
|
4
|
-
import { timesheetDate, timesheetDateTime, } from "./time.js";
|
|
4
|
+
import { timesheetDate, timesheetDateTime, timesheetPunchDeadline, } from "./time.js";
|
|
5
5
|
import { errRequired } from "../core/err.js";
|
|
6
6
|
import { PreActionBlocked } from "../core/pre-action.js";
|
|
7
7
|
import { queryRecordParams, runOwnerScopeQuery, } from "../core/query.js";
|
|
@@ -12,6 +12,8 @@ export const TimesheetsBlock = {
|
|
|
12
12
|
Active: "timesheets_active",
|
|
13
13
|
InvalidDay: "timesheets_invalid_day",
|
|
14
14
|
FinishRequired: "timesheets_finish_required",
|
|
15
|
+
Duration: "timesheets_duration",
|
|
16
|
+
TimeUnavailable: "timesheets_time_unavailable",
|
|
15
17
|
InvalidSync: "timesheets_invalid_sync",
|
|
16
18
|
Unconfirmed: "timesheets_unconfirmed",
|
|
17
19
|
};
|
|
@@ -74,7 +76,9 @@ export class TimesheetsWorkspace {
|
|
|
74
76
|
billable;
|
|
75
77
|
now;
|
|
76
78
|
punchPending = false;
|
|
77
|
-
constructor(client, actions, billable, now = () =>
|
|
79
|
+
constructor(client, actions, billable, now = () => {
|
|
80
|
+
throw new PreActionBlocked(TimesheetsBlock.TimeUnavailable);
|
|
81
|
+
}) {
|
|
78
82
|
this.client = client;
|
|
79
83
|
this.actions = actions;
|
|
80
84
|
this.billable = billable;
|
|
@@ -240,6 +244,8 @@ export class TimesheetsWorkspace {
|
|
|
240
244
|
timesheetDateTime(current.punch.punch_in_time)
|
|
241
245
|
: timesheetDateTime(opts.date) >=
|
|
242
246
|
timesheetDateTime(current.punch.punch_in_time), TimesheetsBlock.InvalidDay);
|
|
247
|
+
requireState(timesheetDateTime(opts.date) <=
|
|
248
|
+
timesheetPunchDeadline(current.punch.punch_in_time), TimesheetsBlock.Duration);
|
|
243
249
|
}
|
|
244
250
|
opts.before_request?.();
|
|
245
251
|
const context = {
|
|
@@ -289,6 +295,7 @@ export class TimesheetsWorkspace {
|
|
|
289
295
|
await this.validateDay(opts.start, opts.timezone);
|
|
290
296
|
await this.validateDay(opts.end, opts.timezone);
|
|
291
297
|
requireState(timesheetDateTime(opts.end) > timesheetDateTime(opts.start), TimesheetsBlock.InvalidDay);
|
|
298
|
+
requireState(timesheetDateTime(opts.end) <= timesheetPunchDeadline(opts.start), TimesheetsBlock.Duration);
|
|
292
299
|
const matches = opts.replace
|
|
293
300
|
? [await this.week(opts.replace.id)]
|
|
294
301
|
: await this.weeks({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabriktor/fx",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.195",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"typescript": "^6.0.3"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@fabriktor/client": "0.0.
|
|
20
|
+
"@fabriktor/client": "0.0.119",
|
|
21
21
|
"@fabriktor/fx": "0.0.94",
|
|
22
|
-
"@fabriktor/schema": "0.0.
|
|
22
|
+
"@fabriktor/schema": "0.0.89",
|
|
23
23
|
"convert": "8.0.2"
|
|
24
24
|
}
|
|
25
25
|
}
|