@agentshouse/mdruntime 0.1.0-cc5745cd9af96 → 0.1.0-ccbe92df1c4f6

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 (188) hide show
  1. package/AGENTS.md +96 -78
  2. package/README.md +9 -8
  3. package/dist/adapter.d.ts +40 -32
  4. package/dist/adapter.d.ts.map +1 -1
  5. package/dist/attached-model.d.ts +4 -1
  6. package/dist/attached-model.d.ts.map +1 -1
  7. package/dist/attached-model.js +13 -3
  8. package/dist/binary.d.ts +0 -5
  9. package/dist/binary.d.ts.map +1 -1
  10. package/dist/binary.js +1 -1
  11. package/dist/bootstrap.d.ts +24 -6
  12. package/dist/bootstrap.d.ts.map +1 -1
  13. package/dist/bootstrap.js +148 -82
  14. package/dist/chain.d.ts +11 -0
  15. package/dist/chain.d.ts.map +1 -0
  16. package/dist/chain.js +64 -0
  17. package/dist/change-set.d.ts +6 -16
  18. package/dist/change-set.d.ts.map +1 -1
  19. package/dist/change-set.js +11 -94
  20. package/dist/change.d.ts +31 -1
  21. package/dist/change.d.ts.map +1 -1
  22. package/dist/change.js +10 -1
  23. package/dist/chat/house.d.ts +25 -0
  24. package/dist/chat/house.d.ts.map +1 -0
  25. package/dist/chat/house.js +38 -0
  26. package/dist/chat/input.d.ts +3 -1
  27. package/dist/chat/input.d.ts.map +1 -1
  28. package/dist/chat/input.js +11 -18
  29. package/dist/chat/list.d.ts.map +1 -1
  30. package/dist/chat/list.js +1 -1
  31. package/dist/chat/markdown.d.ts +1 -2
  32. package/dist/chat/markdown.d.ts.map +1 -1
  33. package/dist/chat/markdown.js +2 -19
  34. package/dist/chat/message.d.ts.map +1 -1
  35. package/dist/chat/message.js +63 -11
  36. package/dist/chat/messages.d.ts +12 -1
  37. package/dist/chat/messages.d.ts.map +1 -1
  38. package/dist/chat/messages.js +36 -13
  39. package/dist/chat/name.d.ts +1 -0
  40. package/dist/chat/name.d.ts.map +1 -1
  41. package/dist/chat/name.js +1 -1
  42. package/dist/chat/opened.d.ts +1 -0
  43. package/dist/chat/opened.d.ts.map +1 -1
  44. package/dist/chat/opened.js +2 -0
  45. package/dist/chat/overlay.d.ts.map +1 -1
  46. package/dist/chat/overlay.js +1 -5
  47. package/dist/chat/parts.d.ts +1 -0
  48. package/dist/chat/parts.d.ts.map +1 -1
  49. package/dist/chat/parts.js +3 -2
  50. package/dist/chat/provider.d.ts +7 -1
  51. package/dist/chat/provider.d.ts.map +1 -1
  52. package/dist/chat/provider.js +75 -78
  53. package/dist/chat/ready.d.ts +4 -1
  54. package/dist/chat/ready.d.ts.map +1 -1
  55. package/dist/chat/ready.js +7 -5
  56. package/dist/chat/room-file.d.ts +8 -0
  57. package/dist/chat/room-file.d.ts.map +1 -0
  58. package/dist/chat/room-file.js +72 -0
  59. package/dist/chat/style.d.ts.map +1 -1
  60. package/dist/chat/style.js +5 -0
  61. package/dist/chat.d.ts +1 -0
  62. package/dist/chat.d.ts.map +1 -1
  63. package/dist/client.d.ts +6 -3
  64. package/dist/client.d.ts.map +1 -1
  65. package/dist/client.js +28 -2
  66. package/dist/collection.d.ts +6 -20
  67. package/dist/collection.d.ts.map +1 -1
  68. package/dist/collection.js +30 -352
  69. package/dist/compile.d.ts +16 -0
  70. package/dist/compile.d.ts.map +1 -0
  71. package/dist/compile.js +721 -0
  72. package/dist/connection.d.ts +13 -8
  73. package/dist/connection.d.ts.map +1 -1
  74. package/dist/connection.js +2179 -817
  75. package/dist/conversation.d.ts +5 -3
  76. package/dist/conversation.d.ts.map +1 -1
  77. package/dist/conversation.js +84 -65
  78. package/dist/digest.d.ts +7 -0
  79. package/dist/digest.d.ts.map +1 -0
  80. package/dist/digest.js +113 -0
  81. package/dist/durability.d.ts +3 -5
  82. package/dist/durability.d.ts.map +1 -1
  83. package/dist/durability.js +5 -0
  84. package/dist/entry.d.ts +3 -1
  85. package/dist/entry.d.ts.map +1 -1
  86. package/dist/entry.js +18 -24
  87. package/dist/file.d.ts +2 -10
  88. package/dist/file.d.ts.map +1 -1
  89. package/dist/file.js +3 -120
  90. package/dist/fulltext.d.ts +27 -0
  91. package/dist/fulltext.d.ts.map +1 -0
  92. package/dist/fulltext.js +368 -0
  93. package/dist/host.d.ts +4 -4
  94. package/dist/host.d.ts.map +1 -1
  95. package/dist/host.js +16 -8
  96. package/dist/identity.d.ts +0 -1
  97. package/dist/identity.d.ts.map +1 -1
  98. package/dist/identity.js +0 -3
  99. package/dist/index.d.ts +12 -9
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +4 -1
  102. package/dist/live.d.ts +22 -0
  103. package/dist/live.d.ts.map +1 -0
  104. package/dist/live.js +123 -0
  105. package/dist/memory.d.ts +1 -0
  106. package/dist/memory.d.ts.map +1 -1
  107. package/dist/memory.js +20 -15
  108. package/dist/messages.d.ts +28 -0
  109. package/dist/messages.d.ts.map +1 -0
  110. package/dist/messages.js +90 -0
  111. package/dist/name.d.ts +4 -0
  112. package/dist/name.d.ts.map +1 -0
  113. package/dist/name.js +122 -0
  114. package/dist/observation.d.ts +12 -0
  115. package/dist/observation.d.ts.map +1 -1
  116. package/dist/observation.js +84 -0
  117. package/dist/opened.d.ts +22 -0
  118. package/dist/opened.d.ts.map +1 -0
  119. package/dist/opened.js +107 -0
  120. package/dist/outcome.d.ts +28 -4
  121. package/dist/outcome.d.ts.map +1 -1
  122. package/dist/outcome.js +22 -0
  123. package/dist/overlay.d.ts +1 -4
  124. package/dist/overlay.d.ts.map +1 -1
  125. package/dist/overlay.js +22 -148
  126. package/dist/query.d.ts +5 -1
  127. package/dist/query.d.ts.map +1 -1
  128. package/dist/query.js +13 -1
  129. package/dist/reach.d.ts +5 -3
  130. package/dist/reach.d.ts.map +1 -1
  131. package/dist/reach.js +149 -61
  132. package/dist/readiness.d.ts +19 -9
  133. package/dist/readiness.d.ts.map +1 -1
  134. package/dist/readiness.js +2 -2
  135. package/dist/reads.d.ts.map +1 -1
  136. package/dist/reads.js +4 -2
  137. package/dist/recovery.d.ts +2 -2
  138. package/dist/recovery.d.ts.map +1 -1
  139. package/dist/recovery.js +8 -7
  140. package/dist/refresh.d.ts +15 -14
  141. package/dist/refresh.d.ts.map +1 -1
  142. package/dist/refresh.js +112 -70
  143. package/dist/replica.d.ts +57 -39
  144. package/dist/replica.d.ts.map +1 -1
  145. package/dist/replica.js +275 -195
  146. package/dist/room-draft.d.ts +3 -1
  147. package/dist/room-draft.d.ts.map +1 -1
  148. package/dist/room-draft.js +21 -13
  149. package/dist/rows.d.ts +29 -31
  150. package/dist/rows.d.ts.map +1 -1
  151. package/dist/rows.js +113 -69
  152. package/dist/save.d.ts +49 -14
  153. package/dist/save.d.ts.map +1 -1
  154. package/dist/save.js +352 -98
  155. package/dist/search.d.ts +11 -43
  156. package/dist/search.d.ts.map +1 -1
  157. package/dist/search.js +0 -213
  158. package/dist/shared.d.ts +4 -3
  159. package/dist/shared.d.ts.map +1 -1
  160. package/dist/shared.js +67 -34
  161. package/dist/store.d.ts +87 -94
  162. package/dist/store.d.ts.map +1 -1
  163. package/dist/store.js +314 -720
  164. package/dist/stored.d.ts +145 -0
  165. package/dist/stored.d.ts.map +1 -0
  166. package/dist/stored.js +567 -0
  167. package/dist/tables.d.ts +344 -0
  168. package/dist/tables.d.ts.map +1 -0
  169. package/dist/tables.js +580 -0
  170. package/dist/turn.d.ts +1 -1
  171. package/dist/turn.d.ts.map +1 -1
  172. package/dist/turn.js +31 -20
  173. package/dist/validation.d.ts +30 -0
  174. package/dist/validation.d.ts.map +1 -0
  175. package/dist/validation.js +162 -0
  176. package/dist/windows.d.ts +2 -6
  177. package/dist/windows.d.ts.map +1 -1
  178. package/dist/windows.js +30 -34
  179. package/dist/wire.d.ts +13 -1
  180. package/dist/wire.d.ts.map +1 -1
  181. package/dist/wire.js +4 -1
  182. package/dist/words.d.ts +19 -0
  183. package/dist/words.d.ts.map +1 -0
  184. package/dist/words.js +150 -0
  185. package/package.json +11 -5
  186. package/dist/read-side.d.ts +0 -27
  187. package/dist/read-side.d.ts.map +0 -1
  188. package/dist/read-side.js +0 -826
