Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
fix(production): soft hyphens in long note words, async QR source, docstrings
Raul6bd2b5ecf45a
diff --git a/apps/erp/app/modules/production/production.service.ts b/apps/erp/app/modules/production/production.service.tsindex 31ab930ed2..aeeecffe35 100644--- a/apps/erp/app/modules/production/production.service.ts+++ b/apps/erp/app/modules/production/production.service.ts@@ -2064,6 +2064,10 @@ export async function getJobOperationsList(const JOB_OPERATION_DETAIL_COLUMNS ="*, jobOperationBatch(id, readableId, status, notes), jobOperationTool(*, jobOperationToolStep(jobOperationStepId)), jobOperationParameter(*), jobOperationStep(*, jobOperationStepRecord(*), jobOperationStepSlide(*))" as const;+/**+ * A make method's operations in order, each with its batch, tools,+ * parameters and steps.+ */export async function getJobOperationsByMethodId(client: SupabaseClient<Database>,jobMakeMethodId: stringdiff --git a/apps/erp/app/routes/file+/batch+/$id[.]pdf.tsx b/apps/erp/app/routes/file+/batch+/$id[.]pdf.tsxindex c65f9f7406..0a01695b8b 100644--- a/apps/erp/app/routes/file+/batch+/$id[.]pdf.tsx+++ b/apps/erp/app/routes/file+/batch+/$id[.]pdf.tsx@@ -15,6 +15,7 @@ import { getBase64ImageFromSupabase } from "~/modules/shared/shared.service";const logger = getLogger("erp", "batch-list", "pdf");+/** The batch list PDF: the batch's jobs, items and quantities, and its notes. */export async function loader({ request, params }: LoaderFunctionArgs) {// Permissionless like the job traveler: shop-floor people without ERP// permissions still print the load sheet. Tenant safety comes from thediff --git a/apps/mes/app/components/JobOperation/JobOperation.tsx b/apps/mes/app/components/JobOperation/JobOperation.tsxindex 4bcea38409..aad86587c5 100644--- a/apps/mes/app/components/JobOperation/JobOperation.tsx+++ b/apps/mes/app/components/JobOperation/JobOperation.tsx@@ -224,6 +224,11 @@ type JobOperationProps = {>;};+/**+ * The operator's screen for one job operation. When the operation is in a+ * released batch, the same screen runs the batch: its details, timer and+ * completion.+ */export const JobOperation = ({batch,batchMaterialTotals,diff --git a/apps/mes/app/components/JobOperation/components/BatchOverview.tsx b/apps/mes/app/components/JobOperation/components/BatchOverview.tsxindex f61f44b0d4..68faa73192 100644--- a/apps/mes/app/components/JobOperation/components/BatchOverview.tsx+++ b/apps/mes/app/components/JobOperation/components/BatchOverview.tsx@@ -62,9 +62,11 @@ import { TableSkeleton } from "./TableSkeleton";type ItemType = Parameters<typeof ItemThumbnail>[0]["type"];-// The batch as the unit of work: aggregated quantities, the one shared pick-// per material, where the output lands, and every member job. Rendered by-// JobOperation in place of the per-job details when the "Batch" scope is on.+/**+ * The batch as the unit of work: aggregated quantities, the one shared pick+ * per material, where the output lands, and every member job. Rendered by+ * JobOperation in place of the per-job details when the "Batch" scope is on.+ */export function BatchOverview({batch,totals,diff --git a/apps/mes/app/components/Kanban/components/ItemCard.tsx b/apps/mes/app/components/Kanban/components/ItemCard.tsxindex 85981a97e3..a80f6e851f 100644--- a/apps/mes/app/components/Kanban/components/ItemCard.tsx+++ b/apps/mes/app/components/Kanban/components/ItemCard.tsx@@ -80,6 +80,10 @@ const cardVariants = cva(});+/**+ * A schedule card for one operation, or for a whole batch when the batch's+ * operations are collapsed into one card.+ */export function ItemCard({item,progressByItemId,diff --git a/apps/mes/app/routes/x+/operations.tsx b/apps/mes/app/routes/x+/operations.tsxindex 86c2adbcf4..fc2f405e90 100644--- a/apps/mes/app/routes/x+/operations.tsx+++ b/apps/mes/app/routes/x+/operations.tsx@@ -77,6 +77,10 @@ type BatchTotals = {notes: string | null;};+/**+ * Per batch: the member count, summed quantities, member job numbers and the+ * batch's notes, from the batch members' rows.+ */function getBatchTotals(members: NonNullable<Awaited<ReturnType<typeof getJobOperationBatchMembers>>["data"]@@ -104,8 +108,10 @@ function getBatchTotals(return totals;}-// Collapse operations sharing a jobOperationBatchId into one card: keep the first-// as the card, tag it with the member count and summed quantities.+/**+ * Collapse operations sharing a jobOperationBatchId into one card: keep the+ * first as the card, tag it with the member count and summed quantities.+ */function collapseBatches(items: Item[],batchTotals: Map<string, BatchTotals>diff --git a/apps/mes/app/services/operations.service.ts b/apps/mes/app/services/operations.service.tsindex 86f3ce0ff0..4f07da1539 100644--- a/apps/mes/app/services/operations.service.ts+++ b/apps/mes/app/services/operations.service.ts@@ -490,6 +490,10 @@ export async function getActiveJobOperationsByLocation(});}+/**+ * The member operations of the given batches: quantities, the job number and+ * the batch's notes.+ */export async function getJobOperationBatchMembers(client: SupabaseClient<Database>,batchIds: string[],diff --git a/packages/documents/src/pdf/BatchListPDF.test.ts b/packages/documents/src/pdf/BatchListPDF.test.tsindex 9693243cb1..8dd8ea2e68 100644--- a/packages/documents/src/pdf/BatchListPDF.test.ts+++ b/packages/documents/src/pdf/BatchListPDF.test.ts@@ -9,7 +9,7 @@ import { BatchListPDF } from "./BatchListPDF";import { SAMPLE_JOB_TRAVELER } from "./jobTraveler.samples";import { breakLongNotesWord } from "./notesText";-// Every string the batch list prints, read off its element tree.+/** Every string the batch list prints, read off its element tree. */function printedText(notes: string | null | undefined): string[] {const document = (BatchListPDF as (p: never) => ReactElement)({company: SAMPLE_JOB_TRAVELER.company,@@ -55,11 +55,16 @@ describe("breakLongNotesWord", () => {expect(breakLongNotesWord("x".repeat(40))).toEqual(["x".repeat(40)]);});- it("lets a longer word break every 40 characters", () => {+ it("lets a longer word break every 40 characters, at a soft hyphen", () => {const url = `https://example.com/${"a".repeat(80)}`;const parts = breakLongNotesWord(url);- expect(parts.join("")).toBe(url);- expect(parts.every((part) => part.length <= 40)).toBe(true);+ const pieces = parts.map((part) => part.replace("\u00AD", ""));+ expect(pieces.join("")).toBe(url);+ expect(pieces.every((piece) => piece.length <= 40)).toBe(true);expect(parts).toHaveLength(3);+ expect(parts.slice(0, -1).every((part) => part.endsWith("\u00AD"))).toBe(+ true+ );+ expect(parts.at(-1)).not.toContain("\u00AD");});});diff --git a/packages/documents/src/pdf/blocks/jobTraveler/OperationsBlock.test.ts b/packages/documents/src/pdf/blocks/jobTraveler/OperationsBlock.test.tsindex 9c687fc862..9cbde9e95f 100644--- a/packages/documents/src/pdf/blocks/jobTraveler/OperationsBlock.test.ts+++ b/packages/documents/src/pdf/blocks/jobTraveler/OperationsBlock.test.ts@@ -10,7 +10,7 @@ import { OperationsBlock } from "./OperationsBlock";type Rendered = { texts: string[]; images: number };-// Every text and image the block draws for one operation.+/** Every text and image the block draws for one operation. */function render(operation: Record<string, unknown>): Rendered {const tree = OperationsBlock({block: { type: "operations", showWorkInstructions: false },diff --git a/packages/documents/src/pdf/blocks/jobTraveler/OperationsBlock.tsx b/packages/documents/src/pdf/blocks/jobTraveler/OperationsBlock.tsxindex 42f8e1113a..24a8467b02 100644--- a/packages/documents/src/pdf/blocks/jobTraveler/OperationsBlock.tsx+++ b/packages/documents/src/pdf/blocks/jobTraveler/OperationsBlock.tsx@@ -21,9 +21,11 @@ function getEndPath(operationId: string) {return `${getMESUrl()}/x/end/${operationId}`;}-// Opens the operation without starting anything. The MES decides from the-// live membership whether it runs in a batch, so the code stays right when-// the job leaves the batch after this page is printed.+/**+ * Opens the operation without starting anything. The MES decides from the+ * live membership whether it runs in a batch, so the code stays right when+ * the job leaves the batch after this page is printed.+ */function getOperationPath(operationId: string) {return `${getMESUrl()}/x/operation/${operationId}`;}@@ -90,7 +92,7 @@ export function OperationsBlock({const batch = operation.jobOperationBatch ?? null;const batchNotes = batch?.notes?.trim() ? batch.notes : null;const openQrCode = batch- ? generateQRCode(getOperationPath(operation.id), 10)+ ? () => generateQRCode(getOperationPath(operation.id), 10): null;const setupQrCode =!batch && operation.setupTime > 0diff --git a/packages/documents/src/pdf/notesText.ts b/packages/documents/src/pdf/notesText.tsindex c6aeb09d4e..1c54b3d2c3 100644--- a/packages/documents/src/pdf/notesText.ts+++ b/packages/documents/src/pdf/notesText.ts@@ -5,15 +5,19 @@// react-pdf breaks a line only between words or at the English hyphenation// points it finds, so an unbroken string wider than the page (a URL, a file// path) printed past the margin. Plain-text notes break at spaces, and a-// longer word every NOTES_WORD_CHUNK characters.+// longer word every NOTES_WORD_CHUNK characters. Each piece but the last ends+// in a soft hyphen, the usual mark for a place a word may break.const NOTES_WORD_CHUNK = 40;+const SOFT_HYPHEN = "\u00AD";/** The `hyphenationCallback` for a `<Text>` of plain-text notes. */export function breakLongNotesWord(word: string): string[] {if (word.length <= NOTES_WORD_CHUNK) return [word];const parts: string[] = [];for (let start = 0; start < word.length; start += NOTES_WORD_CHUNK) {- parts.push(word.slice(start, start + NOTES_WORD_CHUNK));+ const end = Math.min(start + NOTES_WORD_CHUNK, word.length);+ const part = word.slice(start, end);+ parts.push(end < word.length ? `${part}${SOFT_HYPHEN}` : part);}return parts;}