@pod-os/core 0.18.1-rc.54389d8.0 → 0.18.1-rc.5f8057b.0
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/dist/index.js +38 -0
- package/lib/index.js +38 -0
- package/package.json +1 -1
- package/types/thing/Thing.d.ts +38 -0
package/dist/index.js
CHANGED
|
@@ -2821,6 +2821,12 @@ var Thing = class {
|
|
|
2821
2821
|
this.store = store;
|
|
2822
2822
|
this.editable = editable;
|
|
2823
2823
|
}
|
|
2824
|
+
/**
|
|
2825
|
+
* Returns a human-readable label for this thing. Tries to match common RDF terms
|
|
2826
|
+
* used for labels, such as `rdfs:label`, `schema:name` and others.
|
|
2827
|
+
*
|
|
2828
|
+
* If no such term is present, it will derive a label from the URI.
|
|
2829
|
+
*/
|
|
2824
2830
|
label() {
|
|
2825
2831
|
const value7 = this.anyValue(
|
|
2826
2832
|
"http://www.w3.org/2006/vcard/ns#fn",
|
|
@@ -2840,6 +2846,9 @@ var Thing = class {
|
|
|
2840
2846
|
}
|
|
2841
2847
|
return labelFromUri(this.uri);
|
|
2842
2848
|
}
|
|
2849
|
+
/**
|
|
2850
|
+
* Returns all the literal values that are linked to this thing
|
|
2851
|
+
*/
|
|
2843
2852
|
literals() {
|
|
2844
2853
|
const statements = this.store.statementsMatching(namedNode(this.uri));
|
|
2845
2854
|
const values2 = statements.filter((it) => isLiteral(it.object)).reduce(accumulateValues, {});
|
|
@@ -2849,6 +2858,9 @@ var Thing = class {
|
|
|
2849
2858
|
values: values2[predicate4]
|
|
2850
2859
|
}));
|
|
2851
2860
|
}
|
|
2861
|
+
/**
|
|
2862
|
+
* Returns all the links from this thing to other resources
|
|
2863
|
+
*/
|
|
2852
2864
|
relations(predicate4) {
|
|
2853
2865
|
const statements = this.store.statementsMatching(
|
|
2854
2866
|
namedNode(this.uri),
|
|
@@ -2861,6 +2873,9 @@ var Thing = class {
|
|
|
2861
2873
|
uris: values2[predicate5]
|
|
2862
2874
|
}));
|
|
2863
2875
|
}
|
|
2876
|
+
/**
|
|
2877
|
+
* Returns all the links from other resources to this thing
|
|
2878
|
+
*/
|
|
2864
2879
|
reverseRelations(predicate4) {
|
|
2865
2880
|
const statements = this.store.statementsMatching(
|
|
2866
2881
|
void 0,
|
|
@@ -2874,6 +2889,10 @@ var Thing = class {
|
|
|
2874
2889
|
uris: values2[predicate5]
|
|
2875
2890
|
}));
|
|
2876
2891
|
}
|
|
2892
|
+
/**
|
|
2893
|
+
* Returns any value linked from this thing via one of the given predicates
|
|
2894
|
+
* @param predicateUris
|
|
2895
|
+
*/
|
|
2877
2896
|
anyValue(...predicateUris) {
|
|
2878
2897
|
let value7;
|
|
2879
2898
|
predicateUris.some((it) => {
|
|
@@ -2882,6 +2901,10 @@ var Thing = class {
|
|
|
2882
2901
|
});
|
|
2883
2902
|
return value7;
|
|
2884
2903
|
}
|
|
2904
|
+
/**
|
|
2905
|
+
* Returns a literal value that describes this thing. Tries to match common RDF terms
|
|
2906
|
+
* used for descriptions, like `dct:description`, `schema:description` or `rdfs:comment`
|
|
2907
|
+
*/
|
|
2885
2908
|
description() {
|
|
2886
2909
|
return this.anyValue(
|
|
2887
2910
|
"http://purl.org/dc/terms/description",
|
|
@@ -2895,6 +2918,13 @@ var Thing = class {
|
|
|
2895
2918
|
"http://www.w3.org/2006/vcard/ns#note"
|
|
2896
2919
|
);
|
|
2897
2920
|
}
|
|
2921
|
+
/**
|
|
2922
|
+
* Returns the url of a picture or logo associated with this thing
|
|
2923
|
+
* Tries to match common RDF terms used for pictures like `schema:image`,
|
|
2924
|
+
* `vcard:photo` or `foaf:img`
|
|
2925
|
+
*
|
|
2926
|
+
* @return {Object} An object containing the `url` of the picture
|
|
2927
|
+
*/
|
|
2898
2928
|
picture() {
|
|
2899
2929
|
const directUrl = this.anyValue(
|
|
2900
2930
|
"http://schema.org/image",
|
|
@@ -2936,6 +2966,9 @@ var Thing = class {
|
|
|
2936
2966
|
url: url7
|
|
2937
2967
|
} : null;
|
|
2938
2968
|
}
|
|
2969
|
+
/**
|
|
2970
|
+
* Retrieves a list of RDF types for this thing.
|
|
2971
|
+
*/
|
|
2939
2972
|
types() {
|
|
2940
2973
|
const uriMap = this.store.findTypeURIs(namedNode(this.uri));
|
|
2941
2974
|
return Object.keys(uriMap).map((uri6) => ({
|
|
@@ -2943,6 +2976,11 @@ var Thing = class {
|
|
|
2943
2976
|
label: labelForType(uri6)
|
|
2944
2977
|
}));
|
|
2945
2978
|
}
|
|
2979
|
+
/**
|
|
2980
|
+
* Call this method to switch to a more specific subclass of Thing.
|
|
2981
|
+
*
|
|
2982
|
+
* @param SpecificThing - a subclass of Thing to assume
|
|
2983
|
+
*/
|
|
2946
2984
|
assume(SpecificThing) {
|
|
2947
2985
|
return new SpecificThing(this.uri, this.store, this.editable);
|
|
2948
2986
|
}
|
package/lib/index.js
CHANGED
|
@@ -35789,6 +35789,12 @@ _:patch
|
|
|
35789
35789
|
this.store = store;
|
|
35790
35790
|
this.editable = editable;
|
|
35791
35791
|
}
|
|
35792
|
+
/**
|
|
35793
|
+
* Returns a human-readable label for this thing. Tries to match common RDF terms
|
|
35794
|
+
* used for labels, such as `rdfs:label`, `schema:name` and others.
|
|
35795
|
+
*
|
|
35796
|
+
* If no such term is present, it will derive a label from the URI.
|
|
35797
|
+
*/
|
|
35792
35798
|
label() {
|
|
35793
35799
|
const value7 = this.anyValue(
|
|
35794
35800
|
"http://www.w3.org/2006/vcard/ns#fn",
|
|
@@ -35808,6 +35814,9 @@ _:patch
|
|
|
35808
35814
|
}
|
|
35809
35815
|
return labelFromUri(this.uri);
|
|
35810
35816
|
}
|
|
35817
|
+
/**
|
|
35818
|
+
* Returns all the literal values that are linked to this thing
|
|
35819
|
+
*/
|
|
35811
35820
|
literals() {
|
|
35812
35821
|
const statements = this.store.statementsMatching(namedNode(this.uri));
|
|
35813
35822
|
const values2 = statements.filter((it) => isLiteral(it.object)).reduce(accumulateValues, {});
|
|
@@ -35817,6 +35826,9 @@ _:patch
|
|
|
35817
35826
|
values: values2[predicate4]
|
|
35818
35827
|
}));
|
|
35819
35828
|
}
|
|
35829
|
+
/**
|
|
35830
|
+
* Returns all the links from this thing to other resources
|
|
35831
|
+
*/
|
|
35820
35832
|
relations(predicate4) {
|
|
35821
35833
|
const statements = this.store.statementsMatching(
|
|
35822
35834
|
namedNode(this.uri),
|
|
@@ -35829,6 +35841,9 @@ _:patch
|
|
|
35829
35841
|
uris: values2[predicate5]
|
|
35830
35842
|
}));
|
|
35831
35843
|
}
|
|
35844
|
+
/**
|
|
35845
|
+
* Returns all the links from other resources to this thing
|
|
35846
|
+
*/
|
|
35832
35847
|
reverseRelations(predicate4) {
|
|
35833
35848
|
const statements = this.store.statementsMatching(
|
|
35834
35849
|
void 0,
|
|
@@ -35842,6 +35857,10 @@ _:patch
|
|
|
35842
35857
|
uris: values2[predicate5]
|
|
35843
35858
|
}));
|
|
35844
35859
|
}
|
|
35860
|
+
/**
|
|
35861
|
+
* Returns any value linked from this thing via one of the given predicates
|
|
35862
|
+
* @param predicateUris
|
|
35863
|
+
*/
|
|
35845
35864
|
anyValue(...predicateUris) {
|
|
35846
35865
|
let value7;
|
|
35847
35866
|
predicateUris.some((it) => {
|
|
@@ -35850,6 +35869,10 @@ _:patch
|
|
|
35850
35869
|
});
|
|
35851
35870
|
return value7;
|
|
35852
35871
|
}
|
|
35872
|
+
/**
|
|
35873
|
+
* Returns a literal value that describes this thing. Tries to match common RDF terms
|
|
35874
|
+
* used for descriptions, like `dct:description`, `schema:description` or `rdfs:comment`
|
|
35875
|
+
*/
|
|
35853
35876
|
description() {
|
|
35854
35877
|
return this.anyValue(
|
|
35855
35878
|
"http://purl.org/dc/terms/description",
|
|
@@ -35863,6 +35886,13 @@ _:patch
|
|
|
35863
35886
|
"http://www.w3.org/2006/vcard/ns#note"
|
|
35864
35887
|
);
|
|
35865
35888
|
}
|
|
35889
|
+
/**
|
|
35890
|
+
* Returns the url of a picture or logo associated with this thing
|
|
35891
|
+
* Tries to match common RDF terms used for pictures like `schema:image`,
|
|
35892
|
+
* `vcard:photo` or `foaf:img`
|
|
35893
|
+
*
|
|
35894
|
+
* @return {Object} An object containing the `url` of the picture
|
|
35895
|
+
*/
|
|
35866
35896
|
picture() {
|
|
35867
35897
|
const directUrl = this.anyValue(
|
|
35868
35898
|
"http://schema.org/image",
|
|
@@ -35904,6 +35934,9 @@ _:patch
|
|
|
35904
35934
|
url: url7
|
|
35905
35935
|
} : null;
|
|
35906
35936
|
}
|
|
35937
|
+
/**
|
|
35938
|
+
* Retrieves a list of RDF types for this thing.
|
|
35939
|
+
*/
|
|
35907
35940
|
types() {
|
|
35908
35941
|
const uriMap = this.store.findTypeURIs(namedNode(this.uri));
|
|
35909
35942
|
return Object.keys(uriMap).map((uri6) => ({
|
|
@@ -35911,6 +35944,11 @@ _:patch
|
|
|
35911
35944
|
label: labelForType(uri6)
|
|
35912
35945
|
}));
|
|
35913
35946
|
}
|
|
35947
|
+
/**
|
|
35948
|
+
* Call this method to switch to a more specific subclass of Thing.
|
|
35949
|
+
*
|
|
35950
|
+
* @param SpecificThing - a subclass of Thing to assume
|
|
35951
|
+
*/
|
|
35914
35952
|
assume(SpecificThing) {
|
|
35915
35953
|
return new SpecificThing(this.uri, this.store, this.editable);
|
|
35916
35954
|
}
|
package/package.json
CHANGED
package/types/thing/Thing.d.ts
CHANGED
|
@@ -25,16 +25,54 @@ export declare class Thing {
|
|
|
25
25
|
* Whether the Thing can be edited according to its access control settings
|
|
26
26
|
*/
|
|
27
27
|
editable?: boolean);
|
|
28
|
+
/**
|
|
29
|
+
* Returns a human-readable label for this thing. Tries to match common RDF terms
|
|
30
|
+
* used for labels, such as `rdfs:label`, `schema:name` and others.
|
|
31
|
+
*
|
|
32
|
+
* If no such term is present, it will derive a label from the URI.
|
|
33
|
+
*/
|
|
28
34
|
label(): string;
|
|
35
|
+
/**
|
|
36
|
+
* Returns all the literal values that are linked to this thing
|
|
37
|
+
*/
|
|
29
38
|
literals(): Literal[];
|
|
39
|
+
/**
|
|
40
|
+
* Returns all the links from this thing to other resources
|
|
41
|
+
*/
|
|
30
42
|
relations(predicate?: string): Relation[];
|
|
43
|
+
/**
|
|
44
|
+
* Returns all the links from other resources to this thing
|
|
45
|
+
*/
|
|
31
46
|
reverseRelations(predicate?: string): Relation[];
|
|
47
|
+
/**
|
|
48
|
+
* Returns any value linked from this thing via one of the given predicates
|
|
49
|
+
* @param predicateUris
|
|
50
|
+
*/
|
|
32
51
|
anyValue(...predicateUris: string[]): undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Returns a literal value that describes this thing. Tries to match common RDF terms
|
|
54
|
+
* used for descriptions, like `dct:description`, `schema:description` or `rdfs:comment`
|
|
55
|
+
*/
|
|
33
56
|
description(): undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Returns the url of a picture or logo associated with this thing
|
|
59
|
+
* Tries to match common RDF terms used for pictures like `schema:image`,
|
|
60
|
+
* `vcard:photo` or `foaf:img`
|
|
61
|
+
*
|
|
62
|
+
* @return {Object} An object containing the `url` of the picture
|
|
63
|
+
*/
|
|
34
64
|
picture(): {
|
|
35
65
|
url: string;
|
|
36
66
|
} | null;
|
|
37
67
|
private findActivityStreamsPicture;
|
|
68
|
+
/**
|
|
69
|
+
* Retrieves a list of RDF types for this thing.
|
|
70
|
+
*/
|
|
38
71
|
types(): RdfType[];
|
|
72
|
+
/**
|
|
73
|
+
* Call this method to switch to a more specific subclass of Thing.
|
|
74
|
+
*
|
|
75
|
+
* @param SpecificThing - a subclass of Thing to assume
|
|
76
|
+
*/
|
|
39
77
|
assume<T>(SpecificThing: new (uri: string, store: IndexedFormula, editable: boolean) => T): T;
|
|
40
78
|
}
|