@fedify/fedify 0.11.0-dev.258 → 0.11.0-dev.259
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/CHANGES.md +1 -0
- package/esm/vocab/orderedcollectionpage.yaml +11 -0
- package/esm/vocab/vocab.js +195 -0
- package/package.json +1 -1
- package/types/vocab/vocab.d.ts +16 -2
- package/types/vocab/vocab.d.ts.map +1 -1
package/CHANGES.md
CHANGED
@@ -183,6 +183,7 @@ To be released.
|
|
183
183
|
[#76]: https://github.com/dahlia/fedify/pull/76
|
184
184
|
[#78]: https://github.com/dahlia/fedify/issues/78
|
185
185
|
[#79]: https://github.com/dahlia/fedify/issues/79
|
186
|
+
[#80]: https://github.com/dahlia/fedify/pull/80
|
186
187
|
|
187
188
|
|
188
189
|
Version 0.10.0
|
@@ -16,6 +16,17 @@ defaultContext:
|
|
16
16
|
Hashtag: "as:Hashtag"
|
17
17
|
|
18
18
|
properties:
|
19
|
+
- pluralName: items
|
20
|
+
singularName: item
|
21
|
+
uri: "https://www.w3.org/ns/activitystreams#items"
|
22
|
+
container: list
|
23
|
+
description: |
|
24
|
+
Identifies the items contained in a collection. The items might be ordered
|
25
|
+
or unordered.
|
26
|
+
range:
|
27
|
+
- "https://www.w3.org/ns/activitystreams#Object"
|
28
|
+
- "https://www.w3.org/ns/activitystreams#Link"
|
29
|
+
|
19
30
|
- singularName: startIndex
|
20
31
|
functional: true
|
21
32
|
uri: "https://www.w3.org/ns/activitystreams#startIndex"
|
package/esm/vocab/vocab.js
CHANGED
@@ -17654,6 +17654,7 @@ export class OrderedCollectionPage extends CollectionPage {
|
|
17654
17654
|
static get typeId() {
|
17655
17655
|
return new URL("https://www.w3.org/ns/activitystreams#OrderedCollectionPage");
|
17656
17656
|
}
|
17657
|
+
#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = [];
|
17657
17658
|
#_2W4yinFwqmpneu2h4m1mZ3pcLADd = [];
|
17658
17659
|
/**
|
17659
17660
|
* Constructs a new instance of OrderedCollectionPage with the given values.
|
@@ -17662,6 +17663,17 @@ export class OrderedCollectionPage extends CollectionPage {
|
|
17662
17663
|
*/
|
17663
17664
|
constructor(values, { documentLoader, contextLoader, } = {}) {
|
17664
17665
|
super(values, { documentLoader, contextLoader });
|
17666
|
+
if ("items" in values && values.items != null) {
|
17667
|
+
if (Array.isArray(values.items) &&
|
17668
|
+
values.items.every((v) => v instanceof Object || v instanceof Link || v instanceof URL)) {
|
17669
|
+
// @ts-ignore: type is checked above.
|
17670
|
+
this.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = values.items;
|
17671
|
+
}
|
17672
|
+
else {
|
17673
|
+
throw new TypeError("The items must be an array of type " +
|
17674
|
+
"Object | Link | URL" + ".");
|
17675
|
+
}
|
17676
|
+
}
|
17665
17677
|
if ("startIndex" in values && values.startIndex != null) {
|
17666
17678
|
if (typeof values.startIndex === "number" &&
|
17667
17679
|
Number.isInteger(values.startIndex) && values.startIndex >= 0) {
|
@@ -17682,6 +17694,18 @@ export class OrderedCollectionPage extends CollectionPage {
|
|
17682
17694
|
*/
|
17683
17695
|
clone(values = {}, options = {}) {
|
17684
17696
|
const clone = super.clone(values, options);
|
17697
|
+
clone.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = this.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg;
|
17698
|
+
if ("items" in values && values.items != null) {
|
17699
|
+
if (Array.isArray(values.items) &&
|
17700
|
+
values.items.every((v) => v instanceof Object || v instanceof Link || v instanceof URL)) {
|
17701
|
+
// @ts-ignore: type is checked above.
|
17702
|
+
clone.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = values.items;
|
17703
|
+
}
|
17704
|
+
else {
|
17705
|
+
throw new TypeError("The items must be an array of type " +
|
17706
|
+
"Object | Link | URL" + ".");
|
17707
|
+
}
|
17708
|
+
}
|
17685
17709
|
clone.#_2W4yinFwqmpneu2h4m1mZ3pcLADd = this.#_2W4yinFwqmpneu2h4m1mZ3pcLADd;
|
17686
17710
|
if ("startIndex" in values && values.startIndex != null) {
|
17687
17711
|
if (typeof values.startIndex === "number" &&
|
@@ -17696,6 +17720,69 @@ export class OrderedCollectionPage extends CollectionPage {
|
|
17696
17720
|
}
|
17697
17721
|
return clone;
|
17698
17722
|
}
|
17723
|
+
async #fetchItem(url, options = {}) {
|
17724
|
+
const documentLoader = options.documentLoader ?? this._documentLoader ??
|
17725
|
+
fetchDocumentLoader;
|
17726
|
+
const contextLoader = options.contextLoader ?? this._contextLoader ??
|
17727
|
+
fetchDocumentLoader;
|
17728
|
+
let fetchResult;
|
17729
|
+
try {
|
17730
|
+
fetchResult = await documentLoader(url.href);
|
17731
|
+
}
|
17732
|
+
catch (error) {
|
17733
|
+
if (options.suppressError) {
|
17734
|
+
getLogger(["fedify", "vocab"]).error("Failed to fetch {url}: {error}", { error, url: url.href });
|
17735
|
+
return null;
|
17736
|
+
}
|
17737
|
+
throw error;
|
17738
|
+
}
|
17739
|
+
const { document } = fetchResult;
|
17740
|
+
try {
|
17741
|
+
return await Object.fromJsonLd(document, { documentLoader, contextLoader });
|
17742
|
+
}
|
17743
|
+
catch (e) {
|
17744
|
+
if (!(e instanceof TypeError))
|
17745
|
+
throw e;
|
17746
|
+
}
|
17747
|
+
try {
|
17748
|
+
return await Link.fromJsonLd(document, { documentLoader, contextLoader });
|
17749
|
+
}
|
17750
|
+
catch (e) {
|
17751
|
+
if (!(e instanceof TypeError))
|
17752
|
+
throw e;
|
17753
|
+
}
|
17754
|
+
throw new TypeError("Expected an object of any type of: " +
|
17755
|
+
[
|
17756
|
+
"https://www.w3.org/ns/activitystreams#Object",
|
17757
|
+
"https://www.w3.org/ns/activitystreams#Link",
|
17758
|
+
].join(", "));
|
17759
|
+
}
|
17760
|
+
/**
|
17761
|
+
* Similar to
|
17762
|
+
* {@link OrderedCollectionPage.getItems},
|
17763
|
+
* but returns their `@id`s instead of the objects themselves.
|
17764
|
+
*/
|
17765
|
+
get itemIds() {
|
17766
|
+
return this.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg.map((v) => v instanceof URL ? v : v.id).filter((id) => id !== null);
|
17767
|
+
}
|
17768
|
+
/** Identifies the items contained in a collection. The items might be ordered
|
17769
|
+
* or unordered.
|
17770
|
+
*/
|
17771
|
+
async *getItems(options = {}) {
|
17772
|
+
const vs = this.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg;
|
17773
|
+
for (let i = 0; i < vs.length; i++) {
|
17774
|
+
const v = vs[i];
|
17775
|
+
if (v instanceof URL) {
|
17776
|
+
const fetched = await this.#fetchItem(v, options);
|
17777
|
+
if (fetched == null)
|
17778
|
+
continue;
|
17779
|
+
vs[i] = fetched;
|
17780
|
+
yield fetched;
|
17781
|
+
continue;
|
17782
|
+
}
|
17783
|
+
yield v;
|
17784
|
+
}
|
17785
|
+
}
|
17699
17786
|
/** A non-negative integer value identifying the relative position within
|
17700
17787
|
* the logical view of a strictly ordered collection.
|
17701
17788
|
*/
|
@@ -17721,6 +17808,20 @@ export class OrderedCollectionPage extends CollectionPage {
|
|
17721
17808
|
});
|
17722
17809
|
const values = baseValues[0];
|
17723
17810
|
array = [];
|
17811
|
+
for (const v of this.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg) {
|
17812
|
+
const element = v instanceof URL
|
17813
|
+
? { "@id": v.href }
|
17814
|
+
: v instanceof Object
|
17815
|
+
? await v.toJsonLd(options)
|
17816
|
+
: await v.toJsonLd(options);
|
17817
|
+
array.push(element);
|
17818
|
+
}
|
17819
|
+
if (array.length > 0) {
|
17820
|
+
values["https://www.w3.org/ns/activitystreams#items"] = {
|
17821
|
+
"@list": array,
|
17822
|
+
};
|
17823
|
+
}
|
17824
|
+
array = [];
|
17724
17825
|
for (const v of this.#_2W4yinFwqmpneu2h4m1mZ3pcLADd) {
|
17725
17826
|
const element = {
|
17726
17827
|
"@type": "http://www.w3.org/2001/XMLSchema#nonNegativeInteger",
|
@@ -17791,6 +17892,87 @@ export class OrderedCollectionPage extends CollectionPage {
|
|
17791
17892
|
if (!(instance instanceof OrderedCollectionPage)) {
|
17792
17893
|
throw new TypeError("Unexpected type: " + instance.constructor.name);
|
17793
17894
|
}
|
17895
|
+
const _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = [];
|
17896
|
+
const _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg__array = values["https://www.w3.org/ns/activitystreams#items"];
|
17897
|
+
for (const v of _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg__array == null
|
17898
|
+
? []
|
17899
|
+
: _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg__array.length === 1 &&
|
17900
|
+
"@list" in _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg__array[0]
|
17901
|
+
? _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg__array[0]["@list"]
|
17902
|
+
: _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg__array) {
|
17903
|
+
if (v == null)
|
17904
|
+
continue;
|
17905
|
+
if (typeof v === "object" && "@id" in v && !("@type" in v) &&
|
17906
|
+
globalThis.Object.keys(v).length === 1) {
|
17907
|
+
_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg.push(new URL(v["@id"]));
|
17908
|
+
continue;
|
17909
|
+
}
|
17910
|
+
const decoded = typeof v === "object" && "@type" in v &&
|
17911
|
+
Array.isArray(v["@type"]) &&
|
17912
|
+
[
|
17913
|
+
"https://www.w3.org/ns/activitystreams#Object",
|
17914
|
+
"http://joinmastodon.org/ns#Emoji",
|
17915
|
+
"https://www.w3.org/ns/activitystreams#Activity",
|
17916
|
+
"https://www.w3.org/ns/activitystreams#Accept",
|
17917
|
+
"https://www.w3.org/ns/activitystreams#Add",
|
17918
|
+
"https://www.w3.org/ns/activitystreams#Announce",
|
17919
|
+
"https://www.w3.org/ns/activitystreams#Create",
|
17920
|
+
"https://www.w3.org/ns/activitystreams#Delete",
|
17921
|
+
"https://www.w3.org/ns/activitystreams#Dislike",
|
17922
|
+
"https://www.w3.org/ns/activitystreams#Flag",
|
17923
|
+
"https://www.w3.org/ns/activitystreams#Follow",
|
17924
|
+
"https://www.w3.org/ns/activitystreams#Ignore",
|
17925
|
+
"https://www.w3.org/ns/activitystreams#Block",
|
17926
|
+
"https://www.w3.org/ns/activitystreams#IntransitiveActivity",
|
17927
|
+
"https://www.w3.org/ns/activitystreams#Arrive",
|
17928
|
+
"https://www.w3.org/ns/activitystreams#Question",
|
17929
|
+
"https://www.w3.org/ns/activitystreams#Join",
|
17930
|
+
"https://www.w3.org/ns/activitystreams#Leave",
|
17931
|
+
"https://www.w3.org/ns/activitystreams#Like",
|
17932
|
+
"https://www.w3.org/ns/activitystreams#Listen",
|
17933
|
+
"https://www.w3.org/ns/activitystreams#Offer",
|
17934
|
+
"https://www.w3.org/ns/activitystreams#Invite",
|
17935
|
+
"https://www.w3.org/ns/activitystreams#Reject",
|
17936
|
+
"https://www.w3.org/ns/activitystreams#Remove",
|
17937
|
+
"https://www.w3.org/ns/activitystreams#Undo",
|
17938
|
+
"https://www.w3.org/ns/activitystreams#Update",
|
17939
|
+
"https://www.w3.org/ns/activitystreams#Application",
|
17940
|
+
"https://www.w3.org/ns/activitystreams#Article",
|
17941
|
+
"https://www.w3.org/ns/activitystreams#Collection",
|
17942
|
+
"https://www.w3.org/ns/activitystreams#CollectionPage",
|
17943
|
+
"https://www.w3.org/ns/activitystreams#OrderedCollectionPage",
|
17944
|
+
"https://www.w3.org/ns/activitystreams#OrderedCollection",
|
17945
|
+
"https://www.w3.org/ns/activitystreams#Document",
|
17946
|
+
"https://www.w3.org/ns/activitystreams#Audio",
|
17947
|
+
"https://www.w3.org/ns/activitystreams#Image",
|
17948
|
+
"https://www.w3.org/ns/activitystreams#Page",
|
17949
|
+
"https://www.w3.org/ns/activitystreams#Video",
|
17950
|
+
"https://www.w3.org/ns/activitystreams#Event",
|
17951
|
+
"https://www.w3.org/ns/activitystreams#Group",
|
17952
|
+
"https://www.w3.org/ns/activitystreams#Note",
|
17953
|
+
"https://www.w3.org/ns/activitystreams#Organization",
|
17954
|
+
"https://www.w3.org/ns/activitystreams#Person",
|
17955
|
+
"https://www.w3.org/ns/activitystreams#Place",
|
17956
|
+
"https://www.w3.org/ns/activitystreams#Profile",
|
17957
|
+
"https://www.w3.org/ns/activitystreams#Relationship",
|
17958
|
+
"https://www.w3.org/ns/activitystreams#Service",
|
17959
|
+
"https://www.w3.org/ns/activitystreams#Tombstone",
|
17960
|
+
].some((t) => v["@type"].includes(t))
|
17961
|
+
? await Object.fromJsonLd(v, options)
|
17962
|
+
: typeof v === "object" && "@type" in v &&
|
17963
|
+
Array.isArray(v["@type"]) &&
|
17964
|
+
[
|
17965
|
+
"https://www.w3.org/ns/activitystreams#Link",
|
17966
|
+
"https://www.w3.org/ns/activitystreams#Hashtag",
|
17967
|
+
"https://www.w3.org/ns/activitystreams#Mention",
|
17968
|
+
].some((t) => v["@type"].includes(t))
|
17969
|
+
? await Link.fromJsonLd(v, options)
|
17970
|
+
: undefined;
|
17971
|
+
if (typeof decoded === "undefined")
|
17972
|
+
continue;
|
17973
|
+
_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg.push(decoded);
|
17974
|
+
}
|
17975
|
+
instance.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg;
|
17794
17976
|
const _2W4yinFwqmpneu2h4m1mZ3pcLADd = [];
|
17795
17977
|
const _2W4yinFwqmpneu2h4m1mZ3pcLADd__array = values["https://www.w3.org/ns/activitystreams#startIndex"];
|
17796
17978
|
for (const v of _2W4yinFwqmpneu2h4m1mZ3pcLADd__array == null
|
@@ -17808,6 +17990,19 @@ export class OrderedCollectionPage extends CollectionPage {
|
|
17808
17990
|
}
|
17809
17991
|
_getCustomInspectProxy() {
|
17810
17992
|
const proxy = super._getCustomInspectProxy();
|
17993
|
+
const _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = this.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg
|
17994
|
+
// deno-lint-ignore no-explicit-any
|
17995
|
+
.map((v) => v instanceof URL
|
17996
|
+
? {
|
17997
|
+
[Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
|
17998
|
+
[Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
|
17999
|
+
}
|
18000
|
+
: v);
|
18001
|
+
if (_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg.length > 1 ||
|
18002
|
+
!("item" in proxy) &&
|
18003
|
+
_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg.length > 0) {
|
18004
|
+
proxy.items = _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg;
|
18005
|
+
}
|
17811
18006
|
const _2W4yinFwqmpneu2h4m1mZ3pcLADd = this.#_2W4yinFwqmpneu2h4m1mZ3pcLADd
|
17812
18007
|
// deno-lint-ignore no-explicit-any
|
17813
18008
|
.map((v) => v instanceof URL
|
package/package.json
CHANGED
package/types/vocab/vocab.d.ts
CHANGED
@@ -7148,10 +7148,10 @@ export declare class OrderedCollectionPage extends CollectionPage {
|
|
7148
7148
|
current?: CollectionPage | URL | null;
|
7149
7149
|
first?: CollectionPage | URL | null;
|
7150
7150
|
last?: CollectionPage | URL | null;
|
7151
|
-
items?: (Object | Link | URL)[];
|
7152
7151
|
partOf?: Collection | URL | null;
|
7153
7152
|
next?: CollectionPage | URL | null;
|
7154
7153
|
prev?: CollectionPage | URL | null;
|
7154
|
+
items?: (Object | Link | URL)[];
|
7155
7155
|
startIndex?: number | null;
|
7156
7156
|
}, { documentLoader, contextLoader, }?: {
|
7157
7157
|
documentLoader?: DocumentLoader;
|
@@ -7213,15 +7213,29 @@ export declare class OrderedCollectionPage extends CollectionPage {
|
|
7213
7213
|
current?: CollectionPage | URL | null;
|
7214
7214
|
first?: CollectionPage | URL | null;
|
7215
7215
|
last?: CollectionPage | URL | null;
|
7216
|
-
items?: (Object | Link | URL)[];
|
7217
7216
|
partOf?: Collection | URL | null;
|
7218
7217
|
next?: CollectionPage | URL | null;
|
7219
7218
|
prev?: CollectionPage | URL | null;
|
7219
|
+
items?: (Object | Link | URL)[];
|
7220
7220
|
startIndex?: number | null;
|
7221
7221
|
}, options?: {
|
7222
7222
|
documentLoader?: DocumentLoader;
|
7223
7223
|
contextLoader?: DocumentLoader;
|
7224
7224
|
}): OrderedCollectionPage;
|
7225
|
+
/**
|
7226
|
+
* Similar to
|
7227
|
+
* {@link OrderedCollectionPage.getItems},
|
7228
|
+
* but returns their `@id`s instead of the objects themselves.
|
7229
|
+
*/
|
7230
|
+
get itemIds(): URL[];
|
7231
|
+
/** Identifies the items contained in a collection. The items might be ordered
|
7232
|
+
* or unordered.
|
7233
|
+
*/
|
7234
|
+
getItems(options?: {
|
7235
|
+
documentLoader?: DocumentLoader;
|
7236
|
+
contextLoader?: DocumentLoader;
|
7237
|
+
suppressError?: boolean;
|
7238
|
+
}): AsyncIterable<Object | Link>;
|
7225
7239
|
/** A non-negative integer value identifying the relative position within
|
7226
7240
|
* the logical view of a strictly ordered collection.
|
7227
7241
|
*/
|