forked from admin/dyolink
improvements: export to exocad changes reviewed.
This commit is contained in:
@@ -35,6 +35,7 @@ throw new AppException(ErrorCode.PERMISSION_DENIED, HttpStatus.FORBIDDEN);
|
||||
- Schema: `backend/prisma/schema.prisma`
|
||||
- Always add a migration for schema changes (`npm run prisma:migrate` in backend).
|
||||
- Seed permissions stay in sync with `ALL_TAB_PERMISSIONS` in `common/permissions.ts`.
|
||||
- Signup connects the `trial` plan and `CLINIC` / `LAB` organization types by name. `ensureTrialPlan` and `ensureOrganizationType` create a missing row and do not change an existing trial plan's price. Migration `20261021193000_ensure_reference_plans` inserts those rows only when they are absent.
|
||||
- **Schema change ⇒ AdminJS:** update `backend/src/admin/resources.ts` in the same change (add/rename/remove resources, hide new secrets). Trigger-maintained fields such as `LabCase.listedAt` must not be `GENERATED ALWAYS`. See `.cursor/rules/adminjs.mdc`.
|
||||
|
||||
## API responses
|
||||
|
||||
@@ -14,7 +14,7 @@ alwaysApply: false
|
||||
- **Comments:** a generated case hides the eye until a linked clinic is selected; that eye publishes the comment to the clinic. A linked lab reads the thread on the share page and does not use the eye. A received case uses the eye for the clinic. A lab-to-lab case uses it for the sending lab; the sender's handoff lists only comments with that control on.
|
||||
- **Outsource** (`POST /cases/:id/outsource`, label `cases.sendCase`): one linked lab, checked in-progress prosthesis-job steps plus `model_design` / `model_create`, one `LAB_OUTSOURCE` child case. The child stores the sending lab as `referringClinicName` and clears dentist and partner clinic. Those parent steps leave Tasks until the child completes them (written back with no actor). Sender detail shows only that direct lab. The sender chart stays the full plan; the child chart is the selected jobs plus pontics on that bridge, or that line’s teeth for a model step (the whole plan for a historical `__case__` model step). Recall before any of those steps is completed. Received child cases have Outsource, not Start, Delete, or Edit. Scan, packing, and shipping stay on the owning lab. Child `sourceKey` is the child case id. When two selected steps share tooth, prosthesis type, and workflow step, `outsourceChildSourceKey` uses `childId:parentSourceKey` so the current-round unique index accepts both. `dedupeToothJobs` includes `sourceKey`.
|
||||
- **Share link:** QR + URL when the case is sent **or** a lab-origin case is started; token API + focus page — see `.cursor/skills/lab-case-share-link/SKILL.md`.
|
||||
- **Send to Exocad:** local DentalDB SQLite write from the case header, every origin, at every screen size, only in Chrome and Edge (`showOpenFilePicker`). Other browsers do not show the button. There is no local helper and no download fallback. A second send updates the same treatment (`importedOrderId`). An empty `externalCode` becomes that Exocad id when the file is written. The browser remembers the file handle only after the DentalDB check. The next send reopens that file when it still exists and skips Browse. A missing file shows Browse again. A file that is not a DentalDB database is not remembered, and Browse stays available. An empty `workParamsSHA` is filled from the newest saved `WorkParamsDB.xml` case. There is no Local database tab. Keep `LocalDbSessionProvider`, the connect dialog, and the file open/write path.
|
||||
- **Send to Exocad:** local DentalDB SQLite write from the case header, every origin, at every screen size, only in Chrome and Edge (`showOpenFilePicker`). Other browsers do not show the button. There is no local helper and no download fallback. A second send updates the same treatment (`importedOrderId`). An empty `externalCode` becomes that Exocad id when the file is written. The browser remembers the file handle only after the DentalDB check. The next send reopens that file when it still exists and skips Browse. A missing file shows Browse again. A file that is not a DentalDB database is not remembered, and Browse stays available. An empty `workParamsSHA` is copied from the newest saved case whose file name ends with `WorkParamsDB.xml` (not `WorkParamsDB-EndoCrown.xml`) onto a new `WorkParamsInfo` and `WorkParamsInfoLocal`. Do not set treatment `flags` to 16. A tooth is written only when that work type and material already exist; parameters, dependents, and color come from the fullest saved tooth of the same pair. Unmatched lines go to `t_Notes` as `tooth code`. There is no Local database tab. Keep `LocalDbSessionProvider`, the connect dialog, and the file open/write path.
|
||||
- **One plan:** a live case has one prosthesis plan. Clinic send still uses `treatmentDetailId` as `sourceKey`. Lab-origin cases use the case id. Outsource children use the child case id, or `childId:parentSourceKey` when two selected steps would collide (see Outsource). `LabCaseLine` is gone. Detail and New case use `UnderlineTabs`: Details, Files, Messages. Files and Messages show unread counts (`LabCaseSectionReadState`); opening Details does not clear them. `ATTACHMENT_ADDED` is not a sidebar badge. Origin is one combobox of linked clinics and labs, or a typed name. Dentist/Technician stays optional. Arch jobs (`UA`/`LA`) highlight the read-only FDI chart.
|
||||
- **Case Sheet PDF:** same layout for portrait and landscape (Download PDF menu). One A4 page, scaled to fit — the chart is never split. Header is a flex row: current organization name (one line, 56px line box so html2canvas does not clip the 28px glyphs), Nudentic lockup aligned with that text, share QR at 88px inside a 96px frame with `fill` off (a stretched SVG is dropped by html2canvas; not a table cell). Print root top padding is 16px portrait / 24px landscape so the QR is not clipped; `html2canvas` `scrollY` is 0. The page stays LTR in every locale. On `fa`, the org name is a shrink-wrapped `inline-block` (`direction: ltr` unless the name itself contains Arabic script) with `letter-spacing` and `word-spacing` `0px` — a full-width RTL box gaps Latin words. Party and meta values use `printRtlValueStyle` (Arabic script stays RTL; Latin stays LTR and right-aligned). Section rules keep a 12px gap and 8px padding so the line clears the values; `FA_RULE_DROP` (6px) clears Persian descenders. `onclone` must not overwrite the name span’s direction. Print ink is `prosthesisTypePrintColorFromCatalog` (heaviest family swatch). Prosthesis rows are SVG boxes. Chart is 85% of the page width with capped glyph height, shared upper column widths, outline-only unselected teeth, root vs crown fills, a larger gap under the upper caption, and matching tooth/number/midline gaps on both arches. Bridge marks match the FDI chart: 10px `#009cae` dots on the column boundary in the tooth-to-number gap. `onclone` sizes the lockup SVGs and the organization-name line box. Hex inline styles only. Optional `externalCode` replaces the printed order number and the `case-sheet-{orderNumber}.pdf` filename.
|
||||
- **Detail chrome:** The header follows the detail panel width (`@container`, not the viewport): two columns (info start, actions end) from `@2xl`, otherwise one stack with the buttons under the info: name and the same QR thumb (`w-24 sm:w-32`) on the first row, mobile/from/date on one wrapping line, then progress bar, external code, **Mark as important**, and billed, stacked and left aligned. Edit / Outsource / Send to Exocad / Get PDF are one equal-width grid (`responsiveFill`, truncating caption): 2 columns when narrow, one column per button from `@xl`, 2 columns in the `@2xl` end column with the QR below. Get PDF is a primary `CaseLifecycleButton` with no icon. Add files uses that button at the treatment action width. **Add case** is a full-width `px-6 py-3 text-base` split (label + mic) matching New treatment and Add detail voice. There is no Comments button, and opening Messages does not scroll the page. File cards: name at the start and checkbox at the end, then a clipped preview, then size over date at the start with the View/Download menu centered at the end. Remove is on that menu (`DELETE /cases/:id/attachments/:attachmentId`, confirm first). An in-progress upload is its own card with a progress bar. The sent-date line reads “Outsource {date}”.
|
||||
|
||||
@@ -60,9 +60,9 @@ List item shape: `prosthesisGroups: { prosthesisTypeCode, teeth[], ponticTeeth?
|
||||
Writes the open case into a DentalDB SQLite file on this computer. Nothing is uploaded to the Dyolink server. Close Exocad before writing, then open it again.
|
||||
|
||||
- Button `cases.sendToExocad` on the case header at every screen size, every origin, for anyone who can open the case, only when the browser can overwrite the picked file (`showOpenFilePicker`: Chrome and Edge). It is separate from Outsource. Safari and other browsers do not show it. There is no local helper program and no download fallback.
|
||||
- `LocalDbSessionProvider` holds the open file. The browser overwrites the picked file and remembers that file handle (IndexedDB) only after the file passes the DentalDB check. The next send reopens the saved file when it still exists and skips Browse. A missing file shows Browse again. A file that is not a DentalDB database is not remembered, and the connect dialog stays open so Browse can be used again.
|
||||
- Mapper: `frontend/src/components/local-db/exocadTransfer.ts`. Lab id `0`. Match or create the client from `referringClinicName`, otherwise the case clinic name. Never use practice id `2147483647`. Match or create the patient by first and last name. `Treatment.importedOrderId` is the Dyolink case id, so a second send updates that treatment and replaces its `ToothWork` rows. When `workParamsSHA` is empty, the treatment copies that hash and a new `WorkParamsInfo` / `WorkParamsInfoLocal` row from the newest saved case whose file is `WorkParamsDB.xml`. That is the material configuration Exocad needs to open the tooth chart. The CAD-Data project folder is still created by Exocad's own Save.
|
||||
- A tooth is written only when the catalog name has an obvious Exocad material and that work type plus material already exists on a saved tooth. The export copies that tooth’s parameters and color. Glass ceramic is `AnatomicCrown` / `GCER`; zirconia is `ZI`; metal is `NP`; PMMA stays `PMMA`; IPS overlay is `OverlayCrown` / `LS2`. A pontic uses the connected crown’s material when that pontic pair exists. Abutments, posts, indirects with no material in the name, and any pair this file has never saved stay in the treatment notes and are listed after the send. No guessed material is written.
|
||||
- `LocalDbSessionProvider` holds the open file. The browser overwrites the picked file and remembers that file handle (IndexedDB) only after the file passes the DentalDB check. The next send reopens the saved file when it still exists and skips Browse. A missing file shows Browse again. A file that is not a usable DentalDB database is not remembered, and the connect dialog stays open so Browse can be used again.
|
||||
- Mapper: `frontend/src/components/local-db/exocadTransfer.ts`. Lab id `0`. Match or create the client from `referringClinicName`, otherwise the case clinic name. Never use practice id `2147483647`. Match or create the patient by first and last name. `Treatment.importedOrderId` is the Dyolink case id, so a second send updates that treatment and replaces its `ToothWork` rows. When `workParamsSHA` is empty, copy that hash onto a new `WorkParamsInfo` and `WorkParamsInfoLocal` from the newest saved case whose file name ends with `WorkParamsDB.xml` (not `WorkParamsDB-EndoCrown.xml`), then set `workParamsSHA` and `workParamInfoId`. Do not set treatment `flags` to 16. The CAD-Data project folder is still created by Exocad's own Save.
|
||||
- A tooth is written only when the catalog name has an obvious Exocad material and that exact `WorkTypeSN` + `MaterialSN` already exists on a saved tooth. Copy parameters, dependent rows, and `ValuedMaterialParameters` color from the fullest saved tooth of that same pair. Do not copy a donor with no parameters, and do not copy one material's numbers onto another. Obvious pairs: Monolithic Zirconia and PFZ Crown = `AnatomicCrown`/`ZI`; PFM = `Coping`/`NP`; Full Metal = `AnatomicCrown`/`NP`; PMMA = `AnatomicCrown`/`PMMA`; Glass Ceramic Crown = `AnatomicCrown`/`GCER`; pontic = `AnatomicPontic` plus the connected crown material when that pontic pair exists; IPS Overlay = `OverlayCrown`/`LS2`. Pressed Ceramic / IPS e.max (`AnatomicCrown`/`LS2`), PEEK (`AnatomicCrown`/`PEEK`), Veneer Zirconia (`Veneer`/`ZI`), IPS veneers (`Veneer`/`LS2`), and Zirconia Overlay (`AnatomicInlay`/`ZI`) are the same rule: written only when the opened file already has that pair. Temporary resin, veneer/inlay/onlay/overlay full-contour or layered with no material in the name, abutments, cast post, and fiber post get no tooth row. The case header is still created. Unmatched lines are appended to `t_Notes` as `tooth code`, and the skipped toast still lists them.
|
||||
- When the file is written and `externalCode` is empty, save the Exocad `treatment_id` through `PATCH /cases/:id/external-code` (`TAB_CASES_EDIT`).
|
||||
- There is no Local database tab. Send to Exocad keeps `LocalDbSessionProvider`, `LocalDbConnectDialog`, and the file open/write path.
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ frontend/src/
|
||||
**Lab Tasks tab:** Newest case first (`listedAt`); grouping only for date sort; filters include completed step, origin, due date, assignment, and prosthesis. New tasks are plan-scoped: one scan → prosthesis sections → optional Model design/creation (when any type has `requiresModelSteps`) → packing/shipping. `lineCount` stays 1. `__line__` tasks are independently completable. A type with both dry milling and sintering generates `milling_dry_sinter`; both wet milling and sintering generate `milling_wet_sinter`; both stain and glaze generate `stain_glaze`. A type with only one half keeps that half, and existing task rows are not rewritten. Model design and model create can be outsourced with that line’s teeth, or the whole plan for a historical `__case__` model step; scan, packing, and shipping cannot. Historical `__case__` scan keeps whole-case fan-out. Same-type exclusive steps coalesce across matching teeth; duplicate non-model steps for stacked types become `typeA+typeB` sections. Pontics fold into connected crown/indirect sections. Task identity includes source, first tooth, section type, and workflow code because one section may produce different tooth sets across steps. Job titles use `ProsthesisJobLineLabel`; task assignment is in Cases; only assignee/unassigned pool can update status in Tasks. `CASE_COMPLETED` drives inbox/tab badges only after all case tasks finish. See `.cursor/skills/lab-tasks/SKILL.md`.
|
||||
|
||||
**Lab Cases tab:** Filter by **prosthesis type** (not treatment type); auto-select newest case on open; list **10 per page**; left rail list fills column height (`flex-1 overflow-y-auto`). Unstarted lab-origin **drafts** sit in a collapsed expandable rail section (opens on click or **Add case**); received + started cases list below, newest first by send or start time (`listedAt`, same key as Tasks). List cards use `LabCaseProsthesisGroupsList` (colored type + teeth, shared with Treatment rail) plus **From clinic** / **Generated** / **From lab** origin badges. Job titles use `ProsthesisJobLineLabel` the same as Treatment/Tasks (`13 · Pontic - 14 · PFZ Crown`; no category; indirect keeps Inlay · Layered ceramic). Deep link: `?caseId=`, `?clinicOrganizationId=`. **Share link:** QR + URL on sent cases **and** started lab-origin cases (attachment left, QR right); opens `/lab-case/[token]` focus page. **Case Sheet PDF:** same portrait/landscape layout, one A4 page (`jspdf`/`html2canvas`, scaled to fit); realistic FDI chart; hex-only print layout; share QR stays in the flex header; optional `externalCode` replaces order number. The page stays LTR; on Persian sheets the org name is shrink-wrapped (RTL only when the name itself is Arabic script) and labels use `0px` letter-spacing. Lab-origin Start has no clinic send and notifies the linked org once (`PARTNER_CASE_CREATED`, share link); generated-case comments have no visibility toggle. A lab-to-lab case uses the eye button so the sending lab can see that comment. Comments use Cases **or** Tasks permission. Unstarted generated drafts can be deleted (`DELETE /cases/:id`). **Edit** (`POST /cases/:id/stop`) returns a started generated case to that drafts rail: completed steps and the previous prosthesis plan stay as history, in-progress steps are dropped, and the case can be edited and started again. Open outsources with no finished step are cancelled; a finished outsourced step blocks Edit. **Outsource** gives selected in-progress prosthesis steps, plus model design and model create, to one linked lab as a child case. Child `sourceKey` stays the child case id unless two selected steps share tooth, type, and workflow (`childId:parentSourceKey`). The child shows only that sending lab (no original clinic or dentist). Those steps leave Tasks until that lab completes them, and only the sending lab sees that direct handoff. The sender chart stays the full plan; the receiver chart is the selected jobs plus pontics on that bridge, or that line’s teeth for a model step. Scan, packing, and shipping stay on the owning lab. **Live:** inbox Socket.IO → `notifyTabBadgesChanged()` soft-refreshes list + selected detail (no remount). A file upload emits `case-section.changed` on that socket (no inbox card) so Files and Messages unread counts refresh the same way. **Add case** is a full-width split button with the lab mic. One file can be removed from its card menu. An upload keeps running after leaving Files or Cases; the open case adds the file from the upload response without another fetch. Attachments have no size cap; production must recreate nginx from the SSL template or `/api` stays at 50MB. See `.cursor/skills/lab-cases/SKILL.md` and `.cursor/skills/lab-case-share-link/SKILL.md`.
|
||||
**Lab Cases tab:** Filter by **prosthesis type** (not treatment type); auto-select newest case on open; list **10 per page**; left rail list fills column height (`flex-1 overflow-y-auto`). Unstarted lab-origin **drafts** sit in a collapsed expandable rail section (opens on click or **Add case**); received + started cases list below, newest first by send or start time (`listedAt`, same key as Tasks). List cards use `LabCaseProsthesisGroupsList` (colored type + teeth, shared with Treatment rail) plus **From clinic** / **Generated** / **From lab** origin badges. Job titles use `ProsthesisJobLineLabel` the same as Treatment/Tasks (`13 · Pontic - 14 · PFZ Crown`; no category; indirect keeps Inlay · Layered ceramic). Deep link: `?caseId=`, `?clinicOrganizationId=`. **Share link:** QR + URL on sent cases **and** started lab-origin cases (attachment left, QR right); opens `/lab-case/[token]` focus page. **Case Sheet PDF:** same portrait/landscape layout, one A4 page (`jspdf`/`html2canvas`, scaled to fit); realistic FDI chart; hex-only print layout; share QR stays in the flex header; optional `externalCode` replaces the printed order number and the `case-sheet-{orderNumber}.pdf` filename. The page stays LTR; on Persian sheets the org name is shrink-wrapped (RTL only when the name itself is Arabic script) and labels use `0px` letter-spacing. Lab-origin Start has no clinic send and notifies the linked org once (`PARTNER_CASE_CREATED`, share link); generated-case comments have no visibility toggle. A lab-to-lab case uses the eye button so the sending lab can see that comment. Comments use Cases **or** Tasks permission. Unstarted generated drafts can be deleted (`DELETE /cases/:id`). **Edit** (`POST /cases/:id/stop`) returns a started generated case to that drafts rail: completed steps and the previous prosthesis plan stay as history, in-progress steps are dropped, and the case can be edited and started again. Open outsources with no finished step are cancelled; a finished outsourced step blocks Edit. **Outsource** gives selected in-progress prosthesis steps to one linked lab as a child case. Child `sourceKey` stays the child case id unless two selected steps share tooth, type, and workflow (`childId:parentSourceKey`). The child shows only that sending lab (no original clinic or dentist). Those steps leave Tasks until that lab completes them, and only the sending lab sees that direct handoff. The sender chart stays the full plan; the receiver chart is the selected jobs plus pontics on that bridge. **Live:** inbox Socket.IO → `notifyTabBadgesChanged()` soft-refreshes list + selected detail (no remount). A file upload emits `case-section.changed` on that socket (no inbox card) so Files and Messages unread counts refresh the same way. **Add case** is a full-width split button with the lab mic. One file can be removed from its card menu. An upload keeps running after leaving Files or Cases; the open case adds the file from the upload response without another fetch. Attachments have no size cap; production must recreate nginx from the SSL template or `/api` stays at 50MB. **Send to Exocad** (Chrome and Edge only, any screen size; no helper program or download) writes the open case into a DentalDB SQLite file on that computer. There is no Local database tab. Send to Exocad keeps `LocalDbSessionProvider` and reopens the last database file while that file still exists. See `.cursor/skills/lab-cases/SKILL.md` and `.cursor/skills/lab-case-share-link/SKILL.md`.
|
||||
**Lab Cases tab:** Filter by **prosthesis type** (not treatment type); auto-select newest case on open; list **10 per page**; left rail list fills column height (`flex-1 overflow-y-auto`). Unstarted lab-origin **drafts** sit in a collapsed expandable rail section (opens on click or **Add case**); received + started cases list below, newest first by send or start time (`listedAt`, same key as Tasks). List cards use `LabCaseProsthesisGroupsList` (colored type + teeth, shared with Treatment rail) plus **From clinic** / **Generated** / **From lab** origin badges. Job titles use `ProsthesisJobLineLabel` the same as Treatment/Tasks (`13 · Pontic - 14 · PFZ Crown`; no category; indirect keeps Inlay · Layered ceramic). Deep link: `?caseId=`, `?clinicOrganizationId=`. **Share link:** QR + URL on sent cases **and** started lab-origin cases (attachment left, QR right); opens `/lab-case/[token]` focus page. **Case Sheet PDF:** same portrait/landscape layout, one A4 page (`jspdf`/`html2canvas`, scaled to fit); realistic FDI chart; hex-only print layout; share QR stays in the flex header; optional `externalCode` replaces the printed order number and the `case-sheet-{orderNumber}.pdf` filename. The page stays LTR; on Persian sheets the org name is shrink-wrapped (RTL only when the name itself is Arabic script) and labels use `0px` letter-spacing. Lab-origin Start has no clinic send and notifies the linked org once (`PARTNER_CASE_CREATED`, share link); generated-case comments have no visibility toggle. A lab-to-lab case uses the eye button so the sending lab can see that comment. Comments use Cases **or** Tasks permission. Unstarted generated drafts can be deleted (`DELETE /cases/:id`). **Edit** (`POST /cases/:id/stop`) returns a started generated case to that drafts rail: completed steps and the previous prosthesis plan stay as history, in-progress steps are dropped, and the case can be edited and started again. Open outsources with no finished step are cancelled; a finished outsourced step blocks Edit. **Outsource** gives selected in-progress prosthesis steps to one linked lab as a child case. Child `sourceKey` stays the child case id unless two selected steps share tooth, type, and workflow (`childId:parentSourceKey`). The child shows only that sending lab (no original clinic or dentist). Those steps leave Tasks until that lab completes them, and only the sending lab sees that direct handoff. The sender chart stays the full plan; the receiver chart is the selected jobs plus pontics on that bridge. **Live:** inbox Socket.IO → `notifyTabBadgesChanged()` soft-refreshes list + selected detail (no remount). A file upload emits `case-section.changed` on that socket (no inbox card) so Files and Messages unread counts refresh the same way. **Add case** is a full-width split button with the lab mic. One file can be removed from its card menu. An upload keeps running after leaving Files or Cases; the open case adds the file from the upload response without another fetch. Attachments have no size cap; production must recreate nginx from the SSL template or `/api` stays at 50MB. **Send to Exocad** (Chrome and Edge only, any screen size; no helper program or download) writes the open case into a DentalDB SQLite file on that computer. The browser remembers the file only after the DentalDB check and reopens it while it still exists; an invalid file is not remembered, so Browse stays available. A tooth is written only when that work type and material already exist in the file. There is no Local database tab. See `.cursor/skills/lab-cases/SKILL.md` and `.cursor/skills/lab-case-share-link/SKILL.md`.
|
||||
|
||||
**Lab case share link (quick ref):**
|
||||
- Token on first ship **or** lab-origin Start → `/{locale}/lab-case/{token}` after login. Editing a generated case keeps that token. The page reads the current round and the live patient/clinic snapshots. Cases, Treatment lab dispatch, and the Case Sheet QR all use this URL.
|
||||
|
||||
@@ -190,33 +190,19 @@ export async function openWithBrowserPicker(): Promise<DatabaseSink> {
|
||||
if (!picker) {
|
||||
throw new Error('FILE_PICKER_UNAVAILABLE');
|
||||
}
|
||||
// #region agent log
|
||||
fetch('http://127.0.0.1:7814/ingest/421f4a54-ac71-4eaa-bb62-6b661023387a',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'9546d2'},body:JSON.stringify({sessionId:'9546d2',runId:'post-fix',hypothesisId:'C',location:'browserFile.ts:openWithBrowserPicker',message:'picker invoked',data:{phase:'start'},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
try {
|
||||
const [handle] = await picker({
|
||||
multiple: false,
|
||||
excludeAcceptAllOption: false,
|
||||
id: 'dyolink-exocad-database',
|
||||
types: [
|
||||
{
|
||||
description: 'SQLite database',
|
||||
accept: {
|
||||
'application/vnd.sqlite3': ['.db', '.sqlite', '.sqlite3'],
|
||||
'application/x-sqlite3': ['.db', '.sqlite', '.sqlite3'],
|
||||
},
|
||||
const [handle] = await picker({
|
||||
multiple: false,
|
||||
excludeAcceptAllOption: false,
|
||||
id: 'dyolink-exocad-database',
|
||||
types: [
|
||||
{
|
||||
description: 'SQLite database',
|
||||
accept: {
|
||||
'application/vnd.sqlite3': ['.db', '.sqlite', '.sqlite3'],
|
||||
'application/x-sqlite3': ['.db', '.sqlite', '.sqlite3'],
|
||||
},
|
||||
],
|
||||
});
|
||||
const sink = await sinkFromBrowserHandle(handle);
|
||||
// #region agent log
|
||||
fetch('http://127.0.0.1:7814/ingest/421f4a54-ac71-4eaa-bb62-6b661023387a',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'9546d2'},body:JSON.stringify({sessionId:'9546d2',runId:'post-fix',hypothesisId:'C',location:'browserFile.ts:openWithBrowserPicker',message:'picker returned',data:{phase:'returned',fileName:sink.name},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
return sink;
|
||||
} catch (error) {
|
||||
// #region agent log
|
||||
fetch('http://127.0.0.1:7814/ingest/421f4a54-ac71-4eaa-bb62-6b661023387a',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'9546d2'},body:JSON.stringify({sessionId:'9546d2',runId:'post-fix',hypothesisId:'C',location:'browserFile.ts:openWithBrowserPicker',message:'picker failed',data:{phase:'threw',errorName:error instanceof Error ? error.name : 'unknown'},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
],
|
||||
});
|
||||
return sinkFromBrowserHandle(handle);
|
||||
}
|
||||
|
||||
@@ -520,11 +520,12 @@ describe('transferCaseToExocad', () => {
|
||||
|
||||
transferCaseToExocad(query, sampleCase(), options);
|
||||
const header = query.all(
|
||||
'SELECT workParamsSHA, workParamInfoId FROM Treatment WHERE importedOrderId = ?',
|
||||
'SELECT workParamsSHA, workParamInfoId, flags FROM Treatment WHERE importedOrderId = ?',
|
||||
['case-1'],
|
||||
);
|
||||
const infoId = header[0]?.[1];
|
||||
expect(header[0]?.[0]).toBe('file-sha');
|
||||
expect(header[0]?.[2]).toBe(0);
|
||||
expect(infoId).not.toBe(5);
|
||||
expect(query.all('SELECT workParamsDataHash FROM WorkParamsInfo WHERE id = ?', [infoId as number])).toEqual([
|
||||
['content-hash'],
|
||||
|
||||
@@ -21,8 +21,8 @@ const REQUIRED_TABLES = [
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* Catalog names whose material word is one Exocad short code.
|
||||
* A tooth is written only when the opened database already has this pair.
|
||||
* Catalog codes with one obvious Exocad work type and material.
|
||||
* A tooth is written only when the opened database already has that pair.
|
||||
*/
|
||||
const MATERIAL_MATCH: Record<string, { workType: string; material: string }> = {
|
||||
monolithic_zirconia: { workType: 'AnatomicCrown', material: 'ZI' },
|
||||
@@ -515,9 +515,10 @@ function treatmentHasColumn(db: SqliteQuery, column: string): boolean {
|
||||
}
|
||||
|
||||
/**
|
||||
* Point the treatment at the lab's current default material configuration.
|
||||
* Exocad loads WorkParamsInfo by workParamInfoId. A null id is the read-only
|
||||
* project warning and the tooth-click crash. Each saved case has its own info row.
|
||||
* Fill an empty workParamsSHA from the newest saved case whose file name ends
|
||||
* with WorkParamsDB.xml, not WorkParamsDB-EndoCrown.xml. Exocad loads
|
||||
* WorkParamsInfo by workParamInfoId. A null id is the read-only project warning
|
||||
* and the tooth-click crash. Each saved case has its own info row.
|
||||
*/
|
||||
function embedMaterialConfiguration(db: SqliteQuery, treatmentId: number): void {
|
||||
if (!treatmentHasColumn(db, 'workParamsSHA') || !treatmentHasColumn(db, 'workParamInfoId')) return;
|
||||
@@ -547,12 +548,7 @@ function embedMaterialConfiguration(db: SqliteQuery, treatmentId: number): void
|
||||
[treatmentId],
|
||||
);
|
||||
const source = donor[0];
|
||||
if (!source || source[3] == null) {
|
||||
// #region agent log
|
||||
fetch('http://127.0.0.1:7814/ingest/421f4a54-ac71-4eaa-bb62-6b661023387a',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'9546d2'},body:JSON.stringify({sessionId:'9546d2',runId:'post-fix',hypothesisId:'E',location:'exocadTransfer.ts:embedMaterialConfiguration',message:'no material donor',data:{treatmentId},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
return;
|
||||
}
|
||||
if (!source || source[3] == null) return;
|
||||
|
||||
db.run(
|
||||
`INSERT INTO WorkParamsInfo (workParamsDataHash, lastModificationDate) VALUES (?, ?)`,
|
||||
@@ -564,9 +560,6 @@ function embedMaterialConfiguration(db: SqliteQuery, treatmentId: number): void
|
||||
'UPDATE Treatment SET workParamsSHA = ?, workParamInfoId = ? WHERE treatment_id = ?',
|
||||
[String(source[0]), newId, treatmentId],
|
||||
);
|
||||
// #region agent log
|
||||
fetch('http://127.0.0.1:7814/ingest/421f4a54-ac71-4eaa-bb62-6b661023387a',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'9546d2'},body:JSON.stringify({sessionId:'9546d2',runId:'post-fix',hypothesisId:'E',location:'exocadTransfer.ts:embedMaterialConfiguration',message:'embedded material configuration',data:{treatmentId,donorInfoId:numberValue(source[4]),newInfoId:newId,shaCopied:true},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
}
|
||||
|
||||
function writeCase(db: SqliteQuery, input: ExocadCaseInput, options: ExocadTransferOptions): ExocadTransferResult {
|
||||
|
||||
@@ -435,9 +435,6 @@ export function CaseDetailPanel({
|
||||
result = localDb.transferCase(toExocadCase(labCase));
|
||||
} catch (caught) {
|
||||
if (caught instanceof ExocadTransferError) await localDb.abandon();
|
||||
// #region agent log
|
||||
fetch('http://127.0.0.1:7814/ingest/421f4a54-ac71-4eaa-bb62-6b661023387a',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'9546d2'},body:JSON.stringify({sessionId:'9546d2',runId:'post-fix',hypothesisId:'A',location:'CaseDetailPanel.tsx:onSendToExocad',message:'transfer failed',data:{errorName:caught instanceof Error ? caught.name : 'unknown',code:caught instanceof ExocadTransferError ? caught.code : null},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
toast.showError(localDbErrorText(caught, tLocal, 'applyFailed'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
} from 'react';
|
||||
import {
|
||||
assertExocadDatabase,
|
||||
ExocadTransferError,
|
||||
transferCaseToExocad,
|
||||
type ExocadCaseInput,
|
||||
type ExocadTransferResult,
|
||||
@@ -30,8 +29,8 @@ import { LocalDbConnectDialog } from '@/components/ui/local-db/LocalDbConnectDia
|
||||
|
||||
/**
|
||||
* Open Exocad database for Send to Exocad.
|
||||
* Chrome and Edge only. The browser remembers the file handle.
|
||||
* The next send reopens that file when it still exists. A missing file shows Browse again.
|
||||
* Chrome and Edge only. The browser remembers the file handle after the DentalDB check.
|
||||
* The next send reopens that file when it still exists. A missing or rejected file shows Browse again.
|
||||
*/
|
||||
|
||||
export type LocalDbSessionValue = {
|
||||
@@ -79,9 +78,6 @@ export function LocalDbSessionProvider({ children }: { children: ReactNode }) {
|
||||
next.execute((query) => assertExocadDatabase(query));
|
||||
} catch (error) {
|
||||
next.close();
|
||||
// #region agent log
|
||||
fetch('http://127.0.0.1:7814/ingest/421f4a54-ac71-4eaa-bb62-6b661023387a',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'9546d2'},body:JSON.stringify({sessionId:'9546d2',runId:'post-fix',hypothesisId:'D',location:'LocalDbSessionProvider.tsx:replaceWithSink',message:'rejected database',data:{fileName:sink.name,valid:false,errorName:error instanceof Error ? error.name : 'unknown'},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
throw error;
|
||||
}
|
||||
try {
|
||||
@@ -92,17 +88,11 @@ export function LocalDbSessionProvider({ children }: { children: ReactNode }) {
|
||||
sessionRef.current?.close();
|
||||
sessionRef.current = next;
|
||||
sinkRef.current = sink;
|
||||
// #region agent log
|
||||
fetch('http://127.0.0.1:7814/ingest/421f4a54-ac71-4eaa-bb62-6b661023387a',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'9546d2'},body:JSON.stringify({sessionId:'9546d2',runId:'post-fix',hypothesisId:'D',location:'LocalDbSessionProvider.tsx:replaceWithSink',message:'accepted database',data:{fileName:sink.name,valid:true},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
}, []);
|
||||
|
||||
const abandon = useCallback(async () => {
|
||||
dropSession();
|
||||
await forgetBrowserDatabase();
|
||||
// #region agent log
|
||||
fetch('http://127.0.0.1:7814/ingest/421f4a54-ac71-4eaa-bb62-6b661023387a',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'9546d2'},body:JSON.stringify({sessionId:'9546d2',runId:'post-fix',hypothesisId:'A',location:'LocalDbSessionProvider.tsx:abandon',message:'forgot rejected database',data:{forgot:true},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
}, [dropSession]);
|
||||
|
||||
const apply = useCallback(async () => {
|
||||
@@ -130,27 +120,18 @@ export function LocalDbSessionProvider({ children }: { children: ReactNode }) {
|
||||
const sink = sinkRef.current;
|
||||
if (sessionRef.current && sink) {
|
||||
const alive = await browserDatabaseStillExists();
|
||||
// #region agent log
|
||||
fetch('http://127.0.0.1:7814/ingest/421f4a54-ac71-4eaa-bb62-6b661023387a',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'9546d2'},body:JSON.stringify({sessionId:'9546d2',runId:'post-fix',hypothesisId:'A',location:'LocalDbSessionProvider.tsx:requestConnection',message:'existing session',data:{alive,fileName:sink.name},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
if (alive) return true;
|
||||
dropSession();
|
||||
}
|
||||
try {
|
||||
const restored = browserCanWriteLocalFile() ? await reopenStoredBrowserFile() : null;
|
||||
if (restored) {
|
||||
// #region agent log
|
||||
fetch('http://127.0.0.1:7814/ingest/421f4a54-ac71-4eaa-bb62-6b661023387a',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'9546d2'},body:JSON.stringify({sessionId:'9546d2',runId:'post-fix',hypothesisId:'B',location:'LocalDbSessionProvider.tsx:requestConnection',message:'restoring remembered file',data:{fileName:restored.name},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
await replaceWithSink(restored);
|
||||
return true;
|
||||
}
|
||||
} catch (error) {
|
||||
} catch {
|
||||
dropSession();
|
||||
if (error instanceof ExocadTransferError) await forgetBrowserDatabase();
|
||||
// #region agent log
|
||||
fetch('http://127.0.0.1:7814/ingest/421f4a54-ac71-4eaa-bb62-6b661023387a',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'9546d2'},body:JSON.stringify({sessionId:'9546d2',runId:'post-fix',hypothesisId:'B',location:'LocalDbSessionProvider.tsx:requestConnection',message:'remembered file rejected',data:{errorName:error instanceof Error ? error.name : 'unknown'},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
await forgetBrowserDatabase();
|
||||
}
|
||||
return await new Promise<boolean>((resolve) => {
|
||||
connectResolveRef.current = resolve;
|
||||
|
||||
Reference in New Issue
Block a user