@agentshouse/mdmodel 0.1.0-c9a0eed64bb5f → 0.1.0-ca3c1be3cd1a3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,11 +1,13 @@
1
1
  export { candidateOf, datePointers, facts, memberPointers, members, pointed, prosePaths, TEXT_FIELD, valuedChange, WRITE_DOORS, } from './event.js';
2
- export { byCodePoint, compared, dated, fitsKind, instant, instantKey, kindOf, kindWords, } from './kinds.js';
2
+ export { byCodePoint, compared, dated, fitsKind, indexKey, instant, instantKey, kindOf, kindWords, } from './kinds.js';
3
3
  export { bodied, cursorOf, decodedCursor, identityOf, invalid, known, placeText, planOf, QueryError, queryKey, } from './query/language.js';
4
+ export { verifyIndexBounds } from './indexed.js';
4
5
  export { heldAt, matches } from './query/match.js';
5
6
  export { heldKind, indexed } from './query/rows.js';
6
7
  export * as sql from './query/sql.js';
7
8
  export { headingLines } from './markdown.js';
8
9
  export { acceptsType, dataUrl, dataUrlPattern, declaresUtf8, FILE_MEDIA_TYPES, fileExtension, formDataType, gitMediaType, isAudioType, isImageType, isVideoType, MEDIA_TYPES, mediaTypeEssence, SCRIPT_MEDIA_TYPES, servedMediaType, UTF8_TEXT, withCharset, } from './media-type.js';
10
+ export { shownDay, shownMoment } from './moment.js';
9
11
  export { labelAt, NAME_FIELD } from './body.js';
10
12
  export { divide } from './divide.js';
11
13
  export { apply, bodyLinks, create, links, parse, relabel, relabels, relativize, relativizeBody, relinkBody, serialize, textSpans, unlinkBody, } from './document.js';
@@ -17,12 +19,12 @@ export { HOUSE_MODEL, HOUSE_ROOM_TYPES } from './built-in.js';
17
19
  export { APP_PREFERENCES_HOME, HOUSE_MODEL_DECLARATION, HOUSE_TYPED_PATHS } from './house-model.js';
18
20
  export { APP_REFERENCE_PATTERN, APP_REFERENCE_PREFIX, ROOM_REFERENCE_PATTERN, REVISION_REFERENCE_PATTERN, REVISION_REFERENCE_PREFIX, ROOM_REFERENCE_PREFIX, SPACE_REFERENCE_PATTERN, SPACE_REFERENCE_PREFIX, } from './house-references/patterns.js';
19
21
  export { CHAT_MESSAGE_TYPE, CHAT_TYPE, INBOX_CHANNEL_KINDS, INBOX_TYPES } from './room-types.js';
20
- export { linkedPath, relative, retarget, roomPath, roomTarget, target } from './paths.js';
22
+ export { keyedDestination, keyedLink, linkedPath, relative, retarget, roomPath, roomTarget, target, } from './paths.js';
21
23
  export { openPatternBudget } from './pattern.js';
22
24
  export { project } from './project.js';
23
25
  export { references } from './references.js';
24
26
  export { CAPTURE_HOME, isDocumentPath, isReservedName, RESERVED_NAMES, ROOM_DESCRIPTION, } from './reserved.js';
25
27
  export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, JSON_POINTER, memberFacts, pointerFacts, pointerSegments, untitled, } from './definition.js';
26
- export { assess, assessReferences, bodyRoomLinks, checkDocument, definitionAt, readTypes, resolves, roomReferences, validate, validateParsed, validating, verdicts, verify, } from './validate.js';
28
+ export { assess, assessReferences, bodyKeyedLinks, bodyRoomLinks, checkDocument, definitionAt, readTypes, resolves, roomReferences, validate, validateParsed, validating, verdicts, verify, } from './validate.js';
27
29
  export { VERSION } from './version.js';
28
30
  export { bodyAfterFrontmatter, documentValue, equalValue, plain } from './yaml.js';
