@agentshouse/mdruntime 0.1.0-c4ca57eefb98a → 0.1.0-c4ef58fbdca7b
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 +2 -2
- package/dist/acceptance.d.ts +6 -0
- package/dist/acceptance.d.ts.map +1 -0
- package/dist/acceptance.js +389 -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 +85 -67
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +3 -10
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +21 -56
- package/dist/bootstrap.d.ts +11 -10
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +218 -82
- package/dist/cell.d.ts +6 -0
- package/dist/cell.d.ts.map +1 -0
- package/dist/cell.js +9 -0
- package/dist/chain.d.ts +2 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +3 -7
- package/dist/change.d.ts +1 -0
- package/dist/change.d.ts.map +1 -1
- 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 +21 -6
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +3 -1
- package/dist/collection.d.ts +2 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +1 -17
- package/dist/compile.d.ts +6 -6
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +263 -319
- package/dist/connection.d.ts +5 -143
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +102 -5311
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +7 -0
- package/dist/conversation-live.d.ts +136 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +248 -0
- package/dist/conversation-row.d.ts +33 -0
- package/dist/conversation-row.d.ts.map +1 -0
- package/dist/conversation-row.js +53 -0
- package/dist/conversation.d.ts +41 -45
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +860 -869
- package/dist/discovery.d.ts +10 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +175 -0
- package/dist/durability.d.ts +15 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +2 -2
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +17 -7
- 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 +4 -7
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +29 -31
- package/dist/identity.d.ts +0 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +0 -3
- package/dist/index.d.ts +25 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/install.d.ts +56 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +556 -0
- package/dist/job.d.ts +33 -0
- package/dist/job.d.ts.map +1 -0
- package/dist/job.js +54 -0
- package/dist/lifecycle.d.ts +7 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +268 -0
- package/dist/listing.d.ts +53 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +175 -0
- package/dist/live.d.ts +5 -4
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +63 -22
- package/dist/locks.d.ts +9 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +61 -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 +61 -0
- package/dist/media.d.ts +1 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +19 -9
- package/dist/memory.d.ts +11 -4
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +171 -82
- package/dist/messages.d.ts +27 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +97 -19
- package/dist/model.d.ts +2 -10
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -18
- package/dist/models.d.ts +14 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +193 -0
- package/dist/observation.d.ts +2 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +7 -2
- package/dist/opening.d.ts +4 -0
- package/dist/opening.d.ts.map +1 -0
- package/dist/opening.js +57 -0
- package/dist/outcome.d.ts +4 -4
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +3 -0
- package/dist/overlay.d.ts +1 -0
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +11 -0
- package/dist/parts.d.ts +59 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +118 -0
- package/dist/preparation.d.ts +20 -0
- package/dist/preparation.d.ts.map +1 -0
- package/dist/preparation.js +226 -0
- package/dist/queries.d.ts +16 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +272 -0
- package/dist/query.d.ts +14 -209
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -505
- package/dist/questions.d.ts +34 -0
- package/dist/questions.d.ts.map +1 -0
- package/dist/questions.js +122 -0
- package/dist/reach.d.ts +15 -13
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +183 -137
- package/dist/react.d.ts +10 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/read.d.ts +7 -0
- package/dist/read.d.ts.map +1 -0
- package/dist/read.js +17 -0
- package/dist/readiness.d.ts +2 -16
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +4 -10
- package/dist/reads.d.ts +36 -10
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +158 -78
- package/dist/recovery.d.ts +1 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +35 -1
- package/dist/refresh.d.ts +7 -5
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +33 -5
- package/dist/refusal.d.ts +5 -0
- package/dist/refusal.d.ts.map +1 -0
- package/dist/refusal.js +56 -0
- package/dist/replica.d.ts +8 -9
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +52 -20
- package/dist/room-draft.d.ts +4 -3
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +65 -52
- package/dist/room-drafts.d.ts +24 -0
- package/dist/room-drafts.d.ts.map +1 -0
- package/dist/room-drafts.js +216 -0
- package/dist/rows.d.ts +14 -21
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +48 -184
- package/dist/runtime.d.ts +43 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/save.d.ts +3 -1
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +16 -11
- package/dist/saves.d.ts +70 -0
- package/dist/saves.d.ts.map +1 -0
- package/dist/saves.js +1006 -0
- package/dist/search.d.ts +12 -63
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +9 -52
- package/dist/seed.d.ts +11 -2
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +71 -0
- package/dist/shared.d.ts +1 -2
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +9 -15
- package/dist/shown.d.ts +31 -0
- package/dist/shown.d.ts.map +1 -0
- package/dist/shown.js +295 -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/rooms.d.ts +43 -0
- package/dist/socket/rooms.d.ts.map +1 -0
- package/dist/socket/rooms.js +90 -0
- package/dist/socket/session.d.ts +39 -0
- package/dist/socket/session.d.ts.map +1 -0
- package/dist/socket/session.js +23 -0
- package/dist/socket.d.ts +70 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +175 -0
- package/dist/source.d.ts +61 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +81 -0
- package/dist/status.d.ts +0 -6
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +0 -6
- package/dist/store/fences.d.ts +16 -0
- package/dist/store/fences.d.ts.map +1 -0
- package/dist/store/fences.js +26 -0
- 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 +431 -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 +43 -0
- package/dist/store/watchers.d.ts +17 -0
- package/dist/store/watchers.d.ts.map +1 -0
- package/dist/store/watchers.js +57 -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 +107 -157
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +143 -395
- package/dist/stored.d.ts +58 -37
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +283 -203
- 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 +20 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +532 -0
- package/dist/tables.d.ts +120 -55
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +212 -93
- package/dist/tallies.d.ts +18 -0
- package/dist/tallies.d.ts.map +1 -0
- package/dist/tallies.js +129 -0
- package/dist/transfer.d.ts +0 -5
- package/dist/transfer.d.ts.map +1 -1
- package/dist/validation.d.ts +3 -4
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +42 -100
- package/dist/windows.d.ts +1 -12
- package/dist/windows.d.ts.map +1 -1
- package/dist/windows.js +2 -75
- package/dist/wire.d.ts +17 -5
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +7 -1
- package/package.json +2 -2
- package/dist/fence.d.ts +0 -6
- package/dist/fence.d.ts.map +0 -1
- package/dist/fence.js +0 -10
- package/dist/fulltext.d.ts +0 -27
- package/dist/fulltext.d.ts.map +0 -1
- package/dist/fulltext.js +0 -370
- package/dist/words.d.ts +0 -19
- package/dist/words.d.ts.map +0 -1
- package/dist/words.js +0 -156
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ProviderRefusal } from './adapter.js';
|
|
2
|
+
import type { Runtime } from './runtime.js';
|
|
3
|
+
import type { RefusalReason } from './socket.js';
|
|
4
|
+
export declare function refuse(runtime: Runtime, reason: RefusalReason, provider?: ProviderRefusal | null): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=refusal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../src/refusal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAOpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,wBAAsB,MAAM,CAC1B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,aAAa,EACrB,QAAQ,GAAE,eAAe,GAAG,IAAW,iBAmDxC"}
|
package/dist/refusal.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { changeSet, mergeChangeSets } from './change-set.js';
|
|
2
|
+
import { composedOf } from './collection.js';
|
|
3
|
+
import { listedLocators } from './listing.js';
|
|
4
|
+
import { prepare } from './preparation.js';
|
|
5
|
+
import { storedRecord } from './replica.js';
|
|
6
|
+
import { emitRefusal } from './shown.js';
|
|
7
|
+
export async function refuse(runtime, reason, provider = null) {
|
|
8
|
+
const { store, socket, journal } = runtime;
|
|
9
|
+
socket.session.set({ paused: true });
|
|
10
|
+
socket.abortReads();
|
|
11
|
+
try {
|
|
12
|
+
if (reason === 'revoked-authorization') {
|
|
13
|
+
await store.exclusive(async () => {
|
|
14
|
+
const revoked = { status: 'unavailable', reason: 'revoked' };
|
|
15
|
+
let held = new Map();
|
|
16
|
+
try {
|
|
17
|
+
const local = await store.open();
|
|
18
|
+
held = await store.rooms();
|
|
19
|
+
await local.commit({
|
|
20
|
+
rooms: [...held.values()].map(({ record: kept }) => {
|
|
21
|
+
const record = { ...kept, model: revoked };
|
|
22
|
+
return {
|
|
23
|
+
locator: record.locator,
|
|
24
|
+
key: record.key,
|
|
25
|
+
record: storedRecord(record),
|
|
26
|
+
composed: composedOf(store.composed(record)),
|
|
27
|
+
};
|
|
28
|
+
}),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
journal.record('model revocation persistence failed');
|
|
33
|
+
}
|
|
34
|
+
const listedNow = listedLocators(runtime, held);
|
|
35
|
+
for (const locator of listedNow) {
|
|
36
|
+
if (!held.has(locator))
|
|
37
|
+
socket.rooms.stand(locator, { unheldModel: revoked });
|
|
38
|
+
}
|
|
39
|
+
store.changed(mergeChangeSets(listedNow.map((locator) => changeSet(locator, { documents: null, room: true }))));
|
|
40
|
+
prepare(runtime);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
socket.session.set({
|
|
46
|
+
refusal: {
|
|
47
|
+
code: reason,
|
|
48
|
+
retryable: false,
|
|
49
|
+
reauthorizationOffered: reason === 'revoked-authorization',
|
|
50
|
+
refusal: provider,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
journal.record(`connection refused ${reason}`);
|
|
54
|
+
emitRefusal(runtime);
|
|
55
|
+
}
|
|
56
|
+
}
|
package/dist/replica.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type TypedPath } from '@agentshouse/mdmodel';
|
|
2
|
+
import type { BootstrapInventory, SavedFacts, MutationResult, OperationScopes, ReplicaAdmission, TypedSelection } from './adapter.js';
|
|
2
3
|
import { type ChangeBatch, type Precondition } from './change.js';
|
|
3
4
|
import { type Collection, type Composition } from './collection.js';
|
|
4
5
|
import { type ModelState } from './model.js';
|
|
@@ -22,24 +23,22 @@ export type HeldReplica = {
|
|
|
22
23
|
readonly record: ReplicaRecord;
|
|
23
24
|
readonly queue: readonly ChangeBatch[];
|
|
24
25
|
readonly overlaid: ReadonlySet<string>;
|
|
25
|
-
readonly count: number;
|
|
26
|
-
readonly confirmed: number;
|
|
27
|
-
readonly indexed: boolean;
|
|
28
26
|
};
|
|
29
27
|
export type VisibleLayer = Layer & {
|
|
30
28
|
readonly collection: Collection;
|
|
31
29
|
};
|
|
32
30
|
export type Slice = Layer & {
|
|
33
31
|
readonly written: Readonly<Record<string, string>>;
|
|
32
|
+
readonly facts: Readonly<Record<string, SavedFacts>>;
|
|
34
33
|
readonly held: ReadonlySet<string>;
|
|
35
34
|
};
|
|
36
|
-
export declare function compositionOf(record: Pick<ReplicaRecord, 'model' | 'typedSelection'>, builtIn: ModelState): Composition;
|
|
37
|
-
export declare function sameMembership(record: Pick<ReplicaRecord, 'typedSelection'>, other: Pick<ReplicaRecord, 'typedSelection'>): boolean;
|
|
35
|
+
export declare function compositionOf(record: Pick<ReplicaRecord, 'model' | 'typedSelection'>, builtIn: ModelState, typedPaths: readonly TypedPath[]): Composition;
|
|
38
36
|
export declare function storedRecord(record: ReplicaRecord): string;
|
|
39
37
|
export declare function slicing(entries: readonly HeldEntry[], paths: Iterable<string>): Generator<number, Slice, void>;
|
|
38
|
+
export type LayerEntry = Omit<StoredEntry, 'facts'>;
|
|
40
39
|
export declare function entryAt(layer: Layer & {
|
|
41
40
|
readonly written?: Readonly<Record<string, string>>;
|
|
42
|
-
}, path: string):
|
|
41
|
+
}, path: string): LayerEntry | null;
|
|
43
42
|
export declare function slicingWith(slice: Slice, set: readonly StoredEntry[], removed: readonly string[]): Generator<number, Slice, void>;
|
|
44
43
|
export declare function touchedBy(queue: readonly ChangeBatch[]): Set<string>;
|
|
45
44
|
export declare function movedBy(queue: readonly ChangeBatch[], locator: string): Set<string>;
|
|
@@ -48,7 +47,7 @@ export type Replayed = {
|
|
|
48
47
|
readonly touched: ReadonlySet<string>;
|
|
49
48
|
};
|
|
50
49
|
export declare function replaying(confirmed: Slice, queue: readonly ChangeBatch[], locator: string, composition: Composition): Generator<number, Replayed, void>;
|
|
51
|
-
export declare function overlayOf(visible:
|
|
50
|
+
export declare function overlayOf(visible: VisibleLayer, touched: Iterable<string>): Generator<number, OverlayEntry[], void>;
|
|
52
51
|
export declare function holds(layer: Layer, preconditions: readonly Precondition[]): boolean;
|
|
53
52
|
export declare function landed(batch: ChangeBatch, confirmed: Layer, current?: Readonly<Record<string, string>>): boolean;
|
|
54
53
|
export type Standing = {
|
|
@@ -64,6 +63,6 @@ export type Returned = {
|
|
|
64
63
|
readonly removed: readonly string[];
|
|
65
64
|
};
|
|
66
65
|
export declare function returnedPaths(submitted: ChangeBatch, accepted: Accepted): Set<string>;
|
|
67
|
-
export declare function returning(confirmed: Slice, submitted: ChangeBatch, accepted: Accepted, writtenAt: string): Generator<number, Returned, void>;
|
|
66
|
+
export declare function returning(confirmed: Slice, submitted: ChangeBatch, accepted: Accepted, writtenAt: string, composition: Composition): Generator<number, Returned, void>;
|
|
68
67
|
export {};
|
|
69
68
|
//# sourceMappingURL=replica.d.ts.map
|
package/dist/replica.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replica.d.ts","sourceRoot":"","sources":["../src/replica.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"replica.d.ts","sourceRoot":"","sources":["../src/replica.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACxF,OAAO,KAAK,EACV,kBAAkB,EAClB,UAAU,EAEV,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,cAAc,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAmC,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EAAgB,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAClF,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAiD,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAIzF,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAGxE,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,cAAc,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/C,QAAQ,CAAC,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAC;IACvC,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C,OAAO,CAwBT;AAgBD,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,SAAS,EAAE,SAAS,WAAW,EAAE,CAAC;IAC3C,QAAQ,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,CAAC;CACvC,CAAC;AAEF,wBAAiB,QAAQ,CACvB,SAAS,EAAE,KAAK,EAChB,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,YAAY,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,EAC7C,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,WAAW,GACvB,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,CA4BnC;AAED,KAAK,QAAQ,GAAG,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CAAC;AAE9D,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,GAAG,EAAE,SAAS,WAAW,EAAE,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC,CAAC;AAEF,wBAAgB,aAAa,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,CAiBrF;AAED,wBAAiB,SAAS,CACxB,SAAS,EAAE,KAAK,EAChB,SAAS,EAAE,WAAW,EACtB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,WAAW,GACvB,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,CA6FnC"}
|
package/dist/replica.js
CHANGED
|
@@ -3,20 +3,19 @@ import { immutable, landing } from './change.js';
|
|
|
3
3
|
import { collectionOf } from './collection.js';
|
|
4
4
|
import { storedModel } from './model.js';
|
|
5
5
|
import { acceptedBinaries, overlaying } from './overlay.js';
|
|
6
|
+
import { writtenFacts } from './rows.js';
|
|
6
7
|
import { effectiveIn, rewriting } from './save.js';
|
|
8
|
+
import { guarding } from './shared.js';
|
|
7
9
|
import { ROW_WEIGHT } from './turn.js';
|
|
8
|
-
export function compositionOf(record, builtIn) {
|
|
10
|
+
export function compositionOf(record, builtIn, typedPaths) {
|
|
9
11
|
return {
|
|
10
12
|
model: record.model,
|
|
11
13
|
selection: record.typedSelection === null
|
|
12
14
|
? null
|
|
13
15
|
: { roots: record.typedSelection.roots, model: builtIn },
|
|
16
|
+
typedPaths,
|
|
14
17
|
};
|
|
15
18
|
}
|
|
16
|
-
export function sameMembership(record, other) {
|
|
17
|
-
return (JSON.stringify(record.typedSelection?.roots ?? null) ===
|
|
18
|
-
JSON.stringify(other.typedSelection?.roots ?? null));
|
|
19
|
-
}
|
|
20
19
|
export function storedRecord(record) {
|
|
21
20
|
const { key: _key, ...stored } = record;
|
|
22
21
|
return JSON.stringify({ ...stored, model: storedModel(stored.model) });
|
|
@@ -39,7 +38,7 @@ function strict(values, held) {
|
|
|
39
38
|
throw new UnreadPath(property);
|
|
40
39
|
}
|
|
41
40
|
};
|
|
42
|
-
return
|
|
41
|
+
return guarding(values, {
|
|
43
42
|
get(target, property, receiver) {
|
|
44
43
|
guard(property);
|
|
45
44
|
return Reflect.get(target, property, receiver);
|
|
@@ -62,9 +61,13 @@ export function* slicing(entries, paths) {
|
|
|
62
61
|
const binaries = {};
|
|
63
62
|
const revisions = {};
|
|
64
63
|
const fileIds = {};
|
|
64
|
+
const created = {};
|
|
65
65
|
const changes = {};
|
|
66
66
|
const written = {};
|
|
67
|
+
const facts = {};
|
|
67
68
|
for (const entry of entries) {
|
|
69
|
+
if (entry.facts !== null)
|
|
70
|
+
facts[entry.path] = entry.facts;
|
|
68
71
|
if (entry.binary !== null)
|
|
69
72
|
binaries[entry.path] = entry.binary;
|
|
70
73
|
else if (entry.content !== null)
|
|
@@ -73,6 +76,8 @@ export function* slicing(entries, paths) {
|
|
|
73
76
|
revisions[entry.path] = entry.revision;
|
|
74
77
|
if (entry.fileId !== null)
|
|
75
78
|
fileIds[entry.path] = entry.fileId;
|
|
79
|
+
if (entry.created !== null)
|
|
80
|
+
created[entry.path] = entry.created;
|
|
76
81
|
if (entry.change !== null)
|
|
77
82
|
changes[entry.path] = entry.change;
|
|
78
83
|
if (entry.written !== null)
|
|
@@ -84,8 +89,10 @@ export function* slicing(entries, paths) {
|
|
|
84
89
|
binaries: strict(binaries, held),
|
|
85
90
|
revisions: strict(revisions, held),
|
|
86
91
|
fileIds: strict(fileIds, held),
|
|
92
|
+
created: strict(created, held),
|
|
87
93
|
changes: strict(changes, held),
|
|
88
94
|
written: strict(written, held),
|
|
95
|
+
facts: strict(facts, held),
|
|
89
96
|
held,
|
|
90
97
|
};
|
|
91
98
|
}
|
|
@@ -100,6 +107,7 @@ export function entryAt(layer, path) {
|
|
|
100
107
|
binary: binary ?? null,
|
|
101
108
|
revision: layer.revisions[path] ?? null,
|
|
102
109
|
fileId: layer.fileIds[path] ?? null,
|
|
110
|
+
created: layer.created[path] ?? null,
|
|
103
111
|
change: layer.changes[path] ?? null,
|
|
104
112
|
written: layer.written?.[path] ?? null,
|
|
105
113
|
};
|
|
@@ -108,8 +116,9 @@ export function* slicingWith(slice, set, removed) {
|
|
|
108
116
|
const entries = new Map();
|
|
109
117
|
for (const path of slice.held) {
|
|
110
118
|
const entry = entryAt(slice, path);
|
|
111
|
-
if (entry !== null)
|
|
112
|
-
entries.set(path, { ...entry, type: null });
|
|
119
|
+
if (entry !== null) {
|
|
120
|
+
entries.set(path, { ...entry, type: null, facts: slice.facts[path] ?? null });
|
|
121
|
+
}
|
|
113
122
|
yield ROW_WEIGHT;
|
|
114
123
|
}
|
|
115
124
|
for (const path of removed)
|
|
@@ -173,8 +182,9 @@ export function* replaying(confirmed, queue, locator, composition) {
|
|
|
173
182
|
export function* overlayOf(visible, touched) {
|
|
174
183
|
const rows = [];
|
|
175
184
|
for (const path of touched) {
|
|
176
|
-
yield ROW_WEIGHT;
|
|
177
185
|
const entry = entryAt(visible, path);
|
|
186
|
+
yield ROW_WEIGHT + (entry?.content?.length ?? 0);
|
|
187
|
+
const text = entry?.binary === null ? entry.content : null;
|
|
178
188
|
rows.push(entry === null
|
|
179
189
|
? {
|
|
180
190
|
path,
|
|
@@ -183,10 +193,17 @@ export function* overlayOf(visible, touched) {
|
|
|
183
193
|
binary: null,
|
|
184
194
|
revision: null,
|
|
185
195
|
fileId: null,
|
|
196
|
+
created: null,
|
|
186
197
|
change: null,
|
|
187
198
|
written: null,
|
|
199
|
+
facts: null,
|
|
188
200
|
}
|
|
189
|
-
: {
|
|
201
|
+
: {
|
|
202
|
+
...entry,
|
|
203
|
+
written: null,
|
|
204
|
+
present: true,
|
|
205
|
+
facts: text === null ? null : writtenFacts(path, text, visible.collection.composition),
|
|
206
|
+
});
|
|
190
207
|
}
|
|
191
208
|
return rows;
|
|
192
209
|
}
|
|
@@ -351,17 +368,20 @@ export function returnedPaths(submitted, accepted) {
|
|
|
351
368
|
}
|
|
352
369
|
return paths;
|
|
353
370
|
}
|
|
354
|
-
export function* returning(confirmed, submitted, accepted, writtenAt) {
|
|
371
|
+
export function* returning(confirmed, submitted, accepted, writtenAt, composition) {
|
|
355
372
|
const documents = new Map();
|
|
356
373
|
const binaries = new Map();
|
|
357
374
|
const revisions = new Map();
|
|
358
375
|
const fileIds = new Map();
|
|
376
|
+
const created = new Map();
|
|
359
377
|
const changes = new Map();
|
|
360
378
|
const written = new Map();
|
|
379
|
+
const facts = new Map();
|
|
361
380
|
const read = (changed, held, path) => (changed.has(path) ? changed.get(path) : held[path]);
|
|
362
381
|
for (const [path, content] of Object.entries(accepted.documents)) {
|
|
363
|
-
yield ROW_WEIGHT;
|
|
382
|
+
yield ROW_WEIGHT + content.length;
|
|
364
383
|
documents.set(path, content);
|
|
384
|
+
facts.set(path, writtenFacts(path, content, composition));
|
|
365
385
|
fileIds.set(path, undefined);
|
|
366
386
|
written.set(path, writtenAt);
|
|
367
387
|
}
|
|
@@ -384,48 +404,60 @@ export function* returning(confirmed, submitted, accepted, writtenAt) {
|
|
|
384
404
|
written.set(path, undefined);
|
|
385
405
|
}
|
|
386
406
|
for (const change of submitted.changes) {
|
|
387
|
-
if (change.kind === 'arrival'
|
|
388
|
-
if (accepted.revisions[change.path]
|
|
407
|
+
if (change.kind === 'arrival') {
|
|
408
|
+
if (accepted.revisions[change.path] === undefined)
|
|
409
|
+
continue;
|
|
410
|
+
created.set(change.path, change.created);
|
|
411
|
+
if ('binary' in change)
|
|
389
412
|
binaries.set(change.path, { state: 'accepted', ...change.binary });
|
|
390
|
-
}
|
|
391
413
|
continue;
|
|
392
414
|
}
|
|
393
|
-
if (change.kind !== 'move')
|
|
415
|
+
if (change.kind !== 'move' || accepted.revisions[change.to] === undefined)
|
|
394
416
|
continue;
|
|
417
|
+
created.set(change.to, read(created, confirmed.created, change.path));
|
|
418
|
+
created.set(change.path, undefined);
|
|
395
419
|
const moved = read(binaries, confirmed.binaries, change.path);
|
|
396
|
-
if (moved === undefined
|
|
420
|
+
if (moved === undefined)
|
|
397
421
|
continue;
|
|
398
422
|
binaries.set(change.to, moved);
|
|
399
423
|
binaries.set(change.path, undefined);
|
|
400
424
|
}
|
|
401
425
|
for (const [path, binary] of acceptedBinaries(accepted.binaryFiles ?? {}))
|
|
402
426
|
binaries.set(path, binary);
|
|
403
|
-
for (const path of accepted.removals)
|
|
427
|
+
for (const path of accepted.removals) {
|
|
404
428
|
binaries.set(path, undefined);
|
|
429
|
+
created.set(path, undefined);
|
|
430
|
+
}
|
|
405
431
|
const paths = new Set([
|
|
406
432
|
...documents.keys(),
|
|
407
433
|
...binaries.keys(),
|
|
408
434
|
...revisions.keys(),
|
|
409
435
|
...fileIds.keys(),
|
|
436
|
+
...created.keys(),
|
|
410
437
|
...changes.keys(),
|
|
411
438
|
...written.keys(),
|
|
412
439
|
]);
|
|
413
440
|
const set = [];
|
|
414
441
|
const removed = [];
|
|
415
442
|
for (const path of paths) {
|
|
416
|
-
yield ROW_WEIGHT;
|
|
417
443
|
const content = read(documents, confirmed.documents, path);
|
|
418
444
|
const binary = read(binaries, confirmed.binaries, path);
|
|
445
|
+
yield ROW_WEIGHT;
|
|
419
446
|
if (content === undefined && binary === undefined) {
|
|
420
447
|
removed.push(path);
|
|
421
448
|
continue;
|
|
422
449
|
}
|
|
450
|
+
const text = binary === undefined ? (content ?? null) : null;
|
|
451
|
+
const fresh = confirmed.documents[path] === undefined && confirmed.binaries[path] === undefined;
|
|
423
452
|
set.push({
|
|
424
453
|
path,
|
|
425
|
-
content:
|
|
454
|
+
content: text,
|
|
455
|
+
facts: text === null ? null : (read(facts, confirmed.facts, path) ?? null),
|
|
426
456
|
binary: binary ?? null,
|
|
427
457
|
revision: read(revisions, confirmed.revisions, path) ?? null,
|
|
428
458
|
fileId: read(fileIds, confirmed.fileIds, path) ?? null,
|
|
459
|
+
created: read(created, confirmed.created, path) ??
|
|
460
|
+
(fresh ? (read(changes, confirmed.changes, path)?.time ?? null) : null),
|
|
429
461
|
change: read(changes, confirmed.changes, path) ?? null,
|
|
430
462
|
written: read(written, confirmed.written, path) ?? null,
|
|
431
463
|
});
|
package/dist/room-draft.d.ts
CHANGED
|
@@ -90,9 +90,9 @@ type ChangedUnderneath = {
|
|
|
90
90
|
readonly file?: string | null;
|
|
91
91
|
};
|
|
92
92
|
export type ReturnReason = ProviderRefusal & {
|
|
93
|
-
readonly kind: Open<'conflicted' | 'rejected' | '
|
|
93
|
+
readonly kind: Open<'conflicted' | 'rejected' | 'withdrawn'>;
|
|
94
94
|
};
|
|
95
|
-
export declare function returnedBy(kind: '
|
|
95
|
+
export declare function returnedBy(kind: 'withdrawn'): ReturnReason;
|
|
96
96
|
export type RoomDraft = {
|
|
97
97
|
readonly room: string;
|
|
98
98
|
readonly path: string;
|
|
@@ -127,13 +127,14 @@ export type SavedDraft = {
|
|
|
127
127
|
readonly path: string;
|
|
128
128
|
readonly parts: HeldParts;
|
|
129
129
|
};
|
|
130
|
-
export declare function readParts(value: unknown): RoomDraftParts;
|
|
130
|
+
export declare function readParts(value: unknown, path: string): RoomDraftParts;
|
|
131
131
|
export declare function gatheredParts(earlier: unknown, later: unknown): unknown;
|
|
132
132
|
export declare function held(current: HeldParts | undefined, parts: RoomDraftParts, file?: HeldFile): HeldParts;
|
|
133
133
|
export declare function underneath(parts: HeldParts, path: string, visible: VisibleLayer | undefined): ChangedUnderneath;
|
|
134
134
|
export declare function heldFile(blob: Blob, base: string | null): Promise<HeldFile>;
|
|
135
135
|
export declare function binaryBase(visible: VisibleLayer | undefined, path: string): string | null;
|
|
136
136
|
export declare function changedParts(path: string, parts: HeldParts, visible: VisibleLayer | undefined): readonly ChangedPart[];
|
|
137
|
+
export declare function lineEnded(text: string): string;
|
|
137
138
|
export type TextParts = {
|
|
138
139
|
readonly fields?: Readonly<Record<string, {
|
|
139
140
|
readonly value: unknown;
|
package/dist/room-draft.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"room-draft.d.ts","sourceRoot":"","sources":["../src/room-draft.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAAC;AAE5D,MAAM,MAAM,iBAAiB,GACzB;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC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,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,aAAa,EAAE,SAAS,YAAY,EAAE,CAAA;CAAE,CAgB1F;AAED,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,GACf;IAAE,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAA;CAAE,CA2ChE;AAkBD,wBAAgB,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,UAAU,EAAE,GAAG,UAAU,CAkBzF;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,SAAS,UAAU,EAAE,EAC7B,OAAO,EAAE,SAAS,MAAM,EAAE,GACzB,SAAS,UAAU,EAAE,CAqBvB"}
|
package/dist/room-draft.js
CHANGED
|
@@ -9,52 +9,60 @@ export function returnedBy(kind) {
|
|
|
9
9
|
export function staleWrite(current) {
|
|
10
10
|
return { outcome: 'stale', code: 'stale', retryable: false, current };
|
|
11
11
|
}
|
|
12
|
-
function malformed() {
|
|
13
|
-
throw runtimeError('room-draft-malformed');
|
|
12
|
+
function malformed(at, needs) {
|
|
13
|
+
throw runtimeError('room-draft-malformed', at === undefined ? 'room-draft-malformed' : `room-draft-malformed at ${at}: ${needs}`);
|
|
14
14
|
}
|
|
15
15
|
function plain(value) {
|
|
16
16
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
17
17
|
}
|
|
18
|
-
function text(value) {
|
|
19
|
-
return typeof value === 'string' ? value : malformed();
|
|
18
|
+
function text(value, at) {
|
|
19
|
+
return typeof value === 'string' ? value : malformed(at, 'text');
|
|
20
20
|
}
|
|
21
|
-
function optionalText(value) {
|
|
22
|
-
return value === undefined ? undefined : text(value);
|
|
21
|
+
function optionalText(value, at) {
|
|
22
|
+
return value === undefined ? undefined : text(value, at);
|
|
23
23
|
}
|
|
24
|
-
function markdownBase(value) {
|
|
25
|
-
return value === null ? null : optionalText(value);
|
|
24
|
+
function markdownBase(value, at) {
|
|
25
|
+
return value === null ? null : optionalText(value, at);
|
|
26
26
|
}
|
|
27
|
-
function entries(value, each) {
|
|
27
|
+
function entries(value, at, each) {
|
|
28
28
|
if (!plain(value))
|
|
29
|
-
malformed();
|
|
29
|
+
malformed(at, 'an object of named values');
|
|
30
30
|
const read = {};
|
|
31
31
|
for (const [name, item] of Object.entries(value))
|
|
32
|
-
read[name] = each(item);
|
|
32
|
+
read[name] = each(item, `${at}.${name}`);
|
|
33
33
|
return read;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function frontmatter(item, at) {
|
|
36
|
+
return frontmatterValue(item) ? item : malformed(at, 'a frontmatter value');
|
|
37
|
+
}
|
|
38
|
+
function fieldValue(value, at) {
|
|
36
39
|
if (value === null)
|
|
37
40
|
return null;
|
|
38
41
|
if (!plain(value) || !Object.hasOwn(value, 'value') || !frontmatterValue(value.value)) {
|
|
39
|
-
malformed();
|
|
42
|
+
malformed(at, '{ value } with a frontmatter value, or null where the document lacks it');
|
|
40
43
|
}
|
|
41
44
|
return { value: value.value };
|
|
42
45
|
}
|
|
43
|
-
function textPart(value) {
|
|
46
|
+
function textPart(value, at) {
|
|
44
47
|
if (!plain(value))
|
|
45
|
-
malformed();
|
|
46
|
-
const base = optionalText(value.base);
|
|
47
|
-
return { value: text(value.value), ...(base === undefined ? {} : { base }) };
|
|
48
|
+
malformed(at, '{ value, base }');
|
|
49
|
+
const base = optionalText(value.base, `${at}.base`);
|
|
50
|
+
return { value: text(value.value, `${at}.value`), ...(base === undefined ? {} : { base }) };
|
|
48
51
|
}
|
|
49
|
-
function creationOf(value) {
|
|
52
|
+
function creationOf(value, at) {
|
|
50
53
|
if (!plain(value))
|
|
51
|
-
malformed();
|
|
54
|
+
malformed(at, '{ type, fields, sections }, or { markdown }');
|
|
52
55
|
if (Object.hasOwn(value, 'markdown'))
|
|
53
|
-
return { markdown: text(value.markdown) };
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
return { markdown: text(value.markdown, `${at}.markdown`) };
|
|
57
|
+
if (typeof value.type !== 'string')
|
|
58
|
+
malformed(`${at}.type`, 'a type name, or markdown in place of type, fields and sections');
|
|
59
|
+
return {
|
|
60
|
+
type: value.type,
|
|
61
|
+
fields: entries(value.fields, `${at}.fields`, frontmatter),
|
|
62
|
+
sections: entries(value.sections, `${at}.sections`, text),
|
|
63
|
+
};
|
|
56
64
|
}
|
|
57
|
-
const PART_NAMES =
|
|
65
|
+
const PART_NAMES = [
|
|
58
66
|
'fields',
|
|
59
67
|
'sections',
|
|
60
68
|
'preamble',
|
|
@@ -63,52 +71,56 @@ const PART_NAMES = new Set([
|
|
|
63
71
|
'move',
|
|
64
72
|
'removal',
|
|
65
73
|
'file',
|
|
66
|
-
]
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
];
|
|
75
|
+
const NAMED_PARTS = `a part named ${PART_NAMES.slice(0, -1).join(', ')} or ${PART_NAMES.at(-1)}`;
|
|
76
|
+
export function readParts(value, path) {
|
|
77
|
+
if (!plain(value))
|
|
78
|
+
malformed(path, 'an object of parts');
|
|
79
|
+
const unknown = Object.keys(value).find((name) => !PART_NAMES.includes(name));
|
|
80
|
+
if (unknown !== undefined)
|
|
81
|
+
malformed(`${path} ${unknown}`, NAMED_PARTS);
|
|
70
82
|
const parts = {};
|
|
71
83
|
if (value.fields !== undefined) {
|
|
72
|
-
parts.fields = entries(value.fields, (item) => {
|
|
84
|
+
parts.fields = entries(value.fields, `${path} fields`, (item, at) => {
|
|
73
85
|
if (!plain(item) || !Object.hasOwn(item, 'value') || !frontmatterValue(item.value)) {
|
|
74
|
-
malformed();
|
|
86
|
+
malformed(at, '{ value, base } with a frontmatter value');
|
|
75
87
|
}
|
|
76
88
|
return item.base === undefined
|
|
77
89
|
? { value: item.value }
|
|
78
|
-
: { value: item.value, base: fieldValue(item.base) };
|
|
90
|
+
: { value: item.value, base: fieldValue(item.base, `${at}.base`) };
|
|
79
91
|
});
|
|
80
92
|
}
|
|
81
93
|
if (value.sections !== undefined)
|
|
82
|
-
parts.sections = entries(value.sections, textPart);
|
|
94
|
+
parts.sections = entries(value.sections, `${path} sections`, textPart);
|
|
83
95
|
if (value.preamble !== undefined)
|
|
84
|
-
parts.preamble = textPart(value.preamble);
|
|
96
|
+
parts.preamble = textPart(value.preamble, `${path} preamble`);
|
|
85
97
|
if (value.markdown !== undefined)
|
|
86
|
-
parts.markdown = textPart(value.markdown);
|
|
98
|
+
parts.markdown = textPart(value.markdown, `${path} markdown`);
|
|
87
99
|
if (value.creation !== undefined)
|
|
88
|
-
parts.creation = creationOf(value.creation);
|
|
100
|
+
parts.creation = creationOf(value.creation, `${path} creation`);
|
|
89
101
|
if (value.move !== undefined) {
|
|
90
102
|
if (!plain(value.move))
|
|
91
|
-
malformed();
|
|
92
|
-
const base = markdownBase(value.move.base);
|
|
93
|
-
const room = optionalText(value.move.room);
|
|
103
|
+
malformed(`${path} move`, '{ to, room, base }');
|
|
104
|
+
const base = markdownBase(value.move.base, `${path} move.base`);
|
|
105
|
+
const room = optionalText(value.move.room, `${path} move.room`);
|
|
94
106
|
parts.move = {
|
|
95
|
-
to: text(value.move.to),
|
|
107
|
+
to: text(value.move.to, `${path} move.to`),
|
|
96
108
|
...(room === undefined ? {} : { room }),
|
|
97
109
|
...(base === undefined ? {} : { base }),
|
|
98
110
|
};
|
|
99
111
|
}
|
|
100
112
|
if (value.removal !== undefined) {
|
|
101
113
|
if (!plain(value.removal))
|
|
102
|
-
malformed();
|
|
103
|
-
const base = markdownBase(value.removal.base);
|
|
114
|
+
malformed(`${path} removal`, '{ base }');
|
|
115
|
+
const base = markdownBase(value.removal.base, `${path} removal.base`);
|
|
104
116
|
parts.removal = base === undefined ? {} : { base };
|
|
105
117
|
}
|
|
106
118
|
if (value.file !== undefined) {
|
|
107
119
|
if (!plain(value.file) || !(value.file.blob instanceof Blob))
|
|
108
|
-
malformed();
|
|
120
|
+
malformed(`${path} file`, '{ blob, base } with a Blob');
|
|
109
121
|
if (Object.keys(value).length > 1)
|
|
110
122
|
throw runtimeError('room-draft-file-exclusive');
|
|
111
|
-
const base = markdownBase(value.file.base);
|
|
123
|
+
const base = markdownBase(value.file.base, `${path} file.base`);
|
|
112
124
|
parts.file = base === undefined ? { blob: value.file.blob } : { blob: value.file.blob, base };
|
|
113
125
|
}
|
|
114
126
|
return parts;
|
|
@@ -318,7 +330,7 @@ function joined(existing, returned) {
|
|
|
318
330
|
merged[name] = part;
|
|
319
331
|
return Object.keys(merged).length === 0 ? undefined : merged;
|
|
320
332
|
}
|
|
321
|
-
function
|
|
333
|
+
export function lineEnded(text) {
|
|
322
334
|
return text === '' || text.endsWith('\n') ? text : `${text}\n`;
|
|
323
335
|
}
|
|
324
336
|
function frontmatterOf(fields) {
|
|
@@ -342,7 +354,7 @@ export function partsAfter(markdown, parts) {
|
|
|
342
354
|
];
|
|
343
355
|
if (pieces.length === 0)
|
|
344
356
|
return markdown;
|
|
345
|
-
return `${
|
|
357
|
+
return `${lineEnded(markdown)}\n${pieces.map(lineEnded).join('')}`;
|
|
346
358
|
}
|
|
347
359
|
export function returnedInto(existing, returned) {
|
|
348
360
|
if (existing === undefined)
|
|
@@ -386,12 +398,13 @@ export function moveTarget(move) {
|
|
|
386
398
|
return to === null || to === '' ? move.to : to;
|
|
387
399
|
}
|
|
388
400
|
export function readSavedParts(named) {
|
|
389
|
-
const read = named.map(({ path, parts }) => ({ path, parts: readParts(parts) }));
|
|
390
|
-
|
|
391
|
-
normalize(path) !== path
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
401
|
+
const read = named.map(({ path, parts }) => ({ path, parts: readParts(parts, path) }));
|
|
402
|
+
read.forEach(({ path }, at) => {
|
|
403
|
+
if (path === '' || normalize(path) !== path)
|
|
404
|
+
malformed(path, 'a path inside the Room, such as notes/a.md');
|
|
405
|
+
if (read.findIndex((one) => one.path === path) !== at)
|
|
406
|
+
malformed(path, 'each path once in one save');
|
|
407
|
+
});
|
|
395
408
|
return read;
|
|
396
409
|
}
|
|
397
410
|
export function partsChanges(named) {
|
|
@@ -433,11 +446,11 @@ export function changesOf(path, parts) {
|
|
|
433
446
|
bases.push({ kind: 'field', path, name, value: part.base?.value });
|
|
434
447
|
}
|
|
435
448
|
for (const [name, part] of named(parts.sections)) {
|
|
436
|
-
changes.push({ kind: 'section', path, name, value: part.value });
|
|
449
|
+
changes.push({ kind: 'section', path, name, value: lineEnded(part.value) });
|
|
437
450
|
bases.push({ kind: 'section', path, name, value: part.base });
|
|
438
451
|
}
|
|
439
452
|
if (parts.preamble !== undefined) {
|
|
440
|
-
changes.push({ kind: 'preamble', path, value: parts.preamble.value });
|
|
453
|
+
changes.push({ kind: 'preamble', path, value: lineEnded(parts.preamble.value) });
|
|
441
454
|
bases.push({ kind: 'preamble', path, value: parts.preamble.base });
|
|
442
455
|
}
|
|
443
456
|
if (parts.markdown !== undefined) {
|
|
@@ -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
|