| [6b5d7da] | 1 | /**
|
|---|
| 2 | * Guardianship (FEP-633c) — the owner-only dashboard queues.
|
|---|
| 3 | *
|
|---|
| 4 | * Three OrderedCollections on the actor (shaer:queues), same contract as the
|
|---|
| [780a7c6] | 5 | * Shaer test daemon so the iOS/Android dashboards read them as-is:
|
|---|
| 6 | * - offers: pending handshake offers where I am a party (§3), with the full
|
|---|
| 7 | * accept tally so the client shows the right action
|
|---|
| 8 | * - follows: pending gated follows for my wards (§5.3) — Fase 2, empty for now
|
|---|
| 9 | * - wards: my committed wards
|
|---|
| [6b5d7da] | 10 | */
|
|---|
| [780a7c6] | 11 | import * as offers from './offers.js';
|
|---|
| [6b5d7da] | 12 | import * as relations from './relations.js';
|
|---|
| [6eab7e9] | 13 | import * as availability from './availability.js';
|
|---|
| [30d0e2c] | 14 | import * as handshake from './handshake.js';
|
|---|
| [6b5d7da] | 15 |
|
|---|
| 16 | const collection = (id, items) => ({
|
|---|
| 17 | id, type: 'OrderedCollection', totalItems: items.length, orderedItems: items,
|
|---|
| 18 | });
|
|---|
| 19 |
|
|---|
| [6eab7e9] | 20 | /** Pending offers where the local site is a party, each with its accept
|
|---|
| 21 | * tally. The same collection carries the running lapses (§3.6.3) this
|
|---|
| 22 | * account is a party to, exactly as the daemon serves them, so the Shaer
|
|---|
| 23 | * clients render both without a second fetch. */
|
|---|
| [6b5d7da] | 24 | export function offersCollection(id, slug, me) {
|
|---|
| [30d0e2c] | 25 | // §4.2: a handshake whose candidate could not be dereferenced is deferred,
|
|---|
| 26 | // not decided, and the last Accept may already have landed — so nothing else
|
|---|
| 27 | // would ever retry it. This poll is the schedule. Not awaited: the read
|
|---|
| 28 | // answers with what is true now, and a retry that succeeds surfaces in the
|
|---|
| 29 | // next one. `listForParty` settles closed windows on the way past.
|
|---|
| 30 | handshake.retryDeferred(slug).catch(() => { /* the next read tries again */ });
|
|---|
| [780a7c6] | 31 | const items = offers.listForParty(slug, me).map((o) => offers.queueItem(o, me));
|
|---|
| [6eab7e9] | 32 | items.push(...availability.lapseQueueItems(slug, me, Date.now()));
|
|---|
| [6b5d7da] | 33 | return collection(id, items);
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| [780a7c6] | 36 | /** Gated follows awaiting guardian approval — not built in Klonkt yet (Fase 2). */
|
|---|
| [6b5d7da] | 37 | export function followsCollection(id) {
|
|---|
| 38 | return collection(id, []);
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| [780a7c6] | 41 | /** The guardian's committed wards, with cached handle for display. */
|
|---|
| [6b5d7da] | 42 | export function wardsCollection(id, slug) {
|
|---|
| 43 | const items = relations.listWards(slug)
|
|---|
| 44 | .map((r) => ({ id: r.other_uri, 'shaer:handle': r.other_handle || undefined, since: r.created_at }));
|
|---|
| 45 | return collection(id, items);
|
|---|
| 46 | }
|
|---|
| 47 |
|
|---|
| [6eab7e9] | 48 | /** The ward's guardians with their availability (§3.6.1: never public,
|
|---|
| 49 | * owner-only): the real size of the safety net. Same shape as the daemon. */
|
|---|
| 50 | export function guardiansCollection(id, slug) {
|
|---|
| 51 | const uris = relations.listGuardians(slug).map((r) => r.other_uri);
|
|---|
| 52 | return collection(id, availability.statusesFor(slug, uris, Date.now()));
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | export default { offersCollection, followsCollection, wardsCollection, guardiansCollection };
|
|---|