Skip to main content

Module api

Module api 

Source
Expand description

The HTTP surface: the router, the session cookie, and the helpers every handler shares.

Two families of route live here and they answer different callers:

  • /api/... — the PLM itself: accounts, part types, the catalog, parts, revisions, uses lists, BOMs and where-used, families and templates, the bake queue, sourcing and settings. The browser page in web/ is its only client today.
  • /api/store/... — the DOCUMENT surface, shaped to what the CAD app’s StoreBackend needs from a remote backend (see store).

Every handler that changes anything returns the new seq, so a client never has to ask a second question to find out whether its cache is stale.

Modules§

accounts
Sign-in, user administration and part types.
attachments
Attachments over HTTP. The rules are in crate::attach.
audit_log
Reading the audit log (crate::audit).
backups
Backups and exports over HTTP — administrators only. The work is in crate::backup.
bake_worker
Server-owned worker controls; all three routes require an administrator.
bom
Assembly structure over HTTP: a revision’s uses list, its BOM, the diff between two revisions’ lists, and where a part is used.
cad
The hosted CAD app (crate::cad) and GET /cad/config, the server describing itself to an installer (plm-cad-integration-todo §2 P2, P4).
catalog
The catalog tree: every signed-in user reads it, administrators shape it.
credentials
Credentials: changing a password, signing out everywhere, API tokens, and the administrator’s view of the sign-in throttle (crate::security).
desktop_link
The desktop app’s browser sign-in (crate::desktop_link) over HTTP.
family
Families, templates and the bake queue over HTTP. The rules are in crate::family; these handlers decide only who is asking.
instructions
Manufacturing instructions on the PLM: which instructions revisions instruct an assembly (crate::model::Revision::instructs).
jobs
The jobs floor queue over HTTP (crate::jobs).
native_import
The final write of the native-model import wizard. Allocation and checkout use the normal APIs; document and BOM land together with a reviewed hash.
parts
Parts, revisions, checkout and lifecycle.
player
The instructions player over HTTP (crate::player): its data, its page per revision, and customer links.
preferences
The per-user preferences store (plm-cad-integration-todo D1, P5): where the CAD app keeps its reserved keys when the PLM is its store, so a user’s settings, dock layout, pins and libraries follow them to any machine, and the mirror of their unsaved work (@recovery) can be resumed on another.
review
Review and approval over HTTP (crate::review): a revision’s review panel, submitting with reviewers, decisions, a round’s changes, comments, and each person’s inbox.
scripts
The administrator’s script editor: list, read, write and delete the files in the scripts directory, and test-run a function.
settings
The administrator’s policy settings. Every signed-in user reads them — the page needs to know whether “New revision” is open while a draft is — and only an administrator changes them.
setup
Optional starter content. All writes use the normal PLM part/document APIs.
sourcing
Sourcing over HTTP: the manufacturer and supplier lists, and a part’s manufacturer parts and offers.
store
The DOCUMENT surface — the contract the CAD app’s StoreBackend will consume, shaped to the five obligations a remote backend carries.
thumbnails
Revision thumbnails over HTTP. The rules are in crate::thumbnail.
tools
The tools library over HTTP (crate::tools): anyone signed in reads it; the author group adds, edits, retires and pictures tools.
workflow
workspace
Workspaces over HTTP. The rules are in crate::workspace.

Structs§

Identity
Who a request is, once its credential has been checked.

Constants§

CSRF_HEADER
The header a browser request that changes anything carries its session’s CSRF token in (crate::security).
SESSION_COOKIE
The cookie the browser session rides in.

Functions§

actor_of
Who a request is, for the audit log: read-only, and without the expiry checks — the handler still decides whether the credential is good, and a session that expires during this request is logged as ended by its owner.
blocking
Run work on the blocking pool. Anything that may call a script goes through here: a hook can wait on the network or a child process, and that wait must not stall the async runtime’s worker threads.
clear_cookie
The Set-Cookie value that ends one.
guard
Every request passes through here before its handler.
health
A tiny health probe, useful before the page exists.
identify
Check the request’s credential and say who it is.
ok_seq
{ "ok": true, "seq": n } — the shape every mutating handler answers with.
require_admin
The signed-in user, who must be an administrator.
require_author
The signed-in user, who must be able to create and edit work.
require_user
The signed-in user, or a 401. A browser session or an API token (crate::security) — the handler does not care which.
router
Build the whole router.
session_cookie
The Set-Cookie value that starts a browser session.
session_token
The session token the request carries, if any.

Type Aliases§

Shared
Shared handler state.