@fedify/fedify 0.11.0-dev.241 → 0.11.0-dev.243

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.
@@ -3034,8 +3034,9 @@ export class Object {
3034
3034
  : await v.toJsonLd(options);
3035
3035
  array.push({ "@graph": element });
3036
3036
  }
3037
- if (array.length > 0)
3037
+ if (array.length > 0) {
3038
3038
  values["https://w3id.org/security#proof"] = array;
3039
+ }
3039
3040
  values["@type"] = ["https://www.w3.org/ns/activitystreams#Object"];
3040
3041
  if (this.id)
3041
3042
  values["@id"] = this.id.href;
@@ -4684,8 +4685,9 @@ export class PropertyValue {
4684
4685
  };
4685
4686
  array.push(element);
4686
4687
  }
4687
- if (array.length > 0)
4688
+ if (array.length > 0) {
4688
4689
  values["http://schema.org#value"] = array;
4690
+ }
4689
4691
  values["@type"] = ["http://schema.org#PropertyValue"];
4690
4692
  if (this.id)
4691
4693
  values["@id"] = this.id.href;
@@ -5131,8 +5133,9 @@ export class DataIntegrityProof {
5131
5133
  };
5132
5134
  array.push(element);
5133
5135
  }
5134
- if (array.length > 0)
5136
+ if (array.length > 0) {
5135
5137
  values["http://purl.org/dc/terms/created"] = array;
5138
+ }
5136
5139
  values["@type"] = ["https://w3id.org/security#DataIntegrityProof"];
5137
5140
  if (this.id)
5138
5141
  values["@id"] = this.id.href;
@@ -5517,8 +5520,9 @@ export class CryptographicKey {
5517
5520
  : await v.toJsonLd(options);
5518
5521
  array.push(element);
5519
5522
  }
5520
- if (array.length > 0)
5523
+ if (array.length > 0) {
5521
5524
  values["https://w3id.org/security#owner"] = array;
5525
+ }
5522
5526
  array = [];
