@agentshouse/mdmodel 0.1.0-cad192ab63d5f → 0.1.0-ccf1367190878
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 +47 -47
- package/dist/condition.d.ts +0 -1
- package/dist/condition.d.ts.map +1 -1
- package/dist/condition.js +5 -7
- package/dist/definition.d.ts +14 -0
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +134 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/API.md
CHANGED
|
@@ -44,10 +44,14 @@ if (parsed.ok) {
|
|
|
44
44
|
`verify(schema)` reads one schema text, the MD Types of one Room or App: one JSON Schema document
|
|
45
45
|
(draft 2020-12) in the YAML subset. Every top-level key but `$defs` names an MD Type holding the
|
|
46
46
|
JSON Schema of its frontmatter; `$defs` holds shapes the types reuse, reached by a `$ref` under
|
|
47
|
-
`#/$defs/` alone. `type` and the built-in `any` are never declared. The model adds
|
|
47
|
+
`#/$defs/` alone. `type` and the built-in `any` are never declared. The model adds its keywords:
|
|
48
48
|
`reference` on a string names one MD Type, several, `any` or `attachment`; `sections` declares a
|
|
49
49
|
type's H2 sections, each `{ kind: text }` or `{ kind: list, items }` over one string, number,
|
|
50
|
-
integer or boolean, optionally `required: true`; `member_document: true` marks at most one type.
|
|
50
|
+
integer or boolean, optionally `required: true`; `member_document: true` marks at most one type. A
|
|
51
|
+
type alone takes `create_roles` and `delete_roles`, each a list of role names. On a field of a
|
|
52
|
+
type's own `properties` alone, `change_roles` and `initial_roles` each list role names, and
|
|
53
|
+
`transitions` lists `{ from, to, roles? }`, each end a scalar or `null`, on a field whose `type`,
|
|
54
|
+
`enum`, `const`, `$ref`, `allOf`, `anyOf`, `oneOf`, `if` and `not` admit no list or object.
|
|
51
55
|
|
|
52
56
|
```yaml
|
|
53
57
|
$defs:
|
|
@@ -63,18 +67,19 @@ contact: { member_document: true }
|
|
|
63
67
|
```
|
|
64
68
|
|
|
65
69
|
The model's `types` expose each MD Type's `name`, `memberDocument`, `sections`, `shape` (the type as
|
|
66
|
-
written with every `$defs` shape it reaches),
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
`
|
|
70
|
-
`
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
written, its rule keywords left out, with every `$defs` shape it reaches), `createRoles` and
|
|
71
|
+
`deleteRoles` when written, its `rules` by field as `changeRoles`, `initialRoles` and `transitions`,
|
|
72
|
+
the facts of its `frontmatter` and `fields`, its top-level ones: JSON `type`, `format`, `values`,
|
|
73
|
+
`reference` targets, `items`, `properties`, an open map's `patterns` and `additional`, and `prose`,
|
|
74
|
+
a string with no `enum`, `const`, `format`, `pattern` or `reference`. Facts join `$ref` and `allOf`
|
|
75
|
+
to their siblings and the variants of `anyOf`, `oneOf`, `then`, `else` and `dependentSchemas`, a
|
|
76
|
+
variant's own keys `conditional`; a path without one `type`, `null` aside, has none. A malformed
|
|
77
|
+
schema is refused whole, naming its `rule`, the keyword or the model's own, and the JSON Pointer
|
|
78
|
+
`location` it concerns, such as `/plan/properties/status/enum`, or `line <n>` outside the YAML
|
|
79
|
+
subset. `pointerFacts(definition, pointer)` reads the facts a frontmatter pointer reaches,
|
|
80
|
+
`itemFacts` and `memberFacts` take one step and `crossedFacts` reads a list's item facts;
|
|
81
|
+
`pointerSegments` and `escapePointer` split and write a pointer, `ARRAY_INDEX` matches an index
|
|
82
|
+
segment, and `ATTACHMENT` is the `reference` that admits any path.
|
|
78
83
|
|
|
79
84
|
`validate(library, context?, model?)` takes the resulting text Library and one `ValidationContext`
|
|
80
85
|
of `binaryTargets: readonly string[]`, none when omitted. Library keys and binary targets share one
|
|
@@ -114,11 +119,11 @@ boolean, a finite number, a list without holes or a plain object of them, holdin
|
|
|
114
119
|
`equalValue(left, right)` compares two by value, whatever their key order, as `apply` compares a
|
|
115
120
|
field with its prior.
|
|
116
121
|
|
|
117
|
-
`Document.preamble` is a readonly string
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
+
`Document.preamble` is a readonly string holding the exact source after frontmatter and before the
|
|
123
|
+
first section heading the section parser recognizes, `''` when empty, whitespace, newlines, a
|
|
124
|
+
leading H1 and any fenced text before the first section included. The closing frontmatter
|
|
125
|
+
delimiter and its line ending belong to frontmatter: `bodyAfterFrontmatter(content)` is the exact
|
|
126
|
+
source after them, the whole text when it opens no closed fence, and the preamble begins it.
|
|
122
127
|
`headingLines(content, from, to)` reads each ATX heading outside a fence, by `level` and `name`.
|
|
123
128
|
|
|
124
129
|
```ts
|
|
@@ -200,18 +205,16 @@ profile reads back: bare when it carries no whitespace, does not open with `<`,
|
|
|
200
205
|
parentheses, otherwise inside angle brackets, which the original form is kept in when it still
|
|
201
206
|
fits. A destination that neither form can carry is refused as `unwritable-link`.
|
|
202
207
|
|
|
203
|
-
`project(document, file, context?)` is the Embedding projection input of one
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
contributes its
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
them, exactly as written. The Path and every other value stay outside, so
|
|
214
|
-
changing them alone leaves the projection unchanged.
|
|
208
|
+
`project(document, file, context?)` is the Embedding projection input of one Document: the prose a
|
|
209
|
+
consumer embeds, with every internal Markdown-document link reduced to the label a reader sees. A
|
|
210
|
+
Document that declares no MD type contributes its body after the frontmatter fence. A typed one
|
|
211
|
+
contributes its prose values, its preamble, and every H2 section its MD type does not declare as
|
|
212
|
+
structure, each with its own heading line and every occurrence of a repeated name, in Document
|
|
213
|
+
order: a declared text section, a list section of prose items and an undeclared section are in; a
|
|
214
|
+
list section of any other item schema is not. A prose value is a frontmatter string at any depth
|
|
215
|
+
whose schema is prose, projected bare and followed by a blank line, in the order the Document writes
|
|
216
|
+
them, exactly as written. The Path and every other value stay outside, so changing them alone leaves
|
|
217
|
+
the projection unchanged.
|
|
215
218
|
|
|
216
219
|
```ts
|
|
217
220
|
const parsed = parse(content);
|
|
@@ -224,16 +227,14 @@ if (parsed.ok) {
|
|
|
224
227
|
}
|
|
225
228
|
```
|
|
226
229
|
|
|
227
|
-
`ProjectionContext` carries `documentTargets`, the collection-relative Paths the
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
the model reads no bytes, resolves no authority, and classifies nothing it was
|
|
236
|
-
not given.
|
|
230
|
+
`ProjectionContext` carries `documentTargets`, the collection-relative Paths the caller holds as
|
|
231
|
+
Markdown documents, and `definition`, the verified MD Type the Document's `type` names, taken from
|
|
232
|
+
the model `verify` returned. A Document that declares a type the caller supplies no definition for
|
|
233
|
+
is refused as `unknown-type`. `documentTargets` is what makes a destination internal: a destination
|
|
234
|
+
resolving to a supplied Path is internal, and every other destination stays authored text, a binary
|
|
235
|
+
target and a Path nobody supplied alike. The caller supplies that membership, as it does for
|
|
236
|
+
`validate`; the model reads no bytes, resolves no authority, and classifies nothing it was not
|
|
237
|
+
given.
|
|
237
238
|
|
|
238
239
|
An internal link contributes its visible label and no destination, fragment, or
|
|
239
240
|
title, in the inline `[label](path)`, full `[label][id]`, collapsed
|
|
@@ -248,11 +249,10 @@ and `validate` read. `project` returns text and never rewrites the Document.
|
|
|
248
249
|
A `link` change leaves the projection of every Document it rewrites
|
|
249
250
|
byte-identical, while a changed visible label changes it.
|
|
250
251
|
|
|
251
|
-
`divide(document, file, context)` divides that same Embedding projection input
|
|
252
|
-
|
|
253
|
-
`
|
|
254
|
-
|
|
255
|
-
positions, so a caller stores the extent and hydrates the text it shows from
|
|
252
|
+
`divide(document, file, context)` divides that same Embedding projection input into ordered Spans
|
|
253
|
+
under the budget the caller supplies. Each Span carries the `text` to embed and the `start` and
|
|
254
|
+
`end` of the extent it addresses in the Document's own source, as UTF-8 byte offsets into that
|
|
255
|
+
source and never string positions, so a caller stores the extent and hydrates the text it shows from
|
|
256
256
|
the Document itself.
|
|
257
257
|
|
|
258
258
|
```ts
|
|
@@ -350,7 +350,7 @@ names it. A field absent on both sides never fires; `from: 'new'` admits only a
|
|
|
350
350
|
`to: 'deleted'` only a deletion, and listed values need that side to hold `field` `in` them.
|
|
351
351
|
|
|
352
352
|
`itemFires(condition, item, owner)` compares `source` and `address` where given and holds `match`
|
|
353
|
-
over `/delivery`, `/source`, `/
|
|
353
|
+
over `/delivery`, `/source`, `/container`, `/author`, `/has_attachment`,
|
|
354
354
|
`/headers/<name>` and `/json/<pointer>`, unknown for an item with no JSON. `prosePaths(facts)` lists
|
|
355
355
|
the prose and section paths whose text builds `changed`; `pointed(value, pointer)` reads a JSON
|
|
356
356
|
Pointer, `undefined` where nothing is; `dated(value)` checks a `YYYY-MM-DD` date, and
|
package/dist/condition.d.ts
CHANGED
|
@@ -120,7 +120,6 @@ export type ItemFacts = {
|
|
|
120
120
|
readonly source: string | null;
|
|
121
121
|
readonly address: string | null;
|
|
122
122
|
readonly has_attachment: boolean;
|
|
123
|
-
readonly provider: string | null;
|
|
124
123
|
readonly container: string | null;
|
|
125
124
|
readonly author: string | null;
|
|
126
125
|
readonly headers: Readonly<Record<string, string>>;
|
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,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG1D,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAA;CAAE,CAAC;AAElF,MAAM,MAAM,aAAa,GACrB;IAAE,QAAQ,CAAC,GAAG,EAAE,SAA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AAE,MAAM,GAAG,OAAO,CAO3F"}
|
package/dist/condition.js
CHANGED
|
@@ -300,13 +300,11 @@ function readItem(item, path) {
|
|
|
300
300
|
? item.delivery
|
|
301
301
|
: path === '/source'
|
|
302
302
|
? item.source
|
|
303
|
-
: path === '/
|
|
304
|
-
? item.
|
|
305
|
-
: path === '/
|
|
306
|
-
? item.
|
|
307
|
-
:
|
|
308
|
-
? item.author
|
|
309
|
-
: null;
|
|
303
|
+
: path === '/container'
|
|
304
|
+
? item.container
|
|
305
|
+
: path === '/author'
|
|
306
|
+
? item.author
|
|
307
|
+
: null;
|
|
310
308
|
return value === null ? undefined : single({ kind: 'string', value });
|
|
311
309
|
}
|
|
312
310
|
function wanted(value, owner) {
|
package/dist/definition.d.ts
CHANGED
|
@@ -29,12 +29,26 @@ export type Shape = {
|
|
|
29
29
|
readonly schema: Readonly<Record<string, unknown>>;
|
|
30
30
|
readonly defs: Readonly<Record<string, unknown>>;
|
|
31
31
|
};
|
|
32
|
+
export type RuleValue = string | number | boolean | null;
|
|
33
|
+
export type Transition = {
|
|
34
|
+
readonly from: RuleValue;
|
|
35
|
+
readonly to: RuleValue;
|
|
36
|
+
readonly roles?: readonly string[];
|
|
37
|
+
};
|
|
38
|
+
export type FieldRules = {
|
|
39
|
+
readonly changeRoles?: readonly string[];
|
|
40
|
+
readonly initialRoles?: readonly string[];
|
|
41
|
+
readonly transitions?: readonly Transition[];
|
|
42
|
+
};
|
|
32
43
|
export type Definition = {
|
|
33
44
|
readonly name: string;
|
|
34
45
|
readonly memberDocument: boolean;
|
|
35
46
|
readonly frontmatter: ValueFacts;
|
|
36
47
|
readonly fields: Readonly<Record<string, ValueFacts>>;
|
|
37
48
|
readonly sections: Readonly<Record<string, SectionSpec>>;
|
|
49
|
+
readonly rules: Readonly<Record<string, FieldRules>>;
|
|
50
|
+
readonly createRoles?: readonly string[];
|
|
51
|
+
readonly deleteRoles?: readonly string[];
|
|
38
52
|
readonly shape: Shape;
|
|
39
53
|
};
|
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/B,CAAC;AAEF,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,EAAE,CAK5D;AAED,wBAAgB,UAAU,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAItF;AAqBD,wBAAgB,YAAY,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAc9F;AAsPD,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,OAAO,CAiChE"}
|
package/dist/definition.js
CHANGED
|
@@ -12,6 +12,18 @@ export const JSON_TYPES = [
|
|
|
12
12
|
export const BUILT_IN_TYPE = 'any';
|
|
13
13
|
export const ATTACHMENT = 'attachment';
|
|
14
14
|
const SCALAR_TYPES = new Set(['string', 'number', 'integer', 'boolean']);
|
|
15
|
+
const COMPOSITES = ['array', 'object'];
|
|
16
|
+
const ANNOTATIONS = new Set([
|
|
17
|
+
'$comment',
|
|
18
|
+
'title',
|
|
19
|
+
'description',
|
|
20
|
+
'default',
|
|
21
|
+
'examples',
|
|
22
|
+
'deprecated',
|
|
23
|
+
'readOnly',
|
|
24
|
+
'writeOnly',
|
|
25
|
+
]);
|
|
26
|
+
const FIELD_RULES = ['change_roles', 'initial_roles', 'transitions'];
|
|
15
27
|
const DEFS_REFERENCE = '#/$defs/';
|
|
16
28
|
const UNRESOLVED = /[\u0000-\u001f\u007f%[\]\\^{|}]|\s$/u;
|
|
17
29
|
export const ARRAY_INDEX = /^(?:0|[1-9][0-9]*)$/u;
|
|
@@ -538,21 +550,134 @@ function deepFreeze(value) {
|
|
|
538
550
|
}
|
|
539
551
|
return value;
|
|
540
552
|
}
|
|
553
|
+
function ruleValue(value) {
|
|
554
|
+
return value === null || typeof value === 'string' || typeof value === 'boolean' || finite(value);
|
|
555
|
+
}
|
|
556
|
+
function roleNames(value) {
|
|
557
|
+
return strings(value) && value.every((name) => name !== '');
|
|
558
|
+
}
|
|
559
|
+
function compositesOf(value) {
|
|
560
|
+
return Array.isArray(value) ? ['array'] : isRecord(value) ? ['object'] : [];
|
|
561
|
+
}
|
|
562
|
+
function typed(type) {
|
|
563
|
+
const types = typeof type === 'string' ? [type] : type;
|
|
564
|
+
return Array.isArray(types) ? COMPOSITES.filter((kind) => types.includes(kind)) : undefined;
|
|
565
|
+
}
|
|
566
|
+
function admittedWhole(node) {
|
|
567
|
+
if (node === true)
|
|
568
|
+
return COMPOSITES;
|
|
569
|
+
if (!isRecord(node) || Object.keys(node).some((key) => key !== 'type' && !ANNOTATIONS.has(key)))
|
|
570
|
+
return [];
|
|
571
|
+
return typed(node.type) ?? COMPOSITES;
|
|
572
|
+
}
|
|
573
|
+
function composites(node, defs, seen) {
|
|
574
|
+
if (node === false)
|
|
575
|
+
return [];
|
|
576
|
+
if (!isRecord(node))
|
|
577
|
+
return COMPOSITES;
|
|
578
|
+
const each = (nodes) => Array.isArray(nodes) ? nodes.map((one) => composites(one, defs, seen)) : [];
|
|
579
|
+
const target = typeof node.$ref === 'string' ? refTarget(node.$ref, defs)?.node : undefined;
|
|
580
|
+
const conditioned = () => {
|
|
581
|
+
const met = composites(node.then ?? true, defs, seen);
|
|
582
|
+
return COMPOSITES.filter((kind) => (composites(node.if, defs, seen).includes(kind) && met.includes(kind)) ||
|
|
583
|
+
composites(node.else ?? true, defs, seen).includes(kind));
|
|
584
|
+
};
|
|
585
|
+
const bounds = [
|
|
586
|
+
typed(node.type),
|
|
587
|
+
Array.isArray(node.enum) ? node.enum.flatMap(compositesOf) : undefined,
|
|
588
|
+
Object.hasOwn(node, 'const') ? compositesOf(node.const) : undefined,
|
|
589
|
+
target === undefined || seen.has(target)
|
|
590
|
+
? undefined
|
|
591
|
+
: composites(target, defs, new Set([...seen, target])),
|
|
592
|
+
...each(node.allOf),
|
|
593
|
+
...[node.anyOf, node.oneOf].filter(Array.isArray).map((branches) => each(branches).flat()),
|
|
594
|
+
Object.hasOwn(node, 'if') ? conditioned() : undefined,
|
|
595
|
+
Object.hasOwn(node, 'not')
|
|
596
|
+
? COMPOSITES.filter((kind) => !admittedWhole(node.not).includes(kind))
|
|
597
|
+
: undefined,
|
|
598
|
+
];
|
|
599
|
+
return COMPOSITES.filter((kind) => bounds.every((bound) => bound?.includes(kind) ?? true));
|
|
600
|
+
}
|
|
601
|
+
function transitionOf(value) {
|
|
602
|
+
if (!isRecord(value) || !Object.hasOwn(value, 'from') || !Object.hasOwn(value, 'to'))
|
|
603
|
+
return undefined;
|
|
604
|
+
const { from, to, roles, ...rest } = value;
|
|
605
|
+
if (Object.keys(rest).length > 0 || !ruleValue(from) || !ruleValue(to))
|
|
606
|
+
return undefined;
|
|
607
|
+
if (roles === undefined)
|
|
608
|
+
return { from, to };
|
|
609
|
+
return roleNames(roles) ? { from, to, roles } : undefined;
|
|
610
|
+
}
|
|
611
|
+
function fieldRules(written, field, at, defs) {
|
|
612
|
+
const { change_roles: changeRoles, initial_roles: initialRoles, transitions } = written;
|
|
613
|
+
if (changeRoles !== undefined && !roleNames(changeRoles))
|
|
614
|
+
return refuse('change_roles', `${at}/change_roles`);
|
|
615
|
+
if (initialRoles !== undefined && !roleNames(initialRoles))
|
|
616
|
+
return refuse('initial_roles', `${at}/initial_roles`);
|
|
617
|
+
if (transitions === undefined)
|
|
618
|
+
return {
|
|
619
|
+
...(changeRoles === undefined ? {} : { changeRoles }),
|
|
620
|
+
...(initialRoles === undefined ? {} : { initialRoles }),
|
|
621
|
+
};
|
|
622
|
+
if (!Array.isArray(transitions) || composites(field, defs, new Set()).length > 0)
|
|
623
|
+
return refuse('transitions', `${at}/transitions`);
|
|
624
|
+
const listed = [];
|
|
625
|
+
for (const [index, held] of transitions.entries()) {
|
|
626
|
+
const transition = transitionOf(held);
|
|
627
|
+
if (transition === undefined)
|
|
628
|
+
return refuse('transitions', `${at}/transitions/${index}`);
|
|
629
|
+
listed.push(transition);
|
|
630
|
+
}
|
|
631
|
+
return {
|
|
632
|
+
...(changeRoles === undefined ? {} : { changeRoles }),
|
|
633
|
+
...(initialRoles === undefined ? {} : { initialRoles }),
|
|
634
|
+
transitions: listed,
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
function unruled(schema) {
|
|
638
|
+
const written = new Map();
|
|
639
|
+
if (!isRecord(schema.properties))
|
|
640
|
+
return { schema, written };
|
|
641
|
+
const properties = Object.create(null);
|
|
642
|
+
for (const [field, node] of Object.entries(schema.properties)) {
|
|
643
|
+
if (!isRecord(node) || !FIELD_RULES.some((keyword) => Object.hasOwn(node, keyword))) {
|
|
644
|
+
properties[field] = node;
|
|
645
|
+
continue;
|
|
646
|
+
}
|
|
647
|
+
written.set(field, node);
|
|
648
|
+
properties[field] = Object.fromEntries(Object.entries(node).filter(([keyword]) => !FIELD_RULES.includes(keyword)));
|
|
649
|
+
}
|
|
650
|
+
return { schema: written.size === 0 ? schema : { ...schema, properties }, written };
|
|
651
|
+
}
|
|
541
652
|
function readType(name, value, context) {
|
|
542
653
|
const at = `/${escapePointer(name)}`;
|
|
543
654
|
if (!isRecord(value))
|
|
544
655
|
return refuse('schema', at);
|
|
545
|
-
const { sections: declared, member_document: mark, ...
|
|
656
|
+
const { sections: declared, member_document: mark, create_roles: createRoles, delete_roles: deleteRoles, ...ruled } = value;
|
|
546
657
|
if (mark !== undefined && typeof mark !== 'boolean')
|
|
547
658
|
return refuse('member_document', `${at}/member_document`);
|
|
659
|
+
if (createRoles !== undefined && !roleNames(createRoles))
|
|
660
|
+
return refuse('create_roles', `${at}/create_roles`);
|
|
661
|
+
if (deleteRoles !== undefined && !roleNames(deleteRoles))
|
|
662
|
+
return refuse('delete_roles', `${at}/delete_roles`);
|
|
548
663
|
const read = declared === undefined
|
|
549
664
|
? { sections: Object.create(null) }
|
|
550
665
|
: readSections(declared, `${at}/sections`, context);
|
|
551
666
|
if ('failure' in read)
|
|
552
667
|
return read.failure;
|
|
668
|
+
const { schema, written } = unruled(ruled);
|
|
553
669
|
const failure = schemaFailure(schema, at, context);
|
|
554
670
|
if (failure !== undefined)
|
|
555
671
|
return failure;
|
|
672
|
+
const rules = Object.create(null);
|
|
673
|
+
for (const [field, keywords] of written) {
|
|
674
|
+
const properties = schema.properties;
|
|
675
|
+
const where = `${at}/properties/${escapePointer(field)}`;
|
|
676
|
+
const ruling = fieldRules(keywords, properties[field], where, context.defs);
|
|
677
|
+
if ('rule' in ruling)
|
|
678
|
+
return ruling;
|
|
679
|
+
rules[field] = ruling;
|
|
680
|
+
}
|
|
556
681
|
const memberDocument = mark === true;
|
|
557
682
|
const root = valueFacts(schema, context.defs);
|
|
558
683
|
const fields = Object.assign(Object.create(null), root.properties);
|
|
@@ -560,13 +685,20 @@ function readType(name, value, context) {
|
|
|
560
685
|
fields[MEMBER_FIELD] = { type: 'string', prose: false };
|
|
561
686
|
const defs = Object.create(null);
|
|
562
687
|
reachedDefs(value, context.defs, defs);
|
|
688
|
+
const { create_roles: _create, delete_roles: _delete, ...shaped } = value;
|
|
563
689
|
return {
|
|
564
690
|
name,
|
|
565
691
|
memberDocument,
|
|
566
692
|
frontmatter: { ...root, properties: { ...HOUSE_KEYS, ...fields } },
|
|
567
693
|
fields,
|
|
568
694
|
sections: read.sections,
|
|
569
|
-
|
|
695
|
+
rules,
|
|
696
|
+
...(createRoles === undefined ? {} : { createRoles }),
|
|
697
|
+
...(deleteRoles === undefined ? {} : { deleteRoles }),
|
|
698
|
+
shape: {
|
|
699
|
+
schema: written.size === 0 ? shaped : { ...shaped, properties: schema.properties },
|
|
700
|
+
defs,
|
|
701
|
+
},
|
|
570
702
|
};
|
|
571
703
|
}
|
|
572
704
|
function lineAt(text, offset) {
|
package/dist/index.d.ts
CHANGED
|
@@ -10,10 +10,10 @@ export { MARKDOWN_SYNTAX_PROFILE } from './profile.js';
|
|
|
10
10
|
export { project } from './project.js';
|
|
11
11
|
export { references } from './references.js';
|
|
12
12
|
export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
|
|
13
|
-
export type { Definition, JsonType, PatternFacts, PointerFacts, SectionSpec, Shape, ValueFacts, } from './definition.js';
|
|
13
|
+
export type { Definition, FieldRules, JsonType, PatternFacts, PointerFacts, RuleValue, SectionSpec, Shape, Transition, ValueFacts, } from './definition.js';
|
|
14
14
|
export type { ApplyResult, BodyResult, Change, Division, DivisionContext, Document, DocumentCheck, Frontmatter, FrontmatterResult, Library, ModelVerification, Link, LinkOccurrence, ParseResult, Projection, ProjectionContext, Reached, Reference, Refusal, Span, Validation, ValidationContext, VerifiedModel, } from './types.js';
|
|
15
15
|
export { checkDocument, resolves, sectionReferences, validate, verify } from './validate.js';
|
|
16
16
|
export { VERSION } from './version.js';
|
|
17
|
-
export { equalValue, frontmatterValue } from './yaml.js';
|
|
17
|
+
export { bodyAfterFrontmatter, equalValue, frontmatterValue } from './yaml.js';
|
|
18
18
|
export type { FrontmatterValue } from './yaml.js';
|
|
19
19
|
//# 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,YAAY,EACZ,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,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,MAAM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AAC;AACzB,YAAY,EACV,UAAU,EACV,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,WAAW,EACX,KAAK,EACL,UAAU,EACV,UAAU,GACX,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,iBAAiB,EACjB,IAAI,EACJ,cAAc,EACd,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,OAAO,EACP,SAAS,EACT,OAAO,EACP,IAAI,EACJ,UAAU,EACV,iBAAiB,EACjB,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC/E,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -10,4 +10,4 @@ export { references } from './references.js';
|
|
|
10
10
|
export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
|
|
11
11
|
export { checkDocument, resolves, sectionReferences, validate, verify } from './validate.js';
|
|
12
12
|
export { VERSION } from './version.js';
|
|
13
|
-
export { equalValue, frontmatterValue } from './yaml.js';
|
|
13
|
+
export { bodyAfterFrontmatter, equalValue, frontmatterValue } from './yaml.js';
|
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-ccf1367190878",
|
|
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",
|