Skip to content

Commit 087f095

Browse files
committed
doc(core): document public methods of Thing class
1 parent 05359ae commit 087f095

32 files changed

+364
-186
lines changed

core/src/thing/Thing.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ export class Thing {
3838
readonly editable: boolean = false,
3939
) {}
4040

41+
/**
42+
* Returns a human-readable label for this thing. Tries to match common RDF terms
43+
* used for labels, such as `rdfs:label`, `schema:name` and others.
44+
*
45+
* If no such term is present, it will derive a label from the URI.
46+
*/
4147
label() {
4248
const value = this.anyValue(
4349
"http://www.w3.org/2006/vcard/ns#fn",
@@ -58,6 +64,9 @@ export class Thing {
5864
return labelFromUri(this.uri);
5965
}
6066

67+
/**
68+
* Returns all the literal values that are linked to this thing
69+
*/
6170
literals(): Literal[] {
6271
const statements = this.store.statementsMatching(sym(this.uri));
6372

@@ -72,6 +81,9 @@ export class Thing {
7281
}));
7382
}
7483

84+
/**
85+
* Returns all the links from this thing to other resources
86+
*/
7587
relations(predicate?: string): Relation[] {
7688
const statements = this.store.statementsMatching(
7789
sym(this.uri),
@@ -89,6 +101,9 @@ export class Thing {
89101
}));
90102
}
91103

104+
/**
105+
* Returns all the links from other resources to this thing
106+
*/
92107
reverseRelations(predicate?: string): Relation[] {
93108
const statements = this.store.statementsMatching(
94109
undefined,
@@ -105,6 +120,10 @@ export class Thing {
105120
}));
106121
}
107122

