@t4dhg/mcp-factorial 10.1.0 → 11.0.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/README.md +64 -43
- package/dist/api/attendance.d.ts +17 -1
- package/dist/api/attendance.d.ts.map +1 -1
- package/dist/api/attendance.js +38 -1
- package/dist/api/attendance.js.map +1 -1
- package/dist/api/documents.js +11 -11
- package/dist/api/documents.js.map +1 -1
- package/dist/api/index.d.ts +2 -2
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +2 -2
- package/dist/api/index.js.map +1 -1
- package/dist/api/time-off.d.ts +6 -0
- package/dist/api/time-off.d.ts.map +1 -1
- package/dist/api/time-off.js +16 -5
- package/dist/api/time-off.js.map +1 -1
- package/dist/attendance/backfill.d.ts +27 -6
- package/dist/attendance/backfill.d.ts.map +1 -1
- package/dist/attendance/backfill.js +69 -14
- package/dist/attendance/backfill.js.map +1 -1
- package/dist/attendance/gate.js +1 -1
- package/dist/attendance/gate.js.map +1 -1
- package/dist/attendance/planner.d.ts +91 -3
- package/dist/attendance/planner.d.ts.map +1 -1
- package/dist/attendance/planner.js +204 -18
- package/dist/attendance/planner.js.map +1 -1
- package/dist/attendance/report.d.ts +39 -0
- package/dist/attendance/report.d.ts.map +1 -0
- package/dist/attendance/report.js +142 -0
- package/dist/attendance/report.js.map +1 -0
- package/dist/confirmation.d.ts.map +1 -1
- package/dist/confirmation.js +3 -2
- package/dist/confirmation.js.map +1 -1
- package/dist/endpoints.d.ts +2 -0
- package/dist/endpoints.d.ts.map +1 -1
- package/dist/endpoints.js +2 -0
- package/dist/endpoints.js.map +1 -1
- package/dist/errors.d.ts +6 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +10 -5
- package/dist/errors.js.map +1 -1
- package/dist/http-client.d.ts +51 -1
- package/dist/http-client.d.ts.map +1 -1
- package/dist/http-client.js +75 -7
- package/dist/http-client.js.map +1 -1
- package/dist/prompts/attendance.d.ts +55 -0
- package/dist/prompts/attendance.d.ts.map +1 -0
- package/dist/prompts/attendance.js +623 -0
- package/dist/prompts/attendance.js.map +1 -0
- package/dist/schemas/attendance.d.ts +123 -0
- package/dist/schemas/attendance.d.ts.map +1 -1
- package/dist/schemas/attendance.js +58 -0
- package/dist/schemas/attendance.js.map +1 -1
- package/dist/schemas/documents.d.ts +2 -2
- package/dist/schemas/index.d.ts +1 -1
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +1 -1
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/projects.d.ts +2 -2
- package/dist/tools/attendance.d.ts.map +1 -1
- package/dist/tools/attendance.js +378 -82
- package/dist/tools/attendance.js.map +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +6 -7
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/shared.d.ts +10 -1
- package/dist/tools/shared.d.ts.map +1 -1
- package/dist/tools/shared.js +33 -0
- package/dist/tools/shared.js.map +1 -1
- package/dist/tools/time-off.d.ts.map +1 -1
- package/dist/tools/time-off.js +9 -1
- package/dist/tools/time-off.js.map +1 -1
- package/dist/write-safety.d.ts +6 -0
- package/dist/write-safety.d.ts.map +1 -1
- package/dist/write-safety.js +7 -0
- package/dist/write-safety.js.map +1 -1
- package/llms.txt +12 -5
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* writes the planned records one POST at a time, and invalidates the shift
|
|
7
7
|
* cache before planning and after writing whatever happened in between.
|
|
8
8
|
*/
|
|
9
|
-
import { type BackfillPlan, type Gap, type LedgerDay, type PlanFacts, type PlanRequest, type PlannedWrite } from './planner.js';
|
|
9
|
+
import { type BackfillPlan, type FactsCoverage, type Gap, type LedgerDay, type PlanFacts, type PlanRequest, type PlannedWrite } from './planner.js';
|
|
10
10
|
/** Read everything the planner needs for one employee and date window */
|
|
11
11
|
export declare function gatherFacts(employeeId: number, startOn: string, endOn: string, now?: Date): Promise<PlanFacts>;
|
|
12
12
|
/** Plan without writing */
|
|
@@ -15,19 +15,40 @@ export declare function planBackfill(request: PlanRequest, startOn: string, endO
|
|
|
15
15
|
facts: PlanFacts;
|
|
16
16
|
}>;
|
|
17
17
|
/** Workdays where the contract expects more than was tracked */
|
|
18
|
-
export declare function findGaps(employeeId: number, startOn: string, endOn: string, toleranceMinutes?: number): Promise<
|
|
18
|
+
export declare function findGaps(employeeId: number, startOn: string, endOn: string, toleranceMinutes?: number): Promise<{
|
|
19
|
+
gaps: Gap[];
|
|
20
|
+
coverage: FactsCoverage;
|
|
21
|
+
}>;
|
|
19
22
|
/** Day-by-day ledger for an audit of what was clocked against what should have been */
|
|
20
|
-
export declare function buildLedger(employeeId: number, startOn: string, endOn: string, toleranceMinutes?: number): Promise<
|
|
23
|
+
export declare function buildLedger(employeeId: number, startOn: string, endOn: string, toleranceMinutes?: number): Promise<{
|
|
24
|
+
ledger: LedgerDay[];
|
|
25
|
+
coverage: FactsCoverage;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* How many failures in a row mean the problem is the request rather than the
|
|
29
|
+
* record. A bad key or a revoked scope fails every write; grinding through
|
|
30
|
+
* hundreds of certain rejections helps nobody.
|
|
31
|
+
*/
|
|
32
|
+
export declare const CONSECUTIVE_FAILURE_ABORT = 10;
|
|
21
33
|
export interface BackfillResult {
|
|
22
34
|
written: PlannedWrite[];
|
|
23
35
|
failed: Array<PlannedWrite & {
|
|
24
36
|
error: string;
|
|
25
37
|
}>;
|
|
38
|
+
/** Records left unattempted because the run aborted */
|
|
39
|
+
notAttempted: PlannedWrite[];
|
|
40
|
+
abortedEarly: boolean;
|
|
26
41
|
}
|
|
27
42
|
/**
|
|
28
|
-
* Write the planned records sequentially
|
|
29
|
-
*
|
|
30
|
-
*
|
|
43
|
+
* Write the planned records sequentially, attempting every one.
|
|
44
|
+
*
|
|
45
|
+
* An earlier version stopped at the first failure, which turned a fill that
|
|
46
|
+
* touched one bad month into one pass per surviving stretch. A single refused
|
|
47
|
+
* record says nothing about the next one, so the run continues; only a run of
|
|
48
|
+
* consecutive failures is evidence of something systemic, and that aborts.
|
|
49
|
+
*
|
|
50
|
+
* Re-running the identical call stays safe: the planner re-reads shifts and
|
|
51
|
+
* skips whatever overlaps.
|
|
31
52
|
*/
|
|
32
53
|
export declare function executeBackfill(employeeId: number, writes: PlannedWrite[], observations?: string): Promise<BackfillResult>;
|
|
33
54
|
/** The dates a request spans, for the preview header */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backfill.d.ts","sourceRoot":"","sources":["../../src/attendance/backfill.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"backfill.d.ts","sourceRoot":"","sources":["../../src/attendance/backfill.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAaH,OAAO,EAOL,KAAK,YAAY,EAEjB,KAAK,aAAa,EAClB,KAAK,GAAG,EACR,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,cAAc,CAAC;AAEtB,yEAAyE;AACzE,wBAAsB,WAAW,CAC/B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,GAAG,GAAE,IAAiB,GACrB,OAAO,CAAC,SAAS,CAAC,CA2EpB;AAOD,2BAA2B;AAC3B,wBAAsB,YAAY,CAChC,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC,CAGnD;AAED,gEAAgE;AAChE,wBAAsB,QAAQ,CAC5B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC;IAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IAAC,QAAQ,EAAE,aAAa,CAAA;CAAE,CAAC,CAGnD;AAED,uFAAuF;AACvF,wBAAsB,WAAW,CAC/B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC;IAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IAAC,QAAQ,EAAE,aAAa,CAAA;CAAE,CAAC,CAM3D;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAE5C,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,MAAM,EAAE,KAAK,CAAC,YAAY,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAChD,uDAAuD;IACvD,YAAY,EAAE,YAAY,EAAE,CAAC;IAC7B,YAAY,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CACnC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,YAAY,EAAE,EACtB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,cAAc,CAAC,CAqCzB;AAED,wDAAwD;AACxD,wBAAgB,aAAa,CAAC,OAAO,EAAE,WAAW,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAIlF"}
|
|
@@ -7,21 +7,42 @@
|
|
|
7
7
|
* cache before planning and after writing whatever happened in between.
|
|
8
8
|
*/
|
|
9
9
|
import { cache } from '../cache.js';
|
|
10
|
-
import { createShift, listEstimatedTimes, listShiftsInRange, listWorkedTimes, localToday, } from '../api/attendance.js';
|
|
11
|
-
import {
|
|
12
|
-
import { buildBackfillPlan, computeGaps, computeLedger, enumerateDates, expandLeaves, } from './planner.js';
|
|
10
|
+
import { createShift, listEstimatedTimes, listReviews, listShiftsInRange, listWorkedTimes, localToday, } from '../api/attendance.js';
|
|
11
|
+
import { listLeavesInRange } from '../api/time-off.js';
|
|
12
|
+
import { buildBackfillPlan, computeGaps, computeLedger, enumerateDates, expandLeaves, measureCoverage, } from './planner.js';
|
|
13
13
|
/** Read everything the planner needs for one employee and date window */
|
|
14
14
|
export async function gatherFacts(employeeId, startOn, endOn, now = new Date()) {
|
|
15
15
|
// A plan must never reason from a shift list older than the call. None of
|
|
16
16
|
// the reads below is cached today; this keeps that true if one becomes so.
|
|
17
17
|
cache.invalidatePrefix('shifts');
|
|
18
|
+
// Every read below is exhaustive across pages (fetchList follows
|
|
19
|
+
// meta.has_next_page). estimated_times and worked_times page at 100 days,
|
|
20
|
+
// so a single-page read once made every window over 100 days go blind
|
|
21
|
+
// after day 100 and report the rest as not workable.
|
|
22
|
+
// listReviews is the only read this function isolates: it is a newer,
|
|
23
|
+
// less-verified signal (verified against one tenant on one day) than the
|
|
24
|
+
// others, and it fails closed for writing (daySkipReason treats a date not
|
|
25
|
+
// in facts.reviews as not signed off). Letting it reject the whole
|
|
26
|
+
// Promise.all would turn one tenant's 403 or schema mismatch on this one
|
|
27
|
+
// endpoint into a hard outage of every attendance read (audit, gaps,
|
|
28
|
+
// log_range, log_days and all five prompts), not just the signed-off
|
|
29
|
+
// signal it actually carries.
|
|
18
30
|
const range = { employee_ids: [employeeId], start_on: startOn, end_on: endOn };
|
|
19
|
-
const [worked, estimated, shifts, leaves] = await Promise.all([
|
|
31
|
+
const [worked, estimated, shifts, leaves, reviewsResult] = await Promise.all([
|
|
20
32
|
listWorkedTimes(range),
|
|
21
33
|
listEstimatedTimes(range),
|
|
22
34
|
listShiftsInRange([employeeId], startOn, endOn),
|
|
23
|
-
|
|
35
|
+
listLeavesInRange([employeeId], startOn, endOn),
|
|
36
|
+
listReviews(range).then((reviews) => ({
|
|
37
|
+
reviews,
|
|
38
|
+
error: null,
|
|
39
|
+
}), (error) => ({
|
|
40
|
+
reviews: [],
|
|
41
|
+
error: error instanceof Error ? error.message : String(error),
|
|
42
|
+
})),
|
|
24
43
|
]);
|
|
44
|
+
const reviews = reviewsResult.reviews;
|
|
45
|
+
const reviewsError = reviewsResult.error;
|
|
25
46
|
const days = new Map();
|
|
26
47
|
for (const day of worked) {
|
|
27
48
|
days.set(day.date, {
|
|
@@ -49,9 +70,16 @@ export async function gatherFacts(employeeId, startOn, endOn, now = new Date())
|
|
|
49
70
|
shifts: shifts
|
|
50
71
|
.filter(s => s.clock_in !== null)
|
|
51
72
|
.map(s => ({ date: s.date, clock_in: s.clock_in, clock_out: s.clock_out })),
|
|
52
|
-
leaves: expandLeaves(leaves
|
|
73
|
+
leaves: expandLeaves(leaves),
|
|
74
|
+
reviews: new Set(reviews.map(review => review.date)),
|
|
75
|
+
coverage: measureCoverage(enumerateDates(startOn, endOn), days, leaves.length, shifts.length, reviews.length, reviewsError),
|
|
53
76
|
};
|
|
54
77
|
}
|
|
78
|
+
function coverageOf(facts) {
|
|
79
|
+
if (!facts.coverage)
|
|
80
|
+
throw new Error('facts read from the API always carry coverage');
|
|
81
|
+
return facts.coverage;
|
|
82
|
+
}
|
|
55
83
|
/** Plan without writing */
|
|
56
84
|
export async function planBackfill(request, startOn, endOn) {
|
|
57
85
|
const facts = await gatherFacts(request.employee_id, startOn, endOn);
|
|
@@ -60,22 +88,48 @@ export async function planBackfill(request, startOn, endOn) {
|
|
|
60
88
|
/** Workdays where the contract expects more than was tracked */
|
|
61
89
|
export async function findGaps(employeeId, startOn, endOn, toleranceMinutes) {
|
|
62
90
|
const facts = await gatherFacts(employeeId, startOn, endOn);
|
|
63
|
-
return computeGaps(facts, toleranceMinutes);
|
|
91
|
+
return { gaps: computeGaps(facts, toleranceMinutes), coverage: coverageOf(facts) };
|
|
64
92
|
}
|
|
65
93
|
/** Day-by-day ledger for an audit of what was clocked against what should have been */
|
|
66
94
|
export async function buildLedger(employeeId, startOn, endOn, toleranceMinutes) {
|
|
67
95
|
const facts = await gatherFacts(employeeId, startOn, endOn);
|
|
68
|
-
return
|
|
96
|
+
return {
|
|
97
|
+
ledger: computeLedger(enumerateDates(startOn, endOn), facts, toleranceMinutes),
|
|
98
|
+
coverage: coverageOf(facts),
|
|
99
|
+
};
|
|
69
100
|
}
|
|
70
101
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
102
|
+
* How many failures in a row mean the problem is the request rather than the
|
|
103
|
+
* record. A bad key or a revoked scope fails every write; grinding through
|
|
104
|
+
* hundreds of certain rejections helps nobody.
|
|
105
|
+
*/
|
|
106
|
+
export const CONSECUTIVE_FAILURE_ABORT = 10;
|
|
107
|
+
/**
|
|
108
|
+
* Write the planned records sequentially, attempting every one.
|
|
109
|
+
*
|
|
110
|
+
* An earlier version stopped at the first failure, which turned a fill that
|
|
111
|
+
* touched one bad month into one pass per surviving stretch. A single refused
|
|
112
|
+
* record says nothing about the next one, so the run continues; only a run of
|
|
113
|
+
* consecutive failures is evidence of something systemic, and that aborts.
|
|
114
|
+
*
|
|
115
|
+
* Re-running the identical call stays safe: the planner re-reads shifts and
|
|
116
|
+
* skips whatever overlaps.
|
|
74
117
|
*/
|
|
75
118
|
export async function executeBackfill(employeeId, writes, observations) {
|
|
76
|
-
const result = {
|
|
119
|
+
const result = {
|
|
120
|
+
written: [],
|
|
121
|
+
failed: [],
|
|
122
|
+
notAttempted: [],
|
|
123
|
+
abortedEarly: false,
|
|
124
|
+
};
|
|
125
|
+
let consecutiveFailures = 0;
|
|
77
126
|
try {
|
|
78
|
-
for (const write of writes) {
|
|
127
|
+
for (const [index, write] of writes.entries()) {
|
|
128
|
+
if (consecutiveFailures >= CONSECUTIVE_FAILURE_ABORT) {
|
|
129
|
+
result.notAttempted = writes.slice(index);
|
|
130
|
+
result.abortedEarly = true;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
79
133
|
try {
|
|
80
134
|
await createShift({
|
|
81
135
|
employee_id: employeeId,
|
|
@@ -85,13 +139,14 @@ export async function executeBackfill(employeeId, writes, observations) {
|
|
|
85
139
|
observations,
|
|
86
140
|
});
|
|
87
141
|
result.written.push(write);
|
|
142
|
+
consecutiveFailures = 0;
|
|
88
143
|
}
|
|
89
144
|
catch (error) {
|
|
90
145
|
result.failed.push({
|
|
91
146
|
...write,
|
|
92
147
|
error: error instanceof Error ? error.message : String(error),
|
|
93
148
|
});
|
|
94
|
-
|
|
149
|
+
consecutiveFailures += 1;
|
|
95
150
|
}
|
|
96
151
|
}
|
|
97
152
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backfill.js","sourceRoot":"","sources":["../../src/attendance/backfill.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,UAAU,GACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"backfill.js","sourceRoot":"","sources":["../../src/attendance/backfill.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,UAAU,GACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,cAAc,EACd,YAAY,EACZ,eAAe,GAShB,MAAM,cAAc,CAAC;AAEtB,yEAAyE;AACzE,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,UAAkB,EAClB,OAAe,EACf,KAAa,EACb,MAAY,IAAI,IAAI,EAAE;IAEtB,0EAA0E;IAC1E,2EAA2E;IAC3E,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAEjC,iEAAiE;IACjE,0EAA0E;IAC1E,sEAAsE;IACtE,qDAAqD;IACrD,sE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Aa,CAAC,OAAoB;IAChD,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACvF,MAAM,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;IACjC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;AAC9D,CAAC"}
|
package/dist/attendance/gate.js
CHANGED
|
@@ -29,7 +29,7 @@ function issue(request, prefix = '') {
|
|
|
29
29
|
proceed: false,
|
|
30
30
|
message: `${prefix}${request.preview}\n\nNothing has been written. ` +
|
|
31
31
|
`To proceed, call this action again with the same arguments and confirmation_token: ${token}\n` +
|
|
32
|
-
'The token is valid for
|
|
32
|
+
'The token is valid for 15 minutes and for exactly this plan.',
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gate.js","sourceRoot":"","sources":["../../src/attendance/gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAmBrD,4CAA4C;AAC5C,MAAM,UAAU,kBAAkB,CAAC,OAAgB;IACjD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,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;YAC1F,oFAAoF,CACvF,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -7,6 +7,16 @@
|
|
|
7
7
|
* requested segments into an explicit list of writes and skips. Every rule is
|
|
8
8
|
* a unit test in src/__tests__/unit/attendance/planner.test.ts.
|
|
9
9
|
*/
|
|
10
|
+
/**
|
|
11
|
+
* Printed once on every attendance write result and preview.
|
|
12
|
+
*
|
|
13
|
+
* A backfilled record shows the real working day and hours on the attendance
|
|
14
|
+
* sheet, while Factorial's own activity log shows it was entered later through
|
|
15
|
+
* the API. Both are true at once, and neither can be altered through the API.
|
|
16
|
+
* Saying so plainly stops a user believing either that the entry is hidden or
|
|
17
|
+
* that the working time is wrong.
|
|
18
|
+
*/
|
|
19
|
+
export declare const ENTRY_TIME_NOTE: string;
|
|
10
20
|
/** A working segment on one day, in company local wall-clock time */
|
|
11
21
|
export interface Segment {
|
|
12
22
|
clock_in: string;
|
|
@@ -41,6 +51,29 @@ export interface LeaveLike {
|
|
|
41
51
|
approved: boolean | null;
|
|
42
52
|
deleted_at: string | null;
|
|
43
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* How much of the requested window the API actually returned data for. Printed
|
|
56
|
+
* at the top of every audit, gaps and bulk-write preview so that a gap in the
|
|
57
|
+
* data is visible before anyone reasons from it.
|
|
58
|
+
*/
|
|
59
|
+
export interface FactsCoverage {
|
|
60
|
+
days_in_window: number;
|
|
61
|
+
days_with_contract_data: number;
|
|
62
|
+
/** First and last date in the window with no contract data, if any */
|
|
63
|
+
first_uncovered: string | null;
|
|
64
|
+
last_uncovered: string | null;
|
|
65
|
+
leave_records: number;
|
|
66
|
+
shift_records: number;
|
|
67
|
+
review_records: number;
|
|
68
|
+
/**
|
|
69
|
+
* Set when the signed-off-dates read (listReviews) failed; review_records
|
|
70
|
+
* is then 0 and facts.reviews is empty, not because nothing is signed off
|
|
71
|
+
* but because it could not be read. Printed prominently: a plan built on
|
|
72
|
+
* this may queue writes to dates that are actually signed off and will be
|
|
73
|
+
* refused by Factorial.
|
|
74
|
+
*/
|
|
75
|
+
reviews_error: string | null;
|
|
76
|
+
}
|
|
44
77
|
export interface PlanFacts {
|
|
45
78
|
/** Today's date, YYYY-MM-DD, in the zone the caller considers local */
|
|
46
79
|
today: string;
|
|
@@ -50,7 +83,15 @@ export interface PlanFacts {
|
|
|
50
83
|
shifts: ExistingShift[];
|
|
51
84
|
/** Approved leave cover per date, see expandLeaves */
|
|
52
85
|
leaves: Map<string, LeaveCover>;
|
|
86
|
+
/** Dates whose timesheet has been signed off; closed for writing */
|
|
87
|
+
reviews: Set<string>;
|
|
88
|
+
/** What the reads covered; absent when the facts were not read from the API */
|
|
89
|
+
coverage?: FactsCoverage;
|
|
53
90
|
}
|
|
91
|
+
/** Measure how much of a date window the per-day facts cover */
|
|
92
|
+
export declare function measureCoverage(dates: string[], days: Map<string, DayFacts>, leaveRecords: number, shiftRecords: number, reviewRecords: number, reviewsError?: string | null): FactsCoverage;
|
|
93
|
+
/** One line for the header of an audit, gaps or preview */
|
|
94
|
+
export declare function formatCoverage(coverage: FactsCoverage): string;
|
|
54
95
|
export interface RangeRequest {
|
|
55
96
|
mode: 'range';
|
|
56
97
|
employee_id: number;
|
|
@@ -59,6 +100,10 @@ export interface RangeRequest {
|
|
|
59
100
|
skip_leave: boolean;
|
|
60
101
|
/** Vary each written time by up to this many minutes, deterministically per record */
|
|
61
102
|
jitter_minutes?: number;
|
|
103
|
+
/** Shift each whole day by up to this many minutes, deterministically per day */
|
|
104
|
+
variation_minutes?: number;
|
|
105
|
+
/** Dates inside the range to leave alone, for days not worked */
|
|
106
|
+
exclude_dates?: string[];
|
|
62
107
|
}
|
|
63
108
|
export interface DaysRequest {
|
|
64
109
|
mode: 'days';
|
|
@@ -70,9 +115,11 @@ export interface DaysRequest {
|
|
|
70
115
|
skip_leave: boolean;
|
|
71
116
|
/** Vary each written time by up to this many minutes, deterministically per record */
|
|
72
117
|
jitter_minutes?: number;
|
|
118
|
+
/** Shift each whole day by up to this many minutes, deterministically per day */
|
|
119
|
+
variation_minutes?: number;
|
|
73
120
|
}
|
|
74
121
|
export type PlanRequest = RangeRequest | DaysRequest;
|
|
75
|
-
export type SkipReason = 'future_date' | 'weekend' | 'bank_holiday' | 'not_workable' | 'on_leave' | 'half_day_leave';
|
|
122
|
+
export type SkipReason = 'future_date' | 'weekend' | 'bank_holiday' | 'not_workable' | 'no_contract_data' | 'on_leave' | 'half_day_leave' | 'signed_off' | 'excluded';
|
|
76
123
|
export interface SkippedDay {
|
|
77
124
|
date: string;
|
|
78
125
|
reason: SkipReason;
|
|
@@ -99,6 +146,14 @@ export interface Gap {
|
|
|
99
146
|
tracked_minutes: number;
|
|
100
147
|
missing_minutes: number;
|
|
101
148
|
half_day_leave: 'beggining_of_day' | 'end_of_day' | null;
|
|
149
|
+
/**
|
|
150
|
+
* The timesheet for this date has been signed off and is closed for
|
|
151
|
+
* writing. log_range and log_days both skip it (daySkipReason's signed_off
|
|
152
|
+
* rule); only create_edit_request can reach it. Still reported as a gap,
|
|
153
|
+
* since the hours are genuinely missing, but the caller must not be told
|
|
154
|
+
* to fill it the same way as an open date.
|
|
155
|
+
*/
|
|
156
|
+
signed_off: boolean;
|
|
102
157
|
}
|
|
103
158
|
/**
|
|
104
159
|
* A day whose tracked minutes are within this distance of the expected minutes
|
|
@@ -106,10 +161,22 @@ export interface Gap {
|
|
|
106
161
|
* are deliberately not, so a strict comparison would flag nearly every day.
|
|
107
162
|
*/
|
|
108
163
|
export declare const DEFAULT_TOLERANCE_MINUTES = 15;
|
|
164
|
+
/** A preview lists every record up to this many; above it, the first and last few */
|
|
165
|
+
export declare const PREVIEW_FULL_LIST_MAX = 62;
|
|
109
166
|
/** Parse "HH:MM" into minutes since midnight; anything else is rejected */
|
|
110
167
|
export declare function parseHHMM(value: string): number;
|
|
111
168
|
/** True when two [start, end) intervals share any time; touching does not count */
|
|
112
169
|
export declare function intervalsOverlap(a: [number, number], b: [number, number]): boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Turn a company-local day and wall-clock time into a Date in the zone the
|
|
172
|
+
* server runs in, which is the zone `formatLocalIso` stamps an offset from.
|
|
173
|
+
*
|
|
174
|
+
* This exists so a person who forgot to clock can say when they actually
|
|
175
|
+
* started or stopped. The declared moment is what Factorial records as the
|
|
176
|
+
* working time; the moment of the API call is recorded separately by Factorial
|
|
177
|
+
* as created_at and cannot be set through the API.
|
|
178
|
+
*/
|
|
179
|
+
export declare function declaredMoment(date: string, time: string): Date;
|
|
113
180
|
/** Every date from start to end inclusive */
|
|
114
181
|
export declare function enumerateDates(start: string, end: string): string[];
|
|
115
182
|
/**
|
|
@@ -131,8 +198,27 @@ export declare function expandLeaves(leaves: LeaveLike[]): Map<string, LeaveCove
|
|
|
131
198
|
* times: the preview shows exactly what will be written, the confirmation
|
|
132
199
|
* token binds to it, and a retry after a partial failure recognises its own
|
|
133
200
|
* earlier writes. Segments never cross each other or midnight.
|
|
201
|
+
*
|
|
202
|
+
* Both ends of a segment move by the same offset, so the day's total is
|
|
203
|
+
* unchanged and an audit of a jittered backfill reads complete at any
|
|
204
|
+
* tolerance. Only where a segment would otherwise run into its neighbour or
|
|
205
|
+
* past midnight is an end clamped, and then that segment shrinks by at most
|
|
206
|
+
* the magnitude.
|
|
134
207
|
*/
|
|
135
208
|
export declare function jitterSegments(employeeId: number, date: string, segments: Segment[], magnitude: number): Segment[];
|
|
209
|
+
/**
|
|
210
|
+
* Shift a whole day by one offset, so the start time drifts from day to day.
|
|
211
|
+
*
|
|
212
|
+
* This is the variation `jitter_minutes` cannot produce. Jitter moves each
|
|
213
|
+
* segment of a day independently around the pattern, which varies the shape of
|
|
214
|
+
* a day but leaves every day starting near the same time. Reconstructed
|
|
215
|
+
* records that all begin at 09:00 give themselves away; this moves the whole
|
|
216
|
+
* day together, so the pattern within it survives intact.
|
|
217
|
+
*
|
|
218
|
+
* Deterministic from the employee and the date, so the preview, the token and
|
|
219
|
+
* any retry all agree. Compose it before jitter, never after.
|
|
220
|
+
*/
|
|
221
|
+
export declare function varySegments(employeeId: number, date: string, segments: Segment[], magnitude: number): Segment[];
|
|
136
222
|
/**
|
|
137
223
|
* Build the plan. Skip reasons are evaluated in the documented order and the
|
|
138
224
|
* first match wins. Explicit days skip the weekday, holiday and workability
|
|
@@ -150,7 +236,7 @@ export declare function planFingerprint(employeeId: number, writes: PlannedWrite
|
|
|
150
236
|
* refuse them anyway.
|
|
151
237
|
*/
|
|
152
238
|
export declare function computeGaps(facts: PlanFacts, toleranceMinutes?: number): Gap[];
|
|
153
|
-
export type LedgerStatus = 'future' | 'weekend' | 'bank_holiday' | 'not_workable' | 'on_leave' | 'half_day_leave' | 'complete' | 'missing' | 'over';
|
|
239
|
+
export type LedgerStatus = 'future' | 'weekend' | 'bank_holiday' | 'not_workable' | 'no_contract_data' | 'on_leave' | 'half_day_leave' | 'complete' | 'missing' | 'short' | 'over';
|
|
154
240
|
export interface LedgerDay {
|
|
155
241
|
date: string;
|
|
156
242
|
day_type: string | null;
|
|
@@ -163,6 +249,8 @@ export interface LedgerDay {
|
|
|
163
249
|
minutes: number | null;
|
|
164
250
|
}>;
|
|
165
251
|
status: LedgerStatus;
|
|
252
|
+
/** The timesheet for this date has been signed off; it is closed for writing */
|
|
253
|
+
signed_off: boolean;
|
|
166
254
|
/** tracked minus expected; negative means hours are missing */
|
|
167
255
|
delta_minutes: number;
|
|
168
256
|
}
|
|
@@ -185,5 +273,5 @@ export declare function formatPlanPreview(plan: BackfillPlan, employee: {
|
|
|
185
273
|
}, range: {
|
|
186
274
|
start: string;
|
|
187
275
|
end: string;
|
|
188
|
-
}, request: PlanRequest, observations?: string): string;
|
|
276
|
+
}, request: PlanRequest, observations?: string, coverage?: FactsCoverage): string;
|
|
189
277
|
//# sourceMappingURL=planner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner.d.ts","sourceRoot":"","sources":["../../src/attendance/planner.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