diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index a65606c1..d1fbc97c 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -11,7 +11,7 @@ or `fix(layout): keep the label of a moved gateway`. - [ ] `npm run typecheck` passes - [ ] `npm run gate` passes -- [ ] `src/guide.ts` and the matching page in `docs/` are updated (only if a command, option or output changed) +- [ ] `src/report/guide.ts` and the matching page in `docs/` are updated (only if a command, option or output changed) - [ ] PR title is a changelog-worthy Conventional-Commit summary ## Linked issue diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 70865fd4..0bc522a1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,9 +35,32 @@ them on a private corpus without copying it into the repository, are described i ## How the package is laid out -- `src/`: the CLI (`cli.ts`), the in-memory API (`api.ts`, exported from `index.ts`), the ops, the - layout engine and the Camunda 7 / 8 rules (`platform/`). `src/guide.ts` is the source of - `bpmn guide`, `bpmn kinds` and `--help`. +- `src/`: the three entries (`cli.ts`, `api.ts`, the browser-safe `index.ts`) and one folder per + stage of the pipeline. `src/report/guide.ts` is the source of `bpmn guide`, `bpmn kinds` and + `--help`. + + | folder | holds | + | --- | --- | + | `shared/` | errors and the debug sink, used everywhere | + | `model/` | the moddle tree, kinds, `Doc`, the `ChangeSet` of a mutation | + | `ids/` | id words and slugs, the file's id style, the declared id conventions | + | `xml/` | the text-preserving write, the positional XML reader, the encoding | + | `platform/` | Camunda 7 / 8 knowledge; `profiles/` holds the engine rules that load on demand | + | `ops/` | the semantic edits (`add`, `connect`, `set`, ...) and the ops JSON of `apply` | + | `diagram/` | the drawing (BPMN DI) and the geometry building blocks the engines share | + | `layout/` | the layout engines: `clean/` redraws, `incremental.ts` keeps a hand-made drawing | + | `format/` | the format ops (`place`, `align`, `color`, `label`, `route`, `space`, `tidy`, `compact`) | + | `render/` | the SVG of a diagram | + | `validate/` | structural validation, the validator hook, the bpmnlint validator | + | `query/` | the read views: `show`, `find`, `--around`, `--context`, the selectors | + | `pipeline/` | the transactions: `mutateDoc`, `layoutDoc`, `checkDoc` | + | `report/` | what a command prints, as text and JSON, and the guide | + | `node/` | the Node-only layer (`@miragon/bpmn-cli/node`): files, the `.bpmnlintrc`, PNG | + + Where new code goes: a change of the model's semantics is an op (`ops/`); reading the model + without changing it is a view (`query/`); deciding positions is `layout/`, or `format/` when a + user asks for it; geometry more than one engine needs is `diagram/`; text or JSON for the user + is `report/`; anything that touches the file system or `process` is `node/` or `cli.ts`. - `test/`: the vitest suite. It also pins the documentation: the README quick start and the examples in `docs/` must match what the CLI prints. `test/setup.ts` clears `BPMN_KEEP_FLOW_IDS` of your shell before every file, so the tests see the CLI's defaults. @@ -85,7 +108,7 @@ names of zeebe content, see [Camunda 8](docs/camunda.md#camunda-8)). generated from them via [release-please](https://github.com/googleapis/release-please), so a `feat` or `fix` title is what users read in the release notes. - **Documentation moves with the code.** A change to a command, an option or an output also - changes `src/guide.ts` and the matching page in `docs/`. + changes `src/report/guide.ts` and the matching page in `docs/`. ## Before opening a PR diff --git a/docs/testing.md b/docs/testing.md index ce285c0a..f53d4320 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -399,7 +399,7 @@ npx vitest run test/isomorphic.test.ts loads, naming both (Rollup / Vite would put that module into the host's entry chunk and make the rule chunk import the entry chunk back: a host whose entry module awaits a Camunda 7 / 8 call at top level would hang; - the rules get the core helpers from `src/platform/rule-kit.ts`); and + the rules get the core helpers from `src/platform/profiles/rule-kit.ts`); and when a size is over its budget in `tools/iso/budget.json` (KB = 1024 bytes; set to the measured size plus about 2 %: raise one only in the change that needs it, with the reason in @@ -421,7 +421,7 @@ npx vitest run test/isomorphic.test.ts installed `camunda-bpmn-moddle`; regenerate it with `node tools/gen-camunda-descriptor.mjs`. - The same file bundles `src/index.ts` as an ESM split bundle (what Vite or - esbuild make of the `import()` in `src/platform/profile.ts`), writes a + esbuild make of the `import()` in `src/platform/profiles/profile.ts`), writes a fresh copy per case, loads it with Node's own loader and records which chunk is evaluated: a plain model (also with a host validator, whose error, pre-existing error and covered lint warning come out like Node's) and @@ -596,7 +596,7 @@ draw the engine corpus with the same CLI. ## Roundtrip fidelity A write changes the text of the elements it changed and nothing else -(src/preserve.ts, src/mirror.ts; [contract.md](contract.md#what-a-write-changes)). Two checks +(src/xml/preserve.ts, src/model/mirror.ts; [contract.md](contract.md#what-a-write-changes)). Two checks keep it that way: - `test/roundtrip.test.ts` (part of `npx vitest run`): the synthetic @@ -628,7 +628,7 @@ not from the writer: a file without a diagram is drawn, the incremental layout completes missing DI (an edge, a shape, the plane's `bpmnElement`) and routes a line that does not reach its ends again (`detachedEdge`). With `--no-layout` every no-op must be byte-identical; a `fall-backs` count -above zero means preserve.ts could not keep a file's text (the note says +above zero means xml/preserve.ts could not keep a file's text (the note says why) and deserves a synthetic fixture. ## Speaking ids @@ -664,7 +664,7 @@ flow between two lanes). ## Engine checks (Camunda 7) -The Camunda 7 profile of `bpmn validate` (`src/platform/c7.ts`) states for +The Camunda 7 profile of `bpmn validate` (`src/platform/profiles/c7.ts`) states for every rule what the engines do. `test/c7-profile.test.ts` holds one synthetic model per rule (82 models) with the expected codes and the engine verdict; by default it checks only the profile. To re-check the verdicts against live @@ -704,7 +704,7 @@ element by element. ## Engine checks (Camunda 8) -The Camunda 8 profile (`src/platform/c8.ts`) states for every rule what +The Camunda 8 profile (`src/platform/profiles/c8.ts`) states for every rule what Camunda 8.9 does; placement and known names come from the Zeebe descriptor (`src/platform/zeebe.ts`, the inlined `zeebe-bpmn-moddle`; regenerate with `node tools/gen-camunda-descriptor.mjs`, `test/isomorphic.test.ts` fails diff --git a/src/api.ts b/src/api.ts index 73328888..56dae30c 100644 --- a/src/api.ts +++ b/src/api.ts @@ -21,14 +21,14 @@ * whether it is byte-identical to the input (nothing to save), and what the * CLI prints with --json (changes, warnings, layout, validation, import * warnings; the model view with `show`), without the XML. renderMutation - * (src/report.ts) gives the CLI's text for it. The CLI's guards apply: a + * (src/report/command-report.ts) gives the CLI's text for it. The CLI's guards apply: a * lossy import (E_IMPORT_LOSSY), validation errors the ops would introduce * (E_VALIDATION) and content a retype would delete (E_WOULD_DROP_CONTENT) * are refused unless `force`; the layout modes, the format ops and the * platform profile's new findings work as in the CLI, a host's own * validators (`validators`) run in the same transaction, `keepFlowIds` * keeps flow ids like `--keep-flow-ids`, and `conventions` are the declared - * id conventions new ids follow (src/conventions.ts; a host that lints with + * id conventions new ids follow (src/ids/conventions.ts; a host that lints with * element-id-naming builds them from the same configuration). The result * keeps the input's text wherever the ops changed nothing (the * text-preserving step). @@ -37,25 +37,25 @@ * candidates, hint, op), exactly what the CLI prints with --json; the input * string is never modified. */ -import { parseOps } from './batch.js'; -import type { DebugSink } from './debug.js'; +import { parseOps } from './ops/batch.js'; +import type { DebugSink } from './shared/debug.js'; import { layoutProblems, type LayoutMetrics } from './diagram/metrics.js'; -import { layoutView, type LayoutView } from './diagram/view.js'; -import { aroundView, elementContext, type AroundView, type ElementContext } from './context.js'; -import type { BpmnlintSeverity } from './bpmnlint.js'; -import { conventionsView, type ConventionsView, type IdConventions, type Undeclared } from './conventions.js'; -import { Doc, type NewDocOptions } from './document.js'; -import { CliError, usageError } from './errors.js'; -import { renderAround, renderContext, renderDetail, renderLayoutView, renderView } from './format.js'; -import { assertKindToken } from './kinds.js'; -import type { LayoutEngine } from './layout.js'; +import { layoutView, type LayoutView } from './query/layout-view.js'; +import { aroundView, elementContext, type AroundView, type ElementContext } from './query/context.js'; +import type { BpmnlintSeverity } from './validate/bpmnlint-validator.js'; +import { conventionsView, type ConventionsView, type IdConventions, type Undeclared } from './ids/conventions.js'; +import { Doc, type NewDocOptions } from './model/document.js'; +import { CliError, usageError } from './shared/errors.js'; +import { renderAround, renderContext, renderDetail, renderLayoutView, renderView } from './report/view-text.js'; +import { assertKindToken } from './model/kinds.js'; +import type { LayoutEngine } from './layout/index.js'; import { listAllExtensions, type ExtensionInfo } from './ops/ext.js'; import type { Op } from './ops/types.js'; -import { assertLayoutOptions, assertLossless, checkDoc, layoutDoc, mutateDoc, type LayoutMode, type MutationResult } from './pipeline.js'; -import type { PlatformChoice } from './platform/profile.js'; -import { mutationReport, validationReport, type MutationReport, type ValidationReport } from './report.js'; -import type { Validator, ValidatorFinding } from './validators.js'; -import { buildView, elementDetail, findElements, scopeView, type ElementDetail, type FindHit, type ModelView } from './view.js'; +import { assertLayoutOptions, assertLossless, checkDoc, layoutDoc, mutateDoc, type LayoutMode, type MutationResult } from './pipeline/index.js'; +import type { PlatformChoice } from './platform/profiles/profile.js'; +import { mutationReport, validationReport, type MutationReport, type ValidationReport } from './report/command-report.js'; +import type { Validator, ValidatorFinding } from './validate/validators.js'; +import { buildView, elementDetail, findElements, scopeView, type ElementDetail, type FindHit, type ModelView } from './query/model-view.js'; /** Options of the writing functions (the CLI's mutation flags). */ export interface EditOptions { diff --git a/src/cli.ts b/src/cli.ts index 37abef21..cd74d294 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -25,27 +25,27 @@ import { mkdir, readFile, writeFile } from 'node:fs/promises'; import { tmpdir } from 'node:os'; import { basename, dirname, extname, join } from 'node:path'; import { Command, CommanderError, type Command as CommandType, InvalidArgumentError, Option } from 'commander'; -import { BOUNDARY_SIDE_VALUES, COLOR_VALUES, LABEL_SIDE_VALUES, parseOps, SIDE_VALUES } from './batch.js'; -import { setLayoutDebug } from './debug.js'; +import { BOUNDARY_SIDE_VALUES, COLOR_VALUES, LABEL_SIDE_VALUES, parseOps, SIDE_VALUES } from './ops/batch.js'; +import { setLayoutDebug } from './shared/debug.js'; import { layoutProblems } from './diagram/metrics.js'; -import { changeHighlight, RENDER_MAX_SIZE, renderSvg, scaleText, type RenderHighlight, type RenderOptions, type RenderProblem } from './diagram/render.js'; +import { changeHighlight, RENDER_MAX_SIZE, renderSvg, scaleText, type RenderHighlight, type RenderOptions, type RenderProblem } from './render/index.js'; import { renderShown, viewDoc, type ViewOptions } from './api.js'; -import { AROUND_DEFAULT_DEPTH } from './context.js'; -import { conventionsView, renderConventions, type Undeclared } from './conventions.js'; -import { assertProcessId, assertTarget, Doc } from './document.js'; -import { CliError, ioError, isCliError, usageError, type Warning } from './errors.js'; -import { renderExtensionList, renderFind, renderMetrics, renderView } from './format.js'; -import { guideShort, guideText, guideTopic, KINDS_SECTION_NAMES, kindsJson, kindsSectionJson, kindsSectionText, kindsSections, kindsText } from './guide.js'; -import { assertKindToken } from './kinds.js'; +import { AROUND_DEFAULT_DEPTH } from './query/context.js'; +import { conventionsView, renderConventions, type Undeclared } from './ids/conventions.js'; +import { assertProcessId, assertTarget, Doc } from './model/document.js'; +import { CliError, ioError, isCliError, usageError, type Warning } from './shared/errors.js'; +import { renderExtensionList, renderFind, renderMetrics, renderView } from './report/view-text.js'; +import { guideShort, guideText, guideTopic, KINDS_SECTION_NAMES, kindsJson, kindsSectionJson, kindsSectionText, kindsSections, kindsText } from './report/guide.js'; +import { assertKindToken } from './model/kinds.js'; import { projectIdConventions } from './node/bpmnlint.js'; import { assertNewFile, checkFile, checkLoadedDoc, decodeXmlBytes, layoutDocToFile, layoutFile, mutateDocToFile, mutateFile, readDoc, readXml, type FileMutationOptions } from './node/files.js'; import { renderPng } from './node/render.js'; import { listAllExtensions } from './ops/ext.js'; import { parseSpaceAmount, type AddOp, type AlignOp, type ColorOp, type CompactOp, type ConnectOp, type ExtOp, type LabelOp, type MoveOp, type Op, type OrderOp, type PlaceOp, type RemoveOp, type RetypeOp, type RouteOp, type SetOp, type SpaceOp, type TidyOp, type TriggerOptions } from './ops/types.js'; -import { assertLossless, LAYOUT_MODES, type LayoutMode, type MutationResult } from './pipeline.js'; -import { PLATFORM_CHOICES, type PlatformChoice } from './platform/profile.js'; -import { advisoryValidators, mutationReport, mutationSummary, mutationWarnings, renderMutation, renderSummary, renderValidation, validationReport, validatorTag, type MutationReport, type MutationSummary } from './report.js'; -import { findElements } from './view.js'; +import { assertLossless, LAYOUT_MODES, type LayoutMode, type MutationResult } from './pipeline/index.js'; +import { PLATFORM_CHOICES, type PlatformChoice } from './platform/profiles/profile.js'; +import { advisoryValidators, mutationReport, mutationSummary, mutationWarnings, renderMutation, renderSummary, renderValidation, validationReport, validatorTag, type MutationReport, type MutationSummary } from './report/command-report.js'; +import { findElements } from './query/model-view.js'; /** The package version (dist/cli.js and src/cli.ts both sit one level below package.json). */ const VERSION = (JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')) as { version: string }).version; @@ -82,7 +82,7 @@ function printJson(value: unknown, pretty?: boolean, out: Out = process.stdout): } /** - * The result of a mutation (src/report.ts: the same for the CLI and the + * The result of a mutation (src/report/command-report.ts: the same for the CLI and the * in-memory API); --render draws the result (its own block / `render` key); * --strict exits 5 on any warning (process.exitCode, like every exit code: * process.exit would cut off what a pipe has not taken yet, beyond 64 KB on macOS). @@ -444,7 +444,7 @@ function kindArg(value: string): string { return value; } -/* The same rules `apply` enforces on ops JSON (batch.ts), spelled with CLI flags. */ +/* The same rules `apply` enforces on ops JSON (ops/batch.ts), spelled with CLI flags. */ const PLACEMENT_FLAGS = ['after', 'before', 'flow', 'in', 'on'] as const; const FLOW_FLAGS: Record = { flowName: '--flow-name', flowId: '--flow-id', condition: '--condition', language: '--language', default: '--default' }; @@ -908,7 +908,7 @@ async function runFormat(file: string, op: Op, o: RawOpts): Promise { }, opts.json); } -/** --path [--via ], --kind , --branch (src/diagram/select.ts). */ +/** --path [--via ], --kind , --branch (src/query/select.ts). */ function withSelectors(cmd: CommandType, what: string): CommandType { return cmd .option('--path ', `${what} every node${what === 'colour' ? ' and flow' : ''} on the shortest sequence-flow path `) diff --git a/src/diagram/containers.ts b/src/diagram/containers.ts index a36e9471..0e7c5c7c 100644 --- a/src/diagram/containers.ts +++ b/src/diagram/containers.ts @@ -27,7 +27,7 @@ * same border as before, in the same order, with their labels. * Every function returns the ids it moved or resized. */ -import { SIZES } from '../layout/types.js'; +import { SIZES } from './types.js'; import { bottom, copyBox, cy, median, right, type Box } from './geom.js'; import { boundariesOf, contentOf, isLeaf, type DEdge, type DShape, type Plane, type Semantics } from './plane.js'; diff --git a/src/diagram/drawn-ids.ts b/src/diagram/drawn-ids.ts index 2cd2f323..9df52ed4 100644 --- a/src/diagram/drawn-ids.ts +++ b/src/diagram/drawn-ids.ts @@ -13,7 +13,7 @@ * draws or keys by id (processes, collaborations, participants, lanes, * flow nodes, sequence and message flows, data object / store references, * text annotations, groups, associations, data associations) that has no - * id one in the file's id style (src/idstyle.ts; `allocate` claims it in + * id one in the file's id style (src/ids/style.ts; `allocate` claims it in * the caller's registry, by default a registry of every id of `defs`), and * returns them in document order: its name, else its kind and `In `; * a connection names its ends. Nodes and containers get theirs first, so @@ -22,10 +22,10 @@ * id-less elements it changes nothing. The incremental layout does not * need it: it never draws an element without id (the element keeps no DI). */ -import { IdRegistry } from '../ids.js'; -import { contextOf as placeOf, flowRequest, IdStyle, kindRequest, labelOf, typeRequest, type IdRequest } from '../idstyle.js'; -import { kindLabel, kindOf, triggerOf } from '../kinds.js'; -import { indexById, is, isDiElement, walk, type El } from '../model.js'; +import { IdRegistry } from '../ids/slugs.js'; +import { contextOf as placeOf, flowRequest, IdStyle, kindRequest, labelOf, typeRequest, type IdRequest } from '../ids/style.js'; +import { kindLabel, kindOf, triggerOf } from '../model/kinds.js'; +import { indexById, is, isDiElement, walk, type El } from '../model/moddle.js'; /** Element types a full redraw draws (shape, edge or plane) or keys by id. */ const DRAWN = [ diff --git a/src/diagram/geom.ts b/src/diagram/geom.ts index bd82108e..b298e0d1 100644 --- a/src/diagram/geom.ts +++ b/src/diagram/geom.ts @@ -5,7 +5,7 @@ * about moddle or DI. Boxes are `{x, y, width, height}` in diagram pixels, * y grows downwards. */ -import type { Box, Point } from '../layout/types.js'; +import type { Box, Point } from './types.js'; export type { Box, Point }; diff --git a/src/diagram/groups.ts b/src/diagram/groups.ts index 14a9cc92..a06016de 100644 --- a/src/diagram/groups.ts +++ b/src/diagram/groups.ts @@ -16,7 +16,7 @@ * the plane elements; nothing else runs then. * - membersOf(groups): element id -> the ids of the groups that held it, * outermost (largest old box) first; the clean engine keeps the parts of - * a scope no flow connects together by it (layout/place.ts). + * a scope no flow connects together by it (layout/clean/place.ts). * - redrawGroups(moddle, defs, groups), after the redraw, in the order of * the old boxes' areas (smallest first, so a group inside another one is * drawn first and counts as its member): a group whose element is gone, @@ -56,7 +56,7 @@ * materialise empty collections on the semantic elements). */ import type { BpmnModdle } from 'bpmn-moddle'; -import { addTo, is, type El } from '../model.js'; +import { addTo, is, type El } from '../model/moddle.js'; import { bottom, containsPoint, cx, cy, inside, overlaps, right, union, unionAll, type Box, type Point } from './geom.js'; import { idOf, raw, rawList } from './plane.js'; diff --git a/src/diagram/labels.ts b/src/diagram/labels.ts index 971fa6df..01ce06b6 100644 --- a/src/diagram/labels.ts +++ b/src/diagram/labels.ts @@ -58,8 +58,8 @@ * above / below the longest horizontal segment, left / right of the * longest vertical one (undefined when the flow has none). */ -import { labelSize } from '../layout/types.js'; -import { is } from '../model.js'; +import { labelSize } from './types.js'; +import { is } from '../model/moddle.js'; import { bottom, cx, cy, inside, overlaps, right, segmentHits, type Box } from './geom.js'; import { frameOf, raw, titleOf, type DEdge, type DShape, type Plane } from './plane.js'; import { attachedSide } from './router.js'; diff --git a/src/diagram/metrics.ts b/src/diagram/metrics.ts index 2d85b84c..5af9e0d6 100644 --- a/src/diagram/metrics.ts +++ b/src/diagram/metrics.ts @@ -134,8 +134,8 @@ * ids (order-free for symmetric kinds) and the detail unless it is a * measurement (parallelRun length). Duplicates are matched one to one. */ -import { is, parseXml, type El } from '../model.js'; -import type { Box, Point } from '../layout/types.js'; +import { is, parseXml, type El } from '../model/moddle.js'; +import type { Box, Point } from './types.js'; import { titleBox } from './text.js'; /** structural defects the regression harness does not measure (see contract) */ diff --git a/src/diagram/place.ts b/src/diagram/place.ts index f346a683..d29cdaf1 100644 --- a/src/diagram/place.ts +++ b/src/diagram/place.ts @@ -10,19 +10,19 @@ * normal flow's new nodes, so the two do not cross), then nodes with a * placed successor, then the rest (chains of new nodes are placed one after * the other). When more nodes follow, ctx.afterNode gets the node just - * placed (incremental.ts routes its flows and measures the spacing again, + * placed (layout/incremental.ts routes its flows and measures the spacing again, * as the next single command would see them). A join placed in this run * that a flow from its last placed predecessor would enter backwards (no * loop return) is placed again right of its predecessors, before its one * successor, as the `connect` into it does as a single command - * (pullPlacedJoins; incremental.ts pullJoins for joins drawn before). The rules + * (pullPlacedJoins; layout/incremental.ts pullJoins for joins drawn before). The rules * (gap = median horizontal gap between connected neighbours of the plane, * clamped 40..100, fallback 60; row = median row spacing, clamped 80..150): * - splice (the flow P->S was split by N; also N in a chain of new nodes * after a node spliced before S in this run, when S still follows N * through new nodes, branches included: a decision with a new "no" * branch or a `split` in the chain keeps the splice; a join re-placed by - * incremental.ts pullJoins, before its successor): x = P.right + gap (more + * layout/incremental.ts pullJoins, before its successor): x = P.right + gap (more * where P's label and N's on one side, below or above, would come closer * than 4 px; the same between N and S), centred on * S's row when S is in P's row band (or P is a branching node: another @@ -70,7 +70,7 @@ * when they are placed); a node without any successor yet keeps room for * one event (the next command mostly ends the branch there). The chosen * head and its number of candidates are recorded (ctx.heads); the local - * repair (incremental.ts) can ask for the next cheapest one (ctx.skip). + * repair (layout/incremental.ts) can ask for the next cheapest one (ctx.skip). * - unconnected: below the content of its frame (expanded sub-process, lane, * pool or plane), left-aligned at the frame's first column; only the * frame's own content counts (its members, what is drawn in it, the @@ -79,7 +79,7 @@ * Obstacles are the frame's content plus whatever is drawn inside the frame * without belonging to it (annotations and data in a lane, collaboration * annotations in a pool). Groups are obstacles, except a group drawn around - * the anchor: the new node may go inside it (incremental.ts grows the group), + * the anchor: the new node may go inside it (layout/incremental.ts grows the group), * and on a plane without pools that group confines the space tool like a * pool. A boundary event avoids the spots where connections dock on the * host. A relocated node keeps its size and DI; a BPMNShape without valid @@ -102,10 +102,10 @@ * associated with, data object / store below-right of the activity it is * connected to (unconnected: like an unconnected node). */ -import { layoutDebug, layoutDebugOn } from '../debug.js'; -import { annotationSize } from '../layout/place.js'; -import { SIZES } from '../layout/types.js'; -import { is, type El } from '../model.js'; +import { layoutDebug, layoutDebugOn } from '../shared/debug.js'; +import { annotationSize } from '../layout/clean/place.js'; +import { SIZES } from './types.js'; +import { is, type El } from '../model/moddle.js'; import { bottom, clamp, cx, cy, median, overlaps, pathHits, right, segmentHits, type Box, type Point } from './geom.js'; import { defaultLabelSide, hasExternalLabel, labelAt, labelSideOf, labelSizeOf } from './labels.js'; import { boundariesOf, frameOf, frameInterior, idOf, inFrame, isLeaf, isSubProcess, poolOf, raw, rawList, shapeKind, type DEdge, type DShape, type Plane, type Semantics } from './plane.js'; @@ -150,7 +150,7 @@ export interface PlaceCtx { * called after placeFlowNodes placed a node when more nodes follow: its * sequence flows to drawn nodes are routed (and labelled) right away, so * what a batch places next sees them like the next single command would - * (incremental.ts routeNow) + * (layout/incremental.ts routeNow) */ afterNode?: (plane: Plane, id: string) => void; /** fixed sizes for blocks laid out elsewhere (new expanded sub-processes, pools) */ @@ -162,7 +162,7 @@ export interface PlaceCtx { notes: string[]; /** nodes placed in this run as a splice: the successor S they were spliced before (a chain of new nodes continues it) */ spliced?: Map; - /** joins placed again right of their rightmost predecessor, before this successor (incremental.ts pullJoins) */ + /** joins placed again right of their rightmost predecessor, before this successor (layout/incremental.ts pullJoins) */ joins?: Map; /** shapes whose label is placed again at the end (a boundary event moved to the top border) */ relabel?: Set; @@ -638,7 +638,7 @@ function chainCost(plane: Plane, box: Box, cand: Cand): number { * The candidate a branch or exception path starts at: the cheapest by * connectionCost and chainCost plus its penalty, or, when the local repair * asked for it (ctx.skip: the chain crossed a line after placement, - * incremental.ts), the next cheapest one. The head and its number of + * layout/incremental.ts), the next cheapest one. The head and its number of * candidates are recorded (ctx.heads), so the repair knows what it can retry. */ function cheapest(ctx: PlaceCtx, id: string, plane: Plane, from: DShape, kind: ShapeKind, cands: Cand[]): Cand { @@ -1191,7 +1191,7 @@ function topCandidates(ctx: PlaceCtx, plane: Plane, id: string, probe: Probe, ev function seatOnTop(ctx: PlaceCtx, plane: Plane, event: DShape, spot: Box): void { const moved = shiftShape(plane, event.id, spot.x - event.bounds.x, spot.y - event.bounds.y); for (const m of moved) if (!ctx.placed.has(m)) ctx.moved.add(m); - // its label is placed again once its path is drawn (incremental.ts labels) + // its label is placed again once its path is drawn (layout/incremental.ts labels) if (event.label) (ctx.relabel ??= new Set()).add(event.id); ctx.notes.push(`${event.id} moved to the top border of ${event.hostId}: its path runs above it (below, it would cross a line or take more room)`); } @@ -1268,7 +1268,7 @@ function leadsTo(ctx: PlaceCtx, from: string, to: string): boolean { * whose last predecessor `id` was just placed, and that a flow from one of * its predecessors would now enter backwards (no loop return), is placed * again right of its rightmost predecessor, before its one successor S: what - * the `connect` into it does as a single command (incremental.ts + * the `connect` into it does as a single command (layout/incremental.ts * pullJoins). Same conditions: a gateway with two or more incoming flows and * one outgoing flow to S, its predecessors and S in its pool / sub-process, * S right of the predecessors. diff --git a/src/diagram/plane.ts b/src/diagram/plane.ts index 39b2f017..dcc5ac9c 100644 --- a/src/diagram/plane.ts +++ b/src/diagram/plane.ts @@ -25,7 +25,7 @@ * - semantics(defs) indexes the semantic model once (ids, lanes, pools, * scopes); homePlane() says on which plane an element's DI belongs. */ -import { is, type El } from '../model.js'; +import { is, type El } from '../model/moddle.js'; import type { ShapeKind } from './router.js'; import { unionAll, type Box, type Point } from './geom.js'; import { titleBox, titleDepth } from './text.js'; diff --git a/src/diagram/router.ts b/src/diagram/router.ts index a2c3826c..0b1411c3 100644 --- a/src/diagram/router.ts +++ b/src/diagram/router.ts @@ -71,7 +71,7 @@ * `crossings(points, lines)` counts a route's proper crossings with `lines` * (the test of the cost). */ -import type { Box, Point } from '../layout/types.js'; +import type { Box, Point } from './types.js'; export type Side = 'left' | 'right' | 'top' | 'bottom'; diff --git a/src/diagram/separate.ts b/src/diagram/separate.ts index 3bf5ab60..eec4ca1a 100644 --- a/src/diagram/separate.ts +++ b/src/diagram/separate.ts @@ -32,7 +32,7 @@ * every unit active and movable. For `bpmn layout --tidy` and the `tidy` * format op. */ -import { layoutDebug, layoutDebugOn } from '../debug.js'; +import { layoutDebug, layoutDebugOn } from '../shared/debug.js'; import { bottom, right, type Box } from './geom.js'; import { frameOf, isLeaf, type DShape, type Plane } from './plane.js'; import { fitInFrame, shiftShape, unitBox } from './space.js'; diff --git a/src/diagram/space.ts b/src/diagram/space.ts index 785ee4d9..23a266d4 100644 --- a/src/diagram/space.ts +++ b/src/diagram/space.ts @@ -29,7 +29,7 @@ * crossed container: the line rule; untouched shape: kept); interior * waypoints beyond the line are shifted. Orthogonal edges stay * orthogonal unless an end docks on an untouched shape across the line - * (callers repair those, see incremental.ts) + * (callers repair those, see layout/incremental.ts) * - an edge label follows the segment it belongs to (the one nearest to * it): shifted when both ends of that segment were shifted, kept when * neither was, and for a segment stretched by the line shifted when it @@ -87,7 +87,7 @@ * frame mode, anchored at `anchor`). Returns the pixels and what moved; * undefined when the label fits. */ -import { layoutDebug, layoutDebugOn } from '../debug.js'; +import { layoutDebug, layoutDebugOn } from '../shared/debug.js'; import { bottom, containsPoint, cx, cy, overlaps, right, type Box } from './geom.js'; import { defaultLabelSide, hasExternalLabel, labelArea, labelAt, labelSizeOf } from './labels.js'; import { boundariesOf, contentOf, frameOf, inFrame, isLeaf, raw, type DShape, type Plane } from './plane.js'; diff --git a/src/diagram/stickies.ts b/src/diagram/stickies.ts index 90f6a647..43d28a3b 100644 --- a/src/diagram/stickies.ts +++ b/src/diagram/stickies.ts @@ -24,7 +24,7 @@ * Anchors name processes and nodes by element (resolveAnchors maps them to * their ids after the ops, so a renamed node is still followed). */ -import { is, type El } from '../model.js'; +import { is, type El } from '../model/moddle.js'; import { idOf, raw, rawList } from './plane.js'; export const BPMIQ_URI = 'https://bpmiq.io/schema/1.0/bpmiq'; diff --git a/src/diagram/text.ts b/src/diagram/text.ts index 43ddac51..009b7506 100644 --- a/src/diagram/text.ts +++ b/src/diagram/text.ts @@ -35,7 +35,7 @@ * renderer, both layout engines and the metrics use them, so they agree * on where a title is. */ -import type { Box } from '../layout/types.js'; +import type { Box } from './types.js'; /** advance widths of Arial in 1/1000 em */ const ARIAL: Record = { diff --git a/src/layout/types.ts b/src/diagram/types.ts similarity index 90% rename from src/layout/types.ts rename to src/diagram/types.ts index ea312556..4d00ecea 100644 --- a/src/layout/types.ts +++ b/src/diagram/types.ts @@ -1,7 +1,7 @@ /** * Shared types of the "clean" layout engine. */ -import type { El } from '../model.js'; +import type { El } from '../model/moddle.js'; export interface Box { x: number; @@ -27,16 +27,16 @@ export interface GNode { /** host for boundary events */ host?: GNode; /** - * a boundary event on its host's top border instead of the bottom one (place.ts boundariesOnTop): its flows leave - * it upwards over the top (route.ts), its label sits above the host (route.ts elementLabel) + * a boundary event on its host's top border instead of the bottom one (layout/clean/place.ts boundariesOnTop): its flows leave + * it upwards over the top (layout/clean/route.ts), its label sits above the host (layout/clean/route.ts elementLabel) */ onTop?: boolean; - /** such an event's label goes to the upper left of it (place.ts boundariesOnTop: where the upper right is taken) */ + /** such an event's label goes to the upper left of it (layout/clean/place.ts boundariesOnTop: where the upper right is taken) */ labelLeft?: boolean; /** expanded sub-process: its laid-out child scope */ child?: ScopeLayout; /** - * expanded sub-process: where its content sits (place.ts frameSubProcess): `left` and `top` from the + * expanded sub-process: where its content sits (layout/clean/place.ts frameSubProcess): `left` and `top` from the * padding's left edge and the frame's top, `inner` the width of the content with its labels */ childPad?: { left: number; top: number; inner: number }; @@ -67,7 +67,7 @@ export interface GEdge { back: boolean; /** * empty band (gateway -> join without nodes): the reserved row and its y, set by the placer; the router - * draws the flow straight instead when the row between the two is free (route.ts) + * draws the flow straight instead when the row between the two is free (layout/clean/route.ts) */ bandRow?: number; bandY?: number; @@ -76,13 +76,13 @@ export interface GEdge { label?: Box; /** * set by the router on a boundary event's flow that leaves the event downwards to a run below its host's row (at - * its second waypoint's y; the host's lane holds it, engine.ts fitLaneLoops) + * its second waypoint's y; the host's lane holds it, layout/clean/engine.ts fitLaneLoops) */ runsBelow?: boolean; /** * set by the router on such a flow that then goes over the top to its target, and on the flow of a boundary event * on its host's top border (GNode.onTop), which goes straight up over the top (its highest waypoints, its label - * above them; the lane of both ends holds them, engine.ts fitLaneLoops) + * above them; the lane of both ends holds them, layout/clean/engine.ts fitLaneLoops) */ runsAbove?: boolean; } diff --git a/src/diagram/write.ts b/src/diagram/write.ts index acf23b43..87f4d7b3 100644 --- a/src/diagram/write.ts +++ b/src/diagram/write.ts @@ -41,7 +41,7 @@ * `stale(edge, plane, further)` is true (`further`: its diagram shows a * root an earlier diagram already shows, a second view); returns the ids * of their elements in document order. Used for the edges of flows whose - * ends changed (incremental.ts pruneReEnded). + * ends changed (layout/incremental.ts pruneReEnded). * - colorsOf(defs) / applyColors(defs, colors): the bpmn-js colour * attributes by element id, used to carry colours over a full redraw. * - setSwatch(di, swatch) writes one colour of the bpmn-js colour @@ -53,8 +53,8 @@ * back (the swatch name, or 'custom'). */ import type { BpmnModdle } from 'bpmn-moddle'; -import { cutAt, MAX_ID } from '../ids.js'; -import { addTo, is, removeFrom, type El } from '../model.js'; +import { cutAt, MAX_ID } from '../ids/slugs.js'; +import { addTo, is, removeFrom, type El } from '../model/moddle.js'; import { roundPoints, sameBox, samePoints, type Box, type Point } from './geom.js'; import { displayRoot, idOf, raw, rawList, type DEdge, type DShape, type Plane, type Semantics } from './plane.js'; @@ -136,7 +136,7 @@ const MAX_DI = MAX_ID - 3; /** * The DI id of an element in a style (`_di`, `BPMNShape_`, * `Edge_`), at most MAX_ID characters less room for a collision suffix: - * a long element id is cut at a word boundary (src/ids.ts cutAt), like the + * a long element id is cut at a word boundary (src/ids/slugs.ts cutAt), like the * element ids themselves. `legacy`: cut as 0.6 cut (recognising the DI ids * it wrote). */ @@ -173,7 +173,7 @@ export function diIdsFit(defs: El): boolean { return true; } -/** What followDiIds asks and changes: the document's id registry (src/ids.ts IdRegistry). */ +/** What followDiIds asks and changes: the document's id registry (src/ids/slugs.ts IdRegistry). */ export interface IdClaims { has(id: string): boolean; claim(id: string): void; diff --git a/src/diagram/compact.ts b/src/format/compact.ts similarity index 96% rename from src/diagram/compact.ts rename to src/format/compact.ts index b9c0eaf6..b5ca2357 100644 --- a/src/diagram/compact.ts +++ b/src/format/compact.ts @@ -2,7 +2,7 @@ * Compaction of a kept drawing: empty rows and columns are closed and the * frames (expanded sub-processes, lanes, pools) shrink to their content, * keeping the order and the relative positions of everything (the `compact` - * format op and the negative `space` amounts, src/diagram/ops.ts). + * format op and the negative `space` amounts, src/format/index.ts). * * CONTRACT * emptyStrips(plane, axis, region, opts) finds the empty strips of a region @@ -16,7 +16,7 @@ * keep the drawing's gap. A region without content is one strip. * * compactPlane(plane, opts) closes the empty strips of every frame of the - * plane, inside out, each strip with space.ts closeStrip (which checks again + * plane, inside out, each strip with diagram/space.ts closeStrip (which checks again * that nothing is in the way), far strips first: * 1. expanded sub-processes, deepest first: columns, then rows, with * everything outside the sub-process kept where it is (the sub-process @@ -36,20 +36,20 @@ * pool: its columns, its lanes' rows and its sub-processes; a lane: its * leaf lanes' rows and its sub-processes; a sub-process: itself and the * sub-processes inside). Every strip goes through `attempt`, which keeps a - * change only when it adds no hard layout defect (see ops.ts); the + * change only when it adds no hard layout defect (see format/index.ts); the * result counts the strips closed and the pixels removed per axis. * Paddings: lanes and pools 30 px (left of the content: after the 30 px * headers), sub-processes 30 px (45 px at the top, room for the name; a - * name of three lines and more keeps its lines and 4 px, text.ts + * name of three lines and more keeps its lines and 4 px, diagram/text.ts * titleDepth). * Interior gaps: the drawing's gap (spacingOf) on x, clamp(row - 80, 30, * 60) on y. Strips with less than 10 px to gain are left alone. */ -import { bottom, right, type Box } from './geom.js'; -import { spacingOf } from './place.js'; -import { inFrame, isLeaf, raw, type DEdge, type DShape, type Plane } from './plane.js'; -import { closeStrip, type Axis, type SpaceResult } from './space.js'; -import { titleDepth } from './text.js'; +import { bottom, right, type Box } from '../diagram/geom.js'; +import { spacingOf } from '../diagram/place.js'; +import { inFrame, isLeaf, raw, type DEdge, type DShape, type Plane } from '../diagram/plane.js'; +import { closeStrip, type Axis, type SpaceResult } from '../diagram/space.js'; +import { titleDepth } from '../diagram/text.js'; /** padding kept between a frame's border and its content */ export const PAD = 30; @@ -71,7 +71,7 @@ export interface Strip { keep: number; } -/** Runs a change of the drawing; keeps it when it made nothing worse, else undoes it (ops.ts). */ +/** Runs a change of the drawing; keeps it when it made nothing worse, else undoes it (format/index.ts). */ export type Attempt = (change: () => SpaceResult | undefined, reroute?: readonly string[]) => boolean; export interface CompactStats { @@ -210,7 +210,7 @@ export function looseEdges(plane: Plane): Set { } /** - * Closes one empty strip with space.ts closeStrip (which checks that nothing + * Closes one empty strip with diagram/space.ts closeStrip (which checks that nothing * is in the way); message flows do not count, their bends and labels inside * the strip are squeezed into the room it keeps. */ diff --git a/src/diagram/ops.ts b/src/format/index.ts similarity index 98% rename from src/diagram/ops.ts rename to src/format/index.ts index 06d83235..eb9c6c6a 100644 --- a/src/diagram/ops.ts +++ b/src/format/index.ts @@ -28,10 +28,10 @@ * (makeRoom); its outgoing flows are routed again. * - align: every id moves on its own onto the centre line (row) or centre * column of `to` (default: the first id, which then stays). - * - color: a SWATCHES colour (write.ts setSwatch) on shapes and edges; + * - color: a SWATCHES colour (diagram/write.ts setSwatch) on shapes and edges; * 'default' removes every colour. The bioc / color namespaces are * declared on the definitions when missing. - * - label: the external label box on one side of its element (labels.ts + * - label: the external label box on one side of its element (diagram/labels.ts * labelOnSide: off lines, other labels and the titles of expanded * sub-processes where possible, inside its frame below the title first; * flows: edgeLabelAt), keeping the label's size. A label put above a @@ -39,11 +39,11 @@ * title gets room at the top of the sub-process first (space tool in * frame mode: the content moves down, the sub-process grows; a note * says so). - * - route: one flow routed again (reroute.ts routeEdge), `exit` / `entry` + * - route: one flow routed again (diagram/reroute.ts routeEdge), `exit` / `entry` * forcing the side it leaves / enters by. A sequence or message flow * without a connection whose two ends are drawn on one plane (added, or * its ends changed, with --no-layout) gets one there. - * - space: the space tool (space.ts makeSpace) at the far edge of an + * - space: the space tool (diagram/space.ts makeSpace) at the far edge of an * element: `after` moves everything starting right of it (within its * pool), `below` everything starting below it; pools, lanes and the * sub-processes holding the element grow where the line crosses them, @@ -51,7 +51,7 @@ * (anchored at the element). On a pool or lane the line is just inside * its far edge, so the frame itself grows. `by`: 'column' (median task width + gap, default * for after), 'row' (row spacing, default for below) or pixels. - * - tidy: separate.ts tidy on the given shapes (default: every leaf shape + * - tidy: diagram/separate.ts tidy on the given shapes (default: every leaf shape * of every diagram). * - order (lanes): the lane bands of the owner follow the semantic lane * order (ops/order.ts already reordered `laneSet.lanes`), stacked from @@ -62,7 +62,7 @@ * frame's start (more than 10 px into a header), its centre in another lane or pool, or below a lane with a * sibling lane underneath; past the right / bottom edge the frame grows * (also for the shape's label). Then the moved shapes stay and the others - * give way (separate.ts), first with the references fixed, else with them + * give way (diagram/separate.ts), first with the references fixed, else with them * movable too; moved shapes still in conflict give way along the axis the * request leaves free. The request must hold afterwards (row / column / * side of the reference), no sub-process may have grown over a reference, @@ -73,12 +73,12 @@ * in has moved (a pool growing towards a reference in another pool would * push that pool away), else E_NO_ROOM and nothing is written. * After every geometric op: connections whose ends moved by the same - * offset are translated, connections now broken (reroute.ts brokenEdge) + * offset are translated, connections now broken (diagram/reroute.ts brokenEdge) * are routed again, named rerouted flows get their label placed again, a * shape label a rerouted line runs over steps aside (keeping its side), * and so does a label the op brought onto the title of an expanded * sub-process that it was clear of before, to a spot off every title - * inside its sub-process or pool, else it stays (labels.ts clearTitles; + * inside its sub-process or pool, else it stays (diagram/labels.ts clearTitles; * `space` widening a sub-process moves its centred title by half the * added width). * Result per op: {op, index, moved (shapes whose bounds changed), rerouted @@ -98,24 +98,24 @@ * format ops only), details.command (`bpmn space ...`); without * one the hint names the shapes to move first. */ -import type { Doc } from '../document.js'; -import { CliError, modelError, usageError, type ErrorDetails } from '../errors.js'; -import { is, type El } from '../model.js'; +import type { Doc } from '../model/document.js'; +import { CliError, modelError, usageError, type ErrorDetails } from '../shared/errors.js'; +import { is, type El } from '../model/moddle.js'; import { laneSetOf, ordersLanes, ordersPools } from '../ops/order.js'; import { parseSpaceAmount, type AlignOp, type ColorOp, type CompactOp, type FormatOp, type LabelOp, type OrderOp, type PlaceOp, type RouteOp, type SpaceOp, type TidyOp } from '../ops/types.js'; import { closeEmpty, compactPlane, drawingGaps, looseEdges, occupied, PAD as COMPACT_PAD, type Attempt } from './compact.js'; -import { bottom, containsPoint, copyBox, copyPoints, cx, cy, inside, median, overlaps, right, sameBox, samePoints, segmentHits, type Box, type Point } from './geom.js'; -import { clearTitles, edgeLabelAt, hasExternalLabel, labelArea, labelAt, labelOnSide, labelSideOf, labelSizeOf, placeEdgeLabel, placeShapeLabel } from './labels.js'; -import { diffProblems, layoutProblems, problemKey, WEIGHTS, type LayoutMetrics, type LayoutProblem } from './metrics.js'; -import { spacingOf } from './place.js'; -import { edgeEnds, edgeKind, frameInterior, frameOf, homePlane, idOf, isLeaf, raw, rawList, readPlanes, semantics, type DEdge, type DShape, type Plane, type Semantics } from './plane.js'; -import { brokenEdge, edgeBefore, routeEdge, routeRank, routingLines, type EdgeBefore } from './reroute.js'; -import { attachedSide, type Side } from './router.js'; -import { separate, tidy } from './separate.js'; -import { fitInFrame, makeSpace, roomBelowTitle, shiftShape, unitBox } from './space.js'; -import { selection } from './select.js'; -import { titleBox } from './text.js'; -import { setSwatch, writePlanes } from './write.js'; +import { bottom, containsPoint, copyBox, copyPoints, cx, cy, inside, median, overlaps, right, sameBox, samePoints, segmentHits, type Box, type Point } from '../diagram/geom.js'; +import { clearTitles, edgeLabelAt, hasExternalLabel, labelArea, labelAt, labelOnSide, labelSideOf, labelSizeOf, placeEdgeLabel, placeShapeLabel } from '../diagram/labels.js'; +import { diffProblems, layoutProblems, problemKey, WEIGHTS, type LayoutMetrics, type LayoutProblem } from '../diagram/metrics.js'; +import { spacingOf } from '../diagram/place.js'; +import { edgeEnds, edgeKind, frameInterior, frameOf, homePlane, idOf, isLeaf, raw, rawList, readPlanes, semantics, type DEdge, type DShape, type Plane, type Semantics } from '../diagram/plane.js'; +import { brokenEdge, edgeBefore, routeEdge, routeRank, routingLines, type EdgeBefore } from '../diagram/reroute.js'; +import { attachedSide, type Side } from '../diagram/router.js'; +import { separate, tidy } from '../diagram/separate.js'; +import { fitInFrame, makeSpace, roomBelowTitle, shiftShape, unitBox } from '../diagram/space.js'; +import { selection } from '../query/select.js'; +import { titleBox } from '../diagram/text.js'; +import { setSwatch, writePlanes } from '../diagram/write.js'; export interface FormatResult { op: FormatOp['op'] | 'order'; @@ -549,7 +549,7 @@ function restoreState(st: PlaneState): void { } /** - * Shapes moved on request stay; the others give way (separate.ts). First the + * Shapes moved on request stay; the others give way (diagram/separate.ts). First the * references stay too; when the request then does not hold (`holds`, e.g. * "same row as R"), or two shapes ended up on each other, the references may * give way as well (a row reference sliding right keeps its row). When a @@ -1362,7 +1362,7 @@ function orderPoolBands(ctx: Ctx, op: OrderOp, snap: Snap, notes: string[]): str /* ------------------------------------------------------------------ */ /** - * The ids of a format op with selectors (select.ts): explicit ids first, then + * The ids of a format op with selectors (query/select.ts): explicit ids first, then * what --branch, --path and --kind name (connections for color only). An * align without explicit ids or `to` aligns on the first selected element, * with only --kind and --axis column on the rightmost one (nothing moves left). diff --git a/src/conventions.ts b/src/ids/conventions.ts similarity index 98% rename from src/conventions.ts rename to src/ids/conventions.ts index 493e947a..2ce5eb18 100644 --- a/src/conventions.ts +++ b/src/ids/conventions.ts @@ -2,7 +2,7 @@ * Declared id conventions (browser-safe): what a project's .bpmnlintrc says * about ids through @miragon/rules/element-id-naming, as plain data the core * takes (MutationOptions / EditOptions / NewDocOptions `conventions`; - * src/idstyle.ts fills the gaps the file leaves with them), and the view of + * src/ids/style.ts fills the gaps the file leaves with them), and the view of * the conventions new ids follow in a file (`bpmn show --conventions`). * * idConventionsFromLint(setting, naming, { source }) -> { conventions, notes } @@ -34,13 +34,13 @@ * .bpmnlintrc, one that could not be loaded, the rule off, no usable * prefix). */ -import type { BpmnlintRuleSetting, BpmnlintSeverity } from './bpmnlint.js'; -import { closestKey } from './batch.js'; -import type { Doc } from './document.js'; -import { IdStyle, isUsablePrefix, kindRequest, typeRequest, type Body, type FlowForm, type IdRequest, type PrefixSource } from './idstyle.js'; -import { KINDS, TRIGGER_TYPES } from './kinds.js'; -import { createModdle } from './model.js'; -import type { ValidatorFinding } from './validators.js'; +import type { BpmnlintRuleSetting, BpmnlintSeverity } from '../validate/bpmnlint-validator.js'; +import { closestKey } from '../ops/batch.js'; +import type { Doc } from '../model/document.js'; +import { IdStyle, isUsablePrefix, kindRequest, typeRequest, type Body, type FlowForm, type IdRequest, type PrefixSource } from './style.js'; +import { KINDS, TRIGGER_TYPES } from '../model/kinds.js'; +import { createModdle } from '../model/moddle.js'; +import type { ValidatorFinding } from '../validate/validators.js'; /** The rule's name as a resolved .bpmnlintrc keys it (resolveBpmnlintConfig `rules`). */ export const ID_NAMING_RULE = '@miragon/rules/element-id-naming'; diff --git a/src/ids.ts b/src/ids/slugs.ts similarity index 98% rename from src/ids.ts rename to src/ids/slugs.ts index 08740c34..28f4b769 100644 --- a/src/ids.ts +++ b/src/ids/slugs.ts @@ -2,7 +2,7 @@ * Id building blocks: name words, slugs, the id registry. * * Which id a new element gets is decided by the file's id style - * (src/idstyle.ts): new ids follow the conventions the file already uses, + * (src/ids/style.ts): new ids follow the conventions the file already uses, * and a file without a convention gets the bpmn-cli default * (`Activity_CheckInvoice`, `Flow_CheckInvoiceToBookInvoice`). * @@ -23,12 +23,12 @@ /** The longest slug of a name or context (an id body before the prefix). */ export const MAX_SLUG = 40; -/** The longest id the id style generates, a collision suffix included (src/idstyle.ts). */ +/** The longest id the id style generates, a collision suffix included (src/ids/style.ts). */ export const MAX_ID = 64; /** * Function words a cut never ends on (cutName, the ends of a flow: - * src/idstyle.ts fitPair), German and English: `LieferantenbestellungVersenden`, + * src/ids/style.ts fitPair), German and English: `LieferantenbestellungVersenden`, * never `...VersendenUnd`. */ const FILLERS = new Set(['und', 'oder', 'an', 'am', 'auf', 'aus', 'bei', 'mit', 'von', 'vom', 'zu', 'zum', 'zur', 'fuer', 'der', 'die', 'das', 'den', 'dem', 'des', 'ein', 'eine', 'im', 'in', 'and', 'or', 'of', 'to', 'the', 'a', 'for', 'with', 'on', 'at', 'by']); diff --git a/src/idstyle.ts b/src/ids/style.ts similarity index 99% rename from src/idstyle.ts rename to src/ids/style.ts index 055f6f9e..00a03c22 100644 --- a/src/idstyle.ts +++ b/src/ids/style.ts @@ -70,9 +70,9 @@ * names its ends (labelOf: the speaking part of an end's id, also an * unnamed end's own context, AfterCheck, and CheckJoin for the join of the * split after Check; else its name, else a word for its kind). Names and - * contexts are transliterated (ä -> ae, ø -> oe, å -> aa, src/ids.ts). A + * contexts are transliterated (ä -> ae, ø -> oe, å -> aa, src/ids/slugs.ts). A * name or context gives at most MAX_SLUG (40) characters of words (a single - * longer word is cut at 40, src/ids.ts; a cut never ends on a filler word, + * longer word is cut at 40, src/ids/slugs.ts; a cut never ends on a filler word, * cutName: und, an, the). A generated id has at most MAX_ID * (64) characters, a collision suffix included; an id within that is not * cut again. A longer one loses whole words: a long body its last words, a @@ -123,7 +123,7 @@ * style.joinId(gatewayId) the id of a split's join gateway. * * DECLARED CONVENTIONS - * IdStyle.infer(defs, conventions) with IdConventions (src/conventions.ts: + * IdStyle.infer(defs, conventions) with IdConventions (src/ids/conventions.ts: * the prefixes, case and qualifier @miragon/rules/element-id-naming * declares in the project's .bpmnlintrc, or a host's table) fills the gaps * the file leaves: a request whose BPMN type has a declared prefix (the @@ -184,10 +184,10 @@ * (ops/set.ts recordIdState). Without declared conventions nothing of * this runs. */ -import { camelSlug, cutAt, cutName, hasIdWords, idWords, isFiller, isSuffix, isValidId, keptTail, MAX_ID, MAX_SLUG, nameWords, pascalSnakeSlug, readsApart, slugify, snakeSlug, SUFFIX_WORD, withLetter, withSuffix, type IdRegistry } from './ids.js'; +import { camelSlug, cutAt, cutName, hasIdWords, idWords, isFiller, isSuffix, isValidId, keptTail, MAX_ID, MAX_SLUG, nameWords, pascalSnakeSlug, readsApart, slugify, snakeSlug, SUFFIX_WORD, withLetter, withSuffix, type IdRegistry } from './slugs.js'; import type { IdConventions } from './conventions.js'; -import { kindByName, kindOf, KINDS, triggerOf, type KindDef } from './kinds.js'; -import { is, isBpmnElement, walk, type El } from './model.js'; +import { kindByName, kindOf, KINDS, triggerOf, type KindDef } from '../model/kinds.js'; +import { is, isBpmnElement, walk, type El } from '../model/moddle.js'; /** The case of the bodies of new ids. */ export type Body = 'pascal' | 'camel' | 'snake' | 'pascalSnake'; diff --git a/src/index.ts b/src/index.ts index 3acdbf6e..1a595b5c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,17 +11,17 @@ */ /* the in-memory API: strings in, strings / data out (docs/library.md) */ export { applyToXml, newXml, layoutXml, validateXml, viewXml, showXml, conventionsXml, metricsXml, findXml, extensionsXml, viewDoc, renderShown, type EditOptions, type EditResult, type EditReport, type LayoutXmlOptions, type ShownView, type ValidateXmlOptions, type ViewOptions } from './api.js'; -export { mutationReport, mutationWarnings, opWarnings, renderMutation, mutationSummary, renderSummary, advisoryValidators, warningLines, conventionsLines, validationReport, renderValidation, type MutationReport, type MutationReportLike, type MutationSummary, type ValidationReport, type WarningReport } from './report.js'; -export { renderView, renderDetail, renderAround, renderContext, renderLayoutView, renderFind, renderMetrics, renderExtensionList, renderProblems } from './format.js'; -export { setLayoutDebug, type DebugSink } from './debug.js'; -export { guideText, guideShort, guideTopic, GUIDE_TOPICS, kindsJson, kindsText, kindsSections, kindsSectionJson, kindsSectionText, ERROR_CATALOGUE } from './guide.js'; +export { mutationReport, mutationWarnings, opWarnings, renderMutation, mutationSummary, renderSummary, advisoryValidators, warningLines, conventionsLines, validationReport, renderValidation, type MutationReport, type MutationReportLike, type MutationSummary, type ValidationReport, type WarningReport } from './report/command-report.js'; +export { renderView, renderDetail, renderAround, renderContext, renderLayoutView, renderFind, renderMetrics, renderExtensionList, renderProblems } from './report/view-text.js'; +export { setLayoutDebug, type DebugSink } from './shared/debug.js'; +export { guideText, guideShort, guideTopic, GUIDE_TOPICS, kindsJson, kindsText, kindsSections, kindsSectionJson, kindsSectionText, ERROR_CATALOGUE } from './report/guide.js'; /* the reading views of large models: the neighbourhood of an element (show --around) and an element in its context (show --context) */ -export { aroundView, elementContext, implementationOf, AROUND_DEFAULT_DEPTH, type AroundOptions, type AroundView, type AroundNode, type AroundScope, type ElementContext, type ContextRef, type ContextLink, type ContextCatch, type ContextEventSubProcess, type Implementation } from './context.js'; +export { aroundView, elementContext, implementationOf, AROUND_DEFAULT_DEPTH, type AroundOptions, type AroundView, type AroundNode, type AroundScope, type ElementContext, type ContextRef, type ContextLink, type ContextCatch, type ContextEventSubProcess, type Implementation } from './query/context.js'; /* the building blocks */ -export { Doc, TARGETS, type DocSource, type NewDocOptions } from './document.js'; -export { CliError, EXIT_CODES, type ErrorCategory, type Warning } from './errors.js'; -export { KINDS, parseKind, kindOf, kindLabel } from './kinds.js'; -export { layoutModel } from './layout.js'; +export { Doc, TARGETS, type DocSource, type NewDocOptions } from './model/document.js'; +export { CliError, EXIT_CODES, type ErrorCategory, type Warning } from './shared/errors.js'; +export { KINDS, parseKind, kindOf, kindLabel } from './model/kinds.js'; +export { layoutModel } from './layout/index.js'; export { runOp, runOps } from './ops/index.js'; export { FORMAT_OP_NAMES, isFormatOp } from './ops/types.js'; export type { @@ -44,28 +44,28 @@ export type { SpaceOp, TidyOp, } from './ops/types.js'; -export { mutateDoc, layoutDoc, checkDoc, assertLossless, LAYOUT_MODES, type CheckOptions, type CheckResult, type ConventionsReport, type LayoutDocOptions, type LayoutMode, type LayoutStatus, type MutationOptions, type MutationResult, type ValidationDelta } from './pipeline.js'; +export { mutateDoc, layoutDoc, checkDoc, assertLossless, LAYOUT_MODES, type CheckOptions, type CheckResult, type ConventionsReport, type LayoutDocOptions, type LayoutMode, type LayoutStatus, type MutationOptions, type MutationResult, type ValidationDelta } from './pipeline/index.js'; /* text-preserving output: what mutateDoc uses to keep a file's formatting (for hosts that serialise models themselves) */ -export { preserveText, type PreservedText } from './preserve.js'; +export { preserveText, type PreservedText } from './xml/preserve.js'; /* a host's validators, run inside the write transaction (MutationOptions.validators) and by validate (CheckOptions.validators) */ -export type { NamedValidator, Validator, ValidatorContext, ValidatorFinding, ValidatorFn, ValidatorIssue, ValidatorReport, ValidatorSeverity } from './validators.js'; +export type { NamedValidator, Validator, ValidatorContext, ValidatorFinding, ValidatorFn, ValidatorIssue, ValidatorReport, ValidatorSeverity } from './validate/validators.js'; /* the project's bpmnlint configuration as an advisory validator; bpmnlint itself is injected (@miragon/bpmn-cli/node loads it) */ -export { bpmnlintValidator, resolveBpmnlintConfig, BPMNLINT_COVERS, BPMNLINT_VALIDATOR, type BpmnlintConfig, type BpmnlintEngine, type BpmnlintLinter, type BpmnlintLinterClass, type BpmnlintReport, type BpmnlintResolver, type BpmnlintRule, type BpmnlintRuleSetting, type BpmnlintSeverity, type BpmnlintUnavailable, type BpmnlintValidatorOptions, type ResolvedBpmnlintConfig } from './bpmnlint.js'; +export { bpmnlintValidator, resolveBpmnlintConfig, BPMNLINT_COVERS, BPMNLINT_VALIDATOR, type BpmnlintConfig, type BpmnlintEngine, type BpmnlintLinter, type BpmnlintLinterClass, type BpmnlintReport, type BpmnlintResolver, type BpmnlintRule, type BpmnlintRuleSetting, type BpmnlintSeverity, type BpmnlintUnavailable, type BpmnlintValidatorOptions, type ResolvedBpmnlintConfig } from './validate/bpmnlint-validator.js'; /* declared id conventions: what element-id-naming of the project's .bpmnlintrc says about new ids (its naming helpers injected; @miragon/bpmn-cli/node reads the .bpmnlintrc) */ -export { idConventionsFromLint, conventionsView, renderConventions, ID_NAMING_RULE, type IdConventions, type IdNamingHelpers, type QualifierMode, type ConventionsView, type ConventionsRow, type Undeclared } from './conventions.js'; +export { idConventionsFromLint, conventionsView, renderConventions, ID_NAMING_RULE, type IdConventions, type IdNamingHelpers, type QualifierMode, type ConventionsView, type ConventionsRow, type Undeclared } from './ids/conventions.js'; export { decisionLinkOf, type DecisionLink } from './ops/decision.js'; -export { ChangeSet, type Change } from './result.js'; -export { validateDoc, type ValidateOptions, type ValidationResult } from './validate.js'; +export { ChangeSet, type Change } from './model/change-set.js'; +export { validateDoc, type ValidateOptions, type ValidationResult } from './validate/structural.js'; /* the platform profile (Camunda 7 / 8 rules, loaded on demand; validate --platform) */ -export { runProfile, loadProfile, loadProfiles, PLATFORM_CHOICES, type Platform, type PlatformChoice, type PlatformInfo, type PlatformSummary, type ProfileFinding, type ProfileReport, type Severity } from './platform/profile.js'; +export { runProfile, loadProfile, loadProfiles, PLATFORM_CHOICES, type Platform, type PlatformChoice, type PlatformInfo, type PlatformSummary, type ProfileFinding, type ProfileReport, type Severity } from './platform/profiles/profile.js'; export { detectPlatform } from './platform/detect.js'; export { listExtensions, listAllExtensions, type ExtensionInfo } from './ops/ext.js'; -export { buildView, elementDetail, findElements, scopeView, type ModelView, type ElementDetail, type DetailMessageFlow, type DetailData, type FindHit } from './view.js'; -export { parseOps, OPS_SCHEMA } from './batch.js'; +export { buildView, elementDetail, findElements, scopeView, type ModelView, type ElementDetail, type DetailMessageFlow, type DetailData, type FindHit } from './query/model-view.js'; +export { parseOps, OPS_SCHEMA } from './ops/batch.js'; /* the diagram API: read-only views of a drawing and the format operations */ export { layoutProblems, layoutProblemsOfXml, locateProblems, diffProblems, metricsDelta, KEYS as METRIC_KEYS, WEIGHTS as METRIC_WEIGHTS, type LayoutMetrics, type LayoutProblem, type ProblemLocation, type MetricKey, type MetricsDelta, type MetricsSummary } from './diagram/metrics.js'; -export { layoutView, type LayoutView, type LayoutDiagram, type LayoutGroup, type LayoutColor, type LayoutLabel } from './diagram/view.js'; -export { runFormatOps, type FormatResult, type FormatEntry } from './diagram/ops.js'; +export { layoutView, type LayoutView, type LayoutDiagram, type LayoutGroup, type LayoutColor, type LayoutLabel } from './query/layout-view.js'; +export { runFormatOps, type FormatResult, type FormatEntry } from './format/index.js'; export { SWATCHES, type SwatchName } from './diagram/write.js'; /* the drawing as an image: one diagram plane as SVG (`bpmn render --format svg`; PNG: renderPng in @miragon/bpmn-cli/node) */ -export { renderSvg, renderDocSvg, changeHighlight, RENDER_MAX_SIZE, MIN_LABEL_SCALE, HALO_COLORS, type RenderOptions, type RenderResult, type RenderHighlight, type RenderProblem, type RenderTile } from './diagram/render.js'; +export { renderSvg, renderDocSvg, changeHighlight, RENDER_MAX_SIZE, MIN_LABEL_SCALE, HALO_COLORS, type RenderOptions, type RenderResult, type RenderHighlight, type RenderProblem, type RenderTile } from './render/index.js'; diff --git a/src/layout/engine.ts b/src/layout/clean/engine.ts similarity index 99% rename from src/layout/engine.ts rename to src/layout/clean/engine.ts index fb07aaa4..62987111 100644 --- a/src/layout/engine.ts +++ b/src/layout/clean/engine.ts @@ -33,14 +33,14 @@ * title; a spot next to the element before one stepped further out * (declutterLabels) */ -import { titleBox } from '../diagram/text.js'; -import { addTo, is, many, type El, type Model } from '../model.js'; -import { layoutRoot } from '../model.js'; +import { titleBox } from '../../diagram/text.js'; +import { addTo, is, many, type El, type Model } from '../../model/moddle.js'; +import { layoutRoot } from '../../model/moddle.js'; import { DATA_ROW_EXTRA, annotationSize, boundariesOnTop, boundaryExtra, framedSize, freeJoinColumns, gridScope, growToFit, layoutScope, liftChains, nodeLabels, placeAnnotations, placeAttachedArtifacts, shiftNode, type PlaceOptions } from './place.js'; import { messageLabel, poolOrder, routeMessageFlows, type MessageFlowJob, type MessagePool, type Seg } from './messages.js'; import { placeCollaborationNotes, type NoteJob } from './notes.js'; import { borderPoint, elementLabel, routeEdges, routeLinks } from './route.js'; -import { METRICS, SIZES, boxesOverlap, center, type Box, type GEdge, type GNode, type LaneBox, type Point, type ScopeLayout } from './types.js'; +import { METRICS, SIZES, boxesOverlap, center, type Box, type GEdge, type GNode, type LaneBox, type Point, type ScopeLayout } from '../../diagram/types.js'; export interface EngineWarning { code: string; diff --git a/src/layout/messages.ts b/src/layout/clean/messages.ts similarity index 99% rename from src/layout/messages.ts rename to src/layout/clean/messages.ts index 666be06f..a6218654 100644 --- a/src/layout/messages.ts +++ b/src/layout/clean/messages.ts @@ -27,8 +27,8 @@ * - deterministic; obstacles are leaf shapes (no pools, lanes or expanded * sub-process frames), `lines` the edges already drawn inside a pool. */ -import { is, type El } from '../model.js'; -import { SIZES, center, type Box, type Point } from './types.js'; +import { is, type El } from '../../model/moddle.js'; +import { SIZES, center, type Box, type Point } from '../../diagram/types.js'; export type Seg = [Point, Point]; diff --git a/src/layout/notes.ts b/src/layout/clean/notes.ts similarity index 98% rename from src/layout/notes.ts rename to src/layout/clean/notes.ts index 9b710bf0..9a3df31a 100644 --- a/src/layout/notes.ts +++ b/src/layout/clean/notes.ts @@ -17,7 +17,7 @@ * height, below the notes already there (nothing is ever dropped) */ import type { Seg } from './messages.js'; -import type { Box } from './types.js'; +import type { Box } from '../../diagram/types.js'; export interface NoteJob { width: number; diff --git a/src/layout/place.ts b/src/layout/clean/place.ts similarity index 99% rename from src/layout/place.ts rename to src/layout/clean/place.ts index 94895d4a..d0c6f013 100644 --- a/src/layout/place.ts +++ b/src/layout/clean/place.ts @@ -62,11 +62,11 @@ * group): a group is drawn around its members again, so they stay * together */ -import { layoutDebug, layoutDebugOn } from '../debug.js'; -import { titleBox, titleDepth } from '../diagram/text.js'; -import { is, many, type El } from '../model.js'; +import { layoutDebug, layoutDebugOn } from '../../shared/debug.js'; +import { titleBox, titleDepth } from '../../diagram/text.js'; +import { is, many, type El } from '../../model/moddle.js'; import { RISE_KEEP, XIndex, crossingPairs, elementLabel, entriesFromBelow, faultyFlows, nameOf, riseFrom, riseSlots, riseX, risesInto, routeEdges, routeLinks, routedArtifacts, routedSegments, segmentHitsBox } from './route.js'; -import { METRICS, SIZES, boxesOverlap, center, labelSize, type Box, type GArtifact, type GEdge, type GNode, type LaneBandInfo, type LinkEnd, type Point, type ScopeLayout } from './types.js'; +import { METRICS, SIZES, boxesOverlap, center, labelSize, type Box, type GArtifact, type GEdge, type GNode, type LaneBandInfo, type LinkEnd, type Point, type ScopeLayout } from '../../diagram/types.js'; const idOf = (el: El): string => el.get('id'); diff --git a/src/layout/route.ts b/src/layout/clean/route.ts similarity index 99% rename from src/layout/route.ts rename to src/layout/clean/route.ts index cf0d11e7..26031bb7 100644 --- a/src/layout/route.ts +++ b/src/layout/clean/route.ts @@ -75,7 +75,7 @@ * the label box (it wraps at 90 px) * - data associations are orthogonal stubs (vertical / horizontal / Z) */ -import { LABEL_LINE, METRICS, SIZES, boxesOverlap, center, labelSize, type Box, type GArtifact, type GEdge, type GNode, type LaneBandInfo, type Point, type ScopeLayout } from './types.js'; +import { LABEL_LINE, METRICS, SIZES, boxesOverlap, center, labelSize, type Box, type GArtifact, type GEdge, type GNode, type LaneBandInfo, type Point, type ScopeLayout } from '../../diagram/types.js'; interface Channel { y: number; diff --git a/src/diagram/incremental.ts b/src/layout/incremental.ts similarity index 97% rename from src/diagram/incremental.ts rename to src/layout/incremental.ts index ac2aad65..33769a43 100644 --- a/src/diagram/incremental.ts +++ b/src/layout/incremental.ts @@ -36,7 +36,7 @@ * centre left of the flow's source, which it does not lead back to) * is placed again right of its rightmost source, before its one * successor (pullJoins; its DI is reused, it is reported as moved) - * 6. new flow nodes and artifacts are placed (place.ts) in op order + * 6. new flow nodes and artifacts are placed (diagram/place.ts) in op order * (opts.created) where their neighbours allow; while more follow, the * sequence flows of each placed node are routed right away, and so are * the connections the placement broke (sequence flows, associations and @@ -46,7 +46,7 @@ * sub-process with content and a new pool with content are laid out by * the clean engine as one block and placed like a node of that size; * an activity (task, call activity, collapsed sub-process) whose new or - * changed name does not fit its box (text.ts activitySize: bpmn-js line + * changed name does not fit its box (diagram/text.ts activitySize: bpmn-js line * breaking, room kept for a marker or boundary events on the bottom * border) grows: wider in steps of 20 up to 200 px, then higher around * its centre row, never smaller. Its left border stays, its boundary @@ -54,17 +54,17 @@ * drawing's gap (at most 40 px) to what follows on its row (shapes and * their labels), the space tool makes room by the added width (anchored * at the activity); an external label the grown box covers is placed - * again (step 9); a renamed expanded sub-process whose title (text.ts + * again (step 9); a renamed expanded sub-process whose title (diagram/text.ts * titleBox) now takes more lines than the old one did and comes closer * than 4 px to the shapes and labels drawn in it under the title * (inside the frame, below its top border: not a message flow's label * between the pools) makes room: its content moves down by the * difference, at most by the depth the title gained, and it grows * (space tool at its top in frame mode, a note says so) - * 7. local overlap removal around everything placed or moved (separate.ts) + * 7. local overlap removal around everything placed or moved (diagram/separate.ts) * 8. connections: new ones are routed, kept ones are rerouted only when an * end changed, was placed or moved away from it, or when they now cut a - * shape (reroute.ts); connections entirely inside a shifted region were + * shape (diagram/reroute.ts); connections entirely inside a shifted region were * translated by the space tool. A connection routed during step 6 is * routed again only when it broke since (like a flow an earlier single * command drew); an existing one counts as rerouted @@ -72,7 +72,7 @@ * a kept label a new line runs over or a grown activity covers steps * aside (and the label of a boundary event the placement moved to its * host's top border), and so does a label now on the title of an - * expanded sub-process that it was clear of before the ops (labels.ts + * expanded sub-process that it was clear of before the ops (diagram/labels.ts * clearTitles: room made in a sub-process moves its centred title by * half the added width, a label beyond the line by all of it; a renamed * title can be wider), unless its new spot is on a title too or outside @@ -93,7 +93,7 @@ * removed elements is pruned there too, and so is the edge of a flow whose * ends changed (pruneReEnded: it would show the old ends; a note names * them). A kept connection that does not reach an end of its own - * (reroute.ts detachedEnds: left at the end's old place by another tool or + * (diagram/reroute.ts detachedEnds: left at the end's old place by another tool or * an older --no-layout write) counts as broken in step 8 and is rerouted, * whatever it looked like before; not on a plane with vertical pools / * lanes, where nothing is routed (it stays as drawn there). @@ -111,25 +111,25 @@ * model in `laidOut`: the same shapes and connections, every bound, label * and waypoint within 2 px. */ -import { layoutDebug, layoutDebugOn } from '../debug.js'; -import type { Doc } from '../document.js'; -import { resolveExpanded } from '../layout.js'; -import { layoutClean } from '../layout/engine.js'; -import { SIZES } from '../layout/types.js'; -import { is, layoutRoot, parseXml, type El } from '../model.js'; -import { successorOf } from '../result.js'; -import { collapse, expand, placeLane, placePool, removedLane, removedPool, reseatBoundaries, wrapPool } from './containers.js'; -import { bottom, containsPoint, copyBox, copyPoints, cx, cy, inside, overlaps, right, sameBox, samePoints, segmentHits, type Box, type Point } from './geom.js'; -import { clearTitles, hasExternalLabel, placeEdgeLabel, placeShapeLabel, refitLabel } from './labels.js'; -import { layoutProblems, problemKey, WEIGHTS, type LayoutMetrics, type LayoutProblem } from './metrics.js'; -import { changeLane, placeArtifact, placeFlowNodes, predecessors, spacingOf, successors, newShape, type PlaceCtx, type Spacing } from './place.js'; -import { boundariesOf, boxOf, contentOf, edgeEnds, edgeKind, frameInterior, frameOf, homePlane, idOf, inFrame, isLeaf, isSubProcess, raw, rawList, readPlanes, semantics, titleOf, type DEdge, type DShape, type Plane, type Semantics } from './plane.js'; -import { brokenEdge, DETACHED_GAP, detachedEnds, edgeBefore, routeEdge, routeRank, routingLines, type EdgeBefore } from './reroute.js'; -import { separate } from './separate.js'; -import { attachedSide } from './router.js'; -import { closeStrip, fitInFrame, makeSpace } from './space.js'; -import { activitySize, BOTTOM_ROOM, titleBox } from './text.js'; -import { pruneDi, pruneEdges, writePlanes } from './write.js'; +import { layoutDebug, layoutDebugOn } from '../shared/debug.js'; +import type { Doc } from '../model/document.js'; +import { resolveExpanded } from './index.js'; +import { layoutClean } from './clean/engine.js'; +import { SIZES } from '../diagram/types.js'; +import { is, layoutRoot, parseXml, type El } from '../model/moddle.js'; +import { successorOf } from '../model/change-set.js'; +import { collapse, expand, placeLane, placePool, removedLane, removedPool, reseatBoundaries, wrapPool } from '../diagram/containers.js'; +import { bottom, containsPoint, copyBox, copyPoints, cx, cy, inside, overlaps, right, sameBox, samePoints, segmentHits, type Box, type Point } from '../diagram/geom.js'; +import { clearTitles, hasExternalLabel, placeEdgeLabel, placeShapeLabel, refitLabel } from '../diagram/labels.js'; +import { layoutProblems, problemKey, WEIGHTS, type LayoutMetrics, type LayoutProblem } from '../diagram/metrics.js'; +import { changeLane, placeArtifact, placeFlowNodes, predecessors, spacingOf, successors, newShape, type PlaceCtx, type Spacing } from '../diagram/place.js'; +import { boundariesOf, boxOf, contentOf, edgeEnds, edgeKind, frameInterior, frameOf, homePlane, idOf, inFrame, isLeaf, isSubProcess, raw, rawList, readPlanes, semantics, titleOf, type DEdge, type DShape, type Plane, type Semantics } from '../diagram/plane.js'; +import { brokenEdge, DETACHED_GAP, detachedEnds, edgeBefore, routeEdge, routeRank, routingLines, type EdgeBefore } from '../diagram/reroute.js'; +import { separate } from '../diagram/separate.js'; +import { attachedSide } from '../diagram/router.js'; +import { closeStrip, fitInFrame, makeSpace } from '../diagram/space.js'; +import { activitySize, BOTTOM_ROOM, titleBox } from '../diagram/text.js'; +import { pruneDi, pruneEdges, writePlanes } from '../diagram/write.js'; /* ------------------------------------------------------------------ */ /* snapshot */ @@ -271,7 +271,7 @@ export function changedEnds(snap: Snapshot, edge: El): ChangedEnd[] { return out; } -/** The id now of an end known by its id before the ops: follows `set id=` and a retype (result.ts successorOf), so a retyped and renamed end is still the same end. */ +/** The id now of an end known by its id before the ops: follows `set id=` and a retype (model/change-set.ts successorOf), so a retyped and renamed end is still the same end. */ function endNow(snap: Snapshot, oldId: string | undefined): string | undefined { const el = oldId === undefined ? undefined : snap.els.get(oldId); return (el && idOf(successorOf(el))) ?? oldId; @@ -1090,7 +1090,7 @@ function growForTitle(ctx: Ctx, plane: Plane, s: DShape): void { const title = titleOf(s); if (!title) return; const old = oldTitle(ctx, s); - // the depth the title gained (text.ts titleDepth): its new lines, all of it where none was drawn + // the depth the title gained (diagram/text.ts titleDepth): its new lines, all of it where none was drawn const gained = old ? title.height - old.height : bottom(title) - s.bounds.y; if (gained <= 0) return; const { shapes, edges } = contentOf(plane, s.id); @@ -1131,7 +1131,7 @@ function growForNames(ctx: Ctx): void { const lefts = next.flatMap((o) => [o.bounds.x, ...(o.label && onRow(o.label) && right(o.label) > right(old) ? [Math.max(right(old), o.label.x)] : [])]); const free = Math.min(Infinity, ...lefts.map((x) => x - right(old))); if (free - dw < Math.min(sp.gap, 40)) { - // inside a sub-process: frame mode, it never grows over foreign shapes (space.ts) + // inside a sub-process: frame mode, it never grows over foreign shapes (diagram/space.ts) const sub = s.parentId ? plane.shapes.get(s.parentId) : undefined; const frame = sub ?? (s.poolId ? plane.shapes.get(s.poolId) : undefined); const r = makeSpace(plane, { axis: 'x', line: right(old) + 0.5, delta: dw, keep: own, anchors: [s.id], ...(frame ? { within: copyBox(frame.bounds) } : {}), ...(sub ? { frame: sub.id } : {}) }); @@ -1344,7 +1344,7 @@ function labels(ctx: Ctx, routed: ReadonlySet): void { } } -/** The title an expanded sub-process had before the ops (text.ts titleBox of its snapshot bounds and name); undefined without one. */ +/** The title an expanded sub-process had before the ops (diagram/text.ts titleBox of its snapshot bounds and name); undefined without one. */ function oldTitle(ctx: Ctx, s: DShape): Box | undefined { const was = s.di ? ctx.snap.byDi.get(s.di) : undefined; return was?.bounds && was.kind === 'subProcess' && was.expanded === true ? titleBox(was.bounds, ctx.snap.names.get(was.id)) : undefined; diff --git a/src/layout.ts b/src/layout/index.ts similarity index 98% rename from src/layout.ts rename to src/layout/index.ts index 8b9ed512..2636739e 100644 --- a/src/layout.ts +++ b/src/layout/index.ts @@ -39,12 +39,12 @@ * convention) when that spot is free. */ import type { LayoutWarning } from 'bpmn-auto-layout'; -import { giveDrawnElementsIds, type GivenId } from './diagram/drawn-ids.js'; -import { membersOf, redrawGroups, rememberGroups, type RedrawnGroups } from './diagram/groups.js'; -import { diIdsFit, rememberDiIds, restoreDiIds } from './diagram/write.js'; -import type { IdRequest } from './idstyle.js'; -import { layoutClean } from './layout/engine.js'; -import { addTo, is, layoutRoot, many, parseXml, processes, removeFrom, serialize, walk, type El, type Model, ModelError } from './model.js'; +import { giveDrawnElementsIds, type GivenId } from '../diagram/drawn-ids.js'; +import { membersOf, redrawGroups, rememberGroups, type RedrawnGroups } from '../diagram/groups.js'; +import { diIdsFit, rememberDiIds, restoreDiIds } from '../diagram/write.js'; +import type { IdRequest } from '../ids/style.js'; +import { layoutClean } from './clean/engine.js'; +import { addTo, is, layoutRoot, many, parseXml, processes, removeFrom, serialize, walk, type El, type Model, ModelError } from '../model/moddle.js'; export interface LayoutWarningInfo { code: string; diff --git a/src/result.ts b/src/model/change-set.ts similarity index 98% rename from src/result.ts rename to src/model/change-set.ts index 8aefb41c..90eff056 100644 --- a/src/result.ts +++ b/src/model/change-set.ts @@ -1,8 +1,8 @@ /** * What a mutation did. Rendered as text or JSON after every write. */ -import type { Warning } from './errors.js'; -import type { El } from './model.js'; +import type { Warning } from '../shared/errors.js'; +import type { El } from './moddle.js'; export interface Change { id: string; @@ -64,7 +64,7 @@ export function replaced(old: El, next: El): void { if (old !== next) successors.set(old, next); } -/** The element `el` is now: the last one that took its place (replaced), or itself (also read by diagram/incremental.ts changedEnds). */ +/** The element `el` is now: the last one that took its place (replaced), or itself (also read by layout/incremental.ts changedEnds). */ export function successorOf(el: El): El { const seen = new Set([el]); for (let next = successors.get(el); next && !seen.has(next); next = successors.get(el)) { diff --git a/src/document.ts b/src/model/document.ts similarity index 97% rename from src/document.ts rename to src/model/document.ts index 9d54f58e..74203472 100644 --- a/src/document.ts +++ b/src/model/document.ts @@ -4,20 +4,20 @@ * * Ids: the registry and the lookups cover BPMN and DI elements only (DI ids * are reserved but not resolvable); ids of vendor extension elements are - * vendor data (see model.ts) and never resolve: `require` answers E_NOT_FOUND + * vendor data (see moddle.ts) and never resolve: `require` answers E_NOT_FOUND * naming the vendor element and its BPMN owner instead. */ import type { ImportWarning } from 'bpmn-moddle'; import type { BpmnModdle } from 'bpmn-moddle'; -import { modelError, ioError, usageError } from './errors.js'; -import { about, replaced, type ChangeSet, type Rename } from './result.js'; -import { editDistance, hasIdWords, IdRegistry, isValidId, transliterate, typoTolerance, withSuffix } from './ids.js'; -import type { IdConventions } from './conventions.js'; -import { IdStyle, speakingStem, typeRequest, type IdRequest, type IdState } from './idstyle.js'; +import { modelError, ioError, usageError } from '../shared/errors.js'; +import { about, replaced, type ChangeSet, type Rename } from './change-set.js'; +import { editDistance, hasIdWords, IdRegistry, isValidId, transliterate, typoTolerance, withSuffix } from '../ids/slugs.js'; +import type { IdConventions } from '../ids/conventions.js'; +import { IdStyle, speakingStem, typeRequest, type IdRequest, type IdState } from '../ids/style.js'; import { kindLabel, suggestKinds } from './kinds.js'; import { completeMirrorLists, takeMirrorSnapshot, type MirrorSnapshot } from './mirror.js'; -import { C7_DEFAULT_TTL, C7_PLATFORM_VERSION, platformOf } from './platform/descriptor.js'; -import { C8_PLATFORM_VERSION } from './platform/zeebe.js'; +import { C7_DEFAULT_TTL, C7_PLATFORM_VERSION, platformOf } from '../platform/descriptor.js'; +import { C8_PLATFORM_VERSION } from '../platform/zeebe.js'; import { createDefinitions, createModdle, @@ -34,7 +34,7 @@ import { type El, type Model, ModelError, -} from './model.js'; +} from './moddle.js'; export const KNOWN_NAMESPACES: Record = { camunda: 'http://camunda.org/schema/1.0/bpmn', @@ -47,7 +47,7 @@ export const KNOWN_NAMESPACES: Record = { xsi: 'http://www.w3.org/2001/XMLSchema-instance', }; -// `duplicate element`: model.ts parseXml (an element the schema allows once appears twice; the reader keeps the last) +// `duplicate element`: moddle.ts parseXml (an element the schema allows once appears twice; the reader keeps the last) const LOSSY_PATTERNS = [/unparsable content/i, /unrecognized element/i, /unresolved reference/i, /duplicate ID/i, /^duplicate element/i]; export interface NewDocOptions { @@ -57,7 +57,7 @@ export interface NewDocOptions { /** declare vendor namespaces and the execution platform up front (and, for camunda7, the Modeler's process defaults) */ target?: 'camunda8' | 'camunda7' | 'none'; /** - * the project's declared id conventions (src/conventions.ts; the node + * the project's declared id conventions (src/ids/conventions.ts; the node * layer reads them from the .bpmnlintrc): the document keeps them * (Doc.conventions); the process and definitions ids follow them only * where they name bpmn:Process / bpmn:Definitions exactly @@ -228,7 +228,7 @@ export class Doc { * The text the document was read from and its incoming / outgoing lists * at that time (Doc.fromXml, also readDoc / loadDoc of the node layer; * undefined for Doc.create): the write pipeline keeps the file's - * formatting and mirror-list style (preserve.ts, mirror.ts) and reports + * formatting and mirror-list style (xml/preserve.ts, mirror.ts) and reports * a result equal to it as `unchanged`. */ public readonly source?: DocSource, @@ -290,7 +290,7 @@ export class Doc { /** * An explicit platform for the running mutation (MutationOptions.platform - * other than auto; set by pipeline.ts mutateDoc around the ops), so the ops + * other than auto; set by pipeline/index.ts mutateDoc around the ops), so the ops * follow the same engine as the profile that reports on them. */ platformChoice?: 'c7' | 'c8' | 'none'; @@ -483,10 +483,10 @@ export class Doc { } /** - * The project's declared id conventions (src/conventions.ts; the pipeline + * The project's declared id conventions (src/ids/conventions.ts; the pipeline * sets them for a call from MutationOptions.conventions): new ids follow * them where they declare a prefix, the file's own style elsewhere - * (src/idstyle.ts). Setting other ones learns the style again. + * (src/ids/style.ts). Setting other ones learns the style again. */ get conventions(): IdConventions | undefined { return this.declared; @@ -498,13 +498,13 @@ export class Doc { this.style = undefined; } - /** The id conventions of this document, learned from its ids on first use (src/idstyle.ts), the declared ones over them. */ + /** The id conventions of this document, learned from its ids on first use (src/ids/style.ts), the declared ones over them. */ get idStyle(): IdStyle { return (this.style ??= IdStyle.infer(this.definitions, this.declared)); } /** - * A new id in the document's style (src/idstyle.ts) for a kindRequest / + * A new id in the document's style (src/ids/style.ts) for a kindRequest / * typeRequest / connectionRequest / flowRequest; claims it. `base` is the * id the request wanted: when it was taken the id carries a suffix, which * is recorded for W_ID_SUFFIXED (takeSuffixed). An id under a prefix the @@ -661,7 +661,7 @@ export class Doc { * `next` took the place of `old` (a retype that changes the type builds a * new element, ops/retype.ts swapType): what the running batch recorded * about `old` is about `next`, its former ends (recordFormerEnd) and the - * change entries made for it (result.ts replaced). + * change entries made for it (change-set.ts replaced). */ replaceElement(old: El, next: El): void { replaced(old, next); diff --git a/src/kinds.ts b/src/model/kinds.ts similarity index 99% rename from src/kinds.ts rename to src/model/kinds.ts index e6b3a5bb..222a2980 100644 --- a/src/kinds.ts +++ b/src/model/kinds.ts @@ -6,8 +6,8 @@ * moddle type with or without prefix (`bpmn:UserTask`, `UserTask`). Events * take an optional trigger suffix: `startEvent:message`, `boundary:timer`. */ -import { CliError } from './errors.js'; -import { is, type El } from './model.js'; +import { CliError } from '../shared/errors.js'; +import { is, type El } from './moddle.js'; export type Family = | 'task' diff --git a/src/mirror.ts b/src/model/mirror.ts similarity index 96% rename from src/mirror.ts rename to src/model/mirror.ts index 6c5f0366..fc7a6cea 100644 --- a/src/mirror.ts +++ b/src/model/mirror.ts @@ -2,7 +2,7 @@ * The `incoming` / `outgoing` lists of flow nodes are derived data: BPMN 2.0 * makes them optional mirrors of each sequence flow's sourceRef / targetRef. * The CLI completes them in memory when it reads a document (Doc.fromXml, - * after recording them as read; validate.ts repairFlowLinks does the same for + * after recording them as read; validate/structural.ts repairFlowLinks does the same for * a model changed in memory), because the placement grammar, the views, the * lint and the layout read them. A file keeps them only the way it kept them * before: @@ -21,7 +21,7 @@ * A document created by the CLI (`new`) has no snapshot: every entry the ops * maintain is written, like the Modeler does. */ -import { addTo, indexById, is, parseXml, serialize, walk, type El, type Model } from './model.js'; +import { addTo, indexById, is, parseXml, serialize, walk, type El, type Model } from './moddle.js'; type Direction = 'incoming' | 'outgoing'; @@ -50,7 +50,7 @@ const listOf = (node: El, direction: Direction): El[] => (node.get the nearest .bpmnlintrc from dir up to the repository root (the path as given, * then the physical one), or undefined @@ -10,7 +10,7 @@ * on what it left out or read from the project), or why bpmnlint cannot run * projectBpmnlint(file, opts) -> the NamedValidator for a file, or undefined (no .bpmnlintrc, --no-lint-config) * projectBpmnlintSettings(file) -> the effective rule settings (same lookup, flags, cache and errors) - * projectIdConventions(file, opts) -> the id conventions its element-id-naming declares (src/conventions.ts), the + * projectIdConventions(file, opts) -> the id conventions its element-id-naming declares (src/ids/conventions.ts), the * W_CONFIG_IGNORED notes the validator reports and what it leaves out (same lookup, * flags, cache) * @@ -99,10 +99,10 @@ import { lstatSync, readFileSync, realpathSync, statSync } from 'node:fs'; import Module, { createRequire } from 'node:module'; import { homedir } from 'node:os'; import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from 'node:path'; -import { bpmnlintUnavailableFindings, bpmnlintValidator, BPMNLINT_VALIDATOR, moddleEntries, resolveBpmnlintConfig, type BpmnlintConfig, type BpmnlintEngine, type BpmnlintLinterClass, type BpmnlintResolver, type BpmnlintRuleSetting, type BpmnlintUnavailable, type ResolvedBpmnlintConfig } from '../bpmnlint.js'; -import { idConventionsFromLint, ID_NAMING_RULE, type IdConventions, type IdNamingHelpers } from '../conventions.js'; -import { ioError } from '../errors.js'; -import type { NamedValidator, Validator, ValidatorFinding } from '../validators.js'; +import { bpmnlintUnavailableFindings, bpmnlintValidator, BPMNLINT_VALIDATOR, moddleEntries, resolveBpmnlintConfig, type BpmnlintConfig, type BpmnlintEngine, type BpmnlintLinterClass, type BpmnlintResolver, type BpmnlintRuleSetting, type BpmnlintUnavailable, type ResolvedBpmnlintConfig } from '../validate/bpmnlint-validator.js'; +import { idConventionsFromLint, ID_NAMING_RULE, type IdConventions, type IdNamingHelpers } from '../ids/conventions.js'; +import { ioError } from '../shared/errors.js'; +import type { NamedValidator, Validator, ValidatorFinding } from '../validate/validators.js'; import { findUp, gitRoot } from './find-up.js'; export const BPMNLINT_CONFIG_FILE = '.bpmnlintrc'; @@ -963,7 +963,7 @@ export async function projectBpmnlint(file: string | undefined, opts: FileBpmnli /** What the .bpmnlintrc of a file declares about ids (projectIdConventions). */ export interface ProjectIdConventions { - /** the id conventions of its element-id-naming (src/conventions.ts); absent: the rule is off or not configured, or every prefix is switched off */ + /** the id conventions of its element-id-naming (src/ids/conventions.ts); absent: the rule is off or not configured, or every prefix is switched off */ conventions?: IdConventions; /** W_CONFIG_IGNORED: values of the rule's options new ids do not follow (the validator reports them); W_LINT_UNAVAILABLE: what the configuration leaves out, or why it could not be loaded */ notes: ValidatorFinding[]; @@ -977,7 +977,7 @@ export interface ProjectIdConventions { /** * The id conventions the .bpmnlintrc that applies to a file declares through - * @miragon/rules/element-id-naming (src/conventions.ts idConventionsFromLint + * @miragon/rules/element-id-naming (src/ids/conventions.ts idConventionsFromLint * with the plugin's own naming helpers): the same lookup, flags and cache as * projectBpmnlint; undefined without a .bpmnlintrc or with `lintConfig: * false`. The notes list what `validate` lists about the configuration: its diff --git a/src/node/files.ts b/src/node/files.ts index 39974b69..7fb7b7e7 100644 --- a/src/node/files.ts +++ b/src/node/files.ts @@ -25,7 +25,7 @@ * Encoding: a file is read in the encoding its XML declaration names * (decodeXmlBytes: UTF-8 without one, UTF-16 by its byte order mark), so * that the characters of an ISO-8859-1 / Windows-1252 file survive; every - * write is UTF-8, and a changed result declares UTF-8 (src/encoding.ts). + * write is UTF-8, and a changed result declares UTF-8 (src/xml/encoding.ts). * * Validators (MutationOptions.validators): they see the file being written * (the `out` target with `out`) or checked as `ctx.file`, unless `file` names @@ -37,18 +37,18 @@ * or `lintConfig`, runs as an advisory validator next to the host's * (`lintBlocks`: a blocking one); without a .bpmnlintrc nothing is loaded. * Its @miragon/rules/element-id-naming gives the id conventions new ids - * follow (src/conventions.ts), unless the host passes `conventions` itself + * follow (src/ids/conventions.ts), unless the host passes `conventions` itself * (or a validator named bpmnlint: then its own conventions, if any). */ import { copyFile, mkdir, readFile, rename, rm, stat, writeFile } from 'node:fs/promises'; import { basename, dirname, join, resolve } from 'node:path'; -import { Doc } from '../document.js'; -import { declaredEncoding, isUtf8 } from '../encoding.js'; -import { ioError } from '../errors.js'; +import { Doc } from '../model/document.js'; +import { declaredEncoding, isUtf8 } from '../xml/encoding.js'; +import { ioError } from '../shared/errors.js'; import type { Op } from '../ops/types.js'; -import { assertLayoutOptions, assertLossless, checkDoc, layoutDoc, mutateDoc, type CheckOptions, type CheckResult, type LayoutDocOptions, type MutationOptions, type MutationResult } from '../pipeline.js'; -import type { IdConventions } from '../conventions.js'; -import type { Validator } from '../validators.js'; +import { assertLayoutOptions, assertLossless, checkDoc, layoutDoc, mutateDoc, type CheckOptions, type CheckResult, type LayoutDocOptions, type MutationOptions, type MutationResult } from '../pipeline/index.js'; +import type { IdConventions } from '../ids/conventions.js'; +import type { Validator } from '../validate/validators.js'; import { projectLint, type FileBpmnlintOptions } from './bpmnlint.js'; /** Where and whether the node layer writes the result of the in-memory pipeline. */ diff --git a/src/node/render.ts b/src/node/render.ts index 306b203c..0ef916c8 100644 --- a/src/node/render.ts +++ b/src/node/render.ts @@ -1,6 +1,6 @@ /** * PNG images of a diagram (Node only; `@miragon/bpmn-cli/node`): the SVG of - * the core renderer (src/diagram/render.ts) rasterised by resvg compiled to + * the core renderer (src/render/index.ts) rasterised by resvg compiled to * WebAssembly (@resvg/resvg-wasm, imported on the first call, like * bpmn-auto-layout) with the bundled Arimo font (assets/fonts, SIL OFL 1.1; * metric-compatible with Arial, so the SVG's line breaks hold). No system @@ -23,8 +23,8 @@ */ import { readFile } from 'node:fs/promises'; import { createRequire } from 'node:module'; -import { RENDER_MAX_SIZE, renderSvg, type RenderOptions, type RenderProblem, type RenderTile } from '../diagram/render.js'; -import { CliError } from '../errors.js'; +import { RENDER_MAX_SIZE, renderSvg, type RenderOptions, type RenderProblem, type RenderTile } from '../render/index.js'; +import { CliError } from '../shared/errors.js'; export interface PngImage { png: Uint8Array; diff --git a/src/ops/add.ts b/src/ops/add.ts index 792a07c9..4b0879aa 100644 --- a/src/ops/add.ts +++ b/src/ops/add.ts @@ -5,7 +5,7 @@ * - id: op.id (claimId) or a speaking id in the file's style * (doc.allocateId with kindRequest: kind, trigger, name, and the placement * as the context of an unnamed element: Gateway_AfterCheckInvoice, - * Event_TimerOnReview; src/idstyle.ts); a taken id gets a `_2` suffix + * Event_TimerOnReview; src/ids/style.ts); a taken id gets a `_2` suffix * (W_ID_SUFFIXED, reported by ops/index.ts). * - op.ifAbsent with op.id and the element exists -> empty ChangeSet with a note; * ifAbsent without an id is E_USAGE (same rule as `apply`). @@ -21,7 +21,7 @@ * (found by id or name, created when missing), like a message event. * - participants: a new process gets the platform defaults (Doc.initProcess: * camunda:historyTimeToLive in a Camunda 7 file); a user task of a Camunda 8 - * file gets zeebe:userTask (ops/platform.ts). + * file gets zeebe:userTask (platform/defaults.ts). * - flow nodes: create with name (+ def.props), placeNode() from ./flows.js, * applyTrigger() for events (default trigger 'none'; boundary events and * event sub-process start events require a trigger -> E_TRIGGER_REQUIRED; @@ -60,18 +60,18 @@ * Because 'expanded' lives in DI, explicit collapse requests are recorded per * Doc (collapseRequests) so the pipeline can hand them to the layouter. */ -import type { Doc } from '../document.js'; -import { CliError, modelError, usageError } from '../errors.js'; -import { anchorContext, kindRequest, type AnchorContext, type ContextWord, type IdRequest } from '../idstyle.js'; -import { FLOW_NODE_FAMILIES, KindError, kindByName, kindLabel, normalizeTrigger, parseKind, type KindDef, type ParsedKind, type Trigger } from '../kinds.js'; -import { addTo, is, localType, many, type El } from '../model.js'; -import { ChangeSet, renamedNote, type Change } from '../result.js'; +import type { Doc } from '../model/document.js'; +import { CliError, modelError, usageError } from '../shared/errors.js'; +import { anchorContext, kindRequest, type AnchorContext, type ContextWord, type IdRequest } from '../ids/style.js'; +import { FLOW_NODE_FAMILIES, KindError, kindByName, kindLabel, normalizeTrigger, parseKind, type KindDef, type ParsedKind, type Trigger } from '../model/kinds.js'; +import { addTo, is, localType, many, type El } from '../model/moddle.js'; +import { ChangeSet, renamedNote, type Change } from '../model/change-set.js'; import { createAssociation, createDataAssociation, createDataObject, createDataStore, createTextAnnotation } from './artifacts.js'; import { assignLane, createLane, createParticipant, laneOf } from './containers.js'; import { applyTrigger, bindRefAs } from './events.js'; import { inheritedLane, laneInheritedWarning, type InheritedLane } from './lanes.js'; import { assertCondition, flowIdIgnoredHint, placeNode, placementMode, placementScope, warnEventGatewayFlow } from './flows.js'; -import { zeebeUserTaskDefault } from './platform.js'; +import { zeebeUserTaskDefault } from '../platform/defaults.js'; import { setProperties, setTaskMessage } from './set.js'; import type { AddOp, TriggerOptions } from './types.js'; diff --git a/src/ops/aliases.ts b/src/ops/aliases.ts index f8a2a474..52cb9320 100644 --- a/src/ops/aliases.ts +++ b/src/ops/aliases.ts @@ -37,10 +37,10 @@ * (`branches`, their `nodes`) are read only where they are arrays of * objects, so a malformed one reaches splitFlow's own check (E_USAGE). */ -import type { Doc } from '../document.js'; -import { CliError, usageError } from '../errors.js'; -import { editDistance, typoTolerance } from '../ids.js'; -import type { El } from '../model.js'; +import type { Doc } from '../model/document.js'; +import { CliError, usageError } from '../shared/errors.js'; +import { editDistance, typoTolerance } from '../ids/slugs.js'; +import type { El } from '../model/moddle.js'; import type { Op } from './types.js'; export const ALIAS = /^\$[A-Za-z_][A-Za-z0-9_-]*$/; @@ -61,7 +61,7 @@ export const REF_KEYS: Record = { order: ['id', 'flows', 'lanes', 'pools'], ext: ['id'], split: ['after'], - // the selectors of place / align / color / tidy (diagram/select.ts) name elements too: path, via, branch + // the selectors of place / align / color / tidy (query/select.ts) name elements too: path, via, branch place: ['ids', 'path', 'via', 'branch', 'rowOf', 'below', 'above', 'columnOf', 'after', 'before'], align: ['ids', 'path', 'via', 'branch', 'to'], color: ['ids', 'path', 'via', 'branch'], diff --git a/src/ops/artifacts.ts b/src/ops/artifacts.ts index f4c994c6..b1bc0591 100644 --- a/src/ops/artifacts.ts +++ b/src/ops/artifacts.ts @@ -1,7 +1,7 @@ /** * Data objects / stores, text annotations, associations, data associations. * - * Ids follow the file's style (src/idstyle.ts); the bpmn-cli default is + * Ids follow the file's style (src/ids/style.ts); the bpmn-cli default is * given here. * - createDataObject(): bpmn:DataObject (id DataObject_) + a * bpmn:DataObjectReference (id DataObjectReference_, the element the @@ -26,12 +26,12 @@ * - removeDataAssociation() / removeAssociation(): inverse, incl. placeholder * property cleanup when unused. */ -import type { Doc } from '../document.js'; -import { modelError } from '../errors.js'; -import { kindByName, kindLabel, triggerOf } from '../kinds.js'; -import { contextOf, kindRequest, labelOf, speakingStem, typeRequest, type IdRequest } from '../idstyle.js'; -import { addTo, is, many, removeFrom, type El } from '../model.js'; -import type { ChangeSet } from '../result.js'; +import type { Doc } from '../model/document.js'; +import { modelError } from '../shared/errors.js'; +import { kindByName, kindLabel, triggerOf } from '../model/kinds.js'; +import { contextOf, kindRequest, labelOf, speakingStem, typeRequest, type IdRequest } from '../ids/style.js'; +import { addTo, is, many, removeFrom, type El } from '../model/moddle.js'; +import type { ChangeSet } from '../model/change-set.js'; export const PLACEHOLDER_PROPERTY = '__targetRef_placeholder'; diff --git a/src/batch.ts b/src/ops/batch.ts similarity index 99% rename from src/batch.ts rename to src/ops/batch.ts index c1037e7d..8d14d5a8 100644 --- a/src/batch.ts +++ b/src/ops/batch.ts @@ -14,10 +14,10 @@ * ops/aliases.ts) are checked before anything runs: defined once, used only * after the op that defines them. */ -import { usageError, type CliError } from './errors.js'; -import { editDistance } from './ids.js'; -import { FLOW_NODE_FAMILIES, KindError, kindByName, normalizeTrigger, parseKind, type Family } from './kinds.js'; -import { ALIAS, checkAliases } from './ops/aliases.js'; +import { usageError, type CliError } from '../shared/errors.js'; +import { editDistance } from '../ids/slugs.js'; +import { FLOW_NODE_FAMILIES, KindError, kindByName, normalizeTrigger, parseKind, type Family } from '../model/kinds.js'; +import { ALIAS, checkAliases } from './aliases.js'; import { OP_NAMES, parseSpaceAmount, @@ -44,7 +44,7 @@ import { type SplitBranch, type SplitOp, type TriggerOptions, -} from './ops/types.js'; +} from './types.js'; /* ------------------------------------------------------------------ */ /* field specs */ diff --git a/src/ops/connect.ts b/src/ops/connect.ts index b21db7a1..ca94ae09 100644 --- a/src/ops/connect.ts +++ b/src/ops/connect.ts @@ -25,12 +25,12 @@ * message flows, message to message flows (else E_INVALID_VALUE); * default together with condition is E_USAGE (a default flow has none) */ -import type { Doc } from '../document.js'; -import { modelError, usageError } from '../errors.js'; -import { flowRequest } from '../idstyle.js'; -import { kindLabel, triggerOf } from '../kinds.js'; -import { addTo, is, many, type El } from '../model.js'; -import { ChangeSet } from '../result.js'; +import type { Doc } from '../model/document.js'; +import { modelError, usageError } from '../shared/errors.js'; +import { flowRequest } from '../ids/style.js'; +import { kindLabel, triggerOf } from '../model/kinds.js'; +import { addTo, is, many, type El } from '../model/moddle.js'; +import { ChangeSet } from '../model/change-set.js'; import { artifactContainerOf, createAssociation, createDataAssociation, isDataReference } from './artifacts.js'; import { bindRefAs, ensureRootElement } from './events.js'; import { createSequenceFlow, flowChange, warnEventGatewayFlow } from './flows.js'; diff --git a/src/ops/containers.ts b/src/ops/containers.ts index 09491f27..47e0f3b6 100644 --- a/src/ops/containers.ts +++ b/src/ops/containers.ts @@ -8,7 +8,7 @@ * Process_) unless op.process names an existing unbound process or * op.blackBox is set. Participant ids: Participant_ (unnamed: the * label of its process, or BlackBox). (Ids follow the file's style, - * src/idstyle.ts; the bpmn-cli default is given here.) + * src/ids/style.ts; the bpmn-cli default is given here.) * - createLane(): creates the process' laneSet when missing (id * LaneSet_), lane id Lane_; op.in may be a process, participant or a lane * (-> nested childLaneSet); op.members assigns nodes. The first child lane @@ -21,12 +21,12 @@ * members (E_INVALID_LANE_MEMBERSHIP). * - laneOf(): the (deepest) lane referencing a node. */ -import type { Doc } from '../document.js'; -import { modelError } from '../errors.js'; -import { kindByName, kindLabel } from '../kinds.js'; -import { contextOf, kindRequest, labelOf, typeRequest, type IdRequest } from '../idstyle.js'; -import { addTo, insertInto, is, many, removeFrom, type El } from '../model.js'; -import type { ChangeSet } from '../result.js'; +import type { Doc } from '../model/document.js'; +import { modelError } from '../shared/errors.js'; +import { kindByName, kindLabel } from '../model/kinds.js'; +import { contextOf, kindRequest, labelOf, typeRequest, type IdRequest } from '../ids/style.js'; +import { addTo, insertInto, is, many, removeFrom, type El } from '../model/moddle.js'; +import type { ChangeSet } from '../model/change-set.js'; import type { AddOp } from './types.js'; function idOf(el: El): string { diff --git a/src/ops/covers.ts b/src/ops/covers.ts index d38f6551..09582f0f 100644 --- a/src/ops/covers.ts +++ b/src/ops/covers.ts @@ -14,7 +14,7 @@ * Without the profile (`--platform none`, a file of another platform) the * operation warning stays. */ -import type { Warning } from '../errors.js'; +import type { Warning } from '../shared/errors.js'; import { subjectOf, type ProfileFinding } from '../platform/finding.js'; /** Hidden list of profile subjects an operation warning repeats (not serialised). */ diff --git a/src/ops/decision.ts b/src/ops/decision.ts index e4c70ee6..8c391077 100644 --- a/src/ops/decision.ts +++ b/src/ops/decision.ts @@ -36,12 +36,12 @@ * its zeebe:calledDecision with its resultVariable). */ import type { ImportWarning } from 'bpmn-moddle'; -import type { Doc } from '../document.js'; -import { modelError } from '../errors.js'; -import { kindLabel } from '../kinds.js'; -import { addTo, is, many, removeFrom, walk, type El } from '../model.js'; +import type { Doc } from '../model/document.js'; +import { modelError } from '../shared/errors.js'; +import { kindLabel } from '../model/kinds.js'; +import { addTo, is, many, removeFrom, walk, type El } from '../model/moddle.js'; import { C7_URIS, CAMUNDA_URI, OPERATON_URI, ZEEBE_URI } from '../platform/descriptor.js'; -import type { ChangeSet } from '../result.js'; +import type { ChangeSet } from '../model/change-set.js'; import { coversProfileSubjects } from './covers.js'; export interface DecisionLink { diff --git a/src/ops/events.ts b/src/ops/events.ts index 023a812a..befb928e 100644 --- a/src/ops/events.ts +++ b/src/ops/events.ts @@ -26,14 +26,14 @@ * "PT2D", "message OrderReceived", "error PaymentFailed (PAY-001)", "" when none. * - triggerDetails(): the same as structured data for --json views. */ -import type { Doc } from '../document.js'; -import { modelError, usageError, type Warning } from '../errors.js'; -import { typeRequest } from '../idstyle.js'; -import { kindLabel, kindOf, triggerOf, TRIGGER_TYPES, type Trigger } from '../kinds.js'; -import { addTo, is, many, walk, type El } from '../model.js'; +import type { Doc } from '../model/document.js'; +import { modelError, usageError, type Warning } from '../shared/errors.js'; +import { typeRequest } from '../ids/style.js'; +import { kindLabel, kindOf, triggerOf, TRIGGER_TYPES, type Trigger } from '../model/kinds.js'; +import { addTo, is, many, walk, type El } from '../model/moddle.js'; import { isC7Uri } from '../platform/descriptor.js'; -import type { ChangeSet } from '../result.js'; -import { definitionIdDefault } from './platform.js'; +import type { ChangeSet } from '../model/change-set.js'; +import { definitionIdDefault } from '../platform/defaults.js'; import type { TriggerOptions } from './types.js'; export interface TriggerDetails { @@ -73,7 +73,7 @@ function idOf(el: El): string { /** * Finds a root Message/Error/Signal/Escalation by id or name, creating it - * (id `_` in the default style, src/idstyle.ts) when missing. `extra` (errorCode / escalationCode) + * (id `_` in the default style, src/ids/style.ts) when missing. `extra` (errorCode / escalationCode) * is applied to found elements too. Returns whether it was created. */ export function ensureRootElement(doc: Doc, type: RootRefType, nameOrId: string, extra: Record = {}): { el: El; created: boolean } { diff --git a/src/ops/ext.ts b/src/ops/ext.ts index 79dab9fb..0619cdf7 100644 --- a/src/ops/ext.ts +++ b/src/ops/ext.ts @@ -68,13 +68,13 @@ * exactly the generic elements moddle would create (same $type / attrs / * $body / $children shape, verified against moddle's own parse). */ -import type { Doc } from '../document.js'; -import { modelError, usageError, type Warning } from '../errors.js'; -import { addTo, BPMN_NS, is, many, removeFrom, walk, type El } from '../model.js'; +import type { Doc } from '../model/document.js'; +import { modelError, usageError, type Warning } from '../shared/errors.js'; +import { addTo, BPMN_NS, is, many, removeFrom, walk, type El } from '../model/moddle.js'; import { allowedOn, allowedParents, CAMUNDA_URI, containersOf, OPERATON_URI, ZEEBE_URI } from '../platform/descriptor.js'; import { zeebeAllowedOn, zeebeType } from '../platform/zeebe.js'; -import { ChangeSet } from '../result.js'; -import { kindLabel } from '../kinds.js'; +import { ChangeSet } from '../model/change-set.js'; +import { kindLabel } from '../model/kinds.js'; import { coversProfileSubjects } from './covers.js'; import { changeOf, definitionsOf, descriptorOf, idOf, isEl, nestedEntries, NESTED_SLOTS, parseSlotRef, resolveNested, SLOT_TEXT, slotsOf, type NestedSlot } from './set.js'; import type { ExtOp } from './types.js'; diff --git a/src/ops/flows.ts b/src/ops/flows.ts index de27d9f0..2b1353ce 100644 --- a/src/ops/flows.ts +++ b/src/ops/flows.ts @@ -24,14 +24,14 @@ * speaks. A flow without id (valid BPMN, rare in files) whose ends change * gets an id from its new ends. */ -import type { Doc, FlowEnds, FormerEnd, KeptFlow } from '../document.js'; +import type { Doc, FlowEnds, FormerEnd, KeptFlow } from '../model/document.js'; import { followDiIds } from '../diagram/write.js'; -import { modelError, type Warning } from '../errors.js'; -import { connectionRequest, flowRequest, formerLabels, labelOf, speakingStem, type IdRequest } from '../idstyle.js'; -import { hasIdWords, IdRegistry, isSuffix, isValidId, slugify } from '../ids.js'; -import { kindLabel, triggerOf } from '../kinds.js'; -import { addTo, insertInto, is, many, removeFrom, type El } from '../model.js'; -import { about, renamedNote, type ChangeSet } from '../result.js'; +import { modelError, type Warning } from '../shared/errors.js'; +import { connectionRequest, flowRequest, formerLabels, labelOf, speakingStem, type IdRequest } from '../ids/style.js'; +import { hasIdWords, IdRegistry, isSuffix, isValidId, slugify } from '../ids/slugs.js'; +import { kindLabel, triggerOf } from '../model/kinds.js'; +import { addTo, insertInto, is, many, removeFrom, type El } from '../model/moddle.js'; +import { about, renamedNote, type ChangeSet } from '../model/change-set.js'; import type { FlowOptions, Placement } from './types.js'; export interface FlowAttrs { @@ -634,7 +634,7 @@ function restoreFlowIdHints(doc: Doc, cs: ChangeSet, flow: El, id: string): void }); } -/** ` (renamed from )` for a change detail when followEnds renamed the flow (result.ts, where a takeover drops it again). */ +/** ` (renamed from )` for a change detail when followEnds renamed the flow (model/change-set.ts, where a takeover drops it again). */ export { renamedNote }; export function redirectFlow(doc: Doc, flow: El, ends: { source?: El; target?: El }): string | undefined { diff --git a/src/ops/index.ts b/src/ops/index.ts index b7e96ebf..cf40b9ba 100644 --- a/src/ops/index.ts +++ b/src/ops/index.ts @@ -1,10 +1,10 @@ /** * Op dispatcher. Every CLI command and `apply` go through here. */ -import type { BatchContext, Doc, FlowEnds } from '../document.js'; -import { usageError, type Warning } from '../errors.js'; -import { is, type El } from '../model.js'; -import { ChangeSet } from '../result.js'; +import type { BatchContext, Doc, FlowEnds } from '../model/document.js'; +import { usageError, type Warning } from '../shared/errors.js'; +import { is, type El } from '../model/moddle.js'; +import { ChangeSet } from '../model/change-set.js'; import { addElement } from './add.js'; import { AliasTable, referencedIds, referencesOf, resolveOp } from './aliases.js'; import { connectElements } from './connect.js'; @@ -99,7 +99,7 @@ function dispatch(doc: Doc, op: Op): ChangeSet { case 'space': case 'tidy': case 'compact': - // diagram only: they run after the layout (src/diagram/ops.ts, called by the pipeline) + // diagram only: they run after the layout (src/format/index.ts, called by the pipeline) return new ChangeSet(); default: throw usageError(`Unknown operation "${String((op as { op?: unknown }).op)}"`); @@ -132,7 +132,7 @@ export function runBatch(doc: Doc, ops: Op[]): BatchRun { const table = new AliasTable(doc); const resolved: Op[] = []; const deferred: number[] = []; - // what the batch did so far, for E_NOT_FOUND (document.ts require / suggest) + // what the batch did so far, for E_NOT_FOUND (model/document.ts require / suggest) const context: BatchContext = { created: [], renamed: new Map(), retyped: new Set(), aliases: () => table.toRecord() }; readIdStyle(doc); doc.takeKeptFlows(); diff --git a/src/ops/lanes.ts b/src/ops/lanes.ts index 73769275..a0270a81 100644 --- a/src/ops/lanes.ts +++ b/src/ops/lanes.ts @@ -16,9 +16,9 @@ * lane, neither of the two lanes the flow connects: says so and names * the lane of the row the layout would draw a new node on. */ -import type { Doc } from '../document.js'; -import type { Warning } from '../errors.js'; -import { is, type El } from '../model.js'; +import type { Doc } from '../model/document.js'; +import type { Warning } from '../shared/errors.js'; +import { is, type El } from '../model/moddle.js'; import { laneOf } from './containers.js'; import { placementMode } from './flows.js'; import type { Placement } from './types.js'; diff --git a/src/ops/move.ts b/src/ops/move.ts index a0b566d5..fe5e8f72 100644 --- a/src/ops/move.ts +++ b/src/ops/move.ts @@ -75,11 +75,11 @@ * unless op.lane names one. --on re-attaches a boundary event (it takes * its host's lane). */ -import type { Doc } from '../document.js'; -import { modelError, usageError, type Warning } from '../errors.js'; -import { kindLabel } from '../kinds.js'; -import { addTo, is, removeFrom, walk, type El } from '../model.js'; -import { about, ChangeSet } from '../result.js'; +import type { Doc } from '../model/document.js'; +import { modelError, usageError, type Warning } from '../shared/errors.js'; +import { kindLabel } from '../model/kinds.js'; +import { addTo, is, removeFrom, walk, type El } from '../model/moddle.js'; +import { about, ChangeSet } from '../model/change-set.js'; import { assignLane, laneOf } from './containers.js'; import { applyFlowOptions, carryAssociations, flowChange, insertAfterInScope, placeNode, placementMode, placementScope, redirectFlow, removeSequenceFlow, renamedNote, warnEventGatewayFlow, type Bridge, type PlacementOptions } from './flows.js'; import { crossLaneNote, inheritedLane, laneInheritedWarning } from './lanes.js'; diff --git a/src/ops/order.ts b/src/ops/order.ts index 012a896d..6ffc01c8 100644 --- a/src/ops/order.ts +++ b/src/ops/order.ts @@ -13,19 +13,19 @@ * process) or a lane (its child lanes); every listed id must be a direct * child lane of it (E_NOT_CHILD_LANE); unlisted lanes follow in their old * order. Rewrites `laneSet.lanes`. A kept diagram gets its bands reordered in - * the diagram phase (src/diagram/ops.ts, orderBands). + * the diagram phase (src/format/index.ts, orderBands). * * Pools: with `op.pools`, a collaboration as op.id (or participant ids in * `op.flows`) the participants of that collaboration are ordered top to * bottom instead (black-box pools included); every listed id must be one of * its participants (E_NOT_PARTICIPANT); unlisted pools follow in their old * order. Rewrites `collaboration.participants`; a kept diagram gets its pool - * bands reordered in the diagram phase (src/diagram/ops.ts, orderPools). + * bands reordered in the diagram phase (src/format/index.ts, orderPools). */ -import type { Doc } from '../document.js'; -import { modelError, usageError } from '../errors.js'; -import { insertInto, is, many, removeFrom, type El } from '../model.js'; -import { ChangeSet } from '../result.js'; +import type { Doc } from '../model/document.js'; +import { modelError, usageError } from '../shared/errors.js'; +import { insertInto, is, many, removeFrom, type El } from '../model/moddle.js'; +import { ChangeSet } from '../model/change-set.js'; import { changeOf, idOf } from './set.js'; import type { OrderOp } from './types.js'; diff --git a/src/ops/remove.ts b/src/ops/remove.ts index f7fb20e5..a3fe7a1f 100644 --- a/src/ops/remove.ts +++ b/src/ops/remove.ts @@ -61,10 +61,10 @@ * events fall with their host, many-valued references are pruned and * single-valued ones cleared (reported as a change). */ -import type { Doc } from '../document.js'; -import { modelError, usageError } from '../errors.js'; -import { findReferences, is, many, removeFrom, walk, type El } from '../model.js'; -import { ChangeSet } from '../result.js'; +import type { Doc } from '../model/document.js'; +import { modelError, usageError } from '../shared/errors.js'; +import { findReferences, is, many, removeFrom, walk, type El } from '../model/moddle.js'; +import { ChangeSet } from '../model/change-set.js'; import { detachNode, eventGatewayRule, eventGatewayTargetProblem, flowChange, redirectFlow, removeSequenceFlow, renamedNote, type Bridge } from './flows.js'; import { changeOf, descriptorOf, idOf, isEl, ownValue } from './set.js'; import type { RemoveOp } from './types.js'; diff --git a/src/ops/retype.ts b/src/ops/retype.ts index 5a599db3..cedf927b 100644 --- a/src/ops/retype.ts +++ b/src/ops/retype.ts @@ -42,18 +42,18 @@ * W_C7_MISPLACED_EXTENSION, W_C8_MISPLACED_ATTRIBUTE, W_C8_MISPLACED_EXTENSION); * withoutProfileDuplicates() drops the summary then, so * a write reports every item once. Retyped to a userTask in a Camunda 8 - * file, the task gets zeebe:userTask (ops/platform.ts). + * file, the task gets zeebe:userTask (platform/defaults.ts). */ -import type { Doc } from '../document.js'; -import { modelError, type Warning } from '../errors.js'; -import { KindError, kindLabel, kindOf, parseKind, triggerOf, type KindDef, type Trigger } from '../kinds.js'; -import { findReferences, is, many, removeFrom, walk, type El } from '../model.js'; +import type { Doc } from '../model/document.js'; +import { modelError, type Warning } from '../shared/errors.js'; +import { KindError, kindLabel, kindOf, parseKind, triggerOf, type KindDef, type Trigger } from '../model/kinds.js'; +import { findReferences, is, many, removeFrom, walk, type El } from '../model/moddle.js'; import { allowedOn, attrAppliesTo, isC7Uri, ZEEBE_URI } from '../platform/descriptor.js'; import { zeebeAllowedOn, zeebeAttr, zeebeNestedOnly } from '../platform/zeebe.js'; -import { ChangeSet } from '../result.js'; +import { ChangeSet } from '../model/change-set.js'; import { applyTrigger, bindRefAs } from './events.js'; import { coversProfileSubjects } from './covers.js'; -import { zeebeUserTaskDefault } from './platform.js'; +import { zeebeUserTaskDefault } from '../platform/defaults.js'; import { cascadeRemove } from './remove.js'; import { assertMessageFlowsFit, diff --git a/src/ops/set.ts b/src/ops/set.ts index fb31cd2e..8a0d3902 100644 --- a/src/ops/set.ts +++ b/src/ops/set.ts @@ -86,16 +86,16 @@ * (`changeOf`, `descriptorOf`, `ownValue`, `idOf`). */ import { followDiIds } from '../diagram/write.js'; -import type { Doc } from '../document.js'; -import { modelError, usageError } from '../errors.js'; -import { cutAt, IdRegistry, MAX_ID, withSuffix } from '../ids.js'; -import { kindRequest, type IdRequest, type IdState } from '../idstyle.js'; -import { kindLabel, kindOf, normalizeTrigger, triggerOf, TRIGGER_TYPES, type Trigger } from '../kinds.js'; -import { diExpansionState } from '../layout.js'; -import { addTo, is, localType, many, walk, type El } from '../model.js'; +import type { Doc } from '../model/document.js'; +import { modelError, usageError } from '../shared/errors.js'; +import { cutAt, IdRegistry, MAX_ID, withSuffix } from '../ids/slugs.js'; +import { kindRequest, type IdRequest, type IdState } from '../ids/style.js'; +import { kindLabel, kindOf, normalizeTrigger, triggerOf, TRIGGER_TYPES, type Trigger } from '../model/kinds.js'; +import { diExpansionState } from '../layout/index.js'; +import { addTo, is, localType, many, walk, type El } from '../model/moddle.js'; import { attrAppliesTo, camundaAttr, camundaAttrsFor, idReferenceAttrs, isC7Uri, typeIs, ZEEBE_URI } from '../platform/descriptor.js'; import { zeebeAllowedOn, zeebeAttr, zeebeType, zeebeTypeNames } from '../platform/zeebe.js'; -import { about, ChangeSet, type Change } from '../result.js'; +import { about, ChangeSet, type Change } from '../model/change-set.js'; import { assignLane } from './containers.js'; import { setDecisionLink } from './decision.js'; import { applyTrigger, bindRefAs, ensureRootElement, vendorContent } from './events.js'; diff --git a/src/ops/split.ts b/src/ops/split.ts index ccde9086..6bc22a10 100644 --- a/src/ops/split.ts +++ b/src/ops/split.ts @@ -16,7 +16,7 @@ * reach it: when one continues, its end connects to the old * successor directly (no pass-through gateway), when none does no * join is created either. - * - Typed ops of the library skip parseOps (src/batch.ts): before the split + * - Typed ops of the library skip parseOps (src/ops/batch.ts): before the split * changes anything, `branches` must be an array of objects, each with a * `nodes` array (empty allowed) of objects with a string `kind`, else * E_USAGE in parseOps' words (the path starts with `split`, not @@ -24,14 +24,14 @@ * is checked when addElement creates it. * - Returns the merged ChangeSet (notes: which ids were created). */ -import type { Doc } from '../document.js'; -import { modelError, usageError, type CliError } from '../errors.js'; -import { parseKind, KindError } from '../kinds.js'; -import { is, type El } from '../model.js'; -import { ChangeSet } from '../result.js'; -import { anchorContext, keyRequest, labelOf } from '../idstyle.js'; -import { BRANCH_FIELDS, NODE_FIELDS } from '../batch.js'; -import { withSuffix } from '../ids.js'; +import type { Doc } from '../model/document.js'; +import { modelError, usageError, type CliError } from '../shared/errors.js'; +import { parseKind, KindError } from '../model/kinds.js'; +import { is, type El } from '../model/moddle.js'; +import { ChangeSet } from '../model/change-set.js'; +import { anchorContext, keyRequest, labelOf } from '../ids/style.js'; +import { BRANCH_FIELDS, NODE_FIELDS } from './batch.js'; +import { withSuffix } from '../ids/slugs.js'; import { addElement } from './add.js'; import { connectElements } from './connect.js'; import { laneOf } from './containers.js'; diff --git a/src/ops/types.ts b/src/ops/types.ts index 999d0052..5b7e4608 100644 --- a/src/ops/types.ts +++ b/src/ops/types.ts @@ -192,7 +192,7 @@ export interface SplitOp { } /* ------------------------------------------------------------------ */ -/* format operations: diagram only, see src/diagram/ops.ts */ +/* format operations: diagram only, see src/format/index.ts */ /* ------------------------------------------------------------------ */ export type SideName = 'left' | 'right' | 'top' | 'bottom'; @@ -200,7 +200,7 @@ export type LabelSideName = 'above' | 'below' | 'left' | 'right'; export type ColorName = 'blue' | 'orange' | 'green' | 'red' | 'purple' | 'default'; /** - * Selectors of place / align / color / tidy (src/diagram/select.ts): they add + * Selectors of place / align / color / tidy (src/query/select.ts): they add * elements to `ids` (connections only for color). */ export interface Selectors { diff --git a/src/pipeline.ts b/src/pipeline/index.ts similarity index 94% rename from src/pipeline.ts rename to src/pipeline/index.ts index 7e1eeeb8..71694376 100644 --- a/src/pipeline.ts +++ b/src/pipeline/index.ts @@ -8,12 +8,12 @@ * file (`unchanged`; the node layer skips that write). * * Output text (outputText): incoming / outgoing entries are written the way - * the file keeps them (mirror.ts; in memory they are complete), and for a + * the file keeps them (model/mirror.ts; in memory they are complete), and for a * document read from XML every element the ops did not change keeps its - * original text (preserve.ts: prolog, comments, CDATA, attribute order, + * original text (xml/preserve.ts: prolog, comments, CDATA, attribute order, * namespace declarations, indentation); changed and new elements follow the * file's style. A write is UTF-8: a changed result whose XML declaration - * names another encoding declares UTF-8 (src/encoding.ts, with a note). Comments the result cannot keep, and a fall-back to + * names another encoding declares UTF-8 (src/xml/encoding.ts, with a note). Comments the result cannot keep, and a fall-back to * bpmn-moddle's plain serialisation, are reported as notes. A result equal * to the input text is `unchanged: true`; the node layer does not write it * back over its file (`written: false`; `--out` to another file still writes @@ -43,7 +43,7 @@ * removed as `resolved`, and the totals (`bpmn validate` lists them all). * An op warning that the added findings repeat item by item is dropped * (retype's W_PROPERTY_INAPPLICABLE, ops/retype.ts withoutProfileDuplicates). - * - validators (src/validators.ts, MutationOptions.validators): each runs + * - validators (src/validate/validators.ts, MutationOptions.validators): each runs * on the document before the ops and on the candidate XML after the * layout, the format ops and the text-preserving step, i.e. on exactly * what would be written. Errors the change introduced block the write @@ -55,16 +55,16 @@ * introduced among the warnings and never blocks; for a created document * (`new`) it reports everything it finds in the new model. * - * Declared id conventions (MutationOptions.conventions, src/conventions.ts: + * Declared id conventions (MutationOptions.conventions, src/ids/conventions.ts: * element-id-naming of the project's .bpmnlintrc, which the node layer reads) * are the document's for the call: the ids the ops and a full redraw - * generate follow them where they declare a prefix (src/idstyle.ts); the + * generate follow them where they declare a prefix (src/ids/style.ts); the * result names those that differ from the file's own style * (`conventions`). Without them nothing changes. * * Layout modes (MutationOptions.layout): * - false: skip; the DI of removed elements is pruned, new elements have none, - * and a flow whose ends changed loses its edge (diagram/incremental.ts + * and a flow whose ends changed loses its edge (layout/incremental.ts * pruneReEnded; kept when it already reaches its new ends, and on the * root's first diagram while a new end has no shape: the next write places * that end and routes the flow); a note counts what was removed @@ -81,7 +81,7 @@ * layout note says so * - 'incremental': keep every existing shape and connection, place what is * new, prune what is gone, reroute only affected connections - * (src/diagram/incremental.ts); a file without any diagram is drawn in full + * (src/layout/incremental.ts); a file without any diagram is drawn in full * - 'auto' (default, also `true`): full when the layout root had no flow node * DI before the ops, or when the drawing is engine-owned (re-running the * clean engine on the model as it was before the ops reproduces every @@ -94,7 +94,7 @@ * (src/diagram/metrics.ts) with the problems added and resolved. * * Format ops (place, align, color, label, route, space, tidy, and the lane - * part of `order`; src/diagram/ops.ts) run after the layout, on its result, + * part of `order`; src/format/index.ts) run after the layout, on its result, * in batch order; a failing one fails the whole batch. A batch of format ops * only keeps the drawing (no layout runs) unless `full` is requested or the * file has no diagram yet; with --no-layout they run on the existing DI. @@ -110,35 +110,35 @@ * write that moves no node leaves them untouched. `layout.stickies` lists * the stickies that moved. */ -import type { IdConventions } from './conventions.js'; -import { withLayoutDebug, type DebugSink } from './debug.js'; -import { utf8Declaration } from './encoding.js'; -import { Doc } from './document.js'; -import { CliError, ioError, modelError, usageError, type Warning } from './errors.js'; -import { layoutModel, SUB_PROCESS_TYPES, type LayoutWarningInfo, type LayoutEngine } from './layout.js'; -import type { GivenId } from './diagram/drawn-ids.js'; -import { diagramGeometry, engineOwned, layoutIncremental, pruneReEnded, takeSnapshot, type IncrementalReport, type Snapshot } from './diagram/incremental.js'; -import { layoutProblems, metricsDelta, type LayoutMetrics, type MetricsDelta } from './diagram/metrics.js'; -import { runFormatOps, type FormatEntry, type FormatResult } from './diagram/ops.js'; -import { followStickies, stickyAnchors, type ResolvedAnchor, type StickyAnchor } from './diagram/stickies.js'; -import { applyColors, colorsOf, diIds } from './diagram/write.js'; -import { kindLabel } from './kinds.js'; -import { serializeWithout, unkeptEntries, withoutEntries } from './mirror.js'; -import { addTo, is, layoutRoot, many, ModelError, parseXml, serialize, type El } from './model.js'; -import { collapsedIds } from './ops/add.js'; -import { reportedImportWarnings } from './ops/decision.js'; -import { runBatch, runOps } from './ops/index.js'; -import { ordersLanes, ordersPools } from './ops/order.js'; -import { takeDroppedContent, withoutProfileDuplicates, type DroppedContent } from './ops/retype.js'; -import { requestedExpansion } from './ops/set.js'; -import { isFormatOp, type Op } from './ops/types.js'; -import { ChangeSet } from './result.js'; -import { resolvePlatform } from './platform/detect.js'; -import { ensureProfile, profileBaseline, runProfile, type PlatformChoice, type ProfileBaseline, type ProfileFinding, type ProfileReport } from './platform/profile.js'; -import { plainText, preserveText } from './preserve.js'; -import { lintCoveredBy, validateDoc, withProfileChanges, type ValidationResult } from './validate.js'; -import { checkReports, compareRuns, namedValidators, once, renamesOf, runValidators, validatorRefusal, withValidatorReports, type Validator, type ValidatorContext, type ValidatorRun } from './validators.js'; -import { buildView, type ModelView } from './view.js'; +import type { IdConventions } from '../ids/conventions.js'; +import { withLayoutDebug, type DebugSink } from '../shared/debug.js'; +import { utf8Declaration } from '../xml/encoding.js'; +import { Doc } from '../model/document.js'; +import { CliError, ioError, modelError, usageError, type Warning } from '../shared/errors.js'; +import { layoutModel, SUB_PROCESS_TYPES, type LayoutWarningInfo, type LayoutEngine } from '../layout/index.js'; +import type { GivenId } from '../diagram/drawn-ids.js'; +import { diagramGeometry, engineOwned, layoutIncremental, pruneReEnded, takeSnapshot, type IncrementalReport, type Snapshot } from '../layout/incremental.js'; +import { layoutProblems, metricsDelta, type LayoutMetrics, type MetricsDelta } from '../diagram/metrics.js'; +import { runFormatOps, type FormatEntry, type FormatResult } from '../format/index.js'; +import { followStickies, stickyAnchors, type ResolvedAnchor, type StickyAnchor } from '../diagram/stickies.js'; +import { applyColors, colorsOf, diIds } from '../diagram/write.js'; +import { kindLabel } from '../model/kinds.js'; +import { serializeWithout, unkeptEntries, withoutEntries } from '../model/mirror.js'; +import { addTo, is, layoutRoot, many, ModelError, parseXml, serialize, type El } from '../model/moddle.js'; +import { collapsedIds } from '../ops/add.js'; +import { reportedImportWarnings } from '../ops/decision.js'; +import { runBatch, runOps } from '../ops/index.js'; +import { ordersLanes, ordersPools } from '../ops/order.js'; +import { takeDroppedContent, withoutProfileDuplicates, type DroppedContent } from '../ops/retype.js'; +import { requestedExpansion } from '../ops/set.js'; +import { isFormatOp, type Op } from '../ops/types.js'; +import { ChangeSet } from '../model/change-set.js'; +import { resolvePlatform } from '../platform/detect.js'; +import { ensureProfile, profileBaseline, runProfile, type PlatformChoice, type ProfileBaseline, type ProfileFinding, type ProfileReport } from '../platform/profiles/profile.js'; +import { plainText, preserveText } from '../xml/preserve.js'; +import { lintCoveredBy, validateDoc, withProfileChanges, type ValidationResult } from '../validate/structural.js'; +import { checkReports, compareRuns, namedValidators, once, renamesOf, runValidators, validatorRefusal, withValidatorReports, type Validator, type ValidatorContext, type ValidatorRun } from '../validate/validators.js'; +import { buildView, type ModelView } from '../query/model-view.js'; /** * Options of the in-memory pipeline. Writing (out, dryRun, backup, @@ -161,9 +161,9 @@ export interface MutationOptions { engine?: LayoutEngine; /** platform profile whose new findings are reported: 'auto' (default) detects it, 'none' switches it off */ platform?: PlatformChoice; - /** receives the layout engines' diagnostic lines during this call (src/debug.ts; the CLI: BPMN_LAYOUT_DEBUG) */ + /** receives the layout engines' diagnostic lines during this call (src/shared/debug.ts; the CLI: BPMN_LAYOUT_DEBUG) */ debug?: DebugSink; - /** validators run on the candidate XML inside the transaction (src/validators.ts); errors they find in the change block the write */ + /** validators run on the candidate XML inside the transaction (src/validate/validators.ts); errors they find in the change block the write */ validators?: Validator[]; /** the file being written, for the validators (`ctx.file`); default doc.file (the node layer passes its target) */ file?: string; @@ -176,7 +176,7 @@ export interface MutationOptions { */ keepFlowIds?: boolean; /** - * the project's declared id conventions (src/conventions.ts: the + * the project's declared id conventions (src/ids/conventions.ts: the * prefixes, case and qualifier of element-id-naming; the node layer reads * them from the .bpmnlintrc it runs): ids the change generates follow * them where they declare a prefix, the file's own style elsewhere; @@ -397,7 +397,7 @@ function takeMatch(pool: T[], match: (item: T) => boolean): boolean { export function validationDelta(doc: Doc, baseline: ErrorBaseline, raw: ValidationResult, final: ValidationResult, profile?: ProfileReport, validatorCovered: ReadonlySet = new Set()): ValidationDelta { const before = baseline.warnings ?? []; const remaining = [...raw.warnings]; - // a lint warning the platform's resolved finding says again is reported once, as the platform finding (validate.ts withProfile) + // a lint warning the platform's resolved finding says again is reported once, as the platform finding (validate/structural.ts withProfile) const platformResolved = final.platform?.resolved ?? []; const coveredByPlatform = lintCoveredBy(platformResolved); const covered = (w: Warning): boolean => coveredByPlatform(w) || validatorCovered.has(`${w.code}|${w.element ?? ''}`); @@ -588,8 +588,8 @@ async function captureBefore(doc: Doc, mode: LayoutMode | 'skip', formatOnly: bo /** * The text a mutation writes. The mirror entries the file does not keep are - * left out (mirror.ts). For a document read from a file, the parts the ops - * did not change keep their original text (preserve.ts; `baseline` is the + * left out (model/mirror.ts). For a document read from a file, the parts the ops + * did not change keep their original text (xml/preserve.ts; `baseline` is the * serialisation of the document as read); comments that could not be kept * and a fall-back to the plain serialisation are reported as notes. */ @@ -607,7 +607,7 @@ async function outputText(doc: Doc, xml: string, baseline: string | undefined, c changes.note(`${text.droppedComments} XML comment(s) dropped: they were inside or next to elements the change removed or rewrote`); } if (text.xml === source.text) return text.xml; - // a write is UTF-8 (src/encoding.ts): the kept declaration must say so + // a write is UTF-8 (src/xml/encoding.ts): the kept declaration must say so const declared = utf8Declaration(text.xml); if (declared.was !== undefined) changes.note(`the XML declaration named the encoding ${declared.was}; the text is written as UTF-8, so it now says UTF-8`); return declared.text; @@ -975,7 +975,7 @@ export async function layoutDoc(doc: Doc, opts: LayoutDocOptions = {}): Promise< export interface CheckOptions { /** platform profile: 'auto' (default) detects it */ platform?: PlatformChoice; - /** validators (src/validators.ts), run on the document's XML; their errors fail the check (an advisory one's too) */ + /** validators (src/validate/validators.ts), run on the document's XML; their errors fail the check (an advisory one's too) */ validators?: Validator[]; /** the file being checked, for the validators (default doc.file) */ file?: string; diff --git a/src/ops/platform.ts b/src/platform/defaults.ts similarity index 91% rename from src/ops/platform.ts rename to src/platform/defaults.ts index 68000d21..76ecec95 100644 --- a/src/ops/platform.ts +++ b/src/platform/defaults.ts @@ -14,10 +14,10 @@ * Camunda 7 defaults (camunda:historyTimeToLive of a new process) are * Doc.initProcess. */ -import type { Doc } from '../document.js'; -import { labelOf, speakingStem, typeRequest } from '../idstyle.js'; -import { addTo, is, many, type El } from '../model.js'; -import { ZEEBE_URI } from '../platform/descriptor.js'; +import type { Doc } from '../model/document.js'; +import { labelOf, speakingStem, typeRequest } from '../ids/style.js'; +import { addTo, is, many, type El } from '../model/moddle.js'; +import { ZEEBE_URI } from './descriptor.js'; /** Adds `` to a user task of a Camunda 8 file that has none; true when it did. */ export function zeebeUserTaskDefault(doc: Doc, el: El): boolean { diff --git a/src/platform/descriptor.ts b/src/platform/descriptor.ts index e1cd4f41..31a1eb0a 100644 --- a/src/platform/descriptor.ts +++ b/src/platform/descriptor.ts @@ -44,7 +44,7 @@ * Two placement lists of the descriptor are corrected to what the engines * accept (ALLOWED_IN_OVERRIDES): camunda:executionListener and camunda:potentialStarter. */ -import { createModdle, type El } from '../model.js'; +import { createModdle, type El } from '../model/moddle.js'; import { CAMUNDA_DESCRIPTOR } from './camunda-descriptor.js'; import { detectPlatformOf } from './detect.js'; diff --git a/src/platform/detect.ts b/src/platform/detect.ts index 5fabe903..87423d33 100644 --- a/src/platform/detect.ts +++ b/src/platform/detect.ts @@ -20,10 +20,10 @@ * camunda as the fallback), which Camunda 7 and CIB seven ignore. A file that * uses the operaton namespace therefore targets Operaton: `operaton` says so * (and the detail line), and the profile reads its content the way Operaton - * does (platform/c7.ts). + * does (platform/profiles/c7.ts). */ -import { KNOWN_NAMESPACES, type Doc } from '../document.js'; -import { isBpmnElement, walk, type El } from '../model.js'; +import { KNOWN_NAMESPACES, type Doc } from '../model/document.js'; +import { isBpmnElement, walk, type El } from '../model/moddle.js'; import { CAMUNDA_URI, C7_URIS, OPERATON_URI, ZEEBE_URI } from './descriptor.js'; export { C7_URIS, OPERATON_URI } from './descriptor.js'; diff --git a/src/platform/finding.ts b/src/platform/finding.ts index e3abd15d..da61ead2 100644 --- a/src/platform/finding.ts +++ b/src/platform/finding.ts @@ -1,5 +1,5 @@ /** - * A finding of a platform validation profile (src/platform/profile.ts): a + * A finding of a platform validation profile (src/platform/profiles/profile.ts): a * Warning with a severity, so an agent can tell what a deployment will * refuse from what only misbehaves at run time. * @@ -13,7 +13,7 @@ * findings it introduced from those the file already had (profileDelta) * without the subject showing up in JSON output. */ -import type { Warning } from '../errors.js'; +import type { Warning } from '../shared/errors.js'; export type Severity = 'deploy' | 'runtime' | 'practice'; diff --git a/src/platform/c7.ts b/src/platform/profiles/c7.ts similarity index 99% rename from src/platform/c7.ts rename to src/platform/profiles/c7.ts index 28418317..f03510ea 100644 --- a/src/platform/c7.ts +++ b/src/platform/profiles/c7.ts @@ -10,7 +10,7 @@ * * Operaton's own namespace (operaton:*) holds the same types. Only Operaton * reads it, first, with camunda:* as the fallback; Camunda 7 and CIB seven - * ignore it. A file that uses it targets Operaton (detect.ts `operaton`) and + * ignore it. A file that uses it targets Operaton (platform/detect.ts `operaton`) and * is read that way: an operaton attribute wins over the camunda one, and one * operaton:inputOutput next to one camunda:inputOutput is no duplicate. * @@ -75,7 +75,7 @@ * without an engine) is converted to camunda:decisionRef by * `set calledDecision=` * W_C7_DEPLOY_BOUNDARY_HOST boundary event attached to a compensation handler (isForCompensation="true"); - * validate.ts withProfile drops it next to the structural E_INVALID_HOST + * validate/structural.ts withProfile drops it next to the structural E_INVALID_HOST * W_C7_DEPLOY_SCRIPT script task without script and without camunda:resource * W_C7_DEPLOY_EXCLUSIVE_GATEWAY exclusive gateway without outgoing flow, a single conditional flow, a conditional * default flow, or flows without condition next to a default (or more than one) @@ -114,16 +114,16 @@ * with its own selector and adding it again, never with `--replace`, which * would delete its siblings (extHint). */ -import type { Doc } from '../document.js'; -import type { El } from '../model.js'; -import type { CamundaElementType } from './descriptor.js'; -import type { ProfileFinding, Severity } from './finding.js'; +import type { Doc } from '../../model/document.js'; +import type { El } from '../../model/moddle.js'; +import type { CamundaElementType } from '../descriptor.js'; +import type { ProfileFinding, Severity } from '../finding.js'; import type { RuleKit } from './rule-kit.js'; -/* What the rules use of the core: handed over by the loader (useKit), never imported (platform/rule-kit.ts). */ +/* What the rules use of the core: handed over by the loader (useKit), never imported (platform/profiles/rule-kit.ts). */ let { kindLabel, createModdle, is, isBpmnElement, isDiElement, walk, camundaAttr, camundaAttrs, camundaType, containersOf, idReferenceAttrs, isC7Uri, ZEEBE_URI, CAMUNDA_URI, OPERATON_URI, namespaceMap, namespaceUsage, uriOfElement, uriOfName, decisionLinkOf, makeFinding } = {} as RuleKit; -/** Binds the core helpers the rules use (platform/profile.ts, right after the import). */ +/** Binds the core helpers the rules use (platform/profiles/profile.ts, right after the import). */ export function useKit(kit: RuleKit): void { ({ kindLabel, createModdle, is, isBpmnElement, isDiElement, walk, camundaAttr, camundaAttrs, camundaType, containersOf, idReferenceAttrs, isC7Uri, ZEEBE_URI, CAMUNDA_URI, OPERATON_URI, namespaceMap, namespaceUsage, uriOfElement, uriOfName, decisionLinkOf, makeFinding } = kit); } diff --git a/src/platform/c8.ts b/src/platform/profiles/c8.ts similarity index 99% rename from src/platform/c8.ts rename to src/platform/profiles/c8.ts index a6e27c5d..d0efb88d 100644 --- a/src/platform/c8.ts +++ b/src/platform/profiles/c8.ts @@ -33,7 +33,7 @@ * W_C8_DEPLOY_EXPRESSION a static value where Camunda 8 requires a FEEL expression (=...): conditions of * sequence flows and conditional events, zeebe:script expression, multi-instance * inputCollection / outputElement, correlation keys, an ad-hoc sub-process's - * completion condition; a FEEL syntax error (platform/feel.ts) in a value Camunda 8 + * completion condition; a FEEL syntax error (platform/profiles/feel.ts) in a value Camunda 8 * parses at deploy (FEEL_ATTRS, conditions, message / signal names starting with =) * W_C8_DEPLOY_MESSAGE message event / receive task without message, message without name, a catching * message (not a process start) without exactly one zeebe:subscription with a @@ -72,11 +72,11 @@ * listeners on start and boundary events, end listeners on gateways, listeners on * sequence flows * W_C8_DEPLOY_UNSUPPORTED a transaction, a cancel event (complex gateways are E_UNSUPPORTED_KIND) - * W_C8_DEPLOY_BOUNDARY_HOST boundary event on a compensation handler (validate.ts withProfile drops it next to + * W_C8_DEPLOY_BOUNDARY_HOST boundary event on a compensation handler (validate/structural.ts withProfile drops it next to * the structural E_INVALID_HOST) * W_C8_DEPLOY_SCHEMA an attribute without prefix that the BPMN schema does not define (anywhere in the * file), extension elements on bpmn:definitions, an id that is no NCName; from the - * file's text (platform/schema-text.ts): child elements out of the schema's order, + * file's text (platform/profiles/schema-text.ts): child elements out of the schema's order, * IDREFs that name no id, ids bpmn-moddle could not read * severity runtime (it deploys, but the setting is ignored or fails when the process runs): * W_C8_FOREIGN_CONTENT camunda:* / operaton:* attributes or elements (Camunda 7 content) in a Camunda 8 file @@ -103,17 +103,17 @@ * of white space deploys (only an empty one is refused); FEEL, path and enum * attributes, form ids and correlation keys of white space are refused. */ -import type { Doc } from '../document.js'; -import type { El } from '../model.js'; +import type { Doc } from '../../model/document.js'; +import type { El } from '../../model/moddle.js'; import { feelSyntaxError } from './feel.js'; -import type { ProfileFinding, Severity } from './finding.js'; +import type { ProfileFinding, Severity } from '../finding.js'; import type { RuleKit } from './rule-kit.js'; import { NCNAME, schemaTextIssues, useKit as useSchemaTextKit, type SchemaTextIssue } from './schema-text.js'; -/* What the rules use of the core: handed over by the loader (useKit), never imported (platform/rule-kit.ts). */ +/* What the rules use of the core: handed over by the loader (useKit), never imported (platform/profiles/rule-kit.ts). */ let { kindLabel, is, isBpmnElement, isDiElement, walk, unkeptEntries, decisionLinkOf, C7_URIS, ZEEBE_URI, namespaceMap, uriOfElement, uriOfName, makeFinding, zeebeAllowedOn, zeebeAttr, zeebeAttrs, zeebeContainersOf, zeebeNestedOnly, zeebeType, zeebeTypeNames } = {} as RuleKit; -/** Binds the core helpers the rules use, also those of schema-text.ts (platform/profile.ts, right after the import). */ +/** Binds the core helpers the rules use, also those of schema-text.ts (platform/profiles/profile.ts, right after the import). */ export function useKit(kit: RuleKit): void { ({ kindLabel, is, isBpmnElement, isDiElement, walk, unkeptEntries, decisionLinkOf, C7_URIS, ZEEBE_URI, namespaceMap, uriOfElement, uriOfName, makeFinding, zeebeAllowedOn, zeebeAttr, zeebeAttrs, zeebeContainersOf, zeebeNestedOnly, zeebeType, zeebeTypeNames } = kit); useSchemaTextKit(kit); @@ -127,7 +127,7 @@ interface Ctx { out: ProfileFinding[]; /** sequence flows by source, from sourceRef (the outgoing mirror lists are optional) */ outgoing: Map; - /** flows whose source does not list them as written (mirror.ts unkeptEntries): flow -> source */ + /** flows whose source does not list them as written (model/mirror.ts unkeptEntries): flow -> source */ unlisted: Map; } @@ -381,7 +381,7 @@ export function dateTimeRangeProblem(value: string): string | undefined { /** * Why Camunda 8 refuses a FEEL expression at deploy (the text after the `=`), * or undefined. The JUEL habits first, with their FEEL spelling (&&, ||, ==, - * !, ${...}, single quotes), then the syntax check of platform/feel.ts (the + * !, ${...}, single quotes), then the syntax check of platform/profiles/feel.ts (the * grammar Camunda 8.9 parses, engine-checked; every valid probe passes). */ export function feelProblem(expression: string): string | undefined { @@ -1038,7 +1038,7 @@ function checkBranchingGateway(ctx: Ctx, gw: El): void { function checkEventGateway(ctx: Ctx, gw: El): void { const id = idOf(gw)!; const flows = ctx.outgoing.get(gw) ?? []; - // the engine counts the entries of the gateway, which a file may leave out (mirror.ts writes them the file's way) + // the engine counts the entries of the gateway, which a file may leave out (model/mirror.ts writes them the file's way) const listed = flows.filter((f) => !ctx.unlisted.has(f) || ctx.unlisted.get(f) !== gw); if (flows.length < 2) { push(ctx, 'deploy', 'W_C8_DEPLOY_EVENT_GATEWAY', gw, undefined, 'branches', `Event-based gateway ${id} has ${flows.length} outgoing flow${flows.length === 1 ? '' : 's'}; Camunda 8 needs at least two and refuses the file`, `Add a branch: \`bpmn add intermediateCatchEvent:timer "" --after ${id} --timer PT1H\`.`); @@ -1477,7 +1477,7 @@ const TEXT_ISSUES = new WeakMap(); /** * Child element order and IDREFs that name no id, read from the file's text - * (platform/schema-text.ts): the model shows neither, Camunda 8 refuses both. + * (platform/profiles/schema-text.ts): the model shows neither, Camunda 8 refuses both. * After an edit an issue of an element the edit removed is gone. */ function checkSchemaText(ctx: Ctx): void { diff --git a/src/platform/feel.ts b/src/platform/profiles/feel.ts similarity index 100% rename from src/platform/feel.ts rename to src/platform/profiles/feel.ts diff --git a/src/platform/profile.ts b/src/platform/profiles/profile.ts similarity index 92% rename from src/platform/profile.ts rename to src/platform/profiles/profile.ts index a7108a65..03f3b71d 100644 --- a/src/platform/profile.ts +++ b/src/platform/profiles/profile.ts @@ -1,11 +1,11 @@ /** * Platform validation profiles: engine-specific checks on top of the - * structural validation and lint of src/validate.ts. + * structural validation and lint of src/validate/structural.ts. * * - runProfile(doc, choice) detects the platform (platform/detect.ts; an - * explicit choice wins) and runs its rules: Camunda 7 (platform/c7.ts; + * explicit choice wins) and runs its rules: Camunda 7 (platform/profiles/c7.ts; * a file that uses the operaton namespace is read the way Operaton reads - * it, `operaton: true`), Camunda 8 (platform/c8.ts); plain BPMN has no + * it, `operaton: true`), Camunda 8 (platform/profiles/c8.ts); plain BPMN has no * engine rules. * - The rules of a platform are loaded on demand (loadProfile: one * `import()` per platform, cached), so a host's bundler puts each rule @@ -17,7 +17,7 @@ * chunk that fails to load rejects with E_PROFILE_LOAD (category io). * Only this module imports c7.ts / c8.ts (tools/iso/check.mjs fails when * a rule module is in a browser bundle's initial chunks), and they import - * nothing of the core: it hands them RULE_KIT (platform/rule-kit.ts), so + * nothing of the core: it hands them RULE_KIT (platform/profiles/rule-kit.ts), so * a host whose entry module awaits a call at top level does not wait for * itself (Rollup / Vite would make a rule chunk import the entry chunk). * - `bpmn validate` reports every finding as a warning (`--strict` exits 5) @@ -30,16 +30,16 @@ * Findings are matched by code, element (by identity, so a renamed element * keeps its findings) and subject (e.g. the attribute name). */ -import type { Doc } from '../document.js'; -import { CliError, ioError, usageError } from '../errors.js'; -import type { El } from '../model.js'; -import { resolvePlatform, type Platform, type PlatformChoice, type PlatformInfo } from './detect.js'; -import { SEVERITIES, subjectOf, type ProfileFinding, type Severity } from './finding.js'; +import type { Doc } from '../../model/document.js'; +import { CliError, ioError, usageError } from '../../shared/errors.js'; +import type { El } from '../../model/moddle.js'; +import { resolvePlatform, type Platform, type PlatformChoice, type PlatformInfo } from '../detect.js'; +import { SEVERITIES, subjectOf, type ProfileFinding, type Severity } from '../finding.js'; import { RULE_KIT } from './rule-kit.js'; -export type { Platform, PlatformChoice, PlatformInfo } from './detect.js'; -export { PLATFORM_CHOICES } from './detect.js'; -export type { ProfileFinding, Severity } from './finding.js'; +export type { Platform, PlatformChoice, PlatformInfo } from '../detect.js'; +export { PLATFORM_CHOICES } from '../detect.js'; +export type { ProfileFinding, Severity } from '../finding.js'; export interface ProfileReport extends PlatformInfo { findings: ProfileFinding[]; @@ -65,7 +65,7 @@ const ENGINE_NAMES: Record = { c7: 'Camunda 7', c8: 'Cam * The engine rules of each platform, loaded the first time a document of * that platform is validated: a bundler makes each `import()` a chunk of its * own (an IIFE bundle inlines it). The rules get what they use of the core - * from here (RULE_KIT, platform/rule-kit.ts) instead of importing it, so + * from here (RULE_KIT, platform/profiles/rule-kit.ts) instead of importing it, so * their chunk imports nothing, also not the host's entry chunk. */ const LOADERS: Record Promise> = { diff --git a/src/platform/rule-kit.ts b/src/platform/profiles/rule-kit.ts similarity index 79% rename from src/platform/rule-kit.ts rename to src/platform/profiles/rule-kit.ts index 6ecd4592..d9de0af0 100644 --- a/src/platform/rule-kit.ts +++ b/src/platform/profiles/rule-kit.ts @@ -1,7 +1,7 @@ /** - * What the engine rules that load on demand (platform/c7.ts, c8.ts and + * What the engine rules that load on demand (platform/profiles/c7.ts, c8.ts and * schema-text.ts, which comes with c8.ts) use of the core: the loader - * (platform/profile.ts) hands them RULE_KIT right after the import + * (platform/profiles/profile.ts) hands them RULE_KIT right after the import * (`useKit`), they import nothing of the core themselves (type imports * only). * @@ -21,15 +21,15 @@ * test/isomorphic.test.ts fail when a rule module imports a module the * core entry loads, naming both. */ -import { kindLabel } from '../kinds.js'; -import { unkeptEntries } from '../mirror.js'; -import { BPMN_NS, createModdle, is, isBpmnElement, isDiElement, walk } from '../model.js'; -import { decisionLinkOf } from '../ops/decision.js'; -import { decodeXml, elementChildren, readXmlText, XmlTextError } from '../xmltext.js'; -import { C7_URIS, CAMUNDA_URI, camundaAttr, camundaAttrs, camundaType, containersOf, idReferenceAttrs, isC7Uri, OPERATON_URI, ZEEBE_URI } from './descriptor.js'; -import { namespaceMap, namespaceUsage, uriOfElement, uriOfName } from './detect.js'; -import { makeFinding } from './finding.js'; -import { zeebeAllowedOn, zeebeAttr, zeebeAttrs, zeebeContainersOf, zeebeNestedOnly, zeebeType, zeebeTypeNames } from './zeebe.js'; +import { kindLabel } from '../../model/kinds.js'; +import { unkeptEntries } from '../../model/mirror.js'; +import { BPMN_NS, createModdle, is, isBpmnElement, isDiElement, walk } from '../../model/moddle.js'; +import { decisionLinkOf } from '../../ops/decision.js'; +import { decodeXml, elementChildren, readXmlText, XmlTextError } from '../../xml/text-reader.js'; +import { C7_URIS, CAMUNDA_URI, camundaAttr, camundaAttrs, camundaType, containersOf, idReferenceAttrs, isC7Uri, OPERATON_URI, ZEEBE_URI } from '../descriptor.js'; +import { namespaceMap, namespaceUsage, uriOfElement, uriOfName } from '../detect.js'; +import { makeFinding } from '../finding.js'; +import { zeebeAllowedOn, zeebeAttr, zeebeAttrs, zeebeContainersOf, zeebeNestedOnly, zeebeType, zeebeTypeNames } from '../zeebe.js'; export const RULE_KIT = { // model, kinds, findings diff --git a/src/platform/schema-text.ts b/src/platform/profiles/schema-text.ts similarity index 98% rename from src/platform/schema-text.ts rename to src/platform/profiles/schema-text.ts index 245d34c4..85d4bb05 100644 --- a/src/platform/schema-text.ts +++ b/src/platform/profiles/schema-text.ts @@ -15,10 +15,10 @@ * targetRef is left to the structural check (E_DANGLING_REF). */ import type { BpmnModdle } from 'bpmn-moddle'; -import type { XElement } from '../xmltext.js'; +import type { XElement } from '../../xml/text-reader.js'; import type { RuleKit } from './rule-kit.js'; -/* What the check uses of the core: handed over by the loader through c8.ts (useKit), never imported (platform/rule-kit.ts). */ +/* What the check uses of the core: handed over by the loader through c8.ts (useKit), never imported (platform/profiles/rule-kit.ts). */ let { BPMN_NS, decodeXml, elementChildren, readXmlText, XmlTextError } = {} as RuleKit; /** Binds the core helpers the check uses (c8.ts useKit). */ diff --git a/src/platform/zeebe.ts b/src/platform/zeebe.ts index 16f847ad..af140613 100644 --- a/src/platform/zeebe.ts +++ b/src/platform/zeebe.ts @@ -1,7 +1,7 @@ /** * Read-only lookup over the Camunda 8 (Zeebe) descriptor (`zeebe-bpmn-moddle`, * resources/zeebe.json, inlined as zeebe-descriptor.ts), used for validation - * (platform/c8.ts) and for placing zeebe extension elements (ops/ext.ts). + * (platform/profiles/c8.ts) and for placing zeebe extension elements (ops/ext.ts). * * Like the Camunda 7 descriptor (platform/descriptor.ts) it is DATA: it is * never registered with a BpmnModdle instance, so zeebe content stays generic @@ -32,9 +32,9 @@ * - zeebe:properties has no allowedIn: it may sit anywhere. * - zeebe:publishMessage is not in the descriptor; Camunda 8.9 accepts it on a * send task and in a message event definition (it does not execute it yet: - * c8.ts W_C8_UNSUPPORTED_IMPLEMENTATION). + * platform/profiles/c8.ts W_C8_UNSUPPORTED_IMPLEMENTATION). */ -import { is, type El } from '../model.js'; +import { is, type El } from '../model/moddle.js'; import { typeIs } from './descriptor.js'; import { ZEEBE_DESCRIPTOR } from './zeebe-descriptor.js'; diff --git a/src/context.ts b/src/query/context.ts similarity index 98% rename from src/context.ts rename to src/query/context.ts index e6b2af18..d47f94a0 100644 --- a/src/context.ts +++ b/src/query/context.ts @@ -1,7 +1,7 @@ /** * Reading views for agents that work on large models: the neighbourhood of * one element and the context of one element, both in a fraction of the - * bytes of the whole model view (src/view.ts). Ids only: an element is + * bytes of the whole model view (src/query/model-view.ts). Ids only: an element is * addressed by its id, never by its name (names may repeat). * * aroundView(doc, id, { depth, inner }) `show --around [--depth n] [--inner]` @@ -32,14 +32,14 @@ * at the element; a message flow names its ends with their pools and its * message; a message, signal, error or escalation names what uses it. */ -import type { Doc } from './document.js'; -import { usageError } from './errors.js'; -import { kindLabel, triggerOf } from './kinds.js'; -import { diExpansionState } from './layout.js'; -import { is, walk, type El } from './model.js'; -import { laneOf } from './ops/containers.js'; -import { listAllExtensions, type ExtensionInfo } from './ops/ext.js'; -import { flowOrder } from './validate.js'; +import type { Doc } from '../model/document.js'; +import { usageError } from '../shared/errors.js'; +import { kindLabel, triggerOf } from '../model/kinds.js'; +import { diExpansionState } from '../layout/index.js'; +import { is, walk, type El } from '../model/moddle.js'; +import { laneOf } from '../ops/containers.js'; +import { listAllExtensions, type ExtensionInfo } from '../ops/ext.js'; +import { flowOrder } from '../validate/structural.js'; import { annotationsOf, associationsOf, @@ -63,7 +63,7 @@ import { type ViewData, type ViewFlow, type ViewMessageFlow, -} from './view.js'; +} from './model-view.js'; /** Flow steps `show --around` looks at when --depth is not given (like PR #218's `outline --around`). */ export const AROUND_DEFAULT_DEPTH = 2; diff --git a/src/diagram/view.ts b/src/query/layout-view.ts similarity index 95% rename from src/diagram/view.ts rename to src/query/layout-view.ts index 386567f1..6573da5e 100644 --- a/src/diagram/view.ts +++ b/src/query/layout-view.ts @@ -23,21 +23,21 @@ * `compact` can close), `gaps` of a group the places in its rows where * two neighbours are that far apart (index of the node after the gap): * such a row holds unrelated clusters that merely share a y. - * - colors: every coloured shape / edge with its swatch name (write.ts + * - colors: every coloured shape / edge with its swatch name (diagram/write.ts * SWATCHES) or 'custom' plus the raw fill / stroke. * - labels: external labels (events, gateways, data, flows) that are not on - * the default side (labels.ts defaultLabelSide; flows: above), with the + * the default side (diagram/labels.ts defaultLabelSide; flows: above), with the * side they are on. * - metrics: layoutProblems(defs) (counts, score, problems with ids). * Read-only. */ -import { is, type El } from '../model.js'; -import { cx, cy, median, right } from './geom.js'; -import { defaultLabelSide, edgeLabelSideOf, hasExternalLabel, labelSideOf, type LabelSide } from './labels.js'; -import { layoutProblems, type LayoutMetrics } from './metrics.js'; -import { spacingOf } from './place.js'; -import { raw, readPlanes, semantics, type DShape, type Plane } from './plane.js'; -import { swatchOf, type SwatchName } from './write.js'; +import { is, type El } from '../model/moddle.js'; +import { cx, cy, median, right } from '../diagram/geom.js'; +import { defaultLabelSide, edgeLabelSideOf, hasExternalLabel, labelSideOf, type LabelSide } from '../diagram/labels.js'; +import { layoutProblems, type LayoutMetrics } from '../diagram/metrics.js'; +import { spacingOf } from '../diagram/place.js'; +import { raw, readPlanes, semantics, type DShape, type Plane } from '../diagram/plane.js'; +import { swatchOf, type SwatchName } from '../diagram/write.js'; export interface LayoutGroup { /** the frame: plane root, participant, lane or expanded sub-process */ diff --git a/src/view.ts b/src/query/model-view.ts similarity index 98% rename from src/view.ts rename to src/query/model-view.ts index 13d9325a..6f95ddb5 100644 --- a/src/view.ts +++ b/src/query/model-view.ts @@ -14,7 +14,7 @@ * from ops/set.js, listExtensions() from ops/ext.js, flows in/out with * labels/conditions, host, attached boundary events, lane, scope. * Both first add missing incoming/outgoing mirror entries (optional in BPMN - * 2.0, see repairFlowLinks in validate.ts) so flows of hand-written files + * 2.0, see repairFlowLinks in validate/structural.ts) so flows of hand-written files * show up; a file with complete mirrors is left untouched. * - findElements(doc, text, kind?): case-insensitive substring over ids and * names (kind filter by canonical kind), returns ViewNode-like entries; @@ -35,18 +35,18 @@ * attribute names, deduplicated) and `extensionElements` (the extension * element types in document order, repeated ones included). */ -import type { Doc } from './document.js'; -import { usageError, type Warning } from './errors.js'; -import { KindError, kindLabel, kindOf, parseKind, triggerOf, TRIGGER_TYPES } from './kinds.js'; -import { diExpansionState } from './layout.js'; -import { is, localType, walk, type El } from './model.js'; -import { laneOf } from './ops/containers.js'; -import { decisionLinkOf } from './ops/decision.js'; -import { describeTrigger } from './ops/events.js'; -import { listExtensions, type ExtensionInfo } from './ops/ext.js'; -import { definitionsOf, nestedEntries, readProperties, vendorAttributes } from './ops/set.js'; -import { ZEEBE_URI } from './platform/descriptor.js'; -import { flowOrder, repairFlowLinks, validateDoc } from './validate.js'; +import type { Doc } from '../model/document.js'; +import { usageError, type Warning } from '../shared/errors.js'; +import { KindError, kindLabel, kindOf, parseKind, triggerOf, TRIGGER_TYPES } from '../model/kinds.js'; +import { diExpansionState } from '../layout/index.js'; +import { is, localType, walk, type El } from '../model/moddle.js'; +import { laneOf } from '../ops/containers.js'; +import { decisionLinkOf } from '../ops/decision.js'; +import { describeTrigger } from '../ops/events.js'; +import { listExtensions, type ExtensionInfo } from '../ops/ext.js'; +import { definitionsOf, nestedEntries, readProperties, vendorAttributes } from '../ops/set.js'; +import { ZEEBE_URI } from '../platform/descriptor.js'; +import { flowOrder, repairFlowLinks, validateDoc } from '../validate/structural.js'; export interface ViewFlow { id: string; diff --git a/src/diagram/select.ts b/src/query/select.ts similarity index 97% rename from src/diagram/select.ts rename to src/query/select.ts index 6a4c8a9d..b691350e 100644 --- a/src/diagram/select.ts +++ b/src/query/select.ts @@ -31,10 +31,10 @@ * shapes; boundary events too, they follow their host), and elements that are not drawn are left out of what the * selectors found (explicit ids stay, the op reports them). */ -import type { Doc } from '../document.js'; -import { modelError, usageError } from '../errors.js'; -import { is, type El } from '../model.js'; -import { kindFilter } from '../view.js'; +import type { Doc } from '../model/document.js'; +import { modelError, usageError } from '../shared/errors.js'; +import { is, type El } from '../model/moddle.js'; +import { kindFilter } from './model-view.js'; export interface Selection { ids?: string[]; diff --git a/src/diagram/render.ts b/src/render/index.ts similarity index 98% rename from src/diagram/render.ts rename to src/render/index.ts index d0d7c22e..829f6008 100644 --- a/src/diagram/render.ts +++ b/src/render/index.ts @@ -26,10 +26,10 @@ * image-token estimate width * height / 784. * - Crops (at most one of them, E_USAGE otherwise; elements by id only): * around {id, depth, inner} exactly the flow nodes of `show --around` - * (context.ts aroundView; a sequence flow: + * (query/context.ts aroundView; a sequence flow: * both its ends) * path {from, to, via} the nodes and flows of the shortest - * sequence-flow path (select.ts pathOf, the + * sequence-flow path (query/select.ts pathOf, the * --path selector) * scope a pool, lane or expanded sub-process and * every shape whose centre lies inside it; a @@ -64,12 +64,12 @@ * those naming an element drawn in full) in metrics order with the same * ids, a list exactly these problems (matched by problemKey) in its order; * each numbered 1.. in that order. A problem whose location - * (metrics.ts locateProblems) is on this plane and in the image gets a + * (diagram/metrics.ts locateProblems) is on this plane and in the image gets a * numbered badge there (`drawn`); a badge that would cover an earlier one * moves aside within the bounding box of the problem's elements. * - tiles: when the image would draw its labels below MIN_LABEL_SCALE, it is * split into tiles at `scale` (default 1) within maxSize: cut between the - * plane's columns (view.ts planeColumns, `show --layout`'s c) and, + * plane's columns (query/layout-view.ts planeColumns, `show --layout`'s c) and, * when too tall, between rows of shapes. Only tiles holding a shape, a * label (or a frame's name) or a numbered problem are kept: stretches of * half a tile and more with nothing but empty space or connections @@ -113,14 +113,14 @@ * else with a shape is a plain box. * - Labels like bpmn-js 18: external labels (events, gateways, data, flows, * groups) centred on the DI label bounds with their top at its y, in 11 - * px Arial (text.ts wrapLines), 13.2 px a line, laid out twice like + * px Arial (diagram/text.ts wrapLines), 13.2 px a line, laid out twice like * bpmn-js: wrapped at max(90, the label bounds' width), then again at the * width of the widest line of that (rounded up), which may break it * differently; without label bounds (90 px) below the shape (a group: at * its top), a flow's at the middle of its middle segment, 15 px above it * (right of a vertical one). * Embedded labels: 12 px, padding 7, centred in tasks and collapsed - * sub-processes, at the top of expanded ones (their title, text.ts + * sub-processes, at the top of expanded ones (their title, diagram/text.ts * titleBox), left-top in annotations; pool and lane names in their 30 px * header band. * - Off-viewport culling: shapes, connections and labels outside the view @@ -132,18 +132,18 @@ * - Browser-safe and free of side effects at import (tree-shaken out of a * host that does not render). */ -import { aroundView } from '../context.js'; -import { Doc } from '../document.js'; -import { ioError, modelError, usageError } from '../errors.js'; -import { layoutModel } from '../layout.js'; -import { is, type El } from '../model.js'; -import type { MutationReport } from '../report.js'; -import type { Box, Point } from './geom.js'; -import { layoutProblems, locateProblems, problemKey, type LayoutProblem, type MetricKey } from './metrics.js'; -import { homePlane, raw, rawList, readPlanes, semantics, type DEdge, type DShape, type Plane, type Semantics } from './plane.js'; -import { pathOf } from './select.js'; -import { textWidth, titleBox, wrapLines } from './text.js'; -import { planeColumns } from './view.js'; +import { aroundView } from '../query/context.js'; +import { Doc } from '../model/document.js'; +import { ioError, modelError, usageError } from '../shared/errors.js'; +import { layoutModel } from '../layout/index.js'; +import { is, type El } from '../model/moddle.js'; +import type { MutationReport } from '../report/command-report.js'; +import type { Box, Point } from '../diagram/geom.js'; +import { layoutProblems, locateProblems, problemKey, type LayoutProblem, type MetricKey } from '../diagram/metrics.js'; +import { homePlane, raw, rawList, readPlanes, semantics, type DEdge, type DShape, type Plane, type Semantics } from '../diagram/plane.js'; +import { pathOf } from '../query/select.js'; +import { textWidth, titleBox, wrapLines } from '../diagram/text.js'; +import { planeColumns } from '../query/layout-view.js'; /** What a halo marks: the CLI's `--render` colours created, changed and moved elements apart. */ export interface RenderHighlight { @@ -860,7 +860,7 @@ function problemBox(plane: Plane, ids: string[]): Box | undefined { return unionOf(boxes); } -/** The problems listed (see contract), located (metrics.ts locateProblems). */ +/** The problems listed (see contract), located (diagram/metrics.ts locateProblems). */ function problemList(frame: Frame, asked: true | readonly LayoutProblem[]): LayoutProblem[] { const defs = frame.defs; if (!defs || !frame.located) return []; @@ -1261,7 +1261,7 @@ function edgeBox(e: DEdge): Box { return unionOf([box, { x: m.x - 10.5, y: m.y - 7, width: 21, height: 14 }])!; } -/** About where a frame's name is drawn (in a pool's or lane's header band, centred along it; a black-box pool's name; an expanded sub-process's title, text.ts titleBox); undefined without one. */ +/** About where a frame's name is drawn (in a pool's or lane's header band, centred along it; a black-box pool's name; an expanded sub-process's title, diagram/text.ts titleBox); undefined without one. */ function frameNameBox(s: DShape): Box | undefined { const name = s.kind === 'group' ? undefined : raw(s.el, 'name'); if (!name || !name.trim()) return undefined; diff --git a/src/report.ts b/src/report/command-report.ts similarity index 97% rename from src/report.ts rename to src/report/command-report.ts index 5efe54ee..bb41ea4b 100644 --- a/src/report.ts +++ b/src/report/command-report.ts @@ -25,16 +25,16 @@ * too). validate's text folds one of its rules with FLOOD_MIN findings or * more of one hint into one line (`--json` lists every finding). */ -import type { LayoutProblem } from './diagram/metrics.js'; -import type { FormatResult } from './diagram/ops.js'; -import type { Warning } from './errors.js'; -import { formatLine, renderChanges, renderLayout, renderProblems, renderView } from './format.js'; -import type { CheckResult, ConventionsReport, LayoutStatus, MutationResult } from './pipeline.js'; -import type { PlatformSummary } from './platform/profile.js'; -import { ChangeSet, type Change } from './result.js'; -import type { ValidationResult } from './validate.js'; -import type { ValidatorReport } from './validators.js'; -import type { ModelView } from './view.js'; +import type { LayoutProblem } from '../diagram/metrics.js'; +import type { FormatResult } from '../format/index.js'; +import type { Warning } from '../shared/errors.js'; +import { formatLine, renderChanges, renderLayout, renderProblems, renderView } from './view-text.js'; +import type { CheckResult, ConventionsReport, LayoutStatus, MutationResult } from '../pipeline/index.js'; +import type { PlatformSummary } from '../platform/profiles/profile.js'; +import { ChangeSet, type Change } from '../model/change-set.js'; +import type { ValidationResult } from '../validate/structural.js'; +import type { ValidatorReport } from '../validate/validators.js'; +import type { ModelView } from '../query/model-view.js'; /** * The warnings of a mutation as a delta against the file before it: what the @@ -116,7 +116,7 @@ export function mutationWarnings(result: MutationResult): Warning[] { /** * old id -> final id of what the ops renamed of the file's elements (a chain * A -> B -> C as A -> C); absent without renames. A takeover (the id of an - * element the change removed, result.ts Rename.takeover) is no rename: the + * element the change removed, model/change-set.ts Rename.takeover) is no rename: the * old id is listed as removed, the taken one as changed. */ function renamedIds(result: MutationResult): Record | undefined { @@ -288,7 +288,7 @@ function preexistingLine(count: number): string { return `${count} warning${count === 1 ? '' : 's'} already in the file (not repeated: \`bpmn validate \` lists them)`; } -/** `[] ` for a validator's finding (src/validators.ts), else ''. */ +/** `[] ` for a validator's finding (src/validate/validators.ts), else ''. */ export function validatorTag(w: Warning): string { const name = validatorOf(w); return name ? `[${name}] ` : ''; @@ -316,7 +316,7 @@ function leftOutCount(r: ValidatorReport): number { */ function leftOutText(validator: string, g: { reason: string; count: number }): string { const it = g.count === 1 ? 'it' : 'them'; - // 'bpmnlint': BPMNLINT_VALIDATOR, as validatorRefusal names it (report.ts does not import src/bpmnlint.ts) + // 'bpmnlint': BPMNLINT_VALIDATOR, as validatorRefusal names it (command-report.ts does not import src/validate/bpmnlint-validator.ts) return `${g.count} left out (${g.reason}; ${validator === 'bpmnlint' ? `\`bpmn validate \` lists ${it}` : `a check lists ${it}`})`; } diff --git a/src/guide.ts b/src/report/guide.ts similarity index 99% rename from src/guide.ts rename to src/report/guide.ts index 463eccee..30df3a62 100644 --- a/src/guide.ts +++ b/src/report/guide.ts @@ -8,16 +8,16 @@ * the error catalogue, exit codes, trigger options, placement rules and the * command reference are written by hand. */ -import { EXIT_CODES, usageError } from './errors.js'; -import { KINDS, TRIGGER_TYPES, type Family, type KindDef, type Trigger } from './kinds.js'; -import { Doc } from './document.js'; -import { SINGLE_TOP } from './ops/ext.js'; -import { NESTED_SLOTS, NESTED_TYPES, nestedKeysOf, SET_KEYS, type NestedSlot, type SetKeyDoc } from './ops/set.js'; -import { OP_NAMES } from './ops/types.js'; -import { OPS_SCHEMA, OP_DESCRIPTIONS, OP_FIELDS, opsExample } from './batch.js'; -import { SWATCHES } from './diagram/write.js'; -import { LAYOUT_MODES } from './pipeline.js'; -import { zeebeAllowedOn, zeebeContainersOf, zeebeNestedOnly, zeebeType, zeebeTypeNames } from './platform/zeebe.js'; +import { EXIT_CODES, usageError } from '../shared/errors.js'; +import { KINDS, TRIGGER_TYPES, type Family, type KindDef, type Trigger } from '../model/kinds.js'; +import { Doc } from '../model/document.js'; +import { SINGLE_TOP } from '../ops/ext.js'; +import { NESTED_SLOTS, NESTED_TYPES, nestedKeysOf, SET_KEYS, type NestedSlot, type SetKeyDoc } from '../ops/set.js'; +import { OP_NAMES } from '../ops/types.js'; +import { OPS_SCHEMA, OP_DESCRIPTIONS, OP_FIELDS, opsExample } from '../ops/batch.js'; +import { SWATCHES } from '../diagram/write.js'; +import { LAYOUT_MODES } from '../pipeline/index.js'; +import { zeebeAllowedOn, zeebeContainersOf, zeebeNestedOnly, zeebeType, zeebeTypeNames } from '../platform/zeebe.js'; /* ------------------------------------------------------------------ */ /* error catalogue */ @@ -316,7 +316,7 @@ export const PLACEMENT_DOCS: PlacementDoc[] = [ { option: '--to ', key: 'to', rule: 'Additionally connect node -> T (a branch that re-joins the main path).' }, ]; -/** How new ids are made (docs/reference.md "Ids", src/idstyle.ts); `bpmn kinds --json` -> `ids`. */ +/** How new ids are made (docs/reference.md "Ids", src/ids/style.ts); `bpmn kinds --json` -> `ids`. */ export const ID_CONVENTIONS = { rule: 'Elements are addressed by id only (names may repeat). New ids speak (never a hash or a running number) and follow the id style of the file (prefix, case, flow form), and the id conventions the project declares where it declares them (see declared); explicit ids (--id, "id") are taken as given. A rule needs two ids that follow it (one id of a kind in a file whose ids are mostly prefixed).', declared: 'where element-id-naming of the project\'s .bpmnlintrc declares a prefix for a BPMN type, new ids of it take that prefix and the declared case (serviceTask_checkInvoice, flow_checkInvoiceToBookInvoice; required qualifier: timerStartEvent_monthly); under a declared camelCase / PascalCase a taken id gets a glued 2 (serviceTask_checkInvoice2; after a digit No2: serviceTask_step1No2) and a split\'s join is Join (gateway_approvedJoin); the rest follows the file, learned without the ids that already follow the rule; process and definitions ids stay bpmn-cli\'s unless named exactly (a new pool\'s process: the prefix the file\'s process ids share, see prefixes); existing ids never change (W_ID_PREFIX_STALE); `bpmn show --conventions` lists them, `bpmn guide conventions` has the rules', @@ -958,7 +958,7 @@ const CAMUNDA8 = [ ' gateway is never taken, camunda:* content is ignored, ...', ]; -/** BPMNLINT: the project's .bpmnlintrc in validate and every write (src/bpmnlint.ts, src/node/bpmnlint.ts). */ +/** BPMNLINT: the project's .bpmnlintrc in validate and every write (src/validate/bpmnlint-validator.ts, src/node/bpmnlint.ts). */ const BPMNLINT = [ ' A .bpmnlintrc in the model\'s directory or above, up to the repository root (the directory with .git), runs in', ' `bpmn validate` and in every write; --lint-config names another one, --no-lint-config switches it off.', @@ -1001,7 +1001,7 @@ const BPMNLINT = [ ' says what to fix. E_LINT_CONFIG (exit 4): --lint-config names a file that cannot be read or is not strict JSON.', ]; -/** CONVENTIONS: the id conventions element-id-naming of the project's .bpmnlintrc declares (src/conventions.ts, src/idstyle.ts). */ +/** CONVENTIONS: the id conventions element-id-naming of the project's .bpmnlintrc declares (src/ids/conventions.ts, src/ids/style.ts). */ const CONVENTIONS = [ ' A .bpmnlintrc that runs @miragon/rules/element-id-naming (plugin:@miragon/rules/recommended-for-automation and the', ' plugin\'s engine defaults turn it on) declares the prefix of each BPMN type, the case of the body and the', diff --git a/src/format.ts b/src/report/view-text.ts similarity index 98% rename from src/format.ts rename to src/report/view-text.ts index b86585ad..165340ee 100644 --- a/src/format.ts +++ b/src/report/view-text.ts @@ -52,14 +52,14 @@ * with its `lanes:` / `data:` / `annotations:` sections, then `root:` and * `problems:`. */ -import type { AroundNode, AroundView, ContextCatch, ContextLink, ContextMessage, ContextRef, ElementContext, Implementation } from './context.js'; -import { KEYS, type LayoutMetrics, type LayoutProblem } from './diagram/metrics.js'; -import type { FormatResult } from './diagram/ops.js'; -import type { LayoutView } from './diagram/view.js'; -import type { Warning } from './errors.js'; -import type { LayoutStatus } from './pipeline.js'; -import type { Change, ChangeSet } from './result.js'; -import type { DetailMessageFlow, ElementDetail, FindHit, ModelView, ViewAnnotation, ViewFlow, ViewLane, ViewMessageFlow, ViewNode } from './view.js'; +import type { AroundNode, AroundView, ContextCatch, ContextLink, ContextMessage, ContextRef, ElementContext, Implementation } from '../query/context.js'; +import { KEYS, type LayoutMetrics, type LayoutProblem } from '../diagram/metrics.js'; +import type { FormatResult } from '../format/index.js'; +import type { LayoutView } from '../query/layout-view.js'; +import type { Warning } from '../shared/errors.js'; +import type { LayoutStatus } from '../pipeline/index.js'; +import type { Change, ChangeSet } from '../model/change-set.js'; +import type { DetailMessageFlow, ElementDetail, FindHit, ModelView, ViewAnnotation, ViewFlow, ViewLane, ViewMessageFlow, ViewNode } from '../query/model-view.js'; const INDENT = ' '; const DOC_MAX = 80; @@ -540,7 +540,7 @@ export function renderChanges(cs: ChangeSet): string { } function problemLine(p: Warning): string { - // a validator's finding (src/validators.ts) names its validator: `[host] UNNAMED_TASK ...` + // a validator's finding (src/validate/validators.ts) names its validator: `[host] UNNAMED_TASK ...` const validator = (p as Warning & { validator?: string }).validator; let head = validator ? `[${validator}] ${p.code}` : p.code; if (p.element) head += ` ${p.element}`; diff --git a/src/debug.ts b/src/shared/debug.ts similarity index 100% rename from src/debug.ts rename to src/shared/debug.ts diff --git a/src/errors.ts b/src/shared/errors.ts similarity index 100% rename from src/errors.ts rename to src/shared/errors.ts diff --git a/src/bpmnlint.ts b/src/validate/bpmnlint-validator.ts similarity index 99% rename from src/bpmnlint.ts rename to src/validate/bpmnlint-validator.ts index bf9e4afe..43684f1f 100644 --- a/src/bpmnlint.ts +++ b/src/validate/bpmnlint-validator.ts @@ -1,6 +1,6 @@ /** * A project's bpmnlint configuration (.bpmnlintrc) as a validator - * (src/validators.ts). Browser-safe: bpmnlint itself is injected, this module + * (src/validate/validators.ts). Browser-safe: bpmnlint itself is injected, this module * never imports it; the node layer (src/node/bpmnlint.ts) finds the * .bpmnlintrc, loads bpmnlint and @miragon/bpmnlint-plugin-rules and builds * the resolver. @@ -61,7 +61,7 @@ * The validator never throws: what goes wrong is W_LINT_FAILED. */ import { BpmnModdle } from 'bpmn-moddle'; -import { isDecisionLinkWarning, reportedImportWarnings } from './ops/decision.js'; +import { isDecisionLinkWarning, reportedImportWarnings } from '../ops/decision.js'; import type { NamedValidator, ValidatorContext, ValidatorFinding } from './validators.js'; export const BPMNLINT_VALIDATOR = 'bpmnlint'; @@ -340,7 +340,7 @@ export interface BpmnlintValidatorOptions { blocks?: boolean; /** what the host left out besides the configuration's own (moddle extensions) */ unavailable?: BpmnlintUnavailable[]; - /** findings about the configuration itself, reported in every run like W_LINT_UNAVAILABLE (W_CONFIG_IGNORED: values of element-id-naming new ids do not follow, src/conventions.ts) */ + /** findings about the configuration itself, reported in every run like W_LINT_UNAVAILABLE (W_CONFIG_IGNORED: values of element-id-naming new ids do not follow, src/ids/conventions.ts) */ notes?: ValidatorFinding[]; } diff --git a/src/validate.ts b/src/validate/structural.ts similarity index 98% rename from src/validate.ts rename to src/validate/structural.ts index 07392e12..a23473b0 100644 --- a/src/validate.ts +++ b/src/validate/structural.ts @@ -26,7 +26,7 @@ * Before checking, validateDoc normalises the derived incoming/outgoing * mirror lists (optional in BPMN 2.0): a sequence flow missing from * sourceRef.outgoing / targetRef.incoming is added there (repairFlowLinks), - * in memory only (a write keeps the file's lists, see mirror.ts); + * in memory only (a write keeps the file's lists, see model/mirror.ts); * E_FLOW_LINKS is reserved for entries that contradict a flow's endpoints. * Hints name real command lines (`bpmn ...`). * @@ -55,15 +55,15 @@ * W_EMPTY_SUBPROCESS). * Without the option nothing changes (show, library callers). * Mutations report only the profile findings a change introduced - * (pipeline.ts, withProfile + profileDelta). + * (pipeline/index.ts, withProfile + profileDelta). */ -import type { Doc } from './document.js'; -import { isCliError, type Warning } from './errors.js'; -import { isRejectedType, kindLabel, kindOf, triggerOf, type Trigger } from './kinds.js'; -import { completeMirrorLists } from './mirror.js'; -import { is, walk, type El } from './model.js'; -import { assertSequenceFlowEndpoints } from './ops/flows.js'; -import { profileDelta, runProfile, summarize, type PlatformChoice, type PlatformSummary, type ProfileBaseline, type ProfileFinding, type ProfileReport } from './platform/profile.js'; +import type { Doc } from '../model/document.js'; +import { isCliError, type Warning } from '../shared/errors.js'; +import { isRejectedType, kindLabel, kindOf, triggerOf, type Trigger } from '../model/kinds.js'; +import { completeMirrorLists } from '../model/mirror.js'; +import { is, walk, type El } from '../model/moddle.js'; +import { assertSequenceFlowEndpoints } from '../ops/flows.js'; +import { profileDelta, runProfile, summarize, type PlatformChoice, type PlatformSummary, type ProfileBaseline, type ProfileFinding, type ProfileReport } from '../platform/profiles/profile.js'; import type { ValidatorReport } from './validators.js'; export interface ValidationResult { @@ -71,7 +71,7 @@ export interface ValidationResult { warnings: Warning[]; /** the platform profile that ran (validateDoc with a platform option, mutations); its findings are among the warnings */ platform?: PlatformSummary; - /** the validators that ran (MutationOptions.validators, CheckOptions.validators; src/validators.ts); their findings are among the errors / warnings */ + /** the validators that ran (MutationOptions.validators, CheckOptions.validators; src/validate/validators.ts); their findings are among the errors / warnings */ validators?: ValidatorReport[]; } @@ -256,7 +256,7 @@ export function flowOrder(doc: Doc, scope: El): FlowOrder { * derivable from sourceRef/targetRef) and hand-written or generated files * routinely omit them, while the placement grammar, the view and the lint * read them. The completion is in memory only: a write keeps the lists the - * way the file kept them (mirror.ts unkeptEntries), so no entry is written + * way the file kept them (model/mirror.ts unkeptEntries), so no entry is written * for an unchanged flow of a file that omits it. Doc.fromXml completes the * lists when it reads a document; this repeats it for a model changed in * memory. Idempotent; returns the number of entries added. Entries that @@ -747,7 +747,7 @@ function checkDuplicateNames(ctx: Ctx): void { * findings about modelling conventions. Missing incoming/outgoing mirror * entries are added first (see repairFlowLinks): the only change this makes * to the model is derived data every later stage relies on, and it is not - * written where the file omits it (mirror.ts). With + * written where the file omits it (model/mirror.ts). With * `opts.platform` the platform profile runs too (see the module header). */ export function validateDoc(doc: Doc, opts: ValidateOptions = {}): ValidationResult { @@ -763,7 +763,7 @@ export function validateDoc(doc: Doc, opts: ValidateOptions = {}): ValidationRes * event-gateway finding, a W_NO_START / W_EMPTY_SUBPROCESS about the same * (sub-)process as a missing-start finding ("(sub-)process X has no start * event; the engines refuse the file"). withProfile drops them from the - * warnings, pipeline.ts validationDelta from the resolved ones. + * warnings, pipeline/index.ts validationDelta from the resolved ones. */ export function lintCoveredBy(findings: readonly Warning[]): (w: Warning) => boolean { const gateway = new Set(findings.filter((f) => (f.code.startsWith('W_C7_') || f.code.startsWith('W_C8_')) && f.code.includes('EVENT_GATEWAY')).map((f) => `${f.element}|${f.related?.[0] ?? ''}`)); diff --git a/src/validators.ts b/src/validate/validators.ts similarity index 97% rename from src/validators.ts rename to src/validate/validators.ts index c9063b03..52bced2e 100644 --- a/src/validators.ts +++ b/src/validate/validators.ts @@ -18,7 +18,7 @@ * repeated on every write (only counted). * * An advisory validator (`blocks: false`, the project's bpmnlint in - * src/bpmnlint.ts) never blocks: errors the change introduced are reported + * src/validate/bpmnlint-validator.ts) never blocks: errors the change introduced are reported * among the warnings, severity kept; old errors are only counted. `bpmn * validate` reports its errors as errors. * @@ -47,12 +47,12 @@ * resolved. A check reports it like any other finding, and so does a write with * nothing to compare (an advisory validator of a created document). */ -import type { Doc } from './document.js'; -import { modelError, type Warning } from './errors.js'; -import type { El } from './model.js'; -import type { Op } from './ops/types.js'; -import type { Platform } from './platform/detect.js'; -import type { ValidationResult } from './validate.js'; +import type { Doc } from '../model/document.js'; +import { modelError, type Warning } from '../shared/errors.js'; +import type { El } from '../model/moddle.js'; +import type { Op } from '../ops/types.js'; +import type { Platform } from '../platform/detect.js'; +import type { ValidationResult } from './structural.js'; export type ValidatorSeverity = 'error' | 'warning'; diff --git a/src/encoding.ts b/src/xml/encoding.ts similarity index 100% rename from src/encoding.ts rename to src/xml/encoding.ts diff --git a/src/preserve.ts b/src/xml/preserve.ts similarity index 98% rename from src/preserve.ts rename to src/xml/preserve.ts index e332e6bc..289bcdd6 100644 --- a/src/preserve.ts +++ b/src/xml/preserve.ts @@ -35,12 +35,12 @@ * * Safety: the result must read back, with bpmn-moddle, as exactly the model * `next` describes (parsed and serialised again, it must equal `next`) and be - * well-formed for the reader in xmltext.ts. If not, or if anything is + * well-formed for the reader in text-reader.ts. If not, or if anything is * ambiguous or unsupported (a DOCTYPE, differing root elements), the result * is `next` itself (`mode: 'plain'` with a reason). */ -import { parseXml } from './model.js'; -import { attrKey, decodeXml, elementChildren, hasCharacterData, idOf, readXmlText, type XDocument, type XElement } from './xmltext.js'; +import { parseXml } from '../model/moddle.js'; +import { attrKey, decodeXml, elementChildren, hasCharacterData, idOf, readXmlText, type XDocument, type XElement } from './text-reader.js'; export interface PreservedText { xml: string; @@ -102,7 +102,7 @@ function firstLine(err: unknown): string { async function readsAs(xml: string, next: string): Promise { const write = async (text: string): Promise => { try { - // read like Doc.fromXml reads (model.ts parseXml: references with whitespace around the id resolve) + // read like Doc.fromXml reads (model/moddle.ts parseXml: references with whitespace around the id resolve) const { moddle, definitions } = await parseXml(text); return (await moddle.toXML(definitions, { format: true })).xml; } catch { diff --git a/src/xmltext.ts b/src/xml/text-reader.ts similarity index 100% rename from src/xmltext.ts rename to src/xml/text-reader.ts diff --git a/test/batch-aliases.test.ts b/test/batch-aliases.test.ts index 91863e2c..4cca133d 100644 --- a/test/batch-aliases.test.ts +++ b/test/batch-aliases.test.ts @@ -9,15 +9,15 @@ import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; import { applyToXml, newXml } from '../src/api.js'; -import { renderMutation } from '../src/report.js'; -import { OPS_SCHEMA, opsExample, parseOps } from '../src/batch.js'; -import { idConventionsFromLint } from '../src/conventions.js'; -import { Doc } from '../src/document.js'; -import { CliError } from '../src/errors.js'; -import { ERROR_CATALOGUE, guideShort, guideText } from '../src/guide.js'; +import { renderMutation } from '../src/report/command-report.js'; +import { OPS_SCHEMA, opsExample, parseOps } from '../src/ops/batch.js'; +import { idConventionsFromLint } from '../src/ids/conventions.js'; +import { Doc } from '../src/model/document.js'; +import { CliError } from '../src/shared/errors.js'; +import { ERROR_CATALOGUE, guideShort, guideText } from '../src/report/guide.js'; import { bpmnlintEngine } from '../src/node/bpmnlint.js'; import type { Op } from '../src/ops/types.js'; -import { mutateDoc } from '../src/pipeline.js'; +import { mutateDoc } from '../src/pipeline/index.js'; function failure(fn: () => unknown): CliError { try { diff --git a/test/batch.test.ts b/test/batch.test.ts index e52db4fe..5ad918ca 100644 --- a/test/batch.test.ts +++ b/test/batch.test.ts @@ -1,15 +1,15 @@ import { readdirSync, readFileSync, statSync } from 'node:fs'; import { join } from 'node:path'; import { describe, expect, it } from 'vitest'; -import { OPS_SCHEMA, OP_FIELDS, opsExample, parseOps } from '../src/batch.js'; -import { Doc } from '../src/document.js'; -import { isCliError } from '../src/errors.js'; -import { renderView } from '../src/format.js'; -import { COMMANDS, COMMON_OPTIONS, ERROR_CATALOGUE, PLACEMENT_NOTES, guideShort, guideText, kindsJson, kindsSectionText, kindsText } from '../src/guide.js'; -import { MAX_ID, MAX_SLUG } from '../src/ids.js'; -import { KINDS } from '../src/kinds.js'; +import { OPS_SCHEMA, OP_FIELDS, opsExample, parseOps } from '../src/ops/batch.js'; +import { Doc } from '../src/model/document.js'; +import { isCliError } from '../src/shared/errors.js'; +import { renderView } from '../src/report/view-text.js'; +import { COMMANDS, COMMON_OPTIONS, ERROR_CATALOGUE, PLACEMENT_NOTES, guideShort, guideText, kindsJson, kindsSectionText, kindsText } from '../src/report/guide.js'; +import { MAX_ID, MAX_SLUG } from '../src/ids/slugs.js'; +import { KINDS } from '../src/model/kinds.js'; import { OP_NAMES, type Op } from '../src/ops/types.js'; -import { mutateDoc } from '../src/pipeline.js'; +import { mutateDoc } from '../src/pipeline/index.js'; /** Runs parseOps and returns the thrown CliError. */ function failure(input: unknown): { code: string; message: string; op?: number; hint?: string; candidates?: string[] } { @@ -42,7 +42,7 @@ function sourceFiles(dir: string): string[] { function codesInSource(): string[] { const codes = new Set(); for (const file of sourceFiles(SRC_DIR)) { - if (file.endsWith('guide.ts')) continue; + if (file.endsWith('report/guide.ts')) continue; for (const m of readFileSync(file, 'utf8').matchAll(/\b[EW]_[A-Z][A-Z0-9_]*\b/g)) codes.add(m[0].endsWith('_') ? `${m[0]}*` : m[0]); } return [...codes].sort(); diff --git a/test/bpmnlint.test.ts b/test/bpmnlint.test.ts index ec08ed3d..43f6486d 100644 --- a/test/bpmnlint.test.ts +++ b/test/bpmnlint.test.ts @@ -1,5 +1,5 @@ /** - * The project's bpmnlint configuration (issue #33): src/bpmnlint.ts (the + * The project's bpmnlint configuration (issue #33): src/validate/bpmnlint-validator.ts (the * core: resolution, the advisory validator) and src/node/bpmnlint.ts (lookup, * loading, the resolver chain), with the real bpmnlint and * @miragon/bpmnlint-plugin-rules, offline. @@ -19,17 +19,17 @@ import { tmpdir } from 'node:os'; import { basename, dirname, join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest'; import { applyToXml, newXml } from '../src/api.js'; -import { bpmnlintUnavailableFindings, bpmnlintValidator, BPMNLINT_COVERS, resolveBpmnlintConfig, type BpmnlintEngine, type BpmnlintResolver } from '../src/bpmnlint.js'; -import { idConventionsFromLint, ID_NAMING_RULE } from '../src/conventions.js'; -import { Doc } from '../src/document.js'; -import type { CliError } from '../src/errors.js'; +import { bpmnlintUnavailableFindings, bpmnlintValidator, BPMNLINT_COVERS, resolveBpmnlintConfig, type BpmnlintEngine, type BpmnlintResolver } from '../src/validate/bpmnlint-validator.js'; +import { idConventionsFromLint, ID_NAMING_RULE } from '../src/ids/conventions.js'; +import { Doc } from '../src/model/document.js'; +import type { CliError } from '../src/shared/errors.js'; import type { Op } from '../src/ops/types.js'; import { bpmnlintEngine, findBpmnlintConfig, loadBpmnlint, projectBpmnlint, projectBpmnlintSettings } from '../src/node/bpmnlint.js'; import { checkFile, checkLoadedDoc, mutateFile } from '../src/node/files.js'; import { gitRoot } from '../src/node/find-up.js'; -import { checkDoc } from '../src/pipeline.js'; -import { advisoryValidators, mutationReport, mutationSummary, renderMutation, renderSummary, renderValidation, validationReport } from '../src/report.js'; -import type { ValidatorFinding, ValidatorIssue } from '../src/validators.js'; +import { checkDoc } from '../src/pipeline/index.js'; +import { advisoryValidators, mutationReport, mutationSummary, renderMutation, renderSummary, renderValidation, validationReport } from '../src/report/command-report.js'; +import type { ValidatorFinding, ValidatorIssue } from '../src/validate/validators.js'; const ROOT = join(import.meta.dirname, '..'); const fixture = (path: string): string => readFileSync(join(ROOT, 'test', 'fixtures', path), 'utf8'); diff --git a/test/c7-ext-structure.test.ts b/test/c7-ext-structure.test.ts index e1934dad..829a9119 100644 --- a/test/c7-ext-structure.test.ts +++ b/test/c7-ext-structure.test.ts @@ -19,8 +19,8 @@ * 2.2 and Operaton 2.1 (deployment and, for 1b/1c, an external task fetch). */ import { describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; -import { is, many, type El } from '../src/model.js'; +import { Doc } from '../src/model/document.js'; +import { is, many, type El } from '../src/model/moddle.js'; import { connectElements } from '../src/ops/connect.js'; import { extensionOp, listExtensions, parseSelector, SINGLE_TOP, type ExtensionInfo } from '../src/ops/ext.js'; import { eventGatewayTargetProblem } from '../src/ops/flows.js'; @@ -28,7 +28,7 @@ import { runOps } from '../src/ops/index.js'; import { moveElements } from '../src/ops/move.js'; import { removeElements } from '../src/ops/remove.js'; import type { ExtOp, Op } from '../src/ops/types.js'; -import { mutateDoc } from '../src/pipeline.js'; +import { mutateDoc } from '../src/pipeline/index.js'; import { definitionsXml } from './helpers.js'; const CAMUNDA_URI = 'http://camunda.org/schema/1.0/bpmn'; diff --git a/test/c7-followups-integration.test.ts b/test/c7-followups-integration.test.ts index 2b99b39c..4bd98631 100644 --- a/test/c7-followups-integration.test.ts +++ b/test/c7-followups-integration.test.ts @@ -35,14 +35,14 @@ import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; -import { kindsJson, kindsText } from '../src/guide.js'; +import { Doc } from '../src/model/document.js'; +import { kindsJson, kindsText } from '../src/report/guide.js'; import { listAllExtensions } from '../src/ops/ext.js'; import { runOps } from '../src/ops/index.js'; import type { Op } from '../src/ops/types.js'; -import { mutateDoc } from '../src/pipeline.js'; -import { loadProfiles, runProfile } from '../src/platform/profile.js'; -import { validateDoc } from '../src/validate.js'; +import { mutateDoc } from '../src/pipeline/index.js'; +import { loadProfiles, runProfile } from '../src/platform/profiles/profile.js'; +import { validateDoc } from '../src/validate/structural.js'; // the engine rules load on demand; runProfile / validateDoc(doc, { platform }) need them loaded (the pipeline loads them itself) await loadProfiles(); diff --git a/test/c7-followups-ops.test.ts b/test/c7-followups-ops.test.ts index edbbf200..f1a45c53 100644 --- a/test/c7-followups-ops.test.ts +++ b/test/c7-followups-ops.test.ts @@ -27,10 +27,10 @@ * (withoutProfileDuplicates). */ import { describe, expect, it } from 'vitest'; -import { parseOps } from '../src/batch.js'; -import { Doc } from '../src/document.js'; -import { extensionLines, renderDetail, renderExtensionList, renderView } from '../src/format.js'; -import { is, many, type El } from '../src/model.js'; +import { parseOps } from '../src/ops/batch.js'; +import { Doc } from '../src/model/document.js'; +import { extensionLines, renderDetail, renderExtensionList, renderView } from '../src/report/view-text.js'; +import { is, many, type El } from '../src/model/moddle.js'; import { listAllExtensions } from '../src/ops/ext.js'; import { eventGatewayTargetProblem } from '../src/ops/flows.js'; import { runOps } from '../src/ops/index.js'; @@ -38,8 +38,8 @@ import { removeElements } from '../src/ops/remove.js'; import { withoutProfileDuplicates } from '../src/ops/retype.js'; import { readProperties } from '../src/ops/set.js'; import type { Op } from '../src/ops/types.js'; -import { mutateDoc } from '../src/pipeline.js'; -import { buildView, elementDetail } from '../src/view.js'; +import { mutateDoc } from '../src/pipeline/index.js'; +import { buildView, elementDetail } from '../src/query/model-view.js'; import { definitionsXml } from './helpers.js'; const CAMUNDA = 'xmlns:camunda="http://camunda.org/schema/1.0/bpmn"'; diff --git a/test/c7-followups-profile.test.ts b/test/c7-followups-profile.test.ts index 6317efc8..e0644887 100644 --- a/test/c7-followups-profile.test.ts +++ b/test/c7-followups-profile.test.ts @@ -21,11 +21,11 @@ import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; +import { Doc } from '../src/model/document.js'; import { platformOf } from '../src/platform/descriptor.js'; import { detectPlatform } from '../src/platform/detect.js'; -import { loadProfiles, runProfile } from '../src/platform/profile.js'; -import { validateDoc } from '../src/validate.js'; +import { loadProfiles, runProfile } from '../src/platform/profiles/profile.js'; +import { validateDoc } from '../src/validate/structural.js'; // the engine rules load on demand; runProfile / validateDoc(doc, { platform }) need them loaded (the pipeline loads them itself) await loadProfiles(); diff --git a/test/c7-followups-verify.test.ts b/test/c7-followups-verify.test.ts index 32474b3a..68fcbce2 100644 --- a/test/c7-followups-verify.test.ts +++ b/test/c7-followups-verify.test.ts @@ -35,10 +35,10 @@ import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; -import { mutateDoc } from '../src/pipeline.js'; -import { loadProfiles, runProfile } from '../src/platform/profile.js'; -import { validateDoc } from '../src/validate.js'; +import { Doc } from '../src/model/document.js'; +import { mutateDoc } from '../src/pipeline/index.js'; +import { loadProfiles, runProfile } from '../src/platform/profiles/profile.js'; +import { validateDoc } from '../src/validate/structural.js'; // the engine rules load on demand; runProfile / validateDoc(doc, { platform }) need them loaded (the pipeline loads them itself) await loadProfiles(); diff --git a/test/c7-integration.test.ts b/test/c7-integration.test.ts index 44e4dd2d..59783917 100644 --- a/test/c7-integration.test.ts +++ b/test/c7-integration.test.ts @@ -16,18 +16,18 @@ import { mkdtempSync, readFileSync, rmSync, writeFileSync, existsSync } from 'no import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; -import { parseOps } from '../src/batch.js'; -import { Doc } from '../src/document.js'; -import { renderDetail, renderExtensionList } from '../src/format.js'; -import { kindsJson, kindsText } from '../src/guide.js'; -import { is, type El } from '../src/model.js'; +import { parseOps } from '../src/ops/batch.js'; +import { Doc } from '../src/model/document.js'; +import { renderDetail, renderExtensionList } from '../src/report/view-text.js'; +import { kindsJson, kindsText } from '../src/report/guide.js'; +import { is, type El } from '../src/model/moddle.js'; import { extensionOp, listAllExtensions } from '../src/ops/ext.js'; import { runOps } from '../src/ops/index.js'; import { moveElements } from '../src/ops/move.js'; import type { Op } from '../src/ops/types.js'; -import { mutateDoc } from '../src/pipeline.js'; -import { validateDoc } from '../src/validate.js'; -import { elementDetail } from '../src/view.js'; +import { mutateDoc } from '../src/pipeline/index.js'; +import { validateDoc } from '../src/validate/structural.js'; +import { elementDetail } from '../src/query/model-view.js'; import * as lib from '../src/index.js'; import { definitionsXml } from './helpers.js'; diff --git a/test/c7-profile.test.ts b/test/c7-profile.test.ts index 7e41d564..236bb995 100644 --- a/test/c7-profile.test.ts +++ b/test/c7-profile.test.ts @@ -18,12 +18,12 @@ import { mkdtempSync, rmSync, writeFileSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; +import { Doc } from '../src/model/document.js'; import { checkFile } from '../src/node/files.js'; -import { mutateDoc } from '../src/pipeline.js'; +import { mutateDoc } from '../src/pipeline/index.js'; import { detectPlatform } from '../src/platform/detect.js'; -import { loadProfiles, runProfile, type ProfileFinding } from '../src/platform/profile.js'; -import { validateDoc } from '../src/validate.js'; +import { loadProfiles, runProfile, type ProfileFinding } from '../src/platform/profiles/profile.js'; +import { validateDoc } from '../src/validate/structural.js'; // the engine rules load on demand; runProfile / validateDoc(doc, { platform }) need them loaded (the pipeline loads them itself) await loadProfiles(); diff --git a/test/c7-semantic.test.ts b/test/c7-semantic.test.ts index da2d1d13..b305ab04 100644 --- a/test/c7-semantic.test.ts +++ b/test/c7-semantic.test.ts @@ -14,14 +14,14 @@ * + the shared descriptor lookup (src/platform/descriptor.ts) */ import { describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; -import { renderDetail, renderView } from '../src/format.js'; +import { Doc } from '../src/model/document.js'; +import { renderDetail, renderView } from '../src/report/view-text.js'; import { runOps } from '../src/ops/index.js'; import { readProperties } from '../src/ops/set.js'; import type { Op } from '../src/ops/types.js'; -import { mutateDoc } from '../src/pipeline.js'; +import { mutateDoc } from '../src/pipeline/index.js'; import { allowedOn, allowedParents, attrAppliesTo, camundaAttr, camundaAttrsFor, containersOf, idReferenceAttrs, isCamundaType, platformOf, typeIs } from '../src/platform/descriptor.js'; -import { buildView, elementDetail, findElements } from '../src/view.js'; +import { buildView, elementDetail, findElements } from '../src/query/model-view.js'; import { definitionsXml, flowBetween } from './helpers.js'; const CAMUNDA = 'xmlns:camunda="http://camunda.org/schema/1.0/bpmn"'; diff --git a/test/c8-ops.test.ts b/test/c8-ops.test.ts index 374d96ff..b05ac860 100644 --- a/test/c8-ops.test.ts +++ b/test/c8-ops.test.ts @@ -14,13 +14,13 @@ import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; -import { opsExample } from '../src/batch.js'; -import { Doc } from '../src/document.js'; -import { renderView } from '../src/format.js'; +import { opsExample } from '../src/ops/batch.js'; +import { Doc } from '../src/model/document.js'; +import { renderView } from '../src/report/view-text.js'; import { runOps } from '../src/ops/index.js'; -import { mutateDoc } from '../src/pipeline.js'; -import { loadProfiles, runProfile } from '../src/platform/profile.js'; -import { buildView, elementDetail } from '../src/view.js'; +import { mutateDoc } from '../src/pipeline/index.js'; +import { loadProfiles, runProfile } from '../src/platform/profiles/profile.js'; +import { buildView, elementDetail } from '../src/query/model-view.js'; // the engine rules load on demand; runProfile / validateDoc(doc, { platform }) need them loaded (the pipeline loads them itself) await loadProfiles(); diff --git a/test/c8-profile.test.ts b/test/c8-profile.test.ts index bc012d63..824be172 100644 --- a/test/c8-profile.test.ts +++ b/test/c8-profile.test.ts @@ -1,5 +1,5 @@ /** - * The Camunda 8 validation profile (src/platform/c8.ts): one synthetic model + * The Camunda 8 validation profile (src/platform/profiles/c8.ts): one synthetic model * per rule with the exact findings it must produce and what Camunda 8.9 does * with it, the zeebe descriptor lookup, the FEEL and timer value checks, and * the `validate` output for Camunda 8 files. @@ -18,12 +18,12 @@ import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; -import { mutateDoc } from '../src/pipeline.js'; -import { feelProblem, validCycle, validDateTime, validDuration } from '../src/platform/c8.js'; -import { loadProfiles, runProfile } from '../src/platform/profile.js'; +import { Doc } from '../src/model/document.js'; +import { mutateDoc } from '../src/pipeline/index.js'; +import { feelProblem, validCycle, validDateTime, validDuration } from '../src/platform/profiles/c8.js'; +import { loadProfiles, runProfile } from '../src/platform/profiles/profile.js'; import { zeebeAllowedOn, zeebeAttr, zeebeContainersOf, zeebeNestedOnly, zeebeType } from '../src/platform/zeebe.js'; -import { validateDoc } from '../src/validate.js'; +import { validateDoc } from '../src/validate/structural.js'; // the engine rules load on demand; runProfile / validateDoc(doc, { platform }) need them loaded (the pipeline loads them itself) await loadProfiles(); diff --git a/test/cli-format.test.ts b/test/cli-format.test.ts index f5c852cc..844b5aaf 100644 --- a/test/cli-format.test.ts +++ b/test/cli-format.test.ts @@ -9,11 +9,11 @@ import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; +import { Doc } from '../src/model/document.js'; import { readPlanes, type DShape } from '../src/diagram/plane.js'; -import type { El } from '../src/model.js'; +import type { El } from '../src/model/moddle.js'; import type { Op } from '../src/ops/types.js'; -import { mutateDoc } from '../src/pipeline.js'; +import { mutateDoc } from '../src/pipeline/index.js'; const ROOT = join(import.meta.dirname, '..'); let dir: string; diff --git a/test/cli-layout.test.ts b/test/cli-layout.test.ts index 108a70ee..8c4930eb 100644 --- a/test/cli-layout.test.ts +++ b/test/cli-layout.test.ts @@ -9,11 +9,11 @@ import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; +import { Doc } from '../src/model/document.js'; import { readPlanes } from '../src/diagram/plane.js'; -import type { El } from '../src/model.js'; +import type { El } from '../src/model/moddle.js'; import type { Op } from '../src/ops/types.js'; -import { mutateDoc } from '../src/pipeline.js'; +import { mutateDoc } from '../src/pipeline/index.js'; const ROOT = join(import.meta.dirname, '..'); let dir: string; diff --git a/test/cli-views.test.ts b/test/cli-views.test.ts index 4266cba5..e1fd8dde 100644 --- a/test/cli-views.test.ts +++ b/test/cli-views.test.ts @@ -9,8 +9,8 @@ import { copyFileSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from ' import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; -import { COMMANDS, GUIDE_TOPICS, guideTopic, KINDS_SECTION_NAMES } from '../src/guide.js'; +import { Doc } from '../src/model/document.js'; +import { COMMANDS, GUIDE_TOPICS, guideTopic, KINDS_SECTION_NAMES } from '../src/report/guide.js'; const ROOT = join(import.meta.dirname, '..'); const CLAIMS = join(ROOT, 'test', 'fixtures', 'views', 'claims.bpmn'); diff --git a/test/cli.test.ts b/test/cli.test.ts index 5c1b1d8a..dd6e5d92 100644 --- a/test/cli.test.ts +++ b/test/cli.test.ts @@ -6,7 +6,7 @@ import { mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSyn import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; +import { Doc } from '../src/model/document.js'; const ROOT = join(import.meta.dirname, '..'); const BIN = join(ROOT, 'dist', 'cli.js'); diff --git a/test/conventions-declared.test.ts b/test/conventions-declared.test.ts index 6f94000e..c17427eb 100644 --- a/test/conventions-declared.test.ts +++ b/test/conventions-declared.test.ts @@ -1,20 +1,20 @@ /** - * Declared id conventions in the core (issue #34; src/idstyle.ts DECLARED + * Declared id conventions in the core (issue #34; src/ids/style.ts DECLARED * CONVENTIONS): they fill the gaps a change opens and never rename what is * there; the rest of the file keeps its own style, stable over many writes; * W_ID_PREFIX_STALE after a retype or a trigger change; the `conventions` * of a result; the view of `bpmn show --conventions`. The conventions come - * from the real plugin's naming helpers (src/conventions.ts). + * from the real plugin's naming helpers (src/ids/conventions.ts). */ import { describe, expect, it } from 'vitest'; import { applyToXml, conventionsXml } from '../src/api.js'; -import type { BpmnlintRuleSetting } from '../src/bpmnlint.js'; -import { conventionsView, idConventionsFromLint, renderConventions, type IdConventions } from '../src/conventions.js'; -import { Doc } from '../src/document.js'; +import type { BpmnlintRuleSetting } from '../src/validate/bpmnlint-validator.js'; +import { conventionsView, idConventionsFromLint, renderConventions, type IdConventions } from '../src/ids/conventions.js'; +import { Doc } from '../src/model/document.js'; import { bpmnlintEngine } from '../src/node/bpmnlint.js'; import type { Op } from '../src/ops/types.js'; -import { mutateDoc, type MutationResult } from '../src/pipeline.js'; -import { mutationReport, mutationSummary, renderMutation, renderSummary } from '../src/report.js'; +import { mutateDoc, type MutationResult } from '../src/pipeline/index.js'; +import { mutationReport, mutationSummary, renderMutation, renderSummary } from '../src/report/command-report.js'; import { definitionsXml } from './helpers.js'; const naming = bpmnlintEngine().plugin.naming; diff --git a/test/conventions-di.test.ts b/test/conventions-di.test.ts index 98ce512c..460a57cd 100644 --- a/test/conventions-di.test.ts +++ b/test/conventions-di.test.ts @@ -5,10 +5,10 @@ */ import { describe, expect, it } from 'vitest'; import { styledId } from '../src/diagram/write.js'; -import { Doc } from '../src/document.js'; -import { cutAt } from '../src/ids.js'; +import { Doc } from '../src/model/document.js'; +import { cutAt } from '../src/ids/slugs.js'; import type { Op } from '../src/ops/types.js'; -import { mutateDoc, type MutationOptions } from '../src/pipeline.js'; +import { mutateDoc, type MutationOptions } from '../src/pipeline/index.js'; const OPS: Op[] = [ { op: 'add', kind: 'startEvent', id: 'S', name: 'Start' }, diff --git a/test/conventions-ids.test.ts b/test/conventions-ids.test.ts index 1860c909..9491a5c7 100644 --- a/test/conventions-ids.test.ts +++ b/test/conventions-ids.test.ts @@ -1,6 +1,6 @@ /** * Edits follow the file: generated ids take the id style of the file they - * are written into (src/idstyle.ts) and say what they name (never a hash or + * are written into (src/ids/style.ts) and say what they name (never a hash or * a running number: names, kind + context, the ends of a flow), names are * transliterated the German way. All fixtures are synthetic. */ @@ -9,12 +9,12 @@ import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; import { describe, expect, it } from 'vitest'; import { applyToXml } from '../src/api.js'; -import { Doc } from '../src/document.js'; -import { IdStyle } from '../src/idstyle.js'; +import { Doc } from '../src/model/document.js'; +import { IdStyle } from '../src/ids/style.js'; import { runOps } from '../src/ops/index.js'; import type { Op } from '../src/ops/types.js'; -import { guideText, kindsJson } from '../src/guide.js'; -import { mutateDoc } from '../src/pipeline.js'; +import { guideText, kindsJson } from '../src/report/guide.js'; +import { mutateDoc } from '../src/pipeline/index.js'; import { definitionsXml, flowBetween } from './helpers.js'; const HERE = dirname(fileURLToPath(import.meta.url)); diff --git a/test/conventions-lint.test.ts b/test/conventions-lint.test.ts index 1d2ccc7a..1b987923 100644 --- a/test/conventions-lint.test.ts +++ b/test/conventions-lint.test.ts @@ -4,16 +4,16 @@ * bpmnlint and @miragon/bpmnlint-plugin-rules (the ones the node layer * loads), in a new file and in files of other styles; and * idConventionsFromLint reads the rule's options as the rule does - * (src/conventions.ts). + * (src/ids/conventions.ts). */ import { BpmnModdle } from 'bpmn-moddle'; import { describe, expect, it } from 'vitest'; -import type { BpmnlintRuleSetting } from '../src/bpmnlint.js'; -import { idConventionsFromLint, ID_NAMING_RULE, type IdConventions } from '../src/conventions.js'; -import { Doc } from '../src/document.js'; +import type { BpmnlintRuleSetting } from '../src/validate/bpmnlint-validator.js'; +import { idConventionsFromLint, ID_NAMING_RULE, type IdConventions } from '../src/ids/conventions.js'; +import { Doc } from '../src/model/document.js'; import { bpmnlintEngine } from '../src/node/bpmnlint.js'; import type { Op } from '../src/ops/types.js'; -import { mutateDoc } from '../src/pipeline.js'; +import { mutateDoc } from '../src/pipeline/index.js'; const engine = bpmnlintEngine(); const naming = engine.plugin.naming; diff --git a/test/conventions-stickies.test.ts b/test/conventions-stickies.test.ts index e8cf1531..c1223df7 100644 --- a/test/conventions-stickies.test.ts +++ b/test/conventions-stickies.test.ts @@ -4,10 +4,10 @@ * Synthetic fixtures only. */ import { describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; +import { Doc } from '../src/model/document.js'; import type { Op } from '../src/ops/types.js'; -import { mutateDoc, type MutationOptions, type MutationResult } from '../src/pipeline.js'; -import { renderLayout } from '../src/format.js'; +import { mutateDoc, type MutationOptions, type MutationResult } from '../src/pipeline/index.js'; +import { renderLayout } from '../src/report/view-text.js'; const OPS: Op[] = [ { op: 'add', kind: 'startEvent', id: 'S', name: 'Start' }, diff --git a/test/core.test.ts b/test/core.test.ts index a6907dfd..7a287508 100644 --- a/test/core.test.ts +++ b/test/core.test.ts @@ -1,15 +1,15 @@ import { describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; -import { IdRegistry, isValidId, slugify } from '../src/ids.js'; -import { connectionRequest, IdStyle, kindRequest, typeRequest } from '../src/idstyle.js'; -import { kindByName } from '../src/kinds.js'; -import { kindLabel, kindOf, parseKind, suggestKinds, triggerOf } from '../src/kinds.js'; -import { diExpansionState, layoutModel, resolveExpanded } from '../src/layout.js'; -import { many } from '../src/model.js'; +import { Doc } from '../src/model/document.js'; +import { IdRegistry, isValidId, slugify } from '../src/ids/slugs.js'; +import { connectionRequest, IdStyle, kindRequest, typeRequest } from '../src/ids/style.js'; +import { kindByName } from '../src/model/kinds.js'; +import { kindLabel, kindOf, parseKind, suggestKinds, triggerOf } from '../src/model/kinds.js'; +import { diExpansionState, layoutModel, resolveExpanded } from '../src/layout/index.js'; +import { many } from '../src/model/moddle.js'; import { createSequenceFlow, detachNode, placeNode, redirectFlow, spliceIntoFlow } from '../src/ops/flows.js'; import { runOps } from '../src/ops/index.js'; -import { mutateDoc } from '../src/pipeline.js'; -import { ChangeSet } from '../src/result.js'; +import { mutateDoc } from '../src/pipeline/index.js'; +import { ChangeSet } from '../src/model/change-set.js'; import { definitionsXml, flowBetween, linearDoc } from './helpers.js'; function caught(fn: () => unknown): { code?: string; message: string; details: Record } { diff --git a/test/decision-link.test.ts b/test/decision-link.test.ts index 8fb5e7bc..59e47aaf 100644 --- a/test/decision-link.test.ts +++ b/test/decision-link.test.ts @@ -12,14 +12,14 @@ import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; -import { COMMANDS, ERROR_CATALOGUE, guideText, kindsJson } from '../src/guide.js'; +import { Doc } from '../src/model/document.js'; +import { COMMANDS, ERROR_CATALOGUE, guideText, kindsJson } from '../src/report/guide.js'; import { runOps } from '../src/ops/index.js'; import { settableKeys } from '../src/ops/set.js'; import { checkFile } from '../src/node/files.js'; -import { mutateDoc, type MutationOptions } from '../src/pipeline.js'; -import { loadProfiles, runProfile } from '../src/platform/profile.js'; -import { buildView, elementDetail, findElements } from '../src/view.js'; +import { mutateDoc, type MutationOptions } from '../src/pipeline/index.js'; +import { loadProfiles, runProfile } from '../src/platform/profiles/profile.js'; +import { buildView, elementDetail, findElements } from '../src/query/model-view.js'; // the engine rules load on demand; runProfile / validateDoc(doc, { platform }) need them loaded (the pipeline loads them itself) await loadProfiles(); diff --git a/test/diagram-fallback.test.ts b/test/diagram-fallback.test.ts index 4c5218e5..f93a965e 100644 --- a/test/diagram-fallback.test.ts +++ b/test/diagram-fallback.test.ts @@ -5,16 +5,16 @@ */ import { describe, expect, it, vi } from 'vitest'; -vi.mock('../src/diagram/incremental.js', async (importOriginal) => ({ - ...(await importOriginal()), +vi.mock('../src/layout/incremental.js', async (importOriginal) => ({ + ...(await importOriginal()), layoutIncremental: async () => { throw new Error('boom'); }, })); -const { Doc } = await import('../src/document.js'); -const { mutateDoc } = await import('../src/pipeline.js'); -const { CliError } = await import('../src/errors.js'); +const { Doc } = await import('../src/model/document.js'); +const { mutateDoc } = await import('../src/pipeline/index.js'); +const { CliError } = await import('../src/shared/errors.js'); /** A drawn file the clean engine would not reproduce (every shape moved by 30 px). */ async function handXml(): Promise { diff --git a/test/diagram-format.test.ts b/test/diagram-format.test.ts index e19a339f..998aa630 100644 --- a/test/diagram-format.test.ts +++ b/test/diagram-format.test.ts @@ -1,5 +1,5 @@ /** - * Format operations (src/diagram/ops.ts) through the write pipeline: place, + * Format operations (src/format/index.ts) through the write pipeline: place, * align, color, label, route, space, tidy and lane order, their refusals, * batch semantics (after the semantic ops, in batch order, all or nothing) * and the persistence of formatting over later writes; plus the read side @@ -12,18 +12,18 @@ import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; -import { OPS_SCHEMA, parseOps } from '../src/batch.js'; -import { kindsJson } from '../src/guide.js'; +import { OPS_SCHEMA, parseOps } from '../src/ops/batch.js'; +import { kindsJson } from '../src/report/guide.js'; import { FORMAT_OP_NAMES } from '../src/ops/types.js'; -import { Doc } from '../src/document.js'; +import { Doc } from '../src/model/document.js'; import { readPlanes, type DEdge, type DShape } from '../src/diagram/plane.js'; -import { layoutView } from '../src/diagram/view.js'; -import { isCliError } from '../src/errors.js'; -import { renderLayoutView } from '../src/format.js'; -import type { El } from '../src/model.js'; +import { layoutView } from '../src/query/layout-view.js'; +import { isCliError } from '../src/shared/errors.js'; +import { renderLayoutView } from '../src/report/view-text.js'; +import type { El } from '../src/model/moddle.js'; import type { Op } from '../src/ops/types.js'; import { mutateFile } from '../src/node/files.js'; -import { mutateDoc, type MutationOptions, type MutationResult } from '../src/pipeline.js'; +import { mutateDoc, type MutationOptions, type MutationResult } from '../src/pipeline/index.js'; /* ------------------------------------------------------------------ */ /* fixtures */ diff --git a/test/diagram-incremental-robustness.test.ts b/test/diagram-incremental-robustness.test.ts index a1cde774..d56cced0 100644 --- a/test/diagram-incremental-robustness.test.ts +++ b/test/diagram-incremental-robustness.test.ts @@ -7,13 +7,13 @@ import { readFileSync } from 'node:fs'; import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; import { describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; +import { Doc } from '../src/model/document.js'; import { layoutProblems } from '../src/diagram/metrics.js'; import { readPlanes, type DEdge, type DShape } from '../src/diagram/plane.js'; import { detachedEnds } from '../src/diagram/reroute.js'; -import { is, type El } from '../src/model.js'; +import { is, type El } from '../src/model/moddle.js'; import type { Op } from '../src/ops/types.js'; -import { mutateDoc, type MutationOptions, type MutationResult } from '../src/pipeline.js'; +import { mutateDoc, type MutationOptions, type MutationResult } from '../src/pipeline/index.js'; const HERE = dirname(fileURLToPath(import.meta.url)); diff --git a/test/diagram-incremental.test.ts b/test/diagram-incremental.test.ts index 85cde61a..9a1329cf 100644 --- a/test/diagram-incremental.test.ts +++ b/test/diagram-incremental.test.ts @@ -12,13 +12,13 @@ import { readFileSync } from 'node:fs'; import { join } from 'node:path'; import { describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; +import { Doc } from '../src/model/document.js'; import { layoutProblems } from '../src/diagram/metrics.js'; import { readPlanes, type DEdge, type DShape } from '../src/diagram/plane.js'; import { detachedEnds } from '../src/diagram/reroute.js'; -import { is, type El } from '../src/model.js'; +import { is, type El } from '../src/model/moddle.js'; import type { Op } from '../src/ops/types.js'; -import { mutateDoc, type MutationOptions, type MutationResult } from '../src/pipeline.js'; +import { mutateDoc, type MutationOptions, type MutationResult } from '../src/pipeline/index.js'; /* ------------------------------------------------------------------ */ /* fixtures */ @@ -608,7 +608,7 @@ describe('incremental placement', () => { }); it('an engine drawing with a boundary event on its host\'s top border (its way over the top) stays editable: a task after its target, a task into its flow and a reroute keep the event there and its flow leaving it by its top', async () => { - // the clean engine puts Payment failed on Pick invoice's top border (layout/place.ts boundariesOnTop); Rejected, + // the clean engine puts Payment failed on Pick invoice's top border (layout/clean/place.ts boundariesOnTop); Rejected, // whose handler lies below, stays on the bottom border const ops: Op[] = [ { op: 'add', kind: 'startEvent', id: 'S', name: 'Start' }, diff --git a/test/diagram-metrics.test.ts b/test/diagram-metrics.test.ts index a84ca574..b77961f1 100644 --- a/test/diagram-metrics.test.ts +++ b/test/diagram-metrics.test.ts @@ -13,7 +13,7 @@ import { readFileSync } from 'node:fs'; import { join } from 'node:path'; import { describe, expect, it } from 'vitest'; import { EXTRA_KEYS, HARNESS_KEYS, KEYS, QUALITY_KEYS, WEIGHTS, diffProblems, layoutProblems, layoutProblemsOfXml, locateProblems, metricsDelta, problemKey, scoreOf, type LayoutProblem, type MetricKey } from '../src/diagram/metrics.js'; -import { parseXml } from '../src/model.js'; +import { parseXml } from '../src/model/moddle.js'; import { definitionsXml } from './helpers.js'; const DI_NS = diff --git a/test/diagram-plane.test.ts b/test/diagram-plane.test.ts index f9695743..4aae6ad7 100644 --- a/test/diagram-plane.test.ts +++ b/test/diagram-plane.test.ts @@ -3,10 +3,10 @@ * (writing it back, pruning, colours) on hand-written DI fixtures. */ import { describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; +import { Doc } from '../src/model/document.js'; import { readPlanes, semantics, homePlane, frameOf, type Plane } from '../src/diagram/plane.js'; import { applyColors, colorsOf, diIds, pruneDi, writePlanes } from '../src/diagram/write.js'; -import { is, type El } from '../src/model.js'; +import { is, type El } from '../src/model/moddle.js'; import { BPMN_NS } from './helpers.js'; const NS = `xmlns:bpmn="${BPMN_NS}" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:bioc="http://bpmn.io/schema/bpmn/biocolor/1.0" xmlns:color="http://www.omg.org/spec/BPMN/non-normative/color/1.0"`; diff --git a/test/diagram-polish.test.ts b/test/diagram-polish.test.ts index 5de063ec..181a5a05 100644 --- a/test/diagram-polish.test.ts +++ b/test/diagram-polish.test.ts @@ -11,16 +11,16 @@ import { readFileSync } from 'node:fs'; import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; import { describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; +import { Doc } from '../src/model/document.js'; import { layoutProblems } from '../src/diagram/metrics.js'; import { readPlanes, type DEdge, type DShape, type Plane } from '../src/diagram/plane.js'; import { routeOrthogonal } from '../src/diagram/router.js'; import { makeSpace } from '../src/diagram/space.js'; import { activitySize, BOTTOM_ROOM, fitsInside, innerLines } from '../src/diagram/text.js'; -import type { Box, Point } from '../src/layout/types.js'; -import type { El } from '../src/model.js'; +import type { Box, Point } from '../src/diagram/types.js'; +import type { El } from '../src/model/moddle.js'; import type { Op } from '../src/ops/types.js'; -import { mutateDoc, type MutationResult } from '../src/pipeline.js'; +import { mutateDoc, type MutationResult } from '../src/pipeline/index.js'; const HERE = dirname(fileURLToPath(import.meta.url)); const fixture = (name: string): string => readFileSync(join(HERE, 'fixtures', 'incremental', name), 'utf8'); diff --git a/test/diagram-route-labels.test.ts b/test/diagram-route-labels.test.ts index 40ffe39d..9260cd1b 100644 --- a/test/diagram-route-labels.test.ts +++ b/test/diagram-route-labels.test.ts @@ -2,16 +2,16 @@ * Connections and labels in a kept drawing: src/diagram/reroute.ts (routing * one connection with the BPMN side conventions, deciding which kept * connections need a new route), src/diagram/labels.ts (label placement) - * and the text rendering of the layout block (src/format.ts renderLayout). + * and the text rendering of the layout block (src/report/view-text.ts renderLayout). */ import { describe, expect, it } from 'vitest'; import type { DEdge, DShape, Plane } from '../src/diagram/plane.js'; import { brokenEdge, edgeBefore, routeEdge, routingLines } from '../src/diagram/reroute.js'; import { crossings } from '../src/diagram/router.js'; import { clearTitles, labelAt, placeEdgeLabel, placeShapeLabel, refitLabel } from '../src/diagram/labels.js'; -import { renderLayout } from '../src/format.js'; -import { Doc } from '../src/document.js'; -import type { El } from '../src/model.js'; +import { renderLayout } from '../src/report/view-text.js'; +import { Doc } from '../src/model/document.js'; +import type { El } from '../src/model/moddle.js'; /** A real element for `type` with `name` (labels read the name, routing the type). */ const els = Doc.create({ processId: 'P' }); diff --git a/test/diagram-router.test.ts b/test/diagram-router.test.ts index 5ba23990..db9ca13c 100644 --- a/test/diagram-router.test.ts +++ b/test/diagram-router.test.ts @@ -10,7 +10,7 @@ */ import { describe, expect, it } from 'vitest'; import { attachedSide, defaultSides, routeOrthogonal, type RouteRequest, type Side } from '../src/diagram/router.js'; -import type { Box, Point } from '../src/layout/types.js'; +import type { Box, Point } from '../src/diagram/types.js'; const box = (x: number, y: number, width = 100, height = 80): Box => ({ x, y, width, height }); const TASK_OUT = defaultSides('task', 'source'); diff --git a/test/diagram-space.test.ts b/test/diagram-space.test.ts index f352c1ad..232ee943 100644 --- a/test/diagram-space.test.ts +++ b/test/diagram-space.test.ts @@ -4,8 +4,8 @@ * src/diagram/separate.ts (local overlap removal, tidy). */ import { describe, expect, it } from 'vitest'; -import type { Box, Point } from '../src/layout/types.js'; -import type { El } from '../src/model.js'; +import type { Box, Point } from '../src/diagram/types.js'; +import type { El } from '../src/model/moddle.js'; import type { DEdge, DShape, Plane } from '../src/diagram/plane.js'; import { closeStrip, fitInFrame, makeSpace, shiftShape } from '../src/diagram/space.js'; import { separate, tidy } from '../src/diagram/separate.js'; diff --git a/test/drawn-ids.test.ts b/test/drawn-ids.test.ts index f2674cf2..122d682c 100644 --- a/test/drawn-ids.test.ts +++ b/test/drawn-ids.test.ts @@ -7,10 +7,10 @@ */ import { describe, expect, it } from 'vitest'; import { applyToXml, layoutXml } from '../src/api.js'; -import { Doc } from '../src/document.js'; -import { parseXml } from '../src/model.js'; -import { mutateDoc } from '../src/pipeline.js'; -import { mutationSummary, renderMutation, renderSummary } from '../src/report.js'; +import { Doc } from '../src/model/document.js'; +import { parseXml } from '../src/model/moddle.js'; +import { mutateDoc } from '../src/pipeline/index.js'; +import { mutationSummary, renderMutation, renderSummary } from '../src/report/command-report.js'; const NS = 'xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"'; const defs = (body: string): string => ` diff --git a/test/format-frames.test.ts b/test/format-frames.test.ts index 0cc20958..10166b74 100644 --- a/test/format-frames.test.ts +++ b/test/format-frames.test.ts @@ -11,12 +11,12 @@ import { readFileSync } from 'node:fs'; import { join } from 'node:path'; import { describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; +import { Doc } from '../src/model/document.js'; import { readPlanes, semantics } from '../src/diagram/plane.js'; import { inside } from '../src/diagram/geom.js'; -import { isCliError } from '../src/errors.js'; +import { isCliError } from '../src/shared/errors.js'; import type { Op } from '../src/ops/types.js'; -import { mutateDoc, type MutationResult } from '../src/pipeline.js'; +import { mutateDoc, type MutationResult } from '../src/pipeline/index.js'; /** S -> Sub (S1 -> T1 -> E1) -> G -> B -> E, G -> C -> E2: the sub-process's end event E1 lies left of the outer end events. */ const MODEL: Op[] = [ diff --git a/test/helpers.ts b/test/helpers.ts index a3feeb4b..ffaa5fa9 100644 --- a/test/helpers.ts +++ b/test/helpers.ts @@ -1,4 +1,4 @@ -import { Doc } from '../src/document.js'; +import { Doc } from '../src/model/document.js'; export const BPMN_NS = 'http://www.omg.org/spec/BPMN/20100524/MODEL'; diff --git a/test/isomorphic.test.ts b/test/isomorphic.test.ts index 35a0dcd5..272ebd97 100644 --- a/test/isomorphic.test.ts +++ b/test/isomorphic.test.ts @@ -262,7 +262,7 @@ describe('the engine rules load on demand, only for their platform (an ESM split beforeAll(async () => { bundle = await bundleCore({ entry: join('src', 'index.ts'), splitting: true, minify: false }); expect(bundle.violations).toEqual([]); - const profileOf = (c: Chunk): 'c7' | 'c8' | undefined => (c.inputs.includes('src/platform/c7.ts') ? 'c7' : c.inputs.includes('src/platform/c8.ts') ? 'c8' : undefined); + const profileOf = (c: Chunk): 'c7' | 'c8' | undefined => (c.inputs.includes('src/platform/profiles/c7.ts') ? 'c7' : c.inputs.includes('src/platform/profiles/c8.ts') ? 'c8' : undefined); files = bundle.chunks.map((c) => { const text = c.text.replace(/(["'])\.\/([\w.-]+)\.js\1/g, (_m, q: string, name: string) => `${q}./${name}.mjs${q}`); return { name: basename(c.path).replace(/\.js$/, '.mjs'), text: `(globalThis.${LOADS} ??= []).push(import.meta.url);\n${text}`, profile: profileOf(c) }; @@ -303,7 +303,7 @@ describe('the engine rules load on demand, only for their platform (an ESM split it('the entry chunk is the one of the requested entry, though esbuild makes every import() target an entry point', () => { expect(bundle.chunks.filter((c) => c.entry).map((c) => c.entryPoint)).toEqual(['src/index.ts']); expect(bundle.entry.entryPoint).toBe('src/index.ts'); - expect(bundle.chunks.map((c) => c.entryPoint)).toEqual(expect.arrayContaining(['src/platform/c7.ts', 'src/platform/c8.ts'])); + expect(bundle.chunks.map((c) => c.entryPoint)).toEqual(expect.arrayContaining(['src/platform/profiles/c7.ts', 'src/platform/profiles/c8.ts'])); }); it('the rule chunks import nothing the entry loads (a host whose entry module awaits a call at top level does not wait for itself)', () => { @@ -321,15 +321,15 @@ describe('the engine rules load on demand, only for their platform (an ESM split return seen; }; const core = reach('src/index.ts'); - expect(core.has('src/model.ts') && core.has('src/platform/profile.ts')).toBe(true); - for (const rules of ['src/platform/c7.ts', 'src/platform/c8.ts']) { + expect(core.has('src/model/moddle.ts') && core.has('src/platform/profiles/profile.ts')).toBe(true); + for (const rules of ['src/platform/profiles/c7.ts', 'src/platform/profiles/c8.ts']) { const own = [...reach(rules)]; expect(own.filter((f) => core.has(f)), rules).toEqual([]); expect(own.flatMap((f) => bundle.graph[f] ?? []).filter((g) => core.has(g)), rules).toEqual([]); const chunk = bundle.chunks.find((c) => c.inputs.includes(rules))!; expect(chunk.imports.filter((p) => initial.has(p)), rules).toEqual([]); } - expect(bundle.chunks.find((c) => c.inputs.includes('src/platform/c8.ts'))!.inputs).toEqual(expect.arrayContaining(['src/platform/feel.ts', 'src/platform/schema-text.ts'])); + expect(bundle.chunks.find((c) => c.inputs.includes('src/platform/profiles/c8.ts'))!.inputs).toEqual(expect.arrayContaining(['src/platform/profiles/feel.ts', 'src/platform/profiles/schema-text.ts'])); }); it('the instances load natively and record what they evaluate', async () => { diff --git a/test/keep-flow-ids.test.ts b/test/keep-flow-ids.test.ts index 3a930a84..7faea2ea 100644 --- a/test/keep-flow-ids.test.ts +++ b/test/keep-flow-ids.test.ts @@ -11,15 +11,15 @@ import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; import { describe, expect, it } from 'vitest'; import { applyToXml, layoutXml, newXml } from '../src/api.js'; -import { Doc } from '../src/document.js'; -import type { El } from '../src/model.js'; -import type { Warning } from '../src/errors.js'; +import { Doc } from '../src/model/document.js'; +import type { El } from '../src/model/moddle.js'; +import type { Warning } from '../src/shared/errors.js'; import { idNamesEnds } from '../src/ops/flows.js'; import { runOp, runOps } from '../src/ops/index.js'; import type { Op } from '../src/ops/types.js'; -import { mutateDoc } from '../src/pipeline.js'; -import { renderMutation } from '../src/report.js'; -import type { ChangeSet } from '../src/result.js'; +import { mutateDoc } from '../src/pipeline/index.js'; +import { renderMutation } from '../src/report/command-report.js'; +import type { ChangeSet } from '../src/model/change-set.js'; import { definitionsXml, flowBetween } from './helpers.js'; /** A file of the default style with `_di` DI (`bpmn`: the engine's `BPMNShape_`): start -> Check -> Ok? -> Book (default) -> Done. */ diff --git a/test/lane-splice.test.ts b/test/lane-splice.test.ts index 99a0ffaa..00b93e22 100644 --- a/test/lane-splice.test.ts +++ b/test/lane-splice.test.ts @@ -6,7 +6,7 @@ */ import { describe, expect, it } from 'vitest'; import { applyToXml, newXml } from '../src/api.js'; -import { Doc } from '../src/document.js'; +import { Doc } from '../src/model/document.js'; import { laneOf } from '../src/ops/containers.js'; interface Box { diff --git a/test/layout-batch-parity.test.ts b/test/layout-batch-parity.test.ts index b21a530c..f1c39ec8 100644 --- a/test/layout-batch-parity.test.ts +++ b/test/layout-batch-parity.test.ts @@ -32,7 +32,7 @@ import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { afterAll, describe, expect, it } from 'vitest'; import { applyToXml, metricsXml } from '../src/api.js'; -import { CliError } from '../src/errors.js'; +import { CliError } from '../src/shared/errors.js'; import { diffProblems, layoutProblemsOfXml } from '../src/diagram/metrics.js'; const ROOT = join(import.meta.dirname, '..'); diff --git a/test/layout.test.ts b/test/layout.test.ts index ea3b9667..00c2f196 100644 --- a/test/layout.test.ts +++ b/test/layout.test.ts @@ -32,19 +32,19 @@ import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'; import { join } from 'node:path'; import { describe, expect, it } from 'vitest'; -import { withLayoutDebug } from '../src/debug.js'; +import { withLayoutDebug } from '../src/shared/debug.js'; import { layoutProblems } from '../src/diagram/metrics.js'; import { readPlanes as diagramPlanes, type DShape } from '../src/diagram/plane.js'; import { titleBox } from '../src/diagram/text.js'; -import { Doc } from '../src/document.js'; -import { layoutModel, type LayoutOptions, type LayoutWarningInfo } from '../src/layout.js'; -import { freeJoinColumns, gridScope, layoutScope, liftChains, placeAttachedArtifacts, shiftNode } from '../src/layout/place.js'; -import type { GNode, ScopeLayout } from '../src/layout/types.js'; -import { is, many, type El } from '../src/model.js'; +import { Doc } from '../src/model/document.js'; +import { layoutModel, type LayoutOptions, type LayoutWarningInfo } from '../src/layout/index.js'; +import { freeJoinColumns, gridScope, layoutScope, liftChains, placeAttachedArtifacts, shiftNode } from '../src/layout/clean/place.js'; +import type { GNode, ScopeLayout } from '../src/diagram/types.js'; +import { is, many, type El } from '../src/model/moddle.js'; import { collapsedIds } from '../src/ops/add.js'; import { runOps } from '../src/ops/index.js'; import type { AddOp, Op } from '../src/ops/types.js'; -import { layoutDoc, mutateDoc } from '../src/pipeline.js'; +import { layoutDoc, mutateDoc } from '../src/pipeline/index.js'; /* ------------------------------------------------------------------ */ /* DI reading */ diff --git a/test/move-lanes.test.ts b/test/move-lanes.test.ts index e89f63c6..657d242c 100644 --- a/test/move-lanes.test.ts +++ b/test/move-lanes.test.ts @@ -13,7 +13,7 @@ */ import { describe, expect, it } from 'vitest'; import { applyToXml, newXml } from '../src/api.js'; -import { Doc } from '../src/document.js'; +import { Doc } from '../src/model/document.js'; import { laneOf } from '../src/ops/containers.js'; interface Box { diff --git a/test/node-files.test.ts b/test/node-files.test.ts index 73169975..505d9895 100644 --- a/test/node-files.test.ts +++ b/test/node-files.test.ts @@ -10,8 +10,8 @@ import { join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; import * as node from '../src/node/index.js'; import { checkFile, layoutFile, loadDoc, mutateDocToFile, mutateFile, readDoc, readXml, writeAtomic } from '../src/node/files.js'; -import { Doc } from '../src/document.js'; -import { mutateDoc } from '../src/pipeline.js'; +import { Doc } from '../src/model/document.js'; +import { mutateDoc } from '../src/pipeline/index.js'; import { definitionsXml, LINEAR } from './helpers.js'; let dir: string; diff --git a/test/not-found.test.ts b/test/not-found.test.ts index 15ab02fd..d85f5076 100644 --- a/test/not-found.test.ts +++ b/test/not-found.test.ts @@ -6,8 +6,8 @@ */ import { describe, expect, it } from 'vitest'; import { applyToXml, newXml } from '../src/api.js'; -import { CliError } from '../src/errors.js'; -import { Doc } from '../src/document.js'; +import { CliError } from '../src/shared/errors.js'; +import { Doc } from '../src/model/document.js'; import { runOps } from '../src/ops/index.js'; async function invoice(): Promise { diff --git a/test/ops-create.test.ts b/test/ops-create.test.ts index d384301b..534e984e 100644 --- a/test/ops-create.test.ts +++ b/test/ops-create.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; -import { is, many, type El } from '../src/model.js'; +import { Doc } from '../src/model/document.js'; +import { is, many, type El } from '../src/model/moddle.js'; import { addElement, collapsedIds } from '../src/ops/add.js'; import { createDataAssociation, removeDataAssociation, PLACEHOLDER_PROPERTY } from '../src/ops/artifacts.js'; import { connectElements } from '../src/ops/connect.js'; @@ -8,10 +8,10 @@ import { assignLane, laneOf } from '../src/ops/containers.js'; import { applyTrigger, describeTrigger, triggerDetails } from '../src/ops/events.js'; import { splitFlow } from '../src/ops/split.js'; import type { AddOp, ConnectOp, SplitOp } from '../src/ops/types.js'; -import { BRANCH_FIELDS, NODE_FIELDS, parseOps } from '../src/batch.js'; -import type { CliError } from '../src/errors.js'; -import { mutateDoc } from '../src/pipeline.js'; -import { ChangeSet } from '../src/result.js'; +import { BRANCH_FIELDS, NODE_FIELDS, parseOps } from '../src/ops/batch.js'; +import type { CliError } from '../src/shared/errors.js'; +import { mutateDoc } from '../src/pipeline/index.js'; +import { ChangeSet } from '../src/model/change-set.js'; import { definitionsXml, docFromXml, flowBetween, linearDoc } from './helpers.js'; /* ------------------------------------------------------------------ */ @@ -81,7 +81,7 @@ const WITH_JOIN = definitionsXml(` `); -// mostly prefixed ids: its task Task_A makes new tasks Task_* (the file's id style, src/idstyle.ts) +// mostly prefixed ids: its task Task_A makes new tasks Task_* (the file's id style, src/ids/style.ts) const WITH_LANES = definitionsXml(` StartTask_A diff --git a/test/ops-mutate.test.ts b/test/ops-mutate.test.ts index 37ca5b67..56ece7be 100644 --- a/test/ops-mutate.test.ts +++ b/test/ops-mutate.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; -import { isCliError } from '../src/errors.js'; -import { is, many, type El } from '../src/model.js'; +import { Doc } from '../src/model/document.js'; +import { isCliError } from '../src/shared/errors.js'; +import { is, many, type El } from '../src/model/moddle.js'; import { assignLane } from '../src/ops/containers.js'; import { applyTrigger } from '../src/ops/events.js'; import { extensionOp, listExtensions } from '../src/ops/ext.js'; @@ -10,7 +10,7 @@ import { orderFlows } from '../src/ops/order.js'; import { cascadeRemove, removeElements } from '../src/ops/remove.js'; import { retypeElement } from '../src/ops/retype.js'; import { expansionRequests, readProperties, renameId, requestedExpansion, setProperties, SET_KEYS } from '../src/ops/set.js'; -import { ChangeSet } from '../src/result.js'; +import { ChangeSet } from '../src/model/change-set.js'; import { definitionsXml, docFromXml, linearDoc } from './helpers.js'; /* ------------------------------------------------------------------ */ diff --git a/test/remove-branch.test.ts b/test/remove-branch.test.ts index dd9c294b..9a06f9c3 100644 --- a/test/remove-branch.test.ts +++ b/test/remove-branch.test.ts @@ -5,8 +5,8 @@ */ import { describe, expect, it } from 'vitest'; import { applyToXml } from '../src/api.js'; -import { CliError } from '../src/errors.js'; -import { Doc } from '../src/document.js'; +import { CliError } from '../src/shared/errors.js'; +import { Doc } from '../src/model/document.js'; import { runOps } from '../src/ops/index.js'; import { branchOf } from '../src/ops/remove.js'; import { definitionsXml } from './helpers.js'; diff --git a/test/remove-join.test.ts b/test/remove-join.test.ts index 0c6af8e6..afb0c7ed 100644 --- a/test/remove-join.test.ts +++ b/test/remove-join.test.ts @@ -9,8 +9,8 @@ */ import { describe, expect, it } from 'vitest'; import { applyToXml } from '../src/api.js'; -import { CliError } from '../src/errors.js'; -import { Doc } from '../src/document.js'; +import { CliError } from '../src/shared/errors.js'; +import { Doc } from '../src/model/document.js'; import { runOps } from '../src/ops/index.js'; import { definitionsXml } from './helpers.js'; diff --git a/test/render-agent.test.ts b/test/render-agent.test.ts index be6ab3ab..1258603f 100644 --- a/test/render-agent.test.ts +++ b/test/render-agent.test.ts @@ -11,16 +11,16 @@ import { copyFileSync, existsSync, mkdtempSync, readdirSync, readFileSync, rmSyn import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; -import { aroundView } from '../src/context.js'; -import { Doc } from '../src/document.js'; +import { aroundView } from '../src/query/context.js'; +import { Doc } from '../src/model/document.js'; import { layoutProblems, locateProblems, type LayoutProblem } from '../src/diagram/metrics.js'; import { readPlanes, type Plane } from '../src/diagram/plane.js'; -import { changeHighlight, HALO_COLORS, MIN_LABEL_SCALE, renderDocSvg, renderSvg } from '../src/diagram/render.js'; -import { pathOf } from '../src/diagram/select.js'; +import { changeHighlight, HALO_COLORS, MIN_LABEL_SCALE, renderDocSvg, renderSvg } from '../src/render/index.js'; +import { pathOf } from '../src/query/select.js'; import { CliError, parseOps, mutateDoc } from '../src/index.js'; -import { is } from '../src/model.js'; +import { is } from '../src/model/moddle.js'; import { renderPng } from '../src/node/render.js'; -import { mutationReport } from '../src/report.js'; +import { mutationReport } from '../src/report/command-report.js'; // @ts-expect-error plain ESM tooling without type declarations import { libExecutor } from '../tools/fuzz/lib/exec.mjs'; // @ts-expect-error plain ESM tooling without type declarations @@ -313,7 +313,7 @@ describe('tiles', () => { next = t.columns![1] + 1; } const doc = await Doc.fromXml(xml); - const columns = (await import('../src/diagram/view.js')).layoutView(doc.definitions).diagrams[0]!.columns; + const columns = (await import('../src/query/layout-view.js')).layoutView(doc.definitions).diagrams[0]!.columns; expect(next).toBe(columns); expect(r.svg).toBe(r.tiles![0]!.svg); expect(r.notes.join('\n')).toMatch(new RegExp(`split into ${r.tiles!.length} tiles at the diagram's columns`)); diff --git a/test/render-fixes.test.ts b/test/render-fixes.test.ts index d833655c..99a6f460 100644 --- a/test/render-fixes.test.ts +++ b/test/render-fixes.test.ts @@ -13,9 +13,9 @@ import { mkdtempSync, readFileSync, rmSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; +import { Doc } from '../src/model/document.js'; import { layoutProblems } from '../src/diagram/metrics.js'; -import { MAX_TILES, MIN_LABEL_SCALE, renderSvg, scaleText } from '../src/diagram/render.js'; +import { MAX_TILES, MIN_LABEL_SCALE, renderSvg, scaleText } from '../src/render/index.js'; import { textWidth } from '../src/diagram/text.js'; import { rasterize } from '../src/node/render.js'; diff --git a/test/render.test.ts b/test/render.test.ts index 861c861c..befffd4d 100644 --- a/test/render.test.ts +++ b/test/render.test.ts @@ -1,6 +1,6 @@ /** * `bpmn render` (issue #12): the SVG renderer of the core - * (src/diagram/render.ts), the PNG rasteriser of the node layer + * (src/render/index.ts), the PNG rasteriser of the node layer * (src/node/render.ts: resvg-wasm with the bundled Arimo font) and the * command. Every scenario and fixture renders to SVG and PNG with the same * bytes twice; labels are laid out like bpmn-js; a rasteriser failure is @@ -13,9 +13,9 @@ import { existsSync, mkdtempSync, readdirSync, readFileSync, rmSync, statSync, w import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; -import { MIN_LABEL_SCALE, RENDER_MAX_SIZE, renderSvg } from '../src/diagram/render.js'; +import { MIN_LABEL_SCALE, RENDER_MAX_SIZE, renderSvg } from '../src/render/index.js'; import { innerLines, wrapLines } from '../src/diagram/text.js'; -import { CliError } from '../src/errors.js'; +import { CliError } from '../src/shared/errors.js'; import { rasterize, renderPng } from '../src/node/render.js'; // @ts-expect-error plain ESM tooling without type declarations import { bundleCore } from '../tools/iso/bundle.mjs'; @@ -244,7 +244,7 @@ describe('renderSvg', () => { expect(lean.chunks.flatMap((c: { inputs: string[] }) => c.inputs).filter((f: string) => /render/.test(f))).toEqual([]); // (not vacuous: an entry that imports renderSvg has it) const render = await bundleCore({ stdin: { contents: "export { renderSvg } from './src/index.ts';", sourcefile: 'render-only.ts' }, minify: false }); - expect(render.chunks.flatMap((c: { inputs: string[] }) => c.inputs)).toContain('src/diagram/render.ts'); + expect(render.chunks.flatMap((c: { inputs: string[] }) => c.inputs)).toContain('src/render/index.ts'); }, 60000); }); diff --git a/test/report-delta.test.ts b/test/report-delta.test.ts index 04e0f705..8237dfc6 100644 --- a/test/report-delta.test.ts +++ b/test/report-delta.test.ts @@ -8,7 +8,7 @@ import { readFileSync } from 'node:fs'; import { join } from 'node:path'; import { describe, expect, it } from 'vitest'; import { applyToXml, newXml } from '../src/api.js'; -import { mutationSummary, renderMutation, renderSummary, warningLines } from '../src/report.js'; +import { mutationSummary, renderMutation, renderSummary, warningLines } from '../src/report/command-report.js'; import { definitionsXml } from './helpers.js'; const ROOT = join(import.meta.dirname, '..'); diff --git a/test/roundtrip.test.ts b/test/roundtrip.test.ts index 0aed0b65..2e9c88f4 100644 --- a/test/roundtrip.test.ts +++ b/test/roundtrip.test.ts @@ -6,12 +6,12 @@ * - everything outside the changed elements keeps its text: prolog, * comments, the root tag with its namespace order, vendor attributes in * their place, CDATA, entities, quotes, indentation, the missing final - * line break (preserve.ts); + * line break (xml/preserve.ts); * - changed and new elements follow the file's style (attribute order, * indentation unit, `/>`, a CDATA section stays one); * - comments next to removed elements are reported, never dropped silently; * - incoming / outgoing lists are written the way the file keeps them - * (mirror.ts), never added for flows that did not change; + * (model/mirror.ts), never added for flows that did not change; * - the safety net: a text that would not read back as the changed model * falls back to bpmn-moddle's serialisation. * @@ -22,13 +22,13 @@ import { tmpdir } from 'node:os'; import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; -import { is, type El } from '../src/model.js'; +import { Doc } from '../src/model/document.js'; +import { is, type El } from '../src/model/moddle.js'; import type { Op } from '../src/ops/types.js'; import { mutateFile } from '../src/node/files.js'; -import { mutateDoc, type MutationOptions, type MutationResult } from '../src/pipeline.js'; -import { preserveText } from '../src/preserve.js'; -import { readXmlText, XmlTextError } from '../src/xmltext.js'; +import { mutateDoc, type MutationOptions, type MutationResult } from '../src/pipeline/index.js'; +import { preserveText } from '../src/xml/preserve.js'; +import { readXmlText, XmlTextError } from '../src/xml/text-reader.js'; import { definitionsXml } from './helpers.js'; const HERE = dirname(fileURLToPath(import.meta.url)); diff --git a/test/speaking-ids.test.ts b/test/speaking-ids.test.ts index 9d5e6c52..8a55fe3d 100644 --- a/test/speaking-ids.test.ts +++ b/test/speaking-ids.test.ts @@ -6,10 +6,10 @@ */ import { describe, expect, it } from 'vitest'; import { applyToXml, newXml } from '../src/api.js'; -import { Doc } from '../src/document.js'; +import { Doc } from '../src/model/document.js'; import { runOps } from '../src/ops/index.js'; import type { Op } from '../src/ops/types.js'; -import { mutationSummary, renderMutation, renderSummary } from '../src/report.js'; +import { mutationSummary, renderMutation, renderSummary } from '../src/report/command-report.js'; import { definitionsXml, flowBetween } from './helpers.js'; /** Hashes, numbers and tool defaults: what a generated id never ends in. */ diff --git a/test/step1-diagram.test.ts b/test/step1-diagram.test.ts index 1a8ec282..5475e470 100644 --- a/test/step1-diagram.test.ts +++ b/test/step1-diagram.test.ts @@ -20,17 +20,17 @@ import { tmpdir } from 'node:os'; import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; import { describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; +import { Doc } from '../src/model/document.js'; import { diffProblems, layoutProblems, layoutProblemsOfXml, locateProblems, WEIGHTS, type LayoutProblem, type MetricKey } from '../src/diagram/metrics.js'; import { readPlanes, type DEdge, type DShape, type Plane } from '../src/diagram/plane.js'; import { brokenEdge, detachedEnds, edgeBefore } from '../src/diagram/reroute.js'; import { makeSpace } from '../src/diagram/space.js'; import { writePlanes } from '../src/diagram/write.js'; -import { isCliError } from '../src/errors.js'; -import type { El } from '../src/model.js'; +import { isCliError } from '../src/shared/errors.js'; +import type { El } from '../src/model/moddle.js'; import type { Op } from '../src/ops/types.js'; import { mutateFile } from '../src/node/files.js'; -import { mutateDoc, type MutationOptions, type MutationResult } from '../src/pipeline.js'; +import { mutateDoc, type MutationOptions, type MutationResult } from '../src/pipeline/index.js'; import { definitionsXml } from './helpers.js'; const HERE = dirname(fileURLToPath(import.meta.url)); diff --git a/test/step1-engine.test.ts b/test/step1-engine.test.ts index 21f8c618..cfa1fb8f 100644 --- a/test/step1-engine.test.ts +++ b/test/step1-engine.test.ts @@ -13,9 +13,9 @@ import { readFileSync } from 'node:fs'; import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; import { describe, expect, it } from 'vitest'; -import { layoutModel, type LayoutOptions, type LayoutWarningInfo } from '../src/layout.js'; -import { poolOrder, routeMessageFlows, type MessageFlowJob, type MessagePool } from '../src/layout/messages.js'; -import { is, many, parseXml, type El, type Model } from '../src/model.js'; +import { layoutModel, type LayoutOptions, type LayoutWarningInfo } from '../src/layout/index.js'; +import { poolOrder, routeMessageFlows, type MessageFlowJob, type MessagePool } from '../src/layout/clean/messages.js'; +import { is, many, parseXml, type El, type Model } from '../src/model/moddle.js'; const HERE = dirname(fileURLToPath(import.meta.url)); const scenario = (name: string): string => readFileSync(join(HERE, '..', 'tools', 'scenarios', name), 'utf8'); diff --git a/test/step1-gate.test.ts b/test/step1-gate.test.ts index 07531f2e..789a6e8f 100644 --- a/test/step1-gate.test.ts +++ b/test/step1-gate.test.ts @@ -22,13 +22,13 @@ import { readFileSync } from 'node:fs'; import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; import { describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; +import { Doc } from '../src/model/document.js'; import { diffProblems, layoutProblems } from '../src/diagram/metrics.js'; import { readPlanes, type DShape } from '../src/diagram/plane.js'; -import type { El } from '../src/model.js'; +import type { El } from '../src/model/moddle.js'; import type { Op } from '../src/ops/types.js'; -import { mutateDoc, type MutationOptions, type MutationResult } from '../src/pipeline.js'; -import { validateDoc } from '../src/validate.js'; +import { mutateDoc, type MutationOptions, type MutationResult } from '../src/pipeline/index.js'; +import { validateDoc } from '../src/validate/structural.js'; const HERE = dirname(fileURLToPath(import.meta.url)); const HARD = new Set(['overlaps', 'through', 'missing', 'outsideLane', 'outsidePool', 'outsideSub', 'frameIntrusion', 'frameOverlap', 'degenerateEdge']); diff --git a/test/step1-semantic.test.ts b/test/step1-semantic.test.ts index d6f29de3..93c0defc 100644 --- a/test/step1-semantic.test.ts +++ b/test/step1-semantic.test.ts @@ -8,13 +8,13 @@ * - pre-existing validation errors do not block unrelated writes */ import { describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; -import { addTo } from '../src/model.js'; +import { Doc } from '../src/model/document.js'; +import { addTo } from '../src/model/moddle.js'; import { runOps } from '../src/ops/index.js'; -import { mutateDoc, type MutationOptions, type MutationResult } from '../src/pipeline.js'; +import { mutateDoc, type MutationOptions, type MutationResult } from '../src/pipeline/index.js'; import type { Op } from '../src/ops/types.js'; -import { validateDoc } from '../src/validate.js'; -import { elementDetail } from '../src/view.js'; +import { validateDoc } from '../src/validate/structural.js'; +import { elementDetail } from '../src/query/model-view.js'; import { definitionsXml } from './helpers.js'; const CAMUNDA = 'xmlns:camunda="http://camunda.org/schema/1.0/bpmn"'; diff --git a/test/step3-audit.test.ts b/test/step3-audit.test.ts index 5a98011f..091cc1f9 100644 --- a/test/step3-audit.test.ts +++ b/test/step3-audit.test.ts @@ -9,10 +9,10 @@ * missing, not by a whole column, when part of the room is free */ import { describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; +import { Doc } from '../src/model/document.js'; import { readPlanes, semantics, type DShape } from '../src/diagram/plane.js'; import { makeSpace } from '../src/diagram/space.js'; -import { mutateDoc } from '../src/pipeline.js'; +import { mutateDoc } from '../src/pipeline/index.js'; const NS = 'xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI"'; const sh = (id: string, x: number, y: number, w: number, h: number, extra = ''): string => ``; diff --git a/test/step3-c8-fixes.test.ts b/test/step3-c8-fixes.test.ts index 48103a9f..fda25b86 100644 --- a/test/step3-c8-fixes.test.ts +++ b/test/step3-c8-fixes.test.ts @@ -2,7 +2,7 @@ * Camunda 8 after the step 3 verifier round (each finding with a test that * failed before the fix): * - * - FEEL is parsed (src/platform/feel.ts): the 762 expressions of + * - FEEL is parsed (src/platform/profiles/feel.ts): the 762 expressions of * fixtures/c8/feel-verdicts.json were deployed to Camunda 8.9.22 as flow * conditions; the check agrees with the engine on every one (`&`, `|`, * `<>`, `>>`, `%`, if without else, AND, `:=` ... are refused; ranges, @@ -28,12 +28,12 @@ import { spawnSync } from 'node:child_process'; import { readFileSync } from 'node:fs'; import { join } from 'node:path'; import { describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; -import { guideText, KINDS_SECTION_NAMES, kindsSections } from '../src/guide.js'; +import { Doc } from '../src/model/document.js'; +import { guideText, KINDS_SECTION_NAMES, kindsSections } from '../src/report/guide.js'; import { runOps } from '../src/ops/index.js'; -import { mutateDoc } from '../src/pipeline.js'; -import { feelProblem, validCycle, validDateTime, validDuration } from '../src/platform/c8.js'; -import { loadProfiles, runProfile } from '../src/platform/profile.js'; +import { mutateDoc } from '../src/pipeline/index.js'; +import { feelProblem, validCycle, validDateTime, validDuration } from '../src/platform/profiles/c8.js'; +import { loadProfiles, runProfile } from '../src/platform/profiles/profile.js'; // the engine rules load on demand; runProfile / validateDoc(doc, { platform }) need them loaded (the pipeline loads them itself) await loadProfiles(); diff --git a/test/step3-compact.test.ts b/test/step3-compact.test.ts index 12c67a16..007508a3 100644 --- a/test/step3-compact.test.ts +++ b/test/step3-compact.test.ts @@ -1,6 +1,6 @@ /** - * Step 3: closing empty space in a kept drawing (src/diagram/compact.ts and - * the `compact` / negative `space` format ops in src/diagram/ops.ts). + * Step 3: closing empty space in a kept drawing (src/format/compact.ts and + * the `compact` / negative `space` format ops in src/format/index.ts). * * - compact closes empty columns and rows and shrinks lanes, pools and * expanded sub-processes to their content, keeping the order; it never @@ -15,13 +15,13 @@ * keeps them (see test/diagram-format.test.ts), or written by hand. */ import { describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; +import { Doc } from '../src/model/document.js'; import { layoutProblems } from '../src/diagram/metrics.js'; import { readPlanes, type DEdge, type DShape } from '../src/diagram/plane.js'; -import { isCliError } from '../src/errors.js'; -import type { El } from '../src/model.js'; +import { isCliError } from '../src/shared/errors.js'; +import type { El } from '../src/model/moddle.js'; import type { Op } from '../src/ops/types.js'; -import { mutateDoc, type MutationResult } from '../src/pipeline.js'; +import { mutateDoc, type MutationResult } from '../src/pipeline/index.js'; import { definitionsXml } from './helpers.js'; const BASE: Op[] = [ diff --git a/test/step3-fixes-integration.test.ts b/test/step3-fixes-integration.test.ts index d48449ce..bcaf6b3a 100644 --- a/test/step3-fixes-integration.test.ts +++ b/test/step3-fixes-integration.test.ts @@ -6,8 +6,8 @@ */ import { describe, expect, it } from 'vitest'; import { applyToXml, newXml } from '../src/api.js'; -import { CliError } from '../src/errors.js'; -import { mutationSummary, renderSummary } from '../src/report.js'; +import { CliError } from '../src/shared/errors.js'; +import { mutationSummary, renderSummary } from '../src/report/command-report.js'; async function rejection(p: Promise): Promise { try { diff --git a/test/step3-followups-c8.test.ts b/test/step3-followups-c8.test.ts index 2ad0b607..6480618f 100644 --- a/test/step3-followups-c8.test.ts +++ b/test/step3-followups-c8.test.ts @@ -17,9 +17,9 @@ */ import { describe, expect, it } from 'vitest'; import { validateXml } from '../src/api.js'; -import { Doc } from '../src/document.js'; -import { cronProblem, dateTimeRangeProblem, validCycle, validDateTime } from '../src/platform/c8.js'; -import { loadProfiles, runProfile } from '../src/platform/profile.js'; +import { Doc } from '../src/model/document.js'; +import { cronProblem, dateTimeRangeProblem, validCycle, validDateTime } from '../src/platform/profiles/c8.js'; +import { loadProfiles, runProfile } from '../src/platform/profiles/profile.js'; // the engine rules load on demand; runProfile / validateDoc(doc, { platform }) need them loaded (the pipeline loads them itself) await loadProfiles(); diff --git a/test/step3-followups-ids.test.ts b/test/step3-followups-ids.test.ts index 2a255a82..6bf93828 100644 --- a/test/step3-followups-ids.test.ts +++ b/test/step3-followups-ids.test.ts @@ -6,8 +6,8 @@ */ import { describe, expect, it } from 'vitest'; import { applyToXml, newXml } from '../src/api.js'; -import { MAX_ID } from '../src/ids.js'; -import { speakingStem } from '../src/idstyle.js'; +import { MAX_ID } from '../src/ids/slugs.js'; +import { speakingStem } from '../src/ids/style.js'; const flowIds = (xml: string): string[] => [...xml.matchAll(/ m[1]!); const allIds = (xml: string): string[] => [...xml.matchAll(/ id="([^"]+)"/g)].map((m) => m[1]!); diff --git a/test/step3-followups-ops.test.ts b/test/step3-followups-ops.test.ts index 322b6867..8f40ce4e 100644 --- a/test/step3-followups-ops.test.ts +++ b/test/step3-followups-ops.test.ts @@ -21,9 +21,9 @@ import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; import { applyToXml, newXml } from '../src/api.js'; -import { parseOps } from '../src/batch.js'; -import { CliError } from '../src/errors.js'; -import { Doc } from '../src/document.js'; +import { parseOps } from '../src/ops/batch.js'; +import { CliError } from '../src/shared/errors.js'; +import { Doc } from '../src/model/document.js'; import { parseSpaceAmount } from '../src/ops/types.js'; const ROOT = join(import.meta.dirname, '..'); diff --git a/test/step3-ids-report.test.ts b/test/step3-ids-report.test.ts index 70bc77ec..882305c1 100644 --- a/test/step3-ids-report.test.ts +++ b/test/step3-ids-report.test.ts @@ -9,14 +9,14 @@ */ import { describe, expect, it } from 'vitest'; import { applyToXml, newXml, validateXml } from '../src/api.js'; -import { Doc } from '../src/document.js'; -import { conventionsView } from '../src/conventions.js'; -import { ID_CONVENTIONS } from '../src/guide.js'; -import { cutAt, cutName, IdRegistry, idWords, isFiller, keptTail, MAX_ID, slugify, snakeSlug, transliterate } from '../src/ids.js'; -import { connectionRequest, IdStyle, kindRequest } from '../src/idstyle.js'; -import { kindByName } from '../src/kinds.js'; +import { Doc } from '../src/model/document.js'; +import { conventionsView } from '../src/ids/conventions.js'; +import { ID_CONVENTIONS } from '../src/report/guide.js'; +import { cutAt, cutName, IdRegistry, idWords, isFiller, keptTail, MAX_ID, slugify, snakeSlug, transliterate } from '../src/ids/slugs.js'; +import { connectionRequest, IdStyle, kindRequest } from '../src/ids/style.js'; +import { kindByName } from '../src/model/kinds.js'; import { runOps } from '../src/ops/index.js'; -import { mutationSummary, renderMutation, renderSummary } from '../src/report.js'; +import { mutationSummary, renderMutation, renderSummary } from '../src/report/command-report.js'; import { definitionsXml, flowBetween } from './helpers.js'; const ids = (xml: string): string[] => [...xml.matchAll(/ m[1]!); diff --git a/test/step3-integration.test.ts b/test/step3-integration.test.ts index 4788a8be..2e077735 100644 --- a/test/step3-integration.test.ts +++ b/test/step3-integration.test.ts @@ -4,8 +4,8 @@ */ import { describe, expect, it } from 'vitest'; import { applyToXml, newXml, showXml } from '../src/api.js'; -import { CliError } from '../src/errors.js'; -import { mutationSummary, renderSummary } from '../src/report.js'; +import { CliError } from '../src/shared/errors.js'; +import { mutationSummary, renderSummary } from '../src/report/command-report.js'; /** The bounds of an element's shape. */ function bounds(xml: string, id: string): { x: number; y: number; width: number; height: number } { diff --git a/test/step3-order.test.ts b/test/step3-order.test.ts index 9ca11acd..4d8f8055 100644 --- a/test/step3-order.test.ts +++ b/test/step3-order.test.ts @@ -1,6 +1,6 @@ /** * Step 3: pool order (`order `, - * src/ops/order.ts and src/diagram/ops.ts orderPoolBands): the participants + * src/ops/order.ts and src/format/index.ts orderPoolBands): the participants * of a collaboration are reordered top to bottom, black-box partner pools * included; a kept drawing gets its pool bands restacked with their content * and the message flows routed again. @@ -10,14 +10,14 @@ import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { spawnSync } from 'node:child_process'; import { describe, expect, it } from "vitest"; -import { parseOps } from '../src/batch.js'; -import { Doc } from '../src/document.js'; +import { parseOps } from '../src/ops/batch.js'; +import { Doc } from '../src/model/document.js'; import { layoutProblems } from '../src/diagram/metrics.js'; import { readPlanes, type DEdge, type DShape } from '../src/diagram/plane.js'; -import { isCliError } from '../src/errors.js'; -import type { El } from '../src/model.js'; +import { isCliError } from '../src/shared/errors.js'; +import type { El } from '../src/model/moddle.js'; import type { Op } from '../src/ops/types.js'; -import { mutateDoc, type MutationResult } from '../src/pipeline.js'; +import { mutateDoc, type MutationResult } from '../src/pipeline/index.js'; const OPS: Op[] = [ { op: 'add', kind: 'startEvent', id: 'S', name: 'Start' }, diff --git a/test/step3-select.test.ts b/test/step3-select.test.ts index 6da0bf90..a60ee7e0 100644 --- a/test/step3-select.test.ts +++ b/test/step3-select.test.ts @@ -1,5 +1,5 @@ /** - * Step 3: selectors of the format ops (src/diagram/select.ts): `path` + * Step 3: selectors of the format ops (src/query/select.ts): `path` * (with `via`), `kind` and `branch` name the elements of place / align / * color / tidy, so a happy path is coloured, every end event aligned or a * branch moved in one call. Elements are addressed by id only. @@ -9,14 +9,14 @@ import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { describe, expect, it } from 'vitest'; -import { parseOps } from '../src/batch.js'; -import { Doc } from '../src/document.js'; -import { layoutView } from '../src/diagram/view.js'; +import { parseOps } from '../src/ops/batch.js'; +import { Doc } from '../src/model/document.js'; +import { layoutView } from '../src/query/layout-view.js'; import { readPlanes, type DShape } from '../src/diagram/plane.js'; -import { isCliError } from '../src/errors.js'; -import type { El } from '../src/model.js'; +import { isCliError } from '../src/shared/errors.js'; +import type { El } from '../src/model/moddle.js'; import type { Op } from '../src/ops/types.js'; -import { mutateDoc, type MutationResult } from '../src/pipeline.js'; +import { mutateDoc, type MutationResult } from '../src/pipeline/index.js'; const BASE: Op[] = [ { op: 'add', kind: 'startEvent', id: 'S', name: 'Start' }, diff --git a/test/step3-view.test.ts b/test/step3-view.test.ts index 51e78f5a..0bb8e866 100644 --- a/test/step3-view.test.ts +++ b/test/step3-view.test.ts @@ -1,15 +1,15 @@ /** * Step 3: what `show --layout` tells an agent about x positions (columns, * wide gaps, rows that hold unrelated clusters) and the drawing-quality - * problem kinds in a real write (src/diagram/view.ts, metrics.ts). + * problem kinds in a real write (src/query/layout-view.ts, metrics.ts). */ import { describe, expect, it } from 'vitest'; -import { Doc } from '../src/document.js'; -import { layoutView } from '../src/diagram/view.js'; -import { renderLayoutView } from '../src/format.js'; -import type { El } from '../src/model.js'; +import { Doc } from '../src/model/document.js'; +import { layoutView } from '../src/query/layout-view.js'; +import { renderLayoutView } from '../src/report/view-text.js'; +import type { El } from '../src/model/moddle.js'; import type { Op } from '../src/ops/types.js'; -import { mutateDoc } from '../src/pipeline.js'; +import { mutateDoc } from '../src/pipeline/index.js'; const BASE: Op[] = [ { op: 'add', kind: 'startEvent', id: 'S', name: 'Start' }, diff --git a/test/subprocess-titles.test.ts b/test/subprocess-titles.test.ts index afc31417..ab27ca76 100644 --- a/test/subprocess-titles.test.ts +++ b/test/subprocess-titles.test.ts @@ -31,9 +31,9 @@ import { describe, expect, it } from 'vitest'; import { applyToXml, metricsXml, newXml } from '../src/api.js'; import { layoutProblems, locateProblems } from '../src/diagram/metrics.js'; -import { renderSvg } from '../src/diagram/render.js'; +import { renderSvg } from '../src/render/index.js'; import { titleBox } from '../src/diagram/text.js'; -import { parseXml } from '../src/model.js'; +import { parseXml } from '../src/model/moddle.js'; interface Box { x: number; diff --git a/test/validate.test.ts b/test/validate.test.ts index 6a833120..56bb8c9f 100644 --- a/test/validate.test.ts +++ b/test/validate.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest'; -import type { Doc } from '../src/document.js'; -import { addTo, removeFrom } from '../src/model.js'; -import { flowOrder, repairFlowLinks, validateDoc } from '../src/validate.js'; +import type { Doc } from '../src/model/document.js'; +import { addTo, removeFrom } from '../src/model/moddle.js'; +import { flowOrder, repairFlowLinks, validateDoc } from '../src/validate/structural.js'; import { BPMN_NS, definitionsXml, docFromXml, linearDoc } from './helpers.js'; /* ------------------------------------------------------------------ */ @@ -256,7 +256,7 @@ describe('structural errors', () => { `), ); - // Doc.fromXml completes the lists in memory (a write keeps the file's own, see mirror.ts) + // Doc.fromXml completes the lists in memory (a write keeps the file's own, see model/mirror.ts) expect(doc.source?.mirror.listed.has(doc.require('Start'))).toBe(false); expect(codes(doc)).toEqual({ errors: [], warnings: [] }); const id = (el: { get: (k: string) => T }) => el.get('id'); diff --git a/test/validators.test.ts b/test/validators.test.ts index 74b06ec6..5596ffe5 100644 --- a/test/validators.test.ts +++ b/test/validators.test.ts @@ -1,5 +1,5 @@ /** - * The validator hook (src/validators.ts): MutationOptions.validators on + * The validator hook (src/validate/validators.ts): MutationOptions.validators on * writes, CheckOptions.validators on validate. A validator sees the candidate * XML after the layout and the format ops; errors a change introduces block * the write, errors the file already had do not (all models synthetic). The @@ -12,15 +12,15 @@ import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; import { validateXml } from '../src/api.js'; -import { Doc } from '../src/document.js'; -import { ERROR_CATALOGUE } from '../src/guide.js'; -import type { CliError, Warning } from '../src/errors.js'; -import { is, type El } from '../src/model.js'; +import { Doc } from '../src/model/document.js'; +import { ERROR_CATALOGUE } from '../src/report/guide.js'; +import type { CliError, Warning } from '../src/shared/errors.js'; +import { is, type El } from '../src/model/moddle.js'; import type { Op } from '../src/ops/types.js'; import { checkFile, mutateFile } from '../src/node/files.js'; -import { mutateDoc, type MutationOptions } from '../src/pipeline.js'; -import { mutationReport, mutationSummary, renderMutation, renderSummary, renderValidation, validationReport, validatorTag } from '../src/report.js'; -import { compareRuns, runValidators, validatorRefusal, type NamedValidator, type ValidatorContext, type ValidatorFinding, type ValidatorRun } from '../src/validators.js'; +import { mutateDoc, type MutationOptions } from '../src/pipeline/index.js'; +import { mutationReport, mutationSummary, renderMutation, renderSummary, renderValidation, validationReport, validatorTag } from '../src/report/command-report.js'; +import { compareRuns, runValidators, validatorRefusal, type NamedValidator, type ValidatorContext, type ValidatorFinding, type ValidatorRun } from '../src/validate/validators.js'; const ROOT = join(import.meta.dirname, '..'); const NS = 'xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"'; @@ -208,7 +208,7 @@ describe('host validators on mutations (MutationOptions.validators)', () => { it('checks what would be written: without the layout a new node has no shape', async () => { const file = await drawn('no-layout.bpmn', LINE); const r = await refusal(file, [{ op: 'add', kind: 'task', name: 'Inserted', after: 'A' }], { validators: [shapes], layout: false }); - // the new flow's id in the file's style (src/idstyle.ts): LINE numbers its flows F1, F2 (the prefix), the body names the ends + // the new flow's id in the file's style (src/ids/style.ts): LINE numbers its flows F1, F2 (the prefix), the body names the ends expect(codes(r.errors)).toEqual(['[shapes] E_NOT_DRAWN Activity_Inserted', '[shapes] E_NOT_DRAWN F_InsertedToE']); expect((await mutateFile(file, [{ op: 'add', kind: 'task', name: 'Inserted', after: 'A' }], { validators: [shapes], dryRun: true })).validation.validators?.[0]?.errors).toEqual([]); }); @@ -220,7 +220,7 @@ describe('host validators on mutations (MutationOptions.validators)', () => { it('ruleId findings: an introduced ERROR blocks, a pre-existing one (matched by message, renames followed) does not', async () => { const file = await drawn('host.bpmn', LINE); const r = await refusal(file, [{ op: 'add', kind: 'task', after: 'A' }], { validators: [unnamedTasks] }); - // an unnamed task gets its placement as id (Activity_After, src/idstyle.ts) + // an unnamed task gets its placement as id (Activity_After, src/ids/style.ts) expect(r.errors).toEqual([{ code: 'naming/task', message: 'task Activity_AfterCheck has no name', validator: 'unnamedTasks', severity: 'error' }]); const unnamed = await drawn('host-unnamed.bpmn', LINE.replace(' name="Check"', '')); diff --git a/test/view.test.ts b/test/view.test.ts index 32f77280..439000c1 100644 --- a/test/view.test.ts +++ b/test/view.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest'; -import { ChangeSet } from '../src/result.js'; -import { renderChanges, renderDetail, renderProblems, renderView } from '../src/format.js'; -import { buildView, elementDetail, findElements, labelOf, type ViewNode } from '../src/view.js'; +import { ChangeSet } from '../src/model/change-set.js'; +import { renderChanges, renderDetail, renderProblems, renderView } from '../src/report/view-text.js'; +import { buildView, elementDetail, findElements, labelOf, type ViewNode } from '../src/query/model-view.js'; import { BPMN_NS, definitionsXml, docFromXml, linearDoc } from './helpers.js'; /* ------------------------------------------------------------------ */ diff --git a/test/views-context.test.ts b/test/views-context.test.ts index 192a8294..b6450287 100644 --- a/test/views-context.test.ts +++ b/test/views-context.test.ts @@ -9,8 +9,8 @@ */ import { describe, expect, it } from 'vitest'; import { showXml } from '../src/api.js'; -import { elementContext } from '../src/context.js'; -import { Doc } from '../src/document.js'; +import { elementContext } from '../src/query/context.js'; +import { Doc } from '../src/model/document.js'; /** * A shop pool (Process_Shop) between two black boxes (Customer, Bank). diff --git a/test/views.test.ts b/test/views.test.ts index ac54f18d..a10ce2da 100644 --- a/test/views.test.ts +++ b/test/views.test.ts @@ -8,9 +8,9 @@ import { readFileSync } from 'node:fs'; import { join } from 'node:path'; import { describe, expect, it } from 'vitest'; import { showXml, viewXml } from '../src/api.js'; -import { aroundView, elementContext, implementationOf } from '../src/context.js'; -import { Doc } from '../src/document.js'; -import { buildView, elementDetail } from '../src/view.js'; +import { aroundView, elementContext, implementationOf } from '../src/query/context.js'; +import { Doc } from '../src/model/document.js'; +import { buildView, elementDetail } from '../src/query/model-view.js'; const ROOT = join(import.meta.dirname, '..'); const CLAIMS = readFileSync(join(ROOT, 'test', 'fixtures', 'views', 'claims.bpmn'), 'utf8'); diff --git a/tools/fuzz/lib/generate.mjs b/tools/fuzz/lib/generate.mjs index ccf06685..f9e4b36a 100644 --- a/tools/fuzz/lib/generate.mjs +++ b/tools/fuzz/lib/generate.mjs @@ -5,7 +5,7 @@ * Contract * - `genStep(a, r, step, { semantic, format })` reads an analyse() result and * returns `{ name, ops }` or undefined (nothing applicable after 20 tries): - * `ops` is a batch in the JSON format of `bpmn apply` (src/batch.ts), so the + * `ops` is a batch in the JSON format of `bpmn apply` (src/ops/batch.ts), so the * same step runs through the CLI, through `apply` or in-process; `name` * is the generator (statistics, minimisation messages). Generators are * picked by weight; every random choice comes from `r`, so the same model, diff --git a/tools/fuzz/lib/setup.mjs b/tools/fuzz/lib/setup.mjs index 360c2e69..73ff476f 100644 --- a/tools/fuzz/lib/setup.mjs +++ b/tools/fuzz/lib/setup.mjs @@ -47,7 +47,7 @@ export async function loadMetrics() { export async function loadRender() { const lib = await importDist(join('node', 'render.js')); - const core = await importDist(join('diagram', 'render.js')); + const core = await importDist(join('render', 'index.js')); return { draw: (xml) => lib.renderPng(xml, { problems: true, tiles: true }), maxSize: core.RENDER_MAX_SIZE }; } diff --git a/tools/iso/bundle.mjs b/tools/iso/bundle.mjs index a5d18e11..9cef28d5 100644 --- a/tools/iso/bundle.mjs +++ b/tools/iso/bundle.mjs @@ -64,7 +64,7 @@ function esbuildOptions(opts, minify) { }; } -/** The module comments (`// src/model.ts`) of an unminified bundle with their offsets. */ +/** The module comments (`// src/model/moddle.ts`) of an unminified bundle with their offsets. */ function moduleMarks(code) { const marks = []; for (const m of code.matchAll(/^\s*\/\/ (\S+\.(?:[cm]?[jt]s|json))$/gm)) marks.push({ at: m.index, file: m[1] }); diff --git a/tools/iso/check.mjs b/tools/iso/check.mjs index db05f639..853cad65 100644 --- a/tools/iso/check.mjs +++ b/tools/iso/check.mjs @@ -11,7 +11,7 @@ * Buffer, global, require, __dirname, ...), naming the module; * - the bundle contains the node layer (dist/node/) or the CLI (dist/cli.js); * - a module of the engine rules that load on demand (ON_DEMAND: the - * Camunda 7 and Camunda 8 profile, src/platform/profile.ts LOADERS) is + * Camunda 7 and Camunda 8 profile, src/platform/profiles/profile.ts LOADERS) is * in the initial chunks of the whole entry or of the applyToXml-only * entry, naming the module, or is no chunk of its own; * - a module of those rules imports (statically, also through another @@ -19,7 +19,7 @@ * such a module into the host's entry chunk and make the rule chunk * import the entry chunk back, so a host whose entry module awaits a * Camunda 7 / 8 call at top level would wait forever (the rules get - * what they use of the core from src/platform/rule-kit.ts instead); + * what they use of the core from src/platform/profiles/rule-kit.ts instead); * - a size is over its budget in tools/iso/budget.json (KB = 1024 bytes, * minified and gzip: the initial chunks of both entries, the on-demand * rule chunks of both); raising a budget is an explicit diff of that file; @@ -48,8 +48,8 @@ const problems = []; /** What loads on demand, by the module that marks its chunk; `rules`: modules that must never be in the initial chunks. */ const ON_DEMAND = [ - { name: 'c7', label: 'Camunda 7 rules', marker: 'dist/platform/c7.js', rules: ['dist/platform/c7.js'], when: "the first Camunda 7 document a call validates (`loadProfile('c7')` prefetches it)" }, - { name: 'c8', label: 'Camunda 8 rules', marker: 'dist/platform/c8.js', rules: ['dist/platform/c8.js', 'dist/platform/feel.js', 'dist/platform/schema-text.js'], when: "the first Camunda 8 document a call validates (`loadProfile('c8')` prefetches it)" }, + { name: 'c7', label: 'Camunda 7 rules', marker: 'dist/platform/profiles/c7.js', rules: ['dist/platform/profiles/c7.js'], when: "the first Camunda 7 document a call validates (`loadProfile('c7')` prefetches it)" }, + { name: 'c8', label: 'Camunda 8 rules', marker: 'dist/platform/profiles/c8.js', rules: ['dist/platform/profiles/c8.js', 'dist/platform/profiles/feel.js', 'dist/platform/profiles/schema-text.js'], when: "the first Camunda 8 document a call validates (`loadProfile('c8')` prefetches it)" }, { name: 'bpmn-auto-layout', label: 'bpmn-auto-layout', marker: /node_modules\/bpmn-auto-layout\//, rules: [], when: "only for `engine: 'auto'`" }, ]; const ENTRIES = [ @@ -192,11 +192,11 @@ for (const entry of ENTRIES) { if (!s) continue; for (const part of ON_DEMAND) { for (const f of part.rules) { - if (s.initialModules.includes(f)) problems.push(`the initial chunks of ${entry.name} contain ${f}: the ${part.label} load on demand (only src/platform/profile.ts imports them, with import())`); + if (s.initialModules.includes(f)) problems.push(`the initial chunks of ${entry.name} contain ${f}: the ${part.label} load on demand (only src/platform/profiles/profile.ts imports them, with import())`); } if (part.rules.length && !s.onDemand.some((d) => d.name === part.name)) problems.push(`${entry.name} has no on-demand chunk with ${part.marker} (the ${part.label})`); for (const { from, to } of s.onDemand.find((d) => d.name === part.name)?.importsOfEntry ?? []) { - problems.push(`${from} imports ${to}, which ${entry.name} loads too: a host's bundler (Rollup / Vite) puts it into the entry chunk and makes the ${part.label} chunk import the entry chunk back, so a host whose entry module awaits a call at top level waits forever; hand it to the rules in src/platform/rule-kit.ts (RULE_KIT) instead of importing it`); + problems.push(`${from} imports ${to}, which ${entry.name} loads too: a host's bundler (Rollup / Vite) puts it into the entry chunk and makes the ${part.label} chunk import the entry chunk back, so a host whose entry module awaits a call at top level waits forever; hand it to the rules in src/platform/profiles/rule-kit.ts (RULE_KIT) instead of importing it`); } } overBudget(entry.name, s, budget.entries?.[entry.label]);