All domain types live in a single file:Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Aston2710/mc-modeler/llms.txt
Use this file to discover all available pages before exploring further.
/src/domain/types.ts. They are pure TypeScript — no runtime dependencies, no React imports, no bpmn-js references. Every other layer imports from this file; nothing in types.ts imports from any other layer.
These types define what is stored and what flows through the application. They are not Zod schemas — runtime validation happens at the persistence boundary where needed. The types here are the source of truth for what every store, hook, and component agrees on.
Diagram
The primary persisted entity. Every BPMN file the user works with is aDiagram.
Field notes
| Field | Details |
|---|---|
id | Generated by generateDiagramId() in /src/utils/idGenerator.ts. Never mutated after creation. |
xml | The full BPMN 2.0 XML string using the bpmn: prefix and the OMG namespace (http://www.omg.org/spec/BPMN/20100524/MODEL). Compatible with Bizagi Modeler and Camunda. |
thumbnail | Not stored inline in Supabase — the thumbnail field is always null in the list response and fetched separately via getThumbnail(id). In LocalRepository, it is stored in a dedicated localforage instance. |
updatedAt | In SupabaseRepository, this is set by a BEFORE UPDATE database trigger (diagrams_set_updated_at), making it server-authoritative. The client adopts the returned value as its CAS token for the next save. |
parentDiagramId | Links a sub-process diagram to its parent. Sub-process diagrams are regular Diagram records — they are not a separate entity type. |
subProcessElementId | The id of the bpmn:SubProcess element inside the parent diagram that this diagram expands. Used to re-link after import. |
deletedAt | Soft delete timestamp. When set, the diagram is in the trash and excluded from getAll(). Call restore() to clear it or purge() to permanently delete. |
In
SupabaseRepository.getAll(), the xml field is intentionally left empty in list responses. The XML can be hundreds of kilobytes per diagram, and loading it for every diagram card would be unacceptably slow. Call diagramStore.ensureXml(id) to hydrate the XML on demand when a diagram is opened.Project
A named group of diagrams. Projects enable collaboration at the group level — sharing a project gives access to all diagrams within it.Folder
A local organizational grouping for diagrams. Folders have no permission semantics — they are purely cosmetic, like file-system folders.Folders belong to individual users. In
SupabaseRepository, each folder row has an owner_id column enforced by RLS. Collaborators on a project see the project’s diagrams regardless of which folder those diagrams are in.LibraryImage
Images are first-class entities in MC Modeler, not embedded data URLs. BPMN elements link to images byid via the flujo:linkedImages attribute — they never embed bytes directly in the XML.
The ref field
The ref field is an opaque reference string resolved by the image repository at access time:
| Format | Backend | Resolution |
|---|---|---|
storage://diagram-images/<path> | Supabase Storage | Fetched from the diagram-images bucket |
local://<id> | IndexedDB | Fetched from LocalImageRepository by the image id |
Diagram.xml remains lightweight — it contains image IDs, not base64-encoded binary data.
ImageFolder
Organizes images in the library. Parallel to theFolder type for diagrams, but scoped to the image library.
UserPreferences
User-specific application settings, persisted per device. InSupabaseRepository, preferences are always stored locally (delegated to LocalRepository) — they are not synced to the cloud.
DiagramSort
ValidationResult
Produced by the validation engine (/src/domain/validation.ts) when the user triggers a BPMN check. Results are held in uiStore.validationResults.
useBpmnModeler.scrollToElement(elementId), which selects and scrolls to the offending element in the canvas.
Toast
In-app non-blocking notifications. Managed byuiStore. Toasts auto-dismiss after duration milliseconds; a duration of 0 makes a toast persistent until manually dismissed.
Collaboration Types
CollaboratorRole
| Role | Permissions |
|---|---|
owner | Full control: edit, share, delete, manage collaborators |
editor | Can edit the diagram or project content |
viewer | Read-only access; can view and comment, cannot modify |
Collaborator
Represents a user’s membership in a diagram or project’s collaboration roster.DiagramConflictError
DiagramConflictError is defined in /src/persistence/IDiagramRepository.ts, not in types.ts. It is documented here because it is part of the public domain contract — every caller of IDiagramRepository.save() must handle it.IDiagramRepository.save() when an optimistic concurrency check (CAS — Compare-And-Swap) fails. This happens in SupabaseRepository when expectedUpdatedAt is provided but the record in the database has a different updated_at — meaning another writer saved in between.
diagramStore.saveDiagram() catches this error and implements a two-retry resolution strategy:
First conflict
Re-fetch the current server version. If the server already has this exact XML (another writer saved the same state), adopt the server’s
updatedAt and stop.Retry with fresh version
If the content differs, retry
save() using the freshly fetched updatedAt as the new CAS token.UI State Types
The following types are used byuiStore to manage transient, non-persisted application state.
ActiveModal
Union type of all modal identifiers.null means no modal is open.
DiagramTab
Represents an open editor tab. Thedirty flag drives the unsaved-changes indicator in the tab bar.