import type { MemoModel } from '../model/semantic.js'; import type { OntologyView } from '../model/kind-registry.js'; /** * Import provenance — tracks where an element came from. * Stored as _import_* attributes in the generated SysML so the trace is * visible in the model and survives round-trips through the CLI. */ export interface ImportProvenance { /** Source file name (e.g. "requirements-v3.xlsx") */ sourceFile: string; /** 1-based row number in the source artifact */ sourceRow: number; /** ISO-8601 timestamp of the import (e.g. "2026-04-14T18:00:00Z") */ importTimestamp: string; /** Stable session ID grouping all elements from a single import run */ importSessionId: string; } /** Parsed element from CSV (before SysML generation) */ export interface CsvElement { id: string; name: string; kind: string; construct: string; layer?: string; doc: string; attributes: Record; /** Optional provenance metadata written as _import_* attributes in SysML */ provenance?: ImportProvenance; } /** * Attach provenance to a batch of CsvElements. * `sourceRow` is auto-assigned (1-based index into the `elements` array). * Call this after `parseElementsCsv()` when you want full traceability. * * @example * const result = parseElementsCsv(csv, config); * const withProvenance = attachProvenance(result.items, { * sourceFile: 'requirements-v3.xlsx', * importTimestamp: new Date().toISOString(), * importSessionId: crypto.randomUUID(), * }); */ export declare function attachProvenance(elements: CsvElement[], meta: Omit): CsvElement[]; /** Parsed relationship from CSV */ export interface CsvRelationship { sourceId: string; targetId: string; type: string; sourceEnd: string; targetEnd: string; } /** Result of parsing a CSV file */ export interface CsvParseResult { items: T[]; errors: string[]; warnings: string[]; } /** * Parse an elements CSV file. * * **Standard CSV format for elements:** * ``` * id,name,kind,construct,doc,[attr1],[attr2],... * ``` * * - `id` — unique element identifier (required, valid SysML identifier) * - `name` — display name (required) * - `kind` — ontology type from ontology.kinds (required, e.g. "Hazard", "Requirement") * - `construct` — SysML construct override (optional, auto-derived from kind if omitted) * - `doc` — documentation comment (optional) * - Additional columns become `attribute redefines = ""` in SysML * * The `kind` value is validated against the resolved config. If `construct` is omitted, * it is derived from the kind's `sysmlConstruct` definition. The `layer` is always * derived from the kind definition and cannot be set manually. */ export declare function parseElementsCsv(csvText: string, ontology: OntologyView): CsvParseResult; /** * Export model elements to CSV. * * Produces a CSV with fixed columns (id, name, kind, construct, doc) plus * dynamic attribute columns gathered from all elements in the model. */ export declare function exportElementsCsv(model: MemoModel, _ontology: OntologyView): string; /** * Parse a relationships CSV file. * * **Standard CSV format for relationships:** * ``` * sourceId,targetId,type,sourceEnd,targetEnd * ``` * * - `sourceId` — source element id (required, must exist in model or import batch) * - `targetId` — target element id (required, must exist in model or import batch) * - `type` — relationship type from config (required, e.g. "mitigates", "traceTo") * - `sourceEnd` — connection end name (optional, default: "source") * - `targetEnd` — connection end name (optional, default: "target") */ export declare function parseRelationshipsCsv(csvText: string, ontology: OntologyView, knownElementIds?: Set): CsvParseResult; /** * Export model relationships to CSV. */ export declare function exportRelationshipsCsv(model: MemoModel): string; /** * Generate a template CSV for elements based on the config's ontology kinds. * Includes all valid kinds as example rows with their default attributes. */ export declare function generateElementTemplate(ontology: OntologyView): string; /** * Generate a template CSV for relationships based on config relationship types. */ export declare function generateRelationshipTemplate(ontology: OntologyView): string; //# sourceMappingURL=csv-io.d.ts.map