@agentshouse/mdruntime 0.1.0-c09bf842921ff → 0.1.0-c0aa19c04da09
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 +21 -19
- package/dist/acceptance.d.ts +3 -0
- package/dist/acceptance.d.ts.map +1 -0
- package/dist/acceptance.js +299 -0
- 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 +26 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +350 -0
- package/dist/adapter.d.ts +164 -83
- 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 +2 -7
- package/dist/authored.d.ts +88 -0
- package/dist/authored.d.ts.map +1 -0
- package/dist/authored.js +347 -0
- package/dist/binary.d.ts +6 -2
- package/dist/binary.d.ts.map +1 -1
- package/dist/binary.js +10 -3
- package/dist/bootstrap.d.ts +9 -5
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +204 -86
- 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 +1 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +5 -2
- package/dist/change-set.d.ts +4 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +6 -0
- package/dist/change.d.ts +7 -2
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +7 -2
- package/dist/chat-types.d.ts +3 -0
- package/dist/chat-types.d.ts.map +1 -0
- package/dist/chat-types.js +11 -0
- package/dist/client.d.ts +35 -23
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +56 -68
- package/dist/collection.d.ts +27 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +34 -10
- 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 +9 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +283 -114
- package/dist/connection.d.ts +6 -144
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +115 -5019
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +149 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +259 -0
- package/dist/conversation-row.d.ts +40 -0
- package/dist/conversation-row.d.ts.map +1 -0
- package/dist/conversation-row.js +66 -0
- package/dist/conversation.d.ts +71 -46
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +1001 -884
- package/dist/declaration.d.ts +10 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +24 -0
- package/dist/discovery.d.ts +12 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +175 -0
- 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 +14 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +7 -0
- package/dist/entry.d.ts +16 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +75 -29
- package/dist/expectation.d.ts +26 -13
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +72 -19
- package/dist/failure.d.ts +3 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +8 -0
- package/dist/figures.d.ts +49 -0
- package/dist/figures.d.ts.map +1 -0
- package/dist/figures.js +199 -0
- package/dist/file.d.ts +1 -1
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +3 -2
- 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 +25 -4
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +115 -36
- package/dist/house-query.d.ts +24 -0
- package/dist/house-query.d.ts.map +1 -0
- package/dist/house-query.js +82 -0
- package/dist/index.d.ts +38 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -6
- package/dist/install.d.ts +60 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +537 -0
- package/dist/lifecycle.d.ts +7 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +290 -0
- package/dist/listing.d.ts +60 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +168 -0
- package/dist/live.d.ts +22 -6
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +130 -34
- 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 +7 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +34 -0
- package/dist/lost.d.ts +5 -0
- package/dist/lost.d.ts.map +1 -0
- package/dist/lost.js +49 -0
- package/dist/media.d.ts +20 -4
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +170 -36
- package/dist/memory.d.ts +11 -4
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +110 -40
- package/dist/messages.d.ts +38 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +105 -25
- 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 +4 -5
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +6 -11
- package/dist/models.d.ts +10 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +153 -0
- 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 +29 -12
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +217 -85
- 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 +1 -1
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +5 -5
- package/dist/opening.d.ts +4 -0
- package/dist/opening.d.ts.map +1 -0
- package/dist/opening.js +69 -0
- package/dist/outcome.d.ts +28 -5
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +36 -3
- package/dist/overlay.d.ts +10 -5
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +48 -24
- 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 +6 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +36 -0
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +22 -0
- package/dist/preparation.d.ts +46 -0
- package/dist/preparation.d.ts.map +1 -0
- package/dist/preparation.js +344 -0
- package/dist/presence.d.ts +58 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +231 -0
- package/dist/queries.d.ts +16 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +330 -0
- package/dist/query.d.ts +12 -3
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +30 -0
- package/dist/questions.d.ts.map +1 -0
- package/dist/questions.js +117 -0
- package/dist/queue.d.ts +40 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +480 -0
- package/dist/reach.d.ts +20 -9
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +327 -126
- package/dist/react.d.ts +18 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +33 -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 +20 -5
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +17 -10
- package/dist/reads.d.ts +39 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +178 -0
- package/dist/recovery.d.ts +4 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +40 -9
- package/dist/reference-forms.d.ts +4 -0
- package/dist/reference-forms.d.ts.map +1 -0
- package/dist/reference-forms.js +74 -0
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +10 -6
- package/dist/refusal.d.ts +5 -0
- package/dist/refusal.d.ts.map +1 -0
- package/dist/refusal.js +55 -0
- package/dist/replica.d.ts +5 -13
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +42 -26
- 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 +31 -8
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +278 -68
- package/dist/room-drafts.d.ts +24 -0
- package/dist/room-drafts.d.ts.map +1 -0
- package/dist/room-drafts.js +222 -0
- package/dist/room-list.d.ts +10 -0
- package/dist/room-list.d.ts.map +1 -0
- package/dist/room-list.js +45 -0
- package/dist/rows.d.ts +11 -2
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +27 -14
- package/dist/running.d.ts +5 -0
- package/dist/running.d.ts.map +1 -0
- package/dist/running.js +10 -0
- package/dist/runtime.d.ts +37 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/save.d.ts +43 -86
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +332 -228
- package/dist/saves.d.ts +34 -0
- package/dist/saves.d.ts.map +1 -0
- package/dist/saves.js +463 -0
- package/dist/seed.d.ts +11 -2
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +71 -1
- package/dist/shared.d.ts +1 -6
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +13 -95
- package/dist/shown.d.ts +35 -0
- package/dist/shown.d.ts.map +1 -0
- package/dist/shown.js +326 -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 +28 -0
- package/dist/socket/lanes.d.ts.map +1 -0
- package/dist/socket/lanes.js +103 -0
- package/dist/socket/reads.d.ts +10 -0
- package/dist/socket/reads.d.ts.map +1 -0
- package/dist/socket/reads.js +31 -0
- package/dist/socket/session.d.ts +41 -0
- package/dist/socket/session.d.ts.map +1 -0
- package/dist/socket/session.js +26 -0
- package/dist/socket.d.ts +68 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +165 -0
- package/dist/source.d.ts +61 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +95 -0
- package/dist/status.d.ts +0 -2
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +0 -6
- package/dist/store/installs.d.ts +30 -0
- package/dist/store/installs.d.ts.map +1 -0
- package/dist/store/installs.js +40 -0
- package/dist/store/readiness.d.ts +11 -0
- package/dist/store/readiness.d.ts.map +1 -0
- package/dist/store/readiness.js +68 -0
- package/dist/store/records.d.ts +229 -0
- package/dist/store/records.d.ts.map +1 -0
- package/dist/store/records.js +474 -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/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/space.d.ts +11 -0
- package/dist/store/space.d.ts.map +1 -0
- package/dist/store/space.js +41 -0
- package/dist/store/watchers.d.ts +17 -0
- package/dist/store/watchers.d.ts.map +1 -0
- package/dist/store/watchers.js +56 -0
- package/dist/store/writes.d.ts +24 -0
- package/dist/store/writes.d.ts.map +1 -0
- package/dist/store/writes.js +125 -0
- package/dist/store.d.ts +116 -141
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +174 -360
- package/dist/stored.d.ts +84 -32
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +398 -115
- package/dist/surface.d.ts +94 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +255 -0
- package/dist/sync.d.ts +21 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +557 -0
- package/dist/tables.d.ts +120 -59
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +196 -277
- package/dist/tallies.d.ts +18 -0
- package/dist/tallies.d.ts.map +1 -0
- package/dist/tallies.js +128 -0
- package/dist/validation.d.ts +2 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +51 -11
- package/dist/wire.d.ts +79 -13
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +34 -14
- package/package.json +4 -3
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- package/dist/fence.d.ts +0 -6
- package/dist/fence.d.ts.map +0 -1
- package/dist/fence.js +0 -10
- package/dist/job.d.ts +0 -14
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -28
- package/dist/log.d.ts +0 -5
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ATTACHMENT_REFERENCE_PREFIX, CROCKFORD_CHARACTER, CROCKFORD_LEADING_CHARACTER, DOCUMENT_REFERENCE_PREFIX, REVISION_REFERENCE_PREFIX, } from '@agentshouse/mdmodel';
|
|
2
|
+
import { text, texts } from './column.js';
|
|
3
|
+
import { markdownPath } from './rows.js';
|
|
4
|
+
const ORDINAL = `${CROCKFORD_LEADING_CHARACTER}${CROCKFORD_CHARACTER}*`;
|
|
5
|
+
const OLD_REVISION = new RegExp(`^fr_(${ORDINAL}\\.${ORDINAL}\\.${CROCKFORD_CHARACTER})$`, 'u');
|
|
6
|
+
const OLD_ENTRY = new RegExp(`^af_(${ORDINAL})\\.(${CROCKFORD_CHARACTER})$`, 'u');
|
|
7
|
+
const RECORDS = [
|
|
8
|
+
['authored_pending', 'batch', ['locator', 'id']],
|
|
9
|
+
['authored_pending', 'state', ['locator', 'id']],
|
|
10
|
+
['authored_room_drafts', 'record', ['locator', 'path']],
|
|
11
|
+
['authored_chat_drafts', 'record', ['conversation']],
|
|
12
|
+
['authored_calls', 'record', ['operation']],
|
|
13
|
+
];
|
|
14
|
+
const REVISIONS = [
|
|
15
|
+
['replica_entries', 'revision'],
|
|
16
|
+
['opened_files', 'revision'],
|
|
17
|
+
];
|
|
18
|
+
export function kindedRevision(value) {
|
|
19
|
+
const revision = OLD_REVISION.exec(value);
|
|
20
|
+
return revision === null ? value : `${REVISION_REFERENCE_PREFIX}${revision[1]}`;
|
|
21
|
+
}
|
|
22
|
+
function kindedReference(value, paths) {
|
|
23
|
+
const revised = kindedRevision(value);
|
|
24
|
+
if (revised !== value)
|
|
25
|
+
return revised;
|
|
26
|
+
const entry = OLD_ENTRY.exec(value);
|
|
27
|
+
const path = entry === null ? undefined : paths.get(entry[1]);
|
|
28
|
+
if (entry === null || path === undefined)
|
|
29
|
+
return value;
|
|
30
|
+
const prefix = markdownPath(path) ? DOCUMENT_REFERENCE_PREFIX : ATTACHMENT_REFERENCE_PREFIX;
|
|
31
|
+
return `${prefix}${entry[1]}.${entry[2]}`;
|
|
32
|
+
}
|
|
33
|
+
function kinded(value, paths) {
|
|
34
|
+
if (typeof value === 'string')
|
|
35
|
+
return kindedReference(value, paths);
|
|
36
|
+
if (Array.isArray(value))
|
|
37
|
+
return value.map((item) => kinded(item, paths));
|
|
38
|
+
if (value === null || typeof value !== 'object')
|
|
39
|
+
return value;
|
|
40
|
+
return Object.fromEntries(Object.entries(value).map(([name, item]) => [name, kinded(item, paths)]));
|
|
41
|
+
}
|
|
42
|
+
function heldColumns(connection, table) {
|
|
43
|
+
return new Set(texts(connection.rows('SELECT name FROM pragma_table_info(?)', [table]), 'name'));
|
|
44
|
+
}
|
|
45
|
+
function heldPaths(connection) {
|
|
46
|
+
const columns = heldColumns(connection, 'replica_entries');
|
|
47
|
+
if (!columns.has('file_id') || !columns.has('path'))
|
|
48
|
+
return new Map();
|
|
49
|
+
return new Map(connection
|
|
50
|
+
.rows('SELECT DISTINCT file_id, path FROM replica_entries WHERE file_id IS NOT NULL')
|
|
51
|
+
.map((row) => [text(row.file_id), text(row.path)]));
|
|
52
|
+
}
|
|
53
|
+
function holdingOldForm(column) {
|
|
54
|
+
return `(${column} LIKE '%"fr\\_%' ESCAPE '\\' OR ${column} LIKE '%"af\\_%' ESCAPE '\\')`;
|
|
55
|
+
}
|
|
56
|
+
export function kindedReferences(connection) {
|
|
57
|
+
for (const [table, column] of REVISIONS) {
|
|
58
|
+
if (!heldColumns(connection, table).has(column))
|
|
59
|
+
continue;
|
|
60
|
+
connection.run(`UPDATE ${table} SET ${column} = '${REVISION_REFERENCE_PREFIX}' || substr(${column}, 4) WHERE ${column} LIKE 'fr\\_%' ESCAPE '\\'`);
|
|
61
|
+
}
|
|
62
|
+
let paths = null;
|
|
63
|
+
for (const [table, column, keys] of RECORDS) {
|
|
64
|
+
const held = connection.rows(`SELECT ${keys.join(', ')}, ${column} AS value FROM ${table} WHERE ${holdingOldForm(column)}`);
|
|
65
|
+
for (const row of held) {
|
|
66
|
+
paths ??= heldPaths(connection);
|
|
67
|
+
const value = JSON.parse(text(row.value));
|
|
68
|
+
const written = JSON.stringify(kinded(value, paths));
|
|
69
|
+
if (written === JSON.stringify(value))
|
|
70
|
+
continue;
|
|
71
|
+
connection.run(`UPDATE ${table} SET ${column} = ? WHERE ${keys.map((key) => `${key} = ?`).join(' AND ')}`, [written, ...keys.map((key) => row[key])]);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
package/dist/refresh.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export type Refreshing = {
|
|
|
20
20
|
later(paths: readonly string[], roomVersion: string): Promise<ReadonlySet<string>>;
|
|
21
21
|
stage(page: RefreshedPage): Promise<boolean>;
|
|
22
22
|
};
|
|
23
|
-
type PageContent = Pick<RefreshPage, 'documents' | 'facts' | 'revisions' | 'fileIds' | 'changes' | '
|
|
23
|
+
type PageContent = Pick<RefreshPage, 'documents' | 'facts' | 'revisions' | 'fileIds' | 'created' | 'changes' | 'attachments'>;
|
|
24
24
|
export declare function pageEntries(page: PageContent, removals: readonly string[], roomVersion: string, prior: (paths: readonly string[]) => Promise<ReadonlyMap<string, HeldEntry>>): Promise<StoredEntry[]>;
|
|
25
25
|
export declare function advancement(refresh: Refresher, authorization: Authorization, held: ReplicaRecord, remodel: Remodel, continuing: () => boolean, staging: Refreshing): Promise<Advancement>;
|
|
26
26
|
export {};
|
package/dist/refresh.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../src/refresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,WAAW,EACX,cAAc,EACd,aAAa,EACb,gBAAgB,EACjB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAG9D,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,aAAa,CAAC;IAAC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAAE,GACzE;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,GAC1B,gBAAgB,GAChB,WAAW,GACX,cAAc,CAAC;AAEnB,MAAM,MAAM,SAAS,GAAG,CACtB,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,cAAc,KACpB,OAAO,CAAC,aAAa,CAAC,CAAC;AAE5B,MAAM,MAAM,UAAU,GAAG;IAC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AM,SAAS,GAAG,CACtB,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,cAAc,KACpB,OAAO,CAAC,aAAa,CAAC,CAAC;AAE5B,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,IAAI,IAAI,CAAC;IACb,KAAK,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IACzE,KAAK,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;IACnF,KAAK,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9C,CAAC;AASF,KAAK,WAAW,GAAG,IAAI,CACrB,WAAW,EACX,WAAW,GAAG,OAAO,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,aAAa,CACxF,CAAC;AAwFF,wBAAsB,WAAW,CAC/B,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,KAAK,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,GAC3E,OAAO,CAAC,WAAW,EAAE,CAAC,CAKxB;AAgDD,wBAAsB,WAAW,CAC/B,OAAO,EAAE,SAAS,EAClB,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,OAAO,EACzB,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,WAAW,CAAC,CA8CtB"}
|
package/dist/refresh.js
CHANGED
|
@@ -12,7 +12,7 @@ function* listing(page, removals) {
|
|
|
12
12
|
const written = new Set();
|
|
13
13
|
for (const [kept, named] of [
|
|
14
14
|
[documents, page.documents],
|
|
15
|
-
[binaries, page.
|
|
15
|
+
[binaries, page.attachments],
|
|
16
16
|
]) {
|
|
17
17
|
for (const path of Object.keys(named)) {
|
|
18
18
|
yield ROW_WEIGHT;
|
|
@@ -49,6 +49,7 @@ function* entering(page, roomVersion, listed, prior) {
|
|
|
49
49
|
binary: null,
|
|
50
50
|
revision: page.revisions[path] ?? prior.get(path)?.revision ?? null,
|
|
51
51
|
fileId: page.fileIds?.[path] ?? null,
|
|
52
|
+
created: page.created?.[path] ?? null,
|
|
52
53
|
change: page.changes[path] ?? null,
|
|
53
54
|
written: roomVersion,
|
|
54
55
|
});
|
|
@@ -59,9 +60,10 @@ function* entering(page, roomVersion, listed, prior) {
|
|
|
59
60
|
path,
|
|
60
61
|
content: null,
|
|
61
62
|
facts: null,
|
|
62
|
-
binary: { state: 'accepted', ...page.
|
|
63
|
+
binary: { state: 'accepted', ...page.attachments[path] },
|
|
63
64
|
revision: page.revisions[path] ?? prior.get(path)?.revision ?? null,
|
|
64
65
|
fileId: page.fileIds?.[path] ?? null,
|
|
66
|
+
created: page.created?.[path] ?? null,
|
|
65
67
|
change: page.changes[path] ?? null,
|
|
66
68
|
written: null,
|
|
67
69
|
});
|
|
@@ -76,6 +78,7 @@ function* entering(page, roomVersion, listed, prior) {
|
|
|
76
78
|
...kept,
|
|
77
79
|
revision: page.revisions[path] ?? held.revision,
|
|
78
80
|
fileId: page.fileIds?.[path] ?? held.fileId,
|
|
81
|
+
created: page.created?.[path] ?? held.created,
|
|
79
82
|
change: page.changes[path] ?? held.change,
|
|
80
83
|
});
|
|
81
84
|
}
|
|
@@ -99,15 +102,16 @@ function unwritten(page, kept) {
|
|
|
99
102
|
facts: without(page.facts, kept),
|
|
100
103
|
revisions: without(page.revisions, kept),
|
|
101
104
|
...(page.fileIds === undefined ? {} : { fileIds: without(page.fileIds, kept) }),
|
|
105
|
+
...(page.created === undefined ? {} : { created: without(page.created, kept) }),
|
|
102
106
|
changes: without(page.changes, kept),
|
|
103
|
-
|
|
107
|
+
attachments: without(page.attachments, kept),
|
|
104
108
|
removals: page.removals.filter((path) => !kept.has(path)),
|
|
105
109
|
};
|
|
106
110
|
}
|
|
107
111
|
async function pageOf(answered, roomVersion, staging) {
|
|
108
112
|
const page = unwritten(answered, await staging.later([
|
|
109
113
|
...Object.keys(answered.documents),
|
|
110
|
-
...Object.keys(answered.
|
|
114
|
+
...Object.keys(answered.attachments),
|
|
111
115
|
...answered.removals,
|
|
112
116
|
], roomVersion));
|
|
113
117
|
return {
|
|
@@ -125,7 +129,7 @@ export async function advancement(refresh, authorization, held, remodel, continu
|
|
|
125
129
|
return unconfirmed;
|
|
126
130
|
const first = await refresh(authorization, {
|
|
127
131
|
locator,
|
|
128
|
-
selection: held.replica.selection,
|
|
132
|
+
selection: held.declaration.replica.selection,
|
|
129
133
|
fromRoomVersion,
|
|
130
134
|
});
|
|
131
135
|
if (first.kind !== 'net-advancement')
|
|
@@ -150,7 +154,7 @@ export async function advancement(refresh, authorization, held, remodel, continu
|
|
|
150
154
|
return unconfirmed;
|
|
151
155
|
const page = await refresh(authorization, {
|
|
152
156
|
locator,
|
|
153
|
-
selection: held.replica.selection,
|
|
157
|
+
selection: held.declaration.replica.selection,
|
|
154
158
|
fromRoomVersion,
|
|
155
159
|
pageToken,
|
|
156
160
|
});
|
|
@@ -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;AAQpD,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,iBAiDxC"}
|
package/dist/refusal.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { changeSet, mergeChangeSets } from './change-set.js';
|
|
2
|
+
import { composedOf } from './collection.js';
|
|
3
|
+
import { uncaught } from './failure.js';
|
|
4
|
+
import { listedLocators } from './listing.js';
|
|
5
|
+
import { prepare } from './preparation.js';
|
|
6
|
+
import { storedRecord } from './replica.js';
|
|
7
|
+
import { emitRefusal } from './shown.js';
|
|
8
|
+
export async function refuse(runtime, reason, provider = null) {
|
|
9
|
+
const { store, socket, presence } = runtime;
|
|
10
|
+
socket.session.set({ paused: true });
|
|
11
|
+
socket.abortReads();
|
|
12
|
+
try {
|
|
13
|
+
if (reason === 'revoked-authorization') {
|
|
14
|
+
await store.exclusive(async () => {
|
|
15
|
+
const revoked = { status: 'unavailable', reason: 'revoked' };
|
|
16
|
+
let held = new Map();
|
|
17
|
+
try {
|
|
18
|
+
const local = await store.open();
|
|
19
|
+
held = await store.rooms();
|
|
20
|
+
await local.commit({
|
|
21
|
+
rooms: [...held.values()].map(({ record: kept }) => {
|
|
22
|
+
const record = { ...kept, model: revoked };
|
|
23
|
+
return {
|
|
24
|
+
locator: record.locator,
|
|
25
|
+
key: record.key,
|
|
26
|
+
record: storedRecord(record),
|
|
27
|
+
composed: composedOf(store.composed(record)),
|
|
28
|
+
};
|
|
29
|
+
}),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
uncaught(error);
|
|
34
|
+
}
|
|
35
|
+
const listedNow = listedLocators(runtime, held);
|
|
36
|
+
for (const locator of listedNow) {
|
|
37
|
+
if (!held.has(locator))
|
|
38
|
+
presence.modelled(locator, revoked);
|
|
39
|
+
}
|
|
40
|
+
store.changed(mergeChangeSets(listedNow.map((locator) => changeSet(locator, { documents: null, room: true }))));
|
|
41
|
+
prepare(runtime);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
socket.session.set({
|
|
47
|
+
refusal: {
|
|
48
|
+
code: reason,
|
|
49
|
+
reauthorizationOffered: reason === 'revoked-authorization',
|
|
50
|
+
refusal: provider,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
emitRefusal(runtime);
|
|
54
|
+
}
|
|
55
|
+
}
|
package/dist/replica.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type TypedPath } from '@agentshouse/mdmodel';
|
|
2
|
-
import type { BootstrapInventory, SavedFacts, MutationResult,
|
|
2
|
+
import type { BootstrapInventory, SavedFacts, MutationResult, RoomDeclaration, TypedSelection } from './adapter.js';
|
|
3
3
|
import { type ChangeBatch, type Precondition } from './change.js';
|
|
4
4
|
import { type Collection, type Composition } from './collection.js';
|
|
5
5
|
import { type ModelState } from './model.js';
|
|
@@ -7,13 +7,8 @@ import { type Layer } from './overlay.js';
|
|
|
7
7
|
import type { HeldEntry, OverlayEntry, StoredEntry } from './tables.js';
|
|
8
8
|
export type ReplicaRecord = {
|
|
9
9
|
readonly locator: string;
|
|
10
|
-
readonly
|
|
11
|
-
readonly handle: string;
|
|
12
|
-
readonly operations: OperationScopes;
|
|
13
|
-
readonly replica: ReplicaAdmission;
|
|
10
|
+
readonly declaration: RoomDeclaration;
|
|
14
11
|
readonly model: ModelState;
|
|
15
|
-
readonly typedSelection: TypedSelection | null;
|
|
16
|
-
readonly providerOwnedPaths: readonly string[];
|
|
17
12
|
readonly roomVersion: string;
|
|
18
13
|
readonly transfer: string;
|
|
19
14
|
readonly inventory: BootstrapInventory;
|
|
@@ -23,9 +18,6 @@ export type HeldReplica = {
|
|
|
23
18
|
readonly record: ReplicaRecord;
|
|
24
19
|
readonly queue: readonly ChangeBatch[];
|
|
25
20
|
readonly overlaid: ReadonlySet<string>;
|
|
26
|
-
readonly count: number;
|
|
27
|
-
readonly confirmed: number;
|
|
28
|
-
readonly indexed: boolean;
|
|
29
21
|
};
|
|
30
22
|
export type VisibleLayer = Layer & {
|
|
31
23
|
readonly collection: Collection;
|
|
@@ -35,7 +27,7 @@ export type Slice = Layer & {
|
|
|
35
27
|
readonly facts: Readonly<Record<string, SavedFacts>>;
|
|
36
28
|
readonly held: ReadonlySet<string>;
|
|
37
29
|
};
|
|
38
|
-
export declare function compositionOf(
|
|
30
|
+
export declare function compositionOf(model: ModelState, typedSelection: TypedSelection | null, builtIn: ModelState, typedPaths: readonly TypedPath[]): Composition;
|
|
39
31
|
export declare function storedRecord(record: ReplicaRecord): string;
|
|
40
32
|
export declare function slicing(entries: readonly HeldEntry[], paths: Iterable<string>): Generator<number, Slice, void>;
|
|
41
33
|
export type LayerEntry = Omit<StoredEntry, 'facts'>;
|
|
@@ -51,8 +43,8 @@ export type Replayed = {
|
|
|
51
43
|
};
|
|
52
44
|
export declare function replaying(confirmed: Slice, queue: readonly ChangeBatch[], locator: string, composition: Composition): Generator<number, Replayed, void>;
|
|
53
45
|
export declare function overlayOf(visible: VisibleLayer, touched: Iterable<string>): Generator<number, OverlayEntry[], void>;
|
|
54
|
-
export declare function holds(layer: Layer, preconditions: readonly Precondition[]): boolean;
|
|
55
|
-
export declare function landed(batch: ChangeBatch, confirmed: Layer, current?: Readonly<Record<string, string>>): boolean;
|
|
46
|
+
export declare function holds(layer: Layer, preconditions: readonly Precondition[], composition: Composition): boolean;
|
|
47
|
+
export declare function landed(batch: ChangeBatch, confirmed: Layer, composition: Composition, current?: Readonly<Record<string, string>>): boolean;
|
|
56
48
|
export type Standing = {
|
|
57
49
|
readonly withdrawn: readonly ChangeBatch[];
|
|
58
50
|
readonly kept: readonly ChangeBatch[];
|
package/dist/replica.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,cAAc,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAKL,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAA+B,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACjG,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,WAAW,EAAE,eAAe,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAC;IACvC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAA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AQ,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
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { equalValue, parse } from '@agentshouse/mdmodel';
|
|
2
|
-
import { immutable, landing } from './change.js';
|
|
3
|
-
import { collectionOf } from './collection.js';
|
|
2
|
+
import { immutable, isPart, landing, } from './change.js';
|
|
3
|
+
import { collectionOf, definitionsAt } from './collection.js';
|
|
4
4
|
import { storedModel } from './model.js';
|
|
5
5
|
import { acceptedBinaries, overlaying } from './overlay.js';
|
|
6
6
|
import { writtenFacts } from './rows.js';
|
|
7
7
|
import { effectiveIn, rewriting } from './save.js';
|
|
8
|
+
import { guarding } from './shared.js';
|
|
8
9
|
import { ROW_WEIGHT } from './turn.js';
|
|
9
|
-
export function compositionOf(
|
|
10
|
+
export function compositionOf(model, typedSelection, builtIn, typedPaths) {
|
|
10
11
|
return {
|
|
11
|
-
model
|
|
12
|
-
selection:
|
|
13
|
-
? null
|
|
14
|
-
: { roots: record.typedSelection.roots, model: builtIn },
|
|
12
|
+
model,
|
|
13
|
+
selection: typedSelection === null ? null : { roots: typedSelection.roots, model: builtIn },
|
|
15
14
|
typedPaths,
|
|
16
15
|
};
|
|
17
16
|
}
|
|
@@ -37,7 +36,7 @@ function strict(values, held) {
|
|
|
37
36
|
throw new UnreadPath(property);
|
|
38
37
|
}
|
|
39
38
|
};
|
|
40
|
-
return
|
|
39
|
+
return guarding(values, {
|
|
41
40
|
get(target, property, receiver) {
|
|
42
41
|
guard(property);
|
|
43
42
|
return Reflect.get(target, property, receiver);
|
|
@@ -60,6 +59,7 @@ export function* slicing(entries, paths) {
|
|
|
60
59
|
const binaries = {};
|
|
61
60
|
const revisions = {};
|
|
62
61
|
const fileIds = {};
|
|
62
|
+
const created = {};
|
|
63
63
|
const changes = {};
|
|
64
64
|
const written = {};
|
|
65
65
|
const facts = {};
|
|
@@ -74,6 +74,8 @@ export function* slicing(entries, paths) {
|
|
|
74
74
|
revisions[entry.path] = entry.revision;
|
|
75
75
|
if (entry.fileId !== null)
|
|
76
76
|
fileIds[entry.path] = entry.fileId;
|
|
77
|
+
if (entry.created !== null)
|
|
78
|
+
created[entry.path] = entry.created;
|
|
77
79
|
if (entry.change !== null)
|
|
78
80
|
changes[entry.path] = entry.change;
|
|
79
81
|
if (entry.written !== null)
|
|
@@ -85,6 +87,7 @@ export function* slicing(entries, paths) {
|
|
|
85
87
|
binaries: strict(binaries, held),
|
|
86
88
|
revisions: strict(revisions, held),
|
|
87
89
|
fileIds: strict(fileIds, held),
|
|
90
|
+
created: strict(created, held),
|
|
88
91
|
changes: strict(changes, held),
|
|
89
92
|
written: strict(written, held),
|
|
90
93
|
facts: strict(facts, held),
|
|
@@ -102,6 +105,7 @@ export function entryAt(layer, path) {
|
|
|
102
105
|
binary: binary ?? null,
|
|
103
106
|
revision: layer.revisions[path] ?? null,
|
|
104
107
|
fileId: layer.fileIds[path] ?? null,
|
|
108
|
+
created: layer.created[path] ?? null,
|
|
105
109
|
change: layer.changes[path] ?? null,
|
|
106
110
|
written: layer.written?.[path] ?? null,
|
|
107
111
|
};
|
|
@@ -165,7 +169,7 @@ export function* replaying(confirmed, queue, locator, composition) {
|
|
|
165
169
|
for (const change of effective.changes)
|
|
166
170
|
for (const path of changePaths(change))
|
|
167
171
|
touched.add(path);
|
|
168
|
-
layer = yield* overlaying(layer, [effective]);
|
|
172
|
+
layer = yield* overlaying(layer, [effective], composition);
|
|
169
173
|
yield ROW_WEIGHT;
|
|
170
174
|
}
|
|
171
175
|
return {
|
|
@@ -187,6 +191,7 @@ export function* overlayOf(visible, touched) {
|
|
|
187
191
|
binary: null,
|
|
188
192
|
revision: null,
|
|
189
193
|
fileId: null,
|
|
194
|
+
created: null,
|
|
190
195
|
change: null,
|
|
191
196
|
written: null,
|
|
192
197
|
facts: null,
|
|
@@ -203,12 +208,12 @@ export function* overlayOf(visible, touched) {
|
|
|
203
208
|
function present(layer, path) {
|
|
204
209
|
return layer.documents[path] !== undefined || layer.binaries[path] !== undefined;
|
|
205
210
|
}
|
|
206
|
-
export function holds(layer, preconditions) {
|
|
211
|
+
export function holds(layer, preconditions, composition) {
|
|
207
212
|
const parsed = new Map();
|
|
208
213
|
const documentAt = (path) => {
|
|
209
214
|
if (!parsed.has(path)) {
|
|
210
215
|
const text = layer.documents[path];
|
|
211
|
-
const opened = text === undefined ? null : parse(text, path);
|
|
216
|
+
const opened = text === undefined ? null : parse(text, path, definitionsAt(composition, path));
|
|
212
217
|
parsed.set(path, opened?.ok === true ? opened.document : null);
|
|
213
218
|
}
|
|
214
219
|
return parsed.get(path) ?? null;
|
|
@@ -242,7 +247,7 @@ export function holds(layer, preconditions) {
|
|
|
242
247
|
}
|
|
243
248
|
function effects(change) {
|
|
244
249
|
const path = change.path;
|
|
245
|
-
if (change
|
|
250
|
+
if (isPart(change)) {
|
|
246
251
|
return [change];
|
|
247
252
|
}
|
|
248
253
|
if (change.kind === 'create' && !('content' in change)) {
|
|
@@ -268,11 +273,11 @@ function effects(change) {
|
|
|
268
273
|
{ kind: 'present', path: change.to },
|
|
269
274
|
];
|
|
270
275
|
}
|
|
271
|
-
if (change.kind === '
|
|
276
|
+
if (change.kind === 'arrival')
|
|
272
277
|
return [{ kind: 'present', path }];
|
|
273
278
|
return [{ kind: 'absent', path }];
|
|
274
279
|
}
|
|
275
|
-
export function landed(batch, confirmed, current = {}) {
|
|
280
|
+
export function landed(batch, confirmed, composition, current = {}) {
|
|
276
281
|
const documents = new Proxy(confirmed.documents, {
|
|
277
282
|
get(target, property, receiver) {
|
|
278
283
|
if (typeof property === 'string' && Object.hasOwn(current, property))
|
|
@@ -292,9 +297,9 @@ export function landed(batch, confirmed, current = {}) {
|
|
|
292
297
|
}
|
|
293
298
|
return effects(change).every((effect) => {
|
|
294
299
|
if (effect.kind === 'absent')
|
|
295
|
-
return holds(layer, [effect]);
|
|
300
|
+
return holds(layer, [effect], composition);
|
|
296
301
|
const at = landing(batch.changes, index, effect.path);
|
|
297
|
-
return at === null || holds(layer, [{ ...effect, path: at }]);
|
|
302
|
+
return at === null || holds(layer, [{ ...effect, path: at }], composition);
|
|
298
303
|
});
|
|
299
304
|
});
|
|
300
305
|
}
|
|
@@ -319,7 +324,7 @@ export function* standing(confirmed, queue, withdrawable, local, locator, compos
|
|
|
319
324
|
const withdrawn = [];
|
|
320
325
|
const kept = [];
|
|
321
326
|
for (const batch of queue) {
|
|
322
|
-
if (withdrawable(batch) && !holds(layer, batch.preconditions)) {
|
|
327
|
+
if (withdrawable(batch) && !holds(layer, batch.preconditions, composition)) {
|
|
323
328
|
withdrawn.push(batch);
|
|
324
329
|
continue;
|
|
325
330
|
}
|
|
@@ -330,7 +335,7 @@ export function* standing(confirmed, queue, withdrawable, local, locator, compos
|
|
|
330
335
|
})
|
|
331
336
|
: batch;
|
|
332
337
|
let unapplied = false;
|
|
333
|
-
const next = yield* overlaying(layer, [effective], () => {
|
|
338
|
+
const next = yield* overlaying(layer, [effective], composition, () => {
|
|
334
339
|
unapplied = true;
|
|
335
340
|
});
|
|
336
341
|
if (local && unapplied) {
|
|
@@ -348,7 +353,7 @@ export function returnedPaths(submitted, accepted) {
|
|
|
348
353
|
...Object.keys(accepted.revisions),
|
|
349
354
|
...Object.keys(accepted.fileIds ?? {}),
|
|
350
355
|
...Object.keys(accepted.changes),
|
|
351
|
-
...Object.keys(accepted.
|
|
356
|
+
...Object.keys(accepted.attachments ?? {}),
|
|
352
357
|
...accepted.removals,
|
|
353
358
|
]);
|
|
354
359
|
for (const change of submitted.changes) {
|
|
@@ -366,6 +371,7 @@ export function* returning(confirmed, submitted, accepted, writtenAt, compositio
|
|
|
366
371
|
const binaries = new Map();
|
|
367
372
|
const revisions = new Map();
|
|
368
373
|
const fileIds = new Map();
|
|
374
|
+
const created = new Map();
|
|
369
375
|
const changes = new Map();
|
|
370
376
|
const written = new Map();
|
|
371
377
|
const facts = new Map();
|
|
@@ -396,29 +402,36 @@ export function* returning(confirmed, submitted, accepted, writtenAt, compositio
|
|
|
396
402
|
written.set(path, undefined);
|
|
397
403
|
}
|
|
398
404
|
for (const change of submitted.changes) {
|
|
399
|
-
if (change.kind === 'arrival'
|
|
400
|
-
if (accepted.revisions[change.path]
|
|
405
|
+
if (change.kind === 'arrival') {
|
|
406
|
+
if (accepted.revisions[change.path] === undefined)
|
|
407
|
+
continue;
|
|
408
|
+
created.set(change.path, change.created);
|
|
409
|
+
if ('binary' in change)
|
|
401
410
|
binaries.set(change.path, { state: 'accepted', ...change.binary });
|
|
402
|
-
}
|
|
403
411
|
continue;
|
|
404
412
|
}
|
|
405
|
-
if (change.kind !== 'move')
|
|
413
|
+
if (change.kind !== 'move' || accepted.revisions[change.to] === undefined)
|
|
406
414
|
continue;
|
|
415
|
+
created.set(change.to, read(created, confirmed.created, change.path));
|
|
416
|
+
created.set(change.path, undefined);
|
|
407
417
|
const moved = read(binaries, confirmed.binaries, change.path);
|
|
408
|
-
if (moved === undefined
|
|
418
|
+
if (moved === undefined)
|
|
409
419
|
continue;
|
|
410
420
|
binaries.set(change.to, moved);
|
|
411
421
|
binaries.set(change.path, undefined);
|
|
412
422
|
}
|
|
413
|
-
for (const [path, binary] of acceptedBinaries(accepted.
|
|
423
|
+
for (const [path, binary] of acceptedBinaries(accepted.attachments ?? {}))
|
|
414
424
|
binaries.set(path, binary);
|
|
415
|
-
for (const path of accepted.removals)
|
|
425
|
+
for (const path of accepted.removals) {
|
|
416
426
|
binaries.set(path, undefined);
|
|
427
|
+
created.set(path, undefined);
|
|
428
|
+
}
|
|
417
429
|
const paths = new Set([
|
|
418
430
|
...documents.keys(),
|
|
419
431
|
...binaries.keys(),
|
|
420
432
|
...revisions.keys(),
|
|
421
433
|
...fileIds.keys(),
|
|
434
|
+
...created.keys(),
|
|
422
435
|
...changes.keys(),
|
|
423
436
|
...written.keys(),
|
|
424
437
|
]);
|
|
@@ -433,6 +446,7 @@ export function* returning(confirmed, submitted, accepted, writtenAt, compositio
|
|
|
433
446
|
continue;
|
|
434
447
|
}
|
|
435
448
|
const text = binary === undefined ? (content ?? null) : null;
|
|
449
|
+
const fresh = confirmed.documents[path] === undefined && confirmed.binaries[path] === undefined;
|
|
436
450
|
set.push({
|
|
437
451
|
path,
|
|
438
452
|
content: text,
|
|
@@ -440,6 +454,8 @@ export function* returning(confirmed, submitted, accepted, writtenAt, compositio
|
|
|
440
454
|
binary: binary ?? null,
|
|
441
455
|
revision: read(revisions, confirmed.revisions, path) ?? null,
|
|
442
456
|
fileId: read(fileIds, confirmed.fileIds, path) ?? null,
|
|
457
|
+
created: read(created, confirmed.created, path) ??
|
|
458
|
+
(fresh ? (read(changes, confirmed.changes, path)?.time ?? null) : null),
|
|
443
459
|
change: read(changes, confirmed.changes, path) ?? null,
|
|
444
460
|
written: read(written, confirmed.written, path) ?? null,
|
|
445
461
|
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type RuntimeShell } from './durability.js';
|
|
2
|
+
export declare const STEPS: readonly ['database', 'sign_in', 'connection', 'code', 'download', 'conversations', 'sending', 'reading'];
|
|
3
|
+
export type Step = (typeof STEPS)[number];
|
|
4
|
+
export type RetriedFailure = {
|
|
5
|
+
readonly step: Step;
|
|
6
|
+
readonly answered: false;
|
|
7
|
+
} | {
|
|
8
|
+
readonly step: Step;
|
|
9
|
+
readonly answered: true;
|
|
10
|
+
readonly error: unknown;
|
|
11
|
+
};
|
|
12
|
+
export type Uncertain = {
|
|
13
|
+
readonly failure?: unknown;
|
|
14
|
+
};
|
|
15
|
+
export type Attempt = {
|
|
16
|
+
readonly step: Step;
|
|
17
|
+
readonly instance: string;
|
|
18
|
+
};
|
|
19
|
+
export declare class Unanswered extends Error {
|
|
20
|
+
}
|
|
21
|
+
export declare function uncertainError(uncertainty: Uncertain): unknown;
|
|
22
|
+
export type Retries = {
|
|
23
|
+
failed(step: Step, instance: string, error: unknown): void;
|
|
24
|
+
unanswered(step: Step, instance: string): void;
|
|
25
|
+
uncertain(step: Step, instance: string, uncertainty: Uncertain): void;
|
|
26
|
+
succeeded(step: Step, instance: string): void;
|
|
27
|
+
};
|
|
28
|
+
export declare function createRetries(shell: Pick<RuntimeShell, 'retried' | 'succeeded'>): Retries;
|
|
29
|
+
export declare function retrying<T>(retries: Retries, step: Step, instance: string, ask: () => Promise<T>): () => Promise<T>;
|
|
30
|
+
//# sourceMappingURL=retried.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retried.d.ts","sourceRoot":"","sources":["../src/retried.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;A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,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,SAAS,GAAG,WAAW,CAAC,GAAG,OAAO,CA2CzF;AAED,wBAAgB,QAAQ,CAAC,CAAC,EACxB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACpB,MAAM,OAAO,CAAC,CAAC,CAAC,CAYlB"}
|
package/dist/retried.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { refusedForSpace } from './durability.js';
|
|
2
|
+
export const STEPS = [
|
|
3
|
+
'database',
|
|
4
|
+
'sign_in',
|
|
5
|
+
'connection',
|
|
6
|
+
'code',
|
|
7
|
+
'download',
|
|
8
|
+
'conversations',
|
|
9
|
+
'sending',
|
|
10
|
+
'reading',
|
|
11
|
+
];
|
|
12
|
+
export class Unanswered extends Error {
|
|
13
|
+
}
|
|
14
|
+
export function uncertainError(uncertainty) {
|
|
15
|
+
return 'failure' in uncertainty ? uncertainty.failure : new Unanswered();
|
|
16
|
+
}
|
|
17
|
+
export function createRetries(shell) {
|
|
18
|
+
const failing = new Map();
|
|
19
|
+
const handedErrors = new WeakSet();
|
|
20
|
+
function failingIn(step, instance) {
|
|
21
|
+
const instances = failing.get(step) ?? new Set();
|
|
22
|
+
instances.add(instance);
|
|
23
|
+
failing.set(step, instances);
|
|
24
|
+
}
|
|
25
|
+
function handed(failure, instance) {
|
|
26
|
+
failingIn(failure.step, instance);
|
|
27
|
+
shell.retried?.(failure);
|
|
28
|
+
}
|
|
29
|
+
const retries = {
|
|
30
|
+
failed(step, instance, error) {
|
|
31
|
+
if (refusedForSpace(error))
|
|
32
|
+
return;
|
|
33
|
+
if (typeof error === 'object' && error !== null) {
|
|
34
|
+
if (handedErrors.has(error)) {
|
|
35
|
+
failingIn(step, instance);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
handedErrors.add(error);
|
|
39
|
+
}
|
|
40
|
+
if (error instanceof Unanswered)
|
|
41
|
+
retries.unanswered(step, instance);
|
|
42
|
+
else
|
|
43
|
+
handed({ step, answered: true, error }, instance);
|
|
44
|
+
},
|
|
45
|
+
unanswered(step, instance) {
|
|
46
|
+
handed({ step, answered: false }, instance);
|
|
47
|
+
},
|
|
48
|
+
uncertain(step, instance, uncertainty) {
|
|
49
|
+
if ('failure' in uncertainty)
|
|
50
|
+
retries.failed(step, instance, uncertainty.failure);
|
|
51
|
+
else
|
|
52
|
+
retries.unanswered(step, instance);
|
|
53
|
+
},
|
|
54
|
+
succeeded(step, instance) {
|
|
55
|
+
const instances = failing.get(step);
|
|
56
|
+
if (instances === undefined || !instances.delete(instance) || instances.size > 0)
|
|
57
|
+
return;
|
|
58
|
+
failing.delete(step);
|
|
59
|
+
shell.succeeded?.(step);
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
return retries;
|
|
63
|
+
}
|
|
64
|
+
export function retrying(retries, step, instance, ask) {
|
|
65
|
+
return () => ask().then((answer) => {
|
|
66
|
+
retries.succeeded(step, instance);
|
|
67
|
+
return answer;
|
|
68
|
+
}, (error) => {
|
|
69
|
+
retries.failed(step, instance, error);
|
|
70
|
+
throw error;
|
|
71
|
+
});
|
|
72
|
+
}
|