@eriknaslund/skiss 0.2.0 → 0.3.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
@@ -39,6 +39,13 @@ interface JoinRef {
39
39
  interface FieldNode {
40
40
  name: Name;
41
41
  identifier: boolean;
42
+ /**
43
+ * Where the `*` is written, set by `parse` whenever one is present.
44
+ * Whitespace before `*` is allowed, so the position cannot be derived from
45
+ * the field name, and `resolve` points W_MULTIPLE_IDENTIFIERS at it. It
46
+ * stays as written when `resolve` clears `identifier` on a second `*`.
47
+ */
48
+ identifierAt?: Name;
42
49
  type?: TypeRef;
43
50
  system?: Name;
44
51
  joinsTo?: JoinRef;
@@ -56,8 +63,12 @@ interface ClassNode {
56
63
  line: number;
57
64
  }
58
65
  type Severity = 'error' | 'warning';
59
- /** Codes from the table in docs/ARCHITECTURE.md. `parse` adds the `E_` codes, `resolve` the `W_` codes. */
60
- 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_MULTIPLE_IDENTIFIERS' | 'E_NOT_YAML';
61
72
  interface Diagnostic {
62
73
  severity: Severity;
63
74
  code: DiagnosticCode;
@@ -161,6 +172,41 @@ declare function compile(source: string, opts: CompileOptions): CompileResult;
161
172
  */
162
173
  declare function formatDiagnostic(d: Diagnostic, file?: string): string;
163
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`, `schema`. `element` names what carried it as
179
+ * the sketch names it — `Class`, `Class.field` — or, for an enum, its LinkML
180
+ * 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
+
164
210
  declare function parse(source: string): Document;
165
211
 
166
212
  /** What `resolve` returns: a `Document` whose `undeclared` list is always present. */
@@ -169,6 +215,6 @@ interface ResolvedDocument extends Document {
169
215
  }
170
216
  declare function resolve(doc: Document): ResolvedDocument;
171
217
 
172
- declare const VERSION = "0.2.0";
218
+ declare const VERSION = "0.3.0";
173
219
 
174
- 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 };