123+
/**
124+
* Returns any value linked from this thing via one of the given predicates
125+
* @param predicateUris
126+
*/
108127
anyValue(...predicateUris: string[]) {
109128
let value;
110129
predicateUris.some((it) => {
@@ -114,6 +133,10 @@ export class Thing {
114133
return value;
115134
}
116135

136+
/**
137+
* Returns a literal value that describes this thing. Tries to match common RDF terms
138+
* used for descriptions, like `dct:description`, `schema:description` or `rdfs:comment`
139+
*/
117140
description() {
118141
return this.anyValue(
119142
"http://purl.org/dc/terms/description",
@@ -128,6 +151,13 @@ export class Thing {
128151
);
129152
}
130153

154+
/**
155+
* Returns the url of a picture or logo associated with this thing
156+
* Tries to match common RDF terms used for pictures like `schema:image`,
157+
* `vcard:photo` or `foaf:img`
158+
*
159+
* @return {Object} An object containing the `url` of the picture
160+
*/
131161
picture() {
132162
const directUrl = this.anyValue(
133163
"http://schema.org/image",
@@ -178,6 +208,9 @@ export class Thing {
178208
: null;
179209
}
180210

211+
/**
212+
* Retrieves a list of RDF types for this thing.
213+
*/
181214
types(): RdfType[] {
182215
const uriMap = this.store.findTypeURIs(sym(this.uri));
183216
return Object.keys(uriMap).map((uri) => ({
@@ -186,6 +219,11 @@ export class Thing {
186219
}));
187220
}
188221

222+
/**
223+
* Call this method to switch to a more specific subclass of Thing.
224+
*
225+
* @param SpecificThing - a subclass of Thing to assume
226+
*/
189227
assume<T>(
190228
SpecificThing: new (
191229
uri: string,

homepage/docs/reference/core/classes/AnonymousSession.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# Class: AnonymousSession
88

9-
Defined in: [authentication/index.ts:20](https://github.com/pod-os/PodOS/blob/1aecf6de76fa668e7779c8aad7b604e498d41244/core/src/authentication/index.ts#L20)
9+
Defined in: [authentication/index.ts:20](https://github.com/pod-os/PodOS/blob/05359ae5a5ec21be7fe13c91bc776d19e0a5d007/core/src/authentication/index.ts#L20)
1010

1111
## Implements
1212

@@ -30,7 +30,7 @@ Defined in: [authentication/index.ts:20](https://github.com/pod-os/PodOS/blob/1a
3030

3131
> **get** **authenticatedFetch**(): (`url`, `init?`) => `Promise`\<`Response`\>
3232
33-
Defined in: [authentication/index.ts:27](https://github.com/pod-os/PodOS/blob/1aecf6de76fa668e7779c8aad7b604e498d41244/core/src/authentication/index.ts#L27)
33+
Defined in: [authentication/index.ts:27](https://github.com/pod-os/PodOS/blob/05359ae5a5ec21be7fe13c91bc776d19e0a5d007/core/src/authentication/index.ts#L27)
3434

3535
##### Returns
3636

@@ -60,7 +60,7 @@ Defined in: [authentication/index.ts:27](https://github.com/pod-os/PodOS/blob/1a
6060

6161
> **login**(): `Promise`\<`void`\>
6262
63-
Defined in: [authentication/index.ts:38](https://github.com/pod-os/PodOS/blob/1aecf6de76fa668e7779c8aad7b604e498d41244/core/src/authentication/index.ts#L38)
63+
Defined in: [authentication/index.ts:38](https://github.com/pod-os/PodOS/blob/05359ae5a5ec21be7fe13c91bc776d19e0a5d007/core/src/authentication/index.ts#L38)
6464

6565
#### Returns
6666

@@ -76,7 +76,7 @@ Defined in: [authentication/index.ts:38](https://github.com/pod-os/PodOS/blob/1a
7676

7777
> **logout**(): `Promise`\<`void`\>
7878
79-
Defined in: [authentication/index.ts:42](https://github.com/pod-os/PodOS/blob/1aecf6de76fa668e7779c8aad7b604e498d41244/core/src/authentication/index.ts#L42)
79+
Defined in: [authentication/index.ts:42](https://github.com/pod-os/PodOS/blob/05359ae5a5ec21be7fe13c91bc776d19e0a5d007/core/src/authentication/index.ts#L42)
8080

8181
#### Returns
8282

@@ -92,7 +92,7 @@ Defined in: [authentication/index.ts:42](https://github.com/pod-os/PodOS/blob/1a
9292

9393
> **observeSession**(): `BehaviorSubject`\<[`SessionInfo`](../type-aliases/SessionInfo.md)\>
9494
95-
Defined in: [authentication/index.ts:34](https://github.com/pod-os/PodOS/blob/1aecf6de76fa668e7779c8aad7b604e498d41244/core/src/authentication/index.ts#L34)
95+
Defined in: [authentication/index.ts:34](https://github.com/pod-os/PodOS/blob/05359ae5a5ec21be7fe13c91bc776d19e0a5d007/core/src/authentication/index.ts#L34)
9696

9797
#### Returns
9898

homepage/docs/reference/core/classes/AssumeAlwaysOnline.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# Class: AssumeAlwaysOnline
88

9-
Defined in: [offline-cache/OnlineStatus.ts:5](https://github.com/pod-os/PodOS/blob/1aecf6de76fa668e7779c8aad7b604e498d41244/core/src/offline-cache/OnlineStatus.ts#L5)
9+
Defined in: [offline-cache/OnlineStatus.ts:5](https://github.com/pod-os/PodOS/blob/05359ae5a5ec21be7fe13c91bc776d19e0a5d007/core/src/offline-cache/OnlineStatus.ts#L5)
1010

1111
## Implements
1212

@@ -28,7 +28,7 @@ Defined in: [offline-cache/OnlineStatus.ts:5](https://github.com/pod-os/PodOS/bl
2828

2929
> **isOnline**(): `boolean`
3030
31-
Defined in: [offline-cache/OnlineStatus.ts:6](https://github.com/pod-os/PodOS/blob/1aecf6de76fa668e7779c8aad7b604e498d41244/core/src/offline-cache/OnlineStatus.ts#L6)
31+
Defined in: [offline-cache/OnlineStatus.ts:6](https://github.com/pod-os/PodOS/blob/05359ae5a5ec21be7fe13c91bc776d19e0a5d007/core/src/offline-cache/OnlineStatus.ts#L6)
3232

3333
#### Returns
3434

homepage/docs/reference/core/classes/BinaryFile.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# Class: BinaryFile
88

9-
Defined in: [files/BinaryFile.ts:3](https://github.com/pod-os/PodOS/blob/1aecf6de76fa668e7779c8aad7b604e498d41244/core/src/files/BinaryFile.ts#L3)
9+
Defined in: [files/BinaryFile.ts:3](https://github.com/pod-os/PodOS/blob/05359ae5a5ec21be7fe13c91bc776d19e0a5d007/core/src/files/BinaryFile.ts#L3)
1010

1111
## Implements
1212

@@ -18,7 +18,7 @@ Defined in: [files/BinaryFile.ts:3](https://github.com/pod-os/PodOS/blob/1aecf6d
1818

1919
> **new BinaryFile**(`url`, `data`): `BinaryFile`
2020
21-
Defined in: [files/BinaryFile.ts:4](https://github.com/pod-os/PodOS/blob/1aecf6de76fa668e7779c8aad7b604e498d41244/core/src/files/BinaryFile.ts#L4)
21+
Defined in: [files/BinaryFile.ts:4](https://github.com/pod-os/PodOS/blob/05359ae5a5ec21be7fe13c91bc776d19e0a5d007/core/src/files/BinaryFile.ts#L4)
2222

2323
#### Parameters
2424

@@ -40,7 +40,7 @@ Defined in: [files/BinaryFile.ts:4](https://github.com/pod-os/PodOS/blob/1aecf6d
4040

4141
> `readonly` **url**: `string`
4242
43-
Defined in: [files/BinaryFile.ts:5](https://github.com/pod-os/PodOS/blob/1aecf6de76fa668e7779c8aad7b604e498d41244/core/src/files/BinaryFile.ts#L5)
43+
Defined in: [files/BinaryFile.ts:5](https://github.com/pod-os/PodOS/blob/05359ae5a5ec21be7fe13c91bc776d19e0a5d007/core/src/files/BinaryFile.ts#L5)
4444

4545
#### Implementation of
4646

@@ -52,7 +52,7 @@ Defined in: [files/BinaryFile.ts:5](https://github.com/pod-os/PodOS/blob/1aecf6d
5252

5353
> **blob**(): `Blob`
5454
55-
Defined in: [files/BinaryFile.ts:9](https://github.com/pod-os/PodOS/blob/1aecf6de76fa668e7779c8aad7b604e498d41244/core/src/files/BinaryFile.ts#L9)
55+
Defined in: [files/BinaryFile.ts:9](https://github.com/pod-os/PodOS/blob/05359ae5a5ec21be7fe13c91bc776d19e0a5d007/core/src/files/BinaryFile.ts#L9)
5656

5757
#### Returns
5858

homepage/docs/reference/core/classes/BrokenFile.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# Class: BrokenFile
88

9-
Defined in: [files/BrokenFile.ts:4](https://github.com/pod-os/PodOS/blob/1aecf6de76fa668e7779c8aad7b604e498d41244/core/src/files/BrokenFile.ts#L4)
9+
Defined in: [files/BrokenFile.ts:4](https://github.com/pod-os/PodOS/blob/05359ae5a5ec21be7fe13c91bc776d19e0a5d007/core/src/files/BrokenFile.ts#L4)
1010

1111
## Implements
1212

@@ -18,7 +18,7 @@ Defined in: [files/BrokenFile.ts:4](https://github.com/pod-os/PodOS/blob/1aecf6d
1818

1919
> **new BrokenFile**(`url`, `status`): `BrokenFile`
2020
21-
Defined in: [files/BrokenFile.ts:5](https://github.com/pod-os/PodOS/blob/1aecf6de76fa668e7779c8aad7b604e498d41244/core/src/files/BrokenFile.ts#L5)
21+
Defined in: [files/BrokenFile.ts:5](https://github.com/pod-os/PodOS/blob/05359ae5a5ec21be7fe13c91bc776d19e0a5d007/core/src/files/BrokenFile.ts#L5)
2222

2323
#### Parameters
2424

@@ -40,15 +40,15 @@ Defined in: [files/BrokenFile.ts:5](https://github.com/pod-os/PodOS/blob/1aecf6d
4040

4141
> `readonly` **status**: [`HttpStatus`](HttpStatus.md)
4242
43-
Defined in: [files/BrokenFile.ts:7](https://github.com/pod-os/PodOS/blob/1aecf6de76fa668e7779c8aad7b604e498d41244/core/src/files/BrokenFile.ts#L7)
43+
Defined in: [files/BrokenFile.ts:7](https://github.com/pod-os/PodOS/blob/05359ae5a5ec21be7fe13c91bc776d19e0a5d007/core/src/files/BrokenFile.ts#L7)
4444

4545
***
4646

4747
### url
4848

4949
> `readonly` **url**: `string`
5050
51-
Defined in: [files/BrokenFile.ts:6](https://github.com/pod-os/PodOS/blob/1aecf6de76fa668e7779c8aad7b604e498d41244/core/src/files/BrokenFile.ts#L6)
51+
Defined in: [files/BrokenFile.ts:6](https://github.com/pod-os/PodOS/blob/05359ae5a5ec21be7fe13c91bc776d19e0a5d007/core/src/files/BrokenFile.ts#L6)
5252

5353
#### Implementation of
5454

@@ -60,7 +60,7 @@ Defined in: [files/BrokenFile.ts:6](https://github.com/pod-os/PodOS/blob/1aecf6d
6060

6161
> **blob**(): `null` \| `Blob`
6262
63-
Defined in: [files/BrokenFile.ts:14](https://github.com/pod-os/PodOS/blob/1aecf6de76fa668e7779c8aad7b604e498d41244/core/src/files/BrokenFile.ts#L14)
63+
Defined in: [files/BrokenFile.ts:14](https://github.com/pod-os/PodOS/blob/05359ae5a5ec21be7fe13c91bc776d19e0a5d007/core/src/files/BrokenFile.ts#L14)
6464

6565
#### Returns
6666

@@ -76,7 +76,7 @@ Defined in: [files/BrokenFile.ts:14](https://github.com/pod-os/PodOS/blob/1aecf6
7676

7777
> **toString**(): `string`
7878
79-
Defined in: [files/BrokenFile.ts:10](https://github.com/pod-os/PodOS/blob/1aecf6de76fa668e7779c8aad7b604e498d41244/core/src/files/BrokenFile.ts#L10)
79+
Defined in: [files/BrokenFile.ts:10](https://github.com/pod-os/PodOS/blob/05359ae5a5ec21be7fe13c91bc776d19e0a5d007/core/src/files/BrokenFile.ts#L10)
8080

8181
Returns a string representation of an object.
8282

homepage/docs/reference/core/classes/HttpStatus.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
# Class: HttpStatus
88

9-
Defined in: [files/HttpStatus.ts:1](https://github.com/pod-os/PodOS/blob/1aecf6de76fa668e7779c8aad7b604e498d41244/core/src/files/HttpStatus.ts#L1)
9+
Defined in: [files/HttpStatus.ts:1](https://github.com/pod-os/PodOS/blob/05359ae5a5ec21be7fe13c91bc776d19e0a5d007/core/src/files/HttpStatus.ts#L1)
1010

1111
## Constructors
1212

1313
### Constructor
1414

1515
> **new HttpStatus**(`code`, `text?`): `HttpStatus`
1616
17-
Defined in: [files/HttpStatus.ts:2](https://github.com/pod-os/PodOS/blob/1aecf6de76fa668e7779c8aad7b604e498d41244/core/src/files/HttpStatus.ts#L2)
17+
Defined in: [files/HttpStatus.ts:2](https://github.com/pod-os/PodOS/blob/05359ae5a5ec21be7fe13c91bc776d19e0a5d007/core/src/files/HttpStatus.ts#L2)
1818

1919
#### Parameters
2020

@@ -36,23 +36,23 @@ Defined in: [files/HttpStatus.ts:2](https://github.com/pod-os/PodOS/blob/1aecf6d
3636

3737
> `readonly` **code**: `number`
3838
39-
Defined in: [files/HttpStatus.ts:3](https://github.com/pod-os/PodOS/blob/1aecf6de76fa668e7779c8aad7b604e498d41244/core/src/files/HttpStatus.ts#L3)
39+
Defined in: [files/HttpStatus.ts:3](https://github.com/pod-os/PodOS/blob/05359ae5a5ec21be7fe13c91bc776d19e0a5d007/core/src/files/HttpStatus.ts#L3)
4040

4141
***
4242

4343
### text?
4444

4545
> `readonly` `optional` **text**: `string`
4646
47-
Defined in: [files/HttpStatus.ts:4](https://github.com/pod-os/PodOS/blob/1aecf6de76fa668e7779c8aad7b604e498d41244/core/src/files/HttpStatus.ts#L4)
47+
Defined in: [files/HttpStatus.ts:4](https://github.com/pod-os/PodOS/blob/05359ae5a5ec21be7fe13c91bc776d19e0a5d007/core/src/files/HttpStatus.ts#L4)
4848

4949
## Methods
5050

5151
### toString()
5252

5353
> **toString**(): `string`
5454
55-
Defined in: [files/HttpStatus.ts:7](https://github.com/pod-os/PodOS/blob/1aecf6de76fa668e7779c8aad7b604e498d41244/core/src/files/HttpStatus.ts#L7)
55+
Defined in: [files/HttpStatus.ts:7](https://github.com/pod-os/PodOS/blob/05359ae5a5ec21be7fe13c91bc776d19e0a5d007/core/src/files/HttpStatus.ts#L7)
5656

5757
#### Returns
5858

0 commit comments

Comments
 (0)