@agentshouse/mdruntime 0.1.0-cbbae1fff01c6 → 0.1.0-cc00e9289ddf4
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 +17 -15
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +14 -23
- package/dist/act-lanes.d.ts +30 -0
- package/dist/act-lanes.d.ts.map +1 -0
- package/dist/act-lanes.js +225 -0
- package/dist/actions.d.ts +8 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +114 -63
- package/dist/adapter.d.ts +30 -12
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +0 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +0 -5
- package/dist/chat-types.d.ts +0 -2
- package/dist/chat-types.d.ts.map +1 -1
- package/dist/chat-types.js +0 -2
- package/dist/client.d.ts +8 -18
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +27 -15
- package/dist/compile.d.ts +2 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +17 -4
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +15 -13
- package/dist/conversation-live.d.ts +23 -8
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +21 -9
- package/dist/conversation-row.d.ts +2 -0
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +2 -0
- package/dist/conversation.d.ts +27 -5
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +279 -168
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +8 -6
- package/dist/durability.d.ts +4 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +4 -0
- package/dist/entry.js +1 -1
- package/dist/expectation.d.ts +25 -14
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +51 -20
- package/dist/failure.d.ts +2 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +3 -0
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +4 -2
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +2 -1
- package/dist/host.d.ts +1 -0
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +39 -11
- package/dist/index.d.ts +11 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -6
- package/dist/install.d.ts +10 -4
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +45 -46
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +22 -16
- package/dist/listing.d.ts +7 -3
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +26 -13
- package/dist/live.d.ts +5 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +71 -30
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +2 -3
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +2 -3
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +7 -10
- package/dist/memory.d.ts +3 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +50 -22
- package/dist/messages.d.ts +12 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +24 -10
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +5 -8
- package/dist/observation.d.ts +27 -12
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +173 -69
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +3 -9
- package/dist/outcome.d.ts +7 -0
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +23 -2
- package/dist/overlay.d.ts +3 -0
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +8 -4
- 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 +2 -9
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +6 -14
- package/dist/preparation.d.ts +27 -6
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +137 -56
- package/dist/presence.d.ts +7 -1
- package/dist/presence.d.ts.map +1 -1
- package/dist/presence.js +22 -9
- package/dist/queries.d.ts +2 -2
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +62 -24
- package/dist/questions.d.ts +0 -5
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +0 -7
- package/dist/queue.d.ts +2 -2
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +25 -30
- package/dist/reach.d.ts +2 -3
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +75 -21
- package/dist/react.d.ts +7 -5
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +28 -5
- package/dist/readiness.d.ts +9 -3
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +3 -5
- package/dist/reads.d.ts +3 -1
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +5 -1
- package/dist/recovery.d.ts +3 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +29 -7
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +1 -3
- package/dist/retried.d.ts +30 -0
- package/dist/retried.d.ts.map +1 -0
- package/dist/retried.js +72 -0
- package/dist/room-draft.d.ts +2 -2
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +26 -21
- package/dist/rows.d.ts +2 -0
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +3 -0
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +1 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +105 -55
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +3 -6
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +2 -2
- package/dist/shown.d.ts +3 -2
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +58 -39
- package/dist/socket/lanes.d.ts +12 -4
- package/dist/socket/lanes.d.ts.map +1 -1
- package/dist/socket/lanes.js +34 -8
- package/dist/socket.d.ts +3 -3
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +3 -9
- package/dist/source.d.ts +0 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/store/installs.d.ts +2 -2
- package/dist/store/installs.d.ts.map +1 -1
- package/dist/store/installs.js +10 -4
- package/dist/store/readiness.d.ts +5 -4
- package/dist/store/readiness.d.ts.map +1 -1
- package/dist/store/readiness.js +28 -12
- package/dist/store/records.d.ts +11 -4
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +56 -20
- package/dist/store/rooms-shown.d.ts +8 -0
- package/dist/store/rooms-shown.d.ts.map +1 -0
- package/dist/store/rooms-shown.js +13 -0
- package/dist/store.d.ts +9 -6
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +11 -2
- package/dist/stored.d.ts +24 -13
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +73 -17
- package/dist/surface.d.ts +4 -3
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +12 -13
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +31 -17
- package/dist/tables.d.ts +14 -7
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +36 -15
- package/dist/tallies.d.ts.map +1 -1
- package/dist/tallies.js +1 -2
- package/dist/wire.d.ts +40 -3
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +11 -1
- package/package.json +3 -3
- 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 -5
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -7
- package/dist/log.d.ts +0 -6
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
package/dist/models.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;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OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,EAC1C,MAAM,EAAE,SAAS,GAAG,QAAQ,EAC5B,KAAK,EAAE,YAAY,iBAkDpB;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBvF"}
|
package/dist/models.js
CHANGED
|
@@ -35,7 +35,7 @@ function recordAlone(store, record) {
|
|
|
35
35
|
}
|
|
36
36
|
function unheld(runtime, locator, model) {
|
|
37
37
|
runtime.presence.modelled(locator, model);
|
|
38
|
-
emitRooms(runtime);
|
|
38
|
+
emitRooms(runtime, [locator]);
|
|
39
39
|
}
|
|
40
40
|
function recorded(runtime, locator, declaration, model) {
|
|
41
41
|
const { store, socket } = runtime;
|
|
@@ -84,9 +84,8 @@ export async function retainModel(runtime, locator, declaration, given, refused)
|
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
export async function scoped(runtime, result, locator, declaration) {
|
|
87
|
-
const { socket, presence
|
|
87
|
+
const { socket, presence } = runtime;
|
|
88
88
|
if (result.scope === 'content' && !result.retryable) {
|
|
89
|
-
journal.record(`scoped refusal ${locator} ${result.scope} ${result.code}`);
|
|
90
89
|
await loseRooms(runtime, [locator]);
|
|
91
90
|
return;
|
|
92
91
|
}
|
|
@@ -95,11 +94,10 @@ export async function scoped(runtime, result, locator, declaration) {
|
|
|
95
94
|
await retainModel(runtime, locator, declaration, { status: 'unavailable', reason: 'not-readable' }, true);
|
|
96
95
|
if (!socket.continuing())
|
|
97
96
|
return;
|
|
98
|
-
emitRooms(runtime);
|
|
99
|
-
journal.record(`scoped refusal ${locator} ${result.scope} ${result.code}`);
|
|
97
|
+
emitRooms(runtime, [locator]);
|
|
100
98
|
}
|
|
101
99
|
export async function settleModels(runtime, held, status, local) {
|
|
102
|
-
const { store, socket, presence
|
|
100
|
+
const { store, socket, presence } = runtime;
|
|
103
101
|
const owed = (model) => model.status !== 'unavailable' && model.status !== status;
|
|
104
102
|
const declaredAnew = await store.exclusive(async () => {
|
|
105
103
|
if (!socket.continuing())
|
|
@@ -121,7 +119,6 @@ export async function settleModels(runtime, held, status, local) {
|
|
|
121
119
|
await local.commit({ rooms: records.map((record) => recordAlone(store, record)) });
|
|
122
120
|
}
|
|
123
121
|
catch (error) {
|
|
124
|
-
journal.record(`model ${status} persistence failed`);
|
|
125
122
|
uncaught(error);
|
|
126
123
|
}
|
|
127
124
|
}
|
|
@@ -132,7 +129,7 @@ export async function settleModels(runtime, held, status, local) {
|
|
|
132
129
|
}
|
|
133
130
|
}
|
|
134
131
|
if (unchanged.length > 0)
|
|
135
|
-
emitRooms(runtime);
|
|
132
|
+
emitRooms(runtime, unchanged.map(([locator]) => locator));
|
|
136
133
|
const kept = new Set(unchanged.map(([locator]) => locator));
|
|
137
134
|
return [...held].filter(([locator]) => !kept.has(locator) &&
|
|
138
135
|
owed(stored.get(locator)?.record.model ?? unheldModelOf(runtime, locator)));
|
package/dist/observation.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { QueryCoverage, QueryDocument, QueryGroup, QueryResult } from './query.js';
|
|
1
|
+
import type { PendingRoom, QueryCoverage, QueryDocument, QueryGroup, QueryResult } from './query.js';
|
|
2
|
+
import type { ReadinessShown, RoomCoverage } from './readiness.js';
|
|
2
3
|
export type Observation<T> = {
|
|
3
4
|
current(): T;
|
|
4
5
|
subscribe(listener: (value: T) => void): () => void;
|
|
@@ -9,15 +10,24 @@ export type KeyedResult = {
|
|
|
9
10
|
result: QueryResult;
|
|
10
11
|
keys: readonly RowKey[];
|
|
11
12
|
};
|
|
12
|
-
export type
|
|
13
|
-
changed: readonly (readonly [
|
|
14
|
-
removed: readonly
|
|
15
|
-
order: readonly
|
|
13
|
+
export type KeyedChange<K, T> = {
|
|
14
|
+
readonly changed: readonly (readonly [K, T])[];
|
|
15
|
+
readonly removed: readonly K[];
|
|
16
|
+
readonly order: readonly K[] | null;
|
|
17
|
+
};
|
|
18
|
+
export type QueryChange = KeyedChange<RowKey, QueryDocument | QueryGroup> & {
|
|
16
19
|
coverage?: QueryCoverage;
|
|
17
20
|
next?: string | null;
|
|
18
21
|
total?: number;
|
|
19
22
|
};
|
|
20
|
-
export type
|
|
23
|
+
export type ReadinessChange = {
|
|
24
|
+
readonly shown: ReadinessShown;
|
|
25
|
+
readonly rooms: KeyedChange<string, RoomCoverage>;
|
|
26
|
+
};
|
|
27
|
+
export type PendingChange = {
|
|
28
|
+
readonly pending: KeyedChange<string, PendingRoom>;
|
|
29
|
+
};
|
|
30
|
+
export type QueryMessage = KeyedResult | QueryChange | PendingChange;
|
|
21
31
|
export type Observed = {
|
|
22
32
|
observation: Observation<unknown>;
|
|
23
33
|
receive(message: unknown): void;
|
|
@@ -25,15 +35,20 @@ export type Observed = {
|
|
|
25
35
|
};
|
|
26
36
|
export declare function rowsOf(result: QueryResult): readonly (QueryDocument | QueryGroup)[];
|
|
27
37
|
export declare function whole(message: QueryMessage): message is KeyedResult;
|
|
28
|
-
export declare function
|
|
29
|
-
export declare function
|
|
30
|
-
export declare function
|
|
38
|
+
export declare function pendingChange(message: QueryMessage): message is PendingChange;
|
|
39
|
+
export declare function unchanged(change: KeyedChange<unknown, unknown>): boolean;
|
|
40
|
+
export declare function keyedChange<K, H, T>(held: ReadonlyMap<K, H>, keys: readonly K[], rows: readonly T[], same: (was: H, now: T) => boolean): KeyedChange<K, T>;
|
|
41
|
+
export declare function keyedAt<K, H, T>(held: ReadonlyMap<K, H>, at: ReadonlyMap<K, T | null>, same: (was: H, now: T) => boolean): KeyedChange<K, T> | null;
|
|
42
|
+
export declare function keyedInto<K, T>(held: Map<K, T>, change: KeyedChange<K, T>): void;
|
|
43
|
+
export declare function samePending(was: PendingRoom, now: PendingRoom): boolean;
|
|
44
|
+
export declare function replaces(topic: string, message: unknown): boolean;
|
|
45
|
+
export declare function observed(first: unknown, stop: () => void, topic: string): Observed;
|
|
46
|
+
export declare function opened(watch: (deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void, topic: string): Promise<Observation<unknown>>;
|
|
31
47
|
export declare function observing<Topic extends string>(watch: (topic: Topic, input: readonly unknown[], deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void): (topic: Topic, ...input: unknown[]) => Promise<Observation<unknown>>;
|
|
32
48
|
export type Digest = {
|
|
33
|
-
readonly pending: string
|
|
49
|
+
readonly pending: Map<string, PendingRoom>;
|
|
34
50
|
} | {
|
|
35
|
-
readonly
|
|
36
|
-
readonly rows: ReadonlyMap<RowKey, number>;
|
|
51
|
+
readonly rows: Map<RowKey, number>;
|
|
37
52
|
readonly coverage: string;
|
|
38
53
|
readonly next: string | undefined;
|
|
39
54
|
readonly total: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../src/observation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../src/observation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,aAAa,EACb,aAAa,EACb,UAAU,EACV,WAAW,EACZ,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAa,cAAc,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9E,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,OAAO,IAAI,CAAC,CAAC;IACb,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACpD,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAErC,MAAM,MAAM,WAAW,GAAG;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAE3E,MAAM,MAA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G,IAAI,CAsBjF"}
|
package/dist/observation.js
CHANGED
|
@@ -6,49 +6,165 @@ export function rowsOf(result) {
|
|
|
6
6
|
export function whole(message) {
|
|
7
7
|
return 'result' in message;
|
|
8
8
|
}
|
|
9
|
-
export function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
const kept =
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
9
|
+
export function pendingChange(message) {
|
|
10
|
+
return 'pending' in message;
|
|
11
|
+
}
|
|
12
|
+
export function unchanged(change) {
|
|
13
|
+
return change.changed.length === 0 && change.removed.length === 0 && change.order === null;
|
|
14
|
+
}
|
|
15
|
+
export function keyedChange(held, keys, rows, same) {
|
|
16
|
+
const present = new Set(keys);
|
|
17
|
+
const changed = keys.flatMap((key, at) => {
|
|
18
|
+
const was = held.get(key);
|
|
19
|
+
return was !== undefined && same(was, rows[at]) ? [] : [[key, rows[at]]];
|
|
20
|
+
});
|
|
21
|
+
const removed = [];
|
|
22
|
+
const kept = [];
|
|
23
|
+
for (const key of held.keys())
|
|
24
|
+
(present.has(key) ? kept : removed).push(key);
|
|
25
|
+
const moved = kept.length !== keys.length || kept.some((key, at) => keys[at] !== key);
|
|
26
|
+
return { changed, removed, order: moved ? keys : null };
|
|
27
|
+
}
|
|
28
|
+
export function keyedAt(held, at, same) {
|
|
29
|
+
const changed = [];
|
|
30
|
+
const removed = [];
|
|
31
|
+
for (const [key, now] of at) {
|
|
32
|
+
const was = held.get(key);
|
|
33
|
+
if (was === undefined) {
|
|
34
|
+
if (now !== null)
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
else if (now === null)
|
|
38
|
+
removed.push(key);
|
|
39
|
+
else if (!same(was, now))
|
|
40
|
+
changed.push([key, now]);
|
|
41
|
+
}
|
|
42
|
+
return { changed, removed, order: null };
|
|
43
|
+
}
|
|
44
|
+
export function keyedInto(held, change) {
|
|
45
|
+
for (const key of change.removed)
|
|
46
|
+
held.delete(key);
|
|
47
|
+
for (const [key, row] of change.changed)
|
|
48
|
+
held.set(key, row);
|
|
49
|
+
if (change.order === null)
|
|
50
|
+
return;
|
|
51
|
+
const placed = change.order.map((key) => [key, held.get(key)]);
|
|
52
|
+
held.clear();
|
|
53
|
+
for (const [key, row] of placed)
|
|
54
|
+
held.set(key, row);
|
|
55
|
+
}
|
|
56
|
+
export function samePending(was, now) {
|
|
57
|
+
return was.awaits === now.awaits;
|
|
58
|
+
}
|
|
59
|
+
function keyedRows(keys, rows) {
|
|
60
|
+
const held = new Map(keys.map((key, at) => [key, rows[at]]));
|
|
61
|
+
let shown = rows;
|
|
62
|
+
return {
|
|
63
|
+
rows: () => shown,
|
|
64
|
+
apply(change) {
|
|
65
|
+
if (unchanged(change))
|
|
66
|
+
return shown;
|
|
67
|
+
keyedInto(held, change);
|
|
68
|
+
shown = [...held.values()];
|
|
69
|
+
return shown;
|
|
70
|
+
},
|
|
29
71
|
};
|
|
72
|
+
}
|
|
73
|
+
function located(rooms) {
|
|
74
|
+
return keyedRows(rooms.map(({ locator }) => locator), rooms);
|
|
75
|
+
}
|
|
76
|
+
function keyedRooms(first) {
|
|
77
|
+
let held = located(first);
|
|
30
78
|
return {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
79
|
+
value: first,
|
|
80
|
+
next(message) {
|
|
81
|
+
if (!Array.isArray(message))
|
|
82
|
+
return held.apply(message);
|
|
83
|
+
held = located(message);
|
|
84
|
+
return held.rows();
|
|
85
|
+
},
|
|
35
86
|
};
|
|
36
87
|
}
|
|
88
|
+
function covered(readiness) {
|
|
89
|
+
return keyedRows(readiness.coverage.rooms.map(({ room }) => room), readiness.coverage.rooms);
|
|
90
|
+
}
|
|
91
|
+
function keyedReadiness(first) {
|
|
92
|
+
let held = covered(first);
|
|
93
|
+
return {
|
|
94
|
+
value: first,
|
|
95
|
+
next(message) {
|
|
96
|
+
if (!('shown' in message)) {
|
|
97
|
+
held = covered(message);
|
|
98
|
+
return message;
|
|
99
|
+
}
|
|
100
|
+
const { shown, rooms } = message;
|
|
101
|
+
return { ...shown, coverage: { ...shown.coverage, rooms: held.apply(rooms) } };
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function awaiting(pending) {
|
|
106
|
+
return keyedRows(pending.map(({ room }) => room), pending);
|
|
107
|
+
}
|
|
37
108
|
function keyedResult(first) {
|
|
38
|
-
let
|
|
109
|
+
let result = first.result;
|
|
110
|
+
let rows = keyedRows([], []);
|
|
111
|
+
let pending = awaiting([]);
|
|
112
|
+
const take = ({ result: next, keys }) => {
|
|
113
|
+
result = next;
|
|
114
|
+
if ('pending' in next)
|
|
115
|
+
pending = awaiting(next.pending);
|
|
116
|
+
else
|
|
117
|
+
rows = keyedRows(keys, rowsOf(next));
|
|
118
|
+
return result;
|
|
119
|
+
};
|
|
120
|
+
take(first);
|
|
39
121
|
return {
|
|
40
122
|
value: first.result,
|
|
41
123
|
next(message) {
|
|
42
|
-
|
|
43
|
-
|
|
124
|
+
const asked = message;
|
|
125
|
+
if (whole(asked))
|
|
126
|
+
return take(asked);
|
|
127
|
+
if (pendingChange(asked)) {
|
|
128
|
+
if ('pending' in result)
|
|
129
|
+
result = { pending: pending.apply(asked.pending) };
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
if ('pending' in result)
|
|
133
|
+
return result;
|
|
134
|
+
const kept = rows.apply(asked);
|
|
135
|
+
const coverage = asked.coverage ?? result.coverage;
|
|
136
|
+
const next = asked.next === undefined ? result.next : (asked.next ?? undefined);
|
|
137
|
+
const total = asked.total ?? result.total;
|
|
138
|
+
const window = {
|
|
139
|
+
...(next === undefined ? {} : { next }),
|
|
140
|
+
...(total === undefined ? {} : { total }),
|
|
141
|
+
};
|
|
142
|
+
result =
|
|
143
|
+
'groups' in result
|
|
144
|
+
? { groups: kept, coverage, ...window }
|
|
145
|
+
: { documents: kept, coverage, ...window };
|
|
146
|
+
return result;
|
|
44
147
|
},
|
|
45
148
|
};
|
|
46
149
|
}
|
|
150
|
+
const FOLDS = {
|
|
151
|
+
query: (first) => keyedResult(first),
|
|
152
|
+
rooms: (first) => keyedRooms(first),
|
|
153
|
+
readiness: (first) => keyedReadiness(first),
|
|
154
|
+
};
|
|
155
|
+
const WHOLE = {
|
|
156
|
+
query: (message) => whole(message),
|
|
157
|
+
rooms: (message) => Array.isArray(message),
|
|
158
|
+
readiness: (message) => !('shown' in message),
|
|
159
|
+
};
|
|
160
|
+
export function replaces(topic, message) {
|
|
161
|
+
return WHOLE[topic]?.(message) ?? true;
|
|
162
|
+
}
|
|
47
163
|
function replaced(first) {
|
|
48
164
|
return { value: first, next: (message) => message };
|
|
49
165
|
}
|
|
50
|
-
export function observed(first, stop,
|
|
51
|
-
const reducer =
|
|
166
|
+
export function observed(first, stop, topic) {
|
|
167
|
+
const reducer = (FOLDS[topic] ?? replaced)(first);
|
|
52
168
|
let value = reducer.value;
|
|
53
169
|
let open = true;
|
|
54
170
|
const listeners = new Set();
|
|
@@ -86,7 +202,7 @@ export function observed(first, stop, keyed) {
|
|
|
86
202
|
end,
|
|
87
203
|
};
|
|
88
204
|
}
|
|
89
|
-
export function opened(watch,
|
|
205
|
+
export function opened(watch, topic) {
|
|
90
206
|
return new Promise((resolve, reject) => {
|
|
91
207
|
let handle;
|
|
92
208
|
let stop = () => { };
|
|
@@ -95,7 +211,7 @@ export function opened(watch, keyed) {
|
|
|
95
211
|
handle.receive(message);
|
|
96
212
|
return;
|
|
97
213
|
}
|
|
98
|
-
handle = observed(message, () => stop(),
|
|
214
|
+
handle = observed(message, () => stop(), topic);
|
|
99
215
|
resolve(handle.observation);
|
|
100
216
|
}, (error) => {
|
|
101
217
|
if (handle !== undefined)
|
|
@@ -108,7 +224,7 @@ export function opened(watch, keyed) {
|
|
|
108
224
|
export function observing(watch) {
|
|
109
225
|
return (topic, ...input) => opened((deliver, fail) => watch(topic, input, (message) => {
|
|
110
226
|
deliver(structuredClone(message));
|
|
111
|
-
}, fail), topic
|
|
227
|
+
}, fail), topic);
|
|
112
228
|
}
|
|
113
229
|
export function hashed(text) {
|
|
114
230
|
let first = 0xdeadbeef;
|
|
@@ -129,10 +245,9 @@ function rowDigest(row) {
|
|
|
129
245
|
}
|
|
130
246
|
export function digestOf({ result, keys }) {
|
|
131
247
|
if ('pending' in result)
|
|
132
|
-
return { pending:
|
|
248
|
+
return { pending: new Map(result.pending.map((room) => [room.room, room])) };
|
|
133
249
|
const rows = rowsOf(result);
|
|
134
250
|
return {
|
|
135
|
-
keys,
|
|
136
251
|
rows: new Map(keys.map((key, index) => [key, rowDigest(rows[index])])),
|
|
137
252
|
coverage: JSON.stringify(result.coverage),
|
|
138
253
|
next: result.next,
|
|
@@ -140,16 +255,22 @@ export function digestOf({ result, keys }) {
|
|
|
140
255
|
};
|
|
141
256
|
}
|
|
142
257
|
export function digestApplied(digest, message) {
|
|
143
|
-
if (whole(message)
|
|
144
|
-
return
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
258
|
+
if (whole(message))
|
|
259
|
+
return digestOf(message);
|
|
260
|
+
if (pendingChange(message)) {
|
|
261
|
+
if ('pending' in digest)
|
|
262
|
+
keyedInto(digest.pending, message.pending);
|
|
263
|
+
return digest;
|
|
264
|
+
}
|
|
265
|
+
if ('pending' in digest)
|
|
266
|
+
return digest;
|
|
267
|
+
keyedInto(digest.rows, {
|
|
268
|
+
changed: message.changed.map(([key, row]) => [key, rowDigest(row)]),
|
|
269
|
+
removed: message.removed,
|
|
270
|
+
order: message.order,
|
|
271
|
+
});
|
|
150
272
|
return {
|
|
151
|
-
|
|
152
|
-
rows,
|
|
273
|
+
rows: digest.rows,
|
|
153
274
|
coverage: message.coverage === undefined ? digest.coverage : JSON.stringify(message.coverage),
|
|
154
275
|
next: message.next === undefined ? digest.next : (message.next ?? undefined),
|
|
155
276
|
total: message.total ?? digest.total,
|
|
@@ -157,35 +278,18 @@ export function digestApplied(digest, message) {
|
|
|
157
278
|
}
|
|
158
279
|
export function changeOf(previous, next) {
|
|
159
280
|
const after = next.result;
|
|
160
|
-
if ('pending' in previous
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
: next;
|
|
281
|
+
if ('pending' in previous && 'pending' in after) {
|
|
282
|
+
const pending = keyedChange(previous.pending, after.pending.map(({ room }) => room), after.pending, samePending);
|
|
283
|
+
return unchanged(pending) ? null : { pending };
|
|
164
284
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
const row = later[index];
|
|
170
|
-
if (previous.rows.get(key) !== rowDigest(row))
|
|
171
|
-
changed.push([key, row]);
|
|
172
|
-
});
|
|
173
|
-
const removed = previous.keys.filter((key) => !present.has(key));
|
|
174
|
-
const kept = previous.keys.filter((key) => present.has(key));
|
|
175
|
-
const moved = kept.length !== next.keys.length || kept.some((key, index) => next.keys[index] !== key);
|
|
176
|
-
const coverage = JSON.stringify(after.coverage);
|
|
177
|
-
const covered = previous.coverage !== coverage;
|
|
285
|
+
if ('pending' in previous || 'pending' in after)
|
|
286
|
+
return next;
|
|
287
|
+
const rows = keyedChange(previous.rows, next.keys, rowsOf(after), (was, row) => was === rowDigest(row));
|
|
288
|
+
const covered = previous.coverage !== JSON.stringify(after.coverage);
|
|
178
289
|
const framing = reframed(previous, after);
|
|
179
|
-
if (
|
|
290
|
+
if (unchanged(rows) && !covered && framing === null)
|
|
180
291
|
return null;
|
|
181
|
-
}
|
|
182
|
-
return {
|
|
183
|
-
changed,
|
|
184
|
-
removed,
|
|
185
|
-
order: moved ? next.keys : null,
|
|
186
|
-
...(covered ? { coverage: after.coverage } : {}),
|
|
187
|
-
...framing,
|
|
188
|
-
};
|
|
292
|
+
return { ...rows, ...(covered ? { coverage: after.coverage } : {}), ...framing };
|
|
189
293
|
}
|
|
190
294
|
function reframed(before, after) {
|
|
191
295
|
const next = before.next === after.next ? {} : { next: after.next ?? null };
|
package/dist/opening.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opening.d.ts","sourceRoot":"","sources":["../src/opening.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,wBAAsB,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"opening.d.ts","sourceRoot":"","sources":["../src/opening.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,wBAAsB,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAqCxF"}
|
package/dist/opening.js
CHANGED
|
@@ -7,7 +7,7 @@ import { prepare } from './preparation.js';
|
|
|
7
7
|
import { unpair } from './queue.js';
|
|
8
8
|
import { emitRooms, emitStorageLoss, statusShown } from './shown.js';
|
|
9
9
|
export async function open(runtime, opened) {
|
|
10
|
-
const { store, socket,
|
|
10
|
+
const { store, socket, shell, conversations, build, usableWhenHeld } = runtime;
|
|
11
11
|
if (socket.closed())
|
|
12
12
|
throw new Error('runtime closed');
|
|
13
13
|
const interrupted = await opened.fences();
|
|
@@ -42,18 +42,12 @@ export async function open(runtime, opened) {
|
|
|
42
42
|
await conversationsOpened(conversations, opened);
|
|
43
43
|
if (interrupted.length > 0) {
|
|
44
44
|
queueMicrotask(() => {
|
|
45
|
-
void eraseFenced(runtime, interrupted).catch(
|
|
46
|
-
journal.record('erasure failed');
|
|
47
|
-
uncaught(error);
|
|
48
|
-
});
|
|
45
|
+
void eraseFenced(runtime, interrupted).catch(uncaught);
|
|
49
46
|
});
|
|
50
47
|
}
|
|
51
48
|
statusShown(runtime);
|
|
52
49
|
prepare(runtime);
|
|
53
50
|
emitRooms(runtime);
|
|
54
|
-
void unpair(runtime).catch(
|
|
55
|
-
journal.record('unpair failed');
|
|
56
|
-
uncaught(error);
|
|
57
|
-
});
|
|
51
|
+
void unpair(runtime).catch(uncaught);
|
|
58
52
|
return opened;
|
|
59
53
|
}
|
package/dist/outcome.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ActionResult, AdapterFailure, AttachResult, BinaryLinkResult, HistoryResult, HistoryRevision, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
|
|
2
2
|
import type { ChangeBatch } from './change.js';
|
|
3
|
+
import type { Attempt, Retries } from './retried.js';
|
|
3
4
|
import type { KeptBinary, KeptResult } from './opened.js';
|
|
4
5
|
type Refused<Kind extends string> = ProviderRefusal & {
|
|
5
6
|
kind: Kind;
|
|
@@ -56,6 +57,10 @@ export declare const UNREADABLE: Refused<'unreadable'>;
|
|
|
56
57
|
export declare const LOCKED_UNREADABLE: Refused<'unreadable'>;
|
|
57
58
|
export declare const ABSENT_TARGET: Refused<'absent'>;
|
|
58
59
|
export declare function absentBinary(path: string): Refused<'absent'>;
|
|
60
|
+
export declare function declaredType(blob: Blob): string;
|
|
61
|
+
export declare function blobOf(binary: Extract<BinaryAnswer, {
|
|
62
|
+
kind: 'binary';
|
|
63
|
+
}>): Promise<Blob>;
|
|
59
64
|
export declare function binaryAnswer(result: KeptResult): HeldBinaryAnswer;
|
|
60
65
|
export declare function binaryLinkAnswer(result: BinaryLinkResult, held?: string): BinaryLinkAnswer;
|
|
61
66
|
export declare function attachAnswer(result: AttachResult): AttachAnswer;
|
|
@@ -84,5 +89,7 @@ export type QueueEntry = {
|
|
|
84
89
|
} & (Submission | {
|
|
85
90
|
readonly state: 'local';
|
|
86
91
|
});
|
|
92
|
+
export declare const UNANSWERED: ActionResult;
|
|
93
|
+
export declare function handedOutcome(retries: Retries, attempt: Attempt | undefined, result: ActionResult): CallResult;
|
|
87
94
|
export {};
|
|
88
95
|
//# sourceMappingURL=outcome.d.ts.map
|
package/dist/outcome.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../src/outcome.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../src/outcome.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,eAAe,EACf,aAAa,EACb,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE1D,KAAK,OAAO,CAAC,IAAI,SAAS,MAAM,IAAI,eAAe,GAAG;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAC;AAErE,MAAM,MAAM,OAAO,GACf,OAAO,CAAC,uBAAuB,CAAC,GAChC,OAAO,CAAC,uBAAuB,CAAC,GAChC,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,GACpD,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,GAC9C,aAAa,CAAC;AAElB,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,EAAE,CAAC,EAAE,a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1
|
+
import { MEDIA_TYPES } from '@agentshouse/mdmodel';
|
|
2
|
+
import { refusalError } from './failure.js';
|
|
1
3
|
export const UNREADABLE = {
|
|
2
4
|
kind: 'unreadable',
|
|
3
5
|
code: 'room-not-readable',
|
|
@@ -19,17 +21,22 @@ export const ABSENT_TARGET = {
|
|
|
19
21
|
export function absentBinary(path) {
|
|
20
22
|
return { kind: 'absent', code: 'binary-file-absent', fields: { path }, retryable: false };
|
|
21
23
|
}
|
|
24
|
+
export function declaredType(blob) {
|
|
25
|
+
return blob.type === '' ? MEDIA_TYPES.octetStream : blob.type;
|
|
26
|
+
}
|
|
27
|
+
export function blobOf(binary) {
|
|
28
|
+
return new Response(binary.stream, { headers: { 'content-type': binary.mediaType } }).blob();
|
|
29
|
+
}
|
|
22
30
|
export function binaryAnswer(result) {
|
|
23
31
|
return result.kind === 'binary' || result.kind === 'rejected' ? result : failure(result);
|
|
24
32
|
}
|
|
25
|
-
const OCTET_STREAM = 'application/octet-stream';
|
|
26
33
|
export function binaryLinkAnswer(result, held) {
|
|
27
34
|
if (result.kind === 'link') {
|
|
28
35
|
return {
|
|
29
36
|
kind: 'link',
|
|
30
37
|
url: result.url,
|
|
31
38
|
name: result.name,
|
|
32
|
-
mediaType: result.mediaType ?? held ??
|
|
39
|
+
mediaType: result.mediaType ?? held ?? MEDIA_TYPES.octetStream,
|
|
33
40
|
};
|
|
34
41
|
}
|
|
35
42
|
return result.kind === 'rejected' ? result : failure(result);
|
|
@@ -82,3 +89,17 @@ export function historyAnswer(result) {
|
|
|
82
89
|
? result
|
|
83
90
|
: failure(result);
|
|
84
91
|
}
|
|
92
|
+
export const UNANSWERED = { kind: 'transport-uncertainty' };
|
|
93
|
+
export function handedOutcome(retries, attempt, result) {
|
|
94
|
+
if (attempt !== undefined) {
|
|
95
|
+
const { step, instance } = attempt;
|
|
96
|
+
if (result.kind === 'action')
|
|
97
|
+
retries.succeeded(step, instance);
|
|
98
|
+
else if (result.kind === 'transport-uncertainty')
|
|
99
|
+
retries.uncertain(step, instance, result);
|
|
100
|
+
else if (result.kind === 'rejected' && result.retryable) {
|
|
101
|
+
retries.failed(step, instance, refusalError(result));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return calledResult(result);
|
|
105
|
+
}
|
package/dist/overlay.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ApplyResult } from '@agentshouse/mdmodel';
|
|
1
2
|
import type { BinaryFile, HeadChange } from './adapter.js';
|
|
2
3
|
import { type Composition } from './collection.js';
|
|
3
4
|
import type { ChangeBatch } from './change.js';
|
|
@@ -23,5 +24,7 @@ export type Layer = Heads & {
|
|
|
23
24
|
export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Generator<readonly [string, HeldBinary]>;
|
|
24
25
|
export declare function sameBinary(left: HeldBinary | undefined, right: HeldBinary | undefined): boolean;
|
|
25
26
|
export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
|
|
27
|
+
export declare function composed(path: string, fields: Readonly<Record<string, unknown>>, sections: Readonly<Record<string, string>>, composition: Composition): ApplyResult;
|
|
28
|
+
export declare function compose(path: string, fields: Readonly<Record<string, unknown>>, sections: Readonly<Record<string, string>>, composition: Composition): string;
|
|
26
29
|
export declare function overlaying(base: Layer, queue: readonly ChangeBatch[], composition: Composition, unapplied?: () => void): Generator<number, Layer, void>;
|
|
27
30
|
//# sourceMappingURL=overlay.d.ts.map
|
package/dist/overlay.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../src/overlay.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../src/overlay.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,WAAW,EAEjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC3D,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E,UAAU,GAAG,SAAS,EAAE,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAW/F;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,EAAE,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAQ/F;AAqDD,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC1C,WAAW,EAAE,WAAW,GACvB,WAAW,CAqBb;AAED,wBAAgB,OAAO,CACrB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC1C,WAAW,EAAE,WAAW,GACvB,MAAM,CAIR;AA8ID,wBAAiB,UAAU,CACzB,IAAI,EAAE,KAAK,EACX,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,WAAW,EAAE,WAAW,EACxB,SAAS,CAAC,EAAE,MAAM,IAAI,GACrB,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAsChC"}
|
package/dist/overlay.js
CHANGED
|
@@ -53,12 +53,11 @@ function* priorsOf(preconditions) {
|
|
|
53
53
|
preamble: (path) => preambles.get(path) ?? '',
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
export function composed(path, fields, sections, composition) {
|
|
57
57
|
const declared = fields[TYPE_FIELD];
|
|
58
58
|
const type = typeof declared === 'string' && declared !== '' ? declared : undefined;
|
|
59
59
|
const definition = definitionsAt(composition, path)(type);
|
|
60
|
-
|
|
61
|
-
const next = apply(created, [
|
|
60
|
+
return apply(create(type, definition), [
|
|
62
61
|
...Object.entries(fields).flatMap(([name, value]) => (name !== TYPE_FIELD || type === undefined) && frontmatterValue(value)
|
|
63
62
|
? [{ kind: 'field', name, value, prior: undefined }]
|
|
64
63
|
: []),
|
|
@@ -69,7 +68,12 @@ function compose(path, fields, sections, composition) {
|
|
|
69
68
|
prior: undefined,
|
|
70
69
|
})),
|
|
71
70
|
], definition);
|
|
72
|
-
|
|
71
|
+
}
|
|
72
|
+
export function compose(path, fields, sections, composition) {
|
|
73
|
+
const next = composed(path, fields, sections, composition);
|
|
74
|
+
if (next.outcome !== 'applied')
|
|
75
|
+
throw new Error(`the creation of ${path} writes no document`);
|
|
76
|
+
return serialize(next.document);
|
|
73
77
|
}
|
|
74
78
|
function edited(change, priors) {
|
|
75
79
|
if (change.kind === 'field')
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const PAGE_METADATA_WORDS: {
|
|
2
|
+
readonly heading: 'Page metadata';
|
|
3
|
+
readonly app: 'App';
|
|
4
|
+
readonly address: 'Address';
|
|
5
|
+
readonly queries: 'Local Queries';
|
|
6
|
+
};
|
|
7
|
+
export declare function pageMetadataBlock(app: string, address: string, queries: readonly unknown[]): string;
|
|
8
|
+
//# sourceMappingURL=page-metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-metadata.d.ts","sourceRoot":"","sources":["../src/page-metadata.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB;aAC9B,OAAO,EAAE,eAAe;aACxB,GAAG,EAAE,KAAK;aACV,OAAO,EAAE,SAAS;aAClB,OAAO,EAAE,eAAe;CAChB,CAAC;AAIX,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,SAAS,OAAO,EAAE,GAC1B,MAAM,CAUR"}
|