@agentshouse/mdruntime 0.1.0-c01d4615bfe46 → 0.1.0-c024a9c474f5e
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 +14 -13
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +32 -3
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +58 -19
- package/dist/adapter.d.ts +183 -21
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +2 -2
- package/dist/{binary.d.ts → attachment.d.ts} +8 -4
- package/dist/attachment.d.ts.map +1 -0
- package/dist/attachment.js +15 -0
- package/dist/authored.d.ts +88 -0
- package/dist/authored.d.ts.map +1 -0
- package/dist/authored.js +345 -0
- package/dist/chain.d.ts +1 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +5 -2
- package/dist/change.d.ts +6 -2
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +3 -0
- package/dist/chat-types.js +2 -2
- package/dist/client.d.ts +23 -8
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +25 -54
- package/dist/collection.d.ts +6 -1
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +23 -9
- package/dist/column.d.ts +5 -0
- package/dist/column.d.ts.map +1 -0
- package/dist/column.js +9 -0
- package/dist/compile.d.ts +2 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +73 -42
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +16 -6
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +8 -5
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +5 -3
- package/dist/conversation-row.d.ts +23 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +37 -8
- package/dist/conversation.d.ts +20 -9
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +102 -68
- package/dist/declaration.js +3 -3
- package/dist/discovery.d.ts +3 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +30 -5
- package/dist/download.d.ts +6 -0
- package/dist/download.d.ts.map +1 -0
- package/dist/download.js +42 -0
- package/dist/durability.d.ts +2 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +3 -0
- package/dist/entry.d.ts +26 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +126 -36
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +3 -1
- package/dist/figures.d.ts +1 -1
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +6 -4
- package/dist/file.d.ts +1 -1
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +1 -1
- package/dist/holdings.d.ts.map +1 -1
- package/dist/holdings.js +5 -3
- package/dist/host.d.ts +6 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +70 -29
- package/dist/house-query.d.ts +24 -0
- package/dist/house-query.d.ts.map +1 -0
- package/dist/house-query.js +102 -0
- package/dist/identity.d.ts +1 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +1 -1
- package/dist/index.d.ts +20 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -5
- package/dist/install.d.ts +8 -2
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +40 -33
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +42 -25
- package/dist/linked-file.d.ts +7 -0
- package/dist/linked-file.d.ts.map +1 -0
- package/dist/linked-file.js +13 -0
- package/dist/listing.d.ts +24 -12
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +50 -21
- package/dist/live.d.ts +19 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +94 -36
- package/dist/loaded.d.ts +7 -0
- package/dist/loaded.d.ts.map +1 -0
- package/dist/loaded.js +46 -0
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +4 -2
- package/dist/lost.js +1 -1
- package/dist/media.d.ts +19 -3
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +177 -27
- package/dist/memory.d.ts +4 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +50 -16
- package/dist/messages.d.ts +12 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +28 -6
- package/dist/modal.d.ts +2 -0
- package/dist/modal.d.ts.map +1 -0
- package/dist/modal.js +11 -0
- package/dist/model.d.ts +10 -7
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +7 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +3 -3
- package/dist/name.d.ts +0 -1
- package/dist/name.d.ts.map +1 -1
- package/dist/name.js +3 -7
- package/dist/observation.d.ts +26 -10
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +200 -69
- package/dist/online.d.ts +7 -0
- package/dist/online.d.ts.map +1 -0
- package/dist/online.js +29 -0
- package/dist/opened.d.ts +5 -5
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +2 -2
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +20 -2
- package/dist/outcome.d.ts +27 -14
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +14 -5
- package/dist/overlay.d.ts +20 -9
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +110 -41
- package/dist/parts.d.ts +4 -1
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +30 -7
- package/dist/paths.d.ts +1 -1
- package/dist/paths.js +1 -1
- package/dist/preparation.d.ts +33 -7
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +195 -78
- package/dist/presence.d.ts +8 -2
- package/dist/presence.d.ts.map +1 -1
- package/dist/presence.js +24 -13
- package/dist/queries.d.ts +1 -1
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +115 -67
- package/dist/query.d.ts +2 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +1 -0
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +3 -1
- package/dist/queue.d.ts +1 -1
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +55 -23
- package/dist/reach.d.ts +15 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +140 -25
- package/dist/react.d.ts +11 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/readiness.d.ts +22 -3
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +18 -10
- package/dist/reads.d.ts +2 -2
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +21 -13
- package/dist/recovery.d.ts +1 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +2 -1
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.js +4 -4
- package/dist/replica.d.ts +3 -8
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +5 -5
- package/dist/room-draft.d.ts +29 -4
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +237 -16
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +12 -7
- package/dist/room-list.d.ts +10 -0
- package/dist/room-list.d.ts.map +1 -0
- package/dist/room-list.js +47 -0
- package/dist/rows.d.ts +11 -3
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +25 -11
- package/dist/run-tables.d.ts +25 -0
- package/dist/run-tables.d.ts.map +1 -0
- package/dist/run-tables.js +98 -0
- package/dist/running.d.ts +5 -0
- package/dist/running.d.ts.map +1 -0
- package/dist/running.js +10 -0
- package/dist/runs.d.ts +27 -0
- package/dist/runs.d.ts.map +1 -0
- package/dist/runs.js +92 -0
- package/dist/runtime.d.ts +7 -3
- 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 +31 -96
- package/dist/saves.d.ts +7 -5
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +108 -54
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +2 -2
- package/dist/selector.d.ts +3 -0
- package/dist/selector.d.ts.map +1 -0
- package/dist/selector.js +22 -0
- package/dist/shown.d.ts +4 -2
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +73 -48
- package/dist/socket/session.d.ts +4 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket/session.js +3 -0
- package/dist/socket.d.ts +6 -1
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +14 -2
- package/dist/source.d.ts +42 -0
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +76 -9
- 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 +24 -5
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +59 -24
- 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 +15 -10
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +12 -5
- package/dist/stored.d.ts +40 -16
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +210 -52
- package/dist/surface.d.ts +18 -7
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +52 -16
- package/dist/sync.d.ts +4 -2
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +47 -25
- package/dist/tables.d.ts +34 -49
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +84 -325
- package/dist/tallies.js +2 -2
- package/dist/validation.d.ts +2 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +50 -10
- package/dist/wire.d.ts +29 -14
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +18 -13
- package/package.json +4 -4
- package/dist/binary.d.ts.map +0 -1
- package/dist/binary.js +0 -8
package/dist/observation.js
CHANGED
|
@@ -6,55 +6,198 @@ export function rowsOf(result) {
|
|
|
6
6
|
export function whole(message) {
|
|
7
7
|
return 'result' in message;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
return
|
|
9
|
+
export function pendingChange(message) {
|
|
10
|
+
return 'pending' in message;
|
|
11
11
|
}
|
|
12
|
-
export function
|
|
13
|
-
return
|
|
12
|
+
export function unchanged(change) {
|
|
13
|
+
return change.changed.length === 0 && change.removed.length === 0 && change.order === null;
|
|
14
14
|
}
|
|
15
|
-
export function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
for (const key of
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function heldModels(held, sent) {
|
|
74
|
+
return new Map(Object.entries(sent).map(([key, types]) => [key, held.get(key) ?? types]));
|
|
75
|
+
}
|
|
76
|
+
function namedModels(models, rooms) {
|
|
77
|
+
const named = new Set(rooms.flatMap(({ model, typedSelection }) => [model.types, typedSelection?.model.types]));
|
|
78
|
+
return new Map([...models].filter(([, types]) => named.has(types)));
|
|
79
|
+
}
|
|
80
|
+
function typed(model, models) {
|
|
81
|
+
return model.types === null ? model : { ...model, types: models.get(model.types) };
|
|
82
|
+
}
|
|
83
|
+
function appRoom({ model, typedSelection, ...room }, models) {
|
|
84
|
+
return {
|
|
85
|
+
...room,
|
|
86
|
+
model: typed(model, models),
|
|
87
|
+
typedSelection: typedSelection === null
|
|
88
|
+
? null
|
|
89
|
+
: { roots: typedSelection.roots, model: typed(typedSelection.model, models) },
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
export function appRooms({ rooms, models }) {
|
|
93
|
+
const held = heldModels(new Map(), models);
|
|
94
|
+
return rooms.map((room) => appRoom(room, held));
|
|
95
|
+
}
|
|
96
|
+
function keyedRooms(first) {
|
|
97
|
+
let models = new Map();
|
|
98
|
+
let held = keyedRows([], []);
|
|
99
|
+
const whole = (listed) => {
|
|
100
|
+
models = heldModels(models, listed.models);
|
|
101
|
+
held = keyedRows(listed.rooms.map(({ locator }) => locator), listed.rooms.map((room) => appRoom(room, models)));
|
|
102
|
+
return held.rows();
|
|
35
103
|
};
|
|
36
104
|
return {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
105
|
+
value: whole(first),
|
|
106
|
+
next(message) {
|
|
107
|
+
if ('rooms' in message)
|
|
108
|
+
return whole(message);
|
|
109
|
+
const change = message;
|
|
110
|
+
const sent = heldModels(models, change.models);
|
|
111
|
+
const rows = held.apply({
|
|
112
|
+
changed: change.changed.map(([locator, room]) => [locator, appRoom(room, sent)]),
|
|
113
|
+
removed: change.removed,
|
|
114
|
+
order: change.order,
|
|
115
|
+
});
|
|
116
|
+
models = namedModels(new Map([...models, ...sent]), rows);
|
|
117
|
+
return rows;
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
function covered(readiness) {
|
|
122
|
+
return keyedRows(readiness.coverage.rooms.map(({ room }) => room), readiness.coverage.rooms);
|
|
123
|
+
}
|
|
124
|
+
function keyedReadiness(first) {
|
|
125
|
+
let held = covered(first);
|
|
126
|
+
return {
|
|
127
|
+
value: first,
|
|
128
|
+
next(message) {
|
|
129
|
+
if (!('shown' in message)) {
|
|
130
|
+
held = covered(message);
|
|
131
|
+
return message;
|
|
132
|
+
}
|
|
133
|
+
const { shown, rooms } = message;
|
|
134
|
+
return { ...shown, coverage: { ...shown.coverage, rooms: held.apply(rooms) } };
|
|
135
|
+
},
|
|
41
136
|
};
|
|
42
137
|
}
|
|
138
|
+
function awaiting(pending) {
|
|
139
|
+
return keyedRows(pending.map(({ room }) => room), pending);
|
|
140
|
+
}
|
|
43
141
|
function keyedResult(first) {
|
|
44
|
-
let
|
|
142
|
+
let result = first.result;
|
|
143
|
+
let rows = keyedRows([], []);
|
|
144
|
+
let pending = awaiting([]);
|
|
145
|
+
const take = ({ result: next, keys }) => {
|
|
146
|
+
result = next;
|
|
147
|
+
if ('pending' in next)
|
|
148
|
+
pending = awaiting(next.pending);
|
|
149
|
+
else
|
|
150
|
+
rows = keyedRows(keys, rowsOf(next));
|
|
151
|
+
return result;
|
|
152
|
+
};
|
|
153
|
+
take(first);
|
|
45
154
|
return {
|
|
46
155
|
value: first.result,
|
|
47
156
|
next(message) {
|
|
48
|
-
|
|
49
|
-
|
|
157
|
+
const asked = message;
|
|
158
|
+
if (whole(asked))
|
|
159
|
+
return take(asked);
|
|
160
|
+
if (pendingChange(asked)) {
|
|
161
|
+
if ('pending' in result)
|
|
162
|
+
result = { pending: pending.apply(asked.pending) };
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
165
|
+
if ('pending' in result)
|
|
166
|
+
return result;
|
|
167
|
+
const kept = rows.apply(asked);
|
|
168
|
+
const coverage = asked.coverage ?? result.coverage;
|
|
169
|
+
const next = asked.next === undefined ? result.next : (asked.next ?? undefined);
|
|
170
|
+
const total = asked.total ?? result.total;
|
|
171
|
+
const window = {
|
|
172
|
+
...(next === undefined ? {} : { next }),
|
|
173
|
+
...(total === undefined ? {} : { total }),
|
|
174
|
+
};
|
|
175
|
+
result =
|
|
176
|
+
'groups' in result
|
|
177
|
+
? { groups: kept, coverage, ...window }
|
|
178
|
+
: { documents: kept, coverage, ...window };
|
|
179
|
+
return result;
|
|
50
180
|
},
|
|
51
181
|
};
|
|
52
182
|
}
|
|
183
|
+
const FOLDS = {
|
|
184
|
+
query: (first) => keyedResult(first),
|
|
185
|
+
rooms: (first) => keyedRooms(first),
|
|
186
|
+
readiness: (first) => keyedReadiness(first),
|
|
187
|
+
};
|
|
188
|
+
const WHOLE = {
|
|
189
|
+
query: (message) => whole(message),
|
|
190
|
+
rooms: (message) => 'rooms' in message,
|
|
191
|
+
readiness: (message) => !('shown' in message),
|
|
192
|
+
};
|
|
193
|
+
export function replaces(topic, message) {
|
|
194
|
+
return WHOLE[topic]?.(message) ?? true;
|
|
195
|
+
}
|
|
53
196
|
function replaced(first) {
|
|
54
197
|
return { value: first, next: (message) => message };
|
|
55
198
|
}
|
|
56
199
|
export function observed(first, stop, topic) {
|
|
57
|
-
const reducer =
|
|
200
|
+
const reducer = (FOLDS[topic] ?? replaced)(first);
|
|
58
201
|
let value = reducer.value;
|
|
59
202
|
let open = true;
|
|
60
203
|
const listeners = new Set();
|
|
@@ -135,10 +278,9 @@ function rowDigest(row) {
|
|
|
135
278
|
}
|
|
136
279
|
export function digestOf({ result, keys }) {
|
|
137
280
|
if ('pending' in result)
|
|
138
|
-
return { pending:
|
|
281
|
+
return { pending: new Map(result.pending.map((room) => [room.room, room])) };
|
|
139
282
|
const rows = rowsOf(result);
|
|
140
283
|
return {
|
|
141
|
-
keys,
|
|
142
284
|
rows: new Map(keys.map((key, index) => [key, rowDigest(rows[index])])),
|
|
143
285
|
coverage: JSON.stringify(result.coverage),
|
|
144
286
|
next: result.next,
|
|
@@ -146,16 +288,22 @@ export function digestOf({ result, keys }) {
|
|
|
146
288
|
};
|
|
147
289
|
}
|
|
148
290
|
export function digestApplied(digest, message) {
|
|
149
|
-
if (whole(message)
|
|
150
|
-
return
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
291
|
+
if (whole(message))
|
|
292
|
+
return digestOf(message);
|
|
293
|
+
if (pendingChange(message)) {
|
|
294
|
+
if ('pending' in digest)
|
|
295
|
+
keyedInto(digest.pending, message.pending);
|
|
296
|
+
return digest;
|
|
297
|
+
}
|
|
298
|
+
if ('pending' in digest)
|
|
299
|
+
return digest;
|
|
300
|
+
keyedInto(digest.rows, {
|
|
301
|
+
changed: message.changed.map(([key, row]) => [key, rowDigest(row)]),
|
|
302
|
+
removed: message.removed,
|
|
303
|
+
order: message.order,
|
|
304
|
+
});
|
|
156
305
|
return {
|
|
157
|
-
|
|
158
|
-
rows,
|
|
306
|
+
rows: digest.rows,
|
|
159
307
|
coverage: message.coverage === undefined ? digest.coverage : JSON.stringify(message.coverage),
|
|
160
308
|
next: message.next === undefined ? digest.next : (message.next ?? undefined),
|
|
161
309
|
total: message.total ?? digest.total,
|
|
@@ -163,35 +311,18 @@ export function digestApplied(digest, message) {
|
|
|
163
311
|
}
|
|
164
312
|
export function changeOf(previous, next) {
|
|
165
313
|
const after = next.result;
|
|
166
|
-
if ('pending' in previous
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
: next;
|
|
314
|
+
if ('pending' in previous && 'pending' in after) {
|
|
315
|
+
const pending = keyedChange(previous.pending, after.pending.map(({ room }) => room), after.pending, samePending);
|
|
316
|
+
return unchanged(pending) ? null : { pending };
|
|
170
317
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
const row = later[index];
|
|
176
|
-
if (previous.rows.get(key) !== rowDigest(row))
|
|
177
|
-
changed.push([key, row]);
|
|
178
|
-
});
|
|
179
|
-
const removed = previous.keys.filter((key) => !present.has(key));
|
|
180
|
-
const kept = previous.keys.filter((key) => present.has(key));
|
|
181
|
-
const moved = kept.length !== next.keys.length || kept.some((key, index) => next.keys[index] !== key);
|
|
182
|
-
const coverage = JSON.stringify(after.coverage);
|
|
183
|
-
const covered = previous.coverage !== coverage;
|
|
318
|
+
if ('pending' in previous || 'pending' in after)
|
|
319
|
+
return next;
|
|
320
|
+
const rows = keyedChange(previous.rows, next.keys, rowsOf(after), (was, row) => was === rowDigest(row));
|
|
321
|
+
const covered = previous.coverage !== JSON.stringify(after.coverage);
|
|
184
322
|
const framing = reframed(previous, after);
|
|
185
|
-
if (
|
|
323
|
+
if (unchanged(rows) && !covered && framing === null)
|
|
186
324
|
return null;
|
|
187
|
-
}
|
|
188
|
-
return {
|
|
189
|
-
changed,
|
|
190
|
-
removed,
|
|
191
|
-
order: moved ? next.keys : null,
|
|
192
|
-
...(covered ? { coverage: after.coverage } : {}),
|
|
193
|
-
...framing,
|
|
194
|
-
};
|
|
325
|
+
return { ...rows, ...(covered ? { coverage: after.coverage } : {}), ...framing };
|
|
195
326
|
}
|
|
196
327
|
function reframed(before, after) {
|
|
197
328
|
const next = before.next === after.next ? {} : { next: after.next ?? null };
|
package/dist/online.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Authorization } from './adapter.js';
|
|
2
|
+
import type { Runtime } from './runtime.js';
|
|
3
|
+
export declare function offline(runtime: Runtime): Promise<boolean>;
|
|
4
|
+
export declare function askedOnline<T extends {
|
|
5
|
+
readonly kind: string;
|
|
6
|
+
}>(runtime: Runtime, ask: (authorization: Authorization) => Promise<T>): Promise<T | null>;
|
|
7
|
+
//# sourceMappingURL=online.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"online.d.ts","sourceRoot":"","sources":["../src/online.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,wBAAsB,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAOhE;AAED,wBAAsB,WAAW,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EACnE,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,CAAC,aAAa,EAAE,aAAa,KAAK,OAAO,CAAC,CAAC,CAAC,GAChD,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAgBnB"}
|
package/dist/online.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { connectionNow } from './preparation.js';
|
|
2
|
+
import { refuse } from './refusal.js';
|
|
3
|
+
export async function offline(runtime) {
|
|
4
|
+
const { socket } = runtime;
|
|
5
|
+
return (socket.closed() ||
|
|
6
|
+
socket.session.now().refusal !== null ||
|
|
7
|
+
(await connectionNow(runtime)) !== 'connected');
|
|
8
|
+
}
|
|
9
|
+
export async function askedOnline(runtime, ask) {
|
|
10
|
+
const { socket } = runtime;
|
|
11
|
+
try {
|
|
12
|
+
await socket.authorize();
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const { closed, authorization, refusal } = socket.session.now();
|
|
18
|
+
if (closed || authorization === undefined || refusal !== null)
|
|
19
|
+
return null;
|
|
20
|
+
try {
|
|
21
|
+
const answer = await ask(authorization);
|
|
22
|
+
if (answer.kind === 'revoked-authorization')
|
|
23
|
+
await refuse(runtime, 'revoked-authorization');
|
|
24
|
+
return answer;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
package/dist/opened.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AttachmentResult } from './adapter.js';
|
|
2
2
|
import { type RuntimeDatabase } from './tables.js';
|
|
3
3
|
export type OpenedName = {
|
|
4
4
|
readonly locator: string;
|
|
5
5
|
readonly path: string;
|
|
6
6
|
readonly revision: string;
|
|
7
7
|
};
|
|
8
|
-
export type
|
|
8
|
+
export type KeptAttachment = {
|
|
9
9
|
readonly kind: 'binary';
|
|
10
10
|
readonly file: string;
|
|
11
11
|
readonly byteLength: number;
|
|
12
12
|
readonly mediaType: string;
|
|
13
13
|
};
|
|
14
|
-
export type KeptResult =
|
|
14
|
+
export type KeptResult = KeptAttachment | Exclude<AttachmentResult, {
|
|
15
15
|
kind: 'binary';
|
|
16
16
|
}>;
|
|
17
17
|
export type OpenedFiles = {
|
|
18
|
-
find(name: OpenedName): Promise<
|
|
19
|
-
fetch(name: OpenedName, read: () => Promise<
|
|
18
|
+
find(name: OpenedName): Promise<KeptAttachment | null>;
|
|
19
|
+
fetch(name: OpenedName, read: () => Promise<AttachmentResult>): Promise<KeptResult>;
|
|
20
20
|
};
|
|
21
21
|
export declare function openedFiles(database: RuntimeDatabase, lost: (locator: string) => boolean): OpenedFiles;
|
|
22
22
|
//# sourceMappingURL=opened.d.ts.map
|
package/dist/opened.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opened.d.ts","sourceRoot":"","sources":["../src/opened.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"opened.d.ts","sourceRoot":"","sources":["../src/opened.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGrD,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAErF,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG,OAAO,CAAC,gBAAgB,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC;AAExF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACvD,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACrF,CAAC;AAsBF,wBAAgB,WAAW,CACzB,QAAQ,EAAE,eAAe,EACzB,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,GACjC,WAAW,CAsFb"}
|
package/dist/opened.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { digest } from './digest.js';
|
|
2
|
-
import {
|
|
2
|
+
import { attachmentLocalId } from './identity.js';
|
|
3
3
|
import { FILE_PART_BYTES } from './tables.js';
|
|
4
4
|
const UNCERTAIN = { kind: 'transport-uncertainty' };
|
|
5
5
|
function kept({ key, byteLength, mediaType }) {
|
|
@@ -27,7 +27,7 @@ export function openedFiles(database, lost) {
|
|
|
27
27
|
return held === null ? null : kept(held);
|
|
28
28
|
}
|
|
29
29
|
async function written(name, { body, mediaType, sha256 }) {
|
|
30
|
-
const key =
|
|
30
|
+
const key = attachmentLocalId();
|
|
31
31
|
const reader = body.getReader();
|
|
32
32
|
const hashed = digest();
|
|
33
33
|
const chunks = [];
|
package/dist/opening.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opening.d.ts","sourceRoot":"","sources":["../src/opening.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"opening.d.ts","sourceRoot":"","sources":["../src/opening.ts"],"names":[],"mappings":"AAQA,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,CAuCxF"}
|
package/dist/opening.js
CHANGED
|
@@ -5,9 +5,10 @@ import { sweep } from './install.js';
|
|
|
5
5
|
import { eraseFenced } from './lost.js';
|
|
6
6
|
import { prepare } from './preparation.js';
|
|
7
7
|
import { unpair } from './queue.js';
|
|
8
|
+
import { runsOpened } from './runs.js';
|
|
8
9
|
import { emitRooms, emitStorageLoss, statusShown } from './shown.js';
|
|
9
10
|
export async function open(runtime, opened) {
|
|
10
|
-
const { store, socket, shell, conversations, build
|
|
11
|
+
const { store, socket, shell, conversations, build } = runtime;
|
|
11
12
|
if (socket.closed())
|
|
12
13
|
throw new Error('runtime closed');
|
|
13
14
|
const interrupted = await opened.fences();
|
|
@@ -25,7 +26,7 @@ export async function open(runtime, opened) {
|
|
|
25
26
|
}
|
|
26
27
|
const held = await opened.opened();
|
|
27
28
|
store.device.set({
|
|
28
|
-
|
|
29
|
+
completedWhenOpened: (await opened.facts(['lastCompleted'])).lastCompleted !== null,
|
|
29
30
|
});
|
|
30
31
|
try {
|
|
31
32
|
await opened.demote();
|
|
@@ -40,14 +41,31 @@ export async function open(runtime, opened) {
|
|
|
40
41
|
if (held.erasing || held.orphans.length > 0)
|
|
41
42
|
queueMicrotask(() => sweep(runtime));
|
|
42
43
|
await conversationsOpened(conversations, opened);
|
|
44
|
+
await runsOpened(runtime);
|
|
43
45
|
if (interrupted.length > 0) {
|
|
44
46
|
queueMicrotask(() => {
|
|
45
47
|
void eraseFenced(runtime, interrupted).catch(uncaught);
|
|
46
48
|
});
|
|
47
49
|
}
|
|
50
|
+
await factsKept(runtime, opened);
|
|
48
51
|
statusShown(runtime);
|
|
49
52
|
prepare(runtime);
|
|
50
53
|
emitRooms(runtime);
|
|
51
54
|
void unpair(runtime).catch(uncaught);
|
|
52
55
|
return opened;
|
|
53
56
|
}
|
|
57
|
+
async function factsKept({ socket, adopt }, opened) {
|
|
58
|
+
const { session } = socket;
|
|
59
|
+
const { unstored } = session.now();
|
|
60
|
+
if (unstored !== null) {
|
|
61
|
+
queueMicrotask(() => {
|
|
62
|
+
void adopt(unstored).catch(uncaught);
|
|
63
|
+
});
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const { capabilities, queriesOnly } = await opened.facts(['capabilities', 'queriesOnly']);
|
|
67
|
+
if (queriesOnly.length > 0 && !session.now().roomsNamed)
|
|
68
|
+
session.set({ queriesOnly });
|
|
69
|
+
if (capabilities.length > 0)
|
|
70
|
+
socket.readyFromStore();
|
|
71
|
+
}
|
package/dist/outcome.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ActionResult, AdapterFailure, AttachResult,
|
|
1
|
+
import type { ActionResult, AdapterFailure, AttachResult, AttachmentCopy, AttachmentLinkResult, HistoryResult, HistoryRevision, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
|
|
2
2
|
import type { ChangeBatch } from './change.js';
|
|
3
3
|
import type { Attempt, Retries } from './retried.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { KeptAttachment, KeptResult } from './opened.js';
|
|
5
5
|
type Refused<Kind extends string> = ProviderRefusal & {
|
|
6
6
|
kind: Kind;
|
|
7
7
|
};
|
|
@@ -20,26 +20,38 @@ export type CallResult = {
|
|
|
20
20
|
export type HistoryAnswer = Exclude<HistoryResult, {
|
|
21
21
|
kind: Failure['kind'];
|
|
22
22
|
}> | Failure;
|
|
23
|
-
type
|
|
24
|
-
export type
|
|
23
|
+
type AttachmentRefusal = Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
24
|
+
export type AttachmentAnswer = {
|
|
25
25
|
kind: 'binary';
|
|
26
26
|
stream: ReadableStream<Uint8Array>;
|
|
27
27
|
byteLength: number;
|
|
28
28
|
mediaType: string;
|
|
29
|
-
} |
|
|
30
|
-
export type
|
|
31
|
-
export type
|
|
29
|
+
} | AttachmentRefusal;
|
|
30
|
+
export type HeldAttachmentAnswer = KeptAttachment | AttachmentRefusal;
|
|
31
|
+
export type AttachmentLinkAnswer = {
|
|
32
32
|
kind: 'link';
|
|
33
33
|
url: string;
|
|
34
34
|
name: string;
|
|
35
35
|
mediaType: string;
|
|
36
36
|
} | Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
37
|
-
export type
|
|
38
|
-
|
|
37
|
+
export type ShownLinkAnswer = Extract<AttachmentLinkAnswer, {
|
|
38
|
+
kind: 'link';
|
|
39
|
+
}> & {
|
|
40
|
+
copies: readonly AttachmentCopy[];
|
|
41
|
+
};
|
|
42
|
+
type ShownRefusal = Exclude<AttachmentLinkAnswer, {
|
|
43
|
+
kind: 'link';
|
|
44
|
+
}>;
|
|
45
|
+
export type HeldShownAnswer = KeptAttachment | ShownLinkAnswer | ShownRefusal;
|
|
46
|
+
export type ShownAnswer = AttachmentAnswer | ShownLinkAnswer | ShownRefusal;
|
|
39
47
|
export type AttachAnswer = {
|
|
40
48
|
kind: 'attached';
|
|
41
49
|
path: string;
|
|
42
50
|
} | Offline | Refused<'rejected'> | Failure;
|
|
51
|
+
export type ConversationAttachAnswer = {
|
|
52
|
+
kind: 'attached';
|
|
53
|
+
link: string;
|
|
54
|
+
} | Offline | Refused<'rejected'> | Refused<'undeclared'> | Failure;
|
|
43
55
|
export type DownloadAnswer = {
|
|
44
56
|
kind: 'started';
|
|
45
57
|
} | Refused<'rejected'> | Refused<'absent'> | Refused<'blocked'> | Failure;
|
|
@@ -56,14 +68,15 @@ export type Resolution = {
|
|
|
56
68
|
export declare const UNREADABLE: Refused<'unreadable'>;
|
|
57
69
|
export declare const LOCKED_UNREADABLE: Refused<'unreadable'>;
|
|
58
70
|
export declare const ABSENT_TARGET: Refused<'absent'>;
|
|
59
|
-
export declare function
|
|
71
|
+
export declare function absentAttachment(path: string): Refused<'absent'>;
|
|
60
72
|
export declare function declaredType(blob: Blob): string;
|
|
61
|
-
export declare function
|
|
73
|
+
export declare function attachmentBlob(binary: Extract<AttachmentAnswer, {
|
|
62
74
|
kind: 'binary';
|
|
63
75
|
}>): Promise<Blob>;
|
|
64
|
-
export declare function
|
|
65
|
-
export declare function
|
|
76
|
+
export declare function attachmentAnswer(result: KeptResult): HeldAttachmentAnswer;
|
|
77
|
+
export declare function attachmentLinkAnswer(result: AttachmentLinkResult, held?: string): AttachmentLinkAnswer;
|
|
66
78
|
export declare function attachAnswer(result: AttachResult): AttachAnswer;
|
|
79
|
+
export declare function linkedAnswer(result: AttachResult): ConversationAttachAnswer;
|
|
67
80
|
export declare const ROOM_LOCKED = "room-locked";
|
|
68
81
|
export declare function lockedRoom(locator: string): Refused<'room-locked'> & {
|
|
69
82
|
locator: string;
|
|
@@ -74,7 +87,7 @@ export type Offline = {
|
|
|
74
87
|
export declare const OFFLINE: Offline;
|
|
75
88
|
export declare function answeredResult(value: unknown): boolean;
|
|
76
89
|
export declare const UNCERTAIN: Failure;
|
|
77
|
-
export declare function undeclared(name: string):
|
|
90
|
+
export declare function undeclared(name: string): Refused<'undeclared'>;
|
|
78
91
|
export declare function failure(result: AdapterFailure): Failure;
|
|
79
92
|
export declare function calledResult(result: ActionResult): CallResult;
|
|
80
93
|
export declare function historyAnswer(result: HistoryResult): HistoryAnswer;
|
package/dist/outcome.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../src/outcome.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,
|
|
1
|
+
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../src/outcome.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,cAAc,EACd,oBAAoB,EACpB,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,cAAc,EAAE,UAAU,EAAE,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ED,MAAM,MAAM,OAAO,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC;AAEnD,eAAO,MAAM,OAAO,EAAE,OAA6B,CAAC;AAEpD,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEtD;AAED,eAAO,MAAM,SAAS,EAAE,OAKvB,CAAC;AAEF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAE9D;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAiBvD;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,UAAU,CAE7D;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa,CAIlE;AAED,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,WAAW,CAAA;CAAE,GAC3C;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAExD,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAA;CAAE,GAAG,CACvD,UAAU,GACV;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAC9B,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,YAAgD,CAAC;AAE1E,wBAAgB,aAAa,CAC3B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,MAAM,EAAE,YAAY,GACnB,UAAU,CAUZ"}
|
package/dist/outcome.js
CHANGED
|
@@ -18,19 +18,19 @@ export const ABSENT_TARGET = {
|
|
|
18
18
|
fields: {},
|
|
19
19
|
retryable: false,
|
|
20
20
|
};
|
|
21
|
-
export function
|
|
22
|
-
return { kind: 'absent', code: '
|
|
21
|
+
export function absentAttachment(path) {
|
|
22
|
+
return { kind: 'absent', code: 'attachment-absent', fields: { path }, retryable: false };
|
|
23
23
|
}
|
|
24
24
|
export function declaredType(blob) {
|
|
25
25
|
return blob.type === '' ? MEDIA_TYPES.octetStream : blob.type;
|
|
26
26
|
}
|
|
27
|
-
export function
|
|
27
|
+
export function attachmentBlob(binary) {
|
|
28
28
|
return new Response(binary.stream, { headers: { 'content-type': binary.mediaType } }).blob();
|
|
29
29
|
}
|
|
30
|
-
export function
|
|
30
|
+
export function attachmentAnswer(result) {
|
|
31
31
|
return result.kind === 'binary' || result.kind === 'rejected' ? result : failure(result);
|
|
32
32
|
}
|
|
33
|
-
export function
|
|
33
|
+
export function attachmentLinkAnswer(result, held) {
|
|
34
34
|
if (result.kind === 'link') {
|
|
35
35
|
return {
|
|
36
36
|
kind: 'link',
|
|
@@ -44,6 +44,15 @@ export function binaryLinkAnswer(result, held) {
|
|
|
44
44
|
export function attachAnswer(result) {
|
|
45
45
|
if (result.kind === 'attached')
|
|
46
46
|
return { kind: 'attached', path: result.path };
|
|
47
|
+
if (result.kind === 'linked')
|
|
48
|
+
return UNCERTAIN;
|
|
49
|
+
return result.kind === 'rejected' ? result : failure(result);
|
|
50
|
+
}
|
|
51
|
+
export function linkedAnswer(result) {
|
|
52
|
+
if (result.kind === 'linked')
|
|
53
|
+
return { kind: 'attached', link: result.link };
|
|
54
|
+
if (result.kind === 'attached')
|
|
55
|
+
return UNCERTAIN;
|
|
47
56
|
return result.kind === 'rejected' ? result : failure(result);
|
|
48
57
|
}
|
|
49
58
|
export const ROOM_LOCKED = 'room-locked';
|