| [6b5d7da] | 1 | /**
|
|---|
| 2 | * Guardianship (FEP-633c "Guardians") — JSON-LD vocabulary.
|
|---|
| 3 | *
|
|---|
| 4 | * One source of truth for the shaer namespace and the terms Klonkt emits.
|
|---|
| 5 | * ActivityPubService spreads SHAER_CONTEXT into its AP_CONTEXT term block, so
|
|---|
| 6 | * every outgoing document declares the namespace and strict JSON-LD
|
|---|
| 7 | * processors resolve the terms instead of dropping them.
|
|---|
| 8 | */
|
|---|
| 9 |
|
|---|
| 10 | /** The term block merged into AP_CONTEXT. */
|
|---|
| 11 | export const SHAER_CONTEXT = {
|
|---|
| 12 | // FEP-633c (Guardians): the shaer namespace. helpRequest marks a direct
|
|---|
| 13 | // note as a ward's call for help (spec 5.2.1); ignorable by everyone else.
|
|---|
| 14 | shaer: 'https://ns.klonkt.com/shaer#',
|
|---|
| 15 | };
|
|---|
| 16 |
|
|---|
| 17 | /** The Relationship value in the adoption Offer (FEP-633c §3), both forms. */
|
|---|
| 18 | export const GUARDIAN_RELATIONSHIP = 'https://ns.klonkt.com/shaer#Guardian';
|
|---|
| 19 | export const GUARDIAN_RELATIONSHIP_COMPACT = 'shaer:Guardian';
|
|---|
| 20 |
|
|---|
| 21 | /** True when an Offer's relationship names the guardian relation. */
|
|---|
| 22 | export function isGuardianRelationship(value) {
|
|---|
| 23 | return value === GUARDIAN_RELATIONSHIP || value === GUARDIAN_RELATIONSHIP_COMPACT;
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| [3d882bd] | 26 | /**
|
|---|
| 27 | * True when an actor document carries `shaer:guardians` — i.e. it is a ward,
|
|---|
| 28 | * and therefore not a valid guardian (§1). The one question §4 asks, in both
|
|---|
| 29 | * places it asks it: before committing a guardianship (§4.2) and before
|
|---|
| 30 | * delivering an escalation to one (§4.1).
|
|---|
| 31 | *
|
|---|
| 32 | * §2.1 allows the list as an array of URIs, a single URI, or a Collection, so
|
|---|
| 33 | * all three are read here rather than in each caller.
|
|---|
| 34 | */
|
|---|
| 35 | export function carriesGuardians(doc) {
|
|---|
| 36 | const g = doc && doc['shaer:guardians'];
|
|---|
| 37 | if (Array.isArray(g)) return g.length > 0;
|
|---|
| 38 | if (typeof g === 'string') return g.length > 0;
|
|---|
| 39 | if (g && typeof g === 'object') return Array.isArray(g.items) ? g.items.length > 0 : true;
|
|---|
| 40 | return false;
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 | export default { SHAER_CONTEXT, GUARDIAN_RELATIONSHIP, GUARDIAN_RELATIONSHIP_COMPACT, isGuardianRelationship, carriesGuardians };
|
|---|