Skip to main content

Module domain

Module domain 

Source
Expand description

Pure domain rules: roles, lifecycle states, numbering and validation.

Nothing in here touches the database, which keeps the rules easy to unit test.

The rules are split by area; everything is re-exported here, so callers keep using crate::domain::Name.

Structs§

NumberContext
The values a scheme is expanded with.
NumberScheme
A numbering scheme for generated item numbers, e.g. {PROJECT}-{TYPE}-{YYYY}-{SEQ:4} → ROVER-PRT-2026-0007.
ReviewRequirement
What the review policies of all affected project groups ask of a change. The default asks for nothing beyond “every reviewer approves”.
RoleRequirement
A project group that must be represented among the approvals (a role group such as QA): members are the people whose approval counts.
ServerFile
The server side of a file for the concurrency checks.
Skin
A selectable look of the UI. The colours live in static/style.css ([data-skin="<id>"]), the logos in media/.
TransitionRule
One allowed lifecycle transition: how it happens and who may trigger it. The services enforce these rules; this table documents them in the UI and is checked against LifecycleState::can_transition_to by a unit test.

Enums§

AdminRead
How administrators who are not members read a restricted group (the need-to-know policy, project_policies.admin_read).
ApprovalReauth
Whether a review decision in the browser needs a fresh sign-in (TEAMCRAFT_APPROVAL_REAUTH, #152 step 4). API tokens are not asked: approving needs the approve token scope instead.
AttributeCondition
A search condition on one attribute.
AttributeType
Data type of a custom attribute.
BaseConflict
Why a check-in with a stated base is refused, if it is.
BaseVersion
The server version a client based a change of a file on – the version it checked out, by number or by content hash. A check-in that names a base is refused when the file moved on since (optimistic concurrency).
BasisRole
What a simulation takes from the revision it is based on.
ChangeStatus
Classification
Make, buy or standard part – master data of an item.
Decision
DeviationKind
What a deviation of the built unit from its design concerns.
Disposition
The decision about a deviation (the disposition of a nonconformance).
FileRetention
What happens to the old versions of a file when a newer one is uploaded (files.retention).
FileSyncState
State of a workspace file compared with the server.
FilesHint
The way to add files that the Files card shows.
ItemType
LifecycleState
LineAction
What a line of a change order does when the change is released.
NotificationKind
What a notification is about. Users can mute every kind except Test.
Priority
ProjectVisibility
Who may read the data of a project group.
ReferenceKind
How a revision references another item besides the BOM.
RequestDecision
The decision of the triage on a change request.
RequestReason
Why a change is requested.
RequestStatus
Status of an engineering change request.
ResultFilter
Which result values the item search looks for (latest revision of a simulation): within or outside their limits.
ResultStatus
Whether a result value is within its limits.
ReviewConflict
Why somebody may not review a change order (separation of duties).
ReviewOutcome
Outcome of evaluating all review decisions of a change.
RevisionRule
Decides which revision of a child item is shown in a BOM.
Role
Global user role. Ordering matters: Viewer < Editor < Admin.
Scheme
The colour scheme of a skin.
SignOffMethod
How a reviewer confirmed a decision (stored with the review).
TokenScope
What a personal access token may do with the rights of its user.
WebhookEvent
An event an outgoing webhook can subscribe to (webhooks.events; the CHECK constraint in migration 0022 lists the same names).

Constants§

COMMON_UNITS
Common units of measure offered in the UI. Free text is accepted as well.
DEFAULT_NUMBER_SCHEME
Numbering scheme used when a project group has none: the type prefix and a six-digit sequence, e.g. PRT-000042.
DEFAULT_SKIN
LIFECYCLE_RULES
MAX_ATTRIBUTE_TEXT
Longest text value of an attribute.
MAX_FOLDER_DEPTH
Deepest folder nesting of a file.
MAX_FOLDER_LEN
Longest folder path of a file (characters).
MAX_FOLDER_SEGMENT
Longest single folder name.
MAX_SIGN_OFF_MEANING
Longest stated meaning of a sign-off (“approved as design owner”).
MCP_PATH
The path of the MCP endpoint (the only one an mcp_only token reaches).
MIN_PASSWORD_LEN
SKINS
TEAMCRAFT_ICON
The TeamCraft icon (shown in the header, the footer and as favicon).

Functions§

attainable
The part of the requirement the assigned reviewers can still meet. Reviewers are only changed in Draft, so a policy or a group that changed after submit must not make an in-review change undecidable.
attribute_input_text
An API value as the text parse_attribute_value reads (null → empty).
avatar_tint
A stable avatar tint 1..=6 (--avatar-N in skins.css) from the username.
check_base
Checks an upload against the current server file. Identical content is never a conflict (nothing would be overwritten).
combine_min_approvals
Combines the minimum approvals of several groups: a group without a value wants all reviewers, so the strictest wins.
conflicting_reviewer
Four-eyes check: the reviewer must be neither the author, nor the person who submitted the change (an administrator acting for the author), nor anyone who changed the affected revisions (editors).
files_hint
editable: the user holds the check-out and may modify (the rule of ensure_editable); can_work: the user may check out (project group, role, revision in work, not locked by someone else).
files_type_hint
What to put on an item of this type (the item_type text value).
format_age
3 days, 5 h, 12 min, just now – the age of a lock or an event.
format_change_number
Formats an automatically generated change number, e.g. CHG-000007.
format_request_number
Formats an automatically generated change request number, e.g. ECR-000007.
initials
Up to two initials for the avatar: first letters of the first and last word of the display name (the username when the name is empty).
is_approval
Whether a request approves or releases something: the review of a change order (its approval releases the revisions), the decision on a change request and making a revision obsolete. Needs the approve right of a token, i.e. scope full.
is_skin
like_pattern
Escapes %, _ and \ so user input can be used inside a LIKE pattern.
limit_text
Trims a text and checks it is at most max characters.
normalize_attribute_key
Attribute keys: a-z 0-9 _, starting with a letter, at most 40 characters (vendor, length_mm). Upper case and spaces/dashes are folded (Order No. → order_no).
normalize_folder
Normalises the folder of a file inside its project group – the place it gets in the desktop working folder <workspace>/<GROUP>/<folder>/<file>.
normalize_item_number
Item numbers: 1–64 characters A-Z 0-9 . _ -, starting with a letter or digit. They are normalised to upper case.
normalize_project_code
Project codes: 1–32 characters A-Z 0-9 _ -, normalised to upper case.
normalize_username
Usernames: 2–64 characters a-z 0-9 . _ -, normalised to lower case.
number_context
The values for an item of item_type in project group project created at at.
parse_attribute_choices
The choices of a choice attribute from free text (one per line or separated by ;), trimmed, without duplicates.
parse_attribute_condition
Parses a search value for an attribute of data_type: empty = has a value; text and choices match as substring; yes/no; numbers accept 12, >=10, <=20 and 10..20 (no 10-20, which would clash with negative numbers).
parse_attribute_value
Validates one attribute value given as text (form field, or an API value converted to text) and returns it as JSON; empty input removes the value.
parse_decimal
Parses user supplied decimal numbers, accepting both 1.5 and 1,5. Empty input yields None.
policy_shortfalls
Why a set of reviewers can never satisfy the policy (empty = it can). submit refuses a change with any of these.
require_text
Requires a non-empty, trimmed text of at most max characters.
result_status
Pass when lower <= value <= upper (limits inclusive, either may be missing), fail otherwise; ResultStatus::NoLimits without limits.
review_outcome
A single rejection rejects the change; all reviewers must approve.
review_outcome_with
Outcome of a change under a review policy. A single rejection still rejects; the change is approved when enough reviewers approved, every required person did, and every role group is represented. With the default requirement this equals review_outcome.
revision_code
Converts a 1-based revision sequence number into its revision code: 1 → A, 2 → B, …, 20 → Y, 21 → AA, 22 → AB, …
revision_seq
Inverse of revision_code. Returns None for invalid codes.
rules_from
The rules that lead away from state.
skin_is_light
Whether a skin is always light (the System skin is not: it may be dark).
skin_or_default
Returns the skin id if it is known, otherwise the default skin.
skin_scheme
The colour scheme of a skin (unknown ids: the default skin).
sync_state
Compares a local file (local_sha256) with the server file.
truncate_chars
The first max characters of s, with “…” if it was cut.
validate_non_negative
Validates an optional non-negative number such as a mass or a cost.
validate_password
validate_quantity
Validates a BOM quantity.
validate_result_numbers
Validates a result value and its limits (finite numbers, lower ≤ upper).