@agentshouse/mdmodel 0.1.0-ce6172ed6fa4c → 0.1.0-ce7e4efd1b42d

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.
Files changed (79) hide show
  1. package/API.md +31 -97
  2. package/README.md +14 -14
  3. package/dist/definition.d.ts +5 -1
  4. package/dist/definition.d.ts.map +1 -1
  5. package/dist/definition.js +18 -9
  6. package/dist/document.d.ts +2 -2
  7. package/dist/document.d.ts.map +1 -1
  8. package/dist/document.js +88 -69
  9. package/dist/event.js +1 -1
  10. package/dist/fields.d.ts +1 -1
  11. package/dist/fields.d.ts.map +1 -1
  12. package/dist/fields.js +2 -2
  13. package/dist/house-model.d.ts +50 -7
  14. package/dist/house-model.d.ts.map +1 -1
  15. package/dist/house-model.js +18 -5
  16. package/dist/index.d.ts +15 -10
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +10 -8
  19. package/dist/indexed.d.ts +9 -0
  20. package/dist/indexed.d.ts.map +1 -0
  21. package/dist/indexed.js +55 -0
  22. package/dist/kinds.d.ts +3 -0
  23. package/dist/kinds.d.ts.map +1 -1
  24. package/dist/kinds.js +60 -0
  25. package/dist/markdown.d.ts +0 -4
  26. package/dist/markdown.d.ts.map +1 -1
  27. package/dist/markdown.js +1 -34
  28. package/dist/moment.d.ts +7 -0
  29. package/dist/moment.d.ts.map +1 -0
  30. package/dist/moment.js +18 -0
  31. package/dist/not-ready.d.ts +2 -0
  32. package/dist/not-ready.d.ts.map +1 -0
  33. package/dist/not-ready.js +5 -0
  34. package/dist/paths.d.ts +5 -0
  35. package/dist/paths.d.ts.map +1 -1
  36. package/dist/paths.js +14 -0
  37. package/dist/query/language.d.ts +2 -1
  38. package/dist/query/language.d.ts.map +1 -1
  39. package/dist/query/language.js +1 -1
  40. package/dist/query/match.d.ts +1 -1
  41. package/dist/query/match.d.ts.map +1 -1
  42. package/dist/query/rows.d.ts +1 -1
  43. package/dist/query/rows.d.ts.map +1 -1
  44. package/dist/query/rows.js +2 -5
  45. package/dist/query/sql.d.ts +5 -1
  46. package/dist/query/sql.d.ts.map +1 -1
  47. package/dist/query/sql.js +3 -3
  48. package/dist/query/walk.d.ts +63 -0
  49. package/dist/query/walk.d.ts.map +1 -0
  50. package/dist/query/walk.js +263 -0
  51. package/dist/references.d.ts +2 -2
  52. package/dist/references.d.ts.map +1 -1
  53. package/dist/references.js +1 -1
  54. package/dist/room-types.d.ts +1 -1
  55. package/dist/room-types.d.ts.map +1 -1
  56. package/dist/room-types.js +0 -1
  57. package/dist/schema.d.ts +1 -1
  58. package/dist/schema.d.ts.map +1 -1
  59. package/dist/schema.js +6 -7
  60. package/dist/types.d.ts +1 -31
  61. package/dist/types.d.ts.map +1 -1
  62. package/dist/validate.d.ts +2 -0
  63. package/dist/validate.d.ts.map +1 -1
  64. package/dist/validate.js +11 -7
  65. package/dist/yaml.d.ts +4 -4
  66. package/dist/yaml.d.ts.map +1 -1
  67. package/dist/yaml.js +1 -1
  68. package/fixtures/README.md +13 -48
  69. package/fixtures/preamble.json +4 -4
  70. package/fixtures/queries.json +397 -2
  71. package/package.json +1 -1
  72. package/dist/divide.d.ts +0 -3
  73. package/dist/divide.d.ts.map +0 -1
  74. package/dist/divide.js +0 -321
  75. package/dist/project.d.ts +0 -22
  76. package/dist/project.d.ts.map +0 -1
  77. package/dist/project.js +0 -101
  78. package/fixtures/division.json +0 -454
  79. package/fixtures/projection.json +0 -358