@@ -1,11 +1,9 @@
1
- import { checkDocument, parseFrontmatter, references, sectionReferences, target, parse, resolves, validating, VERSION, } from '@agentshouse/mdmodel';
1
+ import { parse, VERSION } from '@agentshouse/mdmodel';
2
2
  import { beneath, normalize } from './paths.js';
3
- import { sameTyping } from './model.js';
4
- import { differences, patched, patching, shared, sizeOf } from './shared.js';
5
- import { after, finished, inUnits, ROW_WEIGHT } from './turn.js';
3
+ import { keysIn, sortedKeys } from './shared.js';
4
+ import { ROW_WEIGHT } from './turn.js';
6
5
  export const MD_MODEL = { identity: '@agentshouse/mdmodel', version: VERSION };
7
- const NO_TYPES = { types: {} };
8
- function selected(composition, path) {
6
+ export function selected(composition, path) {
9
7
  return (composition.selection !== null &&
10
8
  composition.selection.roots.some((root) => beneath(root, path)));
11
9
  }
@@ -14,372 +12,52 @@ export function governing(composition, path) {
14
12
  ? composition.selection.model
15
13
  : composition.model;
16
14
  }
17
- const parsedIn = new WeakMap();
18
- function* carried(previous, text) {
19
- const held = parsedIn.get(previous);
20
- if (held === undefined)
21
- return shared({});
22
- const kept = yield* patching(held.base, held.added);
23
- held.base = kept;
24
- held.added = new Map();
25
- return yield* patching(kept, [], yield* differences(previous.text, text));
26
- }
27
- function cachedIn(collection, path) {
28
- const held = parsedIn.get(collection);
29
- if (held === undefined)
30
- return undefined;
31
- if (held.added.has(path))
32
- return held.added.get(path);
33
- return Object.hasOwn(held.base, path) ? held.base[path] : undefined;
34
- }
35
- export function collectionOf(text, composition, previous) {
36
- return finished(collecting(text, composition, previous));
37
- }
38
- export function* collecting(text, composition, previous) {
39
- const parsed = {
40
- base: previous === undefined ? shared({}) : yield* carried(previous, text),
41
- added: new Map(),
42
- };
43
- const collection = {
15
+ export function collectionOf(text, composition) {
16
+ const parsed = new Map();
17
+ return {
44
18
  text,
45
19
  composition,
46
20
  document(path) {
47
- const held = cachedIn(collection, path);
48
- if (held !== undefined)
49
- return held ?? undefined;
21
+ if (parsed.has(path))
22
+ return parsed.get(path) ?? undefined;
50
23
  const content = text[path];
51
24
  if (content === undefined)
52
25
  return undefined;
53
26
  const read = parse(content, path);
54
- parsed.added.set(path, read.ok ? read.document : null);
27
+ parsed.set(path, read.ok ? read.document : null);
55
28
  return read.ok ? read.document : undefined;
56
29
  },
57
30
  };
58
- parsedIn.set(collection, parsed);
59
- return collection;
60
- }
61
- export function passingFrontmatter(collection, path) {
62
- const held = cachedIn(collection, path);
63
- if (held !== undefined)
64
- return held ?? undefined;
65
- const content = collection.text[path];
66
- if (content === undefined)
67
- return undefined;
68
- const read = parseFrontmatter(content, path);
69
- return read.ok ? read.frontmatter : undefined;
70
31
  }
71
32
  export function* documentsOf(collection) {
72
- for (const path of Object.keys(collection.text).sort()) {
73
- const held = cachedIn(collection, path);
74
- if (held === null)
75
- continue;
76
- if (held !== undefined) {
77
- yield [path, held];
33
+ const paths = yield* sortedKeys(collection.text);
34
+ return (function* () {
35
+ for (const path of paths) {
36
+ const document = collection.document(path);
37
+ if (document !== undefined)
38
+ yield [path, document];
39
+ }
40
+ })();
41
+ }
42
+ export function* unreadable(text, paths = null) {
43
+ const named = paths ?? (yield* keysIn(text));
44
+ let least = null;
45
+ for (const path of named) {
46
+ const content = Object.hasOwn(text, path) ? text[path] : undefined;
47
+ if (content === undefined)
78
48
  continue;
49
+ const read = parse(content, path);
50
+ if (!read.ok && (least === null || path < least.path)) {
51
+ least = { path, refused: { kind: 'refused', refusal: read.refusal } };
79
52
  }
80
- const read = parse(collection.text[path], path);
81
- if (read.ok)
82
- yield [path, read.document];
53
+ yield ROW_WEIGHT + content.length;
83
54
  }
84
- }
85
- export function* unreadable(text, previous) {
86
- const paths = previous === undefined
87
- ? Object.keys(text)
88
- : [...(yield* differences(previous, text))].filter((path) => text[path] !== undefined);
89
- for (const path of paths.sort()) {
90
- const read = parse(text[path], path);
91
- if (!read.ok)
92
- return { kind: 'refused', refusal: read.refusal };
93
- yield ROW_WEIGHT + text[path].length;
94
- }
95
- return null;
55
+ return least?.refused ?? null;
96
56
  }
97
57
  export function validRoot(root) {
98
58
  return typeof root === 'string' && normalize(root) === root;
99
59
  }
100
- function* validateAgainst(documents, binaryTargets, model) {
101
- if (model.status === 'unavailable') {
102
- for (const path of Object.keys(documents)) {
103
- const content = documents[path];
104
- const parsed = parse(content);
105
- if (parsed.ok && parsed.document.type !== undefined && parsed.document.type !== 'any')
106
- return { verdict: 'refuse', rule: 'model-unavailable', file: path };
107
- yield ROW_WEIGHT + content.length;
108
- }
109
- }
110
- const steps = validating(documents, { binaryTargets }, model.status === 'unavailable' ? NO_TYPES : { types: model.types });
111
- for (let step = steps.next();; step = steps.next()) {
112
- if (step.done === true)
113
- return step.value;
114
- yield ROW_WEIGHT + documents[step.value].length;
115
- }
116
- }
117
- export function* validateCollection(text, binaryTargets, composition) {
118
- const collection = {};
119
- const selection = {};
120
- for (const path of Object.keys(text)) {
121
- if (selected(composition, path))
122
- selection[path] = text[path];
123
- else
124
- collection[path] = text[path];
125
- yield ROW_WEIGHT;
126
- }
127
- const verdicts = [
128
- yield* validateAgainst(collection, binaryTargets.filter((path) => !selected(composition, path)), composition.model),
129
- ];
130
- if (composition.selection !== null) {
131
- verdicts.push(yield* validateAgainst(selection, binaryTargets.filter((path) => selected(composition, path)), composition.selection.model));
132
- }
133
- const refusals = verdicts.filter((verdict) => verdict.verdict === 'refuse');
134
- if (refusals.length === 0)
135
- return verdicts[0];
136
- return refusals.find((refusal) => refusal.rule !== 'model-unavailable') ?? refusals[0];
137
- }
138
- const NO_REFERRERS = shared({});
139
- const referrersOf = new WeakMap();
140
- function typing(left, right) {
141
- return (sameTyping(left.model, right.model) &&
142
- (left.selection === null || right.selection === null
143
- ? left.selection === right.selection
144
- : sameTyping(left.selection.model, right.selection.model)) &&
145
- JSON.stringify(left.selection?.roots ?? null) === JSON.stringify(right.selection?.roots ?? null));
146
- }
147
- function declared(content) {
148
- if (content === undefined)
149
- return undefined;
150
- const read = parseFrontmatter(content);
151
- return read.ok ? (read.frontmatter.type ?? 'any') : undefined;
152
- }
153
- function typedIn(content) {
154
- const type = declared(content);
155
- return type !== undefined && type !== 'any';
156
- }
157
- function modelOf(composition, path) {
158
- const model = governing(composition, path);
159
- return model.status === 'unavailable' ? null : { types: model.types };
160
- }
161
- function checked(path, content, composition) {
162
- return checkDocument(path, content, modelOf(composition, path) ?? NO_TYPES);
163
- }
164
- function targetsOf(check) {
165
- if (!check.ok)
166
- return [];
167
- return [...new Set(check.references.flatMap(({ target }) => (target === null ? [] : [target])))];
168
- }
169
- function referencedBy(path, content, composition) {
170
- const model = modelOf(composition, path);
171
- if (model === null)
172
- return [];
173
- const read = parseFrontmatter(content, path);
174
- const type = read.ok ? read.frontmatter.type : undefined;
175
- if (!read.ok || type === undefined || !Object.hasOwn(model.types, type))
176
- return [];
177
- const definition = model.types[type];
178
- return [
179
- ...new Set([
180
- ...references(read.frontmatter, definition).flatMap(({ value }) => {
181
- const found = target(path, value);
182
- return found === null ? [] : [found];
183
- }),
184
- ...sectionReferences(path, content, definition).flatMap(({ target }) => target === null ? [] : [target]),
185
- ]),
186
- ];
187
- }
188
- function referrersOfTarget(index, target) {
189
- return Object.hasOwn(index.referrers, target) ? index.referrers[target] : NO_REFERRERS;
190
- }
191
- function* reindexed(index, changed) {
192
- const moved = new Map();
193
- const movesOf = (target) => {
194
- const held = moved.get(target) ?? { gained: [], lost: [] };
195
- moved.set(target, held);
196
- return held;
197
- };
198
- const targeting = [];
199
- const targetless = [];
200
- for (const [path, found] of changed) {
201
- const before = Object.hasOwn(index.targets, path) ? index.targets[path] : [];
202
- for (const target of before)
203
- if (!found.includes(target))
204
- movesOf(target).lost.push(path);
205
- for (const target of found) {
206
- if (!before.includes(target))
207
- movesOf(target).gained.push([path, true]);
208
- }
209
- if (found.length > 0)
210
- targeting.push([path, found]);
211
- else
212
- targetless.push(path);
213
- yield ROW_WEIGHT * (1 + before.length + found.length);
214
- }
215
- const referred = [];
216
- const unreferred = [];
217
- for (const [target, { gained, lost }] of moved) {
218
- const files = yield* patching(referrersOfTarget(index, target), gained, lost);
219
- if (sizeOf(files) > 0)
220
- referred.push([target, files]);
221
- else
222
- unreferred.push(target);
223
- }
224
- return {
225
- composition: index.composition,
226
- targets: yield* patching(index.targets, targeting, targetless),
227
- referrers: yield* patching(index.referrers, referred, unreferred),
228
- };
229
- }
230
- function storedIn(entries) {
231
- let stored = shared({});
232
- let unit = [];
233
- return after(inUnits(entries, (entry) => {
234
- unit.push(entry);
235
- return ROW_WEIGHT;
236
- }, () => {
237
- stored = patched(stored, unit);
238
- unit = [];
239
- }), () => stored);
240
- }
241
- function storedReferrers(referrers) {
242
- const sets = new Map();
243
- let unit = new Map();
244
- const pairs = function* () {
245
- for (const [target, files] of referrers)
246
- for (const file of files)
247
- yield [target, file];
248
- };
249
- return after(inUnits(pairs(), ([target, file]) => {
250
- const files = unit.get(target);
251
- if (files === undefined)
252
- unit.set(target, [file]);
253
- else
254
- files.push(file);
255
- return ROW_WEIGHT;
256
- }, () => {
257
- for (const [target, files] of unit) {
258
- sets.set(target, patched(sets.get(target) ?? NO_REFERRERS, files.map((file) => [file, true])));
259
- }
260
- unit = new Map();
261
- }), () => storedIn(sets));
262
- }
263
- function heldIndex(held, composition) {
264
- const index = referrersOf.get(held.text);
265
- return index !== undefined && typing(index.composition, composition) ? index : null;
266
- }
267
- const indexing = new WeakMap();
268
- export function indexReferrers(held, composition) {
269
- if (heldIndex(held, composition) !== null)
270
- return;
271
- const running = indexing.get(held.text);
272
- if (running !== undefined)
273
- return running;
274
- const targets = new Map();
275
- const referrers = new Map();
276
- const filled = inUnits(Object.keys(held.text), (path) => {
277
- const content = held.text[path];
278
- const found = referencedBy(path, content, composition);
279
- if (found.length > 0)
280
- targets.set(path, found);
281
- for (const target of found) {
282
- const files = referrers.get(target);
283
- if (files === undefined)
284
- referrers.set(target, [path]);
285
- else
286
- files.push(path);
287
- }
288
- return ROW_WEIGHT + content.length;
289
- });
290
- const indexed = after(filled, () => after(storedIn(targets), (storedTargets) => after(storedReferrers(referrers), (stored) => {
291
- referrersOf.set(held.text, { composition, targets: storedTargets, referrers: stored });
292
- })));
293
- if (!(indexed instanceof Promise))
294
- return;
295
- const building = indexed.finally(() => indexing.delete(held.text));
296
- indexing.set(held.text, building);
297
- return building;
298
- }
299
- export function referencesIndexed(held, composition) {
300
- return heldIndex(held, composition) !== null;
301
- }
302
- export function referring(held, composition, targets) {
303
- const index = heldIndex(held, composition);
304
- if (index === null)
305
- return null;
306
- const found = new Set();
307
- for (const target of targets) {
308
- for (const file of Object.keys(referrersOfTarget(index, target)))
309
- found.add(file);
310
- }
311
- return found;
312
- }
313
60
  export function available(composition) {
314
61
  return (composition.model.status !== 'unavailable' &&
315
62
  (composition.selection === null || composition.selection.model.status !== 'unavailable'));
316
63
  }
317
- export function* changedCleanly(next, previous, composition) {
318
- if (!typing(previous.composition, composition))
319
- return false;
320
- const paths = new Set([
321
- ...(yield* differences(previous.text, next.text)),
322
- ...(yield* differences(previous.binaries, next.binaries, () => true)),
323
- ]);
324
- const binary = (path) => Object.hasOwn(next.binaries, path);
325
- const within = (file) => (path) => selected(composition, path) === selected(composition, file);
326
- const reaching = (file, check) => {
327
- if (!check.ok)
328
- return false;
329
- const part = within(file);
330
- return check.references.every((reference) => resolves(reference, (path) => (part(path) ? declared(next.text[path]) : undefined), (path) => part(path) && binary(path)));
331
- };
332
- const changedTargets = new Map();
333
- const shifted = [];
334
- const admitted = (path) => {
335
- const now = next.text[path];
336
- const was = previous.text[path];
337
- const modeled = modelOf(composition, path) !== null;
338
- if ((now === undefined) !== (was === undefined) ||
339
- declared(now) !== declared(was) ||
340
- binary(path) !== Object.hasOwn(previous.binaries, path)) {
341
- shifted.push(path);
342
- }
343
- if (!modeled && typedIn(was) && !typedIn(now))
344
- return false;
345
- if (now === undefined) {
346
- if (modeled)
347
- changedTargets.set(path, []);
348
- return true;
349
- }
350
- if (binary(path))
351
- return false;
352
- if (!modeled) {
353
- if (declared(now) === undefined)
354
- return false;
355
- return typedIn(now) || checked(path, now, composition).ok;
356
- }
357
- const check = checked(path, now, composition);
358
- if (!reaching(path, check))
359
- return false;
360
- changedTargets.set(path, targetsOf(check));
361
- return true;
362
- };
363
- for (const path of paths) {
364
- if (!admitted(path))
365
- return false;
366
- yield ROW_WEIGHT + (next.text[path]?.length ?? 0);
367
- }
368
- const index = heldIndex(previous, composition);
369
- if (index === null && shifted.length > 0)
370
- return false;
371
- for (const target of shifted) {
372
- const files = index === null ? [] : Object.keys(referrersOfTarget(index, target));
373
- for (const file of files) {
374
- if (paths.has(file))
375
- continue;
376
- if (!reaching(file, checked(file, next.text[file], composition)))
377
- return false;
378
- yield ROW_WEIGHT + next.text[file].length;
379
- }
380
- }
381
- if (index !== null) {
382
- referrersOf.set(next.text, changedTargets.size === 0 ? index : yield* reindexed(index, changedTargets));
383
- }
384
- return true;
385
- }
@@ -0,0 +1,16 @@
1
+ import type { Plan, QueryRows } from './query.js';
2
+ import type { Connection, Value } from './tables.js';
3
+ export type QueryRoom = {
4
+ readonly locator: string;
5
+ readonly key: number;
6
+ };
7
+ export type Fragment = {
8
+ readonly sql: string;
9
+ readonly bind: readonly Value[];
10
+ };
11
+ export type QueryAnswer = QueryRows & {
12
+ readonly more?: string;
13
+ };
14
+ export declare function selected(connection: Connection, plan: Plan, rooms: readonly QueryRoom[]): Fragment;
15
+ export declare function answerQuery(connection: Connection, plan: Plan, rooms: readonly QueryRoom[], budget?: number | null): QueryAnswer;
16
+ //# sourceMappingURL=compile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAOV,IAAI,EAGJ,SAAS,EAIV,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,UAAU,EAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAU1D,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3E,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,KAAK,EAAE,CAAA;CAAE,CAAC;AA+pBjF,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AA8SjE,wBAAgB,QAAQ,CACtB,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,SAAS,SAAS,EAAE,GAC1B,QAAQ,CAEV;AAED,wBAAgB,WAAW,CACzB,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,MAAM,GAAE,MAAM,GAAG,IAAW,GAC3B,WAAW,CAUb"}