@eriknaslund/skiss 0.2.1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -63,8 +63,12 @@ interface ClassNode {
63
63
  line: number;
64
64
  }
65
65
  type Severity = 'error' | 'warning';
66
- /** Codes from the table in docs/ARCHITECTURE.md. `parse` adds the `E_` codes, `resolve` the `W_` codes. */
67
- type DiagnosticCode = 'E_UNPARSABLE' | 'E_FIELD_WITHOUT_CLASS' | 'E_MISSING_TYPE' | 'E_UNCLOSED_MANY' | 'E_BAD_NAME' | 'W_UNKNOWN_TYPE' | 'W_UNDECLARED_CLASS' | 'W_UNDECLARED_FIELD' | 'W_DUPLICATE_CLASS' | 'W_DUPLICATE_FIELD' | 'W_MULTIPLE_IDENTIFIERS';
66
+ /**
67
+ * Codes from the tables in docs/ARCHITECTURE.md. `parse` adds the `E_` codes,
68
+ * `resolve` the `W_` codes, and `importLinkML` the one code of its own,
69
+ * `E_NOT_YAML`, for a text no schema can be read out of.
70
+ */
71
+ type DiagnosticCode = 'E_UNPARSABLE' | 'E_FIELD_WITHOUT_CLASS' | 'E_MISSING_TYPE' | 'E_UNCLOSED_MANY' | 'E_BAD_NAME' | 'W_UNKNOWN_TYPE' | 'W_UNDECLARED_CLASS' | 'W_UNDECLARED_FIELD' | 'W_DUPLICATE_CLASS' | 'W_DUPLICATE_FIELD' | 'W_DUPLICATE_ENUM_VALUE' | 'W_MULTIPLE_IDENTIFIERS' | 'E_NOT_YAML';
68
72
  interface Diagnostic {
69
73
  severity: Severity;
70
74
  code: DiagnosticCode;
@@ -168,6 +172,41 @@ declare function compile(source: string, opts: CompileOptions): CompileResult;
168
172
  */
169
173
  declare function formatDiagnostic(d: Diagnostic, file?: string): string;
170
174
 
175
+ /**
176
+ * One thing the projection could not carry. `kind` is the LinkML key, or one
177
+ * of the projection's own kinds: `renamed`, `narrowed`, `inlined`,
178
+ * `enum_detail`, `annotation`, `reworded`, `schema`, `unreadable`. `element`
179
+ * names what carried it as the sketch names it — `Class`, `Class.field` — or,
180
+ * for an enum, its LinkML name, which the sketch does not keep.
181
+ */
182
+ interface Dropped {
183
+ kind: string;
184
+ element: string;
185
+ detail?: string;
186
+ }
187
+ interface FromLinkMLResult {
188
+ /** The projected sketch, parsed from `source`, so every node has a position. */
189
+ document: Document;
190
+ /** The sketch as canonical Skiss text. */
191
+ source: string;
192
+ /** SPEC §8, in schema order: class by class, then enums, then the schema itself. */
193
+ dropped: Dropped[];
194
+ }
195
+ declare function fromLinkML(schema: unknown): FromLinkMLResult;
196
+ declare function formatDropped(dropped: Dropped[]): string;
197
+
198
+ declare function toSkiss(doc: Document): string;
199
+
200
+ interface ImportResult {
201
+ /** The projected sketch as canonical Skiss text, `\n`-terminated. */
202
+ output: string;
203
+ /** SPEC §8, in schema order: what the projection could not carry. */
204
+ dropped: Dropped[];
205
+ /** The diagnostics of the projected sketch. Their lines are lines of `output`. */
206
+ diagnostics: Diagnostic[];
207
+ }
208
+ declare function importLinkML(text: string): ImportResult;
209
+
171
210
  declare function parse(source: string): Document;
172
211
 
173
212
  /** What `resolve` returns: a `Document` whose `undeclared` list is always present. */
@@ -176,6 +215,6 @@ interface ResolvedDocument extends Document {
176
215
  }
177
216
  declare function resolve(doc: Document): ResolvedDocument;
178
217
 
179
- declare const VERSION = "0.2.1";
218
+ declare const VERSION = "0.4.0";
180
219
 
181
- export { type ClassNode, type CompileOptions, type CompileResult, type Diagnostic, type DiagnosticCode, type Document, type FieldNode, type JoinRef, type LinkMLAnnotations, type LinkMLAttribute, type LinkMLClass, type LinkMLCompileOptions, type LinkMLEnum, type LinkMLOptions, type LinkMLSchema, type MermaidCompileOptions, type MermaidOptions, type Name, type Primitive, type ResolvedDocument, type SerializeFormat, type Severity, type TypeRef, VERSION, compile, formatDiagnostic, parse, resolve, serialize, toLinkML, toMermaid };
220
+ export { type ClassNode, type CompileOptions, type CompileResult, type Diagnostic, type DiagnosticCode, type Document, type Dropped, type FieldNode, type FromLinkMLResult, type ImportResult, type JoinRef, type LinkMLAnnotations, type LinkMLAttribute, type LinkMLClass, type LinkMLCompileOptions, type LinkMLEnum, type LinkMLOptions, type LinkMLSchema, type MermaidCompileOptions, type MermaidOptions, type Name, type Primitive, type ResolvedDocument, type SerializeFormat, type Severity, type TypeRef, VERSION, compile, formatDiagnostic, formatDropped, fromLinkML, importLinkML, parse, resolve, serialize, toLinkML, toMermaid, toSkiss };