@agentshouse/mdmodel 0.1.0-c0d316445d94f → 0.1.0-c3208a08ee314
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/API.md +77 -12
- package/dist/blocks.d.ts.map +1 -1
- package/dist/blocks.js +30 -16
- package/dist/condition.d.ts +1 -0
- package/dist/condition.d.ts.map +1 -1
- package/dist/condition.js +6 -6
- package/dist/definition.js +2 -2
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +13 -13
- package/dist/fields.d.ts +2 -0
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js +7 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/schema.js +2 -2
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +19 -25
- package/dist/yaml.d.ts +7 -3
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +72 -43
- package/fixtures/README.md +1 -1
- package/package.json +1 -1
package/API.md
CHANGED
|
@@ -38,6 +38,9 @@ if (parsed.ok) {
|
|
|
38
38
|
}
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
+
`MARKDOWN_SYNTAX_PROFILE` is the Markdown every reader here applies, GitHub Flavored Markdown
|
|
42
|
+
0.29, and `VERSION` is the MD model version.
|
|
43
|
+
|
|
41
44
|
`verify(schema)` reads one schema text, the MD Types of one Room or App: one
|
|
42
45
|
JSON Schema document (draft 2020-12) in the YAML subset. Every top-level key but
|
|
43
46
|
`$defs` names an MD Type holding the JSON Schema of its frontmatter; `$defs`
|
|
@@ -72,6 +75,10 @@ variant's own keys `conditional`; a path without one `type`, `null` aside, has
|
|
|
72
75
|
none. A malformed schema is refused whole, naming its `rule`, the keyword or the
|
|
73
76
|
model's own, and the JSON Pointer `location` it concerns, such as
|
|
74
77
|
`/plan/properties/status/enum`, or `line <n>` outside the YAML subset.
|
|
78
|
+
`pointerFacts(definition, pointer)` reads the facts a frontmatter pointer reaches,
|
|
79
|
+
`itemFacts` and `memberFacts` take one step and `crossedFacts` reads a list's item
|
|
80
|
+
facts; `pointerSegments` and `escapePointer` split and write a pointer, `ARRAY_INDEX`
|
|
81
|
+
matches an index segment, and `ATTACHMENT` is the `reference` that admits any path.
|
|
75
82
|
|
|
76
83
|
`validate(library, context?, model?)` takes the resulting text Library and one
|
|
77
84
|
`ValidationContext` of `binaryTargets: readonly string[]`, none when omitted.
|
|
@@ -89,24 +96,30 @@ A typed Document's frontmatter satisfies its type's schema, every keyword with
|
|
|
89
96
|
its JSON Schema meaning, formats asserted and defaults never filled, except that
|
|
90
97
|
an object schema declaring neither `additionalProperties` nor
|
|
91
98
|
`unevaluatedProperties` is closed: an undeclared key is refused as `undeclared-
|
|
92
|
-
field`. `
|
|
93
|
-
type, and the string `MEMBER_FIELD` on the `member_document` type
|
|
94
|
-
names the keyword, such as `required`, and the
|
|
95
|
-
`/shipping/city`. Every occurrence of a declared
|
|
96
|
-
values of its item schema, else `structured-section`;
|
|
97
|
-
ordinary link alone, such as `- [Ada](ada.md)`. A
|
|
98
|
-
section item, reaching a URL, a binary target, or a
|
|
99
|
-
not name is `unresolved-reference`, and a frontmatter
|
|
100
|
-
`referenced-missing-file` naming its `referrers`;
|
|
101
|
-
and no body link is a referrer.
|
|
99
|
+
field`. `TYPE_FIELD`, `SITE_FIELD` and `RECEIVED_FIELD` count as declared on every
|
|
100
|
+
type, and the string `MEMBER_FIELD` on the `member_document` type; `HOUSE_FIELDS`
|
|
101
|
+
lists the four. A refusal names the keyword, such as `required`, and the
|
|
102
|
+
value's JSON Pointer, such as `/shipping/city`. Every occurrence of a declared
|
|
103
|
+
list section is a list of values of its item schema, else `structured-section`;
|
|
104
|
+
a reference item is one ordinary link alone, such as `- [Ada](ada.md)`. A
|
|
105
|
+
reference, at any depth or a section item, reaching a URL, a binary target, or a
|
|
106
|
+
Document of a type it does not name is `unresolved-reference`, and a frontmatter
|
|
107
|
+
one reaching no member is `referenced-missing-file` naming its `referrers`;
|
|
108
|
+
`attachment` admits any path, and no body link is a referrer.
|
|
102
109
|
|
|
103
110
|
Validation returns acceptance or one refusal naming the file, the field or
|
|
104
111
|
section, and the violated rule. `parse`, `apply`, and `serialize` operate on a single text
|
|
105
112
|
Document; they do not validate collection membership or consume binary bytes.
|
|
106
|
-
`apply` sets one typed field, including a list
|
|
113
|
+
`apply` sets one typed field, including a list or an object as a whole, replaces
|
|
107
114
|
one existing section body or the preamble against that value's prior content,
|
|
108
115
|
or rewrites one Markdown link destination. A section need not be declared by
|
|
109
|
-
the Document's MD Type to be replaced. A field change does not reformat the rest of the file
|
|
116
|
+
the Document's MD Type to be replaced. A field change does not reformat the rest of the file:
|
|
117
|
+
an inline value is replaced where it stands, and a value written after the key's line, an empty
|
|
118
|
+
one or a block mapping or list, is written after the key's colon in its place.
|
|
119
|
+
A field holds a `FrontmatterValue`: null, a string, a boolean, a finite number, a list
|
|
120
|
+
without holes or a plain object of them, holding no cycle. `frontmatterValue(value)` is that test, and
|
|
121
|
+
`apply` refuses any other value as `frontmatter-fence`; `equalValue(left, right)` compares
|
|
122
|
+
two by value, whatever their key order, as `apply` compares a field with its prior.
|
|
110
123
|
|
|
111
124
|
`Document.preamble` is a readonly string containing the exact source after
|
|
112
125
|
frontmatter and before the first section heading recognized by the existing
|
|
@@ -296,3 +309,55 @@ author quoted. A Span divided out of one free-text field value addresses that
|
|
|
296
309
|
whole value, because a YAML scalar's own positions are the only ones its source
|
|
297
310
|
has, and a Span carrying part of one internal link's label addresses that whole
|
|
298
311
|
link, because a cut never falls inside link syntax.
|
|
312
|
+
|
|
313
|
+
## Conditions
|
|
314
|
+
|
|
315
|
+
`facts(document, { id, path }, model, resolve)` reads one Document as the `DocumentFacts` a
|
|
316
|
+
condition tests: its `id`, its `path` with a leading `/`, its `type` or `null`, its `sections`, and
|
|
317
|
+
a `Fact` for each frontmatter field it writes that its MD Type declares. `factKind(facts)` names
|
|
318
|
+
the kind a declared value compares as: `reference`, `enum`, `number`, `boolean`, `date`, `time`
|
|
319
|
+
(a `date-time`) or `string`, else `null`. A prose value, or one of no kind, is `prose`, a list or
|
|
320
|
+
an object holds the facts of its members, and a value written `null` is `null`. A value that does
|
|
321
|
+
not fit its kind, such as a string in a number field, a value outside its `enum` or a reference
|
|
322
|
+
`resolve` maps to no `{ id, member? }`, is `unreadable`; a readable reference compares as that `id`.
|
|
323
|
+
|
|
324
|
+
`holds(test, facts, owner)` is `true`, `false` or `undefined`, unknown; a Trigger fires on `true`
|
|
325
|
+
alone. A test's `path` is `/path`, `/type`, `/sections/<heading>`, `/fields/<pointer>`, or
|
|
326
|
+
`/members/<pointer>`, the member of the Document a reference field reaches. A pointer segment that
|
|
327
|
+
is not an index reads every item of a list, an item lacking it unknown, and a test over several
|
|
328
|
+
values holds as `any` does. The value `{ owner: true }` stands for `owner`, a User id.
|
|
329
|
+
|
|
330
|
+
| The path reaches | `exists` | `contains` | any other test |
|
|
331
|
+
| --------------------------------------- | ----------- | -------------- | -------------- |
|
|
332
|
+
| a value | present | `undefined` | compared |
|
|
333
|
+
| `null`, prose or a section | present | `undefined` | `undefined` |
|
|
334
|
+
| a list | present | `any` of items | `undefined` |
|
|
335
|
+
| no item, through an empty list | absent | `false` | `false` |
|
|
336
|
+
| nothing: no such field, section or type | absent | `undefined` | `undefined` |
|
|
337
|
+
| only unreadable values | `undefined` | `undefined` | `undefined` |
|
|
338
|
+
|
|
339
|
+
`exists: true` holds where present and fails where absent, `exists: false` the reverse. `all` is
|
|
340
|
+
`false` if a part is, else `undefined` if a part is; `any` is `true` if a part is, else `undefined`
|
|
341
|
+
if a part is; `not` keeps `undefined`, so absence is tested with `exists`, never with `not`. `eq`
|
|
342
|
+
and `in` are `undefined` against a value of another JSON type and compare a `time` as an instant;
|
|
343
|
+
`prefix` reads only a string, never a reference or a member; `gt`, `gte`, `lt` and `lte` order
|
|
344
|
+
numbers, dates and times alone.
|
|
345
|
+
|
|
346
|
+
`fires(condition, event, owner)` reads one change, `{ before, after, changed, by }`: the facts of
|
|
347
|
+
each side, `null` on the side a creation or a deletion lacks, the `changed` paths whose prose
|
|
348
|
+
changed, and the actor whose `/user`, `/site` and `/door`, one of `WRITE_DOORS`, a `by` test reads.
|
|
349
|
+
`starts_matching` fires when the Document is in `scope` and holds `match` after the change and did
|
|
350
|
+
not before; a creation fires only with `new_documents: true`, and a deletion never fires.
|
|
351
|
+
`field_changes` fires when the side the Document has, after or for a deletion before, is in `scope`
|
|
352
|
+
and holds `match`, and `field` changed: its facts differ, or with neither `from` nor `to` `changed`
|
|
353
|
+
names it. A field absent on both sides never fires; `from: 'new'` admits only a creation and
|
|
354
|
+
`to: 'deleted'` only a deletion, and listed values need that side to hold `field` `in` them.
|
|
355
|
+
|
|
356
|
+
`itemFires(condition, item, owner)` compares `source` and `address` where given and holds `match`
|
|
357
|
+
over `/delivery`, `/source`, `/provider`, `/container`, `/author`, `/has_attachment`,
|
|
358
|
+
`/headers/<name>` and `/json/<pointer>`, unknown for an item with no JSON. `prosePaths(facts)` lists
|
|
359
|
+
the prose and section paths whose text builds `changed`; `pointed(value, pointer)` reads a JSON
|
|
360
|
+
Pointer, `undefined` where nothing is; `dated(value)` checks a `YYYY-MM-DD` date, and
|
|
361
|
+
`instant(value)` reads an RFC 3339 time with its offset as epoch nanoseconds, a `bigint`.
|
|
362
|
+
`datePointers(fields)` lists, sorted, the `/fields/<name>` pointers of a type's date fields, the
|
|
363
|
+
only values a `DateCondition`'s `date` takes.
|
package/dist/blocks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../src/blocks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../src/blocks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAqCF,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,WAAW,EAAE,CA+BrF;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAe/E"}
|
package/dist/blocks.js
CHANGED
|
@@ -23,24 +23,38 @@ function scan(content, from, to, visit) {
|
|
|
23
23
|
i = next;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
const HASH = 0x23;
|
|
26
27
|
export function headingLines(content, from, to) {
|
|
27
28
|
const found = [];
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
29
|
+
let fences = null;
|
|
30
|
+
let i = from;
|
|
31
|
+
while (i < to) {
|
|
32
|
+
const nl = content.indexOf('\n', i);
|
|
33
|
+
const end = nl === -1 || nl >= to ? to : nl;
|
|
34
|
+
const next = end === to ? to : end + 1;
|
|
35
|
+
if (content.charCodeAt(i) === HASH) {
|
|
36
|
+
fences ??= fenceSpans(content.slice(from, to));
|
|
37
|
+
const at = i - from;
|
|
38
|
+
if (!fences.some(([start, stop]) => at >= start && at < stop)) {
|
|
39
|
+
const { text } = lineAt(content, i, to);
|
|
40
|
+
const match = HEADING.exec(text);
|
|
41
|
+
const hashes = match?.[1];
|
|
42
|
+
const name = match?.[2];
|
|
43
|
+
if (hashes !== undefined && name !== undefined) {
|
|
44
|
+
found.push({
|
|
45
|
+
level: hashes.length,
|
|
46
|
+
name: name.trim(),
|
|
47
|
+
start: i,
|
|
48
|
+
textEnd: i + text.length,
|
|
49
|
+
next,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (next === i)
|
|
55
|
+
break;
|
|
56
|
+
i = next;
|
|
57
|
+
}
|
|
44
58
|
return found;
|
|
45
59
|
}
|
|
46
60
|
export function blockRanges(content, from, to) {
|
package/dist/condition.d.ts
CHANGED
|
@@ -139,6 +139,7 @@ export declare function facts(document: Document, at: {
|
|
|
139
139
|
readonly path: string;
|
|
140
140
|
}, model: VerifiedModel, resolve: (target: string) => Resolved | undefined): DocumentFacts;
|
|
141
141
|
export declare function prosePaths(facts: DocumentFacts): string[];
|
|
142
|
+
export declare function datePointers(fields: Readonly<Record<string, ValueFacts>>): string[];
|
|
142
143
|
export declare function dated(value: unknown): value is string;
|
|
143
144
|
export declare function instant(value: unknown): bigint | undefined;
|
|
144
145
|
export declare function pointed(value: unknown, pointer: string): unknown;
|
package/dist/condition.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"condition.d.ts","sourceRoot":"","sources":["../src/condition.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,UAAU,EAChB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAA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S,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAO3F"}
|
package/dist/condition.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ARRAY_INDEX, escapePointer, fieldFacts, itemFacts, memberFacts, pointerSegments, } from './definition.js';
|
|
2
2
|
import { target } from './paths.js';
|
|
3
|
-
import { isRecord } from './yaml.js';
|
|
3
|
+
import { isRecord, plain } from './yaml.js';
|
|
4
4
|
export const WRITE_DOORS = ['browser', 'agent', 'client'];
|
|
5
5
|
const PROSE = { kind: 'prose' };
|
|
6
6
|
const NULL = { kind: 'null' };
|
|
@@ -205,11 +205,11 @@ function readActor(actor, path) {
|
|
|
205
205
|
: undefined;
|
|
206
206
|
return value === undefined ? undefined : single({ kind: 'actor', value });
|
|
207
207
|
}
|
|
208
|
-
function
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
208
|
+
export function datePointers(fields) {
|
|
209
|
+
return Object.entries(fields)
|
|
210
|
+
.filter(([, facts]) => facts.type === 'string' && facts.format === 'date')
|
|
211
|
+
.map(([name]) => `/fields/${name}`)
|
|
212
|
+
.sort();
|
|
213
213
|
}
|
|
214
214
|
export function dated(value) {
|
|
215
215
|
return (typeof value === 'string' && DATE.test(value) && instant(`${value}T00:00:00Z`) !== undefined);
|
package/dist/definition.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD } from './fields.js';
|
|
1
|
+
import { MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
|
|
2
2
|
import { equalValue, isRecord, jsValue, parseYamlMapping, YamlError } from './yaml.js';
|
|
3
3
|
export const JSON_TYPES = [
|
|
4
4
|
'string',
|
|
@@ -16,7 +16,7 @@ const DEFS_REFERENCE = '#/$defs/';
|
|
|
16
16
|
const UNRESOLVED = /[\u0000-\u001f\u007f%[\]\\^{|}]|\s$/u;
|
|
17
17
|
export const ARRAY_INDEX = /^(?:0|[1-9][0-9]*)$/u;
|
|
18
18
|
const HOUSE_KEYS = {
|
|
19
|
-
|
|
19
|
+
[TYPE_FIELD]: { prose: false },
|
|
20
20
|
[SITE_FIELD]: { prose: false },
|
|
21
21
|
[RECEIVED_FIELD]: { prose: false },
|
|
22
22
|
};
|
package/dist/document.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAMhF,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,WAAW,EAEZ,MAAM,YAAY,CAAC;AACpB,OAAO,
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAMhF,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,WAAW,EAEZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAaL,KAAK,OAAO,EAEb,MAAM,WAAW,CAAC;AAwCnB,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,SAAK,GAAG,WAAW,CAkD7D;AA+KD,wBAAgB,UAAU,CACxB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,UAAU,GACtB,WAAW,CAYb;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAOrF;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACjC,UAAU,CAeZ;AAeD,wBAAgB,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,IAAI,EAAE,CAEvE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,IAAI,EAAE,CAErE;AAED,wBAAgB,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,CAOrE;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAEpD;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI,CAE9D"}
|
package/dist/document.js
CHANGED
|
@@ -4,7 +4,7 @@ import { relative, retarget, SHELL_ROOMS, shellTarget, target } from './paths.js
|
|
|
4
4
|
import { references } from './references.js';
|
|
5
5
|
import { headingSpans, sectionsRecord } from './sections.js';
|
|
6
6
|
import { refusal } from './refuse.js';
|
|
7
|
-
import { bodyStartAfterYaml, bodyStartOf, equalValue, extractFrontmatter, jsValue, lineEnding, mapEntry, parseYamlMapping, serializeJs, serializeKey, YamlError, } from './yaml.js';
|
|
7
|
+
import { bodyStartAfterYaml, bodyStartOf, equalValue, extractFrontmatter, frontmatterValue, jsValue, lineEnding, mapEntry, parseYamlMapping, serializeJs, serializeKey, YamlError, } from './yaml.js';
|
|
8
8
|
const internals = new WeakMap();
|
|
9
9
|
function refuse(file, rule, location) {
|
|
10
10
|
return location === undefined ? refusal(file, rule) : refusal(file, rule, { location });
|
|
@@ -78,10 +78,18 @@ function applyField(document, name, value, prior) {
|
|
|
78
78
|
if (!equalValue(document.fields[name], prior)) {
|
|
79
79
|
return { outcome: 'stale', document };
|
|
80
80
|
}
|
|
81
|
+
if (!frontmatterValue(value)) {
|
|
82
|
+
return { outcome: 'refuse', refusal: refuse('', 'frontmatter-fence', name) };
|
|
83
|
+
}
|
|
81
84
|
let nextContent;
|
|
82
85
|
const existing = mapEntry(internal.root, name);
|
|
83
86
|
if (existing !== undefined) {
|
|
84
|
-
|
|
87
|
+
const held = existing.value;
|
|
88
|
+
const inline = held.start > existing.after &&
|
|
89
|
+
!/[\r\n]/.test(document.content.slice(existing.after, held.start));
|
|
90
|
+
nextContent = inline
|
|
91
|
+
? splice(document.content, held.start, held.end, serializeJs(value))
|
|
92
|
+
: splice(document.content, existing.after, held.end, ` ${serializeJs(value)}`);
|
|
85
93
|
}
|
|
86
94
|
else if (document.content[internal.root.start] === '{') {
|
|
87
95
|
nextContent = splice(document.content, internal.root.end - 1, internal.root.end - 1, `${internal.root.entries.length === 0 ? '' : ', '}${serializeKey(name)}: ${serializeJs(value)}`);
|
|
@@ -297,17 +305,9 @@ export function apply(document, change) {
|
|
|
297
305
|
return applyReference(document, change.pointer, change.value, change.prior);
|
|
298
306
|
if (change.kind === 'preamble')
|
|
299
307
|
return applyPreamble(document, change.value, change.prior);
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
return applySection(document, change.name, change.value, change.prior);
|
|
304
|
-
}
|
|
305
|
-
catch (error) {
|
|
306
|
-
if (error instanceof YamlError) {
|
|
307
|
-
return { outcome: 'refuse', refusal: refuse('', 'frontmatter-fence', change.name) };
|
|
308
|
-
}
|
|
309
|
-
throw error;
|
|
310
|
-
}
|
|
308
|
+
if (change.kind === 'field')
|
|
309
|
+
return applyField(document, change.name, change.value, change.prior);
|
|
310
|
+
return applySection(document, change.name, change.value, change.prior);
|
|
311
311
|
}
|
|
312
312
|
export function serialize(document) {
|
|
313
313
|
return document.content;
|
package/dist/fields.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
export declare const TYPE_FIELD = "type";
|
|
1
2
|
export declare const MEMBER_FIELD = "member";
|
|
2
3
|
export declare const SITE_FIELD = "site";
|
|
3
4
|
export declare const RECEIVED_FIELD = "received";
|
|
5
|
+
export declare const HOUSE_FIELDS: readonly string[];
|
|
4
6
|
//# sourceMappingURL=fields.d.ts.map
|
package/dist/fields.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,WAAW,CAAC;AAErC,eAAO,MAAM,UAAU,SAAS,CAAC;AAEjC,eAAO,MAAM,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,SAAS,CAAC;AAEjC,eAAO,MAAM,YAAY,WAAW,CAAC;AAErC,eAAO,MAAM,UAAU,SAAS,CAAC;AAEjC,eAAO,MAAM,cAAc,aAAa,CAAC;AAEzC,eAAO,MAAM,YAAY,EAAE,SAAS,MAAM,EAKzC,CAAC"}
|
package/dist/fields.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { dated, factKind, facts, fires, holds, instant, itemFires, pointed, prosePaths, WRITE_DOORS, } from './condition.js';
|
|
1
|
+
export { dated, datePointers, factKind, facts, fires, holds, instant, itemFires, pointed, prosePaths, WRITE_DOORS, } from './condition.js';
|
|
2
2
|
export type { Actor, Condition, ConditionScope, ConditionTest, ConditionValue, CronCondition, DateCondition, DocumentCondition, DocumentEvent, DocumentFacts, Fact, FactKind, ItemCondition, ItemFacts, Resolved, WriteDoor, } from './condition.js';
|
|
3
3
|
export { divide } from './divide.js';
|
|
4
4
|
export { apply, bodyLinks, links, parse, relativize, relativizeBody, relinkBody, serialize, } from './document.js';
|
|
5
|
-
export { MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD } from './fields.js';
|
|
5
|
+
export { HOUSE_FIELDS, MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
|
|
6
6
|
export { relative, retarget, target } from './paths.js';
|
|
7
7
|
export { MARKDOWN_SYNTAX_PROFILE } from './profile.js';
|
|
8
8
|
export { project } from './project.js';
|
|
@@ -12,4 +12,6 @@ export type { Definition, JsonType, PatternFacts, PointerFacts, SectionSpec, Sha
|
|
|
12
12
|
export type { ApplyResult, BodyResult, Change, Division, DivisionContext, Document, Library, ModelVerification, Link, ParseResult, Projection, ProjectionContext, Reference, Refusal, Span, Validation, ValidationContext, VerifiedModel, } from './types.js';
|
|
13
13
|
export { validate, verify } from './validate.js';
|
|
14
14
|
export { VERSION } from './version.js';
|
|
15
|
+
export { equalValue, frontmatterValue } from './yaml.js';
|
|
16
|
+
export type { FrontmatterValue } from './yaml.js';
|
|
15
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,QAAQ,EACR,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,SAAS,EACT,OAAO,EACP,UAAU,EACV,WAAW,GACZ,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,KAAK,EACL,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,EACd,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,IAAI,EACJ,QAAQ,EACR,aAAa,EACb,SAAS,EACT,QAAQ,EACR,SAAS,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,KAAK,EACL,SAAS,EACT,KAAK,EACL,KAAK,EACL,UAAU,EACV,cAAc,EACd,UAAU,EACV,SAAS,GACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts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EACjB,IAAI,EACJ,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,SAAS,EACT,OAAO,EACP,IAAI,EACJ,UAAU,EACV,iBAAiB,EACjB,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AACzD,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { dated, factKind, facts, fires, holds, instant, itemFires, pointed, prosePaths, WRITE_DOORS, } from './condition.js';
|
|
1
|
+
export { dated, datePointers, factKind, facts, fires, holds, instant, itemFires, pointed, prosePaths, WRITE_DOORS, } from './condition.js';
|
|
2
2
|
export { divide } from './divide.js';
|
|
3
3
|
export { apply, bodyLinks, links, parse, relativize, relativizeBody, relinkBody, serialize, } from './document.js';
|
|
4
|
-
export { MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD } from './fields.js';
|
|
4
|
+
export { HOUSE_FIELDS, MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
|
|
5
5
|
export { relative, retarget, target } from './paths.js';
|
|
6
6
|
export { MARKDOWN_SYNTAX_PROFILE } from './profile.js';
|
|
7
7
|
export { project } from './project.js';
|
|
@@ -9,3 +9,4 @@ export { references } from './references.js';
|
|
|
9
9
|
export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
|
|
10
10
|
export { validate, verify } from './validate.js';
|
|
11
11
|
export { VERSION } from './version.js';
|
|
12
|
+
export { equalValue, frontmatterValue } from './yaml.js';
|
package/dist/schema.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Validator } from '@cfworker/json-schema';
|
|
2
2
|
import { escapePointer, refTarget } from './definition.js';
|
|
3
|
-
import { MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD } from './fields.js';
|
|
3
|
+
import { MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
|
|
4
4
|
import { interpretPlain, isRecord } from './yaml.js';
|
|
5
5
|
const STANDING_MAPS = ['properties', 'patternProperties'];
|
|
6
6
|
const STANDING = [
|
|
@@ -101,7 +101,7 @@ function compile(definition) {
|
|
|
101
101
|
const closedDefs = mapped(defs, (held) => closed(held, true, defs));
|
|
102
102
|
const declared = isRecord(root.properties) ? root.properties : {};
|
|
103
103
|
const properties = {
|
|
104
|
-
|
|
104
|
+
[TYPE_FIELD]: true,
|
|
105
105
|
[SITE_FIELD]: true,
|
|
106
106
|
[RECEIVED_FIELD]: true,
|
|
107
107
|
...(definition.memberDocument ? { [MEMBER_FIELD]: { type: 'string' } } : {}),
|
package/dist/validate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAGV,OAAO,EACP,iBAAiB,
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAGV,OAAO,EACP,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,aAAa,EACd,MAAM,YAAY,CAAC;AAwDpB,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAQxD;AAED,wBAAgB,QAAQ,CACtB,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,iBAAyC,EAClD,KAAK,GAAE,aAA6B,GACnC,UAAU,CAqGZ"}
|
package/dist/validate.js
CHANGED
|
@@ -18,7 +18,7 @@ function instanceType(document) {
|
|
|
18
18
|
return null;
|
|
19
19
|
return raw;
|
|
20
20
|
}
|
|
21
|
-
function reaches(file, href, to,
|
|
21
|
+
function reaches(file, href, to, types, binaryTargets) {
|
|
22
22
|
const resolved = classifyHref(file, href);
|
|
23
23
|
if (resolved.kind !== 'path')
|
|
24
24
|
return false;
|
|
@@ -26,8 +26,8 @@ function reaches(file, href, to, documents, binaryTargets) {
|
|
|
26
26
|
return true;
|
|
27
27
|
if (binaryTargets.has(resolved.path))
|
|
28
28
|
return false;
|
|
29
|
-
const held =
|
|
30
|
-
return held === undefined ||
|
|
29
|
+
const held = types.get(resolved.path);
|
|
30
|
+
return held === undefined || to.includes(held);
|
|
31
31
|
}
|
|
32
32
|
function itemHrefs(content, items) {
|
|
33
33
|
const bodyStart = bodyStartOf(content);
|
|
@@ -56,28 +56,28 @@ export function verify(schema) {
|
|
|
56
56
|
export function validate(library, context = { binaryTargets: [] }, model = { types: {} }) {
|
|
57
57
|
const binaryTargets = new Set(context.binaryTargets);
|
|
58
58
|
const files = Object.keys(library).sort();
|
|
59
|
+
const types = new Map();
|
|
59
60
|
const documents = new Map();
|
|
60
61
|
for (const file of files) {
|
|
61
62
|
if (binaryTargets.has(file))
|
|
62
63
|
return refuse(file, 'binary-target-document');
|
|
63
64
|
const parsed = parse(library[file], file);
|
|
64
|
-
documents.set(file, parsed);
|
|
65
65
|
if (!parsed.ok)
|
|
66
66
|
return { verdict: 'refuse', ...parsed.refusal };
|
|
67
|
+
types.set(file, parsed.document.type ?? BUILT_IN_TYPE);
|
|
68
|
+
if (instanceType(parsed.document) !== BUILT_IN_TYPE)
|
|
69
|
+
documents.set(file, parsed.document);
|
|
67
70
|
}
|
|
68
71
|
const definitions = new Map(Object.entries(model.types));
|
|
69
72
|
const sectionReferences = new Map();
|
|
70
|
-
for (const file of
|
|
71
|
-
const
|
|
72
|
-
if (parsed === undefined || !parsed.ok)
|
|
73
|
-
continue;
|
|
74
|
-
const kind = instanceType(parsed.document);
|
|
73
|
+
for (const [file, document] of documents) {
|
|
74
|
+
const kind = instanceType(document);
|
|
75
75
|
if (kind === BUILT_IN_TYPE)
|
|
76
76
|
continue;
|
|
77
77
|
const definition = kind === null ? undefined : definitions.get(kind);
|
|
78
78
|
if (definition === undefined)
|
|
79
79
|
return refuse(file, 'unknown-type', { location: '/type' });
|
|
80
|
-
const fieldFailure = frontmatterRefusal(definition,
|
|
80
|
+
const fieldFailure = frontmatterRefusal(definition, document.fields);
|
|
81
81
|
if (fieldFailure !== undefined) {
|
|
82
82
|
return refuse(file, fieldFailure.rule, { location: fieldFailure.location });
|
|
83
83
|
}
|
|
@@ -105,18 +105,15 @@ export function validate(library, context = { binaryTargets: [] }, model = { typ
|
|
|
105
105
|
}
|
|
106
106
|
sectionReferences.set(file, references);
|
|
107
107
|
}
|
|
108
|
-
for (const file of
|
|
109
|
-
const
|
|
110
|
-
if (parsed === undefined || !parsed.ok)
|
|
111
|
-
continue;
|
|
112
|
-
const kind = instanceType(parsed.document);
|
|
108
|
+
for (const [file, document] of documents) {
|
|
109
|
+
const kind = instanceType(document);
|
|
113
110
|
if (kind === null || kind === BUILT_IN_TYPE)
|
|
114
111
|
continue;
|
|
115
112
|
const definition = definitions.get(kind);
|
|
116
113
|
if (definition === undefined)
|
|
117
114
|
continue;
|
|
118
|
-
for (const { pointer, to, value } of references(
|
|
119
|
-
if (!reaches(file, value, to,
|
|
115
|
+
for (const { pointer, to, value } of references(document, definition)) {
|
|
116
|
+
if (!reaches(file, value, to, types, binaryTargets))
|
|
120
117
|
return refuse(file, 'unresolved-reference', { location: pointer });
|
|
121
118
|
}
|
|
122
119
|
const body = bodyAfterFrontmatter(library[file]);
|
|
@@ -127,24 +124,21 @@ export function validate(library, context = { binaryTargets: [] }, model = { typ
|
|
|
127
124
|
}
|
|
128
125
|
for (const { section, to, hrefs } of sectionReferences.get(file)) {
|
|
129
126
|
for (const href of hrefs) {
|
|
130
|
-
if (!reaches(file, href, to,
|
|
127
|
+
if (!reaches(file, href, to, types, binaryTargets))
|
|
131
128
|
return refuse(file, 'unresolved-reference', { location: section });
|
|
132
129
|
}
|
|
133
130
|
}
|
|
134
131
|
}
|
|
135
132
|
const missing = new Map();
|
|
136
|
-
for (const file of
|
|
137
|
-
const
|
|
138
|
-
if (parsed === undefined || !parsed.ok)
|
|
139
|
-
continue;
|
|
140
|
-
const kind = instanceType(parsed.document);
|
|
133
|
+
for (const [file, document] of documents) {
|
|
134
|
+
const kind = instanceType(document);
|
|
141
135
|
if (kind === null || kind === BUILT_IN_TYPE)
|
|
142
136
|
continue;
|
|
143
137
|
const definition = definitions.get(kind);
|
|
144
138
|
if (definition === undefined)
|
|
145
139
|
continue;
|
|
146
140
|
const named = [
|
|
147
|
-
...references(
|
|
141
|
+
...references(document, definition),
|
|
148
142
|
...sectionReferences
|
|
149
143
|
.get(file)
|
|
150
144
|
.flatMap(({ to, hrefs }) => hrefs.map((value) => ({ value, to }))),
|
|
@@ -155,7 +149,7 @@ export function validate(library, context = { binaryTargets: [] }, model = { typ
|
|
|
155
149
|
const resolved = classifyHref(file, value);
|
|
156
150
|
if (resolved.kind !== 'path')
|
|
157
151
|
continue;
|
|
158
|
-
if (
|
|
152
|
+
if (types.has(resolved.path) || binaryTargets.has(resolved.path))
|
|
159
153
|
continue;
|
|
160
154
|
const referrers = missing.get(resolved.path) ?? [];
|
|
161
155
|
referrers.push(file);
|
package/dist/yaml.d.ts
CHANGED
|
@@ -16,8 +16,7 @@ export type YamlSeq = {
|
|
|
16
16
|
};
|
|
17
17
|
export type YamlEntry = {
|
|
18
18
|
readonly key: string;
|
|
19
|
-
readonly
|
|
20
|
-
readonly keyEnd: number;
|
|
19
|
+
readonly after: number;
|
|
21
20
|
readonly value: YamlNode;
|
|
22
21
|
};
|
|
23
22
|
export type YamlMap = {
|
|
@@ -32,7 +31,12 @@ export declare function parseYamlMapping(text: string, start: number, end: numbe
|
|
|
32
31
|
export declare function jsValue(node: YamlNode): unknown;
|
|
33
32
|
export declare function mapEntry(map: YamlMap, key: string): YamlEntry | undefined;
|
|
34
33
|
export declare function isPlainSafe(text: string): boolean;
|
|
35
|
-
export
|
|
34
|
+
export type FrontmatterValue = string | number | boolean | null | readonly FrontmatterValue[] | {
|
|
35
|
+
readonly [name: string]: FrontmatterValue;
|
|
36
|
+
};
|
|
37
|
+
export declare function plain(value: unknown): value is Record<string, unknown>;
|
|
38
|
+
export declare function frontmatterValue(value: unknown): value is FrontmatterValue;
|
|
39
|
+
export declare function serializeJs(value: FrontmatterValue): string;
|
|
36
40
|
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
37
41
|
export declare function serializeKey(name: string): string;
|
|
38
42
|
export declare function bodyStartAfterYaml(content: string, yamlEnd: number): number;
|
package/dist/yaml.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../src/yaml.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAU,SAAQ,KAAK;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM;IAAnC,YAAqB,MAAM,EAAE,MAAM,EAGlC;CACF;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;IACjD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,
|
|
1
|
+
{"version":3,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G;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAqB9F;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAgBjE;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAEzD"}
|
package/dist/yaml.js
CHANGED
|
@@ -84,6 +84,30 @@ export function interpretPlain(text) {
|
|
|
84
84
|
return Number(text);
|
|
85
85
|
return text;
|
|
86
86
|
}
|
|
87
|
+
const ESCAPES = {
|
|
88
|
+
b: '\b',
|
|
89
|
+
f: '\f',
|
|
90
|
+
n: '\n',
|
|
91
|
+
r: '\r',
|
|
92
|
+
t: '\t',
|
|
93
|
+
'"': '"',
|
|
94
|
+
'/': '/',
|
|
95
|
+
'\\': '\\',
|
|
96
|
+
};
|
|
97
|
+
function parseEscape(c) {
|
|
98
|
+
c.i += 1;
|
|
99
|
+
const escaped = peek(c);
|
|
100
|
+
const held = ESCAPES[escaped];
|
|
101
|
+
if (held !== undefined) {
|
|
102
|
+
c.i += 1;
|
|
103
|
+
return held;
|
|
104
|
+
}
|
|
105
|
+
const hex = c.text.slice(c.i + 1, c.i + 5);
|
|
106
|
+
if (escaped !== 'u' || c.i + 5 > c.end || !/^[0-9A-Fa-f]{4}$/.test(hex))
|
|
107
|
+
throw new YamlError(c.i);
|
|
108
|
+
c.i += 5;
|
|
109
|
+
return String.fromCharCode(Number.parseInt(hex, 16));
|
|
110
|
+
}
|
|
87
111
|
function parseQuoted(c) {
|
|
88
112
|
const quote = peek(c);
|
|
89
113
|
const start = c.i;
|
|
@@ -91,31 +115,19 @@ function parseQuoted(c) {
|
|
|
91
115
|
let out = '';
|
|
92
116
|
while (c.i < c.end) {
|
|
93
117
|
const ch = peek(c);
|
|
118
|
+
if (quote === "'" && ch === "'" && c.i + 1 < c.end && c.text[c.i + 1] === "'") {
|
|
119
|
+
out += "'";
|
|
120
|
+
c.i += 2;
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
94
123
|
if (ch === quote) {
|
|
95
124
|
c.i += 1;
|
|
96
125
|
return scalar(out, start, c.i);
|
|
97
126
|
}
|
|
98
127
|
if (ch === '\n' || ch === '\r')
|
|
99
128
|
throw new YamlError(c.i);
|
|
100
|
-
if (quote === "'" && ch === "'" && c.text[c.i + 1] === "'") {
|
|
101
|
-
out += "'";
|
|
102
|
-
c.i += 2;
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
129
|
if (quote === '"' && ch === '\\') {
|
|
106
|
-
|
|
107
|
-
const escaped = peek(c);
|
|
108
|
-
if (escaped === 'n')
|
|
109
|
-
out += '\n';
|
|
110
|
-
else if (escaped === 't')
|
|
111
|
-
out += '\t';
|
|
112
|
-
else if (escaped === '"')
|
|
113
|
-
out += '"';
|
|
114
|
-
else if (escaped === '\\')
|
|
115
|
-
out += '\\';
|
|
116
|
-
else
|
|
117
|
-
throw new YamlError(c.i);
|
|
118
|
-
c.i += 1;
|
|
130
|
+
out += parseEscape(c);
|
|
119
131
|
continue;
|
|
120
132
|
}
|
|
121
133
|
out += ch;
|
|
@@ -208,11 +220,12 @@ function parseFlowMap(c) {
|
|
|
208
220
|
if (peek(c) !== ':')
|
|
209
221
|
throw new YamlError(c.i);
|
|
210
222
|
c.i += 1;
|
|
223
|
+
const after = c.i;
|
|
211
224
|
const value = parseFlowValue(c);
|
|
212
225
|
if (seen.has(key.name))
|
|
213
226
|
throw new YamlError(key.start);
|
|
214
227
|
seen.add(key.name);
|
|
215
|
-
entries.push({ key: key.name,
|
|
228
|
+
entries.push({ key: key.name, after, value });
|
|
216
229
|
skipFlowSpace(c);
|
|
217
230
|
if (peek(c) === ',') {
|
|
218
231
|
c.i += 1;
|
|
@@ -254,6 +267,7 @@ function parseFlowSeq(c) {
|
|
|
254
267
|
throw new YamlError(c.i);
|
|
255
268
|
}
|
|
256
269
|
function parseValue(c, parentKeyIndent) {
|
|
270
|
+
const at = c.i;
|
|
257
271
|
skipSpaces(c);
|
|
258
272
|
if (peek(c) === '#')
|
|
259
273
|
skipToEol(c);
|
|
@@ -262,12 +276,12 @@ function parseValue(c, parentKeyIndent) {
|
|
|
262
276
|
skipEol(c);
|
|
263
277
|
skipBlankAndComments(c);
|
|
264
278
|
if (c.i >= c.end)
|
|
265
|
-
return scalar(null,
|
|
279
|
+
return scalar(null, at, at);
|
|
266
280
|
const nextIndent = indentAt(c);
|
|
267
281
|
if (nextIndent === parentKeyIndent && seqAhead(c))
|
|
268
282
|
return parseBlockSeq(c, nextIndent);
|
|
269
283
|
if (nextIndent <= parentKeyIndent)
|
|
270
|
-
return scalar(null,
|
|
284
|
+
return scalar(null, at, at);
|
|
271
285
|
if (peek(c) === '-')
|
|
272
286
|
return parseBlockSeq(c, nextIndent);
|
|
273
287
|
if (peek(c) === '[')
|
|
@@ -315,9 +329,6 @@ function lineStartOf(c) {
|
|
|
315
329
|
j -= 1;
|
|
316
330
|
return j;
|
|
317
331
|
}
|
|
318
|
-
function valueEnd(value, marked) {
|
|
319
|
-
return value.kind === 'scalar' && value.start === value.end ? marked : value.end;
|
|
320
|
-
}
|
|
321
332
|
function parseSeqItem(c, indent) {
|
|
322
333
|
skipSpaces(c);
|
|
323
334
|
if (peek(c) !== '#' && peek(c) !== '\n' && peek(c) !== '\r' && c.i < c.end && mappingAhead(c))
|
|
@@ -337,10 +348,9 @@ function parseBlockSeq(c, indent) {
|
|
|
337
348
|
if (peek(c) !== '-')
|
|
338
349
|
break;
|
|
339
350
|
c.i += 1;
|
|
340
|
-
const marked = c.i;
|
|
341
351
|
const item = parseSeqItem(c, indent);
|
|
342
352
|
items.push(item);
|
|
343
|
-
end =
|
|
353
|
+
end = item.end;
|
|
344
354
|
}
|
|
345
355
|
return { kind: 'seq', items, start, end };
|
|
346
356
|
}
|
|
@@ -366,13 +376,13 @@ function parseBlockMap(c, indent, inline = false) {
|
|
|
366
376
|
if (peek(c) !== ':')
|
|
367
377
|
throw new YamlError(c.i);
|
|
368
378
|
c.i += 1;
|
|
369
|
-
const
|
|
379
|
+
const after = c.i;
|
|
370
380
|
const value = parseValue(c, indent);
|
|
371
381
|
if (seen.has(key.name))
|
|
372
382
|
throw new YamlError(key.start);
|
|
373
383
|
seen.add(key.name);
|
|
374
|
-
entries.push({ key: key.name,
|
|
375
|
-
end =
|
|
384
|
+
entries.push({ key: key.name, after, value });
|
|
385
|
+
end = value.end;
|
|
376
386
|
}
|
|
377
387
|
return { kind: 'map', entries, start, end };
|
|
378
388
|
}
|
|
@@ -418,24 +428,42 @@ export function isPlainSafe(text) {
|
|
|
418
428
|
return false;
|
|
419
429
|
return true;
|
|
420
430
|
}
|
|
431
|
+
export function plain(value) {
|
|
432
|
+
if (!isRecord(value))
|
|
433
|
+
return false;
|
|
434
|
+
const prototype = Object.getPrototypeOf(value);
|
|
435
|
+
return prototype === Object.prototype || prototype === null;
|
|
436
|
+
}
|
|
437
|
+
function listed(value) {
|
|
438
|
+
const keys = Object.keys(value);
|
|
439
|
+
return keys.length === value.length && keys.every((key, index) => key === String(index));
|
|
440
|
+
}
|
|
441
|
+
function heldWithin(value, within) {
|
|
442
|
+
if (value === null || typeof value === 'string' || typeof value === 'boolean')
|
|
443
|
+
return true;
|
|
444
|
+
if (typeof value === 'number')
|
|
445
|
+
return Number.isFinite(value);
|
|
446
|
+
if (typeof value !== 'object' || within.includes(value))
|
|
447
|
+
return false;
|
|
448
|
+
const path = [...within, value];
|
|
449
|
+
const held = (item) => heldWithin(item, path);
|
|
450
|
+
if (Array.isArray(value))
|
|
451
|
+
return listed(value) && value.every(held);
|
|
452
|
+
return plain(value) && Object.values(value).every(held);
|
|
453
|
+
}
|
|
454
|
+
export function frontmatterValue(value) {
|
|
455
|
+
return heldWithin(value, []);
|
|
456
|
+
}
|
|
421
457
|
export function serializeJs(value) {
|
|
422
|
-
if (value === null)
|
|
423
|
-
return 'null';
|
|
424
|
-
if (value === true)
|
|
425
|
-
return 'true';
|
|
426
|
-
if (value === false)
|
|
427
|
-
return 'false';
|
|
428
|
-
if (typeof value === 'number' && Number.isFinite(value))
|
|
429
|
-
return JSON.stringify(value);
|
|
430
458
|
if (typeof value === 'string')
|
|
431
459
|
return isPlainSafe(value) ? value : JSON.stringify(value);
|
|
460
|
+
if (value === null || typeof value !== 'object')
|
|
461
|
+
return JSON.stringify(value);
|
|
432
462
|
if (Array.isArray(value))
|
|
433
463
|
return `[${value.map(serializeJs).join(', ')}]`;
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
.join(', ')}}`;
|
|
438
|
-
throw new YamlError(0);
|
|
464
|
+
return `{${Object.entries(value)
|
|
465
|
+
.map(([key, held]) => `${serializeKey(key)}: ${serializeJs(held)}`)
|
|
466
|
+
.join(', ')}}`;
|
|
439
467
|
}
|
|
440
468
|
export function isRecord(value) {
|
|
441
469
|
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
@@ -485,7 +513,8 @@ export function equalValue(left, right) {
|
|
|
485
513
|
if (left === right)
|
|
486
514
|
return true;
|
|
487
515
|
if (Array.isArray(left) && Array.isArray(right)) {
|
|
488
|
-
return (left.length === right.length &&
|
|
516
|
+
return (left.length === right.length &&
|
|
517
|
+
Array.from(left).every((item, index) => equalValue(item, right[index])));
|
|
489
518
|
}
|
|
490
519
|
if (isRecord(left) && isRecord(right)) {
|
|
491
520
|
const keys = Object.keys(left);
|
package/fixtures/README.md
CHANGED
|
@@ -136,6 +136,6 @@ Library is accepted too, so `unresolved-link` never names it and
|
|
|
136
136
|
## YAML subset
|
|
137
137
|
|
|
138
138
|
Frontmatter and a schema text are each a mapping in a closed YAML subset: block and flow mappings,
|
|
139
|
-
block and flow sequences, a block sequence item that opens a mapping, plain and quoted scalars, `true`, `false`, `null`,
|
|
139
|
+
block and flow sequences, a block sequence item that opens a mapping, plain and quoted scalars (a single-quoted scalar doubles its apostrophe, a double-quoted one takes JSON's escapes), `true`, `false`, `null`,
|
|
140
140
|
and decimal numbers. It does not take YAML 1.1 boolean or timestamp aliases,
|
|
141
141
|
octal numbers, anchors, tags, or block scalars. A mapping carries each key once.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentshouse/mdmodel",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-c3208a08ee314",
|
|
4
4
|
"description": "MD Type language, parser, validator, structured change application, Markdown syntax profile, and conformance fixtures",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|