@fedify/fedify 0.13.0-dev.311 → 0.13.0-dev.312

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGES.md CHANGED
@@ -8,6 +8,12 @@ Version 0.13.0
8
8
 
9
9
  To be released.
10
10
 
11
+ - Added `voters` property to `Question` class in Activity Vocabulary API.
12
+
13
+ - Added `Question.voters` property.
14
+ - `new Question()` constructor now accepts `voters` option.
15
+ - `Question.clone()` method now accepts `voters` option.
16
+
11
17
  - Removed the singular actor key pair dispatcher APIs which were deprecated
12
18
  in version 0.10.0.
13
19
 
@@ -12,6 +12,7 @@ defaultContext:
12
12
  - "https://w3id.org/security/data-integrity/v1"
13
13
  - toot: "http://joinmastodon.org/ns#"
14
14
  sensitive: "as:sensitive"
15
+ votersCount: "toot:votersCount"
15
16
  Emoji: "toot:Emoji"
16
17
  Hashtag: "as:Hashtag"
17
18
  properties: []
@@ -9,6 +9,7 @@ defaultContext:
9
9
  - "https://w3id.org/security/data-integrity/v1"
10
10
  - toot: "http://joinmastodon.org/ns#"
11
11
  sensitive: "as:sensitive"
12
+ votersCount: "toot:votersCount"
12
13
  Emoji: "toot:Emoji"
13
14
  Hashtag: "as:Hashtag"
14
15
  ChatMessage: "http://litepub.social/ns#ChatMessage"
@@ -9,5 +9,10 @@ description: |
9
9
  defaultContext:
10
10
  - "https://www.w3.org/ns/activitystreams"
11
11
  - "https://w3id.org/security/data-integrity/v1"
12
- - ChatMessage: "http://litepub.social/ns#ChatMessage"
12
+ - toot: "http://joinmastodon.org/ns#"
13
+ sensitive: "as:sensitive"
14
+ votersCount: "toot:votersCount"
15
+ Emoji: "toot:Emoji"
16
+ Hashtag: "as:Hashtag"
17
+ ChatMessage: "http://litepub.social/ns#ChatMessage"
13
18
  properties: []
@@ -10,12 +10,13 @@ description: |
10
10
  contain an `object` property.
11
11
 
12
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.
13
+ answers, but a Question object *must not* have both properties.
14
14
  defaultContext:
15
15
  - "https://www.w3.org/ns/activitystreams"
16
16
  - "https://w3id.org/security/data-integrity/v1"
17
17
  - toot: "http://joinmastodon.org/ns#"
18
18
  sensitive: "as:sensitive"
19
+ votersCount: "toot:votersCount"
19
20
  Emoji: "toot:Emoji"
20
21
  Hashtag: "as:Hashtag"
21
22
 
@@ -27,7 +28,7 @@ properties:
27
28
  description: |
28
29
  Identifies an exclusive option for a Question. Use of `exclusiveOptions`
29
30
  implies that the Question can have only a single answer. To indicate that
30
- a Question can have multiple answers, use `inclusiveOptions`.
31
+ a Question can have multiple answers, use `inclusiveOptions`.
31
32
  range:
32
33
  - "https://www.w3.org/ns/activitystreams#Object"
33
34
 
@@ -41,3 +42,12 @@ properties:
41
42
  a Question can have only one answer, use `exclusiveOptions`.
42
43
  range:
43
44
  - "https://www.w3.org/ns/activitystreams#Object"
45
+
46
+ - singularName: voters
47
+ functional: true
48
+ uri: "http://joinmastodon.org/ns#votersCount"
49
+ description: |
50
+ How many people have voted in the poll. Distinct from how many votes have
51
+ been cast (in the case of multiple-choice polls).
52
+ range:
53
+ - "http://www.w3.org/2001/XMLSchema#nonNegativeInteger"
@@ -14,6 +14,7 @@ defaultContext:
14
14
  - "https://w3id.org/security/data-integrity/v1"