@@ -0,0 +1,9 @@
1
+ import { type Failure } from './definition.js';
2
+ import type { ModelVerification, VerifiedModel } from './types.js';
3
+ export type IndexBounds = {
4
+ readonly perType: number;
5
+ readonly longestText: number;
6
+ };
7
+ export declare function indexedFailure(model: VerifiedModel): Failure | undefined;
8
+ export declare function verifyIndexBounds(model: VerifiedModel, bounds: IndexBounds): ModelVerification;
9
+ //# sourceMappingURL=indexed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexed.d.ts","sourceRoot":"","sources":["../src/indexed.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,OAAO,EACb,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGnE,MAAM,MAAM,WAAW,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AA+CrF,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,GAAG,SAAS,CAQxE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,GAAG,iBAAiB,CAW9F"}
@@ -0,0 +1,55 @@
1
+ import { admitted, conjoined, escapePointer, refuse, UNIONS, } from './definition.js';
2
+ import { HOUSE_FIELDS } from './fields.js';
3
+ import { kindOf } from './kinds.js';
4
+ import { isRecord } from './yaml.js';
5
+ const PLAIN = ['string', 'number', 'boolean'];
6
+ const UNBOUNDED_KINDS = ['enum', 'date', 'date-time', 'time'];
7
+ function declarations(definition, field) {
8
+ const { schema, defs } = definition.shape;
9
+ return conjoined([{ node: schema, at: '' }], defs, new Set()).held.flatMap(({ node }) => isRecord(node.properties) && Object.hasOwn(node.properties, field)
10
+ ? [node.properties[field]]
11
+ : []);
12
+ }
13
+ function indexable(definition, field) {
14
+ if (HOUSE_FIELDS.includes(field) || !Object.hasOwn(definition.fields, field))
15
+ return null;
16
+ const facts = definition.fields[field];
17
+ if (facts.markdown === true || facts.reference !== undefined)
18
+ return null;
19
+ const declared = declarations(definition, field);
20
+ const { defs } = definition.shape;
21
+ const held = conjoined(declared.map((node) => ({ node, at: '' })), defs, new Set()).held.map(({ node }) => node);
22
+ if (held.length === 0 ||
23
+ held.some((node) => UNIONS.some((keyword) => node[keyword] !== undefined)))
24
+ return null;
25
+ const types = admitted(declared, defs, new Set());
26
+ const plain = types === null ? [] : [...types].filter((type) => type !== 'null');
27
+ if (plain.length !== 1 || !PLAIN.includes(plain[0]))
28
+ return null;
29
+ if (plain[0] !== 'string' || UNBOUNDED_KINDS.includes(kindOf(facts) ?? ''))
30
+ return { text: null };
31
+ const lengths = held.flatMap((node) => typeof node.maxLength === 'number' ? [node.maxLength] : []);
32
+ return lengths.length === 0 ? null : { text: Math.min(...lengths) };
33
+ }
34
+ function at(name, index) {
35
+ return `/${escapePointer(name)}/indexed/${index}`;
36
+ }
37
+ export function indexedFailure(model) {
38
+ for (const [name, definition] of Object.entries(model.types)) {
39
+ const index = (definition.indexed ?? []).findIndex((field) => indexable(definition, field) === null);
40
+ if (index !== -1)
41
+ return refuse('indexed', at(name, index));
42
+ }
43
+ return undefined;
44
+ }
45
+ export function verifyIndexBounds(model, bounds) {
46
+ for (const [name, definition] of Object.entries(model.types)) {
47
+ const indexed = definition.indexed ?? [];
48
+ if (indexed.length > bounds.perType)
49
+ return { verdict: 'refuse', rule: 'indexed', location: at(name, bounds.perType) };
50
+ const index = indexed.findIndex((field) => (indexable(definition, field)?.text ?? 0) > bounds.longestText);
51
+ if (index !== -1)
52
+ return { verdict: 'refuse', rule: 'indexed', location: at(name, index) };
53
+ }
54
+ return { verdict: 'accept', model };
55
+ }
package/dist/kinds.d.ts CHANGED
@@ -13,6 +13,8 @@ export declare function kindWords(facts: ValueFacts | undefined): readonly strin
13
13
  export declare function dated(value: unknown): value is string;
14
14
  export declare function instant(value: unknown): bigint | undefined;
15
15
  export declare function instantKey(value: unknown): string | null;
16
+ export declare function instantOf(facts: ValueFacts | undefined, value: unknown): string | null;
17
+ export declare function indexKey(facts: ValueFacts, value: unknown): Uint8Array;
16
18
  export declare function byCodePoint(left: string, right: string): number;
17
19
  export declare function compared(left: unknown, right: unknown, ordering: Ordering): number;
18
20
  //# sourceMappingURL=kinds.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"kinds.d.ts","sourceRoot":"","sources":["../src/kinds.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,MAAM,MAAM,IAAI,GACZ,QAAQ,GACR,QAAQ,GACR,SA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K,EAAE,MAAM,GAAG,MAAM,CAO/D;AA4BD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAMlF"}
