feat(cli): publish narrative documents from workspaces - #3015
Conversation
|
|
||
| export type ResourceChangeType = 'MAJOR' | 'MINOR' | 'PATCH'; | ||
|
|
||
| export const NARRATIVE_DOCUMENT_TYPES = ['knowledge', 'sad'] as const; |
There was a problem hiding this comment.
These are structurally identical to CALM_DOCUMENT_TYPES_LIST / CalmDocumentType / isValidCalmDocumentType in calm-models/types. Co-locating them there would give a single source of truth and clean up the union in bundle.ts and the import in workspace-document-loader.ts. Hub API DTOs should stay here.
| throw new Error('Narrative document Hub identity is incomplete. Re-add the document to repair it.'); | ||
| } | ||
| const identity = { | ||
| namespace: entry.namespace ?? '', |
There was a problem hiding this comment.
The ?? '' is misleading — validateNarrativeIdentity rejects empty strings anyway. Same at bump.ts.
| const location = await client.createNarrativeDocumentVersion( | ||
| identity.namespace, identity.type, identity.calmHubDocumentId!, version, narrative.request | ||
| ); | ||
| parseNarrativeDocumentLocation(location, identity); |
There was a problem hiding this comment.
Return value discarded — pure validation. A // validate Location comment would prevent someone removing this.
|
|
||
| vi.mock('@finos/calm-shared/src/hub/calm-hub-client', () => ({ | ||
| CalmHubClient: mocks.CalmHubClient, | ||
| NARRATIVE_DOCUMENT_TYPES: ['knowledge', 'sad'], |
There was a problem hiding this comment.
Will drift if a type is added to the canonical constant. Consider vi.importActual.
| copy: options.copy, | ||
| type, | ||
| namespace: options.namespace.trim(), | ||
| version: '1.0.0', |
There was a problem hiding this comment.
Always 1.0.0, no --version override. Re-adding after manifest removal will reset regardless of Hub state.
| for (const [id, entry] of Object.entries(manifest)) { | ||
| const filePath = resolveFilePath(bundlePath, entry.path); | ||
| if (!existsSync(filePath)) { | ||
| if (isNarrativeDocumentType(entry.type)) throw new Error(`Narrative document '${id}' file not found: ${filePath}`); |
There was a problem hiding this comment.
Throws immediately here, while push.ts accumulates. Defensible, but a one-line rationale comment would help.
| import { existsSync, readFileSync } from 'fs'; | ||
| import { SchemaDirectory } from '../schema-directory'; | ||
| import path from 'path'; | ||
| import { NARRATIVE_DOCUMENT_TYPES, type NarrativeDocumentType } from '../hub/calm-hub-client'; |
There was a problem hiding this comment.
If types move to calm-models (see comment on calm-hub-client.ts), this can import from @finos/calm-models/types — matching the existing CalmDocumentType import.
|
@101Steeps — POC is coming along nicely 👍. Just the CalmHub visuals left now. |
| urlToLocalPathMapping?: Map<string, string>; | ||
| } | ||
|
|
||
| const YAML_FRONTMATTER_PATTERN = /^---\r?\n([\s\S]*?)\r?\n---(?=\r?\n|$)/; |
There was a problem hiding this comment.
As we build this out, I want to see what it takes to converge this with docify's parseFrontMatterFromContent just below. For example, docify expects the closing --- (with optional trailing whitespace via .trim()), but this regex is stricter. Part of the POC goal is to figure out where the two can share code. I'll pick that up when I loop back to flow.
Description
Implements #2983: publish versioned Markdown narrative documents from a CALM workspace to CALM Hub.
sadandknowledgeMarkdown documents.workspace check,bump, andpushfor narrative documents.Depends on the narrative-document API in #3002 / #2982. The combined local POC branch was used only for integration testing; this PR remains focused on the CLI and shared client changes.
Type of Change
Affected Components
cli/)calm/)calm-ai/)calm-hub/)calm-hub-ui/)calm-server/)calm-widgets/)docs/)shared/)calm-plugins/vscode/)Commit Message Format ✅
All commits follow Conventional Commits.
Testing
I have tested my changes locally
I have added/updated unit tests
All existing tests pass
npm testpassed on Linux: all 17 workspace summaries passed (including shared: 90 files / 1,084 tests; CLI: 28 files / 682 tests).npm run lintcompleted with 0 errors; 11 existing warnings remain outside this change.npm run build:clipassed.Combined local POC: First-class Documents in CALM Hub #2981 POC, with Add a first-class Document endpoint to CALM Hub #2982 merged locally:
cd calm-hub && ../mvnw verify— 2,772 tests passed; JaCoCo checks passed.cd calm-hub && ../mvnw -P integration verify— 537 tests passed; JaCoCo checks passed.bash scripts/build-hub-smoke-image.sh— passed and builtcalm-hub:smoke.npm run test:smoke --workspace cli— 7 test files / 28 tests passed.The smoke test exercises the full narrative-document workflow against a disposable Docker Calm Hub instance: create a workspace, publish architecture and Markdown SAD
1.0.0, retrieve it, detect an edited-but-unbumped document, bump to1.1.0, republish it, and retrieve the updated Markdown.A standalone manual POC repeated the same flow against local Calm Hub. The final
workspace checkreported the workspace up to date and all documents valid.Swagger Evidence

Endpoint list showing the five narrative document routes
Version API used by

workspace pushRetrieval endpoint used to verify the stored markdown

Checklist