Expand description
Administrator scripts: the directory they live in, the hooks the server calls, and the test run the web editor offers.
The operator’s design:
- Scripts are plain
.jsFILES in a directory on the server (--scripts, default<data>/scripts). The directory is the source of truth, so an administrator can keep it in git. The web editor writes the same files. History is git’s job. - A changed file takes effect on the NEXT call:
Scripts::sourcere-reads a file whenever its modification time or length differs from what it cached. There is no watcher thread and no restart. - Scripts are FULLY TRUSTED — network, the PLM API, the file system and
child processes (
host). - A script that throws, fails to parse or times out in a host call REFUSES
the operation it hooks. The one exception is
AFTER_RELEASE, which runs after the release is committed and so can only report.
§The hooks
One file per hook, each defining one global function that takes one JSON argument:
| File | Function | When |
|---|---|---|
| the type’s own file | partNumber(input) | creating a part of a Script-mode type |
REVISION_LABEL | revisionLabel(input) | creating any revision, when the file exists |
BEFORE_RELEASE | beforeRelease(input) | before a release commits, when the file exists |
AFTER_RELEASE | afterRelease(input) | after a release commits, when the file exists |
A hook NEVER runs while the store lock is held: the store decides on a
snapshot, runs the hook, and then re-checks everything the hook’s answer
depends on inside its one locked write (see crate::db).
Re-exports§
pub use brep_script_core as engine;
Modules§
- host
- The server’s host bindings: what a fully trusted script can reach.
Structs§
- HookDoc
- The hooks, for the page: which file, which function, what it is for.
- Script
File - One file in the directory, as the page lists it.
- Scripts
- The scripts directory and a modification-time cache of its files.
Enums§
- Hook
Result - What a hook call produced, for the caller that runs it.
Constants§
- AFTER_
RELEASE - Told about a release after it commits.
- BEFORE_
RELEASE - May refuse a release.
- DEFAULT_
PART_ NUMBER - The file a new Script-mode part type is offered by default.
- HOOKS
- REVIEWERS
- Proposes a review round’s reviewers when a revision is submitted.
- REVIEW_
EVENT - Told about every review event after it commits — the notification hook.
- REVISION_
LABEL - Suggests or validates the label of every new revision.
Functions§
- run
- Run
functionin the scriptrelative, with the server’s host bindings acting asuser. - run_
source - Run unsaved
source— the editor’s test run of text not yet written. - string_
answer - Read a hook’s answer as a string: either the string itself or the named
field of a returned object (
"B"or{ label: "B" }). - user_
json - The user as a script sees it: identity and groups, never the verifier.