package/dist/kinds.js CHANGED
@@ -3,6 +3,10 @@ import { normalize } from './paths.js';
3
3
  const DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})[Tt\s](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?(?:[Zz]|([+-])(\d{2})(?::?(\d{2}))?)$/u;
4
4
  const BEFORE_YEAR_ZERO = 62200000000000000000n;
5
5
  const INSTANT_DIGITS = 21;
6
+ const MISSING_KEY = 0;
7
+ const NUMBER_KEYS = 1;
8
+ const INSTANT_KEYS = 2;
9
+ const TEXT_KEYS = 3;
6
10
  export function kindOf(facts) {
7
11
  if (facts.reference !== undefined)
8
12
  return 'reference';
@@ -86,6 +90,51 @@ export function instantKey(value) {
86
90
  const at = instant(value);
87
91
  return at === undefined ? null : (at + BEFORE_YEAR_ZERO).toString().padStart(INSTANT_DIGITS, '0');
88
92
  }
93
+ export function instantOf(facts, value) {
94
+ return facts !== undefined && kindOf(facts) === 'date-time' ? instantKey(value) : null;
95
+ }
96
+ function utf8(text) {
97
+ const bytes = [];
98
+ for (const char of text) {
99
+ const code = char.codePointAt(0);
100
+ if (code < 0x80)
101
+ bytes.push(code);
102
+ else if (code < 0x800)
103
+ bytes.push(0xc0 | (code >> 6), 0x80 | (code & 0x3f));
104
+ else if (code < 0x10000)
105
+ bytes.push(0xe0 | (code >> 12), 0x80 | ((code >> 6) & 0x3f), 0x80 | (code & 0x3f));
106
+ else
107
+ bytes.push(0xf0 | (code >> 18), 0x80 | ((code >> 12) & 0x3f), 0x80 | ((code >> 6) & 0x3f), 0x80 | (code & 0x3f));
108
+ }
109
+ return bytes;
110
+ }
111
+ function numberKey(value) {
112
+ const key = new Uint8Array(9);
113
+ const view = new DataView(key.buffer);
114
+ view.setUint8(0, NUMBER_KEYS);
115
+ view.setFloat64(1, value === 0 ? 0 : value);
116
+ const sign = view.getUint8(1);
117
+ if (sign < 0x80)
118
+ view.setUint8(1, sign | 0x80);
119
+ else
120
+ for (let at = 1; at < key.length; at += 1)
121
+ view.setUint8(at, ~view.getUint8(at) & 0xff);
122
+ return key;
123
+ }
124
+ export function indexKey(facts, value) {
125
+ if (value === undefined || value === null)
126
+ return Uint8Array.of(MISSING_KEY);
127
+ if (typeof value === 'boolean')
128
+ return numberKey(value ? 1 : 0);
129
+ if (typeof value === 'number')
130
+ return numberKey(value);
131
+ if (typeof value !== 'string')
132
+ throw new Error('an indexed value is a number, a boolean or a string');
133
+ const at = instantOf(facts, value);
134
+ return at === null
135
+ ? Uint8Array.of(TEXT_KEYS, ...utf8(value))
136
+ : Uint8Array.of(INSTANT_KEYS, ...utf8(at));
137
+ }
89
138
  function rank(value) {
90
139
  if (typeof value === 'boolean' || typeof value === 'number')
91
140
  return 1;
@@ -0,0 +1,7 @@
1
+ export interface MomentReader {
2
+ readonly language: string;
3
+ readonly zone: string | null;
4
+ }
5
+ export declare function shownMoment(at: Date, reader: MomentReader): string;
6
+ export declare function shownDay(at: Date, reader: MomentReader): string;
7
+ //# sourceMappingURL=moment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"moment.d.ts","sourceRoot":"","sources":["../src/moment.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAWD,wBAAgB,WAAW,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,GAAG,MAAM,CAOlE;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,GAAG,MAAM,CAE/D"}
package/dist/moment.js ADDED
@@ -0,0 +1,18 @@
1
+ const DAY = { day: 'numeric', month: 'short', year: 'numeric' };
2
+ function shown(at, reader, form) {
3
+ return new Intl.DateTimeFormat(reader.language, {
4
+ ...form,
5
+ timeZone: reader.zone ?? 'UTC',
6
+ }).format(at);
7
+ }
8
+ export function shownMoment(at, reader) {
9
+ return shown(at, reader, {
10
+ ...DAY,
11
+ hour: '2-digit',
12
+ minute: '2-digit',
13
+ ...(reader.zone === null ? { timeZoneName: 'short' } : {}),
14
+ });
15
+ }
16
+ export function shownDay(at, reader) {
17
+ return shown(at, reader, DAY);
18
+ }
package/dist/paths.d.ts CHANGED
@@ -26,6 +26,11 @@ export interface LinkedPath {
26
26
  readonly fragment: string | null;
27
27
  }
28
28
  export declare function linkedPath(from: string, href: string): LinkedPath | null;
29
+ export interface KeyedLink extends RoomTarget {
30
+ readonly key: string;
31
+ }
32
+ export declare function keyedLink(href: string): KeyedLink | null;
33
+ export declare function keyedDestination(path: string, key: string): string;
29
34
  export declare function retarget(href: string, to: string): string;
30
35
  export declare function relative(from: string, target: string): string;
31
36
  export declare const SHELL_ROOMS = "/rooms/";
@@ -1 +1 @@
1
- {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAUA,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG3D;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAYrD;AA6DD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAW3D;AAgBD,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAiB5E,KAAK,UAAU,GACX;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IA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AAG,IAAI,CAAC;CAClC;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAaxE;AAID,MAAM,WAAW,SAAU,SAAQ,UAAU;IAC3C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAOxD;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAElE;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAW7D;AAED,eAAO,MAAM,WAAW,YAAY,CAAC;AAErC,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMvE;AAoBD,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAI7E"}
package/dist/paths.js CHANGED
@@ -176,6 +176,20 @@ export function linkedPath(from, href) {
176
176
  fragment: fragment === '' ? null : (decodedRun(fragment) ?? fragment),
177
177
  };
178
178
  }
179
+ const LINK_KEY = /^\?key=([A-Za-z0-9._~-]+)(?:#|$)/u;
180
+ export function keyedLink(href) {
181
+ const written = href.trim();
182
+ if (!written.includes('?') && !written.includes('&'))
183
+ return null;
184
+ const key = LINK_KEY.exec(spelled(written, unescaped(written).suffix, false).text)?.[1];
185
+ if (key === undefined)
186
+ return null;
187
+ const room = roomTarget(href);
188
+ return room === null ? null : { ...room, key };
189
+ }
190
+ export function keyedDestination(path, key) {
191
+ return `${written(path)}?key=${key}`;
192
+ }
179
193
  export function retarget(href, to) {
180
194
  const trimmed = href.trim();
181
195
  return written(to) + trimmed.slice(unescaped(trimmed).suffix);
@@ -1 +1 @@
1
- {"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../../src/query/rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,UAAU,EAEhB,MAAM,kBAAkB,CAAC;AAI1B,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEnG,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AAE/C,MAAM,MAAM,MAAM,G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IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AAE/C,MAAM,MAAM,MAAM,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAahG,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,MAAM,CAuB9D;AA4BD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAMjD;AAgGD,wBAAgB,OAAO,CACrB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,GAAG,SAAS,GAC/C,OAAO,CAcT"}
@@ -1,5 +1,5 @@
1
1
  import { ARRAY_INDEX, escapePointer, itemFacts, memberFacts, } from '../definition.js';
2
- import { instantKey, kindOf } from '../kinds.js';
2
+ import { instantOf } from '../kinds.js';
3
3
  import { target } from '../paths.js';
4
4
  export function placedOf(pointer, reach) {
5
5
  const [first = '', ...rest] = pointer.split('/').slice(1);
@@ -67,9 +67,6 @@ function scalarOf(value) {
67
67
  return JSON.stringify(value);
68
68
  return null;
69
69
  }
70
- function instantOf(facts, value) {
71
- return facts !== undefined && kindOf(facts) === 'date-time' ? instantKey(value) : null;
72
- }
73
70
  function held(reading, at, places, value, items) {
74
71
  reading.values.push({
75
72
  keys: at.keys,
@@ -1,4 +1,5 @@
1
1
  import { type Definition } from './definition.js';
2
+ import { type KeyedLink } from './paths.js';
2
3
  import type { DefinitionOf, Document, DocumentCheck, Library, ModelVerification, ParseResult, Reached, RoomReference, TypedPath, Validation, ValidationContext, ValidationStep, VerifiedModel } from './types.js';
3
4
  export declare function definitionAt(model: VerifiedModel, file: string, typedPaths?: readonly TypedPath[]): DefinitionOf;
4
5
  export declare function resolves(reference: Reached, typeOf: (path: string) => string | undefined, binary: (path: string) => boolean): boolean;
@@ -7,6 +8,7 @@ export declare function readTypes(schema: string, provided?: VerifiedModel): Ver
7
8
  type Placing = Pick<ValidationContext, 'anyRoom' | 'typedPaths'>;
8
9
  export declare function checkDocument(file: string, content: string, model: VerifiedModel, context?: Placing): DocumentCheck;
9
10
  export declare function bodyRoomLinks(body: string): RoomReference[];
11
+ export declare function bodyKeyedLinks(body: string): KeyedLink[];
10
12
  export declare function roomReferences(document: Document, definition?: Definition): readonly RoomReference[];
11
13
  type Placed = {
12
14
  readonly reference: Reached;
@@ -1 +1 @@
1
- {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,UAAU,EAEhB,MAAM,iBAAiB,CAAC;AAWzB,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,OAAO,EACP,iBAAiB,EACjB,WAAW,EACX,OAAO,EACP,aAAa,EACb,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,aAAa,EACd,MAAM,YAAY,CAAC;AA6FpB,wBAAgB,YAAY,CAC1B,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,SAAS,SAAS,EAAE,GAChC,YAAY,CAOd;AA8BD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OAAO,IAAI,UAAU,CAAC;CACvB,CAAC;AAEF,wBAAgB,QAAQ,IAAI,QAAQ,CAmDnC;AAWD,wBAAiB,UAAU,CACzB,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,OAAO,GAAE,iBAAyC,EAClD,KAAK,GAAE,aAA6B,GACnC,SAAS,CAAC,cAAc,EAAE,UAAU,EAAE,IAAI,CAAC,CAE7C;AAoCD,wBAAgB,QAAQ,CACtB,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,iBAAyC,EAClD,KAAK,GAAE,aAA6B,GACnC,UAAU,CAEZ;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,EACzC,OAAO,GAAE,iBAAyC,EAClD,KAAK,GAAE,aAA6B,GACnC,UAAU,CAEZ"}
package/dist/validate.js CHANGED
@@ -2,8 +2,9 @@ import { ATTACHMENT, BUILT_IN_TYPE, readSchema, } from './definition.js';
2
2
  import { linkDestinations, links, parse } from './document.js';
3
3
  import { MEMBER_FIELD } from './fields.js';
4
4
  import { formFailure } from './form.js';
5
+ import { indexedFailure } from './indexed.js';
5
6
  import { hrefOccurrences, lineBreaks, lineNumber } from './markdown.js';
6
- import { classifyHref, roomTarget } from './paths.js';
7
+ import { classifyHref, keyedLink, roomTarget } from './paths.js';
7
8
  import { references } from './references.js';
8
9
  import { isDocumentPath, ROOM_DESCRIPTION } from './reserved.js';
9
10
  import { refusal } from './refuse.js';
@@ -114,7 +115,7 @@ export function verify(schema, provided) {
114
115
  const read = readSchema(schema, provided);
115
116
  if (!('types' in read))
116
117
  return schemaRefused(read);
117
- const failure = formFailure(read, provided);
118
+ const failure = formFailure(read, provided) ?? indexedFailure(read);
118
119
  return failure === undefined ? { verdict: 'accept', model: read } : schemaRefused(failure);
119
120
  }
120
121
  export function readTypes(schema, provided) {
@@ -148,7 +149,7 @@ function referred(file, href, to) {
148
149
  : reference;
149
150
  }
150
151
  function crossing(file, href, crossRoom) {
151
- return crossRoom === true && classifyHref(file, href).kind === 'room';
152
+ return (keyedLink(href) !== null || (crossRoom === true && classifyHref(file, href).kind === 'room'));
152
153
  }
153
154
  function definitionOf(kind, model) {
154
155
  return kind === null || !Object.hasOwn(model.types, kind) ? undefined : model.types[kind];
@@ -185,7 +186,7 @@ export function checkDocument(file, content, model, context = {}) {
185
186
  function roomLinks(occurrences) {
186
187
  const found = [];
187
188
  for (const href of new Set(occurrences.map((occurrence) => occurrence.href))) {
188
- const room = roomTarget(href);
189
+ const room = keyedLink(href) === null ? roomTarget(href) : null;
189
190
  if (room !== null)
190
191
  found.push({ kind: 'link', href, ...room });
191
192
  }
@@ -194,12 +195,15 @@ function roomLinks(occurrences) {
194
195
  export function bodyRoomLinks(body) {
195
196
  return roomLinks(hrefOccurrences(body));
196
197
  }
198
+ export function bodyKeyedLinks(body) {
199
+ return [...new Set(hrefOccurrences(body).map((occurrence) => occurrence.href))].flatMap((href) => keyedLink(href) ?? []);
200
+ }
197
201
  export function roomReferences(document, definition) {
198
202
  const found = roomLinks(linkDestinations(document));
199
203
  if (definition === undefined)
200
204
  return found;
201
205
  for (const { pointer, value, to, crossRoom } of references(document, definition)) {
202
- const room = roomTarget(value);
206
+ const room = keyedLink(value) === null ? roomTarget(value) : null;
203
207
  if (room !== null)
204
208
  found.push({
205
209
  kind: 'field',
@@ -90,7 +90,11 @@ the schema and plan `{ ...query, select: {} }` with `planOf` against its types.
90
90
  `matches(plan, candidate)` over the named Document, given its type's definition, and the
91
91
  condition `sql.tests` writes over a collection holding every Document of the table with the
92
92
  values `indexed` derives from it must both answer `matches`. A new operator adds its cases
93
- here first.
93
+ here first. Each of `orders` carries a `name`, one `orderBy` clause on a field the `task` type
94
+ names `indexed` and the `order` of every `task` Document, ties by Path in code-point order in
95
+ either direction. The SQL order `sql.sorted` writes over that collection, `compared` over the
96
+ value `heldAt` reads, its instant for a date-time, and the bytes of each Document's `indexKey`,
97
+ a missing value and `null` placed as the clause's `nulls` asks, must each give that order.
94
98
 
95
99
  ## Verdict format
96
100
 
@@ -142,6 +146,7 @@ schema text. The model's own rules:
142
146
  | `$ref` | A `$ref` reaches no subschema under `#/$defs/` of the same file |
143
147
  | `reference` | `reference` is not on a string or names something but a type, `any`, `attachment` |
144
148
  | `member_document` | The mark is not a boolean, or a second type carries it |
149
+ | `indexed` | `indexed` names a field a type cannot index, or more than its caller's bounds |
145
150
  | `duplicate-label` | Two fields of one object show one label: a field's `title`, else its key |
146
151
  | `conflicting-label` | Declarations of one key in `anyOf`, `oneOf`, `then`, `else` or a composed shape give it two `title`s |
147
152
  | `conflicting-type` | Such declarations give one key two JSON types, integer and number counting as one |
@@ -1,5 +1,5 @@
1
1
  {
2
- "schema": "task:\n type: object\n properties:\n title: { type: string }\n status: { enum: [open, done] }\n due: { type: string, format: date }\n at: { type: string, format: date-time }\n ends: { type: [string, \"null\"], format: date-time }\n place:\n type: object\n properties:\n city: { type: string }\n starts: { type: string, format: time }\n points: { type: number }\n count: { type: integer }\n done: { type: boolean }\n priority: { type: integer, enum: [1, 2, 3] }\n flagged: { enum: [true, false] }\n tier: { enum: [1, 2, null] }\n rank: { enum: [1, high] }\n owner: { type: string, reference: person }\n labels: { type: array, items: { type: string } }\n times: { type: array, items: { type: string, format: date-time } }\n steps:\n type: array\n items:\n type: object\n properties:\n name: { type: string }\n at: { type: string, format: date-time }\nperson:\n type: object\n properties:\n name: { type: string }\n",
2
+ "schema": "task:\n type: object\n properties:\n title: { type: string }\n status: { enum: [open, done] }\n due: { type: string, format: date }\n at: { type: string, format: date-time }\n ends: { type: [string, \"null\"], format: date-time }\n place:\n type: object\n properties:\n city: { type: string }\n starts: { type: string, format: time }\n points: { type: number }\n count: { type: integer }\n done: { type: boolean }\n priority: { type: integer, enum: [1, 2, 3] }\n flagged: { enum: [true, false] }\n tier: { enum: [1, 2, null] }\n rank: { enum: [1, high] }\n code: { type: string, maxLength: 12 }\n owner: { type: string, reference: person }\n labels: { type: array, items: { type: string } }\n times: { type: array, items: { type: string, format: date-time } }\n steps:\n type: array\n items:\n type: object\n properties:\n name: { type: string }\n at: { type: string, format: date-time }\n indexed: [status, due, at, ends, starts, points, count, done, tier, code]\nperson:\n type: object\n properties:\n name: { type: string }\n",
3
3
  "documents": {
4
4
  "task": {
5
5
  "path": "tasks/one.md",
@@ -41,7 +41,8 @@
41
41
  "title": "Two",
42
42
  "status": "done",
43
43
  "ends": null,
44
- "labels": []
44
+ "labels": [],
45
+ "code": "Zeta"
45
46
  }
46
47
  },
47
48
  "spaced-task": {
@@ -76,6 +77,79 @@
76
77
  "fileId": null,
77
78
  "text": "path,status\n",
78
79
  "fields": {}
80
+ },
81
+ "task-four": {
82
+ "path": "tasks/four.md",
83
+ "type": "task",
84
+ "fileId": "file-four",
85
+ "text": null,
86
+ "fields": {
87
+ "title": "Four",
88
+ "status": "done",
89
+ "due": "2025-12-31",
90
+ "at": "2026-10-29T23:30:00-10:00",
91
+ "ends": "2026-10-30T07:00:00Z",
92
+ "starts": "09:30:00+01:00",
93
+ "points": -0,
94
+ "count": 2,
95
+ "done": true,
96
+ "tier": 2,
97
+ "code": "\ufffd"
98
+ }
99
+ },
100
+ "task-five": {
101
+ "path": "tasks/five.md",
102
+ "type": "task",
103
+ "fileId": "file-five",
104
+ "text": null,
105
+ "fields": {
106
+ "title": "Five",
107
+ "status": "open",
108
+ "due": "2026-01-05",
109
+ "at": "2026-10-30T07:59:59.999999999Z",
110
+ "ends": "2026-10-30T09:00:00+01:00",
111
+ "starts": "08:00:00Z",
112
+ "points": 0,
113
+ "count": -1,
114
+ "done": false,
115
+ "tier": null,
116
+ "code": "alpha"
117
+ }
118
+ },
119
+ "task-six": {
120
+ "path": "tasks/six.md",
121
+ "type": "task",
122
+ "fileId": "file-six",
123
+ "text": null,
124
+ "fields": {
125
+ "title": "Six",
126
+ "status": "done",
127
+ "due": "2026-10-30",
128
+ "at": "2026-10-30T09:00:00Z",
129
+ "ends": null,
130
+ "starts": "23:59:60Z",
131
+ "points": 2.5,
132
+ "count": 10,
133
+ "done": null,
134
+ "tier": 1,
135
+ "code": "\ud835\udc9c"
136
+ }
137
+ },
138
+ "task-seven": {
139
+ "path": "tasks/seven.md",
140
+ "type": "task",
141
+ "fileId": "file-seven",
142
+ "text": null,
143
+ "fields": {
144
+ "title": "Seven",
145
+ "ends": "2026-10-30T08:00:00.000000001Z",
146
+ "starts": "09:30:00Z",
147
+ "points": null,
148
+ "count": -1000000,
149
+ "done": true,
150
+ "tier": 2,
151
+ "code": "alpha"
152
+ }
79
153
  }
80
154
  },
81
155
  "cases": [
@@ -960,5 +1034,117 @@
960
1034
  "document": "bare-task",
961
1035
  "matches": true
962
1036
  }
1037
+ ],
1038
+ "orders": [
1039
+ {
1040
+ "name": "numbers ascend with nulls first, a negative zero tied with zero by Path",
1041
+ "orderBy": { "by": { "field": "/points" }, "direction": "asc", "nulls": "first" },
1042
+ "order": ["task-seven", "spaced-task", "bare-task", "task-five", "task-four", "task-six", "task"]
1043
+ },
1044
+ {
1045
+ "name": "numbers descend with nulls first, ties still by Path",
1046
+ "orderBy": { "by": { "field": "/points" }, "direction": "desc", "nulls": "first" },
1047
+ "order": ["task-seven", "spaced-task", "bare-task", "task", "task-six", "task-five", "task-four"]
1048
+ },
1049
+ {
1050
+ "name": "numbers ascend with nulls last",
1051
+ "orderBy": { "by": { "field": "/points" }, "direction": "asc", "nulls": "last" },
1052
+ "order": ["task-five", "task-four", "task-six", "task", "task-seven", "spaced-task", "bare-task"]
1053
+ },
1054
+ {
1055
+ "name": "numbers descend with nulls last",
1056
+ "orderBy": { "by": { "field": "/points" }, "direction": "desc", "nulls": "last" },
1057
+ "order": ["task", "task-six", "task-five", "task-four", "task-seven", "spaced-task", "bare-task"]
1058
+ },
1059
+ {
1060
+ "name": "integers ascend through negatives, ties by Path",
1061
+ "orderBy": { "by": { "field": "/count" }, "direction": "asc", "nulls": "first" },
1062
+ "order": ["spaced-task", "bare-task", "task-seven", "task-five", "task-four", "task", "task-six"]
1063
+ },
1064
+ {
1065
+ "name": "integers descend, ties by Path",
1066
+ "orderBy": { "by": { "field": "/count" }, "direction": "desc", "nulls": "first" },
1067
+ "order": ["spaced-task", "bare-task", "task-six", "task-four", "task", "task-five", "task-seven"]
1068
+ },
1069
+ {
1070
+ "name": "booleans ascend false before true, null with the missing",
1071
+ "orderBy": { "by": { "field": "/done" }, "direction": "asc", "nulls": "first" },
1072
+ "order": ["task-six", "spaced-task", "bare-task", "task-five", "task", "task-four", "task-seven"]
1073
+ },
1074
+ {
1075
+ "name": "booleans descend with nulls last",
1076
+ "orderBy": { "by": { "field": "/done" }, "direction": "desc", "nulls": "last" },
1077
+ "order": ["task-four", "task-seven", "task-five", "task", "task-six", "spaced-task", "bare-task"]
1078
+ },
1079
+ {
1080
+ "name": "a choice ascends by code point",
1081
+ "orderBy": { "by": { "field": "/status" }, "direction": "asc", "nulls": "first", "stringSort": "lexical" },
1082
+ "order": ["task-seven", "task-four", "task-six", "bare-task", "task-five", "task", "spaced-task"]
1083
+ },
1084
+ {
1085
+ "name": "a choice descends by code point",
1086
+ "orderBy": { "by": { "field": "/status" }, "direction": "desc", "nulls": "first", "stringSort": "lexical" },
1087
+ "order": ["task-seven", "task-five", "task", "spaced-task", "task-four", "task-six", "bare-task"]
1088
+ },
1089
+ {
1090
+ "name": "a choice of integers ascends with its null among the missing",
1091
+ "orderBy": { "by": { "field": "/tier" }, "direction": "asc", "nulls": "first" },
1092
+ "order": ["task-five", "task", "spaced-task", "bare-task", "task-six", "task-four", "task-seven"]
1093
+ },
1094
+ {
1095
+ "name": "a choice of integers descends with nulls last",
1096
+ "orderBy": { "by": { "field": "/tier" }, "direction": "desc", "nulls": "last" },
1097
+ "order": ["task-four", "task-seven", "task-six", "task-five", "task", "spaced-task", "bare-task"]
1098
+ },
1099
+ {
1100
+ "name": "dates ascend, ties by Path",
1101
+ "orderBy": { "by": { "field": "/due" }, "direction": "asc", "nulls": "first", "stringSort": "lexical" },
1102
+ "order": ["task-seven", "spaced-task", "bare-task", "task-four", "task-five", "task", "task-six"]
1103
+ },
1104
+ {
1105
+ "name": "dates descend, ties by Path",
1106
+ "orderBy": { "by": { "field": "/due" }, "direction": "desc", "nulls": "first", "stringSort": "lexical" },
1107
+ "order": ["task-seven", "spaced-task", "bare-task", "task", "task-six", "task-five", "task-four"]
1108
+ },
1109
+ {
1110
+ "name": "date-times ascend by instant whatever their offset, the same instant tied by Path",
1111
+ "orderBy": { "by": { "field": "/at" }, "direction": "asc", "nulls": "first", "stringSort": "lexical" },
1112
+ "order": ["task-seven", "bare-task", "task-five", "task", "spaced-task", "task-six", "task-four"]
1113
+ },
1114
+ {
1115
+ "name": "date-times descend by instant",
1116
+ "orderBy": { "by": { "field": "/at" }, "direction": "desc", "nulls": "first", "stringSort": "lexical" },
1117
+ "order": ["task-seven", "bare-task", "task-four", "task-six", "task", "spaced-task", "task-five"]
1118
+ },
1119
+ {
1120
+ "name": "nullable date-times ascend by instant with nulls last",
1121
+ "orderBy": { "by": { "field": "/ends" }, "direction": "asc", "nulls": "last", "stringSort": "lexical" },
1122
+ "order": ["task-four", "task-five", "task-seven", "task", "task-six", "spaced-task", "bare-task"]
1123
+ },
1124
+ {
1125
+ "name": "nullable date-times descend by instant with nulls first",
1126
+ "orderBy": { "by": { "field": "/ends" }, "direction": "desc", "nulls": "first", "stringSort": "lexical" },
1127
+ "order": ["task", "task-six", "spaced-task", "bare-task", "task-seven", "task-five", "task-four"]
1128
+ },
1129
+ {
1130
+ "name": "times ascend as text, ties by Path",
1131
+ "orderBy": { "by": { "field": "/starts" }, "direction": "asc", "nulls": "first", "stringSort": "lexical" },
1132
+ "order": ["spaced-task", "bare-task", "task-five", "task-four", "task", "task-seven", "task-six"]
1133
+ },
1134
+ {
1135
+ "name": "times descend as text, ties by Path",
1136
+ "orderBy": { "by": { "field": "/starts" }, "direction": "desc", "nulls": "first", "stringSort": "lexical" },
1137
+ "order": ["spaced-task", "bare-task", "task-six", "task", "task-seven", "task-four", "task-five"]
1138
+ },
1139
+ {
1140
+ "name": "bounded text ascends by code point, upper case first and past the basic plane last",
1141
+ "orderBy": { "by": { "field": "/code" }, "direction": "asc", "nulls": "first", "stringSort": "lexical" },
1142
+ "order": ["task", "spaced-task", "bare-task", "task-five", "task-seven", "task-four", "task-six"]
1143
+ },
1144
+ {
1145
+ "name": "bounded text descends by code point with nulls last",
1146
+ "orderBy": { "by": { "field": "/code" }, "direction": "desc", "nulls": "last", "stringSort": "lexical" },
1147
+ "order": ["task-six", "task-four", "task-five", "task-seven", "bare-task", "task", "spaced-task"]
1148
+ }
963
1149
  ]
964
1150
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/mdmodel",
3
- "version": "0.1.0-c9a0eed64bb5f",
3
+ "version": "0.1.0-ca3c1be3cd1a3",
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",