5523
5527
  for (const v of this.#_2fE2QMDdg6KFGqa4NEC3TmjApSAD) {
5524
5528
  const element = { "@value": await exportSpki(v) };
@@ -6047,6 +6051,10 @@ export class Activity extends Object {
6047
6051
  }
6048
6052
  #_2DjTTboo3CNHU2a2JQqUSE2dbv9D = [];
6049
6053
  #_2MH19yxjn1wnHsNfa5n4JBhJzxyc = [];
6054
+ #_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF = [];
6055
+ #_u4QGFbRFcYmPEKGbPv1hpBR9r5G = [];
6056
+ #_25zu2s3VxVujgEKqrDycjE284XQR = [];
6057
+ #_3c5t2x7DYRo2shwTxpkd4kYSS5WQ = [];
6050
6058
  /**
6051
6059
  * Constructs a new instance of Activity with the given values.
6052
6060
  * @param values The values to initialize the instance with.
@@ -6111,6 +6119,110 @@ export class Activity extends Object {
6111
6119
  "Object | URL" + ".");
6112
6120
  }
6113
6121
  }
6122
+ if ("target" in values && values.target != null) {
6123
+ if (values.target instanceof Object || values.target instanceof URL) {
6124
+ // @ts-ignore: type is checked above.
6125
+ this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF = [values.target];
6126
+ }
6127
+ else {
6128
+ throw new TypeError("The target must be of type " +
6129
+ "Object | URL" + ".");
6130
+ }
6131
+ }
6132
+ if ("targets" in values && values.targets != null) {
6133
+ if ("target" in values &&
6134
+ values.target != null) {
6135
+ throw new TypeError("Cannot initialize both target and " +
6136
+ "targets at the same time.");
6137
+ }
6138
+ if (Array.isArray(values.targets) &&
6139
+ values.targets.every((v) => v instanceof Object || v instanceof URL)) {
6140
+ // @ts-ignore: type is checked above.
6141
+ this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF = values.targets;
6142
+ }
6143
+ else {
6144
+ throw new TypeError("The targets must be an array of type " +
6145
+ "Object | URL" + ".");
6146
+ }
6147
+ }
6148
+ if ("result" in values && values.result != null) {
6149
+ if (values.result instanceof Object || values.result instanceof URL) {
6150
+ // @ts-ignore: type is checked above.
6151
+ this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G = [values.result];
6152
+ }
6153
+ else {
6154
+ throw new TypeError("The result must be of type " +
6155
+ "Object | URL" + ".");
6156
+ }
6157
+ }
6158
+ if ("results" in values && values.results != null) {
6159
+ if ("result" in values &&
6160
+ values.result != null) {
6161
+ throw new TypeError("Cannot initialize both result and " +
6162
+ "results at the same time.");
6163
+ }
6164
+ if (Array.isArray(values.results) &&
6165
+ values.results.every((v) => v instanceof Object || v instanceof URL)) {
6166
+ // @ts-ignore: type is checked above.
6167
+ this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G = values.results;
6168
+ }
6169
+ else {
6170
+ throw new TypeError("The results must be an array of type " +
6171
+ "Object | URL" + ".");
6172
+ }
6173
+ }
6174
+ if ("origin" in values && values.origin != null) {
6175
+ if (values.origin instanceof Object || values.origin instanceof URL) {
6176
+ // @ts-ignore: type is checked above.
6177
+ this.#_25zu2s3VxVujgEKqrDycjE284XQR = [values.origin];
6178
+ }
6179
+ else {
6180
+ throw new TypeError("The origin must be of type " +
6181
+ "Object | URL" + ".");
6182
+ }
6183
+ }
6184
+ if ("origins" in values && values.origins != null) {
6185
+ if ("origin" in values &&
6186
+ values.origin != null) {
6187
+ throw new TypeError("Cannot initialize both origin and " +
6188
+ "origins at the same time.");
6189
+ }
6190
+ if (Array.isArray(values.origins) &&
6191
+ values.origins.every((v) => v instanceof Object || v instanceof URL)) {
6192
+ // @ts-ignore: type is checked above.
6193
+ this.#_25zu2s3VxVujgEKqrDycjE284XQR = values.origins;
6194
+ }
6195
+ else {
6196
+ throw new TypeError("The origins must be an array of type " +
6197
+ "Object | URL" + ".");
6198
+ }
6199
+ }
6200
+ if ("instrument" in values && values.instrument != null) {
6201
+ if (values.instrument instanceof Object || values.instrument instanceof URL) {
6202
+ // @ts-ignore: type is checked above.
6203
+ this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ = [values.instrument];
6204
+ }
6205
+ else {
6206
+ throw new TypeError("The instrument must be of type " +
6207
+ "Object | URL" + ".");
6208
+ }
6209
+ }
6210
+ if ("instruments" in values && values.instruments != null) {
6211
+ if ("instrument" in values &&
6212
+ values.instrument != null) {
6213
+ throw new TypeError("Cannot initialize both instrument and " +
6214
+ "instruments at the same time.");
6215
+ }
6216
+ if (Array.isArray(values.instruments) &&
6217
+ values.instruments.every((v) => v instanceof Object || v instanceof URL)) {
6218
+ // @ts-ignore: type is checked above.
6219
+ this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ = values.instruments;
6220
+ }
6221
+ else {
6222
+ throw new TypeError("The instruments must be an array of type " +
6223
+ "Object | URL" + ".");
6224
+ }
6225
+ }
6114
6226
  }
6115
6227
  /**
6116
6228
  * Clones this instance, optionally updating it with the given values.
@@ -6179,6 +6291,114 @@ export class Activity extends Object {
6179
6291
  "Object | URL" + ".");
6180
6292
  }
6181
6293
  }
6294
+ clone.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF = this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF;
6295
+ if ("target" in values && values.target != null) {
6296
+ if (values.target instanceof Object || values.target instanceof URL) {
6297
+ // @ts-ignore: type is checked above.
6298
+ clone.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF = [values.target];
6299
+ }
6300
+ else {
6301
+ throw new TypeError("The target must be of type " +
6302
+ "Object | URL" + ".");
6303
+ }
6304
+ }
6305
+ if ("targets" in values && values.targets != null) {
6306
+ if ("target" in values &&
6307
+ values.target != null) {
6308
+ throw new TypeError("Cannot update both target and " +
6309
+ "targets at the same time.");
6310
+ }
6311
+ if (Array.isArray(values.targets) &&
6312
+ values.targets.every((v) => v instanceof Object || v instanceof URL)) {
6313
+ // @ts-ignore: type is checked above.
6314
+ clone.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF = values.targets;
6315
+ }
6316
+ else {
6317
+ throw new TypeError("The targets must be an array of type " +
6318
+ "Object | URL" + ".");
6319
+ }
6320
+ }
6321
+ clone.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G = this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G;
6322
+ if ("result" in values && values.result != null) {
6323
+ if (values.result instanceof Object || values.result instanceof URL) {
6324
+ // @ts-ignore: type is checked above.
6325
+ clone.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G = [values.result];
6326
+ }
6327
+ else {
6328
+ throw new TypeError("The result must be of type " +
6329
+ "Object | URL" + ".");
6330
+ }
6331
+ }
6332
+ if ("results" in values && values.results != null) {
6333
+ if ("result" in values &&
6334
+ values.result != null) {
6335
+ throw new TypeError("Cannot update both result and " +
6336
+ "results at the same time.");
6337
+ }
6338
+ if (Array.isArray(values.results) &&
6339
+ values.results.every((v) => v instanceof Object || v instanceof URL)) {
6340
+ // @ts-ignore: type is checked above.
6341
+ clone.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G = values.results;
6342
+ }
6343
+ else {
6344
+ throw new TypeError("The results must be an array of type " +
6345
+ "Object | URL" + ".");
6346
+ }
6347
+ }
6348
+ clone.#_25zu2s3VxVujgEKqrDycjE284XQR = this.#_25zu2s3VxVujgEKqrDycjE284XQR;
6349
+ if ("origin" in values && values.origin != null) {
6350
+ if (values.origin instanceof Object || values.origin instanceof URL) {
6351
+ // @ts-ignore: type is checked above.
6352
+ clone.#_25zu2s3VxVujgEKqrDycjE284XQR = [values.origin];
6353
+ }
6354
+ else {
6355
+ throw new TypeError("The origin must be of type " +
6356
+ "Object | URL" + ".");
6357
+ }
6358
+ }
6359
+ if ("origins" in values && values.origins != null) {
6360
+ if ("origin" in values &&
6361
+ values.origin != null) {
6362
+ throw new TypeError("Cannot update both origin and " +
6363
+ "origins at the same time.");
6364
+ }
6365
+ if (Array.isArray(values.origins) &&
6366
+ values.origins.every((v) => v instanceof Object || v instanceof URL)) {
6367
+ // @ts-ignore: type is checked above.
6368
+ clone.#_25zu2s3VxVujgEKqrDycjE284XQR = values.origins;
6369
+ }
6370
+ else {
6371
+ throw new TypeError("The origins must be an array of type " +
6372
+ "Object | URL" + ".");
6373
+ }
6374
+ }
6375
+ clone.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ = this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ;
6376
+ if ("instrument" in values && values.instrument != null) {
6377
+ if (values.instrument instanceof Object || values.instrument instanceof URL) {
6378
+ // @ts-ignore: type is checked above.
6379
+ clone.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ = [values.instrument];
6380
+ }
6381
+ else {
6382
+ throw new TypeError("The instrument must be of type " +
6383
+ "Object | URL" + ".");
6384
+ }
6385
+ }
6386
+ if ("instruments" in values && values.instruments != null) {
6387
+ if ("instrument" in values &&
6388
+ values.instrument != null) {
6389
+ throw new TypeError("Cannot update both instrument and " +
6390
+ "instruments at the same time.");
6391
+ }
6392
+ if (Array.isArray(values.instruments) &&
6393
+ values.instruments.every((v) => v instanceof Object || v instanceof URL)) {
6394
+ // @ts-ignore: type is checked above.
6395
+ clone.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ = values.instruments;
6396
+ }
6397
+ else {
6398
+ throw new TypeError("The instruments must be an array of type " +
6399
+ "Object | URL" + ".");
6400
+ }
6401
+ }
6182
6402
  return clone;
6183
6403
  }
6184
6404
  async #fetchActor(url, options = {}) {
@@ -6383,6 +6603,348 @@ export class Activity extends Object {
6383
6603
  yield v;
6384
6604
  }
6385
6605
  }
6606
+ async #fetchTarget(url, options = {}) {
6607
+ const documentLoader = options.documentLoader ?? this._documentLoader ??
6608
+ fetchDocumentLoader;
6609
+ const contextLoader = options.contextLoader ?? this._contextLoader ??
6610
+ fetchDocumentLoader;
6611
+ let fetchResult;
6612
+ try {
6613
+ fetchResult = await documentLoader(url.href);
6614
+ }
6615
+ catch (error) {
6616
+ if (options.suppressError) {
6617
+ getLogger(["fedify", "vocab"]).error("Failed to fetch {url}: {error}", { error, url: url.href });
6618
+ return null;
6619
+ }
6620
+ throw error;
6621
+ }
6622
+ const { document } = fetchResult;
6623
+ try {
6624
+ return await Object.fromJsonLd(document, { documentLoader, contextLoader });
6625
+ }
6626
+ catch (e) {
6627
+ if (!(e instanceof TypeError))
6628
+ throw e;
6629
+ }
6630
+ throw new TypeError("Expected an object of any type of: " +
6631
+ ["https://www.w3.org/ns/activitystreams#Object"].join(", "));
6632
+ }
6633
+ /**
6634
+ * Similar to
6635
+ * {@link Activity.getTarget},
6636
+ * but returns its `@id` URL instead of the object itself.
6637
+ */
6638
+ get targetId() {
6639
+ if (this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF.length < 1)
6640
+ return null;
6641
+ const v = this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF[0];
6642
+ if (v instanceof URL)
6643
+ return v;
6644
+ return v.id;
6645
+ }
6646
+ /** Describes the indirect object, or target, of the activity. The precise
6647
+ * meaning of the target is largely dependent on the type of action being
6648
+ * described but will often be the object of the English preposition "to".
6649
+ * For instance, in the activity "John added a movie to his wishlist",
6650
+ * the target of the activity is John's wishlist. An activity can have more
6651
+ * than one target.
6652
+ */
6653
+ async getTarget(options = {}) {
6654
+ if (this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF.length < 1)
6655
+ return null;
6656
+ const v = this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF[0];
6657
+ if (v instanceof URL) {
6658
+ const fetched = await this.#fetchTarget(v, options);
6659
+ if (fetched == null)
6660
+ return null;
6661
+ this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF[0] = fetched;
6662
+ return fetched;
6663
+ }
6664
+ return v;
6665
+ }
6666
+ /**
6667
+ * Similar to
6668
+ * {@link Activity.getTargets},
6669
+ * but returns their `@id`s instead of the objects themselves.
6670
+ */
6671
+ get targetIds() {
6672
+ return this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF.map((v) => v instanceof URL ? v : v.id).filter((id) => id !== null);
6673
+ }
6674
+ /** Describes the indirect object, or target, of the activity. The precise
6675
+ * meaning of the target is largely dependent on the type of action being
6676
+ * described but will often be the object of the English preposition "to".
6677
+ * For instance, in the activity "John added a movie to his wishlist",
6678
+ * the target of the activity is John's wishlist. An activity can have more
6679
+ * than one target.
6680
+ */
6681
+ async *getTargets(options = {}) {
6682
+ const vs = this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF;
6683
+ for (let i = 0; i < vs.length; i++) {
6684
+ const v = vs[i];
6685
+ if (v instanceof URL) {
6686
+ const fetched = await this.#fetchTarget(v, options);
6687
+ if (fetched == null)
6688
+ continue;
6689
+ vs[i] = fetched;
6690
+ yield fetched;
6691
+ continue;
6692
+ }
6693
+ yield v;
6694
+ }
6695
+ }
6696
+ async #fetchResult(url, options = {}) {
6697
+ const documentLoader = options.documentLoader ?? this._documentLoader ??
6698
+ fetchDocumentLoader;
6699
+ const contextLoader = options.contextLoader ?? this._contextLoader ??
6700
+ fetchDocumentLoader;
6701
+ let fetchResult;
6702
+ try {
6703
+ fetchResult = await documentLoader(url.href);
6704
+ }
6705
+ catch (error) {
6706
+ if (options.suppressError) {
6707
+ getLogger(["fedify", "vocab"]).error("Failed to fetch {url}: {error}", { error, url: url.href });
6708
+ return null;
6709
+ }
6710
+ throw error;
6711
+ }
6712
+ const { document } = fetchResult;
6713
+ try {
6714
+ return await Object.fromJsonLd(document, { documentLoader, contextLoader });
6715
+ }
6716
+ catch (e) {
6717
+ if (!(e instanceof TypeError))
6718
+ throw e;
6719
+ }
6720
+ throw new TypeError("Expected an object of any type of: " +
6721
+ ["https://www.w3.org/ns/activitystreams#Object"].join(", "));
6722
+ }
6723
+ /**
6724
+ * Similar to
6725
+ * {@link Activity.getResult},
6726
+ * but returns its `@id` URL instead of the object itself.
6727
+ */
6728
+ get resultId() {
6729
+ if (this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G.length < 1)
6730
+ return null;
6731
+ const v = this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G[0];
6732
+ if (v instanceof URL)
6733
+ return v;
6734
+ return v.id;
6735
+ }
6736
+ /** Describes the result of the activity. For instance, if a particular action
6737
+ * results in the creation of a new resource, the result property can be used
6738
+ * to describe that new resource.
6739
+ */
6740
+ async getResult(options = {}) {
6741
+ if (this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G.length < 1)
6742
+ return null;
6743
+ const v = this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G[0];
6744
+ if (v instanceof URL) {
6745
+ const fetched = await this.#fetchResult(v, options);
6746
+ if (fetched == null)
6747
+ return null;
6748
+ this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G[0] = fetched;
6749
+ return fetched;
6750
+ }
6751
+ return v;
6752
+ }
6753
+ /**
6754
+ * Similar to
6755
+ * {@link Activity.getResults},
6756
+ * but returns their `@id`s instead of the objects themselves.
6757
+ */
6758
+ get resultIds() {
6759
+ return this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G.map((v) => v instanceof URL ? v : v.id).filter((id) => id !== null);
6760
+ }
6761
+ /** Describes the result of the activity. For instance, if a particular action
6762
+ * results in the creation of a new resource, the result property can be used
6763
+ * to describe that new resource.
6764
+ */
6765
+ async *getResults(options = {}) {
6766
+ const vs = this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G;
6767
+ for (let i = 0; i < vs.length; i++) {
6768
+ const v = vs[i];
6769
+ if (v instanceof URL) {
6770
+ const fetched = await this.#fetchResult(v, options);
6771
+ if (fetched == null)
6772
+ continue;
6773
+ vs[i] = fetched;
6774
+ yield fetched;
6775
+ continue;
6776
+ }
6777
+ yield v;
6778
+ }
6779
+ }
6780
+ async #fetchOrigin(url, options = {}) {
6781
+ const documentLoader = options.documentLoader ?? this._documentLoader ??
6782
+ fetchDocumentLoader;
6783
+ const contextLoader = options.contextLoader ?? this._contextLoader ??
6784
+ fetchDocumentLoader;
6785
+ let fetchResult;
6786
+ try {
6787
+ fetchResult = await documentLoader(url.href);
6788
+ }
6789
+ catch (error) {
6790
+ if (options.suppressError) {
6791
+ getLogger(["fedify", "vocab"]).error("Failed to fetch {url}: {error}", { error, url: url.href });
6792
+ return null;
6793
+ }
6794
+ throw error;
6795
+ }
6796
+ const { document } = fetchResult;
6797
+ try {
6798
+ return await Object.fromJsonLd(document, { documentLoader, contextLoader });
6799
+ }
6800
+ catch (e) {
6801
+ if (!(e instanceof TypeError))
6802
+ throw e;
6803
+ }
6804
+ throw new TypeError("Expected an object of any type of: " +
6805
+ ["https://www.w3.org/ns/activitystreams#Object"].join(", "));
6806
+ }
6807
+ /**
6808
+ * Similar to
6809
+ * {@link Activity.getOrigin},
6810
+ * but returns its `@id` URL instead of the object itself.
6811
+ */
6812
+ get originId() {
6813
+ if (this.#_25zu2s3VxVujgEKqrDycjE284XQR.length < 1)
6814
+ return null;
6815
+ const v = this.#_25zu2s3VxVujgEKqrDycjE284XQR[0];
6816
+ if (v instanceof URL)
6817
+ return v;
6818
+ return v.id;
6819
+ }
6820
+ /** Describes an indirect object of the activity from which the activity is
6821
+ * directed. The precise meaning of the origin is the object of the English
6822
+ * preposition "from". For instance, in the activity "John moved an item to
6823
+ * List B from List A", the origin of the activity is "List A".
6824
+ */
6825
+ async getOrigin(options = {}) {
6826
+ if (this.#_25zu2s3VxVujgEKqrDycjE284XQR.length < 1)
6827
+ return null;
6828
+ const v = this.#_25zu2s3VxVujgEKqrDycjE284XQR[0];
6829
+ if (v instanceof URL) {
6830
+ const fetched = await this.#fetchOrigin(v, options);
6831
+ if (fetched == null)
6832
+ return null;
6833
+ this.#_25zu2s3VxVujgEKqrDycjE284XQR[0] = fetched;
6834
+ return fetched;
6835
+ }
6836
+ return v;
6837
+ }
6838
+ /**
6839
+ * Similar to
6840
+ * {@link Activity.getOrigins},
6841
+ * but returns their `@id`s instead of the objects themselves.
6842
+ */
6843
+ get originIds() {
6844
+ return this.#_25zu2s3VxVujgEKqrDycjE284XQR.map((v) => v instanceof URL ? v : v.id).filter((id) => id !== null);
6845
+ }
6846
+ /** Describes an indirect object of the activity from which the activity is
6847
+ * directed. The precise meaning of the origin is the object of the English
6848
+ * preposition "from". For instance, in the activity "John moved an item to
6849
+ * List B from List A", the origin of the activity is "List A".
6850
+ */
6851
+ async *getOrigins(options = {}) {
6852
+ const vs = this.#_25zu2s3VxVujgEKqrDycjE284XQR;
6853
+ for (let i = 0; i < vs.length; i++) {
6854
+ const v = vs[i];
6855
+ if (v instanceof URL) {
6856
+ const fetched = await this.#fetchOrigin(v, options);
6857
+ if (fetched == null)
6858
+ continue;
6859
+ vs[i] = fetched;
6860
+ yield fetched;
6861
+ continue;
6862
+ }
6863
+ yield v;
6864
+ }
6865
+ }
6866
+ async #fetchInstrument(url, options = {}) {
6867
+ const documentLoader = options.documentLoader ?? this._documentLoader ??
6868
+ fetchDocumentLoader;
6869
+ const contextLoader = options.contextLoader ?? this._contextLoader ??
6870
+ fetchDocumentLoader;
6871
+ let fetchResult;
6872
+ try {
6873
+ fetchResult = await documentLoader(url.href);
6874
+ }
6875
+ catch (error) {
6876
+ if (options.suppressError) {
6877
+ getLogger(["fedify", "vocab"]).error("Failed to fetch {url}: {error}", { error, url: url.href });
6878
+ return null;
6879
+ }
6880
+ throw error;
6881
+ }
6882
+ const { document } = fetchResult;
6883
+ try {
6884
+ return await Object.fromJsonLd(document, { documentLoader, contextLoader });
6885
+ }
6886
+ catch (e) {
6887
+ if (!(e instanceof TypeError))
6888
+ throw e;
6889
+ }
6890
+ throw new TypeError("Expected an object of any type of: " +
6891
+ ["https://www.w3.org/ns/activitystreams#Object"].join(", "));
6892
+ }
6893
+ /**
6894
+ * Similar to
6895
+ * {@link Activity.getInstrument},
6896
+ * but returns its `@id` URL instead of the object itself.
6897
+ */
6898
+ get instrumentId() {
6899
+ if (this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ.length < 1)
6900
+ return null;
6901
+ const v = this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ[0];
6902
+ if (v instanceof URL)
6903
+ return v;
6904
+ return v.id;
6905
+ }
6906
+ /** Identifies one or more objects used (or to be used) in the completion of
6907
+ * an {@link Activity}.
6908
+ */
6909
+ async getInstrument(options = {}) {
6910
+ if (this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ.length < 1)
6911
+ return null;
6912
+ const v = this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ[0];
6913
+ if (v instanceof URL) {
6914
+ const fetched = await this.#fetchInstrument(v, options);
6915
+ if (fetched == null)
6916
+ return null;
6917
+ this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ[0] = fetched;
6918
+ return fetched;
6919
+ }
6920
+ return v;
6921
+ }
6922
+ /**
6923
+ * Similar to
6924
+ * {@link Activity.getInstruments},
6925
+ * but returns their `@id`s instead of the objects themselves.
6926
+ */
6927
+ get instrumentIds() {
6928
+ return this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ.map((v) => v instanceof URL ? v : v.id).filter((id) => id !== null);
6929
+ }
6930
+ /** Identifies one or more objects used (or to be used) in the completion of
6931
+ * an {@link Activity}.
6932
+ */
6933
+ async *getInstruments(options = {}) {
6934
+ const vs = this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ;
6935
+ for (let i = 0; i < vs.length; i++) {
6936
+ const v = vs[i];
6937
+ if (v instanceof URL) {
6938
+ const fetched = await this.#fetchInstrument(v, options);
6939
+ if (fetched == null)
6940
+ continue;
6941
+ vs[i] = fetched;
6942
+ yield fetched;
6943
+ continue;
6944
+ }
6945
+ yield v;
6946
+ }
6947
+ }
6386
6948
  /**
6387
6949
  * Converts this object to a JSON-LD structure.
6388
6950
  * @returns The JSON-LD representation of this object.
@@ -6427,6 +6989,46 @@ export class Activity extends Object {
6427
6989
  if (array.length > 0) {
6428
6990
  values["https://www.w3.org/ns/activitystreams#object"] = array;
6429
6991
  }
6992
+ array = [];
6993
+ for (const v of this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF) {
6994
+ const element = v instanceof URL
6995
+ ? { "@id": v.href }
6996
+ : await v.toJsonLd(options);
6997
+ array.push(element);
6998
+ }
6999
+ if (array.length > 0) {
7000
+ values["https://www.w3.org/ns/activitystreams#target"] = array;
7001
+ }
7002
+ array = [];
7003
+ for (const v of this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G) {
7004
+ const element = v instanceof URL
7005
+ ? { "@id": v.href }
7006
+ : await v.toJsonLd(options);
7007
+ array.push(element);
7008
+ }
7009
+ if (array.length > 0) {
7010
+ values["https://www.w3.org/ns/activitystreams#result"] = array;
7011
+ }
7012
+ array = [];
7013
+ for (const v of this.#_25zu2s3VxVujgEKqrDycjE284XQR) {
7014
+ const element = v instanceof URL
7015
+ ? { "@id": v.href }
7016
+ : await v.toJsonLd(options);
7017
+ array.push(element);
7018
+ }
7019
+ if (array.length > 0) {
7020
+ values["https://www.w3.org/ns/activitystreams#origin"] = array;
7021
+ }
7022
+ array = [];
7023
+ for (const v of this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ) {
7024
+ const element = v instanceof URL
7025
+ ? { "@id": v.href }
7026
+ : await v.toJsonLd(options);
7027
+ array.push(element);
7028
+ }
7029
+ if (array.length > 0) {
7030
+ values["https://www.w3.org/ns/activitystreams#instrument"] = array;
7031
+ }
6430
7032
  values["@type"] = ["https://www.w3.org/ns/activitystreams#Activity"];
6431
7033
  if (this.id)
6432
7034
  values["@id"] = this.id.href;
@@ -6588,21 +7190,70 @@ export class Activity extends Object {
6588
7190
  : undefined;
6589
7191
  if (typeof decoded === "undefined")
6590
7192
  continue;
6591
- _2DjTTboo3CNHU2a2JQqUSE2dbv9D.push(decoded);
7193
+ _2DjTTboo3CNHU2a2JQqUSE2dbv9D.push(decoded);
7194
+ }
7195
+ instance.#_2DjTTboo3CNHU2a2JQqUSE2dbv9D = _2DjTTboo3CNHU2a2JQqUSE2dbv9D;
7196
+ const _2MH19yxjn1wnHsNfa5n4JBhJzxyc = [];
7197
+ for (const v of values["https://www.w3.org/ns/activitystreams#object"] ?? []) {
7198
+ if (v == null)
7199
+ continue;
7200
+ if (typeof v === "object" && "@id" in v && !("@type" in v) &&
7201
+ globalThis.Object.keys(v).length === 1) {
7202
+ _2MH19yxjn1wnHsNfa5n4JBhJzxyc.push(new URL(v["@id"]));
7203
+ continue;
7204
+ }
7205
+ _2MH19yxjn1wnHsNfa5n4JBhJzxyc.push(await Object.fromJsonLd(v, options));
7206
+ }
7207
+ instance.#_2MH19yxjn1wnHsNfa5n4JBhJzxyc = _2MH19yxjn1wnHsNfa5n4JBhJzxyc;
7208
+ const _3JQCmF2Ww56Ag9EWRYoSZRDNCYtF = [];
7209
+ for (const v of values["https://www.w3.org/ns/activitystreams#target"] ?? []) {
7210
+ if (v == null)
7211
+ continue;
7212
+ if (typeof v === "object" && "@id" in v && !("@type" in v) &&
7213
+ globalThis.Object.keys(v).length === 1) {
7214
+ _3JQCmF2Ww56Ag9EWRYoSZRDNCYtF.push(new URL(v["@id"]));
7215
+ continue;
7216
+ }
7217
+ _3JQCmF2Ww56Ag9EWRYoSZRDNCYtF.push(await Object.fromJsonLd(v, options));
6592
7218
  }
6593
- instance.#_2DjTTboo3CNHU2a2JQqUSE2dbv9D = _2DjTTboo3CNHU2a2JQqUSE2dbv9D;
6594
- const _2MH19yxjn1wnHsNfa5n4JBhJzxyc = [];
6595
- for (const v of values["https://www.w3.org/ns/activitystreams#object"] ?? []) {
7219
+ instance.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF = _3JQCmF2Ww56Ag9EWRYoSZRDNCYtF;
7220
+ const _u4QGFbRFcYmPEKGbPv1hpBR9r5G = [];
7221
+ for (const v of values["https://www.w3.org/ns/activitystreams#result"] ?? []) {
6596
7222
  if (v == null)
6597
7223
  continue;
6598
7224
  if (typeof v === "object" && "@id" in v && !("@type" in v) &&
6599
7225
  globalThis.Object.keys(v).length === 1) {
6600
- _2MH19yxjn1wnHsNfa5n4JBhJzxyc.push(new URL(v["@id"]));
7226
+ _u4QGFbRFcYmPEKGbPv1hpBR9r5G.push(new URL(v["@id"]));
6601
7227
  continue;
6602
7228
  }
6603
- _2MH19yxjn1wnHsNfa5n4JBhJzxyc.push(await Object.fromJsonLd(v, options));
7229
+ _u4QGFbRFcYmPEKGbPv1hpBR9r5G.push(await Object.fromJsonLd(v, options));
6604
7230
  }
6605
- instance.#_2MH19yxjn1wnHsNfa5n4JBhJzxyc = _2MH19yxjn1wnHsNfa5n4JBhJzxyc;
7231
+ instance.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G = _u4QGFbRFcYmPEKGbPv1hpBR9r5G;
7232
+ const _25zu2s3VxVujgEKqrDycjE284XQR = [];
7233
+ for (const v of values["https://www.w3.org/ns/activitystreams#origin"] ?? []) {
7234
+ if (v == null)
7235
+ continue;
7236
+ if (typeof v === "object" && "@id" in v && !("@type" in v) &&
7237
+ globalThis.Object.keys(v).length === 1) {
7238
+ _25zu2s3VxVujgEKqrDycjE284XQR.push(new URL(v["@id"]));
7239
+ continue;
7240
+ }
7241
+ _25zu2s3VxVujgEKqrDycjE284XQR.push(await Object.fromJsonLd(v, options));
7242
+ }
7243
+ instance.#_25zu2s3VxVujgEKqrDycjE284XQR = _25zu2s3VxVujgEKqrDycjE284XQR;
7244
+ const _3c5t2x7DYRo2shwTxpkd4kYSS5WQ = [];
7245
+ for (const v of values["https://www.w3.org/ns/activitystreams#instrument"] ??
7246
+ []) {
7247
+ if (v == null)
7248
+ continue;
7249
+ if (typeof v === "object" && "@id" in v && !("@type" in v) &&
7250
+ globalThis.Object.keys(v).length === 1) {
7251
+ _3c5t2x7DYRo2shwTxpkd4kYSS5WQ.push(new URL(v["@id"]));
7252
+ continue;
7253
+ }
7254
+ _3c5t2x7DYRo2shwTxpkd4kYSS5WQ.push(await Object.fromJsonLd(v, options));
7255
+ }
7256
+ instance.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ = _3c5t2x7DYRo2shwTxpkd4kYSS5WQ;
6606
7257
  return instance;
6607
7258
  }
6608
7259
  _getCustomInspectProxy() {
@@ -6639,6 +7290,70 @@ export class Activity extends Object {
6639
7290
  _2MH19yxjn1wnHsNfa5n4JBhJzxyc.length > 0) {
6640
7291
  proxy.objects = _2MH19yxjn1wnHsNfa5n4JBhJzxyc;
6641
7292
  }
7293
+ const _3JQCmF2Ww56Ag9EWRYoSZRDNCYtF = this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF
7294
+ // deno-lint-ignore no-explicit-any
7295
+ .map((v) => v instanceof URL
7296
+ ? {
7297
+ [Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
7298
+ [Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
7299
+ }
7300
+ : v);
7301
+ if (_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF.length == 1) {
7302
+ proxy.target = _3JQCmF2Ww56Ag9EWRYoSZRDNCYtF[0];
7303
+ }
7304
+ if (_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF.length > 1 ||
7305
+ !("target" in proxy) &&
7306
+ _3JQCmF2Ww56Ag9EWRYoSZRDNCYtF.length > 0) {
7307
+ proxy.targets = _3JQCmF2Ww56Ag9EWRYoSZRDNCYtF;
7308
+ }
7309
+ const _u4QGFbRFcYmPEKGbPv1hpBR9r5G = this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G
7310
+ // deno-lint-ignore no-explicit-any
7311
+ .map((v) => v instanceof URL
7312
+ ? {
7313
+ [Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
7314
+ [Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
7315
+ }
7316
+ : v);
7317
+ if (_u4QGFbRFcYmPEKGbPv1hpBR9r5G.length == 1) {
7318
+ proxy.result = _u4QGFbRFcYmPEKGbPv1hpBR9r5G[0];
7319
+ }
7320
+ if (_u4QGFbRFcYmPEKGbPv1hpBR9r5G.length > 1 ||
7321
+ !("result" in proxy) &&
7322
+ _u4QGFbRFcYmPEKGbPv1hpBR9r5G.length > 0) {
7323
+ proxy.results = _u4QGFbRFcYmPEKGbPv1hpBR9r5G;
7324
+ }
7325
+ const _25zu2s3VxVujgEKqrDycjE284XQR = this.#_25zu2s3VxVujgEKqrDycjE284XQR
7326
+ // deno-lint-ignore no-explicit-any
7327
+ .map((v) => v instanceof URL
7328
+ ? {
7329
+ [Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
7330
+ [Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
7331
+ }
7332
+ : v);
7333
+ if (_25zu2s3VxVujgEKqrDycjE284XQR.length == 1) {
7334
+ proxy.origin = _25zu2s3VxVujgEKqrDycjE284XQR[0];
7335
+ }
7336
+ if (_25zu2s3VxVujgEKqrDycjE284XQR.length > 1 ||
7337
+ !("origin" in proxy) &&
7338
+ _25zu2s3VxVujgEKqrDycjE284XQR.length > 0) {
7339
+ proxy.origins = _25zu2s3VxVujgEKqrDycjE284XQR;
7340
+ }
7341
+ const _3c5t2x7DYRo2shwTxpkd4kYSS5WQ = this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ
7342
+ // deno-lint-ignore no-explicit-any
7343
+ .map((v) => v instanceof URL
7344
+ ? {
7345
+ [Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
7346
+ [Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
7347
+ }
7348
+ : v);
7349
+ if (_3c5t2x7DYRo2shwTxpkd4kYSS5WQ.length == 1) {
7350
+ proxy.instrument = _3c5t2x7DYRo2shwTxpkd4kYSS5WQ[0];
7351
+ }
7352
+ if (_3c5t2x7DYRo2shwTxpkd4kYSS5WQ.length > 1 ||
7353
+ !("instrument" in proxy) &&
7354
+ _3c5t2x7DYRo2shwTxpkd4kYSS5WQ.length > 0) {
7355
+ proxy.instruments = _3c5t2x7DYRo2shwTxpkd4kYSS5WQ;
7356
+ }
6642
7357
  return proxy;
6643
7358
  }
6644
7359
  [Symbol.for("Deno.customInspect")](inspect, options) {
@@ -8176,8 +8891,9 @@ export class Application extends Object {
8176
8891
  : await v.toJsonLd(options);
8177
8892
  array.push(element);
8178
8893
  }
8179
- if (array.length > 0)
8894
+ if (array.length > 0) {
8180
8895
  values["https://w3id.org/security#publicKey"] = array;
8896
+ }
8181
8897
  array = [];
8182
8898
  for (const v of this.#_4EHQFWZSz1k1d4LmPrQiMba2GbP3) {
8183
8899
  const element = v instanceof URL
@@ -8203,8 +8919,9 @@ export class Application extends Object {
8203
8919
  : await v.toJsonLd(options);
8204
8920
  array.push(element);
8205
8921
  }
8206
- if (array.length > 0)
8922
+ if (array.length > 0) {
8207
8923
  values["http://www.w3.org/ns/ldp#inbox"] = array;
8924
+ }
8208
8925
  array = [];
8209
8926
  for (const v of this.#_41QwhqJouoLg3h8dRPKat21brynC) {
8210
8927
  const element = v instanceof URL
@@ -8252,8 +8969,9 @@ export class Application extends Object {
8252
8969
  : await v.toJsonLd(options);
8253
8970
  array.push(element);
8254
8971
  }
8255
- if (array.length > 0)
8972
+ if (array.length > 0) {
8256
8973
  values["http://joinmastodon.org/ns#featured"] = array;
8974
+ }
8257
8975
  array = [];
8258
8976
  for (const v of this.#_3sG2Hdwn9qzKGu9mpYkqakAMUkH9) {
8259
8977
  const element = v instanceof URL
@@ -8293,8 +9011,9 @@ export class Application extends Object {
8293
9011
  const element = { "@value": v };
8294
9012
  array.push(element);
8295
9013
  }
8296
- if (array.length > 0)
9014
+ if (array.length > 0) {
8297
9015
  values["http://joinmastodon.org/ns#memorial"] = array;
9016
+ }
8298
9017
  array = [];
8299
9018
  for (const v of this.#_2diCorzqPGQQqftp6e4SrCEwEnyk) {
8300
9019
  const element = { "@value": v };
@@ -9720,46 +10439,44 @@ export class Collection extends Object {
9720
10439
  }
9721
10440
  if ("current" in values && values.current != null) {
9722
10441
  if (values.current instanceof CollectionPage ||
9723
- values.current instanceof Link || values.current instanceof URL) {
10442
+ values.current instanceof URL) {
9724
10443
  // @ts-ignore: type is checked above.
9725
10444
  this.#_3UyUdxnyn6cDn53QKrh4MBiearma = [values.current];
9726
10445
  }
9727
10446
  else {
9728
10447
  throw new TypeError("The current must be of type " +
9729
- "CollectionPage | Link | URL" + ".");
10448
+ "CollectionPage | URL" + ".");
9730
10449
  }
9731
10450
  }
9732
10451
  if ("first" in values && values.first != null) {
9733
- if (values.first instanceof CollectionPage ||
9734
- values.first instanceof Link || values.first instanceof URL) {
10452
+ if (values.first instanceof CollectionPage || values.first instanceof URL) {
9735
10453
  // @ts-ignore: type is checked above.
9736
10454
  this.#_J52RqweMe6hhv7RnLJMC8BExTE5 = [values.first];
9737
10455
  }
9738
10456
  else {
9739
10457
  throw new TypeError("The first must be of type " +
9740
- "CollectionPage | Link | URL" + ".");
10458
+ "CollectionPage | URL" + ".");
9741
10459
  }
9742
10460
  }
9743
10461
  if ("last" in values && values.last != null) {
9744
- if (values.last instanceof CollectionPage || values.last instanceof Link ||
9745
- values.last instanceof URL) {
10462
+ if (values.last instanceof CollectionPage || values.last instanceof URL) {
9746
10463
  // @ts-ignore: type is checked above.
9747
10464
  this.#_gyJJnyEFnuNVi1HFZKfAn3Hfn26 = [values.last];
9748
10465
  }
9749
10466
  else {
9750
10467
  throw new TypeError("The last must be of type " +
9751
- "CollectionPage | Link | URL" + ".");
10468
+ "CollectionPage | URL" + ".");
9752
10469
  }
9753
10470
  }
9754
10471
  if ("items" in values && values.items != null) {
9755
10472
  if (Array.isArray(values.items) &&
9756
- values.items.every((v) => v instanceof Object || v instanceof Link || v instanceof URL)) {
10473
+ values.items.every((v) => v instanceof Object || v instanceof URL)) {
9757
10474
  // @ts-ignore: type is checked above.
9758
10475
  this.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = values.items;
9759
10476
  }
9760
10477
  else {
9761
10478
  throw new TypeError("The items must be an array of type " +
9762
- "Object | Link | URL" + ".");
10479
+ "Object | URL" + ".");
9763
10480
  }
9764
10481
  }
9765
10482
  }
@@ -9786,49 +10503,47 @@ export class Collection extends Object {
9786
10503
  clone.#_3UyUdxnyn6cDn53QKrh4MBiearma = this.#_3UyUdxnyn6cDn53QKrh4MBiearma;
9787
10504
  if ("current" in values && values.current != null) {
9788
10505
  if (values.current instanceof CollectionPage ||
9789
- values.current instanceof Link || values.current instanceof URL) {
10506
+ values.current instanceof URL) {
9790
10507
  // @ts-ignore: type is checked above.
9791
10508
  clone.#_3UyUdxnyn6cDn53QKrh4MBiearma = [values.current];
9792
10509
  }
9793
10510
  else {
9794
10511
  throw new TypeError("The current must be of type " +
9795
- "CollectionPage | Link | URL" + ".");
10512
+ "CollectionPage | URL" + ".");
9796
10513
  }
9797
10514
  }
9798
10515
  clone.#_J52RqweMe6hhv7RnLJMC8BExTE5 = this.#_J52RqweMe6hhv7RnLJMC8BExTE5;
9799
10516
  if ("first" in values && values.first != null) {
9800
- if (values.first instanceof CollectionPage ||
9801
- values.first instanceof Link || values.first instanceof URL) {
10517
+ if (values.first instanceof CollectionPage || values.first instanceof URL) {
9802
10518
  // @ts-ignore: type is checked above.
9803
10519
  clone.#_J52RqweMe6hhv7RnLJMC8BExTE5 = [values.first];
9804
10520
  }
9805
10521
  else {
9806
10522
  throw new TypeError("The first must be of type " +
9807
- "CollectionPage | Link | URL" + ".");
10523
+ "CollectionPage | URL" + ".");
9808
10524
  }
9809
10525
  }
9810
10526
  clone.#_gyJJnyEFnuNVi1HFZKfAn3Hfn26 = this.#_gyJJnyEFnuNVi1HFZKfAn3Hfn26;
9811
10527
  if ("last" in values && values.last != null) {
9812
- if (values.last instanceof CollectionPage || values.last instanceof Link ||
9813
- values.last instanceof URL) {
10528
+ if (values.last instanceof CollectionPage || values.last instanceof URL) {
9814
10529
  // @ts-ignore: type is checked above.
9815
10530
  clone.#_gyJJnyEFnuNVi1HFZKfAn3Hfn26 = [values.last];
9816
10531
  }
9817
10532
  else {
9818
10533
  throw new TypeError("The last must be of type " +
9819
- "CollectionPage | Link | URL" + ".");
10534
+ "CollectionPage | URL" + ".");
9820
10535
  }
9821
10536
  }
9822
10537
  clone.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = this.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg;
9823
10538
  if ("items" in values && values.items != null) {
9824
10539
  if (Array.isArray(values.items) &&
9825
- values.items.every((v) => v instanceof Object || v instanceof Link || v instanceof URL)) {
10540
+ values.items.every((v) => v instanceof Object || v instanceof URL)) {
9826
10541
  // @ts-ignore: type is checked above.
9827
10542
  clone.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = values.items;
9828
10543
  }
9829
10544
  else {
9830
10545
  throw new TypeError("The items must be an array of type " +
9831
- "Object | Link | URL" + ".");
10546
+ "Object | URL" + ".");
9832
10547
  }
9833
10548
  }
9834
10549
  return clone;
@@ -9866,18 +10581,8 @@ export class Collection extends Object {
9866
10581
  if (!(e instanceof TypeError))
9867
10582
  throw e;
9868
10583
  }
9869
- try {
9870
- return await Link.fromJsonLd(document, { documentLoader, contextLoader });
9871
- }
9872
- catch (e) {
9873
- if (!(e instanceof TypeError))
9874
- throw e;
9875
- }
9876
10584
  throw new TypeError("Expected an object of any type of: " +
9877
- [
9878
- "https://www.w3.org/ns/activitystreams#CollectionPage",
9879
- "https://www.w3.org/ns/activitystreams#Link",
9880
- ].join(", "));
10585
+ ["https://www.w3.org/ns/activitystreams#CollectionPage"].join(", "));
9881
10586
  }
9882
10587
  /**
9883
10588
  * Similar to
@@ -9932,18 +10637,8 @@ export class Collection extends Object {
9932
10637
  if (!(e instanceof TypeError))
9933
10638
  throw e;
9934
10639
  }
9935
- try {
9936
- return await Link.fromJsonLd(document, { documentLoader, contextLoader });
9937
- }
9938
- catch (e) {
9939
- if (!(e instanceof TypeError))
9940
- throw e;
9941
- }
9942
10640
  throw new TypeError("Expected an object of any type of: " +
9943
- [
9944
- "https://www.w3.org/ns/activitystreams#CollectionPage",
9945
- "https://www.w3.org/ns/activitystreams#Link",
9946
- ].join(", "));
10641
+ ["https://www.w3.org/ns/activitystreams#CollectionPage"].join(", "));
9947
10642
  }
9948
10643
  /**
9949
10644
  * Similar to
@@ -9998,18 +10693,8 @@ export class Collection extends Object {
9998
10693
  if (!(e instanceof TypeError))
9999
10694
  throw e;
10000
10695
  }
10001
- try {
10002
- return await Link.fromJsonLd(document, { documentLoader, contextLoader });
10003
- }
10004
- catch (e) {
10005
- if (!(e instanceof TypeError))
10006
- throw e;
10007
- }
10008
10696
  throw new TypeError("Expected an object of any type of: " +
10009
- [
10010
- "https://www.w3.org/ns/activitystreams#CollectionPage",
10011
- "https://www.w3.org/ns/activitystreams#Link",
10012
- ].join(", "));
10697
+ ["https://www.w3.org/ns/activitystreams#CollectionPage"].join(", "));
10013
10698
  }
10014
10699
  /**
10015
10700
  * Similar to
@@ -10064,18 +10749,8 @@ export class Collection extends Object {
10064
10749
  if (!(e instanceof TypeError))
10065
10750
  throw e;
10066
10751
  }
10067
- try {
10068
- return await Link.fromJsonLd(document, { documentLoader, contextLoader });
10069
- }
10070
- catch (e) {
10071
- if (!(e instanceof TypeError))
10072
- throw e;
10073
- }
10074
10752
  throw new TypeError("Expected an object of any type of: " +
10075
- [
10076
- "https://www.w3.org/ns/activitystreams#Object",
10077
- "https://www.w3.org/ns/activitystreams#Link",
10078
- ].join(", "));
10753
+ ["https://www.w3.org/ns/activitystreams#Object"].join(", "));
10079
10754
  }
10080
10755
  /**
10081
10756
  * Similar to
@@ -10134,9 +10809,7 @@ export class Collection extends Object {
10134
10809
  for (const v of this.#_3UyUdxnyn6cDn53QKrh4MBiearma) {
10135
10810
  const element = v instanceof URL
10136
10811
  ? { "@id": v.href }
10137
- : v instanceof CollectionPage
10138
- ? await v.toJsonLd(options)
10139
- : await v.toJsonLd(options);
10812
+ : await v.toJsonLd(options);
10140
10813
  array.push(element);
10141
10814
  }
10142
10815
  if (array.length > 0) {
@@ -10146,9 +10819,7 @@ export class Collection extends Object {
10146
10819
  for (const v of this.#_J52RqweMe6hhv7RnLJMC8BExTE5) {
10147
10820
  const element = v instanceof URL
10148
10821
  ? { "@id": v.href }
10149
- : v instanceof CollectionPage
10150
- ? await v.toJsonLd(options)
10151
- : await v.toJsonLd(options);
10822
+ : await v.toJsonLd(options);
10152
10823
  array.push(element);
10153
10824
  }
10154
10825
  if (array.length > 0) {
@@ -10158,9 +10829,7 @@ export class Collection extends Object {
10158
10829
  for (const v of this.#_gyJJnyEFnuNVi1HFZKfAn3Hfn26) {
10159
10830
  const element = v instanceof URL
10160
10831
  ? { "@id": v.href }
10161
- : v instanceof CollectionPage
10162
- ? await v.toJsonLd(options)
10163
- : await v.toJsonLd(options);
10832
+ : await v.toJsonLd(options);
10164
10833
  array.push(element);
10165
10834
  }
10166
10835
  if (array.length > 0) {
@@ -10170,9 +10839,7 @@ export class Collection extends Object {
10170
10839
  for (const v of this.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg) {
10171
10840
  const element = v instanceof URL
10172
10841
  ? { "@id": v.href }
10173
- : v instanceof Object
10174
- ? await v.toJsonLd(options)
10175
- : await v.toJsonLd(options);
10842
+ : await v.toJsonLd(options);
10176
10843
  array.push(element);
10177
10844
  }
10178
10845
  if (array.length > 0) {
@@ -10255,25 +10922,7 @@ export class Collection extends Object {
10255
10922
  _3UyUdxnyn6cDn53QKrh4MBiearma.push(new URL(v["@id"]));
10256
10923
  continue;
10257
10924
  }
10258
- const decoded = typeof v === "object" && "@type" in v &&
10259
- Array.isArray(v["@type"]) &&
10260
- [
10261
- "https://www.w3.org/ns/activitystreams#CollectionPage",
10262
- "https://www.w3.org/ns/activitystreams#OrderedCollectionPage",
10263
- ].some((t) => v["@type"].includes(t))
10264
- ? await CollectionPage.fromJsonLd(v, options)
10265
- : typeof v === "object" && "@type" in v &&
10266
- Array.isArray(v["@type"]) &&
10267
- [
10268
- "https://www.w3.org/ns/activitystreams#Link",
10269
- "https://www.w3.org/ns/activitystreams#Hashtag",
10270
- "https://www.w3.org/ns/activitystreams#Mention",
10271
- ].some((t) => v["@type"].includes(t))
10272
- ? await Link.fromJsonLd(v, options)
10273
- : undefined;
10274
- if (typeof decoded === "undefined")
10275
- continue;
10276
- _3UyUdxnyn6cDn53QKrh4MBiearma.push(decoded);
10925
+ _3UyUdxnyn6cDn53QKrh4MBiearma.push(await CollectionPage.fromJsonLd(v, options));
10277
10926
  }
10278
10927
  instance.#_3UyUdxnyn6cDn53QKrh4MBiearma = _3UyUdxnyn6cDn53QKrh4MBiearma;
10279
10928
  const _J52RqweMe6hhv7RnLJMC8BExTE5 = [];
@@ -10285,126 +10934,31 @@ export class Collection extends Object {
10285
10934
  _J52RqweMe6hhv7RnLJMC8BExTE5.push(new URL(v["@id"]));
10286
10935
  continue;
10287
10936
  }
10288
- const decoded = typeof v === "object" && "@type" in v &&
10289
- Array.isArray(v["@type"]) &&
10290
- [
10291
- "https://www.w3.org/ns/activitystreams#CollectionPage",
10292
- "https://www.w3.org/ns/activitystreams#OrderedCollectionPage",
10293
- ].some((t) => v["@type"].includes(t))
10294
- ? await CollectionPage.fromJsonLd(v, options)
10295
- : typeof v === "object" && "@type" in v &&
10296
- Array.isArray(v["@type"]) &&
10297
- [
10298
- "https://www.w3.org/ns/activitystreams#Link",
10299
- "https://www.w3.org/ns/activitystreams#Hashtag",
10300
- "https://www.w3.org/ns/activitystreams#Mention",
10301
- ].some((t) => v["@type"].includes(t))
10302
- ? await Link.fromJsonLd(v, options)
10303
- : undefined;
10304
- if (typeof decoded === "undefined")
10305
- continue;
10306
- _J52RqweMe6hhv7RnLJMC8BExTE5.push(decoded);
10307
- }
10308
- instance.#_J52RqweMe6hhv7RnLJMC8BExTE5 = _J52RqweMe6hhv7RnLJMC8BExTE5;
10309
- const _gyJJnyEFnuNVi1HFZKfAn3Hfn26 = [];
10310
- for (const v of values["https://www.w3.org/ns/activitystreams#last"] ?? []) {
10311
- if (v == null)
10312
- continue;
10313
- if (typeof v === "object" && "@id" in v && !("@type" in v) &&
10314
- globalThis.Object.keys(v).length === 1) {
10315
- _gyJJnyEFnuNVi1HFZKfAn3Hfn26.push(new URL(v["@id"]));
10316
- continue;
10317
- }
10318
- const decoded = typeof v === "object" && "@type" in v &&
10319
- Array.isArray(v["@type"]) &&
10320
- [
10321
- "https://www.w3.org/ns/activitystreams#CollectionPage",
10322
- "https://www.w3.org/ns/activitystreams#OrderedCollectionPage",
10323
- ].some((t) => v["@type"].includes(t))
10324
- ? await CollectionPage.fromJsonLd(v, options)
10325
- : typeof v === "object" && "@type" in v &&
10326
- Array.isArray(v["@type"]) &&
10327
- [
10328
- "https://www.w3.org/ns/activitystreams#Link",
10329
- "https://www.w3.org/ns/activitystreams#Hashtag",
10330
- "https://www.w3.org/ns/activitystreams#Mention",
10331
- ].some((t) => v["@type"].includes(t))
10332
- ? await Link.fromJsonLd(v, options)
10333
- : undefined;
10334
- if (typeof decoded === "undefined")
10335
- continue;
10336
- _gyJJnyEFnuNVi1HFZKfAn3Hfn26.push(decoded);
10937
+ _J52RqweMe6hhv7RnLJMC8BExTE5.push(await CollectionPage.fromJsonLd(v, options));
10337
10938
  }
10338
- instance.#_gyJJnyEFnuNVi1HFZKfAn3Hfn26 = _gyJJnyEFnuNVi1HFZKfAn3Hfn26;
10339
- const _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = [];
10340
- for (const v of values["https://www.w3.org/ns/activitystreams#items"] ?? []) {
10341
- if (v == null)
10342
- continue;
10343
- if (typeof v === "object" && "@id" in v && !("@type" in v) &&
10344
- globalThis.Object.keys(v).length === 1) {
10345
- _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg.push(new URL(v["@id"]));
10346
- continue;
10347
- }
10348
- const decoded = typeof v === "object" && "@type" in v &&
10349
- Array.isArray(v["@type"]) &&
10350
- [
10351
- "https://www.w3.org/ns/activitystreams#Object",
10352
- "http://joinmastodon.org/ns#Emoji",
10353
- "https://www.w3.org/ns/activitystreams#Activity",
10354
- "https://www.w3.org/ns/activitystreams#Accept",
10355
- "https://www.w3.org/ns/activitystreams#Add",
10356
- "https://www.w3.org/ns/activitystreams#Announce",
10357
- "https://www.w3.org/ns/activitystreams#Create",
10358
- "https://www.w3.org/ns/activitystreams#Delete",
10359
- "https://www.w3.org/ns/activitystreams#Dislike",
10360
- "https://www.w3.org/ns/activitystreams#Flag",
10361
- "https://www.w3.org/ns/activitystreams#Follow",
10362
- "https://www.w3.org/ns/activitystreams#Ignore",
10363
- "https://www.w3.org/ns/activitystreams#Block",
10364
- "https://www.w3.org/ns/activitystreams#IntransitiveActivity",
10365
- "https://www.w3.org/ns/activitystreams#Arrive",
10366
- "https://www.w3.org/ns/activitystreams#Question",
10367
- "https://www.w3.org/ns/activitystreams#Like",
10368
- "https://www.w3.org/ns/activitystreams#Offer",
10369
- "https://www.w3.org/ns/activitystreams#Reject",
10370
- "https://www.w3.org/ns/activitystreams#Remove",
10371
- "https://www.w3.org/ns/activitystreams#Undo",
10372
- "https://www.w3.org/ns/activitystreams#Update",
10373
- "https://www.w3.org/ns/activitystreams#Application",
10374
- "https://www.w3.org/ns/activitystreams#Article",
10375
- "https://www.w3.org/ns/activitystreams#Collection",
10376
- "https://www.w3.org/ns/activitystreams#CollectionPage",
10377
- "https://www.w3.org/ns/activitystreams#OrderedCollectionPage",
10378
- "https://www.w3.org/ns/activitystreams#OrderedCollection",
10379
- "https://www.w3.org/ns/activitystreams#Document",
10380
- "https://www.w3.org/ns/activitystreams#Audio",
10381
- "https://www.w3.org/ns/activitystreams#Image",
10382
- "https://www.w3.org/ns/activitystreams#Page",
10383
- "https://www.w3.org/ns/activitystreams#Video",
10384
- "https://www.w3.org/ns/activitystreams#Event",
10385
- "https://www.w3.org/ns/activitystreams#Group",
10386
- "https://www.w3.org/ns/activitystreams#Note",
10387
- "https://www.w3.org/ns/activitystreams#Organization",
10388
- "https://www.w3.org/ns/activitystreams#Person",
10389
- "https://www.w3.org/ns/activitystreams#Place",
10390
- "https://www.w3.org/ns/activitystreams#Profile",
10391
- "https://www.w3.org/ns/activitystreams#Relationship",
10392
- "https://www.w3.org/ns/activitystreams#Service",
10393
- "https://www.w3.org/ns/activitystreams#Tombstone",
10394
- ].some((t) => v["@type"].includes(t))
10395
- ? await Object.fromJsonLd(v, options)
10396
- : typeof v === "object" && "@type" in v &&
10397
- Array.isArray(v["@type"]) &&
10398
- [
10399
- "https://www.w3.org/ns/activitystreams#Link",
10400
- "https://www.w3.org/ns/activitystreams#Hashtag",
10401
- "https://www.w3.org/ns/activitystreams#Mention",
10402
- ].some((t) => v["@type"].includes(t))
10403
- ? await Link.fromJsonLd(v, options)
10404
- : undefined;
10405
- if (typeof decoded === "undefined")
10939
+ instance.#_J52RqweMe6hhv7RnLJMC8BExTE5 = _J52RqweMe6hhv7RnLJMC8BExTE5;
10940
+ const _gyJJnyEFnuNVi1HFZKfAn3Hfn26 = [];
10941
+ for (const v of values["https://www.w3.org/ns/activitystreams#last"] ?? []) {
10942
+ if (v == null)
10943
+ continue;
10944
+ if (typeof v === "object" && "@id" in v && !("@type" in v) &&
10945
+ globalThis.Object.keys(v).length === 1) {
10946
+ _gyJJnyEFnuNVi1HFZKfAn3Hfn26.push(new URL(v["@id"]));
10947
+ continue;
10948
+ }
10949
+ _gyJJnyEFnuNVi1HFZKfAn3Hfn26.push(await CollectionPage.fromJsonLd(v, options));
10950
+ }
10951
+ instance.#_gyJJnyEFnuNVi1HFZKfAn3Hfn26 = _gyJJnyEFnuNVi1HFZKfAn3Hfn26;
10952
+ const _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = [];
10953
+ for (const v of values["https://www.w3.org/ns/activitystreams#items"] ?? []) {
10954
+ if (v == null)
10955
+ continue;
10956
+ if (typeof v === "object" && "@id" in v && !("@type" in v) &&
10957
+ globalThis.Object.keys(v).length === 1) {
10958
+ _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg.push(new URL(v["@id"]));
10406
10959
  continue;
10407
- _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg.push(decoded);
10960
+ }
10961
+ _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg.push(await Object.fromJsonLd(v, options));
10408
10962
  }
10409
10963
  instance.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg;
10410
10964
  return instance;
@@ -10501,36 +11055,33 @@ export class CollectionPage extends Collection {
10501
11055
  constructor(values, { documentLoader, contextLoader, } = {}) {
10502
11056
  super(values, { documentLoader, contextLoader });
10503
11057
  if ("partOf" in values && values.partOf != null) {
10504
- if (values.partOf instanceof Link || values.partOf instanceof Collection ||
10505
- values.partOf instanceof URL) {
11058
+ if (values.partOf instanceof Collection || values.partOf instanceof URL) {
10506
11059
  // @ts-ignore: type is checked above.
10507
11060
  this.#_2kWgBhQKjEauxx8C6qF3ZQamK4Le = [values.partOf];
10508
11061
  }
10509
11062
  else {
10510
11063
  throw new TypeError("The partOf must be of type " +
10511
- "Link | Collection | URL" + ".");
11064
+ "Collection | URL" + ".");
10512
11065
  }
10513
11066
  }
10514
11067
  if ("next" in values && values.next != null) {
10515
- if (values.next instanceof _b || values.next instanceof Link ||
10516
- values.next instanceof URL) {
11068
+ if (values.next instanceof _b || values.next instanceof URL) {
10517
11069
  // @ts-ignore: type is checked above.
10518
11070
  this.#_3BT4kQLcXhHx7TAWaNDKh8nFn9eY = [values.next];
10519
11071
  }
10520
11072
  else {
10521
11073
  throw new TypeError("The next must be of type " +
10522
- "CollectionPage | Link | URL" + ".");
11074
+ "CollectionPage | URL" + ".");
10523
11075
  }
10524
11076
  }
10525
11077
  if ("prev" in values && values.prev != null) {
10526
- if (values.prev instanceof _b || values.prev instanceof Link ||
10527
- values.prev instanceof URL) {
11078
+ if (values.prev instanceof _b || values.prev instanceof URL) {
10528
11079
  // @ts-ignore: type is checked above.
10529
11080
  this.#_3b8yG8tDNzQFFEnWhCc13G8eHooA = [values.prev];
10530
11081
  }
10531
11082
  else {
10532
11083
  throw new TypeError("The prev must be of type " +
10533
- "CollectionPage | Link | URL" + ".");
11084
+ "CollectionPage | URL" + ".");
10534
11085
  }
10535
11086
  }
10536
11087
  }
@@ -10544,38 +11095,35 @@ export class CollectionPage extends Collection {
10544
11095
  const clone = super.clone(values, options);
10545
11096
  clone.#_2kWgBhQKjEauxx8C6qF3ZQamK4Le = this.#_2kWgBhQKjEauxx8C6qF3ZQamK4Le;
10546
11097
  if ("partOf" in values && values.partOf != null) {
10547
- if (values.partOf instanceof Link || values.partOf instanceof Collection ||
10548
- values.partOf instanceof URL) {
11098
+ if (values.partOf instanceof Collection || values.partOf instanceof URL) {
10549
11099
  // @ts-ignore: type is checked above.
10550
11100
  clone.#_2kWgBhQKjEauxx8C6qF3ZQamK4Le = [values.partOf];
10551
11101
  }
10552
11102
  else {
10553
11103
  throw new TypeError("The partOf must be of type " +
10554
- "Link | Collection | URL" + ".");
11104
+ "Collection | URL" + ".");
10555
11105
  }
10556
11106
  }
10557
11107
  clone.#_3BT4kQLcXhHx7TAWaNDKh8nFn9eY = this.#_3BT4kQLcXhHx7TAWaNDKh8nFn9eY;
10558
11108
  if ("next" in values && values.next != null) {
10559
- if (values.next instanceof _b || values.next instanceof Link ||
10560
- values.next instanceof URL) {
11109
+ if (values.next instanceof _b || values.next instanceof URL) {
10561
11110
  // @ts-ignore: type is checked above.
10562
11111
  clone.#_3BT4kQLcXhHx7TAWaNDKh8nFn9eY = [values.next];
10563
11112
  }
10564
11113
  else {
10565
11114
  throw new TypeError("The next must be of type " +
10566
- "CollectionPage | Link | URL" + ".");
11115
+ "CollectionPage | URL" + ".");
10567
11116
  }
10568
11117
  }
10569
11118
  clone.#_3b8yG8tDNzQFFEnWhCc13G8eHooA = this.#_3b8yG8tDNzQFFEnWhCc13G8eHooA;
10570
11119
  if ("prev" in values && values.prev != null) {
10571
- if (values.prev instanceof _b || values.prev instanceof Link ||
10572
- values.prev instanceof URL) {
11120
+ if (values.prev instanceof _b || values.prev instanceof URL) {
10573
11121
  // @ts-ignore: type is checked above.
10574
11122
  clone.#_3b8yG8tDNzQFFEnWhCc13G8eHooA = [values.prev];
10575
11123
  }
10576
11124
  else {
10577
11125
  throw new TypeError("The prev must be of type " +
10578
- "CollectionPage | Link | URL" + ".");
11126
+ "CollectionPage | URL" + ".");
10579
11127
  }
10580
11128
  }
10581
11129
  return clone;
@@ -10597,13 +11145,6 @@ export class CollectionPage extends Collection {
10597
11145
  throw error;
10598
11146
  }
10599
11147
  const { document } = fetchResult;
10600
- try {
10601
- return await Link.fromJsonLd(document, { documentLoader, contextLoader });
10602
- }
10603
- catch (e) {
10604
- if (!(e instanceof TypeError))
10605
- throw e;
10606
- }
10607
11148
  try {
10608
11149
  return await Collection.fromJsonLd(document, { documentLoader, contextLoader });
10609
11150
  }
@@ -10612,10 +11153,7 @@ export class CollectionPage extends Collection {
10612
11153
  throw e;
10613
11154
  }
10614
11155
  throw new TypeError("Expected an object of any type of: " +
10615
- [
10616
- "https://www.w3.org/ns/activitystreams#Link",
10617
- "https://www.w3.org/ns/activitystreams#Collection",
10618
- ].join(", "));
11156
+ ["https://www.w3.org/ns/activitystreams#Collection"].join(", "));
10619
11157
  }
10620
11158
  /**
10621
11159
  * Similar to
@@ -10670,18 +11208,8 @@ export class CollectionPage extends Collection {
10670
11208
  if (!(e instanceof TypeError))
10671
11209
  throw e;
10672
11210
  }
10673
- try {
10674
- return await Link.fromJsonLd(document, { documentLoader, contextLoader });
10675
- }
10676
- catch (e) {
10677
- if (!(e instanceof TypeError))
10678
- throw e;
10679
- }
10680
11211
  throw new TypeError("Expected an object of any type of: " +
10681
- [
10682
- "https://www.w3.org/ns/activitystreams#CollectionPage",
10683
- "https://www.w3.org/ns/activitystreams#Link",
10684
- ].join(", "));
11212
+ ["https://www.w3.org/ns/activitystreams#CollectionPage"].join(", "));
10685
11213
  }
10686
11214
  /**
10687
11215
  * Similar to
@@ -10735,18 +11263,8 @@ export class CollectionPage extends Collection {
10735
11263
  if (!(e instanceof TypeError))
10736
11264
  throw e;
10737
11265
  }
10738
- try {
10739
- return await Link.fromJsonLd(document, { documentLoader, contextLoader });
10740
- }
10741
- catch (e) {
10742
- if (!(e instanceof TypeError))
10743
- throw e;
10744
- }
10745
11266
  throw new TypeError("Expected an object of any type of: " +
10746
- [
10747
- "https://www.w3.org/ns/activitystreams#CollectionPage",
10748
- "https://www.w3.org/ns/activitystreams#Link",
10749
- ].join(", "));
11267
+ ["https://www.w3.org/ns/activitystreams#CollectionPage"].join(", "));
10750
11268
  }
10751
11269
  /**
10752
11270
  * Similar to
@@ -10796,9 +11314,7 @@ export class CollectionPage extends Collection {
10796
11314
  for (const v of this.#_2kWgBhQKjEauxx8C6qF3ZQamK4Le) {
10797
11315
  const element = v instanceof URL
10798
11316
  ? { "@id": v.href }
10799
- : v instanceof Link
10800
- ? await v.toJsonLd(options)
10801
- : await v.toJsonLd(options);
11317
+ : await v.toJsonLd(options);
10802
11318
  array.push(element);
10803
11319
  }
10804
11320
  if (array.length > 0) {
@@ -10808,9 +11324,7 @@ export class CollectionPage extends Collection {
10808
11324
  for (const v of this.#_3BT4kQLcXhHx7TAWaNDKh8nFn9eY) {
10809
11325
  const element = v instanceof URL
10810
11326
  ? { "@id": v.href }
10811
- : v instanceof _b
10812
- ? await v.toJsonLd(options)
10813
- : await v.toJsonLd(options);
11327
+ : await v.toJsonLd(options);
10814
11328
  array.push(element);
10815
11329
  }
10816
11330
  if (array.length > 0) {
@@ -10820,9 +11334,7 @@ export class CollectionPage extends Collection {
10820
11334
  for (const v of this.#_3b8yG8tDNzQFFEnWhCc13G8eHooA) {
10821
11335
  const element = v instanceof URL
10822
11336
  ? { "@id": v.href }
10823
- : v instanceof _b
10824
- ? await v.toJsonLd(options)
10825
- : await v.toJsonLd(options);
11337
+ : await v.toJsonLd(options);
10826
11338
  array.push(element);
10827
11339
  }
10828
11340
  if (array.length > 0) {
@@ -10889,27 +11401,7 @@ export class CollectionPage extends Collection {
10889
11401
  _2kWgBhQKjEauxx8C6qF3ZQamK4Le.push(new URL(v["@id"]));
10890
11402
  continue;
10891
11403
  }
10892
- const decoded = typeof v === "object" && "@type" in v &&
10893
- Array.isArray(v["@type"]) &&
10894
- [
10895
- "https://www.w3.org/ns/activitystreams#Link",
10896
- "https://www.w3.org/ns/activitystreams#Hashtag",
10897
- "https://www.w3.org/ns/activitystreams#Mention",
10898
- ].some((t) => v["@type"].includes(t))
10899
- ? await Link.fromJsonLd(v, options)
10900
- : typeof v === "object" && "@type" in v &&
10901
- Array.isArray(v["@type"]) &&
10902
- [
10903
- "https://www.w3.org/ns/activitystreams#Collection",
10904
- "https://www.w3.org/ns/activitystreams#CollectionPage",
10905
- "https://www.w3.org/ns/activitystreams#OrderedCollectionPage",
10906
- "https://www.w3.org/ns/activitystreams#OrderedCollection",
10907
- ].some((t) => v["@type"].includes(t))
10908
- ? await Collection.fromJsonLd(v, options)
10909
- : undefined;
10910
- if (typeof decoded === "undefined")
10911
- continue;
10912
- _2kWgBhQKjEauxx8C6qF3ZQamK4Le.push(decoded);
11404
+ _2kWgBhQKjEauxx8C6qF3ZQamK4Le.push(await Collection.fromJsonLd(v, options));
10913
11405
  }
10914
11406
  instance.#_2kWgBhQKjEauxx8C6qF3ZQamK4Le = _2kWgBhQKjEauxx8C6qF3ZQamK4Le;
10915
11407
  const _3BT4kQLcXhHx7TAWaNDKh8nFn9eY = [];
@@ -10921,25 +11413,7 @@ export class CollectionPage extends Collection {
10921
11413
  _3BT4kQLcXhHx7TAWaNDKh8nFn9eY.push(new URL(v["@id"]));
10922
11414
  continue;
10923
11415
  }
10924
- const decoded = typeof v === "object" && "@type" in v &&
10925
- Array.isArray(v["@type"]) &&
10926
- [
10927
- "https://www.w3.org/ns/activitystreams#CollectionPage",
10928
- "https://www.w3.org/ns/activitystreams#OrderedCollectionPage",
10929
- ].some((t) => v["@type"].includes(t))
10930
- ? await _b.fromJsonLd(v, options)
10931
- : typeof v === "object" && "@type" in v &&
10932
- Array.isArray(v["@type"]) &&
10933
- [
10934
- "https://www.w3.org/ns/activitystreams#Link",
10935
- "https://www.w3.org/ns/activitystreams#Hashtag",
10936
- "https://www.w3.org/ns/activitystreams#Mention",
10937
- ].some((t) => v["@type"].includes(t))
10938
- ? await Link.fromJsonLd(v, options)
10939
- : undefined;
10940
- if (typeof decoded === "undefined")
10941
- continue;
10942
- _3BT4kQLcXhHx7TAWaNDKh8nFn9eY.push(decoded);
11416
+ _3BT4kQLcXhHx7TAWaNDKh8nFn9eY.push(await _b.fromJsonLd(v, options));
10943
11417
  }
10944
11418
  instance.#_3BT4kQLcXhHx7TAWaNDKh8nFn9eY = _3BT4kQLcXhHx7TAWaNDKh8nFn9eY;
10945
11419
  const _3b8yG8tDNzQFFEnWhCc13G8eHooA = [];
@@ -10951,25 +11425,7 @@ export class CollectionPage extends Collection {
10951
11425
  _3b8yG8tDNzQFFEnWhCc13G8eHooA.push(new URL(v["@id"]));
10952
11426
  continue;
10953
11427
  }
10954
- const decoded = typeof v === "object" && "@type" in v &&
10955
- Array.isArray(v["@type"]) &&
10956
- [
10957
- "https://www.w3.org/ns/activitystreams#CollectionPage",
10958
- "https://www.w3.org/ns/activitystreams#OrderedCollectionPage",
10959
- ].some((t) => v["@type"].includes(t))
10960
- ? await _b.fromJsonLd(v, options)
10961
- : typeof v === "object" && "@type" in v &&
10962
- Array.isArray(v["@type"]) &&
10963
- [
10964
- "https://www.w3.org/ns/activitystreams#Link",
10965
- "https://www.w3.org/ns/activitystreams#Hashtag",
10966
- "https://www.w3.org/ns/activitystreams#Mention",
10967
- ].some((t) => v["@type"].includes(t))
10968
- ? await Link.fromJsonLd(v, options)
10969
- : undefined;
10970
- if (typeof decoded === "undefined")
10971
- continue;
10972
- _3b8yG8tDNzQFFEnWhCc13G8eHooA.push(decoded);
11428
+ _3b8yG8tDNzQFFEnWhCc13G8eHooA.push(await _b.fromJsonLd(v, options));
10973
11429
  }
10974
11430
  instance.#_3b8yG8tDNzQFFEnWhCc13G8eHooA = _3b8yG8tDNzQFFEnWhCc13G8eHooA;
10975
11431
  return instance;
@@ -13361,8 +13817,9 @@ export class Group extends Object {
13361
13817
  : await v.toJsonLd(options);
13362
13818
  array.push(element);
13363
13819
  }
13364
- if (array.length > 0)
13820
+ if (array.length > 0) {
13365
13821
  values["https://w3id.org/security#publicKey"] = array;
13822
+ }
13366
13823
  array = [];
13367
13824
  for (const v of this.#_4EHQFWZSz1k1d4LmPrQiMba2GbP3) {
13368
13825
  const element = v instanceof URL
@@ -13388,8 +13845,9 @@ export class Group extends Object {
13388
13845
  : await v.toJsonLd(options);
13389
13846
  array.push(element);
13390
13847
  }
13391
- if (array.length > 0)
13848
+ if (array.length > 0) {
13392
13849
  values["http://www.w3.org/ns/ldp#inbox"] = array;
13850
+ }
13393
13851
  array = [];
13394
13852
  for (const v of this.#_41QwhqJouoLg3h8dRPKat21brynC) {
13395
13853
  const element = v instanceof URL
@@ -13437,8 +13895,9 @@ export class Group extends Object {
13437
13895
  : await v.toJsonLd(options);
13438
13896
  array.push(element);
13439
13897
  }
13440
- if (array.length > 0)
13898
+ if (array.length > 0) {
13441
13899
  values["http://joinmastodon.org/ns#featured"] = array;
13900
+ }
13442
13901
  array = [];
13443
13902
  for (const v of this.#_3sG2Hdwn9qzKGu9mpYkqakAMUkH9) {
13444
13903
  const element = v instanceof URL
@@ -13478,8 +13937,9 @@ export class Group extends Object {
13478
13937
  const element = { "@value": v };
13479
13938
  array.push(element);
13480
13939
  }
13481
- if (array.length > 0)
13940
+ if (array.length > 0) {
13482
13941
  values["http://joinmastodon.org/ns#memorial"] = array;
13942
+ }
13483
13943
  array = [];
13484
13944
  for (const v of this.#_2diCorzqPGQQqftp6e4SrCEwEnyk) {
13485
13945
  const element = { "@value": v };
@@ -15432,6 +15892,7 @@ export class OrderedCollection extends Collection {
15432
15892
  static get typeId() {
15433
15893
  return new URL("https://www.w3.org/ns/activitystreams#OrderedCollection");
15434
15894
  }
15895
+ #_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = [];
15435
15896
  /**
15436
15897
  * Constructs a new instance of OrderedCollection with the given values.
15437
15898
  * @param values The values to initialize the instance with.
@@ -15439,6 +15900,17 @@ export class OrderedCollection extends Collection {
15439
15900
  */
15440
15901
  constructor(values, { documentLoader, contextLoader, } = {}) {
15441
15902
  super(values, { documentLoader, contextLoader });
15903
+ if ("items" in values && values.items != null) {
15904
+ if (Array.isArray(values.items) &&
15905
+ values.items.every((v) => v instanceof Object || v instanceof URL)) {
15906
+ // @ts-ignore: type is checked above.
15907
+ this.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = values.items;
15908
+ }
15909
+ else {
15910
+ throw new TypeError("The items must be an array of type " +
15911
+ "Object | URL" + ".");
15912
+ }
15913
+ }
15442
15914
  }
15443
15915
  /**
15444
15916
  * Clones this instance, optionally updating it with the given values.
@@ -15448,8 +15920,73 @@ export class OrderedCollection extends Collection {
15448
15920
  */
15449
15921
  clone(values = {}, options = {}) {
15450
15922
  const clone = super.clone(values, options);
15923
+ clone.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = this.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg;
15924
+ if ("items" in values && values.items != null) {
15925
+ if (Array.isArray(values.items) &&
15926
+ values.items.every((v) => v instanceof Object || v instanceof URL)) {
15927
+ // @ts-ignore: type is checked above.
15928
+ clone.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = values.items;
15929
+ }
15930
+ else {
15931
+ throw new TypeError("The items must be an array of type " +
15932
+ "Object | URL" + ".");
15933
+ }
15934
+ }
15451
15935
  return clone;
15452
15936
  }
15937
+ async #fetchItem(url, options = {}) {
15938
+ const documentLoader = options.documentLoader ?? this._documentLoader ??
15939
+ fetchDocumentLoader;
15940
+ const contextLoader = options.contextLoader ?? this._contextLoader ??
15941
+ fetchDocumentLoader;
15942
+ let fetchResult;
15943
+ try {
15944
+ fetchResult = await documentLoader(url.href);
15945
+ }
15946
+ catch (error) {
15947
+ if (options.suppressError) {
15948
+ getLogger(["fedify", "vocab"]).error("Failed to fetch {url}: {error}", { error, url: url.href });
15949
+ return null;
15950
+ }
15951
+ throw error;
15952
+ }
15953
+ const { document } = fetchResult;
15954
+ try {
15955
+ return await Object.fromJsonLd(document, { documentLoader, contextLoader });
15956
+ }
15957
+ catch (e) {
15958
+ if (!(e instanceof TypeError))
15959
+ throw e;
15960
+ }
15961
+ throw new TypeError("Expected an object of any type of: " +
15962
+ ["https://www.w3.org/ns/activitystreams#Object"].join(", "));
15963
+ }
15964
+ /**
15965
+ * Similar to
15966
+ * {@link OrderedCollection.getItems},
15967
+ * but returns their `@id`s instead of the objects themselves.
15968
+ */
15969
+ get itemIds() {
15970
+ return this.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg.map((v) => v instanceof URL ? v : v.id).filter((id) => id !== null);
15971
+ }
15972
+ /** Identifies the items contained in a collection. The items might be ordered
15973
+ * or unordered.
15974
+ */
15975
+ async *getItems(options = {}) {
15976
+ const vs = this.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg;
15977
+ for (let i = 0; i < vs.length; i++) {
15978
+ const v = vs[i];
15979
+ if (v instanceof URL) {
15980
+ const fetched = await this.#fetchItem(v, options);
15981
+ if (fetched == null)
15982
+ continue;
15983
+ vs[i] = fetched;
15984
+ yield fetched;
15985
+ continue;
15986
+ }
15987
+ yield v;
15988
+ }
15989
+ }
15453
15990
  /**
15454
15991
  * Converts this object to a JSON-LD structure.
15455
15992
  * @returns The JSON-LD representation of this object.
@@ -15466,6 +16003,18 @@ export class OrderedCollection extends Collection {
15466
16003
  expand: true,
15467
16004
  });
15468
16005
  const values = baseValues[0];
16006
+ array = [];
16007
+ for (const v of this.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg) {
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#items"] = {
16015
+ "@list": array,
16016
+ };
16017
+ }
15469
16018
  values["@type"] = [
15470
16019
  "https://www.w3.org/ns/activitystreams#OrderedCollection",
15471
16020
  ];
@@ -15516,10 +16065,35 @@ export class OrderedCollection extends Collection {
15516
16065
  if (!(instance instanceof OrderedCollection)) {
15517
16066
  throw new TypeError("Unexpected type: " + instance.constructor.name);
15518
16067
  }
16068
+ const _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = [];
16069
+ for (const v of values["https://www.w3.org/ns/activitystreams#items"] ?? []) {
16070
+ if (v == null)
16071
+ continue;
16072
+ if (typeof v === "object" && "@id" in v && !("@type" in v) &&
16073
+ globalThis.Object.keys(v).length === 1) {
16074
+ _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg.push(new URL(v["@id"]));
16075
+ continue;
16076
+ }
16077
+ _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg.push(await Object.fromJsonLd(v, options));
16078
+ }
16079
+ instance.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg;
15519
16080
  return instance;
15520
16081
  }
15521
16082
  _getCustomInspectProxy() {
15522
16083
  const proxy = super._getCustomInspectProxy();
16084
+ const _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = this.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg
16085
+ // deno-lint-ignore no-explicit-any
16086
+ .map((v) => v instanceof URL
16087
+ ? {
16088
+ [Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
16089
+ [Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
16090
+ }
16091
+ : v);
16092
+ if (_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg.length > 1 ||
16093
+ !("item" in proxy) &&
16094
+ _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg.length > 0) {
16095
+ proxy.items = _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg;
16096
+ }
15523
16097
  return proxy;
15524
16098
  }
15525
16099
  [Symbol.for("Deno.customInspect")](inspect, options) {
@@ -16886,8 +17460,9 @@ export class Organization extends Object {
16886
17460
  : await v.toJsonLd(options);
16887
17461
  array.push(element);
16888
17462
  }
16889
- if (array.length > 0)
17463
+ if (array.length > 0) {
16890
17464
  values["https://w3id.org/security#publicKey"] = array;
17465
+ }
16891
17466
  array = [];
16892
17467
  for (const v of this.#_4EHQFWZSz1k1d4LmPrQiMba2GbP3) {
16893
17468
  const element = v instanceof URL
@@ -16913,8 +17488,9 @@ export class Organization extends Object {
16913
17488
  : await v.toJsonLd(options);
16914
17489
  array.push(element);
16915
17490
  }
16916
- if (array.length > 0)
17491
+ if (array.length > 0) {
16917
17492
  values["http://www.w3.org/ns/ldp#inbox"] = array;
17493
+ }
16918
17494
  array = [];
16919
17495
  for (const v of this.#_41QwhqJouoLg3h8dRPKat21brynC) {
16920
17496
  const element = v instanceof URL
@@ -16962,8 +17538,9 @@ export class Organization extends Object {
16962
17538
  : await v.toJsonLd(options);
16963
17539
  array.push(element);
16964
17540
  }
16965
- if (array.length > 0)
17541
+ if (array.length > 0) {
16966
17542
  values["http://joinmastodon.org/ns#featured"] = array;
17543
+ }
16967
17544
  array = [];
16968
17545
  for (const v of this.#_3sG2Hdwn9qzKGu9mpYkqakAMUkH9) {
16969
17546
  const element = v instanceof URL
@@ -17003,8 +17580,9 @@ export class Organization extends Object {
17003
17580
  const element = { "@value": v };
17004
17581
  array.push(element);
17005
17582
  }
17006
- if (array.length > 0)
17583
+ if (array.length > 0) {
17007
17584
  values["http://joinmastodon.org/ns#memorial"] = array;
17585
+ }
17008
17586
  array = [];
17009
17587
  for (const v of this.#_2diCorzqPGQQqftp6e4SrCEwEnyk) {
17010
17588
  const element = { "@value": v };
@@ -18749,8 +19327,9 @@ export class Person extends Object {
18749
19327
  : await v.toJsonLd(options);
18750
19328
  array.push(element);
18751
19329
  }
18752
- if (array.length > 0)
19330
+ if (array.length > 0) {
18753
19331
  values["https://w3id.org/security#publicKey"] = array;
19332
+ }
18754
19333
  array = [];
18755
19334
  for (const v of this.#_4EHQFWZSz1k1d4LmPrQiMba2GbP3) {
18756
19335
  const element = v instanceof URL
@@ -18776,8 +19355,9 @@ export class Person extends Object {
18776
19355
  : await v.toJsonLd(options);
18777
19356
  array.push(element);
18778
19357
  }
18779
- if (array.length > 0)
19358
+ if (array.length > 0) {
18780
19359
  values["http://www.w3.org/ns/ldp#inbox"] = array;
19360
+ }
18781
19361
  array = [];
18782
19362
  for (const v of this.#_41QwhqJouoLg3h8dRPKat21brynC) {
18783
19363
  const element = v instanceof URL
@@ -18825,8 +19405,9 @@ export class Person extends Object {
18825
19405
  : await v.toJsonLd(options);
18826
19406
  array.push(element);
18827
19407
  }
18828
- if (array.length > 0)
19408
+ if (array.length > 0) {
18829
19409
  values["http://joinmastodon.org/ns#featured"] = array;
19410
+ }
18830
19411
  array = [];
18831
19412
  for (const v of this.#_3sG2Hdwn9qzKGu9mpYkqakAMUkH9) {
18832
19413
  const element = v instanceof URL
@@ -18866,8 +19447,9 @@ export class Person extends Object {
18866
19447
  const element = { "@value": v };
18867
19448
  array.push(element);
18868
19449
  }
18869
- if (array.length > 0)
19450
+ if (array.length > 0) {
18870
19451
  values["http://joinmastodon.org/ns#memorial"] = array;
19452
+ }
18871
19453
  array = [];
18872
19454
  for (const v of this.#_2diCorzqPGQQqftp6e4SrCEwEnyk) {
18873
19455
  const element = { "@value": v };
@@ -22362,8 +22944,9 @@ export class Service extends Object {
22362
22944
  : await v.toJsonLd(options);
22363
22945
  array.push(element);
22364
22946
  }
22365
- if (array.length > 0)
22947
+ if (array.length > 0) {
22366
22948
  values["https://w3id.org/security#publicKey"] = array;
22949
+ }
22367
22950
  array = [];
22368
22951
  for (const v of this.#_4EHQFWZSz1k1d4LmPrQiMba2GbP3) {
22369
22952
  const element = v instanceof URL
@@ -22389,8 +22972,9 @@ export class Service extends Object {
22389
22972
  : await v.toJsonLd(options);
22390
22973
  array.push(element);
22391
22974
  }
22392
- if (array.length > 0)
22975
+ if (array.length > 0) {
22393
22976
  values["http://www.w3.org/ns/ldp#inbox"] = array;
22977
+ }
22394
22978
  array = [];
22395
22979
  for (const v of this.#_41QwhqJouoLg3h8dRPKat21brynC) {
22396
22980
  const element = v instanceof URL
@@ -22438,8 +23022,9 @@ export class Service extends Object {
22438
23022
  : await v.toJsonLd(options);
22439
23023
  array.push(element);
22440
23024
  }
22441
- if (array.length > 0)
23025
+ if (array.length > 0) {
22442
23026
  values["http://joinmastodon.org/ns#featured"] = array;
23027
+ }
22443
23028
  array = [];
22444
23029
  for (const v of this.#_3sG2Hdwn9qzKGu9mpYkqakAMUkH9) {
22445
23030
  const element = v instanceof URL
@@ -22479,8 +23064,9 @@ export class Service extends Object {
22479
23064
  const element = { "@value": v };
22480
23065
  array.push(element);
22481
23066
  }
22482
- if (array.length > 0)
23067
+ if (array.length > 0) {
22483
23068
  values["http://joinmastodon.org/ns#memorial"] = array;
23069
+ }
22484
23070
  array = [];
22485
23071
  for (const v of this.#_2diCorzqPGQQqftp6e4SrCEwEnyk) {
22486
23072
  const element = { "@value": v };