@@ -50,6 +50,7 @@ export const HOUSE_MODEL_DECLARATION = {
50
50
  'export-failed',
51
51
  'custom',
52
52
  'agent-function-request-finished',
53
+ 'storage-past-included',
53
54
  ],
54
55
  },
55
56
  created: { title: 'Created', type: 'string', format: 'date-time' },
@@ -76,7 +77,7 @@ export const HOUSE_MODEL_DECLARATION = {
76
77
  name: { title: 'Name', type: 'string' },
77
78
  email: { title: 'Email', type: 'string', format: 'email' },
78
79
  },
79
- required: ['name', 'email'],
80
+ required: ['name'],
80
81
  },
81
82
  rooms: {
82
83
  title: 'Rooms',
@@ -160,7 +161,7 @@ export const HOUSE_MODEL_DECLARATION = {
160
161
  name: { title: 'Name', type: 'string' },
161
162
  email: { title: 'Email', type: 'string', format: 'email' },
162
163
  },
163
- required: ['name', 'email'],
164
+ required: ['name'],
164
165
  },
165
166
  environment: {
166
167
  title: 'Environment',
@@ -243,14 +244,18 @@ export const HOUSE_MODEL_DECLARATION = {
243
244
  type: 'string',
244
245
  enum: [
245
246
  'failed',
247
+ 'internal_error',
248
+ 'agent_function_unreadable',
246
249
  'function_failed',
247
250
  'function_not_started',
248
251
  'agent_function_request_not_started',
252
+ 'post_not_confirmed',
249
253
  ],
250
254
  },
251
255
  action: { title: 'Action', type: 'integer', minimum: 0 },
252
256
  moment: { title: 'Moment', type: 'string', format: 'date-time' },
253
257
  error: { title: 'Error', type: 'string' },
258
+ document_path: { title: 'Document path', type: 'string' },
254
259
  agent_function: {
255
260
  title: 'Agent function',
256
261
  type: 'object',
@@ -267,6 +272,12 @@ export const HOUSE_MODEL_DECLARATION = {
267
272
  },
268
273
  ended: { title: 'Ended', type: 'string', enum: ['finished', 'failed'] },
269
274
  duration: { title: 'Duration', type: 'integer', minimum: 1 },
275
+ meter: { title: 'Meter', type: 'string', enum: ['indexed_text', 'blob'] },
276
+ average_bytes: { title: 'Average in bytes', type: 'integer', minimum: 0 },
277
+ included_bytes: { title: 'Included in bytes', type: 'integer', minimum: 1 },
278
+ block_bytes: { title: 'Block in bytes', type: 'integer', minimum: 1 },
279
+ block_usd: { title: 'Block price in USD', type: 'number', exclusiveMinimum: 0 },
280
+ amount_usd: { title: 'Amount in USD', type: 'number', exclusiveMinimum: 0 },
270
281
  },
271
282
  required: ['notification', 'kind', 'created', 'way_in', 'subject'],
272
283
  },
@@ -275,7 +286,7 @@ export const HOUSE_MODEL_DECLARATION = {
275
286
  properties: {},
276
287
  },
277
288
  'house-agent-function': {
278
- description: "One Agent function that serves this Room, which House alone writes from its owner's document in their Private Room: the `agent_function` by identifier, its `description`, the `input` a caller sends, empty when it takes nothing, and the `agent` it starts, by `agent` and the `name` that Agent had when this card was last written. The Agent function's instruction is never written here.",
289
+ description: "One Agent function that serves this Room, which House alone writes from its owner's document in their Private Room and their Standing answer for it: the `agent_function` by identifier, its `description`, the `input` a caller sends, empty when it takes nothing, the `agent` it starts, by `agent` and the `name` that Agent had when this card was last written, and its `answer`, how a request from anyone but its owner starts: `at_once`, `ask_me`, which waits for its owner's approval, or `off`, which refuses it. The Agent function's instruction is never written here.",
279
290
  properties: {
280
291
  reflected: { title: 'Reflected', type: 'string', format: 'date-time' },
281
292
  agent_function: { title: 'Agent function', $ref: '#/$defs/id' },
@@ -291,8 +302,9 @@ export const HOUSE_MODEL_DECLARATION = {
291
302
  },
292
303
  required: ['agent', 'name'],
293
304
  },
305
+ answer: { title: 'Answer', type: 'string', enum: ['at_once', 'ask_me', 'off'] },
294
306
  },
