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

Sign up to get free protection for your applications and to get access to all the features.
@@ -6047,6 +6047,10 @@ export class Activity extends Object {
6047
6047
  }
6048
6048
  #_2DjTTboo3CNHU2a2JQqUSE2dbv9D = [];
6049
6049
  #_2MH19yxjn1wnHsNfa5n4JBhJzxyc = [];
6050
+ #_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF = [];
6051
+ #_u4QGFbRFcYmPEKGbPv1hpBR9r5G = [];
6052
+ #_25zu2s3VxVujgEKqrDycjE284XQR = [];
6053
+ #_3c5t2x7DYRo2shwTxpkd4kYSS5WQ = [];
6050
6054
  /**
6051
6055
  * Constructs a new instance of Activity with the given values.
6052
6056
  * @param values The values to initialize the instance with.
@@ -6111,6 +6115,110 @@ export class Activity extends Object {
6111
6115
  "Object | URL" + ".");
6112
6116
  }
6113
6117
  }
6118
+ if ("target" in values && values.target != null) {
6119
+ if (values.target instanceof Object || values.target instanceof URL) {
6120
+ // @ts-ignore: type is checked above.
6121
+ this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF = [values.target];
6122
+ }
6123
+ else {
6124
+ throw new TypeError("The target must be of type " +
6125
+ "Object | URL" + ".");
6126
+ }
6127
+ }
6128
+ if ("targets" in values && values.targets != null) {
6129
+ if ("target" in values &&
6130
+ values.target != null) {
6131
+ throw new TypeError("Cannot initialize both target and " +
6132
+ "targets at the same time.");
6133
+ }
6134
+ if (Array.isArray(values.targets) &&
6135
+ values.targets.every((v) => v instanceof Object || v instanceof URL)) {
6136
+ // @ts-ignore: type is checked above.
6137
+ this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF = values.targets;
6138
+ }
6139
+ else {
6140
+ throw new TypeError("The targets must be an array of type " +
6141
+ "Object | URL" + ".");
6142
+ }
6143
+ }
6144
+ if ("result" in values && values.result != null) {
6145
+ if (values.result instanceof Object || values.result instanceof URL) {
6146
+ // @ts-ignore: type is checked above.
6147
+ this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G = [values.result];
6148
+ }
6149
+ else {
6150
+ throw new TypeError("The result must be of type " +
6151
+ "Object | URL" + ".");
6152
+ }
6153
+ }
6154
+ if ("results" in values && values.results != null) {
6155
+ if ("result" in values &&
6156
+ values.result != null) {
6157
+ throw new TypeError("Cannot initialize both result and " +
6158
+ "results at the same time.");
6159
+ }
6160
+ if (Array.isArray(values.results) &&
6161
+ values.results.every((v) => v instanceof Object || v instanceof URL)) {
6162
+ // @ts-ignore: type is checked above.
6163
+ this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G = values.results;
6164
+ }
6165
+ else {
6166
+ throw new TypeError("The results must be an array of type " +
6167
+ "Object | URL" + ".");
6168
+ }
6169
+ }
6170
+ if ("origin" in values && values.origin != null) {
6171
+ if (values.origin instanceof Object || values.origin instanceof URL) {
6172
+ // @ts-ignore: type is checked above.
6173
+ this.#_25zu2s3VxVujgEKqrDycjE284XQR = [values.origin];
6174
+ }
6175
+ else {
6176
+ throw new TypeError("The origin must be of type " +
6177
+ "Object | URL" + ".");
6178
+ }
6179
+ }
6180
+ if ("origins" in values && values.origins != null) {
6181
+ if ("origin" in values &&
6182
+ values.origin != null) {
6183
+ throw new TypeError("Cannot initialize both origin and " +
6184
+ "origins at the same time.");
6185
+ }
6186
+ if (Array.isArray(values.origins) &&
6187
+ values.origins.every((v) => v instanceof Object || v instanceof URL)) {
6188
+ // @ts-ignore: type is checked above.
6189
+ this.#_25zu2s3VxVujgEKqrDycjE284XQR = values.origins;
6190
+ }
6191
+ else {
6192
+ throw new TypeError("The origins must be an array of type " +
6193
+ "Object | URL" + ".");
6194
+ }
6195
+ }
6196
+ if ("instrument" in values && values.instrument != null) {
6197
+ if (values.instrument instanceof Object || values.instrument instanceof URL) {
6198
+ // @ts-ignore: type is checked above.
6199
+ this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ = [values.instrument];
6200
+ }
6201
+ else {
6202
+ throw new TypeError("The instrument must be of type " +
6203
+ "Object | URL" + ".");
6204
+ }
6205
+ }
6206
+ if ("instruments" in values && values.instruments != null) {
6207
+ if ("instrument" in values &&
6208
+ values.instrument != null) {
6209
+ throw new TypeError("Cannot initialize both instrument and " +
6210
+ "instruments at the same time.");
6211
+ }
6212
+ if (Array.isArray(values.instruments) &&
6213
+ values.instruments.every((v) => v instanceof Object || v instanceof URL)) {
6214
+ // @ts-ignore: type is checked above.
6215
+ this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ = values.instruments;
6216
+ }
6217
+ else {
6218
+ throw new TypeError("The instruments must be an array of type " +
6219
+ "Object | URL" + ".");
6220
+ }
6221
+ }
6114
6222
  }
6115
6223
  /**
6116
6224
  * Clones this instance, optionally updating it with the given values.
@@ -6179,6 +6287,114 @@ export class Activity extends Object {
6179
6287
  "Object | URL" + ".");
6180
6288
  }
6181
6289
  }
6290
+ clone.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF = this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF;
6291
+ if ("target" in values && values.target != null) {
6292
+ if (values.target instanceof Object || values.target instanceof URL) {
6293
+ // @ts-ignore: type is checked above.
6294
+ clone.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF = [values.target];
6295
+ }
6296
+ else {
6297
+ throw new TypeError("The target must be of type " +
6298
+ "Object | URL" + ".");
6299
+ }
6300
+ }
6301
+ if ("targets" in values && values.targets != null) {
6302
+ if ("target" in values &&
6303
+ values.target != null) {
6304
+ throw new TypeError("Cannot update both target and " +
6305
+ "targets at the same time.");
6306
+ }
6307
+ if (Array.isArray(values.targets) &&
6308
+ values.targets.every((v) => v instanceof Object || v instanceof URL)) {
6309
+ // @ts-ignore: type is checked above.
6310
+ clone.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF = values.targets;
6311
+ }
6312
+ else {
6313
+ throw new TypeError("The targets must be an array of type " +
6314
+ "Object | URL" + ".");
6315
+ }
6316
+ }
6317
+ clone.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G = this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G;
6318
+ if ("result" in values && values.result != null) {
6319
+ if (values.result instanceof Object || values.result instanceof URL) {
6320
+ // @ts-ignore: type is checked above.
6321
+ clone.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G = [values.result];
6322
+ }
6323
+ else {
6324
+ throw new TypeError("The result must be of type " +
6325
+ "Object | URL" + ".");
6326
+ }
6327
+ }
6328
+ if ("results" in values && values.results != null) {
6329
+ if ("result" in values &&
6330
+ values.result != null) {
6331
+ throw new TypeError("Cannot update both result and " +
6332
+ "results at the same time.");
6333
+ }
6334
+ if (Array.isArray(values.results) &&
6335
+ values.results.every((v) => v instanceof Object || v instanceof URL)) {
6336
+ // @ts-ignore: type is checked above.
6337
+ clone.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G = values.results;
6338
+ }
6339
+ else {
6340
+ throw new TypeError("The results must be an array of type " +
6341
+ "Object | URL" + ".");
6342
+ }
6343
+ }
6344
+ clone.#_25zu2s3VxVujgEKqrDycjE284XQR = this.#_25zu2s3VxVujgEKqrDycjE284XQR;
6345
+ if ("origin" in values && values.origin != null) {
6346
+ if (values.origin instanceof Object || values.origin instanceof URL) {
6347
+ // @ts-ignore: type is checked above.
6348
+ clone.#_25zu2s3VxVujgEKqrDycjE284XQR = [values.origin];
6349
+ }
6350
+ else {
6351
+ throw new TypeError("The origin must be of type " +
6352
+ "Object | URL" + ".");
6353
+ }
6354
+ }
6355
+ if ("origins" in values && values.origins != null) {
6356
+ if ("origin" in values &&
6357
+ values.origin != null) {
6358
+ throw new TypeError("Cannot update both origin and " +
6359
+ "origins at the same time.");
6360
+ }
6361
+ if (Array.isArray(values.origins) &&
6362
+ values.origins.every((v) => v instanceof Object || v instanceof URL)) {
6363
+ // @ts-ignore: type is checked above.
6364
+ clone.#_25zu2s3VxVujgEKqrDycjE284XQR = values.origins;
6365
+ }
6366
+ else {
6367
+ throw new TypeError("The origins must be an array of type " +
6368
+ "Object | URL" + ".");
6369
+ }
6370
+ }
6371
+ clone.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ = this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ;
6372
+ if ("instrument" in values && values.instrument != null) {
6373
+ if (values.instrument instanceof Object || values.instrument instanceof URL) {
6374
+ // @ts-ignore: type is checked above.
6375
+ clone.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ = [values.instrument];
6376
+ }
6377
+ else {
6378
+ throw new TypeError("The instrument must be of type " +
6379
+ "Object | URL" + ".");
6380
+ }
6381
+ }
6382
+ if ("instruments" in values && values.instruments != null) {
6383
+ if ("instrument" in values &&
6384
+ values.instrument != null) {
6385
+ throw new TypeError("Cannot update both instrument and " +
6386
+ "instruments at the same time.");
6387
+ }
6388
+ if (Array.isArray(values.instruments) &&
6389
+ values.instruments.every((v) => v instanceof Object || v instanceof URL)) {
6390
+ // @ts-ignore: type is checked above.
6391
+ clone.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ = values.instruments;
6392
+ }
6393
+ else {
6394
+ throw new TypeError("The instruments must be an array of type " +
6395
+ "Object | URL" + ".");
6396
+ }
6397
+ }
6182
6398
  return clone;
6183
6399
  }
6184
6400
  async #fetchActor(url, options = {}) {
@@ -6383,6 +6599,348 @@ export class Activity extends Object {
6383
6599
  yield v;
6384
6600
  }
6385
6601
  }
6602
+ async #fetchTarget(url, options = {}) {
6603
+ const documentLoader = options.documentLoader ?? this._documentLoader ??
6604
+ fetchDocumentLoader;
6605
+ const contextLoader = options.contextLoader ?? this._contextLoader ??
6606
+ fetchDocumentLoader;
6607
+ let fetchResult;
6608
+ try {
6609
+ fetchResult = await documentLoader(url.href);
6610
+ }
6611
+ catch (error) {
6612
+ if (options.suppressError) {
6613
+ getLogger(["fedify", "vocab"]).error("Failed to fetch {url}: {error}", { error, url: url.href });
6614
+ return null;
6615
+ }
6616
+ throw error;
6617
+ }
6618
+ const { document } = fetchResult;
6619
+ try {
6620
+ return await Object.fromJsonLd(document, { documentLoader, contextLoader });
6621
+ }
6622
+ catch (e) {
6623
+ if (!(e instanceof TypeError))
6624
+ throw e;
6625
+ }
6626
+ throw new TypeError("Expected an object of any type of: " +
6627
+ ["https://www.w3.org/ns/activitystreams#Object"].join(", "));
6628
+ }
6629
+ /**
6630
+ * Similar to
6631
+ * {@link Activity.getTarget},
6632
+ * but returns its `@id` URL instead of the object itself.
6633
+ */
6634
+ get targetId() {
6635
+ if (this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF.length < 1)
6636
+ return null;
6637
+ const v = this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF[0];
6638
+ if (v instanceof URL)
6639
+ return v;
6640
+ return v.id;
6641
+ }
6642
+ /** Describes the indirect object, or target, of the activity. The precise
6643
+ * meaning of the target is largely dependent on the type of action being
6644
+ * described but will often be the object of the English preposition "to".
6645
+ * For instance, in the activity "John added a movie to his wishlist",
6646
+ * the target of the activity is John's wishlist. An activity can have more
6647
+ * than one target.
6648
+ */
6649
+ async getTarget(options = {}) {
6650
+ if (this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF.length < 1)
6651
+ return null;
6652
+ const v = this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF[0];
6653
+ if (v instanceof URL) {
6654
+ const fetched = await this.#fetchTarget(v, options);
6655
+ if (fetched == null)
6656
+ return null;
6657
+ this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF[0] = fetched;
6658
+ return fetched;
6659
+ }
6660
+ return v;
6661
+ }
6662
+ /**
6663
+ * Similar to
6664
+ * {@link Activity.getTargets},
6665
+ * but returns their `@id`s instead of the objects themselves.
6666
+ */
6667
+ get targetIds() {
6668
+ return this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF.map((v) => v instanceof URL ? v : v.id).filter((id) => id !== null);
6669
+ }
6670
+ /** Describes the indirect object, or target, of the activity. The precise
6671
+ * meaning of the target is largely dependent on the type of action being
6672
+ * described but will often be the object of the English preposition "to".
6673
+ * For instance, in the activity "John added a movie to his wishlist",
6674
+ * the target of the activity is John's wishlist. An activity can have more
6675
+ * than one target.
6676
+ */
6677
+ async *getTargets(options = {}) {
6678
+ const vs = this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF;
6679
+ for (let i = 0; i < vs.length; i++) {
6680
+ const v = vs[i];
6681
+ if (v instanceof URL) {
6682
+ const fetched = await this.#fetchTarget(v, options);
6683
+ if (fetched == null)
6684
+ continue;
6685
+ vs[i] = fetched;
6686
+ yield fetched;
6687
+ continue;
6688
+ }
6689
+ yield v;
6690
+ }
6691
+ }
6692
+ async #fetchResult(url, options = {}) {
6693
+ const documentLoader = options.documentLoader ?? this._documentLoader ??
6694
+ fetchDocumentLoader;
6695
+ const contextLoader = options.contextLoader ?? this._contextLoader ??
6696
+ fetchDocumentLoader;
6697
+ let fetchResult;
6698
+ try {
6699
+ fetchResult = await documentLoader(url.href);
6700
+ }
6701
+ catch (error) {
6702
+ if (options.suppressError) {
6703
+ getLogger(["fedify", "vocab"]).error("Failed to fetch {url}: {error}", { error, url: url.href });
6704
+ return null;
6705
+ }
6706
+ throw error;
6707
+ }
6708
+ const { document } = fetchResult;
6709
+ try {
6710
+ return await Object.fromJsonLd(document, { documentLoader, contextLoader });
6711
+ }
6712
+ catch (e) {
6713
+ if (!(e instanceof TypeError))
6714
+ throw e;
6715
+ }
6716
+ throw new TypeError("Expected an object of any type of: " +
6717
+ ["https://www.w3.org/ns/activitystreams#Object"].join(", "));
6718
+ }
6719
+ /**
6720
+ * Similar to
6721
+ * {@link Activity.getResult},
6722
+ * but returns its `@id` URL instead of the object itself.
6723
+ */
6724
+ get resultId() {
6725
+ if (this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G.length < 1)
6726
+ return null;
6727
+ const v = this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G[0];
6728
+ if (v instanceof URL)
6729
+ return v;
6730
+ return v.id;
6731
+ }
6732
+ /** Describes the result of the activity. For instance, if a particular action
6733
+ * results in the creation of a new resource, the result property can be used
6734
+ * to describe that new resource.
6735
+ */
6736
+ async getResult(options = {}) {
6737
+ if (this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G.length < 1)
6738
+ return null;
6739
+ const v = this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G[0];
6740
+ if (v instanceof URL) {
6741
+ const fetched = await this.#fetchResult(v, options);
6742
+ if (fetched == null)
6743
+ return null;
6744
+ this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G[0] = fetched;
6745
+ return fetched;
6746
+ }
6747
+ return v;
6748
+ }
6749
+ /**
6750
+ * Similar to
6751
+ * {@link Activity.getResults},
6752
+ * but returns their `@id`s instead of the objects themselves.
6753
+ */
6754
+ get resultIds() {
6755
+ return this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G.map((v) => v instanceof URL ? v : v.id).filter((id) => id !== null);
6756
+ }
6757
+ /** Describes the result of the activity. For instance, if a particular action
6758
+ * results in the creation of a new resource, the result property can be used
6759
+ * to describe that new resource.
6760
+ */
6761
+ async *getResults(options = {}) {
6762
+ const vs = this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G;
6763
+ for (let i = 0; i < vs.length; i++) {
6764
+ const v = vs[i];
6765
+ if (v instanceof URL) {
6766
+ const fetched = await this.#fetchResult(v, options);
6767
+ if (fetched == null)
6768
+ continue;
6769
+ vs[i] = fetched;
6770
+ yield fetched;
6771
+ continue;
6772
+ }
6773
+ yield v;
6774
+ }
6775
+ }
6776
+ async #fetchOrigin(url, options = {}) {
6777
+ const documentLoader = options.documentLoader ?? this._documentLoader ??
6778
+ fetchDocumentLoader;
6779
+ const contextLoader = options.contextLoader ?? this._contextLoader ??
6780
+ fetchDocumentLoader;
6781
+ let fetchResult;
6782
+ try {
6783
+ fetchResult = await documentLoader(url.href);
6784
+ }
6785
+ catch (error) {
6786
+ if (options.suppressError) {
6787
+ getLogger(["fedify", "vocab"]).error("Failed to fetch {url}: {error}", { error, url: url.href });
6788
+ return null;
6789
+ }
6790
+ throw error;
6791
+ }
6792
+ const { document } = fetchResult;
6793
+ try {
6794
+ return await Object.fromJsonLd(document, { documentLoader, contextLoader });
6795
+ }
6796
+ catch (e) {
6797
+ if (!(e instanceof TypeError))
6798
+ throw e;
6799
+ }
6800
+ throw new TypeError("Expected an object of any type of: " +
6801
+ ["https://www.w3.org/ns/activitystreams#Object"].join(", "));
6802
+ }
6803
+ /**
6804
+ * Similar to
6805
+ * {@link Activity.getOrigin},
6806
+ * but returns its `@id` URL instead of the object itself.
6807
+ */
6808
+ get originId() {
6809
+ if (this.#_25zu2s3VxVujgEKqrDycjE284XQR.length < 1)
6810
+ return null;
6811
+ const v = this.#_25zu2s3VxVujgEKqrDycjE284XQR[0];
6812
+ if (v instanceof URL)
6813
+ return v;
6814
+ return v.id;
6815
+ }
6816
+ /** Describes an indirect object of the activity from which the activity is
6817
+ * directed. The precise meaning of the origin is the object of the English
6818
+ * preposition "from". For instance, in the activity "John moved an item to
6819
+ * List B from List A", the origin of the activity is "List A".
6820
+ */
6821
+ async getOrigin(options = {}) {
6822
+ if (this.#_25zu2s3VxVujgEKqrDycjE284XQR.length < 1)
6823
+ return null;
6824
+ const v = this.#_25zu2s3VxVujgEKqrDycjE284XQR[0];
6825
+ if (v instanceof URL) {
6826
+ const fetched = await this.#fetchOrigin(v, options);
6827
+ if (fetched == null)
6828
+ return null;
6829
+ this.#_25zu2s3VxVujgEKqrDycjE284XQR[0] = fetched;
6830
+ return fetched;
6831
+ }
6832
+ return v;
6833
+ }
6834
+ /**
6835
+ * Similar to
6836
+ * {@link Activity.getOrigins},
6837
+ * but returns their `@id`s instead of the objects themselves.
6838
+ */
6839
+ get originIds() {
6840
+ return this.#_25zu2s3VxVujgEKqrDycjE284XQR.map((v) => v instanceof URL ? v : v.id).filter((id) => id !== null);
6841
+ }
6842
+ /** Describes an indirect object of the activity from which the activity is
6843
+ * directed. The precise meaning of the origin is the object of the English
6844
+ * preposition "from". For instance, in the activity "John moved an item to
6845
+ * List B from List A", the origin of the activity is "List A".
6846
+ */
6847
+ async *getOrigins(options = {}) {
6848
+ const vs = this.#_25zu2s3VxVujgEKqrDycjE284XQR;
6849
+ for (let i = 0; i < vs.length; i++) {
6850
+ const v = vs[i];
6851
+ if (v instanceof URL) {
6852
+ const fetched = await this.#fetchOrigin(v, options);
6853
+ if (fetched == null)
6854
+ continue;
6855
+ vs[i] = fetched;
6856
+ yield fetched;
6857
+ continue;
6858
+ }
6859
+ yield v;
6860
+ }
6861
+ }
6862
+ async #fetchInstrument(url, options = {}) {
6863
+ const documentLoader = options.documentLoader ?? this._documentLoader ??
6864
+ fetchDocumentLoader;
6865
+ const contextLoader = options.contextLoader ?? this._contextLoader ??
6866
+ fetchDocumentLoader;
6867
+ let fetchResult;
6868
+ try {
6869
+ fetchResult = await documentLoader(url.href);
6870
+ }
6871
+ catch (error) {
6872
+ if (options.suppressError) {
6873
+ getLogger(["fedify", "vocab"]).error("Failed to fetch {url}: {error}", { error, url: url.href });
6874
+ return null;
6875
+ }
6876
+ throw error;
6877
+ }
6878
+ const { document } = fetchResult;
6879
+ try {
6880
+ return await Object.fromJsonLd(document, { documentLoader, contextLoader });
6881
+ }
6882
+ catch (e) {
6883
+ if (!(e instanceof TypeError))
6884
+ throw e;
6885
+ }
6886
+ throw new TypeError("Expected an object of any type of: " +
6887
+ ["https://www.w3.org/ns/activitystreams#Object"].join(", "));
6888
+ }
6889
+ /**
6890
+ * Similar to
6891
+ * {@link Activity.getInstrument},
6892
+ * but returns its `@id` URL instead of the object itself.
6893
+ */
6894
+ get instrumentId() {
6895
+ if (this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ.length < 1)
6896
+ return null;
6897
+ const v = this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ[0];
6898
+ if (v instanceof URL)
6899
+ return v;
6900
+ return v.id;
6901
+ }
6902
+ /** Identifies one or more objects used (or to be used) in the completion of
6903
+ * an {@link Activity}.
6904
+ */
6905
+ async getInstrument(options = {}) {
6906
+ if (this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ.length < 1)
6907
+ return null;
6908
+ const v = this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ[0];
6909
+ if (v instanceof URL) {
6910
+ const fetched = await this.#fetchInstrument(v, options);
6911
+ if (fetched == null)
6912
+ return null;
6913
+ this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ[0] = fetched;
6914
+ return fetched;
6915
+ }
6916
+ return v;
6917
+ }
6918
+ /**
6919
+ * Similar to
6920
+ * {@link Activity.getInstruments},
6921
+ * but returns their `@id`s instead of the objects themselves.
6922
+ */
6923
+ get instrumentIds() {
6924
+ return this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ.map((v) => v instanceof URL ? v : v.id).filter((id) => id !== null);
6925
+ }
6926
+ /** Identifies one or more objects used (or to be used) in the completion of
6927
+ * an {@link Activity}.
6928
+ */
6929
+ async *getInstruments(options = {}) {
6930
+ const vs = this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ;
6931
+ for (let i = 0; i < vs.length; i++) {
6932
+ const v = vs[i];
6933
+ if (v instanceof URL) {
6934
+ const fetched = await this.#fetchInstrument(v, options);
6935
+ if (fetched == null)
6936
+ continue;
6937
+ vs[i] = fetched;
6938
+ yield fetched;
6939
+ continue;
6940
+ }
6941
+ yield v;
6942
+ }
6943
+ }
6386
6944
  /**
6387
6945
  * Converts this object to a JSON-LD structure.
6388
6946
  * @returns The JSON-LD representation of this object.
@@ -6427,6 +6985,46 @@ export class Activity extends Object {
6427
6985
  if (array.length > 0) {
6428
6986
  values["https://www.w3.org/ns/activitystreams#object"] = array;
6429
6987
  }
6988
+ array = [];
6989
+ for (const v of this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF) {
6990
+ const element = v instanceof URL
6991
+ ? { "@id": v.href }
6992
+ : await v.toJsonLd(options);
6993
+ array.push(element);
6994
+ }
6995
+ if (array.length > 0) {
6996
+ values["https://www.w3.org/ns/activitystreams#target"] = array;
6997
+ }
6998
+ array = [];
6999
+ for (const v of this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G) {
7000
+ const element = v instanceof URL
7001
+ ? { "@id": v.href }
7002
+ : await v.toJsonLd(options);
7003
+ array.push(element);
7004
+ }
7005
+ if (array.length > 0) {
7006
+ values["https://www.w3.org/ns/activitystreams#result"] = array;
7007
+ }
7008
+ array = [];
7009
+ for (const v of this.#_25zu2s3VxVujgEKqrDycjE284XQR) {
7010
+ const element = v instanceof URL
7011
+ ? { "@id": v.href }
7012
+ : await v.toJsonLd(options);
7013
+ array.push(element);
7014
+ }
7015
+ if (array.length > 0) {
7016
+ values["https://www.w3.org/ns/activitystreams#origin"] = array;
7017
+ }
7018
+ array = [];
7019
+ for (const v of this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ) {
7020
+ const element = v instanceof URL
7021
+ ? { "@id": v.href }
7022
+ : await v.toJsonLd(options);
7023
+ array.push(element);
7024
+ }
7025
+ if (array.length > 0) {
7026
+ values["https://www.w3.org/ns/activitystreams#instrument"] = array;
7027
+ }
6430
7028
  values["@type"] = ["https://www.w3.org/ns/activitystreams#Activity"];
6431
7029
  if (this.id)
6432
7030
  values["@id"] = this.id.href;
@@ -6603,6 +7201,55 @@ export class Activity extends Object {
6603
7201
  _2MH19yxjn1wnHsNfa5n4JBhJzxyc.push(await Object.fromJsonLd(v, options));
6604
7202
  }
6605
7203
  instance.#_2MH19yxjn1wnHsNfa5n4JBhJzxyc = _2MH19yxjn1wnHsNfa5n4JBhJzxyc;
7204
+ const _3JQCmF2Ww56Ag9EWRYoSZRDNCYtF = [];
7205
+ for (const v of values["https://www.w3.org/ns/activitystreams#target"] ?? []) {
7206
+ if (v == null)
7207
+ continue;
7208
+ if (typeof v === "object" && "@id" in v && !("@type" in v) &&
7209
+ globalThis.Object.keys(v).length === 1) {
7210
+ _3JQCmF2Ww56Ag9EWRYoSZRDNCYtF.push(new URL(v["@id"]));
7211
+ continue;
7212
+ }
7213
+ _3JQCmF2Ww56Ag9EWRYoSZRDNCYtF.push(await Object.fromJsonLd(v, options));
7214
+ }
7215
+ instance.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF = _3JQCmF2Ww56Ag9EWRYoSZRDNCYtF;
7216
+ const _u4QGFbRFcYmPEKGbPv1hpBR9r5G = [];
7217
+ for (const v of values["https://www.w3.org/ns/activitystreams#result"] ?? []) {
7218
+ if (v == null)
7219
+ continue;
7220
+ if (typeof v === "object" && "@id" in v && !("@type" in v) &&
7221
+ globalThis.Object.keys(v).length === 1) {
7222
+ _u4QGFbRFcYmPEKGbPv1hpBR9r5G.push(new URL(v["@id"]));
7223
+ continue;
7224
+ }
7225
+ _u4QGFbRFcYmPEKGbPv1hpBR9r5G.push(await Object.fromJsonLd(v, options));
7226
+ }
7227
+ instance.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G = _u4QGFbRFcYmPEKGbPv1hpBR9r5G;
7228
+ const _25zu2s3VxVujgEKqrDycjE284XQR = [];
7229
+ for (const v of values["https://www.w3.org/ns/activitystreams#origin"] ?? []) {
7230
+ if (v == null)
7231
+ continue;
7232
+ if (typeof v === "object" && "@id" in v && !("@type" in v) &&
7233
+ globalThis.Object.keys(v).length === 1) {
7234
+ _25zu2s3VxVujgEKqrDycjE284XQR.push(new URL(v["@id"]));
7235
+ continue;
7236
+ }
7237
+ _25zu2s3VxVujgEKqrDycjE284XQR.push(await Object.fromJsonLd(v, options));
7238
+ }
7239
+ instance.#_25zu2s3VxVujgEKqrDycjE284XQR = _25zu2s3VxVujgEKqrDycjE284XQR;
7240
+ const _3c5t2x7DYRo2shwTxpkd4kYSS5WQ = [];
7241
+ for (const v of values["https://www.w3.org/ns/activitystreams#instrument"] ??
7242
+ []) {
7243
+ if (v == null)
7244
+ continue;
7245
+ if (typeof v === "object" && "@id" in v && !("@type" in v) &&
7246
+ globalThis.Object.keys(v).length === 1) {
7247
+ _3c5t2x7DYRo2shwTxpkd4kYSS5WQ.push(new URL(v["@id"]));
7248
+ continue;
7249
+ }
7250
+ _3c5t2x7DYRo2shwTxpkd4kYSS5WQ.push(await Object.fromJsonLd(v, options));
7251
+ }
7252
+ instance.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ = _3c5t2x7DYRo2shwTxpkd4kYSS5WQ;
6606
7253
  return instance;
6607
7254
  }
6608
7255
  _getCustomInspectProxy() {
@@ -6639,6 +7286,70 @@ export class Activity extends Object {
6639
7286
  _2MH19yxjn1wnHsNfa5n4JBhJzxyc.length > 0) {
6640
7287
  proxy.objects = _2MH19yxjn1wnHsNfa5n4JBhJzxyc;
6641
7288
  }
7289
+ const _3JQCmF2Ww56Ag9EWRYoSZRDNCYtF = this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF
7290
+ // deno-lint-ignore no-explicit-any
7291
+ .map((v) => v instanceof URL
7292
+ ? {
7293
+ [Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
7294
+ [Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
7295
+ }
7296
+ : v);
7297
+ if (_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF.length == 1) {
7298
+ proxy.target = _3JQCmF2Ww56Ag9EWRYoSZRDNCYtF[0];
7299
+ }
7300
+ if (_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF.length > 1 ||
7301
+ !("target" in proxy) &&
7302
+ _3JQCmF2Ww56Ag9EWRYoSZRDNCYtF.length > 0) {
7303
+ proxy.targets = _3JQCmF2Ww56Ag9EWRYoSZRDNCYtF;
7304
+ }
7305
+ const _u4QGFbRFcYmPEKGbPv1hpBR9r5G = this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G
7306
+ // deno-lint-ignore no-explicit-any
7307
+ .map((v) => v instanceof URL
7308
+ ? {
7309
+ [Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
7310
+ [Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
7311
+ }
7312
+ : v);
7313
+ if (_u4QGFbRFcYmPEKGbPv1hpBR9r5G.length == 1) {
7314
+ proxy.result = _u4QGFbRFcYmPEKGbPv1hpBR9r5G[0];
7315
+ }
7316
+ if (_u4QGFbRFcYmPEKGbPv1hpBR9r5G.length > 1 ||
7317
+ !("result" in proxy) &&
7318
+ _u4QGFbRFcYmPEKGbPv1hpBR9r5G.length > 0) {
7319
+ proxy.results = _u4QGFbRFcYmPEKGbPv1hpBR9r5G;
7320
+ }
7321
+ const _25zu2s3VxVujgEKqrDycjE284XQR = this.#_25zu2s3VxVujgEKqrDycjE284XQR
7322
+ // deno-lint-ignore no-explicit-any
7323
+ .map((v) => v instanceof URL
7324
+ ? {
7325
+ [Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
7326
+ [Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
7327
+ }
7328
+ : v);
7329
+ if (_25zu2s3VxVujgEKqrDycjE284XQR.length == 1) {
7330
+ proxy.origin = _25zu2s3VxVujgEKqrDycjE284XQR[0];
7331
+ }
7332
+ if (_25zu2s3VxVujgEKqrDycjE284XQR.length > 1 ||
7333
+ !("origin" in proxy) &&
7334
+ _25zu2s3VxVujgEKqrDycjE284XQR.length > 0) {
7335
+ proxy.origins = _25zu2s3VxVujgEKqrDycjE284XQR;
7336
+ }
7337
+ const _3c5t2x7DYRo2shwTxpkd4kYSS5WQ = this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ
7338
+ // deno-lint-ignore no-explicit-any
7339
+ .map((v) => v instanceof URL
7340
+ ? {
7341
+ [Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
7342
+ [Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
7343
+ }
7344
+ : v);
7345
+ if (_3c5t2x7DYRo2shwTxpkd4kYSS5WQ.length == 1) {
7346
+ proxy.instrument = _3c5t2x7DYRo2shwTxpkd4kYSS5WQ[0];
7347
+ }
7348
+ if (_3c5t2x7DYRo2shwTxpkd4kYSS5WQ.length > 1 ||
7349
+ !("instrument" in proxy) &&
7350
+ _3c5t2x7DYRo2shwTxpkd4kYSS5WQ.length > 0) {
7351
+ proxy.instruments = _3c5t2x7DYRo2shwTxpkd4kYSS5WQ;
7352
+ }
6642
7353
  return proxy;
6643
7354
  }
6644
7355
  [Symbol.for("Deno.customInspect")](inspect, options) {
@@ -9720,46 +10431,44 @@ export class Collection extends Object {
9720
10431
  }
9721
10432
  if ("current" in values && values.current != null) {
9722
10433
  if (values.current instanceof CollectionPage ||
9723
- values.current instanceof Link || values.current instanceof URL) {
10434
+ values.current instanceof URL) {
9724
10435
  // @ts-ignore: type is checked above.
9725
10436
  this.#_3UyUdxnyn6cDn53QKrh4MBiearma = [values.current];
9726
10437
  }
9727
10438
  else {
9728
10439
  throw new TypeError("The current must be of type " +
9729
- "CollectionPage | Link | URL" + ".");
10440
+ "CollectionPage | URL" + ".");
9730
10441
  }
9731
10442
  }
9732
10443
  if ("first" in values && values.first != null) {
9733
- if (values.first instanceof CollectionPage ||
9734
- values.first instanceof Link || values.first instanceof URL) {
10444
+ if (values.first instanceof CollectionPage || values.first instanceof URL) {
9735
10445
  // @ts-ignore: type is checked above.
9736
10446
  this.#_J52RqweMe6hhv7RnLJMC8BExTE5 = [values.first];
9737
10447
  }
9738
10448
  else {
9739
10449
  throw new TypeError("The first must be of type " +
9740
- "CollectionPage | Link | URL" + ".");
10450
+ "CollectionPage | URL" + ".");
9741
10451
  }
9742
10452
  }
9743
10453
  if ("last" in values && values.last != null) {
9744
- if (values.last instanceof CollectionPage || values.last instanceof Link ||
9745
- values.last instanceof URL) {
10454
+ if (values.last instanceof CollectionPage || values.last instanceof URL) {
9746
10455
  // @ts-ignore: type is checked above.
9747
10456
  this.#_gyJJnyEFnuNVi1HFZKfAn3Hfn26 = [values.last];
9748
10457
  }
9749
10458
  else {
9750
10459
  throw new TypeError("The last must be of type " +
9751
- "CollectionPage | Link | URL" + ".");
10460
+ "CollectionPage | URL" + ".");
9752
10461
  }
9753
10462
  }
9754
10463
  if ("items" in values && values.items != null) {
9755
10464
  if (Array.isArray(values.items) &&
9756
- values.items.every((v) => v instanceof Object || v instanceof Link || v instanceof URL)) {
10465
+ values.items.every((v) => v instanceof Object || v instanceof URL)) {
9757
10466
  // @ts-ignore: type is checked above.
9758
10467
  this.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = values.items;
9759
10468
  }
9760
10469
  else {
9761
10470
  throw new TypeError("The items must be an array of type " +
9762
- "Object | Link | URL" + ".");
10471
+ "Object | URL" + ".");
9763
10472
  }
9764
10473
  }
9765
10474
  }
@@ -9786,49 +10495,47 @@ export class Collection extends Object {
9786
10495
  clone.#_3UyUdxnyn6cDn53QKrh4MBiearma = this.#_3UyUdxnyn6cDn53QKrh4MBiearma;
9787
10496
  if ("current" in values && values.current != null) {
9788
10497
  if (values.current instanceof CollectionPage ||
9789
- values.current instanceof Link || values.current instanceof URL) {
10498
+ values.current instanceof URL) {
9790
10499
  // @ts-ignore: type is checked above.
9791
10500
  clone.#_3UyUdxnyn6cDn53QKrh4MBiearma = [values.current];
9792
10501
  }
9793
10502
  else {
9794
10503
  throw new TypeError("The current must be of type " +
9795
- "CollectionPage | Link | URL" + ".");
10504
+ "CollectionPage | URL" + ".");
9796
10505
  }
9797
10506
  }
9798
10507
  clone.#_J52RqweMe6hhv7RnLJMC8BExTE5 = this.#_J52RqweMe6hhv7RnLJMC8BExTE5;
9799
10508
  if ("first" in values && values.first != null) {
9800
- if (values.first instanceof CollectionPage ||
9801
- values.first instanceof Link || values.first instanceof URL) {
10509
+ if (values.first instanceof CollectionPage || values.first instanceof URL) {
9802
10510
  // @ts-ignore: type is checked above.
9803
10511
  clone.#_J52RqweMe6hhv7RnLJMC8BExTE5 = [values.first];
9804
10512
  }
9805
10513
  else {
9806
10514
  throw new TypeError("The first must be of type " +
9807
- "CollectionPage | Link | URL" + ".");
10515
+ "CollectionPage | URL" + ".");
9808
10516
  }
9809
10517
  }
9810
10518
  clone.#_gyJJnyEFnuNVi1HFZKfAn3Hfn26 = this.#_gyJJnyEFnuNVi1HFZKfAn3Hfn26;
9811
10519
  if ("last" in values && values.last != null) {
9812
- if (values.last instanceof CollectionPage || values.last instanceof Link ||
9813
- values.last instanceof URL) {
10520
+ if (values.last instanceof CollectionPage || values.last instanceof URL) {
9814
10521
  // @ts-ignore: type is checked above.
9815
10522
  clone.#_gyJJnyEFnuNVi1HFZKfAn3Hfn26 = [values.last];
9816
10523
  }
9817
10524
  else {
9818
10525
  throw new TypeError("The last must be of type " +
9819
- "CollectionPage | Link | URL" + ".");
10526
+ "CollectionPage | URL" + ".");
9820
10527
  }
9821
10528
  }
9822
10529
  clone.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = this.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg;
9823
10530
  if ("items" in values && values.items != null) {
9824
10531
  if (Array.isArray(values.items) &&
9825
- values.items.every((v) => v instanceof Object || v instanceof Link || v instanceof URL)) {
10532
+ values.items.every((v) => v instanceof Object || v instanceof URL)) {
9826
10533
  // @ts-ignore: type is checked above.
9827
10534
  clone.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = values.items;
9828
10535
  }
9829
10536
  else {
9830
10537
  throw new TypeError("The items must be an array of type " +
9831
- "Object | Link | URL" + ".");
10538
+ "Object | URL" + ".");
9832
10539
  }
9833
10540
  }
9834
10541
  return clone;
@@ -9856,28 +10563,18 @@ export class Collection extends Object {
9856
10563
  getLogger(["fedify", "vocab"]).error("Failed to fetch {url}: {error}", { error, url: url.href });
9857
10564
  return null;
9858
10565
  }
9859
- throw error;
9860
- }
9861
- const { document } = fetchResult;
9862
- try {
9863
- return await CollectionPage.fromJsonLd(document, { documentLoader, contextLoader });
9864
- }
9865
- catch (e) {
9866
- if (!(e instanceof TypeError))
9867
- throw e;
10566
+ throw error;
9868
10567
  }
10568
+ const { document } = fetchResult;
9869
10569
  try {
9870
- return await Link.fromJsonLd(document, { documentLoader, contextLoader });
10570
+ return await CollectionPage.fromJsonLd(document, { documentLoader, contextLoader });
9871
10571
  }
9872
10572
  catch (e) {
9873
10573
  if (!(e instanceof TypeError))
9874
10574
  throw e;
9875
10575
  }
9876
10576
  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(", "));
10577
+ ["https://www.w3.org/ns/activitystreams#CollectionPage"].join(", "));
9881
10578
  }
9882
10579
  /**
9883
10580
  * Similar to
@@ -9932,18 +10629,8 @@ export class Collection extends Object {
9932
10629
  if (!(e instanceof TypeError))
9933
10630
  throw e;
9934
10631
  }
9935
- try {
9936
- return await Link.fromJsonLd(document, { documentLoader, contextLoader });
9937
- }
9938
- catch (e) {
9939
- if (!(e instanceof TypeError))
9940
- throw e;
9941
- }
9942
10632
  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(", "));
10633
+ ["https://www.w3.org/ns/activitystreams#CollectionPage"].join(", "));
9947
10634
  }
9948
10635
  /**
9949
10636
  * Similar to
@@ -9998,18 +10685,8 @@ export class Collection extends Object {
9998
10685
  if (!(e instanceof TypeError))
9999
10686
  throw e;
10000
10687
  }
10001
- try {
10002
- return await Link.fromJsonLd(document, { documentLoader, contextLoader });
10003
- }
10004
- catch (e) {
10005
- if (!(e instanceof TypeError))
10006
- throw e;
10007
- }
10008
10688
  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(", "));
10689
+ ["https://www.w3.org/ns/activitystreams#CollectionPage"].join(", "));
10013
10690
  }
10014
10691
  /**
10015
10692
  * Similar to
@@ -10064,18 +10741,8 @@ export class Collection extends Object {
10064
10741
  if (!(e instanceof TypeError))
10065
10742
  throw e;
10066
10743
  }
10067
- try {
10068
- return await Link.fromJsonLd(document, { documentLoader, contextLoader });
10069
- }
10070
- catch (e) {
10071
- if (!(e instanceof TypeError))
10072
- throw e;
10073
- }
10074
10744
  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(", "));
10745
+ ["https://www.w3.org/ns/activitystreams#Object"].join(", "));
10079
10746
  }
10080
10747
  /**
10081
10748
  * Similar to
@@ -10134,9 +10801,7 @@ export class Collection extends Object {
10134
10801
  for (const v of this.#_3UyUdxnyn6cDn53QKrh4MBiearma) {
10135
10802
  const element = v instanceof URL
10136
10803
  ? { "@id": v.href }
10137
- : v instanceof CollectionPage
10138
- ? await v.toJsonLd(options)
10139
- : await v.toJsonLd(options);
10804
+ : await v.toJsonLd(options);
10140
10805
  array.push(element);
10141
10806
  }
10142
10807
  if (array.length > 0) {
@@ -10146,9 +10811,7 @@ export class Collection extends Object {
10146
10811
  for (const v of this.#_J52RqweMe6hhv7RnLJMC8BExTE5) {
10147
10812
  const element = v instanceof URL
10148
10813
  ? { "@id": v.href }
10149
- : v instanceof CollectionPage
10150
- ? await v.toJsonLd(options)
10151
- : await v.toJsonLd(options);
10814
+ : await v.toJsonLd(options);
10152
10815
  array.push(element);
10153
10816
  }
10154
10817
  if (array.length > 0) {
@@ -10158,9 +10821,7 @@ export class Collection extends Object {
10158
10821
  for (const v of this.#_gyJJnyEFnuNVi1HFZKfAn3Hfn26) {
10159
10822
  const element = v instanceof URL
10160
10823
  ? { "@id": v.href }
10161
- : v instanceof CollectionPage
10162
- ? await v.toJsonLd(options)
10163
- : await v.toJsonLd(options);
10824
+ : await v.toJsonLd(options);
10164
10825
  array.push(element);
10165
10826
  }
10166
10827
  if (array.length > 0) {
@@ -10170,9 +10831,7 @@ export class Collection extends Object {
10170
10831
  for (const v of this.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg) {
10171
10832
  const element = v instanceof URL
10172
10833
  ? { "@id": v.href }
10173
- : v instanceof Object
10174
- ? await v.toJsonLd(options)
10175
- : await v.toJsonLd(options);
10834
+ : await v.toJsonLd(options);
10176
10835
  array.push(element);
10177
10836
  }
10178
10837
  if (array.length > 0) {
@@ -10255,25 +10914,7 @@ export class Collection extends Object {
10255
10914
  _3UyUdxnyn6cDn53QKrh4MBiearma.push(new URL(v["@id"]));
10256
10915
  continue;
10257
10916
  }
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);
10917
+ _3UyUdxnyn6cDn53QKrh4MBiearma.push(await CollectionPage.fromJsonLd(v, options));
10277
10918
  }
10278
10919
  instance.#_3UyUdxnyn6cDn53QKrh4MBiearma = _3UyUdxnyn6cDn53QKrh4MBiearma;
10279
10920
  const _J52RqweMe6hhv7RnLJMC8BExTE5 = [];
@@ -10285,25 +10926,7 @@ export class Collection extends Object {
10285
10926
  _J52RqweMe6hhv7RnLJMC8BExTE5.push(new URL(v["@id"]));
10286
10927
  continue;
10287
10928
  }
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);
10929
+ _J52RqweMe6hhv7RnLJMC8BExTE5.push(await CollectionPage.fromJsonLd(v, options));
10307
10930
  }
10308
10931
  instance.#_J52RqweMe6hhv7RnLJMC8BExTE5 = _J52RqweMe6hhv7RnLJMC8BExTE5;
10309
10932
  const _gyJJnyEFnuNVi1HFZKfAn3Hfn26 = [];
@@ -10315,25 +10938,7 @@ export class Collection extends Object {
10315
10938
  _gyJJnyEFnuNVi1HFZKfAn3Hfn26.push(new URL(v["@id"]));
10316
10939
  continue;
10317
10940
  }
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);
10941
+ _gyJJnyEFnuNVi1HFZKfAn3Hfn26.push(await CollectionPage.fromJsonLd(v, options));
10337
10942
  }
10338
10943
  instance.#_gyJJnyEFnuNVi1HFZKfAn3Hfn26 = _gyJJnyEFnuNVi1HFZKfAn3Hfn26;
10339
10944
  const _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = [];
@@ -10345,66 +10950,7 @@ export class Collection extends Object {
10345
10950
  _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg.push(new URL(v["@id"]));
10346
10951
  continue;
10347
10952
  }
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")
10406
- continue;
10407
- _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg.push(decoded);
10953
+ _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg.push(await Object.fromJsonLd(v, options));
10408
10954
  }
10409
10955
  instance.#_2JPCKWTcfBmTCcW8Tv3TpRaLVaqg = _2JPCKWTcfBmTCcW8Tv3TpRaLVaqg;
10410
10956
  return instance;
@@ -10501,36 +11047,33 @@ export class CollectionPage extends Collection {
10501
11047
  constructor(values, { documentLoader, contextLoader, } = {}) {
10502
11048
  super(values, { documentLoader, contextLoader });
10503
11049
  if ("partOf" in values && values.partOf != null) {
10504
- if (values.partOf instanceof Link || values.partOf instanceof Collection ||
10505
- values.partOf instanceof URL) {
11050
+ if (values.partOf instanceof Collection || values.partOf instanceof URL) {
10506
11051
  // @ts-ignore: type is checked above.
10507
11052
  this.#_2kWgBhQKjEauxx8C6qF3ZQamK4Le = [values.partOf];
10508
11053
  }
10509
11054
  else {
10510
11055
  throw new TypeError("The partOf must be of type " +
10511
- "Link | Collection | URL" + ".");
11056
+ "Collection | URL" + ".");
10512
11057
  }
10513
11058
  }
10514
11059
  if ("next" in values && values.next != null) {
10515
- if (values.next instanceof _b || values.next instanceof Link ||
10516
- values.next instanceof URL) {
11060
+ if (values.next instanceof _b || values.next instanceof URL) {
10517
11061
  // @ts-ignore: type is checked above.
10518
11062
  this.#_3BT4kQLcXhHx7TAWaNDKh8nFn9eY = [values.next];
10519
11063
  }
10520
11064
  else {
10521
11065
  throw new TypeError("The next must be of type " +
10522
- "CollectionPage | Link | URL" + ".");
11066
+ "CollectionPage | URL" + ".");
10523
11067
  }
10524
11068
  }
10525
11069
  if ("prev" in values && values.prev != null) {
10526
- if (values.prev instanceof _b || values.prev instanceof Link ||
10527
- values.prev instanceof URL) {
11070
+ if (values.prev instanceof _b || values.prev instanceof URL) {
10528
11071
  // @ts-ignore: type is checked above.
10529
11072
  this.#_3b8yG8tDNzQFFEnWhCc13G8eHooA = [values.prev];
10530
11073
  }
10531
11074
  else {
10532
11075
  throw new TypeError("The prev must be of type " +
10533
- "CollectionPage | Link | URL" + ".");
11076
+ "CollectionPage | URL" + ".");
10534
11077
  }
10535
11078
  }
10536
11079
  }
@@ -10544,38 +11087,35 @@ export class CollectionPage extends Collection {
10544
11087
  const clone = super.clone(values, options);
10545
11088
  clone.#_2kWgBhQKjEauxx8C6qF3ZQamK4Le = this.#_2kWgBhQKjEauxx8C6qF3ZQamK4Le;
10546
11089
  if ("partOf" in values && values.partOf != null) {
10547
- if (values.partOf instanceof Link || values.partOf instanceof Collection ||
10548
- values.partOf instanceof URL) {
11090
+ if (values.partOf instanceof Collection || values.partOf instanceof URL) {
10549
11091
  // @ts-ignore: type is checked above.
10550
11092
  clone.#_2kWgBhQKjEauxx8C6qF3ZQamK4Le = [values.partOf];
10551
11093
  }
10552
11094
  else {
10553
11095
  throw new TypeError("The partOf must be of type " +
10554
- "Link | Collection | URL" + ".");
11096
+ "Collection | URL" + ".");
10555
11097
  }
10556
11098
  }
10557
11099
  clone.#_3BT4kQLcXhHx7TAWaNDKh8nFn9eY = this.#_3BT4kQLcXhHx7TAWaNDKh8nFn9eY;
10558
11100
  if ("next" in values && values.next != null) {
10559
- if (values.next instanceof _b || values.next instanceof Link ||
10560
- values.next instanceof URL) {
11101
+ if (values.next instanceof _b || values.next instanceof URL) {
10561
11102
  // @ts-ignore: type is checked above.
10562
11103
  clone.#_3BT4kQLcXhHx7TAWaNDKh8nFn9eY = [values.next];
10563
11104
  }
10564
11105
  else {
10565
11106
  throw new TypeError("The next must be of type " +
10566
- "CollectionPage | Link | URL" + ".");
11107
+ "CollectionPage | URL" + ".");
10567
11108
  }
10568
11109
  }
10569
11110
  clone.#_3b8yG8tDNzQFFEnWhCc13G8eHooA = this.#_3b8yG8tDNzQFFEnWhCc13G8eHooA;
10570
11111
  if ("prev" in values && values.prev != null) {
10571
- if (values.prev instanceof _b || values.prev instanceof Link ||
10572
- values.prev instanceof URL) {
11112
+ if (values.prev instanceof _b || values.prev instanceof URL) {
10573
11113
  // @ts-ignore: type is checked above.
10574
11114
  clone.#_3b8yG8tDNzQFFEnWhCc13G8eHooA = [values.prev];
10575
11115
  }
10576
11116
  else {
10577
11117
  throw new TypeError("The prev must be of type " +
10578
- "CollectionPage | Link | URL" + ".");
11118
+ "CollectionPage | URL" + ".");
10579
11119
  }
10580
11120
  }
10581
11121
  return clone;
@@ -10597,13 +11137,6 @@ export class CollectionPage extends Collection {
10597
11137
  throw error;
10598
11138
  }
10599
11139
  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
11140
  try {
10608
11141
  return await Collection.fromJsonLd(document, { documentLoader, contextLoader });
10609
11142
  }
@@ -10612,10 +11145,7 @@ export class CollectionPage extends Collection {
10612
11145
  throw e;
10613
11146
  }
10614
11147
  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(", "));
11148
+ ["https://www.w3.org/ns/activitystreams#Collection"].join(", "));
10619
11149
  }
10620
11150
  /**
10621
11151
  * Similar to
@@ -10670,18 +11200,8 @@ export class CollectionPage extends Collection {
10670
11200
  if (!(e instanceof TypeError))
10671
11201
  throw e;
10672
11202
  }
10673
- try {
10674
- return await Link.fromJsonLd(document, { documentLoader, contextLoader });
10675
- }
10676
- catch (e) {
10677
- if (!(e instanceof TypeError))
10678
- throw e;
10679
- }
10680
11203
  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(", "));
11204
+ ["https://www.w3.org/ns/activitystreams#CollectionPage"].join(", "));
10685
11205
  }
10686
11206
  /**
10687
11207
  * Similar to
@@ -10735,18 +11255,8 @@ export class CollectionPage extends Collection {
10735
11255
  if (!(e instanceof TypeError))
10736
11256
  throw e;
10737
11257
  }
10738
- try {
10739
- return await Link.fromJsonLd(document, { documentLoader, contextLoader });
10740
- }
10741
- catch (e) {
10742
- if (!(e instanceof TypeError))
10743
- throw e;
10744
- }
10745
11258
  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(", "));
11259
+ ["https://www.w3.org/ns/activitystreams#CollectionPage"].join(", "));
10750
11260
  }
10751
11261
  /**
10752
11262
  * Similar to
@@ -10796,9 +11306,7 @@ export class CollectionPage extends Collection {
10796
11306
  for (const v of this.#_2kWgBhQKjEauxx8C6qF3ZQamK4Le) {
10797
11307
  const element = v instanceof URL
10798
11308
  ? { "@id": v.href }
10799
- : v instanceof Link
10800
- ? await v.toJsonLd(options)
10801
- : await v.toJsonLd(options);
11309
+ : await v.toJsonLd(options);
10802
11310
  array.push(element);
10803
11311
  }
10804
11312
  if (array.length > 0) {
@@ -10808,9 +11316,7 @@ export class CollectionPage extends Collection {
10808
11316
  for (const v of this.#_3BT4kQLcXhHx7TAWaNDKh8nFn9eY) {
10809
11317
  const element = v instanceof URL
10810
11318
  ? { "@id": v.href }
10811
- : v instanceof _b
10812
- ? await v.toJsonLd(options)
10813
- : await v.toJsonLd(options);
11319
+ : await v.toJsonLd(options);
10814
11320
  array.push(element);
10815
11321
  }
10816
11322
  if (array.length > 0) {
@@ -10820,9 +11326,7 @@ export class CollectionPage extends Collection {
10820
11326
  for (const v of this.#_3b8yG8tDNzQFFEnWhCc13G8eHooA) {
10821
11327
  const element = v instanceof URL
10822
11328
  ? { "@id": v.href }
10823
- : v instanceof _b
10824
- ? await v.toJsonLd(options)
10825
- : await v.toJsonLd(options);
11329
+ : await v.toJsonLd(options);
10826
11330
  array.push(element);
10827
11331
  }
10828
11332
  if (array.length > 0) {
@@ -10889,27 +11393,7 @@ export class CollectionPage extends Collection {
10889
11393
  _2kWgBhQKjEauxx8C6qF3ZQamK4Le.push(new URL(v["@id"]));
10890
11394
  continue;
10891
11395
  }
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);
11396
+ _2kWgBhQKjEauxx8C6qF3ZQamK4Le.push(await Collection.fromJsonLd(v, options));
10913
11397
  }
10914
11398
  instance.#_2kWgBhQKjEauxx8C6qF3ZQamK4Le = _2kWgBhQKjEauxx8C6qF3ZQamK4Le;
10915
11399
  const _3BT4kQLcXhHx7TAWaNDKh8nFn9eY = [];
@@ -10921,25 +11405,7 @@ export class CollectionPage extends Collection {
10921
11405
  _3BT4kQLcXhHx7TAWaNDKh8nFn9eY.push(new URL(v["@id"]));
10922
11406
  continue;
10923
11407
  }
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);
11408
+ _3BT4kQLcXhHx7TAWaNDKh8nFn9eY.push(await _b.fromJsonLd(v, options));
10943
11409
  }
10944
11410
  instance.#_3BT4kQLcXhHx7TAWaNDKh8nFn9eY = _3BT4kQLcXhHx7TAWaNDKh8nFn9eY;
10945
11411
  const _3b8yG8tDNzQFFEnWhCc13G8eHooA = [];
@@ -10951,25 +11417,7 @@ export class CollectionPage extends Collection {
10951
11417
  _3b8yG8tDNzQFFEnWhCc13G8eHooA.push(new URL(v["@id"]));
10952
11418
  continue;
10953
11419
  }
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);
11420
+ _3b8yG8tDNzQFFEnWhCc13G8eHooA.push(await _b.fromJsonLd(v, options));
10973
11421
  }
10974
11422
  instance.#_3b8yG8tDNzQFFEnWhCc13G8eHooA = _3b8yG8tDNzQFFEnWhCc13G8eHooA;
10975
11423
  return instance;