@agentshouse/mdruntime 0.1.0-c49444f2a8fc6 → 0.1.0-c4c5934c45f21
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/README.md +8 -8
- package/dist/acceptance.d.ts +3 -0
- package/dist/acceptance.d.ts.map +1 -0
- package/dist/acceptance.js +308 -0
- package/dist/act-lanes.d.ts +33 -0
- package/dist/act-lanes.d.ts.map +1 -0
- package/dist/act-lanes.js +177 -0
- package/dist/actions.d.ts +20 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +251 -0
- package/dist/adapter.d.ts +31 -44
- package/dist/adapter.d.ts.map +1 -1
- package/dist/bootstrap.d.ts +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +6 -18
- package/dist/cell.d.ts +6 -0
- package/dist/cell.d.ts.map +1 -0
- package/dist/cell.js +9 -0
- package/dist/change-set.d.ts +4 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +6 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +4 -2
- package/dist/chat-types.d.ts +5 -0
- package/dist/chat-types.d.ts.map +1 -0
- package/dist/chat-types.js +13 -0
- package/dist/client.d.ts +19 -13
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +30 -14
- package/dist/collection.d.ts +22 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +12 -2
- package/dist/compile.d.ts +5 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +200 -75
- package/dist/connection.d.ts +5 -143
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +104 -5308
- package/dist/conversation-live.d.ts +136 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +249 -0
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +7 -1
- package/dist/conversation.d.ts +43 -44
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +906 -1024
- package/dist/declaration.d.ts +10 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +24 -0
- package/dist/discovery.d.ts +10 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +148 -0
- package/dist/durability.d.ts +9 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/expectation.d.ts +4 -2
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +33 -11
- package/dist/failure.d.ts +1 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +3 -0
- package/dist/figures.d.ts +49 -0
- package/dist/figures.d.ts.map +1 -0
- package/dist/figures.js +197 -0
- package/dist/holdings.d.ts +29 -0
- package/dist/holdings.d.ts.map +1 -0
- package/dist/holdings.js +95 -0
- package/dist/host.d.ts +18 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +45 -12
- package/dist/index.d.ts +22 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -2
- package/dist/install.d.ts +54 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +538 -0
- package/dist/lifecycle.d.ts +7 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +272 -0
- package/dist/listing.d.ts +48 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +139 -0
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +3 -3
- package/dist/locks.d.ts +7 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +33 -0
- package/dist/log.d.ts +1 -0
- package/dist/log.d.ts.map +1 -1
- package/dist/lost.d.ts +5 -0
- package/dist/lost.d.ts.map +1 -0
- package/dist/lost.js +50 -0
- package/dist/media.d.ts +1 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +4 -4
- package/dist/memory.d.ts +4 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +38 -20
- package/dist/messages.d.ts +1 -4
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +14 -32
- package/dist/model.d.ts +0 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -5
- package/dist/models.d.ts +10 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +156 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +12 -17
- package/dist/opened.d.ts +1 -1
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +5 -5
- package/dist/opening.d.ts +4 -0
- package/dist/opening.d.ts.map +1 -0
- package/dist/opening.js +59 -0
- package/dist/outcome.d.ts +4 -1
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +3 -0
- package/dist/overlay.d.ts +2 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +32 -21
- package/dist/page-metadata.d.ts +8 -0
- package/dist/page-metadata.d.ts.map +1 -0
- package/dist/page-metadata.js +19 -0
- package/dist/parts.d.ts +3 -51
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +14 -111
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +22 -0
- package/dist/preparation.d.ts +20 -0
- package/dist/preparation.d.ts.map +1 -0
- package/dist/preparation.js +233 -0
- package/dist/presence.d.ts +52 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +220 -0
- package/dist/queries.d.ts +16 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +270 -0
- package/dist/query.d.ts +10 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +2 -0
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +5 -1
- package/dist/queue.d.ts +40 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +455 -0
- package/dist/reach.d.ts +3 -1
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +38 -8
- package/dist/react.d.ts +18 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +15 -1
- package/dist/readiness.d.ts +0 -1
- package/dist/readiness.d.ts.map +1 -1
- package/dist/reads.d.ts +37 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +174 -0
- package/dist/refresh.js +2 -2
- package/dist/refusal.d.ts +5 -0
- package/dist/refusal.d.ts.map +1 -0
- package/dist/refusal.js +57 -0
- package/dist/replica.d.ts +5 -13
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +15 -16
- package/dist/room-draft.d.ts +4 -6
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +36 -52
- package/dist/room-drafts.d.ts +24 -0
- package/dist/room-drafts.d.ts.map +1 -0
- package/dist/room-drafts.js +217 -0
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +3 -4
- package/dist/runtime.d.ts +34 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/save.d.ts +41 -86
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +232 -112
- package/dist/saves.d.ts +32 -0
- package/dist/saves.d.ts.map +1 -0
- package/dist/saves.js +413 -0
- package/dist/seed.d.ts +11 -2
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +71 -1
- package/dist/shared.d.ts +1 -6
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +13 -95
- package/dist/shown.d.ts +32 -0
- package/dist/shown.d.ts.map +1 -0
- package/dist/shown.js +290 -0
- package/dist/socket/admission.d.ts +7 -0
- package/dist/socket/admission.d.ts.map +1 -0
- package/dist/socket/admission.js +39 -0
- package/dist/socket/answers.d.ts +6 -0
- package/dist/socket/answers.d.ts.map +1 -0
- package/dist/socket/answers.js +20 -0
- package/dist/socket/lanes.d.ts +20 -0
- package/dist/socket/lanes.d.ts.map +1 -0
- package/dist/socket/lanes.js +77 -0
- package/dist/socket/reads.d.ts +10 -0
- package/dist/socket/reads.d.ts.map +1 -0
- package/dist/socket/reads.js +31 -0
- package/dist/socket/session.d.ts +38 -0
- package/dist/socket/session.d.ts.map +1 -0
- package/dist/socket/session.js +23 -0
- package/dist/socket.d.ts +67 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +170 -0
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +5 -4
- package/dist/store/installs.d.ts +30 -0
- package/dist/store/installs.d.ts.map +1 -0
- package/dist/store/installs.js +34 -0
- package/dist/store/readiness.d.ts +10 -0
- package/dist/store/readiness.d.ts.map +1 -0
- package/dist/store/readiness.js +52 -0
- package/dist/store/records.d.ts +212 -0
- package/dist/store/records.d.ts.map +1 -0
- package/dist/store/records.js +430 -0
- package/dist/store/room-held.d.ts +8 -0
- package/dist/store/room-held.d.ts.map +1 -0
- package/dist/store/room-held.js +17 -0
- package/dist/store/space.d.ts +11 -0
- package/dist/store/space.d.ts.map +1 -0
- package/dist/store/space.js +41 -0
- package/dist/store/watchers.d.ts +17 -0
- package/dist/store/watchers.d.ts.map +1 -0
- package/dist/store/watchers.js +56 -0
- package/dist/store/writes.d.ts +24 -0
- package/dist/store/writes.d.ts.map +1 -0
- package/dist/store/writes.js +125 -0
- package/dist/store.d.ts +112 -204
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +158 -394
- package/dist/stored.d.ts +1 -1
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +28 -14
- package/dist/surface.d.ts +88 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +223 -0
- package/dist/sync.d.ts +19 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +521 -0
- package/dist/tables.d.ts +32 -8
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +43 -12
- package/dist/tallies.d.ts +18 -0
- package/dist/tallies.d.ts.map +1 -0
- package/dist/tallies.js +129 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +2 -2
- package/dist/wire.d.ts +48 -5
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +16 -3
- package/package.json +3 -2
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- package/dist/job.d.ts +0 -33
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -54
package/dist/room-draft.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { apply, equalValue, frontmatterValue, parse, serialize, } from '@agentshouse/mdmodel';
|
|
1
|
+
import { apply, create, equalValue, frontmatterValue, parse, serialize, } from '@agentshouse/mdmodel';
|
|
2
2
|
import { runtimeError } from './failure.js';
|
|
3
3
|
import { sha256 } from './digest.js';
|
|
4
4
|
import { binaryLocalId } from './identity.js';
|
|
5
5
|
import { normalize } from './paths.js';
|
|
6
|
-
export function returnedBy(
|
|
7
|
-
return { kind, code:
|
|
6
|
+
export function returnedBy() {
|
|
7
|
+
return { kind: 'withdrawn', code: 'withdrawn', fields: {}, retryable: false };
|
|
8
8
|
}
|
|
9
9
|
export function staleWrite(current) {
|
|
10
|
-
return { outcome: 'stale',
|
|
10
|
+
return { outcome: 'stale', current };
|
|
11
11
|
}
|
|
12
12
|
function malformed(at, needs) {
|
|
13
13
|
throw runtimeError('room-draft-malformed', at === undefined ? 'room-draft-malformed' : `room-draft-malformed at ${at}: ${needs}`);
|
|
@@ -333,30 +333,43 @@ function joined(existing, returned) {
|
|
|
333
333
|
export function lineEnded(text) {
|
|
334
334
|
return text === '' || text.endsWith('\n') ? text : `${text}\n`;
|
|
335
335
|
}
|
|
336
|
-
function
|
|
337
|
-
const
|
|
338
|
-
if (!opened.ok)
|
|
339
|
-
return malformed();
|
|
340
|
-
const next = apply(opened.document, fields.map(([name, part]) => ({
|
|
341
|
-
kind: 'field',
|
|
342
|
-
name,
|
|
343
|
-
value: part.value,
|
|
344
|
-
prior: undefined,
|
|
345
|
-
})));
|
|
336
|
+
function written(start, changes, definition) {
|
|
337
|
+
const next = apply(start, changes, definition);
|
|
346
338
|
return next.outcome === 'applied' ? serialize(next.document) : malformed();
|
|
347
339
|
}
|
|
348
|
-
|
|
340
|
+
function empty(definition) {
|
|
341
|
+
const parsed = parse('', '', definition);
|
|
342
|
+
return parsed.ok ? parsed.document : malformed();
|
|
343
|
+
}
|
|
344
|
+
export function partsAfter(markdown, parts, definitions) {
|
|
349
345
|
const fields = named(parts.fields);
|
|
346
|
+
const sections = named(parts.sections);
|
|
347
|
+
if (fields.length === 0 && sections.length === 0 && parts.preamble === undefined)
|
|
348
|
+
return markdown;
|
|
349
|
+
const whole = parse(markdown, '', definitions);
|
|
350
|
+
const definition = whole.ok ? definitions?.(whole.document.type) : undefined;
|
|
351
|
+
const head = [
|
|
352
|
+
...fields.map(([name, part]) => ({
|
|
353
|
+
kind: 'field',
|
|
354
|
+
name,
|
|
355
|
+
value: part.value,
|
|
356
|
+
prior: undefined,
|
|
357
|
+
})),
|
|
358
|
+
...(parts.preamble === undefined
|
|
359
|
+
? []
|
|
360
|
+
: [{ kind: 'preamble', value: lineEnded(parts.preamble.value), prior: '' }]),
|
|
361
|
+
];
|
|
350
362
|
const pieces = [
|
|
351
|
-
...(
|
|
352
|
-
|
|
353
|
-
|
|
363
|
+
...(head.length === 0
|
|
364
|
+
? []
|
|
365
|
+
: [
|
|
366
|
+
written(fields.length === 0 ? empty(definition) : create(undefined, definition), head, definition),
|
|
367
|
+
]),
|
|
368
|
+
...sections.map(([name, part]) => written(empty(definition), [{ kind: 'section', name, value: lineEnded(part.value), prior: undefined }], definition)),
|
|
354
369
|
];
|
|
355
|
-
|
|
356
|
-
return markdown;
|
|
357
|
-
return `${lineEnded(markdown)}\n${pieces.map(lineEnded).join('')}`;
|
|
370
|
+
return `${lineEnded(markdown)}\n${pieces.join('')}`;
|
|
358
371
|
}
|
|
359
|
-
export function returnedInto(existing, returned) {
|
|
372
|
+
export function returnedInto(existing, returned, definitions) {
|
|
360
373
|
if (existing === undefined)
|
|
361
374
|
return returned;
|
|
362
375
|
const next = { ...existing };
|
|
@@ -376,7 +389,7 @@ export function returnedInto(existing, returned) {
|
|
|
376
389
|
delete next.fields;
|
|
377
390
|
delete next.sections;
|
|
378
391
|
delete next.preamble;
|
|
379
|
-
const value = partsAfter(whole.value, existing.markdown === undefined ? existing : returned);
|
|
392
|
+
const value = partsAfter(whole.value, existing.markdown === undefined ? existing : returned, definitions);
|
|
380
393
|
next.markdown = { value, base: whole.base };
|
|
381
394
|
}
|
|
382
395
|
const creation = existing.creation ?? returned.creation;
|
|
@@ -474,35 +487,6 @@ export function changesOf(path, parts) {
|
|
|
474
487
|
changes.push({ kind: 'remove', path });
|
|
475
488
|
return { changes, bases };
|
|
476
489
|
}
|
|
477
|
-
function rebased(before, after) {
|
|
478
|
-
return before === undefined ? after : { ...after, base: before.base };
|
|
479
|
-
}
|
|
480
|
-
function rebasedAll(before, after) {
|
|
481
|
-
return {
|
|
482
|
-
...before,
|
|
483
|
-
...Object.fromEntries(Object.entries(after).map(([name, part]) => [name, rebased(before?.[name], part)])),
|
|
484
|
-
};
|
|
485
|
-
}
|
|
486
|
-
export function joinedDraft(carried, saved) {
|
|
487
|
-
const draft = saved.find((item) => item.path === carried.path);
|
|
488
|
-
if (draft === undefined)
|
|
489
|
-
return carried;
|
|
490
|
-
const held = carried.parts;
|
|
491
|
-
const next = draft.parts;
|
|
492
|
-
return {
|
|
493
|
-
path: carried.path,
|
|
494
|
-
parts: {
|
|
495
|
-
...held,
|
|
496
|
-
...next,
|
|
497
|
-
...(next.fields === undefined ? {} : { fields: rebasedAll(held.fields, next.fields) }),
|
|
498
|
-
...(next.sections === undefined
|
|
499
|
-
? {}
|
|
500
|
-
: { sections: rebasedAll(held.sections, next.sections) }),
|
|
501
|
-
...(next.preamble === undefined ? {} : { preamble: rebased(held.preamble, next.preamble) }),
|
|
502
|
-
...(next.markdown === undefined ? {} : { markdown: rebased(held.markdown, next.markdown) }),
|
|
503
|
-
},
|
|
504
|
-
};
|
|
505
|
-
}
|
|
506
490
|
export function withdrawnDrafts(drafts, changes) {
|
|
507
491
|
return drafts.flatMap((draft) => {
|
|
508
492
|
const file = draft.parts.file;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type ChangeSet } from './change-set.js';
|
|
2
|
+
import { type VisibleLayer } from './replica.js';
|
|
3
|
+
import { type RoomDraft, type RoomDraftWrite } from './room-draft.js';
|
|
4
|
+
import type { Runtime } from './runtime.js';
|
|
5
|
+
import type { Store } from './store.js';
|
|
6
|
+
export type RoomDraftSurface = {
|
|
7
|
+
list(): Promise<readonly RoomDraft[]>;
|
|
8
|
+
read(room: string, path: string): Promise<RoomDraft | null>;
|
|
9
|
+
write(room: string, path: string, revision: string | null, parts: unknown, next?: string): Promise<RoomDraftWrite>;
|
|
10
|
+
discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
|
|
11
|
+
};
|
|
12
|
+
export type PresentationSurface = {
|
|
13
|
+
read(app: string): Promise<unknown>;
|
|
14
|
+
write(app: string, value: unknown): Promise<void>;
|
|
15
|
+
edit(app: string, members: Readonly<Record<string, unknown>>): Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
export declare function visibleOf(store: Store, locator: string, paths: readonly string[]): Promise<VisibleLayer | undefined>;
|
|
18
|
+
export declare function publishRoomDrafts({ store, socket }: Runtime, waitingOnly: boolean, touched?: ChangeSet['documents'] | null): Promise<void>;
|
|
19
|
+
export declare function emitPresentation({ store, socket }: Runtime, app: string): Promise<void>;
|
|
20
|
+
export declare function roomDraftSurface(runtime: Runtime): RoomDraftSurface;
|
|
21
|
+
export declare function presentationSurface(runtime: Runtime): PresentationSurface;
|
|
22
|
+
export declare function watchRoomDrafts({ store, socket }: Runtime, deliver: (value: unknown) => void): () => void;
|
|
23
|
+
export declare function watchPresentation({ store, socket }: Runtime, app: string, deliver: (value: unknown) => void): () => void;
|
|
24
|
+
//# sourceMappingURL=room-drafts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"room-drafts.d.ts","sourceRoot":"","sources":["../src/room-drafts.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK5D,OAAO,EAAW,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC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wBAAgB,iBAAiB,CAC/B,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAC1B,WAAW,EAAE,OAAO,EACpB,OAAO,GAAE,SAAS,CAAC,WAAW,CAAC,GAAG,IAAW,GAC5C,OAAO,CAAC,IAAI,CAAC,CAuBf;AAOD,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAUvF;AAoDD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,gBAAgB,CAkDnE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,mBAAmB,CA8BzE;AAED,wBAAgB,eAAe,CAC7B,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAC1B,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAChC,MAAM,IAAI,CAiBZ;AAED,wBAAgB,iBAAiB,CAC/B,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAC1B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAChC,MAAM,IAAI,CASZ"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { plain } from '@agentshouse/mdmodel';
|
|
2
|
+
import { changeSet } from './change-set.js';
|
|
3
|
+
import { collectionOf } from './collection.js';
|
|
4
|
+
import { runtimeError, uncaught } from './failure.js';
|
|
5
|
+
import { roomDraftRevision } from './identity.js';
|
|
6
|
+
import { normalize } from './paths.js';
|
|
7
|
+
import { slicing } from './replica.js';
|
|
8
|
+
import { binaryBase, gatheredParts, held, heldFile, readParts, staleWrite, underneath, } from './room-draft.js';
|
|
9
|
+
import { stepped } from './turn.js';
|
|
10
|
+
const ROOM_DRAFTS = 'room-drafts';
|
|
11
|
+
const presentationTopic = (app) => `presentation\u0000${app}`;
|
|
12
|
+
export async function visibleOf(store, locator, paths) {
|
|
13
|
+
const kept = await store.record(locator);
|
|
14
|
+
if (kept === undefined)
|
|
15
|
+
return undefined;
|
|
16
|
+
const local = await store.open();
|
|
17
|
+
const slice = await stepped(slicing(await local.entries(kept.key, 'visible', paths), paths));
|
|
18
|
+
return { ...slice, collection: collectionOf(slice.documents, store.composed(kept)) };
|
|
19
|
+
}
|
|
20
|
+
function roomDraftOf(record, visible) {
|
|
21
|
+
return structuredClone({
|
|
22
|
+
room: record.locator,
|
|
23
|
+
path: record.path,
|
|
24
|
+
revision: record.revision,
|
|
25
|
+
parts: record.parts,
|
|
26
|
+
changedUnderneath: underneath(record.parts, record.path, visible),
|
|
27
|
+
returned: record.returned,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
async function roomDraftsOf(store, records) {
|
|
31
|
+
const rooms = new Map();
|
|
32
|
+
for (const record of records) {
|
|
33
|
+
const paths = rooms.get(record.locator) ?? [];
|
|
34
|
+
paths.push(record.path);
|
|
35
|
+
rooms.set(record.locator, paths);
|
|
36
|
+
}
|
|
37
|
+
const layers = new Map();
|
|
38
|
+
for (const [locator, paths] of rooms) {
|
|
39
|
+
layers.set(locator, await visibleOf(store, locator, paths));
|
|
40
|
+
}
|
|
41
|
+
return records.map((record) => roomDraftOf(record, layers.get(record.locator)));
|
|
42
|
+
}
|
|
43
|
+
function inOrder(records) {
|
|
44
|
+
return [...records].sort((left, right) => {
|
|
45
|
+
if (left.locator !== right.locator)
|
|
46
|
+
return left.locator < right.locator ? -1 : 1;
|
|
47
|
+
if (left.path !== right.path)
|
|
48
|
+
return left.path < right.path ? -1 : 1;
|
|
49
|
+
return 0;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async function snapshotRoomDrafts(store) {
|
|
53
|
+
return roomDraftsOf(store, inOrder(await store.drafts()));
|
|
54
|
+
}
|
|
55
|
+
export function publishRoomDrafts({ store, socket }, waitingOnly, touched = null) {
|
|
56
|
+
const unwatched = () => socket.closed() || store.watching(ROOM_DRAFTS).length === 0;
|
|
57
|
+
if (unwatched())
|
|
58
|
+
return Promise.resolve();
|
|
59
|
+
return store.publication(async () => {
|
|
60
|
+
if (unwatched())
|
|
61
|
+
return;
|
|
62
|
+
const records = await store.drafts();
|
|
63
|
+
if (socket.closed())
|
|
64
|
+
return;
|
|
65
|
+
if (touched !== null &&
|
|
66
|
+
!records.some((record) => touched.some(({ locator, path }) => locator === record.locator && (path === null || path === record.path)))) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const value = await roomDraftsOf(store, inOrder(records));
|
|
70
|
+
if (socket.closed())
|
|
71
|
+
return;
|
|
72
|
+
const answered = store.watching(ROOM_DRAFTS, waitingOnly ? 'waiting' : 'all');
|
|
73
|
+
for (const watcher of answered)
|
|
74
|
+
watcher.answer(value);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
async function presentationOf(store, app) {
|
|
78
|
+
const value = await (await store.open()).presentation(app);
|
|
79
|
+
return value === undefined ? null : structuredClone(value);
|
|
80
|
+
}
|
|
81
|
+
export function emitPresentation({ store, socket }, app) {
|
|
82
|
+
const topic = presentationTopic(app);
|
|
83
|
+
const listening = () => store.watching(topic, 'ready');
|
|
84
|
+
if (socket.closed() || listening().length === 0)
|
|
85
|
+
return Promise.resolve();
|
|
86
|
+
return store.publication(async () => {
|
|
87
|
+
if (socket.closed() || listening().length === 0)
|
|
88
|
+
return;
|
|
89
|
+
const value = await presentationOf(store, app);
|
|
90
|
+
if (socket.closed())
|
|
91
|
+
return;
|
|
92
|
+
for (const watcher of listening())
|
|
93
|
+
watcher.answer(value);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
async function writtenRoomDraft({ store }, room, path, revision, input, next) {
|
|
97
|
+
const parts = readParts(input, path);
|
|
98
|
+
if (path === '' || normalize(path) !== path)
|
|
99
|
+
throw runtimeError('room-draft-malformed', `room-draft-malformed at ${path}: a path inside the Room, such as notes/a.md`);
|
|
100
|
+
const local = await store.open();
|
|
101
|
+
const current = await store.draft(room, path);
|
|
102
|
+
if ((current?.revision ?? null) !== revision) {
|
|
103
|
+
return staleWrite(current === undefined ? null : (await roomDraftsOf(store, [current]))[0]);
|
|
104
|
+
}
|
|
105
|
+
const file = parts.file === undefined
|
|
106
|
+
? undefined
|
|
107
|
+
: await heldFile(parts.file.blob, parts.file.base === undefined
|
|
108
|
+
? binaryBase(await visibleOf(store, room, [path]), path)
|
|
109
|
+
: parts.file.base);
|
|
110
|
+
const record = {
|
|
111
|
+
locator: room,
|
|
112
|
+
path,
|
|
113
|
+
revision: next,
|
|
114
|
+
parts: held(current?.parts, parts, file),
|
|
115
|
+
returned: current?.returned ?? null,
|
|
116
|
+
};
|
|
117
|
+
await local.keepRoomDraft(record, parts.file === undefined || file === undefined
|
|
118
|
+
? []
|
|
119
|
+
: [{ key: file.localId, blob: parts.file.blob }]);
|
|
120
|
+
await store.changed(changeSet(room, { drafts: [path] }));
|
|
121
|
+
return { outcome: 'written', roomDraft: (await roomDraftsOf(store, [record]))[0] };
|
|
122
|
+
}
|
|
123
|
+
async function keptPresentation({ store }, app, value) {
|
|
124
|
+
await (await store.open()).present({ app, value });
|
|
125
|
+
await store.changed(changeSet('', { presentation: app }));
|
|
126
|
+
}
|
|
127
|
+
export function roomDraftSurface(runtime) {
|
|
128
|
+
const { store } = runtime;
|
|
129
|
+
return {
|
|
130
|
+
list() {
|
|
131
|
+
return store
|
|
132
|
+
.exclusive(async () => {
|
|
133
|
+
await store.open();
|
|
134
|
+
return snapshotRoomDrafts(store);
|
|
135
|
+
})
|
|
136
|
+
.then((listed) => {
|
|
137
|
+
publishRoomDrafts(runtime, true);
|
|
138
|
+
return listed;
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
async read(room, path) {
|
|
142
|
+
const record = await store.draft(room, path);
|
|
143
|
+
return record === undefined ? null : (await roomDraftsOf(store, [record]))[0];
|
|
144
|
+
},
|
|
145
|
+
write(room, path, revision, input, next = roomDraftRevision()) {
|
|
146
|
+
if (typeof next !== 'string' || next === '')
|
|
147
|
+
return Promise.reject(runtimeError('room-draft-malformed'));
|
|
148
|
+
return store.gathered(`room-draft\u0000${room}\u0000${path}`, { revision, input, next }, (earlier, later) => {
|
|
149
|
+
if (later.revision !== earlier.next)
|
|
150
|
+
return null;
|
|
151
|
+
const parts = gatheredParts(earlier.input, later.input);
|
|
152
|
+
return parts === null
|
|
153
|
+
? null
|
|
154
|
+
: { revision: earlier.revision, input: parts, next: later.next };
|
|
155
|
+
}, (written) => writtenRoomDraft(runtime, room, path, written.revision, written.input, written.next));
|
|
156
|
+
},
|
|
157
|
+
discard(room, path, revision) {
|
|
158
|
+
return store.exclusive(async () => {
|
|
159
|
+
const local = await store.open();
|
|
160
|
+
const current = await store.draft(room, path);
|
|
161
|
+
if (current === undefined || current.revision !== revision) {
|
|
162
|
+
return staleWrite(current === undefined ? null : (await roomDraftsOf(store, [current]))[0]);
|
|
163
|
+
}
|
|
164
|
+
await local.discardRoomDraft(room, path);
|
|
165
|
+
await store.changed(changeSet(room, { drafts: [path] }));
|
|
166
|
+
return { outcome: 'written', roomDraft: null };
|
|
167
|
+
});
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
export function presentationSurface(runtime) {
|
|
172
|
+
const { store } = runtime;
|
|
173
|
+
return {
|
|
174
|
+
read(app) {
|
|
175
|
+
return store.exclusive(() => presentationOf(store, app));
|
|
176
|
+
},
|
|
177
|
+
write(app, value) {
|
|
178
|
+
return store.exclusive(() => keptPresentation(runtime, app, structuredClone(value)));
|
|
179
|
+
},
|
|
180
|
+
edit(app, members) {
|
|
181
|
+
return store.gathered(`presentation\u0000${app}`, structuredClone(members), (earlier, later) => ({ ...earlier, ...later }), async (edited) => {
|
|
182
|
+
const kept = await (await store.open()).presentation(app);
|
|
183
|
+
await keptPresentation(runtime, app, Object.fromEntries([
|
|
184
|
+
...Object.entries(plain(kept) ? kept : {}).filter(([member]) => !Object.hasOwn(edited, member)),
|
|
185
|
+
...Object.entries(edited).filter(([, value]) => value !== null),
|
|
186
|
+
]));
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
export function watchRoomDrafts({ store, socket }, deliver) {
|
|
192
|
+
const watcher = store.watch(ROOM_DRAFTS, deliver);
|
|
193
|
+
const unwatched = () => socket.closed() || !watcher.held();
|
|
194
|
+
void store
|
|
195
|
+
.exclusive(async () => {
|
|
196
|
+
await store.open();
|
|
197
|
+
})
|
|
198
|
+
.then(() => store.publication(async () => {
|
|
199
|
+
if (unwatched())
|
|
200
|
+
return;
|
|
201
|
+
const value = await snapshotRoomDrafts(store);
|
|
202
|
+
if (!unwatched())
|
|
203
|
+
watcher.answer(value);
|
|
204
|
+
}), uncaught);
|
|
205
|
+
return watcher.stop;
|
|
206
|
+
}
|
|
207
|
+
export function watchPresentation({ store, socket }, app, deliver) {
|
|
208
|
+
const watcher = store.watch(presentationTopic(app), deliver);
|
|
209
|
+
void store
|
|
210
|
+
.exclusive(async () => {
|
|
211
|
+
const value = await presentationOf(store, app);
|
|
212
|
+
if (!socket.closed() && watcher.held())
|
|
213
|
+
watcher.answer(value);
|
|
214
|
+
})
|
|
215
|
+
.catch(uncaught);
|
|
216
|
+
return watcher.stop;
|
|
217
|
+
}
|
package/dist/rows.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../src/rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAClG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,
|
|
1
|
+
{"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../src/rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAClG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAA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AED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7C;AAaD,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,WAAW,GACvB,UAAU,GAAG,IAAI,CAQnB;AAED,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,KAAK,EAAE,UAAU,GAAG,IAAI,GACvB,SAAS,CAeX;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,GAAG,IAAI,CAK3F;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAYnF"}
|
package/dist/rows.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { byCodePoint, documentFacts, indexed, parse } from '@agentshouse/mdmodel';
|
|
2
|
-
import { governing } from './collection.js';
|
|
3
|
-
import { definitionOf } from './model.js';
|
|
2
|
+
import { definitionsAt, governing } from './collection.js';
|
|
4
3
|
function keyOf(...parts) {
|
|
5
4
|
return `${parts.join('\u0000')}\u0000`;
|
|
6
5
|
}
|
|
@@ -29,7 +28,7 @@ function fieldsText(fields) {
|
|
|
29
28
|
}
|
|
30
29
|
export function writtenFacts(path, content, composition) {
|
|
31
30
|
const model = governing(composition, path);
|
|
32
|
-
const facts = documentFacts(path, parse(content, path), {
|
|
31
|
+
const facts = documentFacts(path, parse(content, path, definitionsAt(composition, path)), {
|
|
33
32
|
types: model.status === 'unavailable' ? {} : model.types,
|
|
34
33
|
});
|
|
35
34
|
return facts === null
|
|
@@ -72,7 +71,7 @@ export function derived(path, held, composition) {
|
|
|
72
71
|
}));
|
|
73
72
|
if (held.type === null || held.fields === null)
|
|
74
73
|
return { values: [], links: stored };
|
|
75
|
-
const definition =
|
|
74
|
+
const definition = definitionsAt(composition, path)(held.type);
|
|
76
75
|
const { values, links: fields } = indexed(path, held.fields, definition);
|
|
77
76
|
return { values, links: [...fields, ...stored] };
|
|
78
77
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { RoomDeclaration, TypedPath } from './adapter.js';
|
|
2
|
+
import type { RuntimeShell } from './durability.js';
|
|
3
|
+
import type { LiveConversations } from './conversation-live.js';
|
|
4
|
+
import type { WriteRule } from './declaration.js';
|
|
5
|
+
import type { FiguresRead } from './figures.js';
|
|
6
|
+
import type { LiveQueries } from './live.js';
|
|
7
|
+
import type { Log } from './log.js';
|
|
8
|
+
import type { ModelState } from './model.js';
|
|
9
|
+
import type { Presence } from './presence.js';
|
|
10
|
+
import type { ReadAnswers } from './reads.js';
|
|
11
|
+
import type { Recovery } from './recovery.js';
|
|
12
|
+
import type { RuntimeSocket } from './socket.js';
|
|
13
|
+
import type { HeldCover, Store } from './store.js';
|
|
14
|
+
import type { schemaTypes } from './attached-model.js';
|
|
15
|
+
export type Runtime = {
|
|
16
|
+
readonly store: Store;
|
|
17
|
+
readonly socket: RuntimeSocket;
|
|
18
|
+
readonly presence: Presence;
|
|
19
|
+
readonly journal: Log;
|
|
20
|
+
readonly recovery: Recovery;
|
|
21
|
+
readonly shell: RuntimeShell;
|
|
22
|
+
readonly localSaves: boolean;
|
|
23
|
+
readonly roomTypes: Parameters<typeof schemaTypes>[1];
|
|
24
|
+
readonly builtIn: ModelState;
|
|
25
|
+
readonly typedPaths: readonly TypedPath[];
|
|
26
|
+
readonly writeRule: (declaration: RoomDeclaration) => WriteRule;
|
|
27
|
+
readonly usableWhenHeld: readonly string[];
|
|
28
|
+
readonly build: string;
|
|
29
|
+
readonly conversations: LiveConversations;
|
|
30
|
+
readonly liveQueries: LiveQueries<HeldCover>;
|
|
31
|
+
readonly figures: FiguresRead;
|
|
32
|
+
readonly lastAnswers: ReadAnswers;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,SAAS,EAAE,CAAC,WAAW,EAAE,eAAe,KAAK,SAAS,CAAC;IAChE,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,aAAa,EAAE,iBAAiB,CAAC;IAC1C,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IAC7C,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;CACnC,CAAC"}
|
package/dist/runtime.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/save.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type Validation } from '@agentshouse/mdmodel';
|
|
2
|
-
import type {
|
|
3
|
-
import { type
|
|
2
|
+
import type { ProviderLimit } from './adapter.js';
|
|
3
|
+
import { type ChangeBatch, type WrittenBy } from './change.js';
|
|
4
4
|
import { type Composition } from './collection.js';
|
|
5
|
+
import type { WriteRule } from './declaration.js';
|
|
5
6
|
import { type Layer } from './overlay.js';
|
|
6
|
-
import type { VisibleLayer } from './replica.js';
|
|
7
|
-
import type
|
|
7
|
+
import type { ReplicaRecord, VisibleLayer } from './replica.js';
|
|
8
|
+
import { type ChangedPart, type RoomDraftRecord, type SavedDraft } from './room-draft.js';
|
|
8
9
|
export type SaveRefusal = {
|
|
9
10
|
code: string;
|
|
10
11
|
retryable: boolean;
|
|
@@ -13,91 +14,45 @@ export type SaveRefusal = {
|
|
|
13
14
|
referrers?: readonly string[];
|
|
14
15
|
parts?: readonly ChangedPart[];
|
|
15
16
|
};
|
|
16
|
-
export type
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
providerLimits: readonly ProviderLimit[];
|
|
23
|
-
visible: VisibleLayer;
|
|
24
|
-
folders: ReadonlySet<string>;
|
|
25
|
-
handle: string;
|
|
26
|
-
changes: readonly Change[];
|
|
27
|
-
bases: readonly Precondition[];
|
|
28
|
-
queued?: ReadonlySet<string>;
|
|
29
|
-
writtenBy?: WrittenBy;
|
|
30
|
-
unmodeled: boolean;
|
|
31
|
-
validate: Validator;
|
|
17
|
+
export type SaveAsk = {
|
|
18
|
+
readonly saved: readonly SavedDraft[];
|
|
19
|
+
readonly consumed: ReadonlySet<string>;
|
|
20
|
+
readonly writtenBy?: WrittenBy;
|
|
21
|
+
readonly local: boolean;
|
|
22
|
+
readonly providerLimits: readonly ProviderLimit[];
|
|
32
23
|
};
|
|
33
|
-
export type
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
24
|
+
export type SavingRoom = {
|
|
25
|
+
readonly record: ReplicaRecord;
|
|
26
|
+
readonly rule: WriteRule;
|
|
27
|
+
readonly composition: Composition;
|
|
28
|
+
readonly queue: readonly ChangeBatch[];
|
|
29
|
+
readonly changeable: ReadonlySet<string>;
|
|
30
|
+
readonly saved: ReadonlyMap<string, readonly SavedDraft[]>;
|
|
31
|
+
readonly replay: (queue: readonly ChangeBatch[]) => Generator<number, VisibleLayer, void>;
|
|
32
|
+
readonly folders: ReadonlySet<string>;
|
|
33
|
+
readonly modelled: boolean;
|
|
34
|
+
readonly drafts: ReadonlyMap<string, RoomDraftRecord>;
|
|
35
|
+
readonly validate: Validator;
|
|
37
36
|
};
|
|
38
|
-
export type
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
export declare function rewriting(batch: ChangeBatch, locator: string): boolean;
|
|
45
|
-
export declare function effectiveIn(batch: ChangeBatch, locator: string, visible: VisibleLayer): Generator<number, ChangeBatch, void>;
|
|
46
|
-
export declare function queuedDocuments(queue: readonly ChangeBatch[]): ReadonlySet<string>;
|
|
47
|
-
export type Requeued = {
|
|
48
|
-
kind: 'requeued';
|
|
49
|
-
queue: readonly ChangeBatch[];
|
|
50
|
-
changes: readonly Change[];
|
|
51
|
-
queued: ReadonlySet<string>;
|
|
52
|
-
withdrawn: ReadonlyMap<string, ChangeBatch | null>;
|
|
53
|
-
owners: ReadonlySet<string>;
|
|
54
|
-
} | {
|
|
55
|
-
kind: 'refused';
|
|
56
|
-
refusal: SaveRefusal;
|
|
37
|
+
export type PlannedRoom = {
|
|
38
|
+
readonly locator: string;
|
|
39
|
+
readonly queue: readonly ChangeBatch[];
|
|
40
|
+
readonly saved: ReadonlyMap<string, readonly SavedDraft[]>;
|
|
41
|
+
readonly consumed: readonly string[];
|
|
42
|
+
readonly carried: readonly RoomDraftRecord[];
|
|
57
43
|
};
|
|
58
|
-
export type
|
|
59
|
-
kind: '
|
|
60
|
-
|
|
61
|
-
queue: readonly ChangeBatch[];
|
|
44
|
+
export type SavePlan = {
|
|
45
|
+
readonly kind: 'refused';
|
|
46
|
+
readonly refusal: SaveRefusal;
|
|
62
47
|
} | {
|
|
63
|
-
kind: '
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
type VisibleOver = (queue: readonly ChangeBatch[]) => Generator<number, VisibleLayer, void>;
|
|
67
|
-
export declare function requeuing(queue: readonly ChangeBatch[], changes: readonly Change[], visible: VisibleLayer, changeable: (batch: ChangeBatch) => boolean, state: VisibleOver): Generator<number, Requeued, void>;
|
|
68
|
-
export declare function joined(queue: readonly ChangeBatch[], owner: ChangeBatch, extra: ChangeBatch): Joining;
|
|
69
|
-
export declare function limiting(queue: readonly ChangeBatch[], batch: ChangeBatch, limits: readonly ProviderLimit[], state: VisibleOver): Generator<number, SaveRefusal | null, void>;
|
|
70
|
-
export declare const MOVE_DOCUMENTS = "move-documents";
|
|
71
|
-
export type MoveSide = {
|
|
72
|
-
room: string;
|
|
73
|
-
handle: string;
|
|
74
|
-
baseRoomVersion: string;
|
|
75
|
-
composition: Composition;
|
|
76
|
-
operations: OperationScopes;
|
|
77
|
-
providerOwnedPaths: readonly string[];
|
|
78
|
-
visible: VisibleLayer;
|
|
79
|
-
folders: ReadonlySet<string>;
|
|
80
|
-
queued: ReadonlySet<string>;
|
|
81
|
-
unmodeled: boolean;
|
|
82
|
-
validate: Validator;
|
|
48
|
+
readonly kind: 'planned';
|
|
49
|
+
readonly identifier: string;
|
|
50
|
+
readonly rooms: readonly PlannedRoom[];
|
|
83
51
|
};
|
|
84
|
-
export type
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}[];
|
|
91
|
-
providerLimits: readonly ProviderLimit[];
|
|
92
|
-
local: boolean;
|
|
93
|
-
writtenBy?: WrittenBy;
|
|
94
|
-
};
|
|
95
|
-
export type MoveResult = {
|
|
96
|
-
kind: 'moved';
|
|
97
|
-
leaving: ChangeBatch;
|
|
98
|
-
arriving: ChangeBatch;
|
|
99
|
-
} | Refusing;
|
|
100
|
-
export declare function buildMove(input: MoveInput): Promise<MoveResult>;
|
|
101
|
-
export declare function buildBatch(input: SaveInput): Promise<BatchResult>;
|
|
102
|
-
export {};
|
|
52
|
+
export type Validator = (resulting: Layer, touched: readonly string[]) => Promise<Validation>;
|
|
53
|
+
export declare function providerRewritten(batch: ChangeBatch, visible: VisibleLayer): Generator<number, ChangeBatch, void>;
|
|
54
|
+
export declare function rewriting(batch: ChangeBatch, locator: string): boolean;
|
|
55
|
+
export declare function effectiveIn(batch: ChangeBatch, locator: string, visible: VisibleLayer): Generator<number, ChangeBatch, void>;
|
|
56
|
+
export declare function destination(locator: string, saved: readonly SavedDraft[]): string | null;
|
|
57
|
+
export declare function planSave(ask: SaveAsk, room: SavingRoom, into?: SavingRoom): Promise<SavePlan>;
|
|
103
58
|
//# sourceMappingURL=save.d.ts.map
|
package/dist/save.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"save.d.ts","sourceRoot":"","sources":["../src/save.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"save.d.ts","sourceRoot":"","sources":["../src/save.ts"],"names":[],"mappings":"AACA,OAAO,EAmBL,KAAK,UAAU,EAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAmB,aAAa,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAML,KAAK,WAAW,EAGhB,KAAK,SAAS,EACf,MAAM,aAAa,CAAC;AACrB,OAAO,EAML,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAc,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,EAKL,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,UAAU,EAChB,MAAM,iBAAiB,CAAC;AAIzB,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,KAAK,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;CAChC,CAAC;A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