@agentshouse/mdruntime-adapter 0.1.0-cd59fd8945dcb → 0.1.0-ce3fe65a95f49
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/AGENTS.md +139 -127
- package/dist/actions.d.ts +22 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +49 -5
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +102 -27
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +5 -2
- package/dist/handed.d.ts +15 -0
- package/dist/handed.d.ts.map +1 -0
- package/dist/handed.js +38 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/model.d.ts +0 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -3
- package/dist/read.d.ts +9 -6
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +73 -49
- package/dist/referrer.d.ts +7 -0
- package/dist/referrer.d.ts.map +1 -0
- package/dist/referrer.js +35 -0
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +2 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +107 -18
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +125 -10
- package/dist/transport.d.ts +25 -5
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +3 -0
- package/dist/write.d.ts +2 -9
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +54 -5
- package/package.json +2 -3
- package/dist/links.d.ts +0 -20
- package/dist/links.d.ts.map +0 -1
- package/dist/links.js +0 -104
package/dist/adapter.js
CHANGED
|
@@ -3,12 +3,13 @@ import { partModels, streamedModels, viewModels } from './model.js';
|
|
|
3
3
|
import { gathered, gatheredEach, selections } from './gather.js';
|
|
4
4
|
import { createSiteAdapter } from './site.js';
|
|
5
5
|
import { bootstrapOf, contentPrefixes, matchesScope, parseEnumeration, parseEnvelope, parseGrant, refreshFrom, viewOf, } from './read.js';
|
|
6
|
-
import {
|
|
6
|
+
import { acceptedHanded, enumeratedHanded, heldHanded, scopeHanded, streamedHanded, } from './handed.js';
|
|
7
7
|
import { houseAction } from './actions.js';
|
|
8
8
|
import { classifyDoor, classifyRead, discoveryFailure, doorRefusal } from './refusal.js';
|
|
9
9
|
import { houseNotifications } from './stream.js';
|
|
10
|
-
import { DOOR_BATCH, DOOR_BATCH_UPLOAD, DOOR_BOOTSTRAP, DOOR_DISCOVER, DOOR_ENUMERATE, DOOR_REVISIONS, } from './transport.js';
|
|
10
|
+
import { DOOR_BATCH, DOOR_BATCH_UPLOAD, DOOR_BOOTSTRAP, DOOR_DISCOVER, DOOR_ENUMERATE, DOOR_FILES_GET, DOOR_REVISIONS, } from './transport.js';
|
|
11
11
|
import { batchPaths, deltaBody, deltaBytes, deltaDigest, historyOutcome, houseChanges, mutationOutcome, operationHead, rejectedMapping, revisionBody, uploadable, } from './write.js';
|
|
12
|
+
import { houseReferrer } from './referrer.js';
|
|
12
13
|
import { followsVersion, logPosition, presented, reachedVersion, roomVersion, } from './version.js';
|
|
13
14
|
const UNCERTAIN = { kind: 'transport-uncertainty' };
|
|
14
15
|
const UNCERTAIN_READ = { kind: 'transport-uncertainty' };
|
|
@@ -33,7 +34,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
33
34
|
return { kind: 'room-not-readable', locator: entry.locator };
|
|
34
35
|
const next = envelope.next?.room === entry.authority ? envelope.next.path : null;
|
|
35
36
|
if (continued === null && next === null)
|
|
36
|
-
handed.set(entry.locator,
|
|
37
|
+
handed.set(entry.locator, scopeHanded(scope));
|
|
37
38
|
else
|
|
38
39
|
handed.delete(entry.locator);
|
|
39
40
|
notifications.reach(entry.authority, scope);
|
|
@@ -57,21 +58,18 @@ export function createAgentsHouseAdapter(options) {
|
|
|
57
58
|
const answer = refreshFrom(view, ask.fromRoomVersion);
|
|
58
59
|
if (answer.kind !== 'net-advancement')
|
|
59
60
|
return answer;
|
|
60
|
-
handed.set(ask.entry.locator,
|
|
61
|
+
handed.set(ask.entry.locator, enumeratedHanded(view, handed.get(ask.entry.locator)));
|
|
61
62
|
const models = await viewModels(view, ask.entry);
|
|
62
63
|
return models === undefined ? answer : { ...answer, models };
|
|
63
64
|
}
|
|
64
65
|
async function streamed(entry, request, from) {
|
|
65
|
-
const
|
|
66
|
-
if (
|
|
66
|
+
const held = handed.get(entry.locator);
|
|
67
|
+
if (held?.roomVersion !== request.fromRoomVersion)
|
|
67
68
|
return null;
|
|
68
|
-
const advanced = notifications.advance(entry, from, (path, revision) =>
|
|
69
|
+
const advanced = notifications.advance(entry, from, (path, revision) => held.revisions.get(path) === revision);
|
|
69
70
|
if (advanced === null)
|
|
70
71
|
return null;
|
|
71
|
-
|
|
72
|
-
if (relinked === null)
|
|
73
|
-
return null;
|
|
74
|
-
handed.set(entry.locator, relinked);
|
|
72
|
+
handed.set(entry.locator, streamedHanded(held, advanced));
|
|
75
73
|
const models = await streamedModels(advanced.schemas, entry, 'credential');
|
|
76
74
|
return models === undefined ? advanced.page : { ...advanced.page, models };
|
|
77
75
|
}
|
|
@@ -81,7 +79,7 @@ export function createAgentsHouseAdapter(options) {
|
|
|
81
79
|
const at = logPosition(room.roomVersion);
|
|
82
80
|
if (entry === undefined || at === null)
|
|
83
81
|
return [];
|
|
84
|
-
handed.set(room.locator,
|
|
82
|
+
handed.set(room.locator, heldHanded(room));
|
|
85
83
|
notifications.reach(entry.authority, at);
|
|
86
84
|
return [presented(entry.authority, at)];
|
|
87
85
|
});
|
|
@@ -90,19 +88,15 @@ export function createAgentsHouseAdapter(options) {
|
|
|
90
88
|
function adopted(entry, outcome) {
|
|
91
89
|
if (outcome.kind !== 'accepted')
|
|
92
90
|
return outcome;
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
handed.set(entry.locator, relinked.links);
|
|
100
|
-
const at = logPosition(accepted.roomVersion);
|
|
91
|
+
const held = handed.get(entry.locator);
|
|
92
|
+
if (held === undefined)
|
|
93
|
+
return outcome;
|
|
94
|
+
const follows = followsVersion(held.roomVersion, outcome.roomVersion);
|
|
95
|
+
handed.set(entry.locator, acceptedHanded(held, outcome, follows ? outcome.roomVersion : held.roomVersion));
|
|
96
|
+
const at = logPosition(outcome.roomVersion);
|
|
101
97
|
if (follows && at !== null)
|
|
102
98
|
notifications.reach(entry.authority, at);
|
|
103
|
-
return
|
|
104
|
-
? accepted
|
|
105
|
-
: { ...accepted, attachments: relinked.attachments };
|
|
99
|
+
return outcome;
|
|
106
100
|
}
|
|
107
101
|
function authorityFor(locator) {
|
|
108
102
|
return tracked.get(locator);
|
|
@@ -244,7 +238,30 @@ export function createAgentsHouseAdapter(options) {
|
|
|
244
238
|
await keep(upload);
|
|
245
239
|
return { body: { ...head, paths, upload, runtime: notifications.runtime } };
|
|
246
240
|
}
|
|
247
|
-
async function
|
|
241
|
+
async function staged(answer, batch) {
|
|
242
|
+
const refusal = doorRefusal(answer.body);
|
|
243
|
+
if (refusal?.code !== 'files_unstaged')
|
|
244
|
+
return null;
|
|
245
|
+
const grants = refusal.fields.upload;
|
|
246
|
+
if (!Array.isArray(grants))
|
|
247
|
+
return false;
|
|
248
|
+
for (const grant of grants) {
|
|
249
|
+
const { url, operation, sha256 } = grant;
|
|
250
|
+
const change = batch.changes.find((held) => held.kind === 'binary' && held.sha256 === sha256);
|
|
251
|
+
if (typeof url !== 'string' || typeof operation !== 'string' || change === undefined)
|
|
252
|
+
return false;
|
|
253
|
+
const delivered = await transport.transfer({
|
|
254
|
+
act: 'binary_stage',
|
|
255
|
+
url,
|
|
256
|
+
body: change.blob,
|
|
257
|
+
operation,
|
|
258
|
+
});
|
|
259
|
+
if (delivered.status !== 200)
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
async function submit(batch, head, changes, delta, bytes, entry, handed, keep) {
|
|
248
265
|
const inline = { ...head, changes, runtime: notifications.runtime };
|
|
249
266
|
const prepared = uploadable(inline, bytes, declared())
|
|
250
267
|
? await uploaded(head, changes, delta, bytes, entry, handed, keep)
|
|
@@ -252,7 +269,33 @@ export function createAgentsHouseAdapter(options) {
|
|
|
252
269
|
if ('outcome' in prepared)
|
|
253
270
|
return prepared.outcome;
|
|
254
271
|
const answer = await transport.door(DOOR_BATCH, prepared.body);
|
|
255
|
-
|
|
272
|
+
const stagedFiles = await staged(answer, batch);
|
|
273
|
+
if (stagedFiles === false)
|
|
274
|
+
return UNCERTAIN;
|
|
275
|
+
const settled = stagedFiles === null ? answer : await transport.door(DOOR_BATCH, prepared.body);
|
|
276
|
+
if (stagedFiles === true && (await staged(settled, batch)) !== null)
|
|
277
|
+
return UNCERTAIN;
|
|
278
|
+
return mutationOutcome(settled.status, settled.body, entry.locator, entry.handle);
|
|
279
|
+
}
|
|
280
|
+
async function downloaded(answer, locator) {
|
|
281
|
+
const failure = classifyDoor(answer.status, answer.body, locator);
|
|
282
|
+
if (failure !== null) {
|
|
283
|
+
return failure.kind === 'scoped-refusal'
|
|
284
|
+
? {
|
|
285
|
+
kind: 'rejected',
|
|
286
|
+
code: failure.code,
|
|
287
|
+
fields: failure.fields,
|
|
288
|
+
retryable: failure.retryable,
|
|
289
|
+
}
|
|
290
|
+
: failure;
|
|
291
|
+
}
|
|
292
|
+
const grant = parseGrant(answer.body);
|
|
293
|
+
if (grant === null || grant.method !== 'GET')
|
|
294
|
+
return UNCERTAIN_READ;
|
|
295
|
+
const read = await transport.download(grant.url);
|
|
296
|
+
if (read.status !== 200 || read.blob === null)
|
|
297
|
+
return UNCERTAIN_READ;
|
|
298
|
+
return { kind: 'binary', blob: read.blob };
|
|
256
299
|
}
|
|
257
300
|
return {
|
|
258
301
|
async authorize() {
|
|
@@ -314,10 +357,11 @@ export function createAgentsHouseAdapter(options) {
|
|
|
314
357
|
const delta = deltaBody(mapped.changes);
|
|
315
358
|
const bytes = deltaBytes(delta);
|
|
316
359
|
const handed = request.upload;
|
|
317
|
-
const
|
|
360
|
+
const batch = request.changeBatch;
|
|
361
|
+
const outcome = await submit(batch, head, mapped.changes, delta, bytes, entry, handed, keep);
|
|
318
362
|
if (handed === undefined || !lapsedGrant(outcome))
|
|
319
363
|
return adopted(entry, outcome);
|
|
320
|
-
return adopted(entry, await submit(head, mapped.changes, delta, bytes, entry, undefined, keep));
|
|
364
|
+
return adopted(entry, await submit(batch, head, mapped.changes, delta, bytes, entry, undefined, keep));
|
|
321
365
|
},
|
|
322
366
|
async history(_authorization, request) {
|
|
323
367
|
const entry = authorityFor(request.locator);
|
|
@@ -334,6 +378,37 @@ export function createAgentsHouseAdapter(options) {
|
|
|
334
378
|
...(request.revision === undefined ? {} : { revision: request.revision }),
|
|
335
379
|
});
|
|
336
380
|
},
|
|
381
|
+
async binary(_authorization, request) {
|
|
382
|
+
if (request.kind === 'path') {
|
|
383
|
+
const entry = authorityFor(request.locator);
|
|
384
|
+
if (entry === undefined)
|
|
385
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
386
|
+
const answer = await transport.door(DOOR_FILES_GET, {
|
|
387
|
+
room_ref: entry.authority,
|
|
388
|
+
path: request.path,
|
|
389
|
+
revision: request.revision,
|
|
390
|
+
});
|
|
391
|
+
return downloaded(answer, request.locator);
|
|
392
|
+
}
|
|
393
|
+
const referrer = houseReferrer(request.referrer, tracked);
|
|
394
|
+
if (referrer === null) {
|
|
395
|
+
return { kind: 'rejected', code: 'referrer_unknown', fields: {}, retryable: false };
|
|
396
|
+
}
|
|
397
|
+
const answer = await transport.door(DOOR_FILES_GET, {
|
|
398
|
+
file: request.fileRef,
|
|
399
|
+
referrer: referrer.referrer,
|
|
400
|
+
});
|
|
401
|
+
return downloaded(answer, referrer.locator);
|
|
402
|
+
},
|
|
403
|
+
referrerScope(referrer) {
|
|
404
|
+
const held = houseReferrer(referrer, tracked);
|
|
405
|
+
if (held === null)
|
|
406
|
+
return null;
|
|
407
|
+
if (held.locator === '')
|
|
408
|
+
return { kind: 'conversations' };
|
|
409
|
+
const { path } = held.referrer;
|
|
410
|
+
return { kind: 'room', locator: held.locator, ...(path === undefined ? {} : { path }) };
|
|
411
|
+
},
|
|
337
412
|
reached(locator, version, target) {
|
|
338
413
|
return reachedVersion(version, target, authorityFor(locator)?.logEpoch);
|
|
339
414
|
},
|
package/dist/discovery.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,SAAS,EACT,MAAM,EACN,aAAa,EACb,SAAS,EACV,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAA6B,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3E,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AAEnD,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAAU,CAAC;AAE1D,MAAM,MAAM,WAAW,GAAG;IACxB,uBAAuB,EAAE,MAAM,CAAC;IAChC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,wBAAwB,EAAE,MAAM,CAAC;IACjC,2BAA2B,EAAE,MAAM,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B,CAAC;AAEF,MAAM,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UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,WAAW,CAAC;IACpB,WAAW,EAAE,SAAS,kBAAkB,EAAE,CAAC;CAC5C,CAAC;AA8FF,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,sBAAsB,GAAG,IAAI,CAsB3E;AAmBD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,kBAAkB,GAAG,IAAI,CAa3E;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,kBAAkB,GAAG,gBAAgB,EAAE,CAW5E;AAQD,wBAAgB,WAAW,CAAC,QAAQ,EAAE,sBAAsB,GAAG,gBAAgB,EAAE,CAWhF;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,aAAa,EAAE,CAU5E;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAMhE;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,sBAAsB,GAAG,SAAS,UAAU,EAAE,CAWpF;AAED,wBAAgB,gBAAgB,IAAI,SAAS,UAAU,EAAE,CAOxD;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,cAAc,GAAG,cAAc,CAmBxE;AAED,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,IAAI,CAAC,sBAAsB,EAAE,QAAQ,CAAC,EAChD,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,QAAQ,EAAE,SAAS,UAAU,EAAE,GAC9B,SAAS,CAQX"}
|
package/dist/discovery.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { declaredActions, houseConversationAgents } from './actions.js';
|
|
1
|
+
import { declaredActions, houseConversationAgents, SITE_SUBMIT } from './actions.js';
|
|
2
2
|
import { readPosition, roomVersion } from './version.js';
|
|
3
3
|
export const PROVIDER_ACTIONS = 'provider-actions';
|
|
4
4
|
export const DISCOVER_PREFIXES = ['/'];
|
|
@@ -229,7 +229,10 @@ export function capabilities(document) {
|
|
|
229
229
|
}
|
|
230
230
|
export function siteCapabilities() {
|
|
231
231
|
return [
|
|
232
|
-
{
|
|
232
|
+
{
|
|
233
|
+
name: PROVIDER_ACTIONS,
|
|
234
|
+
actions: [{ name: SITE_SUBMIT, inputShape: {}, resultKind: 'house' }],
|
|
235
|
+
},
|
|
233
236
|
];
|
|
234
237
|
}
|
|
235
238
|
export function discoveredRoom(authority) {
|
package/dist/handed.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { HeldRoom, MutationResult } from '@agentshouse/mdruntime';
|
|
2
|
+
import type { HouseScope, HouseView } from './read.js';
|
|
3
|
+
import type { StreamedAdvancement } from './stream.js';
|
|
4
|
+
export type HandedRoom = {
|
|
5
|
+
roomVersion: string;
|
|
6
|
+
revisions: ReadonlyMap<string, string>;
|
|
7
|
+
};
|
|
8
|
+
export declare function scopeHanded(scope: HouseScope): HandedRoom;
|
|
9
|
+
export declare function heldHanded(held: HeldRoom): HandedRoom;
|
|
10
|
+
export declare function acceptedHanded(held: HandedRoom, accepted: Extract<MutationResult, {
|
|
11
|
+
kind: 'accepted';
|
|
12
|
+
}>, roomVersion: string): HandedRoom;
|
|
13
|
+
export declare function enumeratedHanded(view: HouseView, earlier: HandedRoom | undefined): HandedRoom;
|
|
14
|
+
export declare function streamedHanded(held: HandedRoom, advanced: StreamedAdvancement): HandedRoom;
|
|
15
|
+
//# sourceMappingURL=handed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handed.d.ts","sourceRoot":"","sources":["../src/handed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGvD,MAAM,MAAM,UAAU,GAAG;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC,CAAC;AAEF,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CASzD;AAOD,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,UAAU,CAErD;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,OAAO,CAAC,cAAc,EAAE;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,EACvD,WAAW,EAAE,MAAM,GAClB,UAAU,CAKZ;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,GAAG,SAAS,GAAG,UAAU,CAM7F;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,mBAAmB,GAAG,UAAU,CAM1F"}
|
package/dist/handed.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { roomVersion } from './version.js';
|
|
2
|
+
export function scopeHanded(scope) {
|
|
3
|
+
return {
|
|
4
|
+
roomVersion: roomVersion(scope),
|
|
5
|
+
revisions: new Map(scope.files.flatMap(({ path, revision }) => revision === undefined ? [] : [[path, revision]])),
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
function revised(revisions, path, revision) {
|
|
9
|
+
if (revision === undefined)
|
|
10
|
+
revisions.delete(path);
|
|
11
|
+
else
|
|
12
|
+
revisions.set(path, revision);
|
|
13
|
+
}
|
|
14
|
+
export function heldHanded(held) {
|
|
15
|
+
return { roomVersion: held.roomVersion, revisions: new Map(Object.entries(held.revisions)) };
|
|
16
|
+
}
|
|
17
|
+
export function acceptedHanded(held, accepted, roomVersion) {
|
|
18
|
+
const revisions = new Map(held.revisions);
|
|
19
|
+
for (const [path, revision] of Object.entries(accepted.revisions))
|
|
20
|
+
revisions.set(path, revision);
|
|
21
|
+
for (const path of accepted.removals)
|
|
22
|
+
revisions.delete(path);
|
|
23
|
+
return { roomVersion, revisions };
|
|
24
|
+
}
|
|
25
|
+
export function enumeratedHanded(view, earlier) {
|
|
26
|
+
const revisions = new Map(earlier?.revisions);
|
|
27
|
+
for (const change of view.changes) {
|
|
28
|
+
revised(revisions, change.path, 'removed' in change ? undefined : change.revision);
|
|
29
|
+
}
|
|
30
|
+
return { roomVersion: roomVersion(view), revisions };
|
|
31
|
+
}
|
|
32
|
+
export function streamedHanded(held, advanced) {
|
|
33
|
+
const revisions = new Map(held.revisions);
|
|
34
|
+
for (const entry of advanced.entries) {
|
|
35
|
+
revised(revisions, entry.path, entry.kind === 'removed' ? undefined : entry.revision);
|
|
36
|
+
}
|
|
37
|
+
return { roomVersion: advanced.page.roomVersion, revisions };
|
|
38
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { createAgentsHouseAdapter, type AgentsHouseAdapterOptions } from './adapter.js';
|
|
2
|
-
export { HOUSE_APP_ACTS } from './actions.js';
|
|
3
|
-
export type { HouseByteAct, HouseByteTransfer, HouseDoorAnswer, HouseHeldRoom, HouseOpening, HouseStream, HouseStreamEntry, HouseStreamFrame, HouseSiteTransport, HouseTransport, } from './transport.js';
|
|
2
|
+
export { HOUSE_APP_ACTS, HOUSE_APP_BATCHES, HOUSE_SITE_ACTS } from './actions.js';
|
|
3
|
+
export type { HouseByteAct, HouseByteTransfer, HouseBytesAnswer, HouseDoorAnswer, HouseHeldRoom, HouseOpening, HouseStream, HouseStreamEntry, HouseStreamFrame, HouseSiteTransport, HouseTransport, } from './transport.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAClF,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GACf,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { createAgentsHouseAdapter } from './adapter.js';
|
|
2
|
-
export { HOUSE_APP_ACTS } from './actions.js';
|
|
2
|
+
export { HOUSE_APP_ACTS, HOUSE_APP_BATCHES, HOUSE_SITE_ACTS } from './actions.js';
|
package/dist/model.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import type { TrackedAuthority } from './discovery.js';
|
|
|
3
3
|
import { type HouseScope, type HouseView } from './read.js';
|
|
4
4
|
import type { HouseMode, HouseStreamEntry } from './transport.js';
|
|
5
5
|
export declare function partModels(scope: HouseScope, tracked: TrackedAuthority, seen: ReadonlySet<string>, final: boolean): Promise<RoomModels | undefined>;
|
|
6
|
-
export declare function scopeModels(scope: HouseScope, tracked: TrackedAuthority): Promise<RoomModels | undefined>;
|
|
7
6
|
export declare function viewModels(view: HouseView, tracked: TrackedAuthority): Promise<RoomModels | undefined>;
|
|
8
7
|
export declare function streamedModels(schemas: ReadonlyMap<string, HouseStreamEntry>, tracked: TrackedAuthority, mode: HouseMode): Promise<RoomModels | undefined>;
|
|
9
8
|
//# sourceMappingURL=model.d.ts.map
|
package/dist/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAA0C,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACpG,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAoClE,wBAAgB,UAAU,CACxB,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,EACzB,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAKjC;AAED,wBAAgB,
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAA0C,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACpG,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAoClE,wBAAgB,UAAU,CACxB,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,EACzB,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAKjC;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAcjC;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,EAC9C,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAWjC"}
|
package/dist/model.js
CHANGED
|
@@ -33,9 +33,6 @@ export function partModels(scope, tracked, seen, final) {
|
|
|
33
33
|
return final && !seen.has(schema) ? ABSENT_SCHEMA : undefined;
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
|
-
export function scopeModels(scope, tracked) {
|
|
37
|
-
return partModels(scope, tracked, new Set(), true);
|
|
38
|
-
}
|
|
39
36
|
export function viewModels(view, tracked) {
|
|
40
37
|
return modelsOf(tracked, (schema) => {
|
|
41
38
|
const change = view.changes.find((candidate) => candidate.path === schema);
|
package/dist/read.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BootstrapPage, RefreshResult
|
|
1
|
+
import type { BinaryFile, BootstrapPage, RefreshResult } from '@agentshouse/mdruntime';
|
|
2
2
|
import type { TrackedAuthority } from './discovery.js';
|
|
3
3
|
import type { HouseMode } from './transport.js';
|
|
4
4
|
import { type LogPosition } from './version.js';
|
|
@@ -8,6 +8,7 @@ export type HouseManifestFile = {
|
|
|
8
8
|
revision: string | undefined;
|
|
9
9
|
version: string;
|
|
10
10
|
head?: HeadChange;
|
|
11
|
+
binary?: BinaryFile;
|
|
11
12
|
};
|
|
12
13
|
export type HouseContent = {
|
|
13
14
|
path: string;
|
|
@@ -17,7 +18,6 @@ export type HouseScope = LogPosition & {
|
|
|
17
18
|
anchor: string;
|
|
18
19
|
files: readonly HouseManifestFile[];
|
|
19
20
|
contents: readonly HouseContent[];
|
|
20
|
-
attachments?: readonly RoomAttachment[];
|
|
21
21
|
};
|
|
22
22
|
export type HouseCursor = {
|
|
23
23
|
room: string;
|
|
@@ -46,14 +46,14 @@ export type HouseChange = {
|
|
|
46
46
|
head?: HeadChange;
|
|
47
47
|
} | {
|
|
48
48
|
path: string;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
binary: BinaryFile;
|
|
50
|
+
revision: string | undefined;
|
|
51
|
+
version: string;
|
|
52
|
+
head?: HeadChange;
|
|
52
53
|
};
|
|
53
54
|
export type HouseView = LogPosition & {
|
|
54
55
|
authority: string;
|
|
55
56
|
changes: readonly HouseChange[];
|
|
56
|
-
attachments?: readonly RoomAttachment[];
|
|
57
57
|
};
|
|
58
58
|
export type HouseEnumeration = {
|
|
59
59
|
authorities: readonly HouseView[];
|
|
@@ -66,8 +66,11 @@ export declare function headChange(held: {
|
|
|
66
66
|
readonly author?: unknown;
|
|
67
67
|
readonly created_at?: unknown;
|
|
68
68
|
}): HeadChange | undefined | null;
|
|
69
|
+
export declare function binaryFileOf(held: Readonly<Record<string, unknown>>): BinaryFile | undefined | null;
|
|
69
70
|
export declare function parseEnvelope(body: unknown): HouseEnvelope | null;
|
|
70
71
|
export declare function parseSiteBootstrap(body: unknown): HouseScope | null;
|
|
72
|
+
export declare function siteBootstrapNext(body: unknown): string | null;
|
|
73
|
+
export declare function siteBootstrapOffset(body: unknown): number | null;
|
|
71
74
|
export declare function parseEnumeration(body: unknown, mode: HouseMode): HouseEnumeration | null;
|
|
72
75
|
export declare function advancedScope(scope: HouseScope, view: HouseView): HouseScope;
|
|
73
76
|
export declare function matchesScope(scope: HouseScope, tracked: TrackedAuthority): boolean;
|
package/dist/read.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EAEb,aAAa,
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,aAAa,EAEb,aAAa,EACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB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B;AAoED,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,aAAa,GAAG,IAAI,CAYjE;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAEnE;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAG9D;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAKhE;AAqCD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,GAAG,gBAAgB,GAAG,IAAI,CAmBxF;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,GAAG,UAAU,CAuB5E;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAElF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,aAAa,CAqB5D;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAO9E;AAED,wBAAgB,MAAM,CACpB,WAAW,EAAE,gBAAgB,EAC7B,OAAO,EAAE,gBAAgB,GACxB,SAAS,GAAG,SAAS,CAEvB;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,GAAG,aAAa,CA0BnF"}
|
package/dist/read.js
CHANGED
|
@@ -51,8 +51,19 @@ export function headChange(held) {
|
|
|
51
51
|
function headed(head) {
|
|
52
52
|
return head === undefined ? {} : { head };
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
54
|
+
export function binaryFileOf(held) {
|
|
55
|
+
if (held.file === undefined)
|
|
56
|
+
return undefined;
|
|
57
|
+
const { file, bytes, media_type: mediaType, sha256 } = held;
|
|
58
|
+
if (typeof file !== 'string' ||
|
|
59
|
+
typeof bytes !== 'number' ||
|
|
60
|
+
typeof mediaType !== 'string' ||
|
|
61
|
+
typeof sha256 !== 'string')
|
|
62
|
+
return null;
|
|
63
|
+
return { fileRef: file, byteLength: bytes, mediaType, sha256 };
|
|
64
|
+
}
|
|
65
|
+
function binaried(binary) {
|
|
66
|
+
return binary === undefined ? {} : { binary };
|
|
56
67
|
}
|
|
57
68
|
function parseFile(value, mode) {
|
|
58
69
|
if (typeof value !== 'object' || value === null)
|
|
@@ -61,16 +72,29 @@ function parseFile(value, mode) {
|
|
|
61
72
|
if (typeof file.path !== 'string')
|
|
62
73
|
return null;
|
|
63
74
|
const head = headChange(file);
|
|
64
|
-
|
|
75
|
+
const binary = binaryFileOf(file);
|
|
76
|
+
if (head === null || binary === null)
|
|
65
77
|
return null;
|
|
66
78
|
if (mode === 'site') {
|
|
67
79
|
if (typeof file.sha256 !== 'string')
|
|
68
80
|
return null;
|
|
69
|
-
return {
|
|
81
|
+
return {
|
|
82
|
+
path: file.path,
|
|
83
|
+
revision: binary?.sha256,
|
|
84
|
+
version: file.sha256,
|
|
85
|
+
...headed(head),
|
|
86
|
+
...binaried(binary),
|
|
87
|
+
};
|
|
70
88
|
}
|
|
71
89
|
if (typeof file.revision !== 'string')
|
|
72
90
|
return null;
|
|
73
|
-
return {
|
|
91
|
+
return {
|
|
92
|
+
path: file.path,
|
|
93
|
+
revision: file.revision,
|
|
94
|
+
version: file.revision,
|
|
95
|
+
...headed(head),
|
|
96
|
+
...binaried(binary),
|
|
97
|
+
};
|
|
74
98
|
}
|
|
75
99
|
function parseScope(value, mode) {
|
|
76
100
|
if (typeof value !== 'object' || value === null)
|
|
@@ -106,9 +130,7 @@ function parseScope(value, mode) {
|
|
|
106
130
|
return null;
|
|
107
131
|
contents.push({ path: content.path, content: content.content });
|
|
108
132
|
}
|
|
109
|
-
|
|
110
|
-
return { anchor: manifest.anchor, ...at, files, contents };
|
|
111
|
-
return { anchor: manifest.anchor, ...at, files, contents, attachments: [] };
|
|
133
|
+
return { anchor: manifest.anchor, ...at, files, contents };
|
|
112
134
|
}
|
|
113
135
|
function parseCursor(value) {
|
|
114
136
|
if (typeof value !== 'object' || value === null)
|
|
@@ -138,6 +160,18 @@ export function parseEnvelope(body) {
|
|
|
138
160
|
export function parseSiteBootstrap(body) {
|
|
139
161
|
return parseScope(body, 'site');
|
|
140
162
|
}
|
|
163
|
+
export function siteBootstrapNext(body) {
|
|
164
|
+
if (typeof body !== 'object' || body === null || !('next' in body))
|
|
165
|
+
return null;
|
|
166
|
+
return typeof body.next === 'string' && body.next.length > 0 ? body.next : null;
|
|
167
|
+
}
|
|
168
|
+
export function siteBootstrapOffset(body) {
|
|
169
|
+
if (typeof body !== 'object' || body === null || !('offset' in body))
|
|
170
|
+
return null;
|
|
171
|
+
return Number.isSafeInteger(body.offset) && body.offset > 0
|
|
172
|
+
? body.offset
|
|
173
|
+
: null;
|
|
174
|
+
}
|
|
141
175
|
function parseChange(value, mode) {
|
|
142
176
|
if (typeof value !== 'object' || value === null)
|
|
143
177
|
return null;
|
|
@@ -147,8 +181,15 @@ function parseChange(value, mode) {
|
|
|
147
181
|
if (held.removed === true)
|
|
148
182
|
return { path: held.path, removed: true };
|
|
149
183
|
const head = headChange(held);
|
|
150
|
-
|
|
184
|
+
const binary = binaryFileOf(held);
|
|
185
|
+
if (head === null || binary === null)
|
|
151
186
|
return null;
|
|
187
|
+
if (binary !== undefined) {
|
|
188
|
+
if (mode === 'credential' && typeof held.revision !== 'string')
|
|
189
|
+
return null;
|
|
190
|
+
const revision = typeof held.revision === 'string' ? held.revision : binary.sha256;
|
|
191
|
+
return { path: held.path, binary, revision, version: revision, ...headed(head) };
|
|
192
|
+
}
|
|
152
193
|
if (mode === 'site') {
|
|
153
194
|
if (typeof held.content !== 'string' || typeof held.sha256 !== 'string')
|
|
154
195
|
return null;
|
|
@@ -169,12 +210,6 @@ function parseChange(value, mode) {
|
|
|
169
210
|
...headed(head),
|
|
170
211
|
};
|
|
171
212
|
}
|
|
172
|
-
if (typeof held.reference === 'object' && held.reference !== null) {
|
|
173
|
-
const reference = held.reference;
|
|
174
|
-
if (typeof reference.revision !== 'string')
|
|
175
|
-
return null;
|
|
176
|
-
return { path: held.path, reference: { revision: reference.revision } };
|
|
177
|
-
}
|
|
178
213
|
return null;
|
|
179
214
|
}
|
|
180
215
|
export function parseEnumeration(body, mode) {
|
|
@@ -199,11 +234,7 @@ export function parseEnumeration(body, mode) {
|
|
|
199
234
|
return null;
|
|
200
235
|
changes.push(mapped);
|
|
201
236
|
}
|
|
202
|
-
|
|
203
|
-
authorities.push({ authority: held.authority, ...at, changes });
|
|
204
|
-
continue;
|
|
205
|
-
}
|
|
206
|
-
authorities.push({ authority: held.authority, ...at, changes, attachments: [] });
|
|
237
|
+
authorities.push({ authority: held.authority, ...at, changes });
|
|
207
238
|
}
|
|
208
239
|
return { authorities };
|
|
209
240
|
}
|
|
@@ -215,18 +246,15 @@ export function advancedScope(scope, view) {
|
|
|
215
246
|
contents.delete(change.path);
|
|
216
247
|
if ('removed' in change)
|
|
217
248
|
continue;
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
249
|
+
files.set(change.path, {
|
|
250
|
+
path: change.path,
|
|
251
|
+
revision: change.revision,
|
|
252
|
+
version: change.version,
|
|
253
|
+
...headed(change.head),
|
|
254
|
+
...('binary' in change ? { binary: change.binary } : {}),
|
|
255
|
+
});
|
|
256
|
+
if ('content' in change)
|
|
225
257
|
contents.set(change.path, change.content);
|
|
226
|
-
continue;
|
|
227
|
-
}
|
|
228
|
-
const { revision } = change.reference;
|
|
229
|
-
files.set(change.path, { path: change.path, revision, version: revision });
|
|
230
258
|
}
|
|
231
259
|
return {
|
|
232
260
|
...scope,
|
|
@@ -244,16 +272,16 @@ export function bootstrapOf(scope) {
|
|
|
244
272
|
const documents = {};
|
|
245
273
|
const revisions = {};
|
|
246
274
|
const changes = {};
|
|
247
|
-
const
|
|
275
|
+
const binaryFiles = {};
|
|
248
276
|
for (const file of scope.files) {
|
|
249
277
|
if (file.revision !== undefined)
|
|
250
278
|
revisions[file.path] = file.revision;
|
|
251
279
|
if (file.head !== undefined)
|
|
252
280
|
changes[file.path] = file.head;
|
|
253
281
|
const content = contents.get(file.path);
|
|
254
|
-
if (
|
|
255
|
-
|
|
256
|
-
else
|
|
282
|
+
if (file.binary !== undefined)
|
|
283
|
+
binaryFiles[file.path] = file.binary;
|
|
284
|
+
else if (content !== undefined)
|
|
257
285
|
documents[file.path] = content;
|
|
258
286
|
}
|
|
259
287
|
return {
|
|
@@ -262,8 +290,7 @@ export function bootstrapOf(scope) {
|
|
|
262
290
|
documents,
|
|
263
291
|
revisions,
|
|
264
292
|
changes,
|
|
265
|
-
|
|
266
|
-
...declared(scope.attachments),
|
|
293
|
+
binaryFiles,
|
|
267
294
|
};
|
|
268
295
|
}
|
|
269
296
|
export function schemaOf(scope, schema) {
|
|
@@ -284,23 +311,21 @@ export function refreshFrom(view, fromRoomVersion) {
|
|
|
284
311
|
const documents = {};
|
|
285
312
|
const revisions = {};
|
|
286
313
|
const changes = {};
|
|
287
|
-
const
|
|
314
|
+
const binaryFiles = {};
|
|
288
315
|
const removals = [];
|
|
289
316
|
for (const change of view.changes) {
|
|
290
317
|
if ('removed' in change) {
|
|
291
318
|
removals.push(change.path);
|
|
292
319
|
continue;
|
|
293
320
|
}
|
|
294
|
-
if ('content' in change)
|
|
321
|
+
if ('content' in change)
|
|
295
322
|
documents[change.path] = change.content;
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
binaryTargets.push(change.path);
|
|
303
|
-
revisions[change.path] = change.reference.revision;
|
|
323
|
+
else
|
|
324
|
+
binaryFiles[change.path] = change.binary;
|
|
325
|
+
if (change.revision !== undefined)
|
|
326
|
+
revisions[change.path] = change.revision;
|
|
327
|
+
if (change.head !== undefined)
|
|
328
|
+
changes[change.path] = change.head;
|
|
304
329
|
}
|
|
305
330
|
return {
|
|
306
331
|
kind: 'net-advancement',
|
|
@@ -308,8 +333,7 @@ export function refreshFrom(view, fromRoomVersion) {
|
|
|
308
333
|
documents,
|
|
309
334
|
revisions,
|
|
310
335
|
changes,
|
|
311
|
-
|
|
336
|
+
binaryFiles,
|
|
312
337
|
removals: removals.sort(),
|
|
313
|
-
...declared(view.attachments),
|
|
314
338
|
};
|
|
315
339
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TrackedAuthority } from './discovery.js';
|
|
2
|
+
export type HouseReferrer = {
|
|
3
|
+
locator: string;
|
|
4
|
+
referrer: Readonly<Record<string, string>>;
|
|
5
|
+
};
|
|
6
|
+
export declare function houseReferrer(referrer: unknown, tracked: ReadonlyMap<string, TrackedAuthority>): HouseReferrer | null;
|
|
7
|
+
//# sourceMappingURL=referrer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"referrer.d.ts","sourceRoot":"","sources":["../src/referrer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,MAAM,MAAM,aAAa,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAAE,CAAC;AAgB5F,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAC7C,aAAa,GAAG,IAAI,CAqBtB"}
|