@agentshouse/mdmodel 0.1.0-ceaa149100378 → 0.1.0-ced713d53efb3
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 +41 -95
- package/README.md +0 -1
- package/dist/definition.d.ts +1 -1
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +34 -7
- package/dist/document.d.ts +2 -1
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +18 -1
- package/dist/facts.d.ts.map +1 -1
- package/dist/facts.js +3 -2
- package/dist/house-model.d.ts +67 -25
- package/dist/house-model.d.ts.map +1 -1
- package/dist/house-model.js +44 -14
- package/dist/house-references/patterns.d.ts +5 -1
- package/dist/house-references/patterns.d.ts.map +1 -1
- package/dist/house-references/patterns.js +8 -1
- package/dist/index.d.ts +9 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -9
- package/dist/markdown.d.ts +0 -4
- package/dist/markdown.d.ts.map +1 -1
- package/dist/markdown.js +1 -34
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +20 -4
- package/dist/query/language.d.ts +2 -0
- package/dist/query/language.d.ts.map +1 -1
- package/dist/query/language.js +3 -2
- package/dist/query/match.d.ts.map +1 -1
- package/dist/query/match.js +3 -24
- package/dist/query/rows.d.ts +4 -0
- package/dist/query/rows.d.ts.map +1 -1
- package/dist/query/rows.js +21 -0
- package/dist/query/sql.d.ts +2 -0
- package/dist/query/sql.d.ts.map +1 -1
- package/dist/query/sql.js +11 -0
- package/dist/query/walk.d.ts +6 -0
- package/dist/query/walk.d.ts.map +1 -1
- package/dist/query/walk.js +12 -1
- package/dist/reserved.d.ts +1 -0
- package/dist/reserved.d.ts.map +1 -1
- package/dist/reserved.js +15 -4
- package/dist/room-types.d.ts +2 -1
- package/dist/room-types.d.ts.map +1 -1
- package/dist/room-types.js +8 -0
- package/dist/types.d.ts +10 -21
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +2 -0
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +37 -10
- package/dist/view.d.ts +5 -0
- package/dist/view.d.ts.map +1 -0
- package/dist/view.js +27 -0
- package/dist/yaml.d.ts +3 -1
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +153 -32
- package/fixtures/README.md +46 -55
- package/fixtures/cases/absent-link-dangles/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/absent-optional-field/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/absolute-link/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/attachment-reference-any-file/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/attachment-reference-dangles/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/attachment-reference-outside/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-any-reference/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-document-collision/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-image-dangles/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-link-dangles/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-link-outside-collection/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-prototype-reference/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-typed-reference/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/block-scalar-frontmatter/expected.json +1 -0
- package/fixtures/cases/block-scalar-frontmatter/library/notes/literal.md +17 -0
- package/fixtures/cases/block-scalar-frontmatter/library/skills/notes/SKILL.md +10 -0
- package/fixtures/cases/boolean-field/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/{duplicate-link-definition/schema.yaml → bracketed-link-definition/schema.md} +2 -0
- package/fixtures/cases/closed-nested-object/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/composed-root-reference/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/conditional-long-text/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/cross-room-link/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/cross-room-reference/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/date-time-format/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/declared-binary-links/schema.md +3 -0
- package/fixtures/cases/default-unfilled/schema.md +57 -0
- package/fixtures/cases/defs-pattern/schema.md +57 -0
- package/fixtures/cases/dependent-rule/schema.md +57 -0
- package/fixtures/cases/{bracketed-link-definition/schema.yaml → duplicate-link-definition/schema.md} +2 -0
- package/fixtures/cases/email-format/schema.md +57 -0
- package/fixtures/cases/equal-labels/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/fenced-link-definition/schema.md +7 -0
- package/fixtures/cases/field-enum/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/frontmatter-construct/context.json +1 -0
- package/fixtures/cases/frontmatter-construct/expected.json +7 -0
- package/fixtures/cases/frontmatter-construct/library/note.md +6 -0
- package/fixtures/cases/integer-field/schema.md +57 -0
- package/fixtures/cases/interrupted-link-definition/schema.md +3 -0
- package/fixtures/cases/json-schema-constructs/schema.md +57 -0
- package/fixtures/cases/labels-in-the-rooms-language/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/lazy-list-item/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/link-into-a-reserved-name/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/list-item-enum/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/list-item-kind/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/list-items/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/list-of-objects-closed/schema.md +57 -0
- package/fixtures/cases/list-of-objects-item/schema.md +57 -0
- package/fixtures/cases/list-of-objects-reference/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/list-reference-path/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/list-reference-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/list-size/schema.md +57 -0
- package/fixtures/cases/long-fence-link-definition/schema.md +3 -0
- package/fixtures/cases/long-value-past-six-levels/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/malformed-definition/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/malformed-list/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/member-document/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/member-on-another-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/missing-required-field/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/misspelled-key/schema.md +57 -0
- package/fixtures/cases/name-not-a-string/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/nested-defs/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/nested-object-reference/schema.md +34 -0
- package/fixtures/cases/nested-reference/schema.md +34 -0
- package/fixtures/cases/nested-required-field/schema.md +57 -0
- package/fixtures/cases/numeric-range/schema.md +57 -0
- package/fixtures/cases/one-key-two-labels/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/one-key-two-types/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/one-of-variant/schema.md +57 -0
- package/fixtures/cases/other-room-reference/schema.md +34 -0
- package/fixtures/cases/paragraph-link-definition/schema.md +3 -0
- package/fixtures/cases/prototype-field/schema.md +7 -0
- package/fixtures/cases/quoted-link-definition/schema.md +3 -0
- package/fixtures/cases/reference-into-a-reserved-name/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/reference-to-any-file-name/context.json +1 -0
- package/fixtures/cases/reference-to-any-file-name/expected.json +1 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/100%.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/C#.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/My notes.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/[draft].md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/c (d).md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/caf/303/251.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people//320/236/321/202/321/207/321/221/321/202.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/bracket.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/cyrillic.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/decomposed.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/hash.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/parenthesis.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/percent.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/spaced.md +9 -0
- package/fixtures/cases/{referenced-missing-file/schema.yaml → reference-to-any-file-name/schema.md} +2 -0
- package/fixtures/cases/referenced-missing-file/schema.md +12 -0
- package/fixtures/cases/referenced-missing-non-latin-file/context.json +1 -0
- package/fixtures/cases/referenced-missing-non-latin-file/expected.json +6 -0
- package/fixtures/cases/referenced-missing-non-latin-file/library/tasks/a.md +9 -0
- package/fixtures/cases/referenced-missing-non-latin-file/library/tasks/b.md +9 -0
- package/fixtures/cases/referenced-missing-non-latin-file/schema.md +12 -0
- package/fixtures/cases/remote-ref/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/schema-body-ignored/context.json +1 -0
- package/fixtures/cases/schema-body-ignored/expected.json +1 -0
- package/fixtures/cases/schema-body-ignored/schema.md +9 -0
- package/fixtures/cases/schema-type-named-folders/context.json +1 -0
- package/fixtures/cases/schema-type-named-folders/expected.json +5 -0
- package/fixtures/cases/schema-type-named-folders/schema.md +5 -0
- package/fixtures/cases/schema-type-named-type/context.json +1 -0
- package/fixtures/cases/schema-type-named-type/expected.json +5 -0
- package/fixtures/cases/{unknown-type/schema.yaml → schema-type-named-type/schema.md} +3 -1
- package/fixtures/cases/second-member-document/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/sections-keyword-refused/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/shortcut-reference-link/schema.md +7 -0
- package/fixtures/cases/string-length/schema.md +57 -0
- package/fixtures/cases/submission-keys/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/text-field-kind/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/thematic-break-ends-the-values/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/truncated-link-definition/schema.md +3 -0
- package/fixtures/cases/typed-path-names-another-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/typed-path-names-its-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/typed-path-names-no-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/types-folder-content/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/undeclared-field/schema.md +7 -0
- package/fixtures/cases/unevaluated-items-closed/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/unlisted-reference-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/unresolved-link/schema.md +7 -0
- package/fixtures/cases/valid-typed-document/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/wide-item-fence-link/schema.md +3 -0
- package/fixtures/forms.json +24 -0
- package/fixtures/queries.json +204 -1
- package/fixtures/references.json +15 -0
- package/package.json +1 -1
- package/dist/divide.d.ts +0 -3
- package/dist/divide.d.ts.map +0 -1
- package/dist/divide.js +0 -321
- package/dist/project.d.ts +0 -22
- package/dist/project.d.ts.map +0 -1
- package/dist/project.js +0 -101
- package/fixtures/cases/declared-binary-links/schema.yaml +0 -1
- package/fixtures/cases/default-unfilled/schema.yaml +0 -55
- package/fixtures/cases/defs-pattern/schema.yaml +0 -55
- package/fixtures/cases/dependent-rule/schema.yaml +0 -55
- package/fixtures/cases/email-format/schema.yaml +0 -55
- package/fixtures/cases/fenced-link-definition/schema.yaml +0 -5
- package/fixtures/cases/frontmatter-schema/expected.json +0 -5
- package/fixtures/cases/integer-field/schema.yaml +0 -55
- package/fixtures/cases/interrupted-link-definition/schema.yaml +0 -1
- package/fixtures/cases/json-schema-constructs/schema.yaml +0 -55
- package/fixtures/cases/list-of-objects-closed/schema.yaml +0 -55
- package/fixtures/cases/list-of-objects-item/schema.yaml +0 -55
- package/fixtures/cases/list-size/schema.yaml +0 -55
- package/fixtures/cases/long-fence-link-definition/schema.yaml +0 -1
- package/fixtures/cases/misspelled-key/schema.yaml +0 -55
- package/fixtures/cases/nested-object-reference/schema.yaml +0 -32
- package/fixtures/cases/nested-reference/schema.yaml +0 -32
- package/fixtures/cases/nested-required-field/schema.yaml +0 -55
- package/fixtures/cases/numeric-range/schema.yaml +0 -55
- package/fixtures/cases/one-of-variant/schema.yaml +0 -55
- package/fixtures/cases/other-room-reference/schema.yaml +0 -32
- package/fixtures/cases/paragraph-link-definition/schema.yaml +0 -1
- package/fixtures/cases/prototype-field/schema.yaml +0 -5
- package/fixtures/cases/quoted-link-definition/schema.yaml +0 -1
- package/fixtures/cases/shortcut-reference-link/schema.yaml +0 -5
- package/fixtures/cases/string-length/schema.yaml +0 -55
- package/fixtures/cases/truncated-link-definition/schema.yaml +0 -1
- package/fixtures/cases/undeclared-field/schema.yaml +0 -5
- package/fixtures/cases/unresolved-link/schema.yaml +0 -5
- package/fixtures/cases/wide-item-fence-link/schema.yaml +0 -1
- package/fixtures/division.json +0 -454
- package/fixtures/projection.json +0 -358
- /package/fixtures/cases/{frontmatter-schema → block-scalar-frontmatter}/context.json +0 -0
- /package/fixtures/cases/{frontmatter-schema/schema.yaml → unknown-type/schema.md} +0 -0
package/API.md
CHANGED
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
```ts
|
|
4
4
|
import {
|
|
5
5
|
apply,
|
|
6
|
-
divide,
|
|
7
6
|
links,
|
|
8
7
|
parse,
|
|
9
|
-
project,
|
|
10
8
|
retarget,
|
|
11
9
|
serialize,
|
|
12
10
|
target,
|
|
@@ -39,9 +37,11 @@ Every reader here reads a Document's body once, on first need, as one GitHub Fla
|
|
|
39
37
|
without literal autolinks, which no reader counts as links, and `VERSION` is the MD model version.
|
|
40
38
|
|
|
41
39
|
`verify(schema)` reads one schema text, the MD Types of one Room or App: one JSON Schema document
|
|
42
|
-
(draft 2020-12) in the YAML subset. Every top-level key but `$defs` names an MD Type holding the
|
|
40
|
+
(draft 2020-12) in the YAML subset. Every top-level key but `$defs` and `roles` names an MD Type holding the
|
|
43
41
|
JSON Schema of its Documents' values; `$defs` holds shapes the types reuse, reached by a `$ref` under
|
|
44
|
-
`#/$defs/` alone
|
|
42
|
+
`#/$defs/` alone, and `roles` maps a role name to its `RoleNeed`, `read` or `write`, which the model
|
|
43
|
+
answers as `roles` beside its `types` and which changes no type; a `roles` that is no mapping, an empty
|
|
44
|
+
role name or any other value is refused under the rule `roles`. `type`, `folders`, `attachment` and the built-in `any` are never declared. The model adds its keywords:
|
|
45
45
|
`reference` on a string names one MD Type, several, `any` or `attachment`, and `cross_room: true`
|
|
46
46
|
beside it admits a Document in another Room, of a type that Room declares; `title` is the label a
|
|
47
47
|
Document shows for a field and `contentMediaType: text/markdown` marks a string of Markdown text
|
|
@@ -57,7 +57,13 @@ of a type's own `properties` alone, `change_roles` and `initial_roles` each list
|
|
|
57
57
|
A field's label is its `title`, else its key; the fixtures' rule ids name `verify`'s label, `name` and nesting rules,
|
|
58
58
|
a value under a heading counting a level for each property or list item above it and none inside a `json` block.
|
|
59
59
|
`readTypes(schema, provided?)` returns the model of a schema `verify` already accepted, checking
|
|
60
|
-
none of these rules, and throws on a text it cannot read as types.
|
|
60
|
+
none of these rules, and throws on a text it cannot read as types. A Room schema and a Space schema
|
|
61
|
+
are each one Markdown Document whose YAML frontmatter is that schema, whole, and whose body is text
|
|
62
|
+
for people the model never reads: `verifySchemaDocument(document, provided?)` and
|
|
63
|
+
`readSchemaDocument(document, provided?)` answer as `verify` and `readTypes` do over its
|
|
64
|
+
frontmatter alone, a Document with no frontmatter holding no types, and refuse an unclosed one as
|
|
65
|
+
`schema-yaml` at `line 1`; a refusal's line is the Document's own. An App's schema stays a YAML
|
|
66
|
+
text, which `verify` reads.
|
|
61
67
|
|
|
62
68
|
```yaml
|
|
63
69
|
$defs:
|
|
@@ -91,15 +97,15 @@ JSON Pointer grammar, `''` included, `pointerSegments` and `escapePointer` split
|
|
|
91
97
|
`validate(library, context?, model?)` takes the resulting text Library and one `ValidationContext` of
|
|
92
98
|
`binaryTargets: readonly string[]`, none when omitted. Library keys and binary targets share one
|
|
93
99
|
canonical collection-relative path namespace; a path declared text and binary is refused. House declares
|
|
94
|
-
every
|
|
100
|
+
every attachment of the Room as a binary target, and the model reads no bytes. Ordinary links and
|
|
95
101
|
images in typed Documents may resolve to either membership, relative to the source Document, and one to
|
|
96
102
|
a path neither holds is not refused: it dangles. One written `/rooms/<handle>/<path>` names a file in
|
|
97
103
|
another Room, which the caller checks; any other absolute path, or one that leaves the collection, is
|
|
98
104
|
`unresolved-link`. A binary target supplies no Document or MD Type. `model` types the Library. A typed
|
|
99
105
|
Document, `any` included, at an `isDocumentPath` (no `isReservedName` of `RESERVED_NAMES` first) linking
|
|
100
|
-
into a reserved name is `unresolved-link`; a typed `ROOM_DESCRIPTION` is `room-md-type`. `CAPTURE_HOME`, one of `RESERVED_NAMES`, names the Capture home at a Room's root. The context's `typedPaths` bind each `path`, a name's one `*` standing for any nonempty part, to a `type` of `model`: a Document there naming another, or naming any unless `named`, is `unknown-type` at `/type`, one not `named` is checked as it and stays `any`, and one whose free text holds nothing but whitespace is `required-body` if `body`.
|
|
106
|
+
into a reserved name is `unresolved-link`; a typed `ROOM_DESCRIPTION` is `room-md-type`. `CAPTURE_HOME`, one of `RESERVED_NAMES`, names the Capture home at a Room's root. `isReservedName` compares a name with `RESERVED_NAMES` after `foldedName(name)`, the name in Unicode NFC under Unicode default case folding, which is how two names of one folder compare. The context's `typedPaths` bind each `path`, a name's one `*` standing for any nonempty part, to a `type` of `model`: a Document there naming another, or naming any unless `named`, is `unknown-type` at `/type`, one not `named` is checked as it and stays `any`, and one whose free text holds nothing but whitespace is `required-body` if `body`. A View whose `query` `planOf` refuses over `model`'s types, a type or field it does not declare included, or which names `rooms`, is `invalid-query` at that part under `/query`.
|
|
101
107
|
|
|
102
|
-
`HOUSE_ROOM_TYPES` is the `provided` model of every Room, verified: the Inbox's `CHAT_TYPE` card, whose `channel` is one of `INBOX_CHANNEL_KINDS`, and its `CHAT_MESSAGE_TYPE` messages, the two `INBOX_TYPES` and its `nameable` ones, a Wayfinding map and its tickets, and every type of `HOUSE_MODEL`, the House model `HOUSE_MODEL_DECLARATION` declares, from which the `HouseModelType` names and the `HouseDocumentFields<type>` of each type's Document follow. `HOUSE_TYPED_PATHS` binds House's paths to their types: `settings/panel.md`, an App's preferences under `APP_PREFERENCES_HOME` and an Agent function document under `rooms/<handle>/agent-functions/`. Its `room`, `app` and `space` definitions are `ROOM_REFERENCE_PATTERN`, `APP_REFERENCE_PATTERN` and `SPACE_REFERENCE_PATTERN`: a prefix, `ROOM_REFERENCE_PREFIX`, `APP_REFERENCE_PREFIX` or `SPACE_REFERENCE_PREFIX`, then an ordinal, a dot and a check character; `REVISION_REFERENCE_PATTERN` reads a revision, `REVISION_REFERENCE_PREFIX`, its
|
|
108
|
+
`HOUSE_ROOM_TYPES` is the `provided` model of every Room, verified: the Inbox's `CHAT_TYPE` card, whose `channel` is one of `INBOX_CHANNEL_KINDS`, and its `CHAT_MESSAGE_TYPE` messages, the two `INBOX_TYPES` and its `nameable` ones, a Wayfinding map and its tickets, a View, `VIEW_TYPE`, whose `name`, `description` and `query` it requires, and every type of `HOUSE_MODEL`, the House model `HOUSE_MODEL_DECLARATION` declares, from which the `HouseModelType` names and the `HouseDocumentFields<type>` of each type's Document follow. `HOUSE_TYPED_PATHS` binds House's paths to their types: `settings/panel.md`, an App's preferences under `APP_PREFERENCES_HOME` and an Agent function document under `rooms/<handle>/agent-functions/`. Its `room`, `app` and `space` definitions are `ROOM_REFERENCE_PATTERN`, `APP_REFERENCE_PATTERN` and `SPACE_REFERENCE_PATTERN`: a prefix, `ROOM_REFERENCE_PREFIX`, `APP_REFERENCE_PREFIX` or `SPACE_REFERENCE_PREFIX`, then an ordinal, a dot and a check character; `DOCUMENT_REFERENCE_PATTERN` reads a document, `DOCUMENT_REFERENCE_PREFIX`, `d_`, and `ATTACHMENT_REFERENCE_PATTERN` an attachment, `ATTACHMENT_REFERENCE_PREFIX`, `at_`, each then an ordinal, a dot and a check character; `REVISION_REFERENCE_PATTERN` reads a revision, `REVISION_REFERENCE_PREFIX`, `v_`, its entry's ordinal, a dot, the revision's and a check character, each character one `CROCKFORD_CHARACTER` of the lowercase Crockford alphabet `CROCKFORD_ALPHABET`, and `CROCKFORD_LEADING_CHARACTER` any of it but `0`.
|
|
103
109
|
|
|
104
110
|
A typed Document writes its values in its body, as Markdown, and its frontmatter holds only
|
|
105
111
|
`TYPE_FIELD`, `MEMBER_FIELD`, `SITE_FIELD` and `SUBMITTED_FIELD` (`submitted`), which `parse` reads
|
|
@@ -139,7 +145,9 @@ refused as `pattern`; `openPatternBudget()` opens one such bound over the assess
|
|
|
139
145
|
function it returns is called, and an inner one shares the outer.
|
|
140
146
|
|
|
141
147
|
Validation returns acceptance or one refusal naming the file, the field, its line and the violated
|
|
142
|
-
rule.
|
|
148
|
+
rule. A frontmatter outside the YAML subset the fixtures README states is refused as
|
|
149
|
+
`frontmatter-fence`, its `location` naming the construct the subset does not take and its `line`
|
|
150
|
+
where that construct is written. `parse`, `apply`, and `serialize` operate on a single text Document; they do not validate
|
|
143
151
|
collection membership or consume binary bytes. `parse(content, file?, definition?)` and
|
|
144
152
|
`apply(document, changes, definition?, nameOf?)` take the Document's MD Type definition: `parse` takes the
|
|
145
153
|
`Definition` itself or a `DefinitionOf`, a function from the type the frontmatter declares to its
|
|
@@ -212,7 +220,9 @@ Frontmatter values and the links that write reference values are never in it.
|
|
|
212
220
|
by the rule `links` and `validate` read: surrounding spaces and the `?query` or `#fragment` it
|
|
213
221
|
carries are not part of that Path. It reads backslash escapes and character references, strips as a
|
|
214
222
|
URL does, then percent-encodings, so `plan\.md`, `plan.md` and `pl%61n.md` all name `plan.md`;
|
|
215
|
-
an escaped or referenced `?` or `#` starts the suffix.
|
|
223
|
+
an escaped or referenced `?` or `#` starts the suffix. The Path is in Unicode NFC, so a destination
|
|
224
|
+
written decomposed names the composed Path, and every target `links`, `validate` and `documentFacts`
|
|
225
|
+
read is NFC. A destination that is empty, a bare fragment,
|
|
216
226
|
carries a URL scheme, starts at `/` once read, encodes no UTF-8 text, or leaves the collection
|
|
217
227
|
resolves to `null`. It reads a destination written anywhere, such as a typed reference field value,
|
|
218
228
|
which `links` never enumerates. `roomTarget(href)` reads `/rooms/<handle>/<path>` as its `handle`
|
|
@@ -221,7 +231,12 @@ any reference written so. `linkedPath(from, href)` reads a link so, with the `ha
|
|
|
221
231
|
`/rooms/<handle>` one names, `''` for the Room's root and the heading its `#fragment` names, `from`
|
|
222
232
|
if it names no Path. `retarget(href, to)` is that destination rewritten to `to`, keeping the
|
|
223
233
|
`?query` or `#fragment` it carried, which is the destination the `link` change below writes. It
|
|
224
|
-
percent-encodes in `to` what `target` would decode,
|
|
234
|
+
percent-encodes in `to` what `target` would decode or strip, a space at either end among them, so it
|
|
235
|
+
resolves to `to` again. `urlDestination(url)` is the destination that reads as `url`, the address a
|
|
236
|
+
Markdown renderer gives a link with its escapes and character references already read, so
|
|
237
|
+
`linkedPath(from, urlDestination(url))` reads them once. `destinationText(to, bracketed)` is `to` as
|
|
238
|
+
a link writes it, `<…>` when `bracketed` asks for it or the bare form cannot hold it, and `null`
|
|
239
|
+
when neither form can.
|
|
225
240
|
|
|
226
241
|
`untitled(definition)` is a definition without its `title`s at any depth, a property named `title` kept, so two types that differ only in their labels compare equal.
|
|
227
242
|
|
|
@@ -236,14 +251,18 @@ of the link that writes one, keeping its text, or is stale. `referenceTarget(fil
|
|
|
236
251
|
read as a link destination, else `null`; `referenceTargets(document, file, model)` lists each
|
|
237
252
|
reference's `location`, `to` and `target`. `documentFacts(file, parsed, model)`, `null` where the
|
|
238
253
|
text does not parse, is the `type` (`any` if none), `fields` and sorted distinct link and reference
|
|
239
|
-
`links` a save stores, no links under `settings
|
|
254
|
+
`links` a save stores, no links under `settings/` and no fields for a document there that declares no `type`, such as the Room schema. `relativize(document, file, handle, definition?, kept?)`
|
|
240
255
|
rewrites, in one `apply`, each link destination and reference written `/rooms/<handle>/<path>` and
|
|
241
256
|
not in `kept` to `relative(file, path)`, keeping its `?query` or `#fragment`. A text without
|
|
242
257
|
frontmatter, such as a captured body, is read from its first character: `relativizeBody(body, file, handle)` converts it
|
|
243
258
|
so, refusing a `/rooms/` one naming no Room's file as `unresolved-link`; `bodyLinks(body, file)`
|
|
244
|
-
is its `links` and `bodyRoomLinks(body)` its other Rooms'. A keyed link, `/rooms/<handle>/<path>?key=<key>` as a body link or a reference value, stays as written, which no relativizing or relinking rewrites, out of `roomReferences` and `bodyRoomLinks` and naming no target validation checks; `keyedLink(href)` reads one as its `handle`, `path` and `key`, or `null` for any other href, `bodyKeyedLinks(body)` lists each in a body, and `keyedDestination(path, key)` writes one. `relinkBody(body, file, moves)` writes,
|
|
259
|
+
is its `links` and `bodyRoomLinks(body)` its other Rooms'. A keyed link, `/rooms/<handle>/<path>?key=<key>` as a body link or a reference value, stays as written, which no relativizing or relinking rewrites, out of `roomReferences` and `bodyRoomLinks` and naming no target validation checks; `keyedLink(href)` reads one as its `handle`, `path` and `key`, or `null` for any other href, `bodyKeyedLinks(body)` lists each in a body, and `keyedDestination(path, key)` writes one, each name percent-encoding every ASCII character but letters, digits, `.`, `_`, `~` and `-` and keeping every other character as written, which `keyedLink` decodes and takes in NFC. `relinkBody(body, file, moves)` writes,
|
|
245
260
|
in the `link` change's form, each destination whose Path keys `moves` as that value relative to
|
|
246
261
|
`file`, or as that value when it is a `/rooms/` path, and one whose `roomPath` does as that value.
|
|
262
|
+
`linkSpans(body)` lists, in source order, every link, image and reference definition the body
|
|
263
|
+
holds, each with its `start` and `end`, the `label` text's extent (`null` for a definition), its
|
|
264
|
+
`href` as written and the `destination` extent that writes it, `bracketed` when it is written
|
|
265
|
+
`<…>`; a reference link carries its definition's destination.
|
|
247
266
|
`unlinkBody(body, hrefs)` cuts every link and reference definition whose written destination is
|
|
248
267
|
in `hrefs`, and answers the rest as `body` with `links`, each such destination written as one link.
|
|
249
268
|
|
|
@@ -262,82 +281,6 @@ profile reads back: bare when it carries no whitespace, does not open with `<`,
|
|
|
262
281
|
parentheses, otherwise inside angle brackets, which the original form is kept in when it still
|
|
263
282
|
fits. A destination that neither form can carry is refused as `unwritable-link`.
|
|
264
283
|
|
|
265
|
-
`project(document, file, context?)` is the Embedding projection input of one Document: the prose a
|
|
266
|
-
consumer embeds, with every internal Markdown-document link reduced to the label a reader sees. A
|
|
267
|
-
Document that declares no MD type contributes its body after the frontmatter fence. A typed one
|
|
268
|
-
contributes its prose values, each bare without its label, first the ones written on a line, in a
|
|
269
|
-
cell or in a `json` block, each followed by a blank line, then its Markdown long values and its free
|
|
270
|
-
text, its preamble, each section whose heading names no field and what follows a thematic break,
|
|
271
|
-
in Document order. A prose value is a string at any depth whose schema is prose. The Path, every
|
|
272
|
-
label and every other value stay outside, so changing them alone leaves the projection unchanged.
|
|
273
|
-
|
|
274
|
-
```ts
|
|
275
|
-
const parsed = parse(content);
|
|
276
|
-
if (parsed.ok) {
|
|
277
|
-
const projected = project(parsed.document, 'tasks/two.md', {
|
|
278
|
-
documentTargets: ['plans/q3.md', 'people/ana.md'],
|
|
279
|
-
definition: model.types.task,
|
|
280
|
-
});
|
|
281
|
-
if (projected.ok) embed(projected.text);
|
|
282
|
-
}
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
`ProjectionContext` carries `documentTargets`, the collection-relative Paths the caller holds as
|
|
286
|
-
Markdown documents, and `definition`, the verified MD Type the Document's `type` names, taken from
|
|
287
|
-
the model `verify` returned. A Document that declares a type the caller supplies no definition for
|
|
288
|
-
is refused as `unknown-type`. `documentTargets` is what makes a destination internal: a destination
|
|
289
|
-
resolving to a supplied Path is internal, as is one into another Room, and every other stays text, a
|
|
290
|
-
binary target and a Path nobody supplied alike. The caller supplies that membership, as it does for
|
|
291
|
-
`validate`; the model reads no bytes, resolves no authority, and classifies nothing unsupplied.
|
|
292
|
-
|
|
293
|
-
An internal link contributes its visible label and no destination, fragment, or title, in the inline
|
|
294
|
-
`[label](path)`, full `[label][id]`, collapsed `[label][]`, and shortcut `[label]` forms, and the
|
|
295
|
-
link reference definition an enumerated use resolves through leaves the projection with it. An image
|
|
296
|
-
at a supplied document target contributes its alt text the same way, because a move rewrites that
|
|
297
|
-
destination too. External URLs, binary targets, unsupplied destinations, bare fragments, code spans,
|
|
298
|
-
fenced code, and escaped syntax stay exactly as authored, read through the same syntax profile
|
|
299
|
-
`links` and `validate` read. `project` returns text and never rewrites the Document.
|
|
300
|
-
|
|
301
|
-
A `link` change leaves the projection of every Document it rewrites byte-identical, while a changed visible label changes it.
|
|
302
|
-
|
|
303
|
-
`divide(document, file, context)` divides that same Embedding projection input into ordered Spans
|
|
304
|
-
under the bound the caller supplies. Each Span carries the `text` to embed and the `start` and `end`
|
|
305
|
-
of the extent it addresses in the Document's own source, as UTF-8 byte offsets and never string
|
|
306
|
-
positions, so a caller stores the extent and hydrates the text it shows from the Document itself.
|
|
307
|
-
|
|
308
|
-
`DivisionContext` is a `ProjectionContext` and one `bound`, the greatest number of characters a
|
|
309
|
-
Span's embedded text may carry, counted the way JavaScript counts a string's length and not in the
|
|
310
|
-
bytes the extent is measured in. No Span's text is ever longer than the bound. A bound cut never
|
|
311
|
-
divides a character: where the bound ends between the two halves of a surrogate pair, the cut falls
|
|
312
|
-
before the pair. A cut never falls inside link syntax either: it falls before an internal link, and
|
|
313
|
-
a label longer than a whole piece's room is divided at the bound like any other text. The smallest
|
|
314
|
-
bound is `2`, the length of one astral character; a bound that is not a whole number of at least
|
|
315
|
-
`2` is refused with `division-bound` before any division. The bound is the caller's number alone:
|
|
316
|
-
the model holds no tokenizer, counts nothing else, and refuses no input for being too long. A
|
|
317
|
-
Document the caller supplies no definition for carries the `unknown-type` refusal of `project`.
|
|
318
|
-
|
|
319
|
-
The division descends one level at a time, and only into the piece that does not fit: the whole
|
|
320
|
-
input, a heading node, adjacent sibling nodes packed under one parent, adjacent blocks inside a
|
|
321
|
-
node, sentences inside a block, and a bound cut inside a single sentence. A Span covers whole
|
|
322
|
-
heading nodes or one contiguous piece inside a single node, never a partial node beside another. A
|
|
323
|
-
Span that continues a node repeats that node's own heading line, projected like any other text and
|
|
324
|
-
so carrying an internal link's label rather than its destination, and never an ancestor's heading,
|
|
325
|
-
so renaming a heading costs what editing that heading's own body costs. A heading the bound cannot
|
|
326
|
-
hold beside any text is not repeated, a continuation piece that begins with an astral character the
|
|
327
|
-
room beside its heading cannot hold is carried without the heading, and a heading with no body of
|
|
328
|
-
its own leads its first child node rather than standing as a Span of nothing but itself. Overlap
|
|
329
|
-
exists at the sentence level alone, where each Span after the first repeats its predecessor's last
|
|
330
|
-
sentence whenever the bound holds both; when it cannot hold both, the Span carries its own sentence
|
|
331
|
-
alone. An untyped input arrives without a definition and descends the same ladder.
|
|
332
|
-
|
|
333
|
-
Division is total: every authored character of the input belongs to at least one Span, and an input
|
|
334
|
-
carrying no authored text divides into no Span at all. A Span's extent is the smallest range of the
|
|
335
|
-
source that contains everything the Span covers, so it spans what the input excludes between two
|
|
336
|
-
eligible pieces, and the extent addresses the authored source where the embedded text carries a
|
|
337
|
-
repeated heading, an internal link's visible label, or a value the author escaped. A Span divided
|
|
338
|
-
out of one value written on a line addresses that whole value, and a Span carrying part of one
|
|
339
|
-
internal link's label addresses that whole link, because a cut never falls inside link syntax.
|
|
340
|
-
|
|
341
284
|
`notReadyWaitMs(asked)` is how long a client told a Room's chunk list is not ready waits before it
|
|
342
285
|
asks again: 1, 2, 3, 5, 8, 11 and 15 seconds by `asked`, counted from zero, then 15 seconds.
|
|
343
286
|
|
|
@@ -351,12 +294,12 @@ the query, which `placeText` writes as its message does, and whose `accepts` lis
|
|
|
351
294
|
take there: the types or fields the Rooms declare, a field's `kindWords`, or the parts and operators
|
|
352
295
|
a query knows. A query is data: `types`, `where` field predicates by JSON Pointer (`$eq`, `$ne`,
|
|
353
296
|
`$in`, `$nin`, `$gt`, `$gte`, `$lt`, `$lte`, `$all`, `$size`, `$exists`, `$prefix`, `$and`, `$or`),
|
|
354
|
-
`pathPrefix`, `outside` (directories left out), `folder`, `paths`, `fileIds`, `hop
|
|
355
|
-
`text`, then `select` or `groupBy`, `orderBy`, `limit`, `after` and `total`. A Document query
|
|
297
|
+
`pathPrefix`, `outside` (directories left out), `folder`, `paths`, `fileIds`, `hop` (with
|
|
298
|
+
`none: true`, the Documents whose reference names no matching Document), `backlinks`, `text`, then `select` or `groupBy`, `orderBy`, `limit`, `after` and `total`. A Document query
|
|
356
299
|
selects and orders by a row's `size`, `created` and its change's time `updated` beside `room`,
|
|
357
300
|
`path`, `type`, `folder` and a field. A group query groups by `room`, `type`, `folder`, `subfolder`
|
|
358
301
|
(the child folder of `pathPrefix` holding a row) or a field, selects each group's `size`, its
|
|
359
|
-
documents and
|
|
302
|
+
documents and attachments apart, its latest `updated` and the `greatest` value of a field, and orders by
|
|
360
303
|
`count`, those or its keys. `queryKey` and `identityOf` are a query's and a plan's canonical text,
|
|
361
304
|
`bodied` says a shape reads text, `cursorOf` and `decodedCursor` write and read the `after` a window
|
|
362
305
|
continues from, and `invalid`, `known` and `plain` are the check's refusal and tests.
|
|
@@ -371,17 +314,20 @@ then lists item by item. `indexKey(facts, value)` is the key whose bytes order a
|
|
|
371
314
|
a date-time by its instant, text by code point, and a missing value with `null` first. `pageOrder(plan)` is the one order a page of
|
|
372
315
|
House's query walks, by Path or a field its types index, both by code point, and `walkOf(plan, model)` what drives that walk: an indexed
|
|
373
316
|
order as runs of keys, its continuation's, a missing value's and a range on that field, else the keys of the first top-level equality
|
|
374
|
-
or list on a field every named type indexes, else Path. Each refuses what no walk serves; `walkedValue` names a walked value as a continuation does. `countShape(plan)` says whether a plan asks a total or groups and refuses what no count serves, and `countOf(plan, model, where)` names a count's walk, in no order and from no continuation: those keys, else the range of the first top-level range on such a field, else Path, with every field it tests or groups by.
|
|
317
|
+
or list on a field every named type indexes, else Path. Each refuses what no walk serves; `walkedValue` names a walked value as a continuation does. `countShape(plan)` says whether a plan asks a total or groups and refuses what no count serves, a `hop` among it, and `countOf(plan, model, where)` names a count's walk, in no order and from no continuation: those keys, else the range of the first top-level range on such a field, else Path, with every field it tests or groups by. `hopTargets(plan, model, row)` names the Paths a walked row's stored `path`, `type` and `fields` (`WalkedFacts`) name in the plan's `hop` field, which a page reads to answer that row.
|
|
375
318
|
|
|
376
319
|
Two evaluators answer a plan's tests on one Document alike, a test on a missing value false and
|
|
377
320
|
its negation (`$ne`, `$nin`, `$exists: false`) true. `matches(plan, candidate)` answers in
|
|
378
321
|
memory over one `Candidate`: its `path`, `type`, `fileId`, `fields`, `definition` and the
|
|
379
|
-
`text` held, and refuses a plan that
|
|
380
|
-
selects a group's totals, which one Document cannot answer. The `sql` namespace compiles them to SQL over a collection: `indexed(path, fields,
|
|
322
|
+
`text` held, and refuses a plan that names `rooms`, `hop` or `backlinks`, orders by `size`,
|
|
323
|
+
`created`, `updated` or `greatest`, or selects a group's totals, which one Document cannot answer. The `sql` namespace compiles them to SQL over a collection: `indexed(path, fields,
|
|
381
324
|
definition)` derives a Document's values and field links, its date-times with their instants,
|
|
382
325
|
`sql.VALUE_TABLE` holds those values and `sql.insertedValues` writes those of many documents, and `sql.tests(alias,
|
|
383
326
|
plan)` tests a document row of `id`, `path`, `folder`, `type`, `file_id` and `content`, its
|
|
384
327
|
phrase through the function a connection registers as `sql.HOLDS_PHRASE` with `sql.holdsPhrase`.
|
|
328
|
+
`sql.hopped(alias, hop, targets)` tests a plan's `hop` through a `replica_links` table of those
|
|
329
|
+
field links by `doc`, `kind`, `keys`, `places` and `target`, where `targets(link, document)` joins
|
|
330
|
+
the Document row a link names: `EXISTS`, or `NOT EXISTS` with `none`.
|
|
385
331
|
`sql.scoped`, `sql.placed`, `sql.sorted`, `sql.beyond`, `sql.following` and `sql.sortValue`
|
|
386
332
|
render a scope, a pointer, an order and a window's continuation, a date-time ordering as its
|
|
387
333
|
instant between numbers and text; `sql.fragment`, `sql.joined`, `sql.all`, `sql.any`,
|
package/README.md
CHANGED
|
@@ -43,7 +43,6 @@ if (checked.verdict === 'accept') {
|
|
|
43
43
|
| `apply` | Apply field, section, preamble, link and reference changes at once |
|
|
44
44
|
| `links`, `target`, `retarget` | Inventory and rewrite link destinations |
|
|
45
45
|
| `escapePointer` | Write one key as a JSON Pointer token |
|
|
46
|
-
| `project`, `divide` | Embedding projection input and its division into Spans |
|
|
47
46
|
| `facts`, `candidateOf` | A Document as one change saw it, matched as one query candidate |
|
|
48
47
|
| `planOf`, `matches`, `sql` | Check a query, answer it over one Document or compile it to SQL |
|
|
49
48
|
| `VERSION` | The MD model version |
|
package/dist/definition.d.ts
CHANGED
|
@@ -91,5 +91,5 @@ export declare function crossedFacts(facts: ValueFacts): ValueFacts[];
|
|
|
91
91
|
export declare function fieldFacts(definition: Definition, key: string): ValueFacts | undefined;
|
|
92
92
|
export declare function pointerFacts(definition: Definition, pointer: string): PointerFacts | undefined;
|
|
93
93
|
export declare function untitled(definition: Definition): Definition;
|
|
94
|
-
export declare function readSchema(text: string, provided?: VerifiedModel, checked?: boolean): VerifiedModel | Failure;
|
|
94
|
+
export declare function readSchema(text: string, provided?: VerifiedModel, checked?: boolean, start?: number, end?: number): VerifiedModel | Failure;
|
|
95
95
|
//# sourceMappingURL=definition.d.ts.map
|
package/dist/definition.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"definition.d.ts","sourceR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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;AAmED,wBAAgB,QAAQ,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAY3D;AA+ND,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,aAAwB,EAClC,OAAO,UAAO,EACd,KAAK,SAAI,EACT,GAAG,SAAc,GAChB,aAAa,GAAG,OAAO,CAqDzB"}
|
package/dist/definition.js
CHANGED
|
@@ -13,6 +13,7 @@ export const JSON_TYPES = [
|
|
|
13
13
|
];
|
|
14
14
|
export const BUILT_IN_TYPE = 'any';
|
|
15
15
|
export const ATTACHMENT = 'attachment';
|
|
16
|
+
const RESERVED_TYPE_NAMES = [TYPE_FIELD, 'folders'];
|
|
16
17
|
const COMPOSITES = ['array', 'object'];
|
|
17
18
|
const ANNOTATIONS = new Set([
|
|
18
19
|
'$comment',
|
|
@@ -28,6 +29,10 @@ export const OPENING = ['additionalProperties', 'unevaluatedProperties'];
|
|
|
28
29
|
const FIELD_RULES = ['change_roles', 'initial_roles', 'transitions'];
|
|
29
30
|
const PROVIDED_KEYWORDS = ['create_roles', 'delete_roles'];
|
|
30
31
|
const NO_TYPES = Object.freeze({ types: Object.freeze({}) });
|
|
32
|
+
const DEFS_SECTION = '$defs';
|
|
33
|
+
const ROLES_SECTION = 'roles';
|
|
34
|
+
const SECTIONS = [DEFS_SECTION, ROLES_SECTION];
|
|
35
|
+
const ROLE_NEEDS = ['read', 'write'];
|
|
31
36
|
const DEFS_REFERENCE = '#/$defs/';
|
|
32
37
|
const UNBOUNDED_FORMAT = 'url';
|
|
33
38
|
export const UNIONS = ['anyOf', 'oneOf'];
|
|
@@ -838,22 +843,41 @@ function readType(name, value, context) {
|
|
|
838
843
|
function lineAt(text, offset) {
|
|
839
844
|
return text.slice(0, offset).split(/\r\n|\r|\n/).length;
|
|
840
845
|
}
|
|
841
|
-
|
|
846
|
+
function roleNeeds(value) {
|
|
847
|
+
const at = `/${ROLES_SECTION}`;
|
|
848
|
+
if (!isRecord(value))
|
|
849
|
+
return refuse(ROLES_SECTION, at);
|
|
850
|
+
const needs = Object.create(null);
|
|
851
|
+
for (const [role, need] of Object.entries(value)) {
|
|
852
|
+
if (role === '' || typeof need !== 'string' || !ROLE_NEEDS.includes(need))
|
|
853
|
+
return refuse(ROLES_SECTION, `${at}/${escapePointer(role)}`);
|
|
854
|
+
needs[role] = need;
|
|
855
|
+
}
|
|
856
|
+
return { needs };
|
|
857
|
+
}
|
|
858
|
+
export function readSchema(text, provided = NO_TYPES, checked = true, start = 0, end = text.length) {
|
|
842
859
|
let root;
|
|
843
860
|
try {
|
|
844
|
-
root = jsValue(parseYamlMapping(text,
|
|
861
|
+
root = jsValue(parseYamlMapping(text, start, end));
|
|
845
862
|
}
|
|
846
863
|
catch (error) {
|
|
847
864
|
if (error instanceof YamlError)
|
|
848
865
|
return refuse('schema-yaml', `line ${lineAt(text, error.offset)}`);
|
|
849
866
|
throw error;
|
|
850
867
|
}
|
|
851
|
-
const defs = root
|
|
868
|
+
const defs = root[DEFS_SECTION] ?? Object.create(null);
|
|
852
869
|
if (!isRecord(defs))
|
|
853
|
-
return refuse(
|
|
854
|
-
const
|
|
870
|
+
return refuse(DEFS_SECTION, `/${DEFS_SECTION}`);
|
|
871
|
+
const roles = Object.hasOwn(root, ROLES_SECTION) ? roleNeeds(root[ROLES_SECTION]) : undefined;
|
|
872
|
+
if (roles !== undefined && 'rule' in roles)
|
|
873
|
+
return roles;
|
|
874
|
+
const names = Object.keys(root).filter((key) => !SECTIONS.includes(key));
|
|
855
875
|
for (const name of checked ? names : []) {
|
|
856
|
-
if (name === '' ||
|
|
876
|
+
if (name === '' ||
|
|
877
|
+
name.startsWith('$') ||
|
|
878
|
+
name === BUILT_IN_TYPE ||
|
|
879
|
+
name === ATTACHMENT ||
|
|
880
|
+
RESERVED_TYPE_NAMES.includes(name))
|
|
857
881
|
return refuse('schema-type-name', `/${escapePointer(name)}`);
|
|
858
882
|
}
|
|
859
883
|
const context = {
|
|
@@ -885,5 +909,8 @@ export function readSchema(text, provided = NO_TYPES, checked = true) {
|
|
|
885
909
|
if (!Object.hasOwn(types, name))
|
|
886
910
|
types[name] = definition;
|
|
887
911
|
}
|
|
888
|
-
return Object.freeze({
|
|
912
|
+
return Object.freeze({
|
|
913
|
+
types: Object.freeze(types),
|
|
914
|
+
...(roles === undefined ? {} : { roles: Object.freeze(roles.needs) }),
|
|
915
|
+
});
|
|
889
916
|
}
|
package/dist/document.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Body, type Naming } from './body.js';
|
|
2
2
|
import { type Definition } from './definition.js';
|
|
3
3
|
import { type HrefOccurrence, type Reading } from './markdown.js';
|
|
4
|
-
import type { ApplyResult, BodyResult, Change, DefinitionOf, Document, Link, ParseResult, Refusal, Span, UnlinkedBody } from './types.js';
|
|
4
|
+
import type { ApplyResult, BodyResult, Change, DefinitionOf, Document, Link, LinkSpan, ParseResult, Refusal, Span, UnlinkedBody } from './types.js';
|
|
5
5
|
export declare function readingOf(document: Document): Reading;
|
|
6
6
|
export declare function bodyOf(document: Document): Body | null;
|
|
7
7
|
export declare function linkDestinations(document: Document): readonly HrefOccurrence[];
|
|
@@ -13,6 +13,7 @@ export declare function relativizeBody(body: string, file: string, handle: strin
|
|
|
13
13
|
export declare function relinkBody(body: string, file: string, moves: ReadonlyMap<string, string>): BodyResult;
|
|
14
14
|
export declare function unlinkBody(body: string, hrefs: ReadonlySet<string>): UnlinkedBody;
|
|
15
15
|
export declare function links(document: Document, file: string): readonly Link[];
|
|
16
|
+
export declare function linkSpans(body: string): readonly LinkSpan[];
|
|
16
17
|
export declare function bodyLinks(body: string, file: string): readonly Link[];
|
|
17
18
|
export declare function bodyWith(document: Document, definition: Definition | undefined): Body | null | Refusal;
|
|
18
19
|
export declare function partText(part: string): string;
|
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,EAUL,KAAK,IAAI,EACT,KAAK,MAAM,EAGZ,MAAM,WAAW,CAAC;AACnB,OAAO,EAKL,KAAK,UAAU,EAEhB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EASL,KAAK,cAAc,EACnB,KAAK,OAAO,EAEb,MAAM,eAAe,CAAC;AAevB,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,MAAM,EACN,YAAY,EACZ,QAAQ,EAER,IAAI,EACJ,WAAW,EACX,OAAO,EACP,IAAI,EACJ,YAAY,EACb,MAAM,YAAY,CAAC;AAoDpB,wBAAgB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAKrD;AAeD,wBAAgB,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI,CAGtD;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,cAAc,EAAE,CAQ9E;AAiCD,wBAAgB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,IAAI,EAAE,CAM7D;AA6FD,wBAAgB,KAAK,CACnB,OAAO,EAAE,MAAM,EACf,IAAI,SAAK,EACT,UAAU,CAAC,EAAE,UAAU,GAAG,YAAY,GACrC,WAAW,CA8Cb;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,UAAU,CAAC,EAAE,UAAU,GAAG,QAAQ,CAQlF;AA2CD,wBAAgB,UAAU,CACxB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd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"}
|
package/dist/document.js
CHANGED
|
@@ -140,7 +140,7 @@ function opened(content, file) {
|
|
|
140
140
|
if (error instanceof YamlError)
|
|
141
141
|
return {
|
|
142
142
|
ok: false,
|
|
143
|
-
refusal: refuse(file, 'frontmatter-fence',
|
|
143
|
+
refusal: refuse(file, 'frontmatter-fence', error.construct, lineOf(content, error.offset)),
|
|
144
144
|
};
|
|
145
145
|
throw error;
|
|
146
146
|
}
|
|
@@ -320,6 +320,23 @@ function linksIn(occurrences, file) {
|
|
|
320
320
|
export function links(document, file) {
|
|
321
321
|
return linksIn(linkDestinations(document), file);
|
|
322
322
|
}
|
|
323
|
+
export function linkSpans(body) {
|
|
324
|
+
if (!linkable(body))
|
|
325
|
+
return [];
|
|
326
|
+
const { uses, definitions } = read(body);
|
|
327
|
+
const span = (start, end, label, destination) => ({
|
|
328
|
+
start,
|
|
329
|
+
end,
|
|
330
|
+
label,
|
|
331
|
+
href: destination.href,
|
|
332
|
+
destination: { start: destination.start, end: destination.end },
|
|
333
|
+
bracketed: destination.bracketed,
|
|
334
|
+
});
|
|
335
|
+
return [
|
|
336
|
+
...uses.map((use) => span(use.start, use.end, { start: use.labelStart, end: use.labelEnd }, use.destination)),
|
|
337
|
+
...definitions.map((definition) => span(definition.start, definition.end, null, definition.destination)),
|
|
338
|
+
].sort((left, right) => left.start - right.start);
|
|
339
|
+
}
|
|
323
340
|
export function bodyLinks(body, file) {
|
|
324
341
|
return linksIn(hrefOccurrences(body), file);
|
|
325
342
|
}
|
package/dist/facts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"facts.d.ts","sourceRoot":"","sources":["../src/facts.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEvE,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE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ACzB,CAAC;AAIF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM1E;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,aAAa,GACnB,SAAS,eAAe,EAAE,CAO5B;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,aAAa,GACnB,UAAU,GAAG,IAAI,CAgBnB"}
|
package/dist/facts.js
CHANGED
|
@@ -26,10 +26,11 @@ export function documentFacts(file, parsed, model) {
|
|
|
26
26
|
if (!parsed.ok)
|
|
27
27
|
return null;
|
|
28
28
|
const { document } = parsed;
|
|
29
|
+
const setting = file.startsWith(SETTINGS_AREA);
|
|
29
30
|
return {
|
|
30
31
|
type: document.type ?? BUILT_IN_TYPE,
|
|
31
|
-
fields: document.fields,
|
|
32
|
-
links:
|
|
32
|
+
fields: setting && document.type === undefined ? {} : document.fields,
|
|
33
|
+
links: setting
|
|
33
34
|
? []
|
|
34
35
|
: [
|
|
35
36
|
...new Set([
|
package/dist/house-model.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export declare const HOUSE_MODEL_DECLARATION: {
|
|
|
43
43
|
readonly kind: {
|
|
44
44
|
readonly title: 'Kind';
|
|
45
45
|
readonly type: 'string';
|
|
46
|
-
readonly enum: readonly ['share-offer', 'join-request', 'join-request-approved', 'room-ownership-offer', 'managed-environment-retention-opened', 'storage-full', 'sandbox-budget-spent', 'trigger-failed', 'room-telegram-chat-paused', 'break-glass-owner-disclosure', 'export-ready', 'export-failed', 'custom', 'agent-function-request-finished', 'storage-past-included'];
|
|
46
|
+
readonly enum: readonly ['share-offer', 'join-request', 'join-request-approved', 'room-ownership-offer', 'managed-environment-retention-opened', 'storage-full', 'sandbox-budget-spent', 'trigger-failed', 'app-origins-added', 'room-telegram-chat-paused', 'viber-number-unlinked', 'break-glass-owner-disclosure', 'export-ready', 'export-failed', 'custom', 'agent-function-request-finished', 'storage-past-included'];
|
|
47
47
|
};
|
|
48
48
|
readonly created: {
|
|
49
49
|
readonly title: 'Created';
|
|
@@ -212,9 +212,57 @@ export declare const HOUSE_MODEL_DECLARATION: {
|
|
|
212
212
|
readonly title: 'App';
|
|
213
213
|
readonly $ref: '#/$defs/app';
|
|
214
214
|
};
|
|
215
|
+
readonly name: {
|
|
216
|
+
readonly title: 'Name';
|
|
217
|
+
readonly type: 'string';
|
|
218
|
+
};
|
|
215
219
|
};
|
|
216
220
|
readonly required: readonly ['app'];
|
|
217
221
|
};
|
|
222
|
+
readonly origins: {
|
|
223
|
+
readonly title: 'Origins';
|
|
224
|
+
readonly type: 'array';
|
|
225
|
+
readonly items: {
|
|
226
|
+
readonly type: 'string';
|
|
227
|
+
readonly minLength: 1;
|
|
228
|
+
readonly maxLength: 512;
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
readonly triggers: {
|
|
232
|
+
readonly title: 'Triggers';
|
|
233
|
+
readonly type: 'array';
|
|
234
|
+
readonly items: {
|
|
235
|
+
readonly type: 'object';
|
|
236
|
+
readonly additionalProperties: false;
|
|
237
|
+
readonly properties: {
|
|
238
|
+
readonly trigger: {
|
|
239
|
+
readonly title: 'Trigger';
|
|
240
|
+
readonly $ref: '#/$defs/id';
|
|
241
|
+
};
|
|
242
|
+
readonly description: {
|
|
243
|
+
readonly title: 'Description';
|
|
244
|
+
readonly type: 'string';
|
|
245
|
+
};
|
|
246
|
+
readonly room: {
|
|
247
|
+
readonly title: 'Room';
|
|
248
|
+
readonly type: 'object';
|
|
249
|
+
readonly additionalProperties: false;
|
|
250
|
+
readonly properties: {
|
|
251
|
+
readonly room: {
|
|
252
|
+
readonly title: 'Room';
|
|
253
|
+
readonly $ref: '#/$defs/room';
|
|
254
|
+
};
|
|
255
|
+
readonly name: {
|
|
256
|
+
readonly title: 'Name';
|
|
257
|
+
readonly type: 'string';
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
readonly required: readonly ['room', 'name'];
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
readonly required: readonly ['trigger', 'description', 'room'];
|
|
264
|
+
};
|
|
265
|
+
};
|
|
218
266
|
readonly space: {
|
|
219
267
|
readonly title: 'Space';
|
|
220
268
|
readonly type: 'object';
|
|
@@ -312,6 +360,10 @@ export declare const HOUSE_MODEL_DECLARATION: {
|
|
|
312
360
|
readonly enum: readonly ['private', 'topics', 'ban_users', 'invite_users', 'manage_topics', 'post_messages', 'edit_messages', 'inbox_manage_topics', 'inbox_delete_messages'];
|
|
313
361
|
};
|
|
314
362
|
};
|
|
363
|
+
readonly number: {
|
|
364
|
+
readonly title: 'Number';
|
|
365
|
+
readonly type: 'string';
|
|
366
|
+
};
|
|
315
367
|
readonly budget: {
|
|
316
368
|
readonly title: 'Budget';
|
|
317
369
|
readonly type: 'string';
|
|
@@ -571,7 +623,7 @@ export declare const HOUSE_MODEL_DECLARATION: {
|
|
|
571
623
|
readonly required: readonly ['description', 'input', 'agent'];
|
|
572
624
|
};
|
|
573
625
|
readonly 'house-trigger': {
|
|
574
|
-
readonly description: "One Trigger of this Room as its acts wrote it, which House alone writes: its `description`, the `condition` it fires on, its `actions` in order, whether each action and the Trigger are `enabled`, `paused_by` `types` while a change of the Room's types paused it, its `creator` by `user` and the `name` they had then, and when it was `created`. A `notify` action reaches the `users` its `to` names, the members its `fields` name in the matched document and the holders of its `roles`, or, `in_group`, posts once in this Room's Telegram group in their place, mentioning each; an `agent_function` action
|
|
626
|
+
readonly description: "One Trigger of this Room as its acts wrote it, which House alone writes: its `description`, the `condition` it fires on, its `actions` in order, whether each action and the Trigger are `enabled`, `paused_by` `types` while a change of the Room's types paused it, its `creator` by `user` and the `name` they had then, and when it was `created`. A `notify` action reaches the `users` its `to` names, the members its `fields` name in the matched document and the holders of its `roles`, or, `in_group`, posts once in this Room's Telegram group in their place, mentioning each; an `agent_function` action starts the Agent function whose card under this Room's `house/agent-functions/` its `card` names with the Event, `card` absent while this Room holds no card of that Agent function; a `message` action puts the Event into the active conversation that Agent function started for what the Event is about, or starts that Agent function with it when none is active; a `function` action runs the `function` its `app`'s latest release declares, on House's servers, while the `user` it was `attached_by` owns this Room, or, naming no `app`, the Room owner's Environment function of that name on its Environment, which only a Trigger of their Private Room holds. Whether an action's target holds is not written: it follows from the Room's members, the Agent function's card, the App's latest release, who owns this Room and the owner's functions.";
|
|
575
627
|
readonly properties: {
|
|
576
628
|
readonly reflected: {
|
|
577
629
|
readonly title: 'Reflected';
|
|
@@ -676,12 +728,8 @@ export declare const HOUSE_MODEL_DECLARATION: {
|
|
|
676
728
|
readonly type: 'string';
|
|
677
729
|
readonly minLength: 1;
|
|
678
730
|
};
|
|
679
|
-
readonly payload: {
|
|
680
|
-
readonly title: 'Payload';
|
|
681
|
-
readonly type: 'string';
|
|
682
|
-
};
|
|
683
731
|
};
|
|
684
|
-
readonly required: readonly ['kind', 'enabled'
|
|
732
|
+
readonly required: readonly ['kind', 'enabled'];
|
|
685
733
|
}, {
|
|
686
734
|
readonly type: 'object';
|
|
687
735
|
readonly additionalProperties: false;
|
|
@@ -699,24 +747,6 @@ export declare const HOUSE_MODEL_DECLARATION: {
|
|
|
699
747
|
readonly type: 'string';
|
|
700
748
|
readonly minLength: 1;
|
|
701
749
|
};
|
|
702
|
-
readonly text: {
|
|
703
|
-
readonly title: 'Text';
|
|
704
|
-
readonly type: 'string';
|
|
705
|
-
};
|
|
706
|
-
};
|
|
707
|
-
readonly required: readonly ['kind', 'enabled', 'text'];
|
|
708
|
-
}, {
|
|
709
|
-
readonly type: 'object';
|
|
710
|
-
readonly additionalProperties: false;
|
|
711
|
-
readonly properties: {
|
|
712
|
-
readonly kind: {
|
|
713
|
-
readonly title: 'Kind';
|
|
714
|
-
readonly const: 'done';
|
|
715
|
-
};
|
|
716
|
-
readonly enabled: {
|
|
717
|
-
readonly title: 'Enabled';
|
|
718
|
-
readonly type: 'boolean';
|
|
719
|
-
};
|
|
720
750
|
};
|
|
721
751
|
readonly required: readonly ['kind', 'enabled'];
|
|
722
752
|
}, {
|
|
@@ -739,6 +769,18 @@ export declare const HOUSE_MODEL_DECLARATION: {
|
|
|
739
769
|
readonly title: 'Function';
|
|
740
770
|
readonly type: 'string';
|
|
741
771
|
};
|
|
772
|
+
readonly attached_by: {
|
|
773
|
+
readonly title: 'Attached by';
|
|
774
|
+
readonly type: 'object';
|
|
775
|
+
readonly additionalProperties: false;
|
|
776
|
+
readonly properties: {
|
|
777
|
+
readonly user: {
|
|
778
|
+
readonly title: 'User';
|
|
779
|
+
readonly $ref: '#/$defs/id';
|
|
780
|
+
};
|
|
781
|
+
};
|
|
782
|
+
readonly required: readonly ['user'];
|
|
783
|
+
};
|
|
742
784
|
};
|
|
743
785
|
readonly required: readonly ['kind', 'enabled', 'function'];
|
|
744
786
|
}];
|