15
15
  - toot: "http://joinmastodon.org/ns#"
16
16
  sensitive: "as:sensitive"
17
+ votersCount: "toot:votersCount"
17
18
  Emoji: "toot:Emoji"
18
19
  Hashtag: "as:Hashtag"
19
20
  ChatMessage: "http://litepub.social/ns#ChatMessage"
@@ -8318,6 +8318,7 @@ export class Announce extends Activity {
8318
8318
  {
8319
8319
  "toot": "http://joinmastodon.org/ns#",
8320
8320
  "sensitive": "as:sensitive",
8321
+ "votersCount": "toot:votersCount",
8321
8322
  "Emoji": "toot:Emoji",
8322
8323
  "Hashtag": "as:Hashtag",
8323
8324
  },
@@ -12761,6 +12762,7 @@ export class Create extends Activity {
12761
12762
  {
12762
12763
  "toot": "http://joinmastodon.org/ns#",
12763
12764
  "sensitive": "as:sensitive",
12765
+ "votersCount": "toot:votersCount",
12764
12766
  "Emoji": "toot:Emoji",
12765
12767
  "Hashtag": "as:Hashtag",
12766
12768
  "ChatMessage": "http://litepub.social/ns#ChatMessage",
@@ -12892,7 +12894,14 @@ export class Delete extends Activity {
12892
12894
  [
12893
12895
  "https://www.w3.org/ns/activitystreams",
12894
12896
  "https://w3id.org/security/data-integrity/v1",
12895
- { "ChatMessage": "http://litepub.social/ns#ChatMessage" },
12897
+ {
12898
+ "toot": "http://joinmastodon.org/ns#",
12899
+ "sensitive": "as:sensitive",
12900
+ "votersCount": "toot:votersCount",
12901
+ "Emoji": "toot:Emoji",
12902
+ "Hashtag": "as:Hashtag",
12903
+ "ChatMessage": "http://litepub.social/ns#ChatMessage",
12904
+ },
12896
12905
  ];
12897
12906
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
12898
12907
  if (docContext != null) {
@@ -23909,6 +23918,7 @@ export class Question extends IntransitiveActivity {
23909
23918
  }
23910
23919
  #_2N5scKaVEcdYHFmfKYYacAwUhUgQ = [];
23911
23920
  #_2mV6isMTPRKbWdLCjcpiEysq5dAY = [];
23921
+ #_3H4RdST7dxfmghccvE3rKD3KgcxG = [];
23912
23922
  /**
23913
23923
  * Constructs a new instance of Question with the given values.
23914
23924
  * @param values The values to initialize the instance with.
@@ -23938,6 +23948,17 @@ export class Question extends IntransitiveActivity {
23938
23948
  "Object | URL" + ".");
23939
23949
  }
23940
23950
  }
23951
+ if ("voters" in values && values.voters != null) {
23952
+ if (typeof values.voters === "number" && Number.isInteger(values.voters) &&
23953
+ values.voters >= 0) {
23954
+ // @ts-ignore: type is checked above.
23955
+ this.#_3H4RdST7dxfmghccvE3rKD3KgcxG = [values.voters];
23956
+ }
23957
+ else {
23958
+ throw new TypeError("The voters must be of type " +
23959
+ "number" + ".");
23960
+ }
23961
+ }
23941
23962
  }
23942
23963
  /**
23943
23964
  * Clones this instance, optionally updating it with the given values.
@@ -23971,6 +23992,18 @@ export class Question extends IntransitiveActivity {
23971
23992
  "Object | URL" + ".");
23972
23993
  }
23973
23994
  }
23995
+ clone.#_3H4RdST7dxfmghccvE3rKD3KgcxG = this.#_3H4RdST7dxfmghccvE3rKD3KgcxG;
23996
+ if ("voters" in values && values.voters != null) {
23997
+ if (typeof values.voters === "number" && Number.isInteger(values.voters) &&
23998
+ values.voters >= 0) {
23999
+ // @ts-ignore: type is checked above.
24000
+ clone.#_3H4RdST7dxfmghccvE3rKD3KgcxG = [values.voters];
24001
+ }
24002
+ else {
24003
+ throw new TypeError("The voters must be of type " +
24004
+ "number" + ".");
24005
+ }
24006
+ }
23974
24007
  return clone;
23975
24008
  }
23976
24009
  async #fetchExclusiveOption(url, options = {}) {
@@ -24081,6 +24114,14 @@ export class Question extends IntransitiveActivity {
24081
24114
  yield v;
24082
24115
  }
24083
24116
  }
24117
+ /** How many people have voted in the poll. Distinct from how many votes have
24118
+ * been cast (in the case of multiple-choice polls).
24119
+ */
24120
+ get voters() {
24121
+ if (this.#_3H4RdST7dxfmghccvE3rKD3KgcxG.length < 1)
24122
+ return null;
24123
+ return this.#_3H4RdST7dxfmghccvE3rKD3KgcxG[0];
24124
+ }
24084
24125
  /**
24085
24126
  * Converts this object to a JSON-LD structure.
24086
24127
  * @returns The JSON-LD representation of this object.
@@ -24117,6 +24158,17 @@ export class Question extends IntransitiveActivity {
24117
24158
  if (array.length > 0) {
24118
24159
  values["https://www.w3.org/ns/activitystreams#anyOf"] = array;
24119
24160
  }
24161
+ array = [];
24162
+ for (const v of this.#_3H4RdST7dxfmghccvE3rKD3KgcxG) {
24163
+ const element = {
24164
+ "@type": "http://www.w3.org/2001/XMLSchema#nonNegativeInteger",
24165
+ "@value": v,
24166
+ };
24167
+ array.push(element);
24168
+ }
24169
+ if (array.length > 0) {
24170
+ values["http://joinmastodon.org/ns#votersCount"] = array;
24171
+ }
24120
24172
  values["@type"] = ["https://www.w3.org/ns/activitystreams#Question"];
24121
24173
  if (this.id)
24122
24174
  values["@id"] = this.id.href;
@@ -24130,6 +24182,7 @@ export class Question extends IntransitiveActivity {
24130
24182
  {
24131
24183
  "toot": "http://joinmastodon.org/ns#",
24132
24184
  "sensitive": "as:sensitive",
24185
+ "votersCount": "toot:votersCount",
24133
24186
  "Emoji": "toot:Emoji",
24134
24187
  "Hashtag": "as:Hashtag",
24135
24188
  },
@@ -24227,6 +24280,19 @@ export class Question extends IntransitiveActivity {
24227
24280
  _2mV6isMTPRKbWdLCjcpiEysq5dAY.push(await Object.fromJsonLd(v, options));
24228
24281
  }
24229
24282
  instance.#_2mV6isMTPRKbWdLCjcpiEysq5dAY = _2mV6isMTPRKbWdLCjcpiEysq5dAY;
24283
+ const _3H4RdST7dxfmghccvE3rKD3KgcxG = [];
24284
+ const _3H4RdST7dxfmghccvE3rKD3KgcxG__array = values["http://joinmastodon.org/ns#votersCount"];
24285
+ for (const v of _3H4RdST7dxfmghccvE3rKD3KgcxG__array == null
24286
+ ? []
24287
+ : _3H4RdST7dxfmghccvE3rKD3KgcxG__array.length === 1 &&
24288
+ "@list" in _3H4RdST7dxfmghccvE3rKD3KgcxG__array[0]
24289
+ ? _3H4RdST7dxfmghccvE3rKD3KgcxG__array[0]["@list"]
24290
+ : _3H4RdST7dxfmghccvE3rKD3KgcxG__array) {
24291
+ if (v == null)
24292
+ continue;
24293
+ _3H4RdST7dxfmghccvE3rKD3KgcxG.push(v["@value"]);
24294
+ }
24295
+ instance.#_3H4RdST7dxfmghccvE3rKD3KgcxG = _3H4RdST7dxfmghccvE3rKD3KgcxG;
24230
24296
  return instance;
24231
24297
  }
24232
24298
  _getCustomInspectProxy() {
@@ -24257,6 +24323,17 @@ export class Question extends IntransitiveActivity {
24257
24323
  _2mV6isMTPRKbWdLCjcpiEysq5dAY.length > 0) {
24258
24324
  proxy.inclusiveOptions = _2mV6isMTPRKbWdLCjcpiEysq5dAY;
24259
24325
  }
24326
+ const _3H4RdST7dxfmghccvE3rKD3KgcxG = this.#_3H4RdST7dxfmghccvE3rKD3KgcxG
24327
+ // deno-lint-ignore no-explicit-any
24328
+ .map((v) => v instanceof URL
24329
+ ? {
24330
+ [Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
24331
+ [Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
24332
+ }
24333
+ : v);
24334
+ if (_3H4RdST7dxfmghccvE3rKD3KgcxG.length == 1) {
24335
+ proxy.voters = _3H4RdST7dxfmghccvE3rKD3KgcxG[0];
24336
+ }
24260
24337
  return proxy;
24261
24338
  }
24262
24339
  [Symbol.for("Deno.customInspect")](inspect, options) {
@@ -28023,6 +28100,7 @@ export class Update extends Activity {
28023
28100
  {
28024
28101
  "toot": "http://joinmastodon.org/ns#",
28025
28102
  "sensitive": "as:sensitive",
28103
+ "votersCount": "toot:votersCount",
28026
28104
  "Emoji": "toot:Emoji",
28027
28105
  "Hashtag": "as:Hashtag",
28028
28106
  "ChatMessage": "http://litepub.social/ns#ChatMessage",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/fedify",
3
- "version": "0.13.0-dev.311+4c301514",
3
+ "version": "0.13.0-dev.312+fdc60db3",
4
4
  "description": "An ActivityPub server framework",
5
5
  "keywords": [
6
6
  "ActivityPub",
@@ -8977,6 +8977,7 @@ export declare class Question extends IntransitiveActivity {
8977
8977
  instruments?: (Object | URL)[];
8978
8978
  exclusiveOptions?: (Object | URL)[];
8979
8979
  inclusiveOptions?: (Object | URL)[];
8980
+ voters?: number | null;
8980
8981
  }, { documentLoader, contextLoader, }?: {
8981
8982
  documentLoader?: DocumentLoader;
8982
8983
  contextLoader?: DocumentLoader;
@@ -9047,6 +9048,7 @@ export declare class Question extends IntransitiveActivity {
9047
9048
  instruments?: (Object | URL)[];
9048
9049
  exclusiveOptions?: (Object | URL)[];
9049
9050
  inclusiveOptions?: (Object | URL)[];
9051
+ voters?: number | null;
9050
9052
  }, options?: {
9051
9053
  documentLoader?: DocumentLoader;
9052
9054
  contextLoader?: DocumentLoader;
@@ -9081,6 +9083,10 @@ export declare class Question extends IntransitiveActivity {
9081
9083
  contextLoader?: DocumentLoader;
9082
9084
  suppressError?: boolean;
9083
9085
  }): AsyncIterable<Object>;
9086
+ /** How many people have voted in the poll. Distinct from how many votes have
9087
+ * been cast (in the case of multiple-choice polls).
9088
+ */
9089
+ get voters(): number | null;
9084
9090
  /**
9085
9091
  * Converts this object to a JSON-LD structure.
9086
9092
  * @returns The JSON-LD representation of this object.