295
- required: ['reflected', 'agent_function', 'description', 'input', 'agent'],
307
+ required: ['reflected', 'agent_function', 'description', 'input', 'agent', 'answer'],
296
308
  },
297
309
  'house-agent-function-document': {
298
310
  description: 'One Agent function as its owner writes it in their Private Room at rooms/<room-handle>/agent-functions/<name>.md, a path that binds this type and a document that names no type: what it does as `description`, what a caller sends as `input`, empty when it takes nothing, the `agent` it starts, by identifier, and `afk`, true for a run nobody watches, off when absent. Its body is the instruction that Agent follows.',
@@ -305,7 +317,7 @@ export const HOUSE_MODEL_DECLARATION = {
305
317
  required: ['description', 'input', 'agent'],
306
318
  },
307
319
  'house-trigger': {
308
- 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`; an `agent_function` action sends its `payload` to the Agent function whose card under this Room's `house/agent-functions/` its `card` names, absent while this Room holds no card of that Agent function; a `message` action puts its `text` into the active conversation that Agent function started for what the Event is about, or starts that Agent function when none is active; a `done` action marks Done every active conversation an Agent function request of this Room started for the Event's document; a `function` action runs the `function` its `app`'s latest release declares, on House's servers, 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 and the owner's functions.",
320
+ 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 sends its `payload` to the Agent function whose card under this Room's `house/agent-functions/` its `card` names, absent while this Room holds no card of that Agent function; a `message` action puts its `text` into the active conversation that Agent function started for what the Event is about, or starts that Agent function when none is active; a `done` action marks Done every active conversation an Agent function request of this Room started for the Event's document; a `function` action runs the `function` its `app`'s latest release declares, on House's servers, 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 and the owner's functions.",
309
321
  properties: {
310
322
  reflected: { title: 'Reflected', type: 'string', format: 'date-time' },
311
323
  trigger: { title: 'Trigger', $ref: '#/$defs/id' },
@@ -349,6 +361,7 @@ export const HOUSE_MODEL_DECLARATION = {
349
361
  },
350
362
  required: ['users', 'fields', 'roles'],
351
363
  },
364
+ in_group: { title: 'In group', const: true },
352
365
  },
353
366
  required: ['kind', 'enabled', 'title', 'text', 'to'],
354
367
  },
package/dist/index.d.ts CHANGED
@@ -1,9 +1,13 @@
1
1
  export { candidateOf, datePointers, facts, memberPointers, members, pointed, prosePaths, TEXT_FIELD, valuedChange, WRITE_DOORS, } from './event.js';
2
2
  export type { Actor, DocumentEvent, DocumentFacts, Fact, ItemFacts, MessageFacts, Resolved, WriteDoor, } from './event.js';
3
- export { byCodePoint, compared, dated, fitsKind, instant, instantKey, kindOf, kindWords, } from './kinds.js';
3
+ export { byCodePoint, compared, dated, fitsKind, indexKey, instant, instantKey, kindOf, kindWords, } from './kinds.js';
4
4
  export type { Kind, Ordering } from './kinds.js';
5
5
  export { bodied, cursorOf, decodedCursor, identityOf, invalid, known, placeText, planOf, QueryError, queryKey, } from './query/language.js';
6
6
  export type { Clause, Continuation, Direction, DocumentQuery, DocumentShape, Filter, GroupKey, GroupOrder, GroupQuery, GroupSelect, GroupShape, HeldRooms, Key, KeyPlan, LocalQuery, OrderOptions, Place, Predicate, QueryErrorCode, QueryPlan, Related, RoomFacts, Scope, Select, Test, Value, Where, } from './query/language.js';
7
+ export { countOf, countShape, pageOrder, walkedValue, walkOf } from './query/walk.js';
8
+ export type { Count, KeyBound, KeyRange, PageOrder, Walk, WalkRun } from './query/walk.js';
9
+ export { verifyIndexBounds } from './indexed.js';
10
+ export type { IndexBounds } from './indexed.js';
7
11
  export { heldAt, matches } from './query/match.js';
8
12
  export type { Candidate } from './query/match.js';
9
13
  export { heldKind, indexed } from './query/rows.js';
@@ -12,32 +16,33 @@ export * as sql from './query/sql.js';
12
16
  export { headingLines } from './markdown.js';
13
17
  export type { HeadingLine } from './markdown.js';
14
18
  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';
19
+ export { shownDay, shownMoment } from './moment.js';
20
+ export type { MomentReader } from './moment.js';
15
21
  export { labelAt, NAME_FIELD } from './body.js';
16
22
  export type { Naming } from './body.js';
17
- export { divide } from './divide.js';
18
- export { apply, bodyLinks, create, links, parse, parseFrontmatter, relabel, relabels, relativize, relativizeBody, relinkBody, serialize, textSpans, unlinkBody, } from './document.js';
23
+ export { apply, bodyLinks, create, links, parse, partText, relabel, relabels, relativize, relativizeBody, relinkBody, serialize, textSpans, unlinkBody, } from './document.js';
19
24
  export { documentFacts, referenceTarget, referenceTargets } from './facts.js';
25
+ export { notReadyWaitMs } from './not-ready.js';
20
26
  export type { ReferenceTarget, SavedFacts } from './facts.js';
21
27
  export { CROCKFORD_ALPHABET, CROCKFORD_CHARACTER, CROCKFORD_LEADING_CHARACTER, } from './house-references/crockford.js';
22
- export { HOUSE_FIELDS, MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
28
+ export { HOUSE_FIELDS, MEMBER_FIELD, SITE_FIELD, SUBMITTED_FIELD, TYPE_FIELD } from './fields.js';
23
29
  export { HOUSE_MODEL, HOUSE_ROOM_TYPES } from './built-in.js';
24
30
  export { APP_PREFERENCES_HOME, HOUSE_MODEL_DECLARATION, HOUSE_TYPED_PATHS } from './house-model.js';
25
31
  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';
26
32
  export type { HouseDocumentFields, HouseModelType } from './house-model.js';
27
33
  export { CHAT_MESSAGE_TYPE, CHAT_TYPE, INBOX_CHANNEL_KINDS, INBOX_TYPES } from './room-types.js';
28
34
  export type { InboxChannelKind } from './room-types.js';
29
- export { linkedPath, relative, retarget, roomPath, roomTarget, target } from './paths.js';
35
+ export { keyedDestination, keyedLink, linkedPath, relative, retarget, roomPath, roomTarget, target, } from './paths.js';
30
36
  export { openPatternBudget } from './pattern.js';
31
37
  export type { LinkedPath, RoomTarget } from './paths.js';
32
- export { project } from './project.js';
33
38
  export { references } from './references.js';
34
39
  export { CAPTURE_HOME, isDocumentPath, isReservedName, RESERVED_NAMES, ROOM_DESCRIPTION, } from './reserved.js';
35
40
  export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, JSON_POINTER, memberFacts, pointerFacts, pointerSegments, untitled, } from './definition.js';
36
41
  export type { Definition, FieldRules, JsonType, PatternFacts, PointerFacts, RuleValue, Shape, Transition, ValueFacts, } from './definition.js';
37
- export type { ApplyResult, BodyResult, Change, DefinitionOf, Division, DivisionContext, Document, DocumentCheck, Extent, Frontmatter, FrontmatterResult, Library, ModelVerification, Link, ParseResult, Projection, ProjectionContext, Reached, Reference, Refusal, RoomReference, Span, TypedPath, UnlinkedBody, Validation, ValidationContext, ValidationStep, VerifiedModel, } from './types.js';
38
- export { assess, assessReferences, bodyRoomLinks, checkDocument, definitionAt, readTypes, resolves, roomReferences, validate, validateParsed, validating, verdicts, verify, } from './validate.js';
42
+ export type { ApplyResult, BodyResult, Change, DefinitionOf, Document, DocumentCheck, Extent, Library, ModelVerification, Link, ParseResult, Reached, Reference, Refusal, RoomReference, Span, TypedPath, UnlinkedBody, Validation, ValidationContext, ValidationStep, VerifiedModel, } from './types.js';
43
+ export { assess, assessReferences, bodyKeyedLinks, bodyRoomLinks, checkDocument, definitionAt, readTypes, resolves, roomReferences, validate, validateParsed, validating, verdicts, verify, } from './validate.js';
39
44
  export type { Assessment, Verdicts } from './validate.js';
40
45
  export { VERSION } from './version.js';
41
- export { bodyAfterFrontmatter, equalValue, frontmatterValue, plain } from './yaml.js';
42
- export type { FrontmatterValue } from './yaml.js';
46
+ export { bodyAfterFrontmatter, documentValue, equalValue, plain } from './yaml.js';
47
+ export type { DocumentValue } from './yaml.js';
43
48
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,YAAY,EACZ,KAAK,EACL,cAAc,EACd,OAAO,EACP,OAAO,EACP,UAAU,EACV,UAAU,EACV,YAAY,EACZ,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,KAAK,EACL,aAAa,EACb,a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Aa,EACb,aAAa,EACb,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,cAAc,EACd,QAAQ,EACR,cAAc,EACd,UAAU,EACV,QAAQ,EACR,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACtF,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,YAAY,EACZ,KAAK,EACL,cAAc,EACd,OAAO,EACP,OAAO,EACP,UAAU,EACV,UAAU,EACV,YAAY,EACZ,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,KAAK,EACL,aAAa,EACb,aAAa,EACb,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,SAAS,GACV,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,WAAW,EACX,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,UAAU,EACV,MAAM,EACN,SAAS,GACV,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EACL,MAAM,EACN,QAAQ,EACR,aAAa,EACb,UAAU,EACV,OAAO,EACP,KAAK,EACL,SAAS,EACT,MAAM,EACN,UAAU,EACV,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,MAAM,EACN,YAAY,EACZ,SAAS,EACT,aAAa,EACb,aAAa,EACb,MAAM,EACN,QAAQ,EACR,UAAU,EACV,UAAU,EACV,WAAW,EACX,UAAU,EACV,SAAS,EACT,GAAG,E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AACvC,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACnF,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"}
package/dist/index.js CHANGED
@@ -1,27 +1,29 @@
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 { countOf, countShape, pageOrder, walkedValue, walkOf } from './query/walk.js';
5
+ export { verifyIndexBounds } from './indexed.js';
4
6
  export { heldAt, matches } from './query/match.js';
5
7
  export { heldKind, indexed } from './query/rows.js';
6
8
  export * as sql from './query/sql.js';
7
9
  export { headingLines } from './markdown.js';
8
10
  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';
11
+ export { shownDay, shownMoment } from './moment.js';
9
12
  export { labelAt, NAME_FIELD } from './body.js';
10
- export { divide } from './divide.js';
11
- export { apply, bodyLinks, create, links, parse, parseFrontmatter, relabel, relabels, relativize, relativizeBody, relinkBody, serialize, textSpans, unlinkBody, } from './document.js';
13
+ export { apply, bodyLinks, create, links, parse, partText, relabel, relabels, relativize, relativizeBody, relinkBody, serialize, textSpans, unlinkBody, } from './document.js';
12
14
  export { documentFacts, referenceTarget, referenceTargets } from './facts.js';
15
+ export { notReadyWaitMs } from './not-ready.js';
13
16
  export { CROCKFORD_ALPHABET, CROCKFORD_CHARACTER, CROCKFORD_LEADING_CHARACTER, } from './house-references/crockford.js';
14
- export { HOUSE_FIELDS, MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
17
+ export { HOUSE_FIELDS, MEMBER_FIELD, SITE_FIELD, SUBMITTED_FIELD, TYPE_FIELD } from './fields.js';
15
18
  export { HOUSE_MODEL, HOUSE_ROOM_TYPES } from './built-in.js';
16
19
  export { APP_PREFERENCES_HOME, HOUSE_MODEL_DECLARATION, HOUSE_TYPED_PATHS } from './house-model.js';
17
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';
18
21
  export { CHAT_MESSAGE_TYPE, CHAT_TYPE, INBOX_CHANNEL_KINDS, INBOX_TYPES } from './room-types.js';
19
- export { linkedPath, relative, retarget, roomPath, roomTarget, target } from './paths.js';
22
+ export { keyedDestination, keyedLink, linkedPath, relative, retarget, roomPath, roomTarget, target, } from './paths.js';
20
23
  export { openPatternBudget } from './pattern.js';
21
- export { project } from './project.js';
22
24
  export { references } from './references.js';
23
25
  export { CAPTURE_HOME, isDocumentPath, isReservedName, RESERVED_NAMES, ROOM_DESCRIPTION, } from './reserved.js';
24
26
  export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, JSON_POINTER, memberFacts, pointerFacts, pointerSegments, untitled, } from './definition.js';
25
- export { assess, assessReferences, bodyRoomLinks, checkDocument, definitionAt, readTypes, resolves, roomReferences, validate, validateParsed, validating, verdicts, verify, } from './validate.js';
27
+ export { assess, assessReferences, bodyKeyedLinks, bodyRoomLinks, checkDocument, definitionAt, readTypes, resolves, roomReferences, validate, validateParsed, validating, verdicts, verify, } from './validate.js';
26
28
  export { VERSION } from './version.js';
27
- export { bodyAfterFrontmatter, equalValue, frontmatterValue, plain } from './yaml.js';
29
+ 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,9 @@ 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;
18
+ export declare function sortedKey(value: unknown): Uint8Array | null;
16
19
  export declare function byCodePoint(left: string, right: string): number;
17
20
  export declare function compared(left: unknown, right: unknown, ordering: Ordering): number;
18
21
  //# 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,SAAS,GACT,SAAS,GACT,MAAM,GACN,WAAW,GACX,MAAM,GACN,MAAM,GACN,WAAW,CAAC;AAEhB,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,SAAS,EAAE,KAAK,GAAG,MAAM,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACjC,QAAQ,CAAC,UAAU,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC1C,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;CAC1D,CAAC;AASF,wBAAgB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,GAAG,IAAI,CAWrD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAW/E;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,SAAS,MAAM,EAAE,CAe1E;AAED,wBAAgB,KA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AE,UAAU,GAAG,SAAS,GAAG,SAAS,MAAM,EAAE,CAe1E;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAErD;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAqB1D;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAGxD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAEtF;AAgCD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,UAAU,CAUtE;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAU3D;AAaD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,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,62 @@ 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
+ }
138
+ export function sortedKey(value) {
139
+ if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
140
+ const { instant, ...rest } = value;
141
+ return typeof instant === 'string' && Object.keys(rest).length === 0
142
+ ? Uint8Array.of(INSTANT_KEYS, ...utf8(instant))
143
+ : null;
144
+ }
145
+ return value === null || ['boolean', 'number', 'string'].includes(typeof value)
146
+ ? indexKey({ prose: false }, value)
147
+ : null;
148
+ }
89
149
  function rank(value) {
90
150
  if (typeof value === 'boolean' || typeof value === 'number')
91
151
  return 1;
@@ -1,4 +1,3 @@
1
- import type { Extent } from './types.js';
2
1
  export type HeadingLine = {
3
2
  readonly level: number;
4
3
  readonly name: string;
@@ -44,7 +43,6 @@ export type Node = {
44
43
  };
45
44
  export type Reading = {
46
45
  readonly headings: readonly HeadingLine[];
47
- readonly blocks: readonly Extent[];
48
46
  readonly uses: readonly LinkUse[];
49
47
  readonly definitions: readonly DefinitionBlock[];
50
48
  readonly tree: readonly Node[];
@@ -70,6 +68,4 @@ export type SectionSpan = {
70
68
  };
71
69
  export declare function sectionSpans(reading: Reading, end: number): SectionSpan[];
72
70
  export declare function sectionsRecord(spans: readonly SectionSpan[], content: string): Record<string, string>;
73
- export declare function headingsIn(reading: Reading, from: number, to: number): readonly HeadingLine[];
74
- export declare function blockRanges(reading: Reading, from: number, to: number): Extent[];
75
71
  //# sourceMappingURL=markdown.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB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tB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,WAAW,EAAE,CAczE;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,OAAO,EAAE,MAAM,GACd,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOxB"}
package/dist/markdown.js CHANGED
@@ -129,7 +129,6 @@ export function read(text, at = 0) {
129
129
  });
130
130
  const local = (offset) => offset + shift;
131
131
  const headings = [];
132
- const blocks = [];
133
132
  for (const node of root.children ?? []) {
134
133
  let start = local(startOf(node));
135
134
  while (start > 0 && (text[start - 1] === ' ' || text[start - 1] === '\t'))
@@ -146,7 +145,6 @@ export function read(text, at = 0) {
146
145
  next: at + line.next,
147
146
  });
148
147
  }
149
- blocks.push({ start: at + start, end: at + end });
150
148
  }
151
149
  const destinations = new Map();
152
150
  const definitions = [];
@@ -191,7 +189,7 @@ export function read(text, at = 0) {
191
189
  });
192
190
  }
193
191
  uses.sort((left, right) => left.start - right.start);
194
- return { headings, blocks, uses, definitions, tree: root.children ?? [], base: at + shift };
192
+ return { headings, uses, definitions, tree: root.children ?? [], base: at + shift };
195
193
  }
196
194
  export function destinations(reading) {
197
195
  const byStart = new Map();
@@ -232,34 +230,3 @@ export function sectionsRecord(spans, content) {
232
230
  }
233
231
  return record;
234
232
  }
235
- function firstPast(items, at, key) {
236
- let low = 0;
237
- let high = items.length;
238
- while (low < high) {
239
- const middle = (low + high) >>> 1;
240
- if (key(items[middle]) <= at)
241
- low = middle + 1;
242
- else
243
- high = middle;
244
- }
245
- return low;
246
- }
247
- function blocksIn(reading, from, to) {
248
- const blocks = reading.blocks;
249
- const first = firstPast(blocks, from, (block) => block.end);
250
- let end = first;
251
- while (end < blocks.length && blocks[end].start < to)
252
- end += 1;
253
- return blocks.slice(first, end);
254
- }
255
- export function headingsIn(reading, from, to) {
256
- const start = (heading) => heading.start;
257
- return reading.headings.slice(firstPast(reading.headings, from - 1, start), firstPast(reading.headings, to - 1, start));
258
- }
259
- export function blockRanges(reading, from, to) {
260
- const starts = blocksIn(reading, from, to).map((block) => block.start);
261
- return starts.map((start, index) => ({
262
- start: index === 0 ? from : start,
263
- end: starts[index + 1] ?? to,
264
- }));
265
- }
@@ -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
+ }
@@ -0,0 +1,2 @@
1
+ export declare function notReadyWaitMs(asked: number): number;
2
+ //# sourceMappingURL=not-ready.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"not-ready.d.ts","sourceRoot":"","sources":["../src/not-ready.ts"],"names":[],"mappings":"AAGA,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpD"}
@@ -0,0 +1,5 @@
1
+ // A Room answered not ready is asked again after these waits, the last repeating, so a chunk build that catches up within seconds installs at once and a long one is asked every 15 seconds.
2
+ const NOT_READY_WAITS_MS = [1_000, 2_000, 3_000, 5_000, 8_000, 11_000, 15_000];
3
+ export function notReadyWaitMs(asked) {
4
+ return NOT_READY_WAITS_MS[Math.min(asked, NOT_READY_WAITS_MS.length - 1)];
5
+ }
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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M,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGhE;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,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,4 +1,4 @@
1
- import { type Definition } from '../definition.js';
1
+ import { type Definition, type ValueFacts } from '../definition.js';
2
2
  export type Value = string | number | boolean | null;
3
3
  export type Predicate = Value | {
4
4
  $eq: Value;
@@ -245,6 +245,7 @@ export declare function bodied(shape: DocumentShape): boolean;
245
245
  export declare function invalid(at: At, problem: string, accepts?: readonly string[]): never;
246
246
  export declare function placeText(at: Place): string;
247
247
  export declare function known(value: Entries, allowed: readonly string[], at: At): void;
248
+ export declare function textless(facts: ValueFacts): boolean;
248
249
  export declare function planOf(input: unknown, facts: HeldRooms): QueryPlan;
249
250
  export declare function cursorOf(values: readonly unknown[]): string;
250
251
  export declare function decodedCursor(text: string): readonly unknown[] | null;