@fedify/fedify 0.10.0-dev.209 → 0.10.0-dev.211
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 +2 -0
- package/FEDERATION.md +1 -0
- package/esm/vocab/question.yaml +43 -0
- package/esm/vocab/vocab.js +311 -0
- package/package.json +1 -1
- package/types/vocab/vocab.d.ts +186 -0
- package/types/vocab/vocab.d.ts.map +1 -1
package/CHANGES.md
CHANGED
@@ -106,6 +106,8 @@ To be released.
|
|
106
106
|
- The `Context.sendActivity()` method's first parameter now accepts
|
107
107
|
`SenderKeyPair[]` as well.
|
108
108
|
|
109
|
+
- Added `Question` class to Activity Vocabulary API.
|
110
|
+
|
109
111
|
- Added `context` option to `Object.toJsonLd()` method. This applies to
|
110
112
|
any subclasses of the `Object` class too.
|
111
113
|
|
package/FEDERATION.md
CHANGED
@@ -56,6 +56,7 @@ lists the activity types that Fedify provides:
|
|
56
56
|
- [`Follow`](https://jsr.io/@fedify/fedify/doc/vocab/~/Follow)
|
57
57
|
- [`Ignore`](https://jsr.io/@fedify/fedify/doc/vocab/~/Ignore)
|
58
58
|
- [`Like`](https://jsr.io/@fedify/fedify/doc/vocab/~/Like)
|
59
|
+
- [`Question`](https://jsr.io/@fedify/fedify/doc/vocab/~/Question)
|
59
60
|
- [`Reject`](https://jsr.io/@fedify/fedify/doc/vocab/~/Reject)
|
60
61
|
- [`Remove`](https://jsr.io/@fedify/fedify/doc/vocab/~/Remove)
|
61
62
|
- [`Undo`](https://jsr.io/@fedify/fedify/doc/vocab/~/Undo)
|
@@ -0,0 +1,43 @@
|
|
1
|
+
$schema: ../codegen/schema.yaml
|
2
|
+
name: Question
|
3
|
+
uri: "https://www.w3.org/ns/activitystreams#Question"
|
4
|
+
extends: "https://www.w3.org/ns/activitystreams#IntransitiveActivity"
|
5
|
+
entity: true
|
6
|
+
description: |
|
7
|
+
Represents a question being asked. Question objects are an extension of
|
8
|
+
{@link IntransitiveActivity}. That is, the Question object is an Activity,
|
9
|
+
but the direct object is the question itself and therefore it would not
|
10
|
+
contain an `object` property.
|
11
|
+
|
12
|
+
Either of the `anyOf` and `oneOf` properties *may* be used to express possible
|
13
|
+
answers, but a Question object *must not* have both properties.
|
14
|
+
defaultContext:
|
15
|
+
- "https://www.w3.org/ns/activitystreams"
|
16
|
+
- "https://w3id.org/security/data-integrity/v1"
|
17
|
+
- toot: "http://joinmastodon.org/ns#"
|
18
|
+
sensitive: "as:sensitive"
|
19
|
+
Emoji: "toot:Emoji"
|
20
|
+
Hashtag: "as:Hashtag"
|
21
|
+
|
22
|
+
properties:
|
23
|
+
- pluralName: exclusiveOptions
|
24
|
+
singularName: exclusiveOption
|
25
|
+
singularAccessor: false
|
26
|
+
uri: "https://www.w3.org/ns/activitystreams#oneOf"
|
27
|
+
description: |
|
28
|
+
Identifies an exclusive option for a Question. Use of `exclusiveOptions`
|
29
|
+
implies that the Question can have only a single answer. To indicate that
|
30
|
+
a Question can have multiple answers, use `inclusiveOptions`.
|
31
|
+
range:
|
32
|
+
- "https://www.w3.org/ns/activitystreams#Object"
|
33
|
+
|
34
|
+
- pluralName: inclusiveOptions
|
35
|
+
singularName: inclusiveOption
|
36
|
+
singularAccessor: false
|
37
|
+
uri: "https://www.w3.org/ns/activitystreams#anyOf"
|
38
|
+
description: |
|
39
|
+
Identifies an inclusive option for a Question. Use of `inclusiveOptions`
|
40
|
+
implies that the Question can have multiple answers. To indicate that
|
41
|
+
a Question can have only one answer, use `exclusiveOptions`.
|
42
|
+
range:
|
43
|
+
- "https://www.w3.org/ns/activitystreams#Object"
|
package/esm/vocab/vocab.js
CHANGED
@@ -2198,6 +2198,10 @@ export class Object {
|
|
2198
2198
|
delete values["@type"];
|
2199
2199
|
return await IntransitiveActivity.fromJsonLd(values, options);
|
2200
2200
|
}
|
2201
|
+
if (values["@type"].includes("https://www.w3.org/ns/activitystreams#Question")) {
|
2202
|
+
delete values["@type"];
|
2203
|
+
return await Question.fromJsonLd(values, options);
|
2204
|
+
}
|
2201
2205
|
if (values["@type"].includes("https://www.w3.org/ns/activitystreams#Like")) {
|
2202
2206
|
delete values["@type"];
|
2203
2207
|
return await Like.fromJsonLd(values, options);
|
@@ -2334,6 +2338,7 @@ export class Object {
|
|
2334
2338
|
"https://www.w3.org/ns/activitystreams#Ignore",
|
2335
2339
|
"https://www.w3.org/ns/activitystreams#Block",
|
2336
2340
|
"https://www.w3.org/ns/activitystreams#IntransitiveActivity",
|
2341
|
+
"https://www.w3.org/ns/activitystreams#Question",
|
2337
2342
|
"https://www.w3.org/ns/activitystreams#Like",
|
2338
2343
|
"https://www.w3.org/ns/activitystreams#Reject",
|
2339
2344
|
"https://www.w3.org/ns/activitystreams#Remove",
|
@@ -2471,6 +2476,7 @@ export class Object {
|
|
2471
2476
|
"https://www.w3.org/ns/activitystreams#Ignore",
|
2472
2477
|
"https://www.w3.org/ns/activitystreams#Block",
|
2473
2478
|
"https://www.w3.org/ns/activitystreams#IntransitiveActivity",
|
2479
|
+
"https://www.w3.org/ns/activitystreams#Question",
|
2474
2480
|
"https://www.w3.org/ns/activitystreams#Like",
|
2475
2481
|
"https://www.w3.org/ns/activitystreams#Reject",
|
2476
2482
|
"https://www.w3.org/ns/activitystreams#Remove",
|
@@ -2563,6 +2569,7 @@ export class Object {
|
|
2563
2569
|
"https://www.w3.org/ns/activitystreams#Ignore",
|
2564
2570
|
"https://www.w3.org/ns/activitystreams#Block",
|
2565
2571
|
"https://www.w3.org/ns/activitystreams#IntransitiveActivity",
|
2572
|
+
"https://www.w3.org/ns/activitystreams#Question",
|
2566
2573
|
"https://www.w3.org/ns/activitystreams#Like",
|
2567
2574
|
"https://www.w3.org/ns/activitystreams#Reject",
|
2568
2575
|
"https://www.w3.org/ns/activitystreams#Remove",
|
@@ -2655,6 +2662,7 @@ export class Object {
|
|
2655
2662
|
"https://www.w3.org/ns/activitystreams#Ignore",
|
2656
2663
|
"https://www.w3.org/ns/activitystreams#Block",
|
2657
2664
|
"https://www.w3.org/ns/activitystreams#IntransitiveActivity",
|
2665
|
+
"https://www.w3.org/ns/activitystreams#Question",
|
2658
2666
|
"https://www.w3.org/ns/activitystreams#Like",
|
2659
2667
|
"https://www.w3.org/ns/activitystreams#Reject",
|
2660
2668
|
"https://www.w3.org/ns/activitystreams#Remove",
|
@@ -2723,6 +2731,7 @@ export class Object {
|
|
2723
2731
|
"https://www.w3.org/ns/activitystreams#Ignore",
|
2724
2732
|
"https://www.w3.org/ns/activitystreams#Block",
|
2725
2733
|
"https://www.w3.org/ns/activitystreams#IntransitiveActivity",
|
2734
|
+
"https://www.w3.org/ns/activitystreams#Question",
|
2726
2735
|
"https://www.w3.org/ns/activitystreams#Like",
|
2727
2736
|
"https://www.w3.org/ns/activitystreams#Reject",
|
2728
2737
|
"https://www.w3.org/ns/activitystreams#Remove",
|
@@ -2799,6 +2808,7 @@ export class Object {
|
|
2799
2808
|
"https://www.w3.org/ns/activitystreams#Ignore",
|
2800
2809
|
"https://www.w3.org/ns/activitystreams#Block",
|
2801
2810
|
"https://www.w3.org/ns/activitystreams#IntransitiveActivity",
|
2811
|
+
"https://www.w3.org/ns/activitystreams#Question",
|
2802
2812
|
"https://www.w3.org/ns/activitystreams#Like",
|
2803
2813
|
"https://www.w3.org/ns/activitystreams#Reject",
|
2804
2814
|
"https://www.w3.org/ns/activitystreams#Remove",
|
@@ -2902,6 +2912,7 @@ export class Object {
|
|
2902
2912
|
"https://www.w3.org/ns/activitystreams#Ignore",
|
2903
2913
|
"https://www.w3.org/ns/activitystreams#Block",
|
2904
2914
|
"https://www.w3.org/ns/activitystreams#IntransitiveActivity",
|
2915
|
+
"https://www.w3.org/ns/activitystreams#Question",
|
2905
2916
|
"https://www.w3.org/ns/activitystreams#Like",
|
2906
2917
|
"https://www.w3.org/ns/activitystreams#Reject",
|
2907
2918
|
"https://www.w3.org/ns/activitystreams#Remove",
|
@@ -5195,6 +5206,10 @@ export class Activity extends Object {
|
|
5195
5206
|
delete values["@type"];
|
5196
5207
|
return await IntransitiveActivity.fromJsonLd(values, options);
|
5197
5208
|
}
|
5209
|
+
if (values["@type"].includes("https://www.w3.org/ns/activitystreams#Question")) {
|
5210
|
+
delete values["@type"];
|
5211
|
+
return await Question.fromJsonLd(values, options);
|
5212
|
+
}
|
5198
5213
|
if (values["@type"].includes("https://www.w3.org/ns/activitystreams#Like")) {
|
5199
5214
|
delete values["@type"];
|
5200
5215
|
return await Like.fromJsonLd(values, options);
|
@@ -8136,6 +8151,7 @@ export class Collection extends Object {
|
|
8136
8151
|
"https://www.w3.org/ns/activitystreams#Ignore",
|
8137
8152
|
"https://www.w3.org/ns/activitystreams#Block",
|
8138
8153
|
"https://www.w3.org/ns/activitystreams#IntransitiveActivity",
|
8154
|
+
"https://www.w3.org/ns/activitystreams#Question",
|
8139
8155
|
"https://www.w3.org/ns/activitystreams#Like",
|
8140
8156
|
"https://www.w3.org/ns/activitystreams#Reject",
|
8141
8157
|
"https://www.w3.org/ns/activitystreams#Remove",
|
@@ -11532,6 +11548,7 @@ export class Link {
|
|
11532
11548
|
"https://www.w3.org/ns/activitystreams#Ignore",
|
11533
11549
|
"https://www.w3.org/ns/activitystreams#Block",
|
11534
11550
|
"https://www.w3.org/ns/activitystreams#IntransitiveActivity",
|
11551
|
+
"https://www.w3.org/ns/activitystreams#Question",
|
11535
11552
|
"https://www.w3.org/ns/activitystreams#Like",
|
11536
11553
|
"https://www.w3.org/ns/activitystreams#Reject",
|
11537
11554
|
"https://www.w3.org/ns/activitystreams#Remove",
|
@@ -11994,6 +12011,10 @@ export class IntransitiveActivity extends Activity {
|
|
11994
12011
|
(expanded[0] ?? {});
|
11995
12012
|
}
|
11996
12013
|
if ("@type" in values) {
|
12014
|
+
if (values["@type"].includes("https://www.w3.org/ns/activitystreams#Question")) {
|
12015
|
+
delete values["@type"];
|
12016
|
+
return await Question.fromJsonLd(values, options);
|
12017
|
+
}
|
11997
12018
|
if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#IntransitiveActivity")) {
|
11998
12019
|
throw new TypeError("Invalid type: " + values["@type"]);
|
11999
12020
|
}
|
@@ -15835,6 +15856,296 @@ export class Profile extends Object {
|
|
15835
15856
|
return "Profile " + inspect(proxy, options);
|
15836
15857
|
}
|
15837
15858
|
}
|
15859
|
+
/** Represents a question being asked. Question objects are an extension of
|
15860
|
+
* {@link IntransitiveActivity}. That is, the Question object is an Activity,
|
15861
|
+
* but the direct object is the question itself and therefore it would not
|
15862
|
+
* contain an `object` property.
|
15863
|
+
*
|
15864
|
+
* Either of the `anyOf` and `oneOf` properties *may* be used to express possible
|
15865
|
+
* answers, but a Question object *must not* have both properties.
|
15866
|
+
*/
|
15867
|
+
export class Question extends IntransitiveActivity {
|
15868
|
+
/**
|
15869
|
+
* The type URI of {@link Question}: `https://www.w3.org/ns/activitystreams#Question`.
|
15870
|
+
*/
|
15871
|
+
static get typeId() {
|
15872
|
+
return new URL("https://www.w3.org/ns/activitystreams#Question");
|
15873
|
+
}
|
15874
|
+
#_2N5scKaVEcdYHFmfKYYacAwUhUgQ = [];
|
15875
|
+
#_2mV6isMTPRKbWdLCjcpiEysq5dAY = [];
|
15876
|
+
/**
|
15877
|
+
* Constructs a new instance of Question with the given values.
|
15878
|
+
* @param values The values to initialize the instance with.
|
15879
|
+
* @param options The options to use for initialization.
|
15880
|
+
*/
|
15881
|
+
constructor(values, { documentLoader, contextLoader, } = {}) {
|
15882
|
+
super(values, { documentLoader, contextLoader });
|
15883
|
+
if ("exclusiveOptions" in values && values.exclusiveOptions != null) {
|
15884
|
+
this.#_2N5scKaVEcdYHFmfKYYacAwUhUgQ = values.exclusiveOptions;
|
15885
|
+
}
|
15886
|
+
if ("inclusiveOptions" in values && values.inclusiveOptions != null) {
|
15887
|
+
this.#_2mV6isMTPRKbWdLCjcpiEysq5dAY = values.inclusiveOptions;
|
15888
|
+
}
|
15889
|
+
}
|
15890
|
+
/**
|
15891
|
+
* Clones this instance, optionally updating it with the given values.
|
15892
|
+
* @param values The values to update the clone with.
|
15893
|
+
* @options The options to use for cloning.
|
15894
|
+
* @returns The cloned instance.
|
15895
|
+
*/
|
15896
|
+
clone(values = {}, options = {}) {
|
15897
|
+
const clone = super.clone(values, options);
|
15898
|
+
clone.#_2N5scKaVEcdYHFmfKYYacAwUhUgQ = this.#_2N5scKaVEcdYHFmfKYYacAwUhUgQ;
|
15899
|
+
if ("exclusiveOptions" in values && values.exclusiveOptions != null) {
|
15900
|
+
clone.#_2N5scKaVEcdYHFmfKYYacAwUhUgQ = values.exclusiveOptions;
|
15901
|
+
}
|
15902
|
+
clone.#_2mV6isMTPRKbWdLCjcpiEysq5dAY = this.#_2mV6isMTPRKbWdLCjcpiEysq5dAY;
|
15903
|
+
if ("inclusiveOptions" in values && values.inclusiveOptions != null) {
|
15904
|
+
clone.#_2mV6isMTPRKbWdLCjcpiEysq5dAY = values.inclusiveOptions;
|
15905
|
+
}
|
15906
|
+
return clone;
|
15907
|
+
}
|
15908
|
+
async #fetchExclusiveOption(url, options = {}) {
|
15909
|
+
const documentLoader = options.documentLoader ?? this._documentLoader ??
|
15910
|
+
fetchDocumentLoader;
|
15911
|
+
const contextLoader = options.contextLoader ?? this._contextLoader ??
|
15912
|
+
fetchDocumentLoader;
|
15913
|
+
const { document } = await documentLoader(url.href);
|
15914
|
+
try {
|
15915
|
+
return await Object.fromJsonLd(document, { documentLoader, contextLoader });
|
15916
|
+
}
|
15917
|
+
catch (e) {
|
15918
|
+
if (!(e instanceof TypeError))
|
15919
|
+
throw e;
|
15920
|
+
}
|
15921
|
+
throw new TypeError("Expected an object of any type of: " +
|
15922
|
+
["https://www.w3.org/ns/activitystreams#Object"].join(", "));
|
15923
|
+
}
|
15924
|
+
/**
|
15925
|
+
* Similar to
|
15926
|
+
* {@link Question.getExclusiveOptions},
|
15927
|
+
* but returns their `@id`s instead of the objects themselves.
|
15928
|
+
*/
|
15929
|
+
get exclusiveOptionIds() {
|
15930
|
+
return this.#_2N5scKaVEcdYHFmfKYYacAwUhUgQ.map((v) => v instanceof URL ? v : v.id).filter((id) => id !== null);
|
15931
|
+
}
|
15932
|
+
/** Identifies an exclusive option for a Question. Use of `exclusiveOptions`
|
15933
|
+
* implies that the Question can have only a single answer. To indicate that
|
15934
|
+
* a Question can have multiple answers, use `inclusiveOptions`.
|
15935
|
+
*/
|
15936
|
+
async *getExclusiveOptions(options = {}) {
|
15937
|
+
const vs = this.#_2N5scKaVEcdYHFmfKYYacAwUhUgQ;
|
15938
|
+
for (let i = 0; i < vs.length; i++) {
|
15939
|
+
const v = vs[i];
|
15940
|
+
if (v instanceof URL) {
|
15941
|
+
const fetched = await this.#fetchExclusiveOption(v, options);
|
15942
|
+
vs[i] = fetched;
|
15943
|
+
yield fetched;
|
15944
|
+
continue;
|
15945
|
+
}
|
15946
|
+
yield v;
|
15947
|
+
}
|
15948
|
+
}
|
15949
|
+
async #fetchInclusiveOption(url, options = {}) {
|
15950
|
+
const documentLoader = options.documentLoader ?? this._documentLoader ??
|
15951
|
+
fetchDocumentLoader;
|
15952
|
+
const contextLoader = options.contextLoader ?? this._contextLoader ??
|
15953
|
+
fetchDocumentLoader;
|
15954
|
+
const { document } = await documentLoader(url.href);
|
15955
|
+
try {
|
15956
|
+
return await Object.fromJsonLd(document, { documentLoader, contextLoader });
|
15957
|
+
}
|
15958
|
+
catch (e) {
|
15959
|
+
if (!(e instanceof TypeError))
|
15960
|
+
throw e;
|
15961
|
+
}
|
15962
|
+
throw new TypeError("Expected an object of any type of: " +
|
15963
|
+
["https://www.w3.org/ns/activitystreams#Object"].join(", "));
|
15964
|
+
}
|
15965
|
+
/**
|
15966
|
+
* Similar to
|
15967
|
+
* {@link Question.getInclusiveOptions},
|
15968
|
+
* but returns their `@id`s instead of the objects themselves.
|
15969
|
+
*/
|
15970
|
+
get inclusiveOptionIds() {
|
15971
|
+
return this.#_2mV6isMTPRKbWdLCjcpiEysq5dAY.map((v) => v instanceof URL ? v : v.id).filter((id) => id !== null);
|
15972
|
+
}
|
15973
|
+
/** Identifies an inclusive option for a Question. Use of `inclusiveOptions`
|
15974
|
+
* implies that the Question can have multiple answers. To indicate that
|
15975
|
+
* a Question can have only one answer, use `exclusiveOptions`.
|
15976
|
+
*/
|
15977
|
+
async *getInclusiveOptions(options = {}) {
|
15978
|
+
const vs = this.#_2mV6isMTPRKbWdLCjcpiEysq5dAY;
|
15979
|
+
for (let i = 0; i < vs.length; i++) {
|
15980
|
+
const v = vs[i];
|
15981
|
+
if (v instanceof URL) {
|
15982
|
+
const fetched = await this.#fetchInclusiveOption(v, options);
|
15983
|
+
vs[i] = fetched;
|
15984
|
+
yield fetched;
|
15985
|
+
continue;
|
15986
|
+
}
|
15987
|
+
yield v;
|
15988
|
+
}
|
15989
|
+
}
|
15990
|
+
/**
|
15991
|
+
* Converts this object to a JSON-LD structure.
|
15992
|
+
* @returns The JSON-LD representation of this object.
|
15993
|
+
*/
|
15994
|
+
async toJsonLd(options = {}) {
|
15995
|
+
options = {
|
15996
|
+
...options,
|
15997
|
+
contextLoader: options.contextLoader ?? fetchDocumentLoader,
|
15998
|
+
};
|
15999
|
+
// deno-lint-ignore no-unused-vars prefer-const
|
16000
|
+
let array;
|
16001
|
+
const baseValues = await super.toJsonLd({
|
16002
|
+
...options,
|
16003
|
+
expand: true,
|
16004
|
+
});
|
16005
|
+
const values = baseValues[0];
|
16006
|
+
array = [];
|
16007
|
+
for (const v of this.#_2N5scKaVEcdYHFmfKYYacAwUhUgQ) {
|
16008
|
+
const element = v instanceof URL
|
16009
|
+
? { "@id": v.href }
|
16010
|
+
: await v.toJsonLd(options);
|
16011
|
+
array.push(element);
|
16012
|
+
}
|
16013
|
+
if (array.length > 0) {
|
16014
|
+
values["https://www.w3.org/ns/activitystreams#oneOf"] = array;
|
16015
|
+
}
|
16016
|
+
array = [];
|
16017
|
+
for (const v of this.#_2mV6isMTPRKbWdLCjcpiEysq5dAY) {
|
16018
|
+
const element = v instanceof URL
|
16019
|
+
? { "@id": v.href }
|
16020
|
+
: await v.toJsonLd(options);
|
16021
|
+
array.push(element);
|
16022
|
+
}
|
16023
|
+
if (array.length > 0) {
|
16024
|
+
values["https://www.w3.org/ns/activitystreams#anyOf"] = array;
|
16025
|
+
}
|
16026
|
+
values["@type"] = ["https://www.w3.org/ns/activitystreams#Question"];
|
16027
|
+
if (this.id)
|
16028
|
+
values["@id"] = this.id.href;
|
16029
|
+
if (options.expand) {
|
16030
|
+
return await jsonld.expand(values, { documentLoader: options.contextLoader });
|
16031
|
+
}
|
16032
|
+
return await jsonld.compact(values, options.context ??
|
16033
|
+
[
|
16034
|
+
"https://www.w3.org/ns/activitystreams",
|
16035
|
+
"https://w3id.org/security/data-integrity/v1",
|
16036
|
+
{
|
16037
|
+
"toot": "http://joinmastodon.org/ns#",
|
16038
|
+
"sensitive": "as:sensitive",
|
16039
|
+
"Emoji": "toot:Emoji",
|
16040
|
+
"Hashtag": "as:Hashtag",
|
16041
|
+
},
|
16042
|
+
], { documentLoader: options.contextLoader });
|
16043
|
+
}
|
16044
|
+
/**
|
16045
|
+
* Converts a JSON-LD structure to an object of this type.
|
16046
|
+
* @param json The JSON-LD structure to convert.
|
16047
|
+
* @returns The object of this type.
|
16048
|
+
* @throws {TypeError} If the given `json` is invalid.
|
16049
|
+
*/
|
16050
|
+
static async fromJsonLd(json, options = {}) {
|
16051
|
+
if (typeof json === "undefined") {
|
16052
|
+
throw new TypeError("Invalid JSON-LD: undefined.");
|
16053
|
+
}
|
16054
|
+
else if (json === null)
|
16055
|
+
throw new TypeError("Invalid JSON-LD: null.");
|
16056
|
+
options = {
|
16057
|
+
...options,
|
16058
|
+
documentLoader: options.documentLoader ?? fetchDocumentLoader,
|
16059
|
+
contextLoader: options.contextLoader ?? fetchDocumentLoader,
|
16060
|
+
};
|
16061
|
+
// deno-lint-ignore no-explicit-any
|
16062
|
+
let values;
|
16063
|
+
if (globalThis.Object.keys(json).length == 0) {
|
16064
|
+
values = {};
|
16065
|
+
}
|
16066
|
+
else {
|
16067
|
+
const expanded = await jsonld.expand(json, {
|
16068
|
+
documentLoader: options.contextLoader,
|
16069
|
+
keepFreeFloatingNodes: true,
|
16070
|
+
});
|
16071
|
+
values =
|
16072
|
+
// deno-lint-ignore no-explicit-any
|
16073
|
+
(expanded[0] ?? {});
|
16074
|
+
}
|
16075
|
+
if ("@type" in values) {
|
16076
|
+
if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Question")) {
|
16077
|
+
throw new TypeError("Invalid type: " + values["@type"]);
|
16078
|
+
}
|
16079
|
+
}
|
16080
|
+
const instance = await super.fromJsonLd(values, options);
|
16081
|
+
if (!(instance instanceof Question)) {
|
16082
|
+
throw new TypeError("Unexpected type: " + instance.constructor.name);
|
16083
|
+
}
|
16084
|
+
const _2N5scKaVEcdYHFmfKYYacAwUhUgQ = [];
|
16085
|
+
for (const v of values["https://www.w3.org/ns/activitystreams#oneOf"] ?? []) {
|
16086
|
+
if (v == null)
|
16087
|
+
continue;
|
16088
|
+
if (typeof v === "object" && "@id" in v && !("@type" in v) &&
|
16089
|
+
globalThis.Object.keys(v).length === 1) {
|
16090
|
+
_2N5scKaVEcdYHFmfKYYacAwUhUgQ.push(new URL(v["@id"]));
|
16091
|
+
continue;
|
16092
|
+
}
|
16093
|
+
_2N5scKaVEcdYHFmfKYYacAwUhUgQ.push(await Object.fromJsonLd(v, options));
|
16094
|
+
}
|
16095
|
+
instance.#_2N5scKaVEcdYHFmfKYYacAwUhUgQ = _2N5scKaVEcdYHFmfKYYacAwUhUgQ;
|
16096
|
+
const _2mV6isMTPRKbWdLCjcpiEysq5dAY = [];
|
16097
|
+
for (const v of values["https://www.w3.org/ns/activitystreams#anyOf"] ?? []) {
|
16098
|
+
if (v == null)
|
16099
|
+
continue;
|
16100
|
+
if (typeof v === "object" && "@id" in v && !("@type" in v) &&
|
16101
|
+
globalThis.Object.keys(v).length === 1) {
|
16102
|
+
_2mV6isMTPRKbWdLCjcpiEysq5dAY.push(new URL(v["@id"]));
|
16103
|
+
continue;
|
16104
|
+
}
|
16105
|
+
_2mV6isMTPRKbWdLCjcpiEysq5dAY.push(await Object.fromJsonLd(v, options));
|
16106
|
+
}
|
16107
|
+
instance.#_2mV6isMTPRKbWdLCjcpiEysq5dAY = _2mV6isMTPRKbWdLCjcpiEysq5dAY;
|
16108
|
+
return instance;
|
16109
|
+
}
|
16110
|
+
_getCustomInspectProxy() {
|
16111
|
+
const proxy = super._getCustomInspectProxy();
|
16112
|
+
const _2N5scKaVEcdYHFmfKYYacAwUhUgQ = this.#_2N5scKaVEcdYHFmfKYYacAwUhUgQ
|
16113
|
+
// deno-lint-ignore no-explicit-any
|
16114
|
+
.map((v) => v instanceof URL
|
16115
|
+
? {
|
16116
|
+
[Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
|
16117
|
+
[Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
|
16118
|
+
}
|
16119
|
+
: v);
|
16120
|
+
if (_2N5scKaVEcdYHFmfKYYacAwUhUgQ.length > 1 ||
|
16121
|
+
!("exclusiveOption" in proxy) &&
|
16122
|
+
_2N5scKaVEcdYHFmfKYYacAwUhUgQ.length > 0) {
|
16123
|
+
proxy.exclusiveOptions = _2N5scKaVEcdYHFmfKYYacAwUhUgQ;
|
16124
|
+
}
|
16125
|
+
const _2mV6isMTPRKbWdLCjcpiEysq5dAY = this.#_2mV6isMTPRKbWdLCjcpiEysq5dAY
|
16126
|
+
// deno-lint-ignore no-explicit-any
|
16127
|
+
.map((v) => v instanceof URL
|
16128
|
+
? {
|
16129
|
+
[Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
|
16130
|
+
[Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
|
16131
|
+
}
|
16132
|
+
: v);
|
16133
|
+
if (_2mV6isMTPRKbWdLCjcpiEysq5dAY.length > 1 ||
|
16134
|
+
!("inclusiveOption" in proxy) &&
|
16135
|
+
_2mV6isMTPRKbWdLCjcpiEysq5dAY.length > 0) {
|
16136
|
+
proxy.inclusiveOptions = _2mV6isMTPRKbWdLCjcpiEysq5dAY;
|
16137
|
+
}
|
16138
|
+
return proxy;
|
16139
|
+
}
|
16140
|
+
[Symbol.for("Deno.customInspect")](inspect, options) {
|
16141
|
+
const proxy = this._getCustomInspectProxy();
|
16142
|
+
return "Question " + inspect(proxy, options);
|
16143
|
+
}
|
16144
|
+
[Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
|
16145
|
+
const proxy = this._getCustomInspectProxy();
|
16146
|
+
return "Question " + inspect(proxy, options);
|
16147
|
+
}
|
16148
|
+
}
|
15838
16149
|
/** Indicates that the `actor` is rejecting the `object`. The `target` and
|
15839
16150
|
* `origin` typically have no defined meaning.
|
15840
16151
|
*/
|
package/package.json
CHANGED
package/types/vocab/vocab.d.ts
CHANGED
@@ -7013,6 +7013,192 @@ export declare class Profile extends Object {
|
|
7013
7013
|
}): Promise<Profile>;
|
7014
7014
|
protected _getCustomInspectProxy(): Record<string, unknown>;
|
7015
7015
|
}
|
7016
|
+
/** Represents a question being asked. Question objects are an extension of
|
7017
|
+
* {@link IntransitiveActivity}. That is, the Question object is an Activity,
|
7018
|
+
* but the direct object is the question itself and therefore it would not
|
7019
|
+
* contain an `object` property.
|
7020
|
+
*
|
7021
|
+
* Either of the `anyOf` and `oneOf` properties *may* be used to express possible
|
7022
|
+
* answers, but a Question object *must not* have both properties.
|
7023
|
+
*/
|
7024
|
+
export declare class Question extends IntransitiveActivity {
|
7025
|
+
#private;
|
7026
|
+
/**
|
7027
|
+
* The type URI of {@link Question}: `https://www.w3.org/ns/activitystreams#Question`.
|
7028
|
+
*/
|
7029
|
+
static get typeId(): URL;
|
7030
|
+
/**
|
7031
|
+
* Constructs a new instance of Question with the given values.
|
7032
|
+
* @param values The values to initialize the instance with.
|
7033
|
+
* @param options The options to use for initialization.
|
7034
|
+
*/
|
7035
|
+
constructor(values: {
|
7036
|
+
id?: URL | null;
|
7037
|
+
attachments?: (Object | Link | PropertyValue | URL)[];
|
7038
|
+
attribution?: Application | Group | Organization | Person | Service | URL | null;
|
7039
|
+
attributions?: (Application | Group | Organization | Person | Service | URL)[];
|
7040
|
+
audience?: Object | URL | null;
|
7041
|
+
audiences?: (Object | URL)[];
|
7042
|
+
content?: string | LanguageString | null;
|
7043
|
+
contents?: (string | LanguageString)[];
|
7044
|
+
contexts?: (Object | Link | URL)[];
|
7045
|
+
name?: string | LanguageString | null;
|
7046
|
+
names?: (string | LanguageString)[];
|
7047
|
+
endTime?: dntShim.Temporal.Instant | null;
|
7048
|
+
generators?: (Object | Link | URL)[];
|
7049
|
+
icon?: Image | URL | null;
|
7050
|
+
icons?: (Image | URL)[];
|
7051
|
+
image?: Image | URL | null;
|
7052
|
+
images?: (Image | URL)[];
|
7053
|
+
replyTarget?: Object | Link | URL | null;
|
7054
|
+
replyTargets?: (Object | Link | URL)[];
|
7055
|
+
location?: Object | Link | URL | null;
|
7056
|
+
locations?: (Object | Link | URL)[];
|
7057
|
+
preview?: Link | Object | URL | null;
|
7058
|
+
previews?: (Link | Object | URL)[];
|
7059
|
+
published?: dntShim.Temporal.Instant | null;
|
7060
|
+
replies?: Collection | URL | null;
|
7061
|
+
startTime?: dntShim.Temporal.Instant | null;
|
7062
|
+
summary?: string | LanguageString | null;
|
7063
|
+
summaries?: (string | LanguageString)[];
|
7064
|
+
tags?: (Object | Link | URL)[];
|
7065
|
+
updated?: dntShim.Temporal.Instant | null;
|
7066
|
+
url?: URL | Link | null;
|
7067
|
+
urls?: (URL | Link)[];
|
7068
|
+
to?: Object | URL | null;
|
7069
|
+
tos?: (Object | URL)[];
|
7070
|
+
bto?: Object | URL | null;
|
7071
|
+
btos?: (Object | URL)[];
|
7072
|
+
cc?: Object | URL | null;
|
7073
|
+
ccs?: (Object | URL)[];
|
7074
|
+
bcc?: Object | URL | null;
|
7075
|
+
bccs?: (Object | URL)[];
|
7076
|
+
mediaType?: string | null;
|
7077
|
+
duration?: dntShim.Temporal.Duration | null;
|
7078
|
+
sensitive?: boolean | null;
|
7079
|
+
proof?: DataIntegrityProof | URL | null;
|
7080
|
+
proofs?: (DataIntegrityProof | URL)[];
|
7081
|
+
actor?: Application | Group | Organization | Person | Service | URL | null;
|
7082
|
+
actors?: (Application | Group | Organization | Person | Service | URL)[];
|
7083
|
+
object?: Object | URL | null;
|
7084
|
+
objects?: (Object | URL)[];
|
7085
|
+
exclusiveOptions?: (Object | URL)[];
|
7086
|
+
inclusiveOptions?: (Object | URL)[];
|
7087
|
+
}, { documentLoader, contextLoader, }?: {
|
7088
|
+
documentLoader?: DocumentLoader;
|
7089
|
+
contextLoader?: DocumentLoader;
|
7090
|
+
});
|
7091
|
+
/**
|
7092
|
+
* Clones this instance, optionally updating it with the given values.
|
7093
|
+
* @param values The values to update the clone with.
|
7094
|
+
* @options The options to use for cloning.
|
7095
|
+
* @returns The cloned instance.
|
7096
|
+
*/
|
7097
|
+
clone(values?: {
|
7098
|
+
id?: URL | null;
|
7099
|
+
attachments?: (Object | Link | PropertyValue | URL)[];
|
7100
|
+
attribution?: Application | Group | Organization | Person | Service | URL | null;
|
7101
|
+
attributions?: (Application | Group | Organization | Person | Service | URL)[];
|
7102
|
+
audience?: Object | URL | null;
|
7103
|
+
audiences?: (Object | URL)[];
|
7104
|
+
content?: string | LanguageString | null;
|
7105
|
+
contents?: (string | LanguageString)[];
|
7106
|
+
contexts?: (Object | Link | URL)[];
|
7107
|
+
name?: string | LanguageString | null;
|
7108
|
+
names?: (string | LanguageString)[];
|
7109
|
+
endTime?: dntShim.Temporal.Instant | null;
|
7110
|
+
generators?: (Object | Link | URL)[];
|
7111
|
+
icon?: Image | URL | null;
|
7112
|
+
icons?: (Image | URL)[];
|
7113
|
+
image?: Image | URL | null;
|
7114
|
+
images?: (Image | URL)[];
|
7115
|
+
replyTarget?: Object | Link | URL | null;
|
7116
|
+
replyTargets?: (Object | Link | URL)[];
|
7117
|
+
location?: Object | Link | URL | null;
|
7118
|
+
locations?: (Object | Link | URL)[];
|
7119
|
+
preview?: Link | Object | URL | null;
|
7120
|
+
previews?: (Link | Object | URL)[];
|
7121
|
+
published?: dntShim.Temporal.Instant | null;
|
7122
|
+
replies?: Collection | URL | null;
|
7123
|
+
startTime?: dntShim.Temporal.Instant | null;
|
7124
|
+
summary?: string | LanguageString | null;
|
7125
|
+
summaries?: (string | LanguageString)[];
|
7126
|
+
tags?: (Object | Link | URL)[];
|
7127
|
+
updated?: dntShim.Temporal.Instant | null;
|
7128
|
+
url?: URL | Link | null;
|
7129
|
+
urls?: (URL | Link)[];
|
7130
|
+
to?: Object | URL | null;
|
7131
|
+
tos?: (Object | URL)[];
|
7132
|
+
bto?: Object | URL | null;
|
7133
|
+
btos?: (Object | URL)[];
|
7134
|
+
cc?: Object | URL | null;
|
7135
|
+
ccs?: (Object | URL)[];
|
7136
|
+
bcc?: Object | URL | null;
|
7137
|
+
bccs?: (Object | URL)[];
|
7138
|
+
mediaType?: string | null;
|
7139
|
+
duration?: dntShim.Temporal.Duration | null;
|
7140
|
+
sensitive?: boolean | null;
|
7141
|
+
proof?: DataIntegrityProof | URL | null;
|
7142
|
+
proofs?: (DataIntegrityProof | URL)[];
|
7143
|
+
actor?: Application | Group | Organization | Person | Service | URL | null;
|
7144
|
+
actors?: (Application | Group | Organization | Person | Service | URL)[];
|
7145
|
+
object?: Object | URL | null;
|
7146
|
+
objects?: (Object | URL)[];
|
7147
|
+
exclusiveOptions?: (Object | URL)[];
|
7148
|
+
inclusiveOptions?: (Object | URL)[];
|
7149
|
+
}, options?: {
|
7150
|
+
documentLoader?: DocumentLoader;
|
7151
|
+
contextLoader?: DocumentLoader;
|
7152
|
+
}): Question;
|
7153
|
+
/**
|
7154
|
+
* Similar to
|
7155
|
+
* {@link Question.getExclusiveOptions},
|
7156
|
+
* but returns their `@id`s instead of the objects themselves.
|
7157
|
+
*/
|
7158
|
+
get exclusiveOptionIds(): URL[];
|
7159
|
+
/** Identifies an exclusive option for a Question. Use of `exclusiveOptions`
|
7160
|
+
* implies that the Question can have only a single answer. To indicate that
|
7161
|
+
* a Question can have multiple answers, use `inclusiveOptions`.
|
7162
|
+
*/
|
7163
|
+
getExclusiveOptions(options?: {
|
7164
|
+
documentLoader?: DocumentLoader;
|
7165
|
+
contextLoader?: DocumentLoader;
|
7166
|
+
}): AsyncIterable<Object>;
|
7167
|
+
/**
|
7168
|
+
* Similar to
|
7169
|
+
* {@link Question.getInclusiveOptions},
|
7170
|
+
* but returns their `@id`s instead of the objects themselves.
|
7171
|
+
*/
|
7172
|
+
get inclusiveOptionIds(): URL[];
|
7173
|
+
/** Identifies an inclusive option for a Question. Use of `inclusiveOptions`
|
7174
|
+
* implies that the Question can have multiple answers. To indicate that
|
7175
|
+
* a Question can have only one answer, use `exclusiveOptions`.
|
7176
|
+
*/
|
7177
|
+
getInclusiveOptions(options?: {
|
7178
|
+
documentLoader?: DocumentLoader;
|
7179
|
+
contextLoader?: DocumentLoader;
|
7180
|
+
}): AsyncIterable<Object>;
|
7181
|
+
/**
|
7182
|
+
* Converts this object to a JSON-LD structure.
|
7183
|
+
* @returns The JSON-LD representation of this object.
|
7184
|
+
*/
|
7185
|
+
toJsonLd(options?: {
|
7186
|
+
expand?: boolean;
|
7187
|
+
contextLoader?: DocumentLoader;
|
7188
|
+
context?: string | Record<string, string> | (string | Record<string, string>)[];
|
7189
|
+
}): Promise<unknown>;
|
7190
|
+
/**
|
7191
|
+
* Converts a JSON-LD structure to an object of this type.
|
7192
|
+
* @param json The JSON-LD structure to convert.
|
7193
|
+
* @returns The object of this type.
|
7194
|
+
* @throws {TypeError} If the given `json` is invalid.
|
7195
|
+
*/
|
7196
|
+
static fromJsonLd(json: unknown, options?: {
|
7197
|
+
documentLoader?: DocumentLoader;
|
7198
|
+
contextLoader?: DocumentLoader;
|
7199
|
+
}): Promise<Question>;
|
7200
|
+
protected _getCustomInspectProxy(): Record<string, unknown>;
|
7201
|
+
}
|
7016
7202
|
/** Indicates that the `actor` is rejecting the `object`. The `target` and
|
7017
7203
|
* `origin` typically have no defined meaning.
|
7018
7204
|
*/
|