timeconditions: office hours, holidays, override codes, weekly grid

/api/time-conditions (company time zone by default, ranges validated,
unique override digit, never pointing at itself) with a live status
("open/closed/holiday now", same logic as the dialplan, shared), and
POST /:id/override, which writes PostgreSQL then AstDB SP/TCOVR.
/api/holidays CRUD plus import-us-federal (observed dates, computed in
code, skips days already listed). services/astdb.ts resyncs AstDB on
every AMI connect (PostgreSQL wins); services/toggles.ts applies
SpToggle TCOVR from *31N/*32N/*33N.

Generator: sp-tc-{id} per 03 §6.10 (override, holidays within the next
year, ranges rendered a minute short because GotoIfTime's end is
inclusive), sp-tc-override with a no-service fallback, admin-only
*3[123]X in sp-featurecodes, destApp time_condition. The date changing
in the company time zone triggers a forced apply so holidays roll over.
Golden cases holidays and ivr-business-hours.

Office hours page: click-and-drag half-hour grid plus an exact range
list, destinations, holiday destination, override key, status chip with
Force open / Force closed / Automatic; Holidays tab with the US federal
import. e2e m6-t4 found two bugs (pointer capture release throwing,
drawer overflow) and checks routing, AstDB, *321/*331 from an admin
phone, refusal for others, and the import reaching the dialplan.

Task: M6-T4
This commit is contained in:
iamdoubz committed 2026-10-18 10:56:28 -05:00
1 parent 15624f7b77
commit 108547046c
57 files changed
+3221 -29

No files matched your search

+12
View File
@@ -663,6 +663,18 @@ Holiday rules:
Override codes use `time_conditions.override_digit` (02). Feature codes `*31N` force open,
`*32N` force closed, `*33N` automatic (§6.13).
As built (M6-T4):
- A range's `end` is exclusive ("closed at 17:00") but `GotoIfTime`'s end minute is inclusive, so
ranges render one minute short: `08:00-16:59`; `24:00` (end of day) renders `23:59`.
- Holiday days are deduplicated and sorted by month/day; a range over New Year works.
- `[sp-tc-override]` is always rendered, ending with `exten => _*3[123]X` → `ss-noservice` for
digits no office hours use. `*33N` plays `de-activated`.
- The api's "open now" (`timeConditionStatus` in `packages/shared`) makes the same decision.
- Holidays roll over by re-rendering when the company date changes (a 10-minute check in
`index.ts`) instead of a croner job at 00:05; M11-T4 can move it into the jobs.
- Golden cases `holidays` and `ivr-business-hours`; `scripts/e2e/m6-t4.mjs` checks force
open/closed routing, `*321`/`*331` from an admin phone, and refusal for a non-admin.
### 6.11 Announcements, conferences, paging
```ini
+2
View File
@@ -233,6 +233,8 @@ On every AMI connect, PostgreSQL wins:
5. For each time condition with `override_state`: `DBPut SP TCOVR/<id> <state>`.
Keep one function per key type (`setDnd(ext, on)`, etc.). Routes call these after writing PostgreSQL.
M6-T4 implements the sync and `setTcOverride`; DND/forwards (M6-T7), blocks (M6-T8) and queue
pauses (M8) add their keys.
### 5.6 Voicemail watcher (`services/voicemail.ts`)