Repository navigation
Feat/policy level switcher - #261
pavelkornev wants to merge 26 commits into
Conversation
|
swennemers
left a comment
There was a problem hiding this comment.
+1 for the feature. Align the code with @Fannon
|
@Fannon please review |
fd47577 to
e54fc3a
Compare
|
At For example, existing consumers using: import type { OrdDocument, ApiResource } from "@open-resource-discovery/specification";fail with TS2724 against this PR because the exports become Proposed fix: 85c3e9f1. |
Policy levels (sap:base/documentation/core/dp) were documented on standalone pages separate from the Document spec they constrain. This adds an in-page single-select switcher on the ORD Document page that re-annotates the spec in place for the chosen level - swapping requirement badges, marking value-level constraints, and injecting policy notes - with the selection kept in the URL (?policy=) so links are shareable. Rules are authored as overlays on top of the default Document schema in spec-extension/policy-levels/*.overlay.yaml (validated against policy-overlay.schema.json). A build step (src/build/compilePolicyLevels.ts, wired into postgenerate) validates every overlay target against the real anchors emitted in Document.md (failing the build on any dangling target), compiles src/generated/policy-levels.json for the client, and regenerates the standalone policy pages from the same overlays (single source of truth). The client island (src/components/PolicyOverlay) applies the overlay to the rendered DOM, reusing the settle-detection in src/theme (contentStable.ts, extracted from Root.tsx). Signed-off-by: Simon Heimler <simon.heimler@sap.com> Signed-off-by: Pavel Kornev <pavel.kornev@sap.com>
Per review feedback, the policy content was dumped in a panel above the whole specification. Now each requirement renders where it applies: - propertyName rules (title / description / shortDescription constraints) inject a highlighted note at EVERY matching property row (e.g. all titles), so a requirement that applies to all titles is shown at each title - not a chip plus a panel entry. - general (document-wide) rules inject at the root "Ord Document" section, their natural in-place home. - property- and definition-scoped rules remain inline at their anchors. The top panel is reduced to a compact info bar (level, inheritance, link to the full policy page, badge legend, draft banner); the big rule lists and the property-name group dump are removed. badgeByAnchor/noteRulesByAnchor and the compiled types are updated accordingly. Signed-off-by: Simon Heimler <simon.heimler@sap.com>
…level - Inline policy notes injected as table rows no longer sit flush against the table border (the note-row cell now has a horizontal inset). - Each note is labelled with the authoring policy level's name (e.g. "SAP Base v1" / "SAP Documentation v1") instead of a generic "NOTE", so the reader sees which level the extra requirement comes from. The label is resolved at compile time via each rule's inheritedFrom and carried as CompiledRule.sourceTitle; it is styled as a small provenance tag. Signed-off-by: Simon Heimler <simon.heimler@sap.com>
Every inline policy note is now tagged with the currently selected policy level (e.g. "SAP Core v1"). When the requirement is inherited from an ancestor level, an additional italic "inherited from <level>" sub-label names its origin (e.g. "inherited from SAP Documentation v1"), making the provenance explicit instead of only showing the authoring level. Signed-off-by: Simon Heimler <simon.heimler@sap.com>
…abel Signed-off-by: Simon Heimler <simon.heimler@sap.com>
…yLevels rows Re-scope the base-level rule from a document-wide (top) general policy to a propertyName rule on `policyLevels`, so it renders in place at every policyLevels property across the document rather than at the very top. Signed-off-by: Simon Heimler <simon.heimler@sap.com>
Signed-off-by: Simon Heimler <simon.heimler@sap.com>
Instead of injecting a full-width table row that spans all three columns, the requirement callout is now appended into the property's description cell, so it reads as additional description content alongside the base spec's own text. Signed-off-by: Simon Heimler <simon.heimler@sap.com>
… on its own line - Insert the requirement callout before the <hr/> in the description cell, so it sits below the default requirements but above the schema constraints (Regex Pattern, Introduced in Version, Example Values). - Move the requirement title onto its own line, below the policy-level label. Signed-off-by: Simon Heimler <simon.heimler@sap.com>
- Remove the requirement-severity legend from the policy info bar (the badges are self-explanatory) and drop the now-dead legend CSS. - Balance the panel padding by zeroing the trailing child's bottom margin, which was making the bottom padding larger than the top. Signed-off-by: Simon Heimler <simon.heimler@sap.com>
Rendering (in place, where each requirement belongs): - Inject each requirement into the property's description column (not a full-width row), below the default requirements and above the schema constraints, with the title on its own line. - Tag every note with the selected level and an "inherited from <level>" chip; drop the severity legend and the inheritance breadcrumb. - Style the charset/term tables (borders, header, non-wrapping char cells) and render authored <br/> as real line breaks. Switcher: - Sticky, collapsible selection bar that docks under the navbar (not over it); the detailed description auto-collapses when stuck and is expandable on demand. - Preserve scroll position on policy switch (anchor the property in view). - Dropdown order Base, Core, Documentation (draft), Data Product. Content / overlays: - policyLevels namespace rules now attach to the policyLevels property rows. - Package title charset is a single unified list incl. the forward slash; the slash no longer appears on other titles. Adds an `excludeTargets` option to propertyName rules to support per-anchor overrides. - Uppercase API/ORD (and OData/JSON) in Document schema titles; anchors are unchanged since both forms slug identically. Layout: - Wider doc content on large screens (reduced gutters). - Property tables no longer overflow horizontally; custom select caret spacing. Signed-off-by: Simon Heimler <simon.heimler@sap.com>
Link `title` values are exempt from the SAP Documentation title rules, but the propertyName expansion was applying them to `link_title` too. Exclude `link_title` via excludeTargets on each title rule and drop the now-redundant "(except link titles)" caveat text. Signed-off-by: Simon Heimler <simon.heimler@sap.com>
- copyGeneratedToDestination referenced "Ord Document.csv/.xlsx" but the tabular export is now "ORD Document.*" after the title casing change; this broke `npm run generate` on case-sensitive filesystems (CI/Linux) with ENOENT. - anchors.ts: strip inline HTML from headings in a fixpoint loop so nested/split tags can't leave a partial "<tag" (CodeQL: incomplete multi-character sanitization). Build-time, first-party input, but clears the scan alert. Signed-off-by: Simon Heimler <simon.heimler@sap.com>
- "Full policy level →" used an absolute /spec-extensions/... href that broke under the PR-preview base path (/pr-preview/specification/pr-XXX/...). Use a relative href so it resolves under any base path. - Treat the four generated policy-level pages as build artifacts: gitignore and untrack them (overlays remain the single source of truth; `npm run generate` produces them), consistent with how Document.md/Configuration.md are handled. Signed-off-by: Simon Heimler <simon.heimler@sap.com> Signed-off-by: Pavel Kornev <pavel.kornev@sap.com>
…licy levels
- Render block markdown (paragraphs, lists, blockquotes, italics) in policy
summaries and note bodies, not just inline — e.g. the SAP Data Product draft
note now renders properly.
- Rewrite the policy-level descriptions in a consistent style and drop the
technical own-policyId from them (display names only; validator/namespace-
syntax identifiers kept where they are the point).
- Reference other levels by display name ("SAP Base v1") with relative links,
and resolve those links client-side against the deployment-aware base so they
work on localhost, PR preview and GH Pages (in the info bar and inline notes).
- Hot reload: a Docusaurus plugin watches spec-extension/policy-levels/*.overlay
.yaml and recompiles in dev so the live site updates on overlay edits.
- Move the "Keep existing x-sap- OpenAPI extensions" rule onto the API Resource
Definition `type` property instead of a top-level general rule.
Signed-off-by: Simon Heimler <simon.heimler@sap.com>
Annotate the in-page table of contents with a blue dot on each concept that gains requirements under the selected policy level; the dot expands to the requirement count on hover (and all counts show when hovering the TOC), giving a visual map of which parts of the spec are affected (e.g. API Resource shows 22 under SAP Core v1). - Dots sit in a left gutter so item text stays aligned; the count is centered. - The gutter is reserved whenever the switcher is mounted (body.policy-has- switcher), so the sidebar does not shift when toggling between levels with and without requirements. Signed-off-by: Simon Heimler <simon.heimler@sap.com>
Replace the per-item left gutter + dot with an absolute left accent bar on affected TOC entries only, so base-level pages match other pages and the sidebar never reflows when switching levels. Show the requirement count as a right-aligned pill revealed on TOC hover. Drop the chip borders on the policy-level name and 'inherited from' labels. Signed-off-by: Simon Heimler <simon.heimler@sap.com>
… their properties Move the SAP Core 'Entity Type definition visibility' rule onto the entity-type visibility property, and the SAP Base 'Package vendor' rule onto the package vendor property, so both render inline in context rather than as definition-level section notes. Signed-off-by: Simon Heimler <simon.heimler@sap.com>
Move ord-spec-version, api/event resource-definitions, overlay visibility, and OpenAPI-validation rules onto the exact properties they govern (openResourceDiscovery, resourceDefinitions, overlay visibility, api-resource-definition type) so they render inline in context. Also equalize the policy panel inline-hint text size with the surrounding summary text. Signed-off-by: Simon Heimler <simon.heimler@sap.com>
…s; fix badge override Move the remaining SAP Core/Documentation general rules onto the exact properties they govern (access strategies -> accessStrategies & access strategy type, API compatibility -> version). Fix a regression where value/usage rules (openResourceDiscovery version, OpenAPI validation, x-sap extensions, visibility, vendor, charset, etc.) rewrote the property presence badge: only genuine presence rules (the 'extensible MUST be provided' rules) now flip a badge; value rules keep the base spec badge and render as inline notes. Drop the redundant provenance chip from the Property column (the inline note label and TOC bar already signal provenance). Tidy the Preferred Approach list header. Signed-off-by: Simon Heimler <simon.heimler@sap.com>
…e in CI Convert policy-overlay.schema.json to the 2020-12 dialect ($schema + definitions -> $defs) and switch the build-time overlay validation to Ajv2020 so the validated dialect matches the declared one. Add a standalone validator (validate:policy) with two Ajv checks: the schema document is valid JSON Schema 2020-12, and every overlay validates against it. Wire it into the Main workflow as a dedicated step. Signed-off-by: Simon Heimler <simon.heimler@sap.com>
Two fixes for anchor navigation with the policy switcher active: - The apply effect keyed on the URL hash, so a TOC click (hash-only change) tore down and rebuilt the whole overlay mid-scroll, shifting the target behind the toolbar (fine only on a second click). Key the effect on pathname + policy; leave the overlay untouched on hash-only navigation. - Publish the sticky bar's live height as --policy-switcher-offset and fold it into scroll-margin-top / scroll-padding-top and the JS re-align, so the heading clears the toolbar. Signed-off-by: Simon Heimler <simon.heimler@sap.com>
Signed-off-by: Simon Heimler <simon.heimler@sap.com>
Signed-off-by: Simon Heimler <simon.heimler@sap.com>
85c3e9f to
affc978
Compare
Signed-off-by: Simon Heimler <simon.heimler@sap.com>
Signed-off-by: Simon Heimler <simon.heimler@sap.com>

Adds a policy-level switcher to the ORD Document reference that displays additional requirements and their inheritance alongside the base specification.
Selections are stored in the URL so policy-specific reference links can be shared.
Authored policy overlays provide the source for both the switcher and the generated standalone policy pages.
The rebased implementation preserves existing public TypeScript type names and current standalone-overlay target requirements.
It also carries the agreed Core-level Arazzo recommendation from PR #241 into the policy source so generated pages retain it.
The release changelog records the switcher.