@fedify/fedify 1.0.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. package/CHANGES.md +23 -0
  2. package/esm/federation/handler.js +1 -1
  3. package/esm/vocab/accept.yaml +1 -1
  4. package/esm/vocab/activity.yaml +1 -1
  5. package/esm/vocab/add.yaml +1 -1
  6. package/esm/vocab/announce.yaml +1 -1
  7. package/esm/vocab/arrive.yaml +1 -1
  8. package/esm/vocab/block.yaml +1 -1
  9. package/esm/vocab/create.yaml +1 -1
  10. package/esm/vocab/delete.yaml +1 -1
  11. package/esm/vocab/dislike.yaml +1 -1
  12. package/esm/vocab/flag.yaml +1 -1
  13. package/esm/vocab/follow.yaml +1 -1
  14. package/esm/vocab/ignore.yaml +1 -1
  15. package/esm/vocab/intransitiveactivity.yaml +1 -1
  16. package/esm/vocab/invite.yaml +1 -1
  17. package/esm/vocab/join.yaml +1 -1
  18. package/esm/vocab/leave.yaml +1 -1
  19. package/esm/vocab/like.yaml +1 -1
  20. package/esm/vocab/listen.yaml +1 -1
  21. package/esm/vocab/move.yaml +1 -1
  22. package/esm/vocab/offer.yaml +1 -1
  23. package/esm/vocab/question.yaml +1 -1
  24. package/esm/vocab/read.yaml +1 -1
  25. package/esm/vocab/reject.yaml +1 -1
  26. package/esm/vocab/remove.yaml +1 -1
  27. package/esm/vocab/tentativeaccept.yaml +1 -1
  28. package/esm/vocab/tentativereject.yaml +1 -1
  29. package/esm/vocab/travel.yaml +1 -1
  30. package/esm/vocab/undo.yaml +1 -1
  31. package/esm/vocab/update.yaml +1 -1
  32. package/esm/vocab/view.yaml +1 -1
  33. package/esm/vocab/vocab.js +549 -1256
  34. package/esm/webfinger/handler.js +1 -1
  35. package/package.json +1 -1
  36. package/types/deps/jsr.io/@std/http/{1.0.7 → 1.0.8}/_negotiation/common.d.ts.map +1 -1
  37. package/types/deps/jsr.io/@std/http/{1.0.7 → 1.0.8}/_negotiation/encoding.d.ts.map +1 -1
  38. package/types/deps/jsr.io/@std/http/{1.0.7 → 1.0.8}/_negotiation/language.d.ts.map +1 -1
  39. package/types/deps/jsr.io/@std/http/{1.0.7 → 1.0.8}/_negotiation/media_type.d.ts.map +1 -1
  40. package/types/deps/jsr.io/@std/http/{1.0.7 → 1.0.8}/negotiation.d.ts.map +1 -1
  41. package/types/vocab/vocab.d.ts.map +1 -1
  42. /package/esm/deps/jsr.io/@std/http/{1.0.7 → 1.0.8}/_negotiation/common.js +0 -0
  43. /package/esm/deps/jsr.io/@std/http/{1.0.7 → 1.0.8}/_negotiation/encoding.js +0 -0
  44. /package/esm/deps/jsr.io/@std/http/{1.0.7 → 1.0.8}/_negotiation/language.js +0 -0
  45. /package/esm/deps/jsr.io/@std/http/{1.0.7 → 1.0.8}/_negotiation/media_type.js +0 -0
  46. /package/esm/deps/jsr.io/@std/http/{1.0.7 → 1.0.8}/negotiation.js +0 -0
  47. /package/types/deps/jsr.io/@std/http/{1.0.7 → 1.0.8}/_negotiation/common.d.ts +0 -0
  48. /package/types/deps/jsr.io/@std/http/{1.0.7 → 1.0.8}/_negotiation/encoding.d.ts +0 -0
  49. /package/types/deps/jsr.io/@std/http/{1.0.7 → 1.0.8}/_negotiation/language.d.ts +0 -0
  50. /package/types/deps/jsr.io/@std/http/{1.0.7 → 1.0.8}/_negotiation/media_type.d.ts +0 -0
  51. /package/types/deps/jsr.io/@std/http/{1.0.7 → 1.0.8}/negotiation.d.ts +0 -0
@@ -3701,7 +3701,8 @@ export class Object {
3701
3701
  // deno-lint-ignore no-explicit-any
3702
3702
  (expanded[0] ?? {});
3703
3703
  }
3704
- if ("@type" in values) {
3704
+ if ("@type" in values &&
3705
+ !values["@type"].every((t) => t.startsWith("_:"))) {
3705
3706
  if (values["@type"].includes("http://joinmastodon.org/ns#Emoji")) {
3706
3707
  return await Emoji.fromJsonLd(json, options);
3707
3708
  }
@@ -5522,7 +5523,8 @@ export class Emoji extends Object {
5522
5523
  // deno-lint-ignore no-explicit-any
5523
5524
  (expanded[0] ?? {});
5524
5525
  }
5525
- if ("@type" in values) {
5526
+ if ("@type" in values &&
5527
+ !values["@type"].every((t) => t.startsWith("_:"))) {
5526
5528
  if (!values["@type"].includes("http://joinmastodon.org/ns#Emoji")) {
5527
5529
  throw new TypeError("Invalid type: " + values["@type"]);
5528
5530
  }
@@ -5786,7 +5788,8 @@ export class ChatMessage extends Object {
5786
5788
  // deno-lint-ignore no-explicit-any
5787
5789
  (expanded[0] ?? {});
5788
5790
  }
5789
- if ("@type" in values) {
5791
+ if ("@type" in values &&
5792
+ !values["@type"].every((t) => t.startsWith("_:"))) {
5790
5793
  if (!values["@type"].includes("http://litepub.social/ns#ChatMessage")) {
5791
5794
  throw new TypeError("Invalid type: " + values["@type"]);
5792
5795
  }
@@ -6113,7 +6116,8 @@ export class PropertyValue {
6113
6116
  // deno-lint-ignore no-explicit-any
6114
6117
  (expanded[0] ?? {});
6115
6118
  }
6116
- if ("@type" in values) {
6119
+ if ("@type" in values &&
6120
+ !values["@type"].every((t) => t.startsWith("_:"))) {
6117
6121
  if (!values["@type"].includes("http://schema.org#PropertyValue")) {
6118
6122
  throw new TypeError("Invalid type: " + values["@type"]);
6119
6123
  }
@@ -6623,7 +6627,8 @@ export class DataIntegrityProof {
6623
6627
  // deno-lint-ignore no-explicit-any
6624
6628
  (expanded[0] ?? {});
6625
6629
  }
6626
- if ("@type" in values) {
6630
+ if ("@type" in values &&
6631
+ !values["@type"].every((t) => t.startsWith("_:"))) {
6627
6632
  if (!values["@type"].includes("https://w3id.org/security#DataIntegrityProof")) {
6628
6633
  throw new TypeError("Invalid type: " + values["@type"]);
6629
6634
  }
@@ -7155,7 +7160,8 @@ export class CryptographicKey {
7155
7160
  // deno-lint-ignore no-explicit-any
7156
7161
  (expanded[0] ?? {});
7157
7162
  }
7158
- if ("@type" in values) {
7163
+ if ("@type" in values &&
7164
+ !values["@type"].every((t) => t.startsWith("_:"))) {
7159
7165
  if (!values["@type"].includes("https://w3id.org/security#Key")) {
7160
7166
  throw new TypeError("Invalid type: " + values["@type"]);
7161
7167
  }
@@ -7646,7 +7652,8 @@ export class Multikey {
7646
7652
  // deno-lint-ignore no-explicit-any
7647
7653
  (expanded[0] ?? {});
7648
7654
  }
7649
- if ("@type" in values) {
7655
+ if ("@type" in values &&
7656
+ !values["@type"].every((t) => t.startsWith("_:"))) {
7650
7657
  if (!values["@type"].includes("https://w3id.org/security#Multikey")) {
7651
7658
  throw new TypeError("Invalid type: " + values["@type"]);
7652
7659
  }
@@ -8701,135 +8708,6 @@ export class Activity extends Object {
8701
8708
  ...options,
8702
8709
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
8703
8710
  };
8704
- if (options.format == null && this.isCompactable()) {
8705
- const result = await super.toJsonLd({
8706
- ...options,
8707
- format: undefined,
8708
- context: undefined,
8709
- });
8710
- // deno-lint-ignore no-unused-vars
8711
- let compactItems;
8712
- compactItems = [];
8713
- for (const v of this.#_2DjTTboo3CNHU2a2JQqUSE2dbv9D_actor) {
8714
- const item = v instanceof URL
8715
- ? v.href
8716
- : v instanceof Application
8717
- ? await v.toJsonLd({
8718
- ...options,
8719
- format: undefined,
8720
- context: undefined,
8721
- })
8722
- : v instanceof Group
8723
- ? await v.toJsonLd({
8724
- ...options,
8725
- format: undefined,
8726
- context: undefined,
8727
- })
8728
- : v instanceof Organization
8729
- ? await v.toJsonLd({
8730
- ...options,
8731
- format: undefined,
8732
- context: undefined,
8733
- })
8734
- : v instanceof Person
8735
- ? await v.toJsonLd({
8736
- ...options,
8737
- format: undefined,
8738
- context: undefined,
8739
- })
8740
- : await v.toJsonLd({
8741
- ...options,
8742
- format: undefined,
8743
- context: undefined,
8744
- });
8745
- compactItems.push(item);
8746
- }
8747
- if (compactItems.length > 0) {
8748
- result["actor"] = compactItems.length > 1
8749
- ? compactItems
8750
- : compactItems[0];
8751
- }
8752
- compactItems = [];
8753
- for (const v of this.#_2MH19yxjn1wnHsNfa5n4JBhJzxyc_object) {
8754
- const item = v instanceof URL ? v.href : await v.toJsonLd({
8755
- ...options,
8756
- format: undefined,
8757
- context: undefined,
8758
- });
8759
- compactItems.push(item);
8760
- }
8761
- if (compactItems.length > 0) {
8762
- result["object"] = compactItems.length > 1
8763
- ? compactItems
8764
- : compactItems[0];
8765
- }
8766
- compactItems = [];
8767
- for (const v of this.#_3JQCmF2Ww56Ag9EWRYoSZRDNCYtF_target) {
8768
- const item = v instanceof URL ? v.href : await v.toJsonLd({
8769
- ...options,
8770
- format: undefined,
8771
- context: undefined,
8772
- });
8773
- compactItems.push(item);
8774
- }
8775
- if (compactItems.length > 0) {
8776
- result["target"] = compactItems.length > 1
8777
- ? compactItems
8778
- : compactItems[0];
8779
- }
8780
- compactItems = [];
8781
- for (const v of this.#_u4QGFbRFcYmPEKGbPv1hpBR9r5G_result) {
8782
- const item = v instanceof URL ? v.href : await v.toJsonLd({
8783
- ...options,
8784
- format: undefined,
8785
- context: undefined,
8786
- });
8787
- compactItems.push(item);
8788
- }
8789
- if (compactItems.length > 0) {
8790
- result["result"] = compactItems.length > 1
8791
- ? compactItems
8792
- : compactItems[0];
8793
- }
8794
- compactItems = [];
8795
- for (const v of this.#_25zu2s3VxVujgEKqrDycjE284XQR_origin) {
8796
- const item = v instanceof URL ? v.href : await v.toJsonLd({
8797
- ...options,
8798
- format: undefined,
8799
- context: undefined,
8800
- });
8801
- compactItems.push(item);
8802
- }
8803
- if (compactItems.length > 0) {
8804
- result["origin"] = compactItems.length > 1
8805
- ? compactItems
8806
- : compactItems[0];
8807
- }
8808
- compactItems = [];
8809
- for (const v of this.#_3c5t2x7DYRo2shwTxpkd4kYSS5WQ_instrument) {
8810
- const item = v instanceof URL ? v.href : await v.toJsonLd({
8811
- ...options,
8812
- format: undefined,
8813
- context: undefined,
8814
- });
8815
- compactItems.push(item);
8816
- }
8817
- if (compactItems.length > 0) {
8818
- result["instrument"] = compactItems.length > 1
8819
- ? compactItems
8820
- : compactItems[0];
8821
- }
8822
- result["type"] = "Activity";
8823
- if (this.id != null)
8824
- result["id"] = this.id.href;
8825
- result["@context"] = [
8826
- "https://www.w3.org/ns/activitystreams",
8827
- "https://w3id.org/security/v1",
8828
- "https://w3id.org/security/data-integrity/v1",
8829
- "https://w3id.org/identity/v1",
8830
- ];
8831
- return result;
8832
- }
8833
8711
  // deno-lint-ignore no-unused-vars prefer-const
8834
8712
  let array;
8835
8713
  const baseValues = await super.toJsonLd({
@@ -8920,10 +8798,10 @@ export class Activity extends Object {
8920
8798
  }
8921
8799
  const docContext = options.context ??
8922
8800
  [
8801
+ "https://w3id.org/identity/v1",
8923
8802
  "https://www.w3.org/ns/activitystreams",
8924
8803
  "https://w3id.org/security/v1",
8925
8804
  "https://w3id.org/security/data-integrity/v1",
8926
- "https://w3id.org/identity/v1",
8927
8805
  ];
8928
8806
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
8929
8807
  if (docContext != null) {
@@ -8976,7 +8854,8 @@ export class Activity extends Object {
8976
8854
  // deno-lint-ignore no-explicit-any
8977
8855
  (expanded[0] ?? {});
8978
8856
  }
8979
- if ("@type" in values) {
8857
+ if ("@type" in values &&
8858
+ !values["@type"].every((t) => t.startsWith("_:"))) {
8980
8859
  if (values["@type"].includes("https://www.w3.org/ns/activitystreams#Accept")) {
8981
8860
  return await Accept.fromJsonLd(json, options);
8982
8861
  }
@@ -9391,24 +9270,6 @@ export class Accept extends Activity {
9391
9270
  ...options,
9392
9271
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
9393
9272
  };
9394
- if (options.format == null && this.isCompactable()) {
9395
- const result = await super.toJsonLd({
9396
- ...options,
9397
- format: undefined,
9398
- context: undefined,
9399
- });
9400
- // deno-lint-ignore no-unused-vars
9401
- let compactItems;
9402
- result["type"] = "Accept";
9403
- if (this.id != null)
9404
- result["id"] = this.id.href;
9405
- result["@context"] = [
9406
- "https://www.w3.org/ns/activitystreams",
9407
- "https://w3id.org/security/data-integrity/v1",
9408
- "https://w3id.org/identity/v1",
9409
- ];
9410
- return result;
9411
- }
9412
9273
  // deno-lint-ignore no-unused-vars prefer-const
9413
9274
  let array;
9414
9275
  const baseValues = await super.toJsonLd({
@@ -9425,9 +9286,9 @@ export class Accept extends Activity {
9425
9286
  }
9426
9287
  const docContext = options.context ??
9427
9288
  [
9289
+ "https://w3id.org/identity/v1",
9428
9290
  "https://www.w3.org/ns/activitystreams",
9429
9291
  "https://w3id.org/security/data-integrity/v1",
9430
- "https://w3id.org/identity/v1",
9431
9292
  ];
9432
9293
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
9433
9294
  if (docContext != null) {
@@ -9480,7 +9341,8 @@ export class Accept extends Activity {
9480
9341
  // deno-lint-ignore no-explicit-any
9481
9342
  (expanded[0] ?? {});
9482
9343
  }
9483
- if ("@type" in values) {
9344
+ if ("@type" in values &&
9345
+ !values["@type"].every((t) => t.startsWith("_:"))) {
9484
9346
  if (values["@type"].includes("https://www.w3.org/ns/activitystreams#TentativeAccept")) {
9485
9347
  return await TentativeAccept.fromJsonLd(json, options);
9486
9348
  }
@@ -9573,24 +9435,6 @@ export class Add extends Activity {
9573
9435
  ...options,
9574
9436
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
9575
9437
  };
9576
- if (options.format == null && this.isCompactable()) {
9577
- const result = await super.toJsonLd({
9578
- ...options,
9579
- format: undefined,
9580
- context: undefined,
9581
- });
9582
- // deno-lint-ignore no-unused-vars
9583
- let compactItems;
9584
- result["type"] = "Add";
9585
- if (this.id != null)
9586
- result["id"] = this.id.href;
9587
- result["@context"] = [
9588
- "https://www.w3.org/ns/activitystreams",
9589
- "https://w3id.org/security/data-integrity/v1",
9590
- "https://w3id.org/identity/v1",
9591
- ];
9592
- return result;
9593
- }
9594
9438
  // deno-lint-ignore no-unused-vars prefer-const
9595
9439
  let array;
9596
9440
  const baseValues = await super.toJsonLd({
@@ -9607,9 +9451,9 @@ export class Add extends Activity {
9607
9451
  }
9608
9452
  const docContext = options.context ??
9609
9453
  [
9454
+ "https://w3id.org/identity/v1",
9610
9455
  "https://www.w3.org/ns/activitystreams",
9611
9456
  "https://w3id.org/security/data-integrity/v1",
9612
- "https://w3id.org/identity/v1",
9613
9457
  ];
9614
9458
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
9615
9459
  if (docContext != null) {
@@ -9662,7 +9506,8 @@ export class Add extends Activity {
9662
9506
  // deno-lint-ignore no-explicit-any
9663
9507
  (expanded[0] ?? {});
9664
9508
  }
9665
- if ("@type" in values) {
9509
+ if ("@type" in values &&
9510
+ !values["@type"].every((t) => t.startsWith("_:"))) {
9666
9511
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Add")) {
9667
9512
  throw new TypeError("Invalid type: " + values["@type"]);
9668
9513
  }
@@ -9751,36 +9596,6 @@ export class Announce extends Activity {
9751
9596
  ...options,
9752
9597
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
9753
9598
  };
9754
- if (options.format == null && this.isCompactable()) {
9755
- const result = await super.toJsonLd({
9756
- ...options,
9757
- format: undefined,
9758
- context: undefined,
9759
- });
9760
- // deno-lint-ignore no-unused-vars
9761
- let compactItems;
9762
- result["type"] = "Announce";
9763
- if (this.id != null)
9764
- result["id"] = this.id.href;
9765
- result["@context"] = [
9766
- "https://www.w3.org/ns/activitystreams",
9767
- "https://w3id.org/security/data-integrity/v1",
9768
- "https://w3id.org/identity/v1",
9769
- {
9770
- "toot": "http://joinmastodon.org/ns#",
9771
- "misskey": "https://misskey-hub.net/ns#",
9772
- "fedibird": "http://fedibird.com/ns#",
9773
- "sensitive": "as:sensitive",
9774
- "votersCount": "toot:votersCount",
9775
- "Emoji": "toot:Emoji",
9776
- "Hashtag": "as:Hashtag",
9777
- "quoteUrl": "as:quoteUrl",
9778
- "_misskey_quote": "misskey:_misskey_quote",
9779
- "quoteUri": "fedibird:quoteUri",
9780
- },
9781
- ];
9782
- return result;
9783
- }
9784
9599
  // deno-lint-ignore no-unused-vars prefer-const
9785
9600
  let array;
9786
9601
  const baseValues = await super.toJsonLd({
@@ -9797,9 +9612,9 @@ export class Announce extends Activity {
9797
9612
  }
9798
9613
  const docContext = options.context ??
9799
9614
  [
9615
+ "https://w3id.org/identity/v1",
9800
9616
  "https://www.w3.org/ns/activitystreams",
9801
9617
  "https://w3id.org/security/data-integrity/v1",
9802
- "https://w3id.org/identity/v1",
9803
9618
  {
9804
9619
  "toot": "http://joinmastodon.org/ns#",
9805
9620
  "misskey": "https://misskey-hub.net/ns#",
@@ -9864,7 +9679,8 @@ export class Announce extends Activity {
9864
9679
  // deno-lint-ignore no-explicit-any
9865
9680
  (expanded[0] ?? {});
9866
9681
  }
9867
- if ("@type" in values) {
9682
+ if ("@type" in values &&
9683
+ !values["@type"].every((t) => t.startsWith("_:"))) {
9868
9684
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Announce")) {
9869
9685
  throw new TypeError("Invalid type: " + values["@type"]);
9870
9686
  }
@@ -12013,7 +11829,8 @@ export class Application extends Object {
12013
11829
  // deno-lint-ignore no-explicit-any
12014
11830
  (expanded[0] ?? {});
12015
11831
  }
12016
- if ("@type" in values) {
11832
+ if ("@type" in values &&
11833
+ !values["@type"].every((t) => t.startsWith("_:"))) {
12017
11834
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Application")) {
12018
11835
  throw new TypeError("Invalid type: " + values["@type"]);
12019
11836
  }
@@ -12712,24 +12529,6 @@ export class IntransitiveActivity extends Activity {
12712
12529
  ...options,
12713
12530
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
12714
12531
  };
12715
- if (options.format == null && this.isCompactable()) {
12716
- const result = await super.toJsonLd({
12717
- ...options,
12718
- format: undefined,
12719
- context: undefined,
12720
- });
12721
- // deno-lint-ignore no-unused-vars
12722
- let compactItems;
12723
- result["type"] = "IntransitiveActivity";
12724
- if (this.id != null)
12725
- result["id"] = this.id.href;
12726
- result["@context"] = [
12727
- "https://www.w3.org/ns/activitystreams",
12728
- "https://w3id.org/security/data-integrity/v1",
12729
- "https://w3id.org/identity/v1",
12730
- ];
12731
- return result;
12732
- }
12733
12532
  // deno-lint-ignore no-unused-vars prefer-const
12734
12533
  let array;
12735
12534
  const baseValues = await super.toJsonLd({
@@ -12748,9 +12547,9 @@ export class IntransitiveActivity extends Activity {
12748
12547
  }
12749
12548
  const docContext = options.context ??
12750
12549
  [
12550
+ "https://w3id.org/identity/v1",
12751
12551
  "https://www.w3.org/ns/activitystreams",
12752
12552
  "https://w3id.org/security/data-integrity/v1",
12753
- "https://w3id.org/identity/v1",
12754
12553
  ];
12755
12554
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
12756
12555
  if (docContext != null) {
@@ -12803,7 +12602,8 @@ export class IntransitiveActivity extends Activity {
12803
12602
  // deno-lint-ignore no-explicit-any
12804
12603
  (expanded[0] ?? {});
12805
12604
  }
12806
- if ("@type" in values) {
12605
+ if ("@type" in values &&
12606
+ !values["@type"].every((t) => t.startsWith("_:"))) {
12807
12607
  if (values["@type"].includes("https://www.w3.org/ns/activitystreams#Arrive")) {
12808
12608
  return await Arrive.fromJsonLd(json, options);
12809
12609
  }
@@ -12917,9 +12717,9 @@ export class Arrive extends IntransitiveActivity {
12917
12717
  }
12918
12718
  const docContext = options.context ??
12919
12719
  [
12720
+ "https://w3id.org/identity/v1",
12920
12721
  "https://www.w3.org/ns/activitystreams",
12921
12722
  "https://w3id.org/security/data-integrity/v1",
12922
- "https://w3id.org/identity/v1",
12923
12723
  ];
12924
12724
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
12925
12725
  if (docContext != null) {
@@ -12972,7 +12772,8 @@ export class Arrive extends IntransitiveActivity {
12972
12772
  // deno-lint-ignore no-explicit-any
12973
12773
  (expanded[0] ?? {});
12974
12774
  }
12975
- if ("@type" in values) {
12775
+ if ("@type" in values &&
12776
+ !values["@type"].every((t) => t.startsWith("_:"))) {
12976
12777
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Arrive")) {
12977
12778
  throw new TypeError("Invalid type: " + values["@type"]);
12978
12779
  }
@@ -13234,7 +13035,8 @@ export class Article extends Object {
13234
13035
  // deno-lint-ignore no-explicit-any
13235
13036
  (expanded[0] ?? {});
13236
13037
  }
13237
- if ("@type" in values) {
13038
+ if ("@type" in values &&
13039
+ !values["@type"].every((t) => t.startsWith("_:"))) {
13238
13040
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Article")) {
13239
13041
  throw new TypeError("Invalid type: " + values["@type"]);
13240
13042
  }
@@ -13554,7 +13356,8 @@ export class Document extends Object {
13554
13356
  // deno-lint-ignore no-explicit-any
13555
13357
  (expanded[0] ?? {});
13556
13358
  }
13557
- if ("@type" in values) {
13359
+ if ("@type" in values &&
13360
+ !values["@type"].every((t) => t.startsWith("_:"))) {
13558
13361
  if (values["@type"].includes("https://www.w3.org/ns/activitystreams#Audio")) {
13559
13362
  return await Audio.fromJsonLd(json, options);
13560
13363
  }
@@ -13792,7 +13595,8 @@ export class Audio extends Document {
13792
13595
  // deno-lint-ignore no-explicit-any
13793
13596
  (expanded[0] ?? {});
13794
13597
  }
13795
- if ("@type" in values) {
13598
+ if ("@type" in values &&
13599
+ !values["@type"].every((t) => t.startsWith("_:"))) {
13796
13600
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Audio")) {
13797
13601
  throw new TypeError("Invalid type: " + values["@type"]);
13798
13602
  }
@@ -13880,24 +13684,6 @@ export class Ignore extends Activity {
13880
13684
  ...options,
13881
13685
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
13882
13686
  };
13883
- if (options.format == null && this.isCompactable()) {
13884
- const result = await super.toJsonLd({
13885
- ...options,
13886
- format: undefined,
13887
- context: undefined,
13888
- });
13889
- // deno-lint-ignore no-unused-vars
13890
- let compactItems;
13891
- result["type"] = "Ignore";
13892
- if (this.id != null)
13893
- result["id"] = this.id.href;
13894
- result["@context"] = [
13895
- "https://www.w3.org/ns/activitystreams",
13896
- "https://w3id.org/security/data-integrity/v1",
13897
- "https://w3id.org/identity/v1",
13898
- ];
13899
- return result;
13900
- }
13901
13687
  // deno-lint-ignore no-unused-vars prefer-const
13902
13688
  let array;
13903
13689
  const baseValues = await super.toJsonLd({
@@ -13914,9 +13700,9 @@ export class Ignore extends Activity {
13914
13700
  }
13915
13701
  const docContext = options.context ??
13916
13702
  [
13703
+ "https://w3id.org/identity/v1",
13917
13704
  "https://www.w3.org/ns/activitystreams",
13918
13705
  "https://w3id.org/security/data-integrity/v1",
13919
- "https://w3id.org/identity/v1",
13920
13706
  ];
13921
13707
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
13922
13708
  if (docContext != null) {
@@ -13969,7 +13755,8 @@ export class Ignore extends Activity {
13969
13755
  // deno-lint-ignore no-explicit-any
13970
13756
  (expanded[0] ?? {});
13971
13757
  }
13972
- if ("@type" in values) {
13758
+ if ("@type" in values &&
13759
+ !values["@type"].every((t) => t.startsWith("_:"))) {
13973
13760
  if (values["@type"].includes("https://www.w3.org/ns/activitystreams#Block")) {
13974
13761
  return await Block.fromJsonLd(json, options);
13975
13762
  }
@@ -14062,24 +13849,6 @@ export class Block extends Ignore {
14062
13849
  ...options,
14063
13850
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
14064
13851
  };
14065
- if (options.format == null && this.isCompactable()) {
14066
- const result = await super.toJsonLd({
14067
- ...options,
14068
- format: undefined,
14069
- context: undefined,
14070
- });
14071
- // deno-lint-ignore no-unused-vars
14072
- let compactItems;
14073
- result["type"] = "Block";
14074
- if (this.id != null)
14075
- result["id"] = this.id.href;
14076
- result["@context"] = [
14077
- "https://www.w3.org/ns/activitystreams",
14078
- "https://w3id.org/security/data-integrity/v1",
14079
- "https://w3id.org/identity/v1",
14080
- ];
14081
- return result;
14082
- }
14083
13852
  // deno-lint-ignore no-unused-vars prefer-const
14084
13853
  let array;
14085
13854
  const baseValues = await super.toJsonLd({
@@ -14096,9 +13865,9 @@ export class Block extends Ignore {
14096
13865
  }
14097
13866
  const docContext = options.context ??
14098
13867
  [
13868
+ "https://w3id.org/identity/v1",
14099
13869
  "https://www.w3.org/ns/activitystreams",
14100
13870
  "https://w3id.org/security/data-integrity/v1",
14101
- "https://w3id.org/identity/v1",
14102
13871
  ];
14103
13872
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
14104
13873
  if (docContext != null) {
@@ -14151,7 +13920,8 @@ export class Block extends Ignore {
14151
13920
  // deno-lint-ignore no-explicit-any
14152
13921
  (expanded[0] ?? {});
14153
13922
  }
14154
- if ("@type" in values) {
13923
+ if ("@type" in values &&
13924
+ !values["@type"].every((t) => t.startsWith("_:"))) {
14155
13925
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Block")) {
14156
13926
  throw new TypeError("Invalid type: " + values["@type"]);
14157
13927
  }
@@ -14834,7 +14604,8 @@ export class Collection extends Object {
14834
14604
  // deno-lint-ignore no-explicit-any
14835
14605
  (expanded[0] ?? {});
14836
14606
  }
14837
- if ("@type" in values) {
14607
+ if ("@type" in values &&
14608
+ !values["@type"].every((t) => t.startsWith("_:"))) {
14838
14609
  if (values["@type"].includes("https://www.w3.org/ns/activitystreams#CollectionPage")) {
14839
14610
  return await CollectionPage.fromJsonLd(json, options);
14840
14611
  }
@@ -15563,7 +15334,8 @@ export class CollectionPage extends Collection {
15563
15334
  // deno-lint-ignore no-explicit-any
15564
15335
  (expanded[0] ?? {});
15565
15336
  }
15566
- if ("@type" in values) {
15337
+ if ("@type" in values &&
15338
+ !values["@type"].every((t) => t.startsWith("_:"))) {
15567
15339
  if (values["@type"].includes("https://www.w3.org/ns/activitystreams#OrderedCollectionPage")) {
15568
15340
  return await OrderedCollectionPage.fromJsonLd(json, options);
15569
15341
  }
@@ -15747,37 +15519,6 @@ export class Create extends Activity {
15747
15519
  ...options,
15748
15520
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
15749
15521
  };
15750
- if (options.format == null && this.isCompactable()) {
15751
- const result = await super.toJsonLd({
15752
- ...options,
15753
- format: undefined,
15754
- context: undefined,
15755
- });
15756
- // deno-lint-ignore no-unused-vars
15757
- let compactItems;
15758
- result["type"] = "Create";
15759
- if (this.id != null)
15760
- result["id"] = this.id.href;
15761
- result["@context"] = [
15762
- "https://www.w3.org/ns/activitystreams",
15763
- "https://w3id.org/security/data-integrity/v1",
15764
- "https://w3id.org/identity/v1",
15765
- {
15766
- "toot": "http://joinmastodon.org/ns#",
15767
- "misskey": "https://misskey-hub.net/ns#",
15768
- "fedibird": "http://fedibird.com/ns#",
15769
- "sensitive": "as:sensitive",
15770
- "votersCount": "toot:votersCount",
15771
- "Emoji": "toot:Emoji",
15772
- "Hashtag": "as:Hashtag",
15773
- "ChatMessage": "http://litepub.social/ns#ChatMessage",
15774
- "quoteUrl": "as:quoteUrl",
15775
- "_misskey_quote": "misskey:_misskey_quote",
15776
- "quoteUri": "fedibird:quoteUri",
15777
- },
15778
- ];
15779
- return result;
15780
- }
15781
15522
  // deno-lint-ignore no-unused-vars prefer-const
15782
15523
  let array;
15783
15524
  const baseValues = await super.toJsonLd({
@@ -15794,9 +15535,9 @@ export class Create extends Activity {
15794
15535
  }
15795
15536
  const docContext = options.context ??
15796
15537
  [
15538
+ "https://w3id.org/identity/v1",
15797
15539
  "https://www.w3.org/ns/activitystreams",
15798
15540
  "https://w3id.org/security/data-integrity/v1",
15799
- "https://w3id.org/identity/v1",
15800
15541
  {
15801
15542
  "toot": "http://joinmastodon.org/ns#",
15802
15543
  "misskey": "https://misskey-hub.net/ns#",
@@ -15862,7 +15603,8 @@ export class Create extends Activity {
15862
15603
  // deno-lint-ignore no-explicit-any
15863
15604
  (expanded[0] ?? {});
15864
15605
  }
15865
- if ("@type" in values) {
15606
+ if ("@type" in values &&
15607
+ !values["@type"].every((t) => t.startsWith("_:"))) {
15866
15608
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Create")) {
15867
15609
  throw new TypeError("Invalid type: " + values["@type"]);
15868
15610
  }
@@ -15950,37 +15692,6 @@ export class Delete extends Activity {
15950
15692
  ...options,
15951
15693
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
15952
15694
  };
15953
- if (options.format == null && this.isCompactable()) {
15954
- const result = await super.toJsonLd({
15955
- ...options,
15956
- format: undefined,
15957
- context: undefined,
15958
- });
15959
- // deno-lint-ignore no-unused-vars
15960
- let compactItems;
15961
- result["type"] = "Delete";
15962
- if (this.id != null)
15963
- result["id"] = this.id.href;
15964
- result["@context"] = [
15965
- "https://www.w3.org/ns/activitystreams",
15966
- "https://w3id.org/security/data-integrity/v1",
15967
- "https://w3id.org/identity/v1",
15968
- {
15969
- "toot": "http://joinmastodon.org/ns#",
15970
- "misskey": "https://misskey-hub.net/ns#",
15971
- "fedibird": "http://fedibird.com/ns#",
15972
- "sensitive": "as:sensitive",
15973
- "votersCount": "toot:votersCount",
15974
- "Emoji": "toot:Emoji",
15975
- "Hashtag": "as:Hashtag",
15976
- "ChatMessage": "http://litepub.social/ns#ChatMessage",
15977
- "quoteUrl": "as:quoteUrl",
15978
- "_misskey_quote": "misskey:_misskey_quote",
15979
- "quoteUri": "fedibird:quoteUri",
15980
- },
15981
- ];
15982
- return result;
15983
- }
15984
15695
  // deno-lint-ignore no-unused-vars prefer-const
15985
15696
  let array;
15986
15697
  const baseValues = await super.toJsonLd({
@@ -15997,9 +15708,9 @@ export class Delete extends Activity {
15997
15708
  }
15998
15709
  const docContext = options.context ??
15999
15710
  [
15711
+ "https://w3id.org/identity/v1",
16000
15712
  "https://www.w3.org/ns/activitystreams",
16001
15713
  "https://w3id.org/security/data-integrity/v1",
16002
- "https://w3id.org/identity/v1",
16003
15714
  {
16004
15715
  "toot": "http://joinmastodon.org/ns#",
16005
15716
  "misskey": "https://misskey-hub.net/ns#",
@@ -16065,7 +15776,8 @@ export class Delete extends Activity {
16065
15776
  // deno-lint-ignore no-explicit-any
16066
15777
  (expanded[0] ?? {});
16067
15778
  }
16068
- if ("@type" in values) {
15779
+ if ("@type" in values &&
15780
+ !values["@type"].every((t) => t.startsWith("_:"))) {
16069
15781
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Delete")) {
16070
15782
  throw new TypeError("Invalid type: " + values["@type"]);
16071
15783
  }
@@ -16152,24 +15864,6 @@ export class Dislike extends Activity {
16152
15864
  ...options,
16153
15865
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
16154
15866
  };
16155
- if (options.format == null && this.isCompactable()) {
16156
- const result = await super.toJsonLd({
16157
- ...options,
16158
- format: undefined,
16159
- context: undefined,
16160
- });
16161
- // deno-lint-ignore no-unused-vars
16162
- let compactItems;
16163
- result["type"] = "Dislike";
16164
- if (this.id != null)
16165
- result["id"] = this.id.href;
16166
- result["@context"] = [
16167
- "https://www.w3.org/ns/activitystreams",
16168
- "https://w3id.org/security/data-integrity/v1",
16169
- "https://w3id.org/identity/v1",
16170
- ];
16171
- return result;
16172
- }
16173
15867
  // deno-lint-ignore no-unused-vars prefer-const
16174
15868
  let array;
16175
15869
  const baseValues = await super.toJsonLd({
@@ -16186,9 +15880,9 @@ export class Dislike extends Activity {
16186
15880
  }
16187
15881
  const docContext = options.context ??
16188
15882
  [
15883
+ "https://w3id.org/identity/v1",
16189
15884
  "https://www.w3.org/ns/activitystreams",
16190
15885
  "https://w3id.org/security/data-integrity/v1",
16191
- "https://w3id.org/identity/v1",
16192
15886
  ];
16193
15887
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
16194
15888
  if (docContext != null) {
@@ -16241,7 +15935,8 @@ export class Dislike extends Activity {
16241
15935
  // deno-lint-ignore no-explicit-any
16242
15936
  (expanded[0] ?? {});
16243
15937
  }
16244
- if ("@type" in values) {
15938
+ if ("@type" in values &&
15939
+ !values["@type"].every((t) => t.startsWith("_:"))) {
16245
15940
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Dislike")) {
16246
15941
  throw new TypeError("Invalid type: " + values["@type"]);
16247
15942
  }
@@ -16747,7 +16442,8 @@ export class Endpoints {
16747
16442
  // deno-lint-ignore no-explicit-any
16748
16443
  (expanded[0] ?? {});
16749
16444
  }
16750
- if ("@type" in values) {
16445
+ if ("@type" in values &&
16446
+ !values["@type"].every((t) => t.startsWith("_:"))) {
16751
16447
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Endpoints")) {
16752
16448
  throw new TypeError("Invalid type: " + values["@type"]);
16753
16449
  }
@@ -17080,7 +16776,8 @@ export class Event extends Object {
17080
16776
  // deno-lint-ignore no-explicit-any
17081
16777
  (expanded[0] ?? {});
17082
16778
  }
17083
- if ("@type" in values) {
16779
+ if ("@type" in values &&
16780
+ !values["@type"].every((t) => t.startsWith("_:"))) {
17084
16781
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Event")) {
17085
16782
  throw new TypeError("Invalid type: " + values["@type"]);
17086
16783
  }
@@ -17169,24 +16866,6 @@ export class Flag extends Activity {
17169
16866
  ...options,
17170
16867
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
17171
16868
  };
17172
- if (options.format == null && this.isCompactable()) {
17173
- const result = await super.toJsonLd({
17174
- ...options,
17175
- format: undefined,
17176
- context: undefined,
17177
- });
17178
- // deno-lint-ignore no-unused-vars
17179
- let compactItems;
17180
- result["type"] = "Flag";
17181
- if (this.id != null)
17182
- result["id"] = this.id.href;
17183
- result["@context"] = [
17184
- "https://www.w3.org/ns/activitystreams",
17185
- "https://w3id.org/security/data-integrity/v1",
17186
- "https://w3id.org/identity/v1",
17187
- ];
17188
- return result;
17189
- }
17190
16869
  // deno-lint-ignore no-unused-vars prefer-const
17191
16870
  let array;
17192
16871
  const baseValues = await super.toJsonLd({
@@ -17203,9 +16882,9 @@ export class Flag extends Activity {
17203
16882
  }
17204
16883
  const docContext = options.context ??
17205
16884
  [
16885
+ "https://w3id.org/identity/v1",
17206
16886
  "https://www.w3.org/ns/activitystreams",
17207
16887
  "https://w3id.org/security/data-integrity/v1",
17208
- "https://w3id.org/identity/v1",
17209
16888
  ];
17210
16889
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
17211
16890
  if (docContext != null) {
@@ -17258,7 +16937,8 @@ export class Flag extends Activity {
17258
16937
  // deno-lint-ignore no-explicit-any
17259
16938
  (expanded[0] ?? {});
17260
16939
  }
17261
- if ("@type" in values) {
16940
+ if ("@type" in values &&
16941
+ !values["@type"].every((t) => t.startsWith("_:"))) {
17262
16942
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Flag")) {
17263
16943
  throw new TypeError("Invalid type: " + values["@type"]);
17264
16944
  }
@@ -17348,24 +17028,6 @@ export class Follow extends Activity {
17348
17028
  ...options,
17349
17029
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
17350
17030
  };
17351
- if (options.format == null && this.isCompactable()) {
17352
- const result = await super.toJsonLd({
17353
- ...options,
17354
- format: undefined,
17355
- context: undefined,
17356
- });
17357
- // deno-lint-ignore no-unused-vars
17358
- let compactItems;
17359
- result["type"] = "Follow";
17360
- if (this.id != null)
17361
- result["id"] = this.id.href;
17362
- result["@context"] = [
17363
- "https://www.w3.org/ns/activitystreams",
17364
- "https://w3id.org/security/data-integrity/v1",
17365
- "https://w3id.org/identity/v1",
17366
- ];
17367
- return result;
17368
- }
17369
17031
  // deno-lint-ignore no-unused-vars prefer-const
17370
17032
  let array;
17371
17033
  const baseValues = await super.toJsonLd({
@@ -17382,9 +17044,9 @@ export class Follow extends Activity {
17382
17044
  }
17383
17045
  const docContext = options.context ??
17384
17046
  [
17047
+ "https://w3id.org/identity/v1",
17385
17048
  "https://www.w3.org/ns/activitystreams",
17386
17049
  "https://w3id.org/security/data-integrity/v1",
17387
- "https://w3id.org/identity/v1",
17388
17050
  ];
17389
17051
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
17390
17052
  if (docContext != null) {
@@ -17437,7 +17099,8 @@ export class Follow extends Activity {
17437
17099
  // deno-lint-ignore no-explicit-any
17438
17100
  (expanded[0] ?? {});
17439
17101
  }
17440
- if ("@type" in values) {
17102
+ if ("@type" in values &&
17103
+ !values["@type"].every((t) => t.startsWith("_:"))) {
17441
17104
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Follow")) {
17442
17105
  throw new TypeError("Invalid type: " + values["@type"]);
17443
17106
  }
@@ -19586,7 +19249,8 @@ export class Group extends Object {
19586
19249
  // deno-lint-ignore no-explicit-any
19587
19250
  (expanded[0] ?? {});
19588
19251
  }
19589
- if ("@type" in values) {
19252
+ if ("@type" in values &&
19253
+ !values["@type"].every((t) => t.startsWith("_:"))) {
19590
19254
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Group")) {
19591
19255
  throw new TypeError("Invalid type: " + values["@type"]);
19592
19256
  }
@@ -20944,7 +20608,8 @@ export class Link {
20944
20608
  // deno-lint-ignore no-explicit-any
20945
20609
  (expanded[0] ?? {});
20946
20610
  }
20947
- if ("@type" in values) {
20611
+ if ("@type" in values &&
20612
+ !values["@type"].every((t) => t.startsWith("_:"))) {
20948
20613
  if (values["@type"].includes("https://www.w3.org/ns/activitystreams#Hashtag")) {
20949
20614
  return await Hashtag.fromJsonLd(json, options);
20950
20615
  }
@@ -21415,7 +21080,8 @@ export class Hashtag extends Link {
21415
21080
  // deno-lint-ignore no-explicit-any
21416
21081
  (expanded[0] ?? {});
21417
21082
  }
21418
- if ("@type" in values) {
21083
+ if ("@type" in values &&
21084
+ !values["@type"].every((t) => t.startsWith("_:"))) {
21419
21085
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Hashtag")) {
21420
21086
  throw new TypeError("Invalid type: " + values["@type"]);
21421
21087
  }
@@ -21583,7 +21249,8 @@ export class Image extends Document {
21583
21249
  // deno-lint-ignore no-explicit-any
21584
21250
  (expanded[0] ?? {});
21585
21251
  }
21586
- if ("@type" in values) {
21252
+ if ("@type" in values &&
21253
+ !values["@type"].every((t) => t.startsWith("_:"))) {
21587
21254
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Image")) {
21588
21255
  throw new TypeError("Invalid type: " + values["@type"]);
21589
21256
  }
@@ -21672,24 +21339,169 @@ export class Offer extends Activity {
21672
21339
  ...options,
21673
21340
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
21674
21341
  };
21675
- if (options.format == null && this.isCompactable()) {
21676
- const result = await super.toJsonLd({
21677
- ...options,
21678
- format: undefined,
21679
- context: undefined,
21680
- });
21681
- // deno-lint-ignore no-unused-vars
21682
- let compactItems;
21683
- result["type"] = "Offer";
21684
- if (this.id != null)
21685
- result["id"] = this.id.href;
21686
- result["@context"] = [
21342
+ // deno-lint-ignore no-unused-vars prefer-const
21343
+ let array;
21344
+ const baseValues = await super.toJsonLd({
21345
+ ...options,
21346
+ format: "expand",
21347
+ context: undefined,
21348
+ });
21349
+ const values = baseValues[0];
21350
+ values["@type"] = ["https://www.w3.org/ns/activitystreams#Offer"];
21351
+ if (this.id != null)
21352
+ values["@id"] = this.id.href;
21353
+ if (options.format === "expand") {
21354
+ return await jsonld.expand(values, { documentLoader: options.contextLoader });
21355
+ }
21356
+ const docContext = options.context ??
21357
+ [
21358
+ "https://w3id.org/identity/v1",
21687
21359
  "https://www.w3.org/ns/activitystreams",
21688
21360
  "https://w3id.org/security/data-integrity/v1",
21689
- "https://w3id.org/identity/v1",
21690
21361
  ];
21691
- return result;
21362
+ const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
21363
+ if (docContext != null) {
21364
+ // Embed context
21365
+ if ("proof" in compacted &&
21366
+ compacted.proof != null) {
21367
+ if (Array.isArray(compacted.proof)) {
21368
+ for (const element of compacted.proof) {
21369
+ element["@context"] = docContext;
21370
+ }
21371
+ }
21372
+ else {
21373
+ compacted.proof["@context"] = docContext;
21374
+ }
21375
+ }
21376
+ }
21377
+ return compacted;
21378
+ }
21379
+ isCompactable() {
21380
+ return super.isCompactable();
21381
+ }
21382
+ /**
21383
+ * Converts a JSON-LD structure to an object of this type.
21384
+ * @param json The JSON-LD structure to convert.
21385
+ * @returns The object of this type.
21386
+ * @throws {TypeError} If the given `json` is invalid.
21387
+ */
21388
+ static async fromJsonLd(json, options = {}) {
21389
+ if (typeof json === "undefined") {
21390
+ throw new TypeError("Invalid JSON-LD: undefined.");
21391
+ }
21392
+ else if (json === null)
21393
+ throw new TypeError("Invalid JSON-LD: null.");
21394
+ options = {
21395
+ ...options,
21396
+ documentLoader: options.documentLoader ?? fetchDocumentLoader,
21397
+ contextLoader: options.contextLoader ?? fetchDocumentLoader,
21398
+ };
21399
+ // deno-lint-ignore no-explicit-any
21400
+ let values;
21401
+ if (globalThis.Object.keys(json).length == 0) {
21402
+ values = {};
21403
+ }
21404
+ else {
21405
+ const expanded = await jsonld.expand(json, {
21406
+ documentLoader: options.contextLoader,
21407
+ keepFreeFloatingNodes: true,
21408
+ });
21409
+ values =
21410
+ // deno-lint-ignore no-explicit-any
21411
+ (expanded[0] ?? {});
21692
21412
  }
21413
+ if ("@type" in values &&
21414
+ !values["@type"].every((t) => t.startsWith("_:"))) {
21415
+ if (values["@type"].includes("https://www.w3.org/ns/activitystreams#Invite")) {
21416
+ return await Invite.fromJsonLd(json, options);
21417
+ }
21418
+ if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Offer")) {
21419
+ throw new TypeError("Invalid type: " + values["@type"]);
21420
+ }
21421
+ }
21422
+ delete values["@type"];
21423
+ const instance = await super.fromJsonLd(values, {
21424
+ ...options,
21425
+ // @ts-ignore: an internal option
21426
+ _fromSubclass: true,
21427
+ });
21428
+ if (!(instance instanceof Offer)) {
21429
+ throw new TypeError("Unexpected type: " + instance.constructor.name);
21430
+ }
21431
+ if (!("_fromSubclass" in options) || !options._fromSubclass) {
21432
+ try {
21433
+ instance.#cachedJsonLd = structuredClone(json);
21434
+ }
21435
+ catch {
21436
+ getLogger(["fedify", "vocab"]).warn("Failed to cache JSON-LD: {json}", { json });
21437
+ }
21438
+ }
21439
+ return instance;
21440
+ }
21441
+ _getCustomInspectProxy() {
21442
+ const proxy = super._getCustomInspectProxy();
21443
+ return proxy;
21444
+ }
21445
+ [Symbol.for("Deno.customInspect")](inspect, options) {
21446
+ const proxy = this._getCustomInspectProxy();
21447
+ return "Offer " + inspect(proxy, options);
21448
+ }
21449
+ [Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
21450
+ const proxy = this._getCustomInspectProxy();
21451
+ return "Offer " + inspect(proxy, options);
21452
+ }
21453
+ }
21454
+ /** A specialization of `Offer` in which the `actor` is extending an invitation
21455
+ * for the `object` to the `target`.
21456
+ */
21457
+ export class Invite extends Offer {
21458
+ #cachedJsonLd;
21459
+ /**
21460
+ * The type URI of {@link Invite}: `https://www.w3.org/ns/activitystreams#Invite`.
21461
+ */
21462
+ static get typeId() {
21463
+ return new URL("https://www.w3.org/ns/activitystreams#Invite");
21464
+ }
21465
+ /**
21466
+ * Constructs a new instance of Invite with the given values.
21467
+ * @param values The values to initialize the instance with.
21468
+ * @param options The options to use for initialization.
21469
+ */
21470
+ constructor(values, { documentLoader, contextLoader, } = {}) {
21471
+ super(values, { documentLoader, contextLoader });
21472
+ }
21473
+ /**
21474
+ * Clones this instance, optionally updating it with the given values.
21475
+ * @param values The values to update the clone with.
21476
+ * @options The options to use for cloning.
21477
+ * @returns The cloned instance.
21478
+ */
21479
+ clone(values = {}, options = {}) {
21480
+ const clone = super.clone(values, options);
21481
+ return clone;
21482
+ }
21483
+ /**
21484
+ * Converts this object to a JSON-LD structure.
21485
+ * @param options The options to use.
21486
+ * - `format`: The format of the output: `compact` or
21487
+ `expand`.
21488
+ * - `contextLoader`: The loader for remote JSON-LD contexts.
21489
+ * - `context`: The JSON-LD context to use. Not applicable
21490
+ when `format` is set to `'expand'`.
21491
+ * @returns The JSON-LD representation of this object.
21492
+ */
21493
+ async toJsonLd(options = {}) {
21494
+ if (options.format == null && this.#cachedJsonLd != null) {
21495
+ return this.#cachedJsonLd;
21496
+ }
21497
+ if (options.format !== "compact" && options.context != null) {
21498
+ throw new TypeError("The context option can only be used when the format option is set " +
21499
+ "to 'compact'.");
21500
+ }
21501
+ options = {
21502
+ ...options,
21503
+ contextLoader: options.contextLoader ?? fetchDocumentLoader,
21504
+ };
21693
21505
  // deno-lint-ignore no-unused-vars prefer-const
21694
21506
  let array;
21695
21507
  const baseValues = await super.toJsonLd({
@@ -21698,7 +21510,7 @@ export class Offer extends Activity {
21698
21510
  context: undefined,
21699
21511
  });
21700
21512
  const values = baseValues[0];
21701
- values["@type"] = ["https://www.w3.org/ns/activitystreams#Offer"];
21513
+ values["@type"] = ["https://www.w3.org/ns/activitystreams#Invite"];
21702
21514
  if (this.id != null)
21703
21515
  values["@id"] = this.id.href;
21704
21516
  if (options.format === "expand") {
@@ -21706,9 +21518,9 @@ export class Offer extends Activity {
21706
21518
  }
21707
21519
  const docContext = options.context ??
21708
21520
  [
21521
+ "https://w3id.org/identity/v1",
21709
21522
  "https://www.w3.org/ns/activitystreams",
21710
21523
  "https://w3id.org/security/data-integrity/v1",
21711
- "https://w3id.org/identity/v1",
21712
21524
  ];
21713
21525
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
21714
21526
  if (docContext != null) {
@@ -21761,11 +21573,9 @@ export class Offer extends Activity {
21761
21573
  // deno-lint-ignore no-explicit-any
21762
21574
  (expanded[0] ?? {});
21763
21575
  }
21764
- if ("@type" in values) {
21765
- if (values["@type"].includes("https://www.w3.org/ns/activitystreams#Invite")) {
21766
- return await Invite.fromJsonLd(json, options);
21767
- }
21768
- if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Offer")) {
21576
+ if ("@type" in values &&
21577
+ !values["@type"].every((t) => t.startsWith("_:"))) {
21578
+ if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Invite")) {
21769
21579
  throw new TypeError("Invalid type: " + values["@type"]);
21770
21580
  }
21771
21581
  }
@@ -21775,7 +21585,7 @@ export class Offer extends Activity {
21775
21585
  // @ts-ignore: an internal option
21776
21586
  _fromSubclass: true,
21777
21587
  });
21778
- if (!(instance instanceof Offer)) {
21588
+ if (!(instance instanceof Invite)) {
21779
21589
  throw new TypeError("Unexpected type: " + instance.constructor.name);
21780
21590
  }
21781
21591
  if (!("_fromSubclass" in options) || !options._fromSubclass) {
@@ -21794,26 +21604,26 @@ export class Offer extends Activity {
21794
21604
  }
21795
21605
  [Symbol.for("Deno.customInspect")](inspect, options) {
21796
21606
  const proxy = this._getCustomInspectProxy();
21797
- return "Offer " + inspect(proxy, options);
21607
+ return "Invite " + inspect(proxy, options);
21798
21608
  }
21799
21609
  [Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
21800
21610
  const proxy = this._getCustomInspectProxy();
21801
- return "Offer " + inspect(proxy, options);
21611
+ return "Invite " + inspect(proxy, options);
21802
21612
  }
21803
21613
  }
21804
- /** A specialization of `Offer` in which the `actor` is extending an invitation
21805
- * for the `object` to the `target`.
21614
+ /** Indicates that the `actor` has joined the `object`.
21615
+ * The `target` and `origin` typically have no defined meaning.
21806
21616
  */
21807
- export class Invite extends Offer {
21617
+ export class Join extends Activity {
21808
21618
  #cachedJsonLd;
21809
21619
  /**
21810
- * The type URI of {@link Invite}: `https://www.w3.org/ns/activitystreams#Invite`.
21620
+ * The type URI of {@link Join}: `https://www.w3.org/ns/activitystreams#Join`.
21811
21621
  */
21812
21622
  static get typeId() {
21813
- return new URL("https://www.w3.org/ns/activitystreams#Invite");
21623
+ return new URL("https://www.w3.org/ns/activitystreams#Join");
21814
21624
  }
21815
21625
  /**
21816
- * Constructs a new instance of Invite with the given values.
21626
+ * Constructs a new instance of Join with the given values.
21817
21627
  * @param values The values to initialize the instance with.
21818
21628
  * @param options The options to use for initialization.
21819
21629
  */
@@ -21852,24 +21662,6 @@ export class Invite extends Offer {
21852
21662
  ...options,
21853
21663
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
21854
21664
  };
21855
- if (options.format == null && this.isCompactable()) {
21856
- const result = await super.toJsonLd({
21857
- ...options,
21858
- format: undefined,
21859
- context: undefined,
21860
- });
21861
- // deno-lint-ignore no-unused-vars
21862
- let compactItems;
21863
- result["type"] = "Invite";
21864
- if (this.id != null)
21865
- result["id"] = this.id.href;
21866
- result["@context"] = [
21867
- "https://www.w3.org/ns/activitystreams",
21868
- "https://w3id.org/security/data-integrity/v1",
21869
- "https://w3id.org/identity/v1",
21870
- ];
21871
- return result;
21872
- }
21873
21665
  // deno-lint-ignore no-unused-vars prefer-const
21874
21666
  let array;
21875
21667
  const baseValues = await super.toJsonLd({
@@ -21878,7 +21670,7 @@ export class Invite extends Offer {
21878
21670
  context: undefined,
21879
21671
  });
21880
21672
  const values = baseValues[0];
21881
- values["@type"] = ["https://www.w3.org/ns/activitystreams#Invite"];
21673
+ values["@type"] = ["https://www.w3.org/ns/activitystreams#Join"];
21882
21674
  if (this.id != null)
21883
21675
  values["@id"] = this.id.href;
21884
21676
  if (options.format === "expand") {
@@ -21886,9 +21678,9 @@ export class Invite extends Offer {
21886
21678
  }
21887
21679
  const docContext = options.context ??
21888
21680
  [
21681
+ "https://w3id.org/identity/v1",
21889
21682
  "https://www.w3.org/ns/activitystreams",
21890
21683
  "https://w3id.org/security/data-integrity/v1",
21891
- "https://w3id.org/identity/v1",
21892
21684
  ];
21893
21685
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
21894
21686
  if (docContext != null) {
@@ -21941,8 +21733,9 @@ export class Invite extends Offer {
21941
21733
  // deno-lint-ignore no-explicit-any
21942
21734
  (expanded[0] ?? {});
21943
21735
  }
21944
- if ("@type" in values) {
21945
- if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Invite")) {
21736
+ if ("@type" in values &&
21737
+ !values["@type"].every((t) => t.startsWith("_:"))) {
21738
+ if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Join")) {
21946
21739
  throw new TypeError("Invalid type: " + values["@type"]);
21947
21740
  }
21948
21741
  }
@@ -21952,7 +21745,7 @@ export class Invite extends Offer {
21952
21745
  // @ts-ignore: an internal option
21953
21746
  _fromSubclass: true,
21954
21747
  });
21955
- if (!(instance instanceof Invite)) {
21748
+ if (!(instance instanceof Join)) {
21956
21749
  throw new TypeError("Unexpected type: " + instance.constructor.name);
21957
21750
  }
21958
21751
  if (!("_fromSubclass" in options) || !options._fromSubclass) {
@@ -21971,26 +21764,26 @@ export class Invite extends Offer {
21971
21764
  }
21972
21765
  [Symbol.for("Deno.customInspect")](inspect, options) {
21973
21766
  const proxy = this._getCustomInspectProxy();
21974
- return "Invite " + inspect(proxy, options);
21767
+ return "Join " + inspect(proxy, options);
21975
21768
  }
21976
21769
  [Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
21977
21770
  const proxy = this._getCustomInspectProxy();
21978
- return "Invite " + inspect(proxy, options);
21771
+ return "Join " + inspect(proxy, options);
21979
21772
  }
21980
21773
  }
21981
- /** Indicates that the `actor` has joined the `object`.
21982
- * The `target` and `origin` typically have no defined meaning.
21774
+ /** Indicates that the `actor` has left the `object`.
21775
+ * The `target` and `origin` typically have no meaning.
21983
21776
  */
21984
- export class Join extends Activity {
21777
+ export class Leave extends Activity {
21985
21778
  #cachedJsonLd;
21986
21779
  /**
21987
- * The type URI of {@link Join}: `https://www.w3.org/ns/activitystreams#Join`.
21780
+ * The type URI of {@link Leave}: `https://www.w3.org/ns/activitystreams#Leave`.
21988
21781
  */
21989
21782
  static get typeId() {
21990
- return new URL("https://www.w3.org/ns/activitystreams#Join");
21783
+ return new URL("https://www.w3.org/ns/activitystreams#Leave");
21991
21784
  }
21992
21785
  /**
21993
- * Constructs a new instance of Join with the given values.
21786
+ * Constructs a new instance of Leave with the given values.
21994
21787
  * @param values The values to initialize the instance with.
21995
21788
  * @param options The options to use for initialization.
21996
21789
  */
@@ -22029,24 +21822,6 @@ export class Join extends Activity {
22029
21822
  ...options,
22030
21823
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
22031
21824
  };
22032
- if (options.format == null && this.isCompactable()) {
22033
- const result = await super.toJsonLd({
22034
- ...options,
22035
- format: undefined,
22036
- context: undefined,
22037
- });
22038
- // deno-lint-ignore no-unused-vars
22039
- let compactItems;
22040
- result["type"] = "Join";
22041
- if (this.id != null)
22042
- result["id"] = this.id.href;
22043
- result["@context"] = [
22044
- "https://www.w3.org/ns/activitystreams",
22045
- "https://w3id.org/security/data-integrity/v1",
22046
- "https://w3id.org/identity/v1",
22047
- ];
22048
- return result;
22049
- }
22050
21825
  // deno-lint-ignore no-unused-vars prefer-const
22051
21826
  let array;
22052
21827
  const baseValues = await super.toJsonLd({
@@ -22055,7 +21830,7 @@ export class Join extends Activity {
22055
21830
  context: undefined,
22056
21831
  });
22057
21832
  const values = baseValues[0];
22058
- values["@type"] = ["https://www.w3.org/ns/activitystreams#Join"];
21833
+ values["@type"] = ["https://www.w3.org/ns/activitystreams#Leave"];
22059
21834
  if (this.id != null)
22060
21835
  values["@id"] = this.id.href;
22061
21836
  if (options.format === "expand") {
@@ -22063,9 +21838,9 @@ export class Join extends Activity {
22063
21838
  }
22064
21839
  const docContext = options.context ??
22065
21840
  [
21841
+ "https://w3id.org/identity/v1",
22066
21842
  "https://www.w3.org/ns/activitystreams",
22067
21843
  "https://w3id.org/security/data-integrity/v1",
22068
- "https://w3id.org/identity/v1",
22069
21844
  ];
22070
21845
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
22071
21846
  if (docContext != null) {
@@ -22118,8 +21893,9 @@ export class Join extends Activity {
22118
21893
  // deno-lint-ignore no-explicit-any
22119
21894
  (expanded[0] ?? {});
22120
21895
  }
22121
- if ("@type" in values) {
22122
- if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Join")) {
21896
+ if ("@type" in values &&
21897
+ !values["@type"].every((t) => t.startsWith("_:"))) {
21898
+ if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Leave")) {
22123
21899
  throw new TypeError("Invalid type: " + values["@type"]);
22124
21900
  }
22125
21901
  }
@@ -22129,7 +21905,7 @@ export class Join extends Activity {
22129
21905
  // @ts-ignore: an internal option
22130
21906
  _fromSubclass: true,
22131
21907
  });
22132
- if (!(instance instanceof Join)) {
21908
+ if (!(instance instanceof Leave)) {
22133
21909
  throw new TypeError("Unexpected type: " + instance.constructor.name);
22134
21910
  }
22135
21911
  if (!("_fromSubclass" in options) || !options._fromSubclass) {
@@ -22148,26 +21924,26 @@ export class Join extends Activity {
22148
21924
  }
22149
21925
  [Symbol.for("Deno.customInspect")](inspect, options) {
22150
21926
  const proxy = this._getCustomInspectProxy();
22151
- return "Join " + inspect(proxy, options);
21927
+ return "Leave " + inspect(proxy, options);
22152
21928
  }
22153
21929
  [Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
22154
21930
  const proxy = this._getCustomInspectProxy();
22155
- return "Join " + inspect(proxy, options);
21931
+ return "Leave " + inspect(proxy, options);
22156
21932
  }
22157
21933
  }
22158
- /** Indicates that the `actor` has left the `object`.
22159
- * The `target` and `origin` typically have no meaning.
21934
+ /** Indicates that the `actor` likes, recommends or endorses the `object`.
21935
+ * The `target` and `origin` typically have no defined meaning.
22160
21936
  */
22161
- export class Leave extends Activity {
21937
+ export class Like extends Activity {
22162
21938
  #cachedJsonLd;
22163
21939
  /**
22164
- * The type URI of {@link Leave}: `https://www.w3.org/ns/activitystreams#Leave`.
21940
+ * The type URI of {@link Like}: `https://www.w3.org/ns/activitystreams#Like`.
22165
21941
  */
22166
21942
  static get typeId() {
22167
- return new URL("https://www.w3.org/ns/activitystreams#Leave");
21943
+ return new URL("https://www.w3.org/ns/activitystreams#Like");
22168
21944
  }
22169
21945
  /**
22170
- * Constructs a new instance of Leave with the given values.
21946
+ * Constructs a new instance of Like with the given values.
22171
21947
  * @param values The values to initialize the instance with.
22172
21948
  * @param options The options to use for initialization.
22173
21949
  */
@@ -22206,24 +21982,6 @@ export class Leave extends Activity {
22206
21982
  ...options,
22207
21983
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
22208
21984
  };
22209
- if (options.format == null && this.isCompactable()) {
22210
- const result = await super.toJsonLd({
22211
- ...options,
22212
- format: undefined,
22213
- context: undefined,
22214
- });
22215
- // deno-lint-ignore no-unused-vars
22216
- let compactItems;
22217
- result["type"] = "Leave";
22218
- if (this.id != null)
22219
- result["id"] = this.id.href;
22220
- result["@context"] = [
22221
- "https://www.w3.org/ns/activitystreams",
22222
- "https://w3id.org/security/data-integrity/v1",
22223
- "https://w3id.org/identity/v1",
22224
- ];
22225
- return result;
22226
- }
22227
21985
  // deno-lint-ignore no-unused-vars prefer-const
22228
21986
  let array;
22229
21987
  const baseValues = await super.toJsonLd({
@@ -22232,7 +21990,7 @@ export class Leave extends Activity {
22232
21990
  context: undefined,
22233
21991
  });
22234
21992
  const values = baseValues[0];
22235
- values["@type"] = ["https://www.w3.org/ns/activitystreams#Leave"];
21993
+ values["@type"] = ["https://www.w3.org/ns/activitystreams#Like"];
22236
21994
  if (this.id != null)
22237
21995
  values["@id"] = this.id.href;
22238
21996
  if (options.format === "expand") {
@@ -22240,9 +21998,9 @@ export class Leave extends Activity {
22240
21998
  }
22241
21999
  const docContext = options.context ??
22242
22000
  [
22001
+ "https://w3id.org/identity/v1",
22243
22002
  "https://www.w3.org/ns/activitystreams",
22244
22003
  "https://w3id.org/security/data-integrity/v1",
22245
- "https://w3id.org/identity/v1",
22246
22004
  ];
22247
22005
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
22248
22006
  if (docContext != null) {
@@ -22295,8 +22053,9 @@ export class Leave extends Activity {
22295
22053
  // deno-lint-ignore no-explicit-any
22296
22054
  (expanded[0] ?? {});
22297
22055
  }
22298
- if ("@type" in values) {
22299
- if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Leave")) {
22056
+ if ("@type" in values &&
22057
+ !values["@type"].every((t) => t.startsWith("_:"))) {
22058
+ if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Like")) {
22300
22059
  throw new TypeError("Invalid type: " + values["@type"]);
22301
22060
  }
22302
22061
  }
@@ -22306,7 +22065,7 @@ export class Leave extends Activity {
22306
22065
  // @ts-ignore: an internal option
22307
22066
  _fromSubclass: true,
22308
22067
  });
22309
- if (!(instance instanceof Leave)) {
22068
+ if (!(instance instanceof Like)) {
22310
22069
  throw new TypeError("Unexpected type: " + instance.constructor.name);
22311
22070
  }
22312
22071
  if (!("_fromSubclass" in options) || !options._fromSubclass) {
@@ -22325,26 +22084,25 @@ export class Leave extends Activity {
22325
22084
  }
22326
22085
  [Symbol.for("Deno.customInspect")](inspect, options) {
22327
22086
  const proxy = this._getCustomInspectProxy();
22328
- return "Leave " + inspect(proxy, options);
22087
+ return "Like " + inspect(proxy, options);
22329
22088
  }
22330
22089
  [Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
22331
22090
  const proxy = this._getCustomInspectProxy();
22332
- return "Leave " + inspect(proxy, options);
22091
+ return "Like " + inspect(proxy, options);
22333
22092
  }
22334
22093
  }
22335
- /** Indicates that the `actor` likes, recommends or endorses the `object`.
22336
- * The `target` and `origin` typically have no defined meaning.
22094
+ /** Indicates that the `actor` has listened to the `object`.
22337
22095
  */
22338
- export class Like extends Activity {
22096
+ export class Listen extends Activity {
22339
22097
  #cachedJsonLd;
22340
22098
  /**
22341
- * The type URI of {@link Like}: `https://www.w3.org/ns/activitystreams#Like`.
22099
+ * The type URI of {@link Listen}: `https://www.w3.org/ns/activitystreams#Listen`.
22342
22100
  */
22343
22101
  static get typeId() {
22344
- return new URL("https://www.w3.org/ns/activitystreams#Like");
22102
+ return new URL("https://www.w3.org/ns/activitystreams#Listen");
22345
22103
  }
22346
22104
  /**
22347
- * Constructs a new instance of Like with the given values.
22105
+ * Constructs a new instance of Listen with the given values.
22348
22106
  * @param values The values to initialize the instance with.
22349
22107
  * @param options The options to use for initialization.
22350
22108
  */
@@ -22383,24 +22141,6 @@ export class Like extends Activity {
22383
22141
  ...options,
22384
22142
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
22385
22143
  };
22386
- if (options.format == null && this.isCompactable()) {
22387
- const result = await super.toJsonLd({
22388
- ...options,
22389
- format: undefined,
22390
- context: undefined,
22391
- });
22392
- // deno-lint-ignore no-unused-vars
22393
- let compactItems;
22394
- result["type"] = "Like";
22395
- if (this.id != null)
22396
- result["id"] = this.id.href;
22397
- result["@context"] = [
22398
- "https://www.w3.org/ns/activitystreams",
22399
- "https://w3id.org/security/data-integrity/v1",
22400
- "https://w3id.org/identity/v1",
22401
- ];
22402
- return result;
22403
- }
22404
22144
  // deno-lint-ignore no-unused-vars prefer-const
22405
22145
  let array;
22406
22146
  const baseValues = await super.toJsonLd({
@@ -22409,7 +22149,7 @@ export class Like extends Activity {
22409
22149
  context: undefined,
22410
22150
  });
22411
22151
  const values = baseValues[0];
22412
- values["@type"] = ["https://www.w3.org/ns/activitystreams#Like"];
22152
+ values["@type"] = ["https://www.w3.org/ns/activitystreams#Listen"];
22413
22153
  if (this.id != null)
22414
22154
  values["@id"] = this.id.href;
22415
22155
  if (options.format === "expand") {
@@ -22417,9 +22157,9 @@ export class Like extends Activity {
22417
22157
  }
22418
22158
  const docContext = options.context ??
22419
22159
  [
22160
+ "https://w3id.org/identity/v1",
22420
22161
  "https://www.w3.org/ns/activitystreams",
22421
22162
  "https://w3id.org/security/data-integrity/v1",
22422
- "https://w3id.org/identity/v1",
22423
22163
  ];
22424
22164
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
22425
22165
  if (docContext != null) {
@@ -22472,8 +22212,9 @@ export class Like extends Activity {
22472
22212
  // deno-lint-ignore no-explicit-any
22473
22213
  (expanded[0] ?? {});
22474
22214
  }
22475
- if ("@type" in values) {
22476
- if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Like")) {
22215
+ if ("@type" in values &&
22216
+ !values["@type"].every((t) => t.startsWith("_:"))) {
22217
+ if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Listen")) {
22477
22218
  throw new TypeError("Invalid type: " + values["@type"]);
22478
22219
  }
22479
22220
  }
@@ -22483,7 +22224,7 @@ export class Like extends Activity {
22483
22224
  // @ts-ignore: an internal option
22484
22225
  _fromSubclass: true,
22485
22226
  });
22486
- if (!(instance instanceof Like)) {
22227
+ if (!(instance instanceof Listen)) {
22487
22228
  throw new TypeError("Unexpected type: " + instance.constructor.name);
22488
22229
  }
22489
22230
  if (!("_fromSubclass" in options) || !options._fromSubclass) {
@@ -22502,25 +22243,25 @@ export class Like extends Activity {
22502
22243
  }
22503
22244
  [Symbol.for("Deno.customInspect")](inspect, options) {
22504
22245
  const proxy = this._getCustomInspectProxy();
22505
- return "Like " + inspect(proxy, options);
22246
+ return "Listen " + inspect(proxy, options);
22506
22247
  }
22507
22248
  [Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
22508
22249
  const proxy = this._getCustomInspectProxy();
22509
- return "Like " + inspect(proxy, options);
22250
+ return "Listen " + inspect(proxy, options);
22510
22251
  }
22511
22252
  }
22512
- /** Indicates that the `actor` has listened to the `object`.
22253
+ /** A specialized {@link Link} that represents an @mention.
22513
22254
  */
22514
- export class Listen extends Activity {
22255
+ export class Mention extends Link {
22515
22256
  #cachedJsonLd;
22516
22257
  /**
22517
- * The type URI of {@link Listen}: `https://www.w3.org/ns/activitystreams#Listen`.
22258
+ * The type URI of {@link Mention}: `https://www.w3.org/ns/activitystreams#Mention`.
22518
22259
  */
22519
22260
  static get typeId() {
22520
- return new URL("https://www.w3.org/ns/activitystreams#Listen");
22261
+ return new URL("https://www.w3.org/ns/activitystreams#Mention");
22521
22262
  }
22522
22263
  /**
22523
- * Constructs a new instance of Listen with the given values.
22264
+ * Constructs a new instance of Mention with the given values.
22524
22265
  * @param values The values to initialize the instance with.
22525
22266
  * @param options The options to use for initialization.
22526
22267
  */
@@ -22567,14 +22308,10 @@ export class Listen extends Activity {
22567
22308
  });
22568
22309
  // deno-lint-ignore no-unused-vars
22569
22310
  let compactItems;
22570
- result["type"] = "Listen";
22311
+ result["type"] = "Mention";
22571
22312
  if (this.id != null)
22572
22313
  result["id"] = this.id.href;
22573
- result["@context"] = [
22574
- "https://www.w3.org/ns/activitystreams",
22575
- "https://w3id.org/security/data-integrity/v1",
22576
- "https://w3id.org/identity/v1",
22577
- ];
22314
+ result["@context"] = "https://www.w3.org/ns/activitystreams";
22578
22315
  return result;
22579
22316
  }
22580
22317
  // deno-lint-ignore no-unused-vars prefer-const
@@ -22585,32 +22322,17 @@ export class Listen extends Activity {
22585
22322
  context: undefined,
22586
22323
  });
22587
22324
  const values = baseValues[0];
22588
- values["@type"] = ["https://www.w3.org/ns/activitystreams#Listen"];
22325
+ values["@type"] = ["https://www.w3.org/ns/activitystreams#Mention"];
22589
22326
  if (this.id != null)
22590
22327
  values["@id"] = this.id.href;
22591
22328
  if (options.format === "expand") {
22592
22329
  return await jsonld.expand(values, { documentLoader: options.contextLoader });
22593
22330
  }
22594
22331
  const docContext = options.context ??
22595
- [
22596
- "https://www.w3.org/ns/activitystreams",
22597
- "https://w3id.org/security/data-integrity/v1",
22598
- "https://w3id.org/identity/v1",
22599
- ];
22332
+ "https://www.w3.org/ns/activitystreams";
22600
22333
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
22601
22334
  if (docContext != null) {
22602
22335
  // Embed context
22603
- if ("proof" in compacted &&
22604
- compacted.proof != null) {
22605
- if (Array.isArray(compacted.proof)) {
22606
- for (const element of compacted.proof) {
22607
- element["@context"] = docContext;
22608
- }
22609
- }
22610
- else {
22611
- compacted.proof["@context"] = docContext;
22612
- }
22613
- }
22614
22336
  }
22615
22337
  return compacted;
22616
22338
  }
@@ -22648,8 +22370,9 @@ export class Listen extends Activity {
22648
22370
  // deno-lint-ignore no-explicit-any
22649
22371
  (expanded[0] ?? {});
22650
22372
  }
22651
- if ("@type" in values) {
22652
- if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Listen")) {
22373
+ if ("@type" in values &&
22374
+ !values["@type"].every((t) => t.startsWith("_:"))) {
22375
+ if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Mention")) {
22653
22376
  throw new TypeError("Invalid type: " + values["@type"]);
22654
22377
  }
22655
22378
  }
@@ -22659,7 +22382,7 @@ export class Listen extends Activity {
22659
22382
  // @ts-ignore: an internal option
22660
22383
  _fromSubclass: true,
22661
22384
  });
22662
- if (!(instance instanceof Listen)) {
22385
+ if (!(instance instanceof Mention)) {
22663
22386
  throw new TypeError("Unexpected type: " + instance.constructor.name);
22664
22387
  }
22665
22388
  if (!("_fromSubclass" in options) || !options._fromSubclass) {
@@ -22678,25 +22401,27 @@ export class Listen extends Activity {
22678
22401
  }
22679
22402
  [Symbol.for("Deno.customInspect")](inspect, options) {
22680
22403
  const proxy = this._getCustomInspectProxy();
22681
- return "Listen " + inspect(proxy, options);
22404
+ return "Mention " + inspect(proxy, options);
22682
22405
  }
22683
22406
  [Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
22684
22407
  const proxy = this._getCustomInspectProxy();
22685
- return "Listen " + inspect(proxy, options);
22408
+ return "Mention " + inspect(proxy, options);
22686
22409
  }
22687
22410
  }
22688
- /** A specialized {@link Link} that represents an @mention.
22411
+ /** Indicates that the `actor` has moved `object` from `origin` to `target`.
22412
+ * If the `origin` or `target` are not specified,
22413
+ * either can be determined by context.
22689
22414
  */
22690
- export class Mention extends Link {
22415
+ export class Move extends Activity {
22691
22416
  #cachedJsonLd;
22692
22417
  /**
22693
- * The type URI of {@link Mention}: `https://www.w3.org/ns/activitystreams#Mention`.
22418
+ * The type URI of {@link Move}: `https://www.w3.org/ns/activitystreams#Move`.
22694
22419
  */
22695
22420
  static get typeId() {
22696
- return new URL("https://www.w3.org/ns/activitystreams#Mention");
22421
+ return new URL("https://www.w3.org/ns/activitystreams#Move");
22697
22422
  }
22698
22423
  /**
22699
- * Constructs a new instance of Mention with the given values.
22424
+ * Constructs a new instance of Move with the given values.
22700
22425
  * @param values The values to initialize the instance with.
22701
22426
  * @param options The options to use for initialization.
22702
22427
  */
@@ -22735,20 +22460,6 @@ export class Mention extends Link {
22735
22460
  ...options,
22736
22461
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
22737
22462
  };
22738
- if (options.format == null && this.isCompactable()) {
22739
- const result = await super.toJsonLd({
22740
- ...options,
22741
- format: undefined,
22742
- context: undefined,
22743
- });
22744
- // deno-lint-ignore no-unused-vars
22745
- let compactItems;
22746
- result["type"] = "Mention";
22747
- if (this.id != null)
22748
- result["id"] = this.id.href;
22749
- result["@context"] = "https://www.w3.org/ns/activitystreams";
22750
- return result;
22751
- }
22752
22463
  // deno-lint-ignore no-unused-vars prefer-const
22753
22464
  let array;
22754
22465
  const baseValues = await super.toJsonLd({
@@ -22757,17 +22468,32 @@ export class Mention extends Link {
22757
22468
  context: undefined,
22758
22469
  });
22759
22470
  const values = baseValues[0];
22760
- values["@type"] = ["https://www.w3.org/ns/activitystreams#Mention"];
22471
+ values["@type"] = ["https://www.w3.org/ns/activitystreams#Move"];
22761
22472
  if (this.id != null)
22762
22473
  values["@id"] = this.id.href;
22763
22474
  if (options.format === "expand") {
22764
22475
  return await jsonld.expand(values, { documentLoader: options.contextLoader });
22765
22476
  }
22766
22477
  const docContext = options.context ??
22767
- "https://www.w3.org/ns/activitystreams";
22478
+ [
22479
+ "https://w3id.org/identity/v1",
22480
+ "https://www.w3.org/ns/activitystreams",
22481
+ "https://w3id.org/security/data-integrity/v1",
22482
+ ];
22768
22483
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
22769
22484
  if (docContext != null) {
22770
22485
  // Embed context
22486
+ if ("proof" in compacted &&
22487
+ compacted.proof != null) {
22488
+ if (Array.isArray(compacted.proof)) {
22489
+ for (const element of compacted.proof) {
22490
+ element["@context"] = docContext;
22491
+ }
22492
+ }
22493
+ else {
22494
+ compacted.proof["@context"] = docContext;
22495
+ }
22496
+ }
22771
22497
  }
22772
22498
  return compacted;
22773
22499
  }
@@ -22805,185 +22531,8 @@ export class Mention extends Link {
22805
22531
  // deno-lint-ignore no-explicit-any
22806
22532
  (expanded[0] ?? {});
22807
22533
  }
22808
- if ("@type" in values) {
22809
- if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Mention")) {
22810
- throw new TypeError("Invalid type: " + values["@type"]);
22811
- }
22812
- }
22813
- delete values["@type"];
22814
- const instance = await super.fromJsonLd(values, {
22815
- ...options,
22816
- // @ts-ignore: an internal option
22817
- _fromSubclass: true,
22818
- });
22819
- if (!(instance instanceof Mention)) {
22820
- throw new TypeError("Unexpected type: " + instance.constructor.name);
22821
- }
22822
- if (!("_fromSubclass" in options) || !options._fromSubclass) {
22823
- try {
22824
- instance.#cachedJsonLd = structuredClone(json);
22825
- }
22826
- catch {
22827
- getLogger(["fedify", "vocab"]).warn("Failed to cache JSON-LD: {json}", { json });
22828
- }
22829
- }
22830
- return instance;
22831
- }
22832
- _getCustomInspectProxy() {
22833
- const proxy = super._getCustomInspectProxy();
22834
- return proxy;
22835
- }
22836
- [Symbol.for("Deno.customInspect")](inspect, options) {
22837
- const proxy = this._getCustomInspectProxy();
22838
- return "Mention " + inspect(proxy, options);
22839
- }
22840
- [Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
22841
- const proxy = this._getCustomInspectProxy();
22842
- return "Mention " + inspect(proxy, options);
22843
- }
22844
- }
22845
- /** Indicates that the `actor` has moved `object` from `origin` to `target`.
22846
- * If the `origin` or `target` are not specified,
22847
- * either can be determined by context.
22848
- */
22849
- export class Move extends Activity {
22850
- #cachedJsonLd;
22851
- /**
22852
- * The type URI of {@link Move}: `https://www.w3.org/ns/activitystreams#Move`.
22853
- */
22854
- static get typeId() {
22855
- return new URL("https://www.w3.org/ns/activitystreams#Move");
22856
- }
22857
- /**
22858
- * Constructs a new instance of Move with the given values.
22859
- * @param values The values to initialize the instance with.
22860
- * @param options The options to use for initialization.
22861
- */
22862
- constructor(values, { documentLoader, contextLoader, } = {}) {
22863
- super(values, { documentLoader, contextLoader });
22864
- }
22865
- /**
22866
- * Clones this instance, optionally updating it with the given values.
22867
- * @param values The values to update the clone with.
22868
- * @options The options to use for cloning.
22869
- * @returns The cloned instance.
22870
- */
22871
- clone(values = {}, options = {}) {
22872
- const clone = super.clone(values, options);
22873
- return clone;
22874
- }
22875
- /**
22876
- * Converts this object to a JSON-LD structure.
22877
- * @param options The options to use.
22878
- * - `format`: The format of the output: `compact` or
22879
- `expand`.
22880
- * - `contextLoader`: The loader for remote JSON-LD contexts.
22881
- * - `context`: The JSON-LD context to use. Not applicable
22882
- when `format` is set to `'expand'`.
22883
- * @returns The JSON-LD representation of this object.
22884
- */
22885
- async toJsonLd(options = {}) {
22886
- if (options.format == null && this.#cachedJsonLd != null) {
22887
- return this.#cachedJsonLd;
22888
- }
22889
- if (options.format !== "compact" && options.context != null) {
22890
- throw new TypeError("The context option can only be used when the format option is set " +
22891
- "to 'compact'.");
22892
- }
22893
- options = {
22894
- ...options,
22895
- contextLoader: options.contextLoader ?? fetchDocumentLoader,
22896
- };
22897
- if (options.format == null && this.isCompactable()) {
22898
- const result = await super.toJsonLd({
22899
- ...options,
22900
- format: undefined,
22901
- context: undefined,
22902
- });
22903
- // deno-lint-ignore no-unused-vars
22904
- let compactItems;
22905
- result["type"] = "Move";
22906
- if (this.id != null)
22907
- result["id"] = this.id.href;
22908
- result["@context"] = [
22909
- "https://www.w3.org/ns/activitystreams",
22910
- "https://w3id.org/security/data-integrity/v1",
22911
- "https://w3id.org/identity/v1",
22912
- ];
22913
- return result;
22914
- }
22915
- // deno-lint-ignore no-unused-vars prefer-const
22916
- let array;
22917
- const baseValues = await super.toJsonLd({
22918
- ...options,
22919
- format: "expand",
22920
- context: undefined,
22921
- });
22922
- const values = baseValues[0];
22923
- values["@type"] = ["https://www.w3.org/ns/activitystreams#Move"];
22924
- if (this.id != null)
22925
- values["@id"] = this.id.href;
22926
- if (options.format === "expand") {
22927
- return await jsonld.expand(values, { documentLoader: options.contextLoader });
22928
- }
22929
- const docContext = options.context ??
22930
- [
22931
- "https://www.w3.org/ns/activitystreams",
22932
- "https://w3id.org/security/data-integrity/v1",
22933
- "https://w3id.org/identity/v1",
22934
- ];
22935
- const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
22936
- if (docContext != null) {
22937
- // Embed context
22938
- if ("proof" in compacted &&
22939
- compacted.proof != null) {
22940
- if (Array.isArray(compacted.proof)) {
22941
- for (const element of compacted.proof) {
22942
- element["@context"] = docContext;
22943
- }
22944
- }
22945
- else {
22946
- compacted.proof["@context"] = docContext;
22947
- }
22948
- }
22949
- }
22950
- return compacted;
22951
- }
22952
- isCompactable() {
22953
- return super.isCompactable();
22954
- }
22955
- /**
22956
- * Converts a JSON-LD structure to an object of this type.
22957
- * @param json The JSON-LD structure to convert.
22958
- * @returns The object of this type.
22959
- * @throws {TypeError} If the given `json` is invalid.
22960
- */
22961
- static async fromJsonLd(json, options = {}) {
22962
- if (typeof json === "undefined") {
22963
- throw new TypeError("Invalid JSON-LD: undefined.");
22964
- }
22965
- else if (json === null)
22966
- throw new TypeError("Invalid JSON-LD: null.");
22967
- options = {
22968
- ...options,
22969
- documentLoader: options.documentLoader ?? fetchDocumentLoader,
22970
- contextLoader: options.contextLoader ?? fetchDocumentLoader,
22971
- };
22972
- // deno-lint-ignore no-explicit-any
22973
- let values;
22974
- if (globalThis.Object.keys(json).length == 0) {
22975
- values = {};
22976
- }
22977
- else {
22978
- const expanded = await jsonld.expand(json, {
22979
- documentLoader: options.contextLoader,
22980
- keepFreeFloatingNodes: true,
22981
- });
22982
- values =
22983
- // deno-lint-ignore no-explicit-any
22984
- (expanded[0] ?? {});
22985
- }
22986
- if ("@type" in values) {
22534
+ if ("@type" in values &&
22535
+ !values["@type"].every((t) => t.startsWith("_:"))) {
22987
22536
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Move")) {
22988
22537
  throw new TypeError("Invalid type: " + values["@type"]);
22989
22538
  }
@@ -23246,7 +22795,8 @@ export class Note extends Object {
23246
22795
  // deno-lint-ignore no-explicit-any
23247
22796
  (expanded[0] ?? {});
23248
22797
  }
23249
- if ("@type" in values) {
22798
+ if ("@type" in values &&
22799
+ !values["@type"].every((t) => t.startsWith("_:"))) {
23250
22800
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Note")) {
23251
22801
  throw new TypeError("Invalid type: " + values["@type"]);
23252
22802
  }
@@ -23593,7 +23143,8 @@ export class OrderedCollection extends Collection {
23593
23143
  // deno-lint-ignore no-explicit-any
23594
23144
  (expanded[0] ?? {});
23595
23145
  }
23596
- if ("@type" in values) {
23146
+ if ("@type" in values &&
23147
+ !values["@type"].every((t) => t.startsWith("_:"))) {
23597
23148
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#OrderedCollection")) {
23598
23149
  throw new TypeError("Invalid type: " + values["@type"]);
23599
23150
  }
@@ -24063,7 +23614,8 @@ export class OrderedCollectionPage extends CollectionPage {
24063
23614
  // deno-lint-ignore no-explicit-any
24064
23615
  (expanded[0] ?? {});
24065
23616
  }
24066
- if ("@type" in values) {
23617
+ if ("@type" in values &&
23618
+ !values["@type"].every((t) => t.startsWith("_:"))) {
24067
23619
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#OrderedCollectionPage")) {
24068
23620
  throw new TypeError("Invalid type: " + values["@type"]);
24069
23621
  }
@@ -26341,7 +25893,8 @@ export class Organization extends Object {
26341
25893
  // deno-lint-ignore no-explicit-any
26342
25894
  (expanded[0] ?? {});
26343
25895
  }
26344
- if ("@type" in values) {
25896
+ if ("@type" in values &&
25897
+ !values["@type"].every((t) => t.startsWith("_:"))) {
26345
25898
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Organization")) {
26346
25899
  throw new TypeError("Invalid type: " + values["@type"]);
26347
25900
  }
@@ -27125,7 +26678,8 @@ export class Page extends Document {
27125
26678
  // deno-lint-ignore no-explicit-any
27126
26679
  (expanded[0] ?? {});
27127
26680
  }
27128
- if ("@type" in values) {
26681
+ if ("@type" in values &&
26682
+ !values["@type"].every((t) => t.startsWith("_:"))) {
27129
26683
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Page")) {
27130
26684
  throw new TypeError("Invalid type: " + values["@type"]);
27131
26685
  }
@@ -29274,7 +28828,8 @@ export class Person extends Object {
29274
28828
  // deno-lint-ignore no-explicit-any
29275
28829
  (expanded[0] ?? {});
29276
28830
  }
29277
- if ("@type" in values) {
28831
+ if ("@type" in values &&
28832
+ !values["@type"].every((t) => t.startsWith("_:"))) {
29278
28833
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Person")) {
29279
28834
  throw new TypeError("Invalid type: " + values["@type"]);
29280
28835
  }
@@ -30389,7 +29944,8 @@ export class Place extends Object {
30389
29944
  // deno-lint-ignore no-explicit-any
30390
29945
  (expanded[0] ?? {});
30391
29946
  }
30392
- if ("@type" in values) {
29947
+ if ("@type" in values &&
29948
+ !values["@type"].every((t) => t.startsWith("_:"))) {
30393
29949
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Place")) {
30394
29950
  throw new TypeError("Invalid type: " + values["@type"]);
30395
29951
  }
@@ -30839,7 +30395,8 @@ export class Profile extends Object {
30839
30395
  // deno-lint-ignore no-explicit-any
30840
30396
  (expanded[0] ?? {});
30841
30397
  }
30842
- if ("@type" in values) {
30398
+ if ("@type" in values &&
30399
+ !values["@type"].every((t) => t.startsWith("_:"))) {
30843
30400
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Profile")) {
30844
30401
  throw new TypeError("Invalid type: " + values["@type"]);
30845
30402
  }
@@ -31227,100 +30784,6 @@ export class Question extends IntransitiveActivity {
31227
30784
  ...options,
31228
30785
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
31229
30786
  };
31230
- if (options.format == null && this.isCompactable()) {
31231
- const result = await super.toJsonLd({
31232
- ...options,
31233
- format: undefined,
31234
- context: undefined,
31235
- });
31236
- // deno-lint-ignore no-unused-vars
31237
- let compactItems;
31238
- compactItems = [];
31239
- for (const v of this.#_2N5scKaVEcdYHFmfKYYacAwUhUgQ_oneOf) {
31240
- const item = v instanceof URL ? v.href : await v.toJsonLd({
31241
- ...options,
31242
- format: undefined,
31243
- context: undefined,
31244
- });
31245
- compactItems.push(item);
31246
- }
31247
- if (compactItems.length > 0) {
31248
- result["oneOf"] = compactItems.length > 1
31249
- ? compactItems
31250
- : compactItems[0];
31251
- }
31252
- compactItems = [];
31253
- for (const v of this.#_2mV6isMTPRKbWdLCjcpiEysq5dAY_anyOf) {
31254
- const item = v instanceof URL ? v.href : await v.toJsonLd({
31255
- ...options,
31256
- format: undefined,
31257
- context: undefined,
31258
- });
31259
- compactItems.push(item);
31260
- }
31261
- if (compactItems.length > 0) {
31262
- result["anyOf"] = compactItems.length > 1
31263
- ? compactItems
31264
- : compactItems[0];
31265
- }
31266
- compactItems = [];
31267
- for (const v of this.#_3KronwL8DiiKBRcJFKQPiEHm8xb6_closed) {
31268
- const item = v instanceof dntShim.Temporal.Instant ? v.toString() : v;
31269
- compactItems.push(item);
31270
- }
31271
- if (compactItems.length > 0) {
31272
- result["closed"] = compactItems.length > 1
31273
- ? compactItems
31274
- : compactItems[0];
31275
- }
31276
- compactItems = [];
31277
- for (const v of this.#_3H4RdST7dxfmghccvE3rKD3KgcxG_votersCount) {
31278
- const item = v;
31279
- compactItems.push(item);
31280
- }
31281
- if (compactItems.length > 0) {
31282
- result["votersCount"] = compactItems.length > 1
31283
- ? compactItems
31284
- : compactItems[0];
31285
- }
31286
- compactItems = [];
31287
- for (const v of this.#_K1zrMQkQjmciFAmGdGLfaDbG925_quoteUrl) {
31288
- const item = v.href;
31289
- compactItems.push(item);
31290
- }
31291
- if (compactItems.length > 0) {
31292
- result["quoteUrl"] = compactItems.length > 1
31293
- ? compactItems
31294
- : compactItems[0];
31295
- result["_misskey_quote"] = compactItems.length > 1
31296
- ? compactItems
31297
- : compactItems[0];
31298
- result["quoteUri"] = compactItems.length > 1
31299
- ? compactItems
31300
- : compactItems[0];
31301
- }
31302
- result["type"] = "Question";
31303
- if (this.id != null)
31304
- result["id"] = this.id.href;
31305
- result["@context"] = [
31306
- "https://www.w3.org/ns/activitystreams",
31307
- "https://w3id.org/security/data-integrity/v1",
31308
- "https://w3id.org/identity/v1",
31309
- {
31310
- "toot": "http://joinmastodon.org/ns#",
31311
- "misskey": "https://misskey-hub.net/ns#",
31312
- "fedibird": "http://fedibird.com/ns#",
31313
- "sensitive": "as:sensitive",
31314
- "votersCount": "toot:votersCount",
31315
- "Emoji": "toot:Emoji",
31316
- "Hashtag": "as:Hashtag",
31317
- "quoteUrl": "as:quoteUrl",
31318
- "_misskey_quote": "misskey:_misskey_quote",
31319
- "quoteUri": "fedibird:quoteUri",
31320
- },
31321
- ];
31322
- return result;
31323
- }
31324
30787
  // deno-lint-ignore no-unused-vars prefer-const
31325
30788
  let array;
31326
30789
  const baseValues = await super.toJsonLd({
@@ -31396,9 +30859,9 @@ export class Question extends IntransitiveActivity {
31396
30859
  }
31397
30860
  const docContext = options.context ??
31398
30861
  [
30862
+ "https://w3id.org/identity/v1",
31399
30863
  "https://www.w3.org/ns/activitystreams",
31400
30864
  "https://w3id.org/security/data-integrity/v1",
31401
- "https://w3id.org/identity/v1",
31402
30865
  {
31403
30866
  "toot": "http://joinmastodon.org/ns#",
31404
30867
  "misskey": "https://misskey-hub.net/ns#",
@@ -31463,7 +30926,8 @@ export class Question extends IntransitiveActivity {
31463
30926
  // deno-lint-ignore no-explicit-any
31464
30927
  (expanded[0] ?? {});
31465
30928
  }
31466
- if ("@type" in values) {
30929
+ if ("@type" in values &&
30930
+ !values["@type"].every((t) => t.startsWith("_:"))) {
31467
30931
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Question")) {
31468
30932
  throw new TypeError("Invalid type: " + values["@type"]);
31469
30933
  }
@@ -31714,24 +31178,6 @@ export class Read extends Activity {
31714
31178
  ...options,
31715
31179
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
31716
31180
  };
31717
- if (options.format == null && this.isCompactable()) {
31718
- const result = await super.toJsonLd({
31719
- ...options,
31720
- format: undefined,
31721
- context: undefined,
31722
- });
31723
- // deno-lint-ignore no-unused-vars
31724
- let compactItems;
31725
- result["type"] = "Read";
31726
- if (this.id != null)
31727
- result["id"] = this.id.href;
31728
- result["@context"] = [
31729
- "https://www.w3.org/ns/activitystreams",
31730
- "https://w3id.org/security/data-integrity/v1",
31731
- "https://w3id.org/identity/v1",
31732
- ];
31733
- return result;
31734
- }
31735
31181
  // deno-lint-ignore no-unused-vars prefer-const
31736
31182
  let array;
31737
31183
  const baseValues = await super.toJsonLd({
@@ -31748,9 +31194,9 @@ export class Read extends Activity {
31748
31194
  }
31749
31195
  const docContext = options.context ??
31750
31196
  [
31197
+ "https://w3id.org/identity/v1",
31751
31198
  "https://www.w3.org/ns/activitystreams",
31752
31199
  "https://w3id.org/security/data-integrity/v1",
31753
- "https://w3id.org/identity/v1",
31754
31200
  ];
31755
31201
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
31756
31202
  if (docContext != null) {
@@ -31803,7 +31249,8 @@ export class Read extends Activity {
31803
31249
  // deno-lint-ignore no-explicit-any
31804
31250
  (expanded[0] ?? {});
31805
31251
  }
31806
- if ("@type" in values) {
31252
+ if ("@type" in values &&
31253
+ !values["@type"].every((t) => t.startsWith("_:"))) {
31807
31254
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Read")) {
31808
31255
  throw new TypeError("Invalid type: " + values["@type"]);
31809
31256
  }
@@ -31891,24 +31338,6 @@ export class Reject extends Activity {
31891
31338
  ...options,
31892
31339
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
31893
31340
  };
31894
- if (options.format == null && this.isCompactable()) {
31895
- const result = await super.toJsonLd({
31896
- ...options,
31897
- format: undefined,
31898
- context: undefined,
31899
- });
31900
- // deno-lint-ignore no-unused-vars
31901
- let compactItems;
31902
- result["type"] = "Reject";
31903
- if (this.id != null)
31904
- result["id"] = this.id.href;
31905
- result["@context"] = [
31906
- "https://www.w3.org/ns/activitystreams",
31907
- "https://w3id.org/security/data-integrity/v1",
31908
- "https://w3id.org/identity/v1",
31909
- ];
31910
- return result;
31911
- }
31912
31341
  // deno-lint-ignore no-unused-vars prefer-const
31913
31342
  let array;
31914
31343
  const baseValues = await super.toJsonLd({
@@ -31925,9 +31354,9 @@ export class Reject extends Activity {
31925
31354
  }
31926
31355
  const docContext = options.context ??
31927
31356
  [
31357
+ "https://w3id.org/identity/v1",
31928
31358
  "https://www.w3.org/ns/activitystreams",
31929
31359
  "https://w3id.org/security/data-integrity/v1",
31930
- "https://w3id.org/identity/v1",
31931
31360
  ];
31932
31361
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
31933
31362
  if (docContext != null) {
@@ -31980,7 +31409,8 @@ export class Reject extends Activity {
31980
31409
  // deno-lint-ignore no-explicit-any
31981
31410
  (expanded[0] ?? {});
31982
31411
  }
31983
- if ("@type" in values) {
31412
+ if ("@type" in values &&
31413
+ !values["@type"].every((t) => t.startsWith("_:"))) {
31984
31414
  if (values["@type"].includes("https://www.w3.org/ns/activitystreams#TentativeReject")) {
31985
31415
  return await TentativeReject.fromJsonLd(json, options);
31986
31416
  }
@@ -32602,7 +32032,8 @@ export class Relationship extends Object {
32602
32032
  // deno-lint-ignore no-explicit-any
32603
32033
  (expanded[0] ?? {});
32604
32034
  }
32605
- if ("@type" in values) {
32035
+ if ("@type" in values &&
32036
+ !values["@type"].every((t) => t.startsWith("_:"))) {
32606
32037
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Relationship")) {
32607
32038
  throw new TypeError("Invalid type: " + values["@type"]);
32608
32039
  }
@@ -32793,24 +32224,6 @@ export class Remove extends Activity {
32793
32224
  ...options,
32794
32225
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
32795
32226
  };
32796
- if (options.format == null && this.isCompactable()) {
32797
- const result = await super.toJsonLd({
32798
- ...options,
32799
- format: undefined,
32800
- context: undefined,
32801
- });
32802
- // deno-lint-ignore no-unused-vars
32803
- let compactItems;
32804
- result["type"] = "Remove";
32805
- if (this.id != null)
32806
- result["id"] = this.id.href;
32807
- result["@context"] = [
32808
- "https://www.w3.org/ns/activitystreams",
32809
- "https://w3id.org/security/data-integrity/v1",
32810
- "https://w3id.org/identity/v1",
32811
- ];
32812
- return result;
32813
- }
32814
32227
  // deno-lint-ignore no-unused-vars prefer-const
32815
32228
  let array;
32816
32229
  const baseValues = await super.toJsonLd({
@@ -32827,9 +32240,9 @@ export class Remove extends Activity {
32827
32240
  }
32828
32241
  const docContext = options.context ??
32829
32242
  [
32243
+ "https://w3id.org/identity/v1",
32830
32244
  "https://www.w3.org/ns/activitystreams",
32831
32245
  "https://w3id.org/security/data-integrity/v1",
32832
- "https://w3id.org/identity/v1",
32833
32246
  ];
32834
32247
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
32835
32248
  if (docContext != null) {
@@ -32882,7 +32295,8 @@ export class Remove extends Activity {
32882
32295
  // deno-lint-ignore no-explicit-any
32883
32296
  (expanded[0] ?? {});
32884
32297
  }
32885
- if ("@type" in values) {
32298
+ if ("@type" in values &&
32299
+ !values["@type"].every((t) => t.startsWith("_:"))) {
32886
32300
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Remove")) {
32887
32301
  throw new TypeError("Invalid type: " + values["@type"]);
32888
32302
  }
@@ -35031,7 +34445,8 @@ export class Service extends Object {
35031
34445
  // deno-lint-ignore no-explicit-any
35032
34446
  (expanded[0] ?? {});
35033
34447
  }
35034
- if ("@type" in values) {
34448
+ if ("@type" in values &&
34449
+ !values["@type"].every((t) => t.startsWith("_:"))) {
35035
34450
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Service")) {
35036
34451
  throw new TypeError("Invalid type: " + values["@type"]);
35037
34452
  }
@@ -35952,7 +35367,8 @@ export class Source {
35952
35367
  // deno-lint-ignore no-explicit-any
35953
35368
  (expanded[0] ?? {});
35954
35369
  }
35955
- if ("@type" in values) {
35370
+ if ("@type" in values &&
35371
+ !values["@type"].every((t) => t.startsWith("_:"))) {
35956
35372
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Source")) {
35957
35373
  throw new TypeError("Invalid type: " + values["@type"]);
35958
35374
  }
@@ -36105,201 +35521,166 @@ export class TentativeAccept extends Accept {
36105
35521
  ...options,
36106
35522
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
36107
35523
  };
36108
- if (options.format == null && this.isCompactable()) {
36109
- const result = await super.toJsonLd({
36110
- ...options,
36111
- format: undefined,
36112
- context: undefined,
36113
- });
36114
- // deno-lint-ignore no-unused-vars
36115
- let compactItems;
36116
- result["type"] = "TentativeAccept";
36117
- if (this.id != null)
36118
- result["id"] = this.id.href;
36119
- result["@context"] = [
36120
- "https://www.w3.org/ns/activitystreams",
36121
- "https://w3id.org/security/data-integrity/v1",
36122
- "https://w3id.org/identity/v1",
36123
- ];
36124
- return result;
36125
- }
36126
- // deno-lint-ignore no-unused-vars prefer-const
36127
- let array;
36128
- const baseValues = await super.toJsonLd({
36129
- ...options,
36130
- format: "expand",
36131
- context: undefined,
36132
- });
36133
- const values = baseValues[0];
36134
- values["@type"] = ["https://www.w3.org/ns/activitystreams#TentativeAccept"];
36135
- if (this.id != null)
36136
- values["@id"] = this.id.href;
36137
- if (options.format === "expand") {
36138
- return await jsonld.expand(values, { documentLoader: options.contextLoader });
36139
- }
36140
- const docContext = options.context ??
36141
- [
36142
- "https://www.w3.org/ns/activitystreams",
36143
- "https://w3id.org/security/data-integrity/v1",
36144
- "https://w3id.org/identity/v1",
36145
- ];
36146
- const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
36147
- if (docContext != null) {
36148
- // Embed context
36149
- if ("proof" in compacted &&
36150
- compacted.proof != null) {
36151
- if (Array.isArray(compacted.proof)) {
36152
- for (const element of compacted.proof) {
36153
- element["@context"] = docContext;
36154
- }
36155
- }
36156
- else {
36157
- compacted.proof["@context"] = docContext;
36158
- }
36159
- }
36160
- }
36161
- return compacted;
36162
- }
36163
- isCompactable() {
36164
- return super.isCompactable();
36165
- }
36166
- /**
36167
- * Converts a JSON-LD structure to an object of this type.
36168
- * @param json The JSON-LD structure to convert.
36169
- * @returns The object of this type.
36170
- * @throws {TypeError} If the given `json` is invalid.
36171
- */
36172
- static async fromJsonLd(json, options = {}) {
36173
- if (typeof json === "undefined") {
36174
- throw new TypeError("Invalid JSON-LD: undefined.");
36175
- }
36176
- else if (json === null)
36177
- throw new TypeError("Invalid JSON-LD: null.");
36178
- options = {
36179
- ...options,
36180
- documentLoader: options.documentLoader ?? fetchDocumentLoader,
36181
- contextLoader: options.contextLoader ?? fetchDocumentLoader,
36182
- };
36183
- // deno-lint-ignore no-explicit-any
36184
- let values;
36185
- if (globalThis.Object.keys(json).length == 0) {
36186
- values = {};
36187
- }
36188
- else {
36189
- const expanded = await jsonld.expand(json, {
36190
- documentLoader: options.contextLoader,
36191
- keepFreeFloatingNodes: true,
36192
- });
36193
- values =
36194
- // deno-lint-ignore no-explicit-any
36195
- (expanded[0] ?? {});
36196
- }
36197
- if ("@type" in values) {
36198
- if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#TentativeAccept")) {
36199
- throw new TypeError("Invalid type: " + values["@type"]);
36200
- }
36201
- }
36202
- delete values["@type"];
36203
- const instance = await super.fromJsonLd(values, {
36204
- ...options,
36205
- // @ts-ignore: an internal option
36206
- _fromSubclass: true,
36207
- });
36208
- if (!(instance instanceof TentativeAccept)) {
36209
- throw new TypeError("Unexpected type: " + instance.constructor.name);
36210
- }
36211
- if (!("_fromSubclass" in options) || !options._fromSubclass) {
36212
- try {
36213
- instance.#cachedJsonLd = structuredClone(json);
36214
- }
36215
- catch {
36216
- getLogger(["fedify", "vocab"]).warn("Failed to cache JSON-LD: {json}", { json });
36217
- }
36218
- }
36219
- return instance;
36220
- }
36221
- _getCustomInspectProxy() {
36222
- const proxy = super._getCustomInspectProxy();
36223
- return proxy;
36224
- }
36225
- [Symbol.for("Deno.customInspect")](inspect, options) {
36226
- const proxy = this._getCustomInspectProxy();
36227
- return "TentativeAccept " + inspect(proxy, options);
36228
- }
36229
- [Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
36230
- const proxy = this._getCustomInspectProxy();
36231
- return "TentativeAccept " + inspect(proxy, options);
36232
- }
36233
- }
36234
- /** A specialization of {@link Reject} in which
36235
- * the rejection is considered tentative.
36236
- */
36237
- export class TentativeReject extends Reject {
36238
- #cachedJsonLd;
36239
- /**
36240
- * The type URI of {@link TentativeReject}: `https://www.w3.org/ns/activitystreams#TentativeReject`.
36241
- */
36242
- static get typeId() {
36243
- return new URL("https://www.w3.org/ns/activitystreams#TentativeReject");
36244
- }
36245
- /**
36246
- * Constructs a new instance of TentativeReject with the given values.
36247
- * @param values The values to initialize the instance with.
36248
- * @param options The options to use for initialization.
36249
- */
36250
- constructor(values, { documentLoader, contextLoader, } = {}) {
36251
- super(values, { documentLoader, contextLoader });
36252
- }
36253
- /**
36254
- * Clones this instance, optionally updating it with the given values.
36255
- * @param values The values to update the clone with.
36256
- * @options The options to use for cloning.
36257
- * @returns The cloned instance.
36258
- */
36259
- clone(values = {}, options = {}) {
36260
- const clone = super.clone(values, options);
36261
- return clone;
36262
- }
36263
- /**
36264
- * Converts this object to a JSON-LD structure.
36265
- * @param options The options to use.
36266
- * - `format`: The format of the output: `compact` or
36267
- `expand`.
36268
- * - `contextLoader`: The loader for remote JSON-LD contexts.
36269
- * - `context`: The JSON-LD context to use. Not applicable
36270
- when `format` is set to `'expand'`.
36271
- * @returns The JSON-LD representation of this object.
36272
- */
36273
- async toJsonLd(options = {}) {
36274
- if (options.format == null && this.#cachedJsonLd != null) {
36275
- return this.#cachedJsonLd;
36276
- }
36277
- if (options.format !== "compact" && options.context != null) {
36278
- throw new TypeError("The context option can only be used when the format option is set " +
36279
- "to 'compact'.");
36280
- }
36281
- options = {
36282
- ...options,
36283
- contextLoader: options.contextLoader ?? fetchDocumentLoader,
36284
- };
36285
- if (options.format == null && this.isCompactable()) {
36286
- const result = await super.toJsonLd({
36287
- ...options,
36288
- format: undefined,
36289
- context: undefined,
36290
- });
36291
- // deno-lint-ignore no-unused-vars
36292
- let compactItems;
36293
- result["type"] = "TentativeReject";
36294
- if (this.id != null)
36295
- result["id"] = this.id.href;
36296
- result["@context"] = [
35524
+ // deno-lint-ignore no-unused-vars prefer-const
35525
+ let array;
35526
+ const baseValues = await super.toJsonLd({
35527
+ ...options,
35528
+ format: "expand",
35529
+ context: undefined,
35530
+ });
35531
+ const values = baseValues[0];
35532
+ values["@type"] = ["https://www.w3.org/ns/activitystreams#TentativeAccept"];
35533
+ if (this.id != null)
35534
+ values["@id"] = this.id.href;
35535
+ if (options.format === "expand") {
35536
+ return await jsonld.expand(values, { documentLoader: options.contextLoader });
35537
+ }
35538
+ const docContext = options.context ??
35539
+ [
35540
+ "https://w3id.org/identity/v1",
36297
35541
  "https://www.w3.org/ns/activitystreams",
36298
35542
  "https://w3id.org/security/data-integrity/v1",
36299
- "https://w3id.org/identity/v1",
36300
35543
  ];
36301
- return result;
35544
+ const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
35545
+ if (docContext != null) {
35546
+ // Embed context
35547
+ if ("proof" in compacted &&
35548
+ compacted.proof != null) {
35549
+ if (Array.isArray(compacted.proof)) {
35550
+ for (const element of compacted.proof) {
35551
+ element["@context"] = docContext;
35552
+ }
35553
+ }
35554
+ else {
35555
+ compacted.proof["@context"] = docContext;
35556
+ }
35557
+ }
35558
+ }
35559
+ return compacted;
35560
+ }
35561
+ isCompactable() {
35562
+ return super.isCompactable();
35563
+ }
35564
+ /**
35565
+ * Converts a JSON-LD structure to an object of this type.
35566
+ * @param json The JSON-LD structure to convert.
35567
+ * @returns The object of this type.
35568
+ * @throws {TypeError} If the given `json` is invalid.
35569
+ */
35570
+ static async fromJsonLd(json, options = {}) {
35571
+ if (typeof json === "undefined") {
35572
+ throw new TypeError("Invalid JSON-LD: undefined.");
35573
+ }
35574
+ else if (json === null)
35575
+ throw new TypeError("Invalid JSON-LD: null.");
35576
+ options = {
35577
+ ...options,
35578
+ documentLoader: options.documentLoader ?? fetchDocumentLoader,
35579
+ contextLoader: options.contextLoader ?? fetchDocumentLoader,
35580
+ };
35581
+ // deno-lint-ignore no-explicit-any
35582
+ let values;
35583
+ if (globalThis.Object.keys(json).length == 0) {
35584
+ values = {};
35585
+ }
35586
+ else {
35587
+ const expanded = await jsonld.expand(json, {
35588
+ documentLoader: options.contextLoader,
35589
+ keepFreeFloatingNodes: true,
35590
+ });
35591
+ values =
35592
+ // deno-lint-ignore no-explicit-any
35593
+ (expanded[0] ?? {});
35594
+ }
35595
+ if ("@type" in values &&
35596
+ !values["@type"].every((t) => t.startsWith("_:"))) {
35597
+ if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#TentativeAccept")) {
35598
+ throw new TypeError("Invalid type: " + values["@type"]);
35599
+ }
35600
+ }
35601
+ delete values["@type"];
35602
+ const instance = await super.fromJsonLd(values, {
35603
+ ...options,
35604
+ // @ts-ignore: an internal option
35605
+ _fromSubclass: true,
35606
+ });
35607
+ if (!(instance instanceof TentativeAccept)) {
35608
+ throw new TypeError("Unexpected type: " + instance.constructor.name);
35609
+ }
35610
+ if (!("_fromSubclass" in options) || !options._fromSubclass) {
35611
+ try {
35612
+ instance.#cachedJsonLd = structuredClone(json);
35613
+ }
35614
+ catch {
35615
+ getLogger(["fedify", "vocab"]).warn("Failed to cache JSON-LD: {json}", { json });
35616
+ }
35617
+ }
35618
+ return instance;
35619
+ }
35620
+ _getCustomInspectProxy() {
35621
+ const proxy = super._getCustomInspectProxy();
35622
+ return proxy;
35623
+ }
35624
+ [Symbol.for("Deno.customInspect")](inspect, options) {
35625
+ const proxy = this._getCustomInspectProxy();
35626
+ return "TentativeAccept " + inspect(proxy, options);
35627
+ }
35628
+ [Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
35629
+ const proxy = this._getCustomInspectProxy();
35630
+ return "TentativeAccept " + inspect(proxy, options);
35631
+ }
35632
+ }
35633
+ /** A specialization of {@link Reject} in which
35634
+ * the rejection is considered tentative.
35635
+ */
35636
+ export class TentativeReject extends Reject {
35637
+ #cachedJsonLd;
35638
+ /**
35639
+ * The type URI of {@link TentativeReject}: `https://www.w3.org/ns/activitystreams#TentativeReject`.
35640
+ */
35641
+ static get typeId() {
35642
+ return new URL("https://www.w3.org/ns/activitystreams#TentativeReject");
35643
+ }
35644
+ /**
35645
+ * Constructs a new instance of TentativeReject with the given values.
35646
+ * @param values The values to initialize the instance with.
35647
+ * @param options The options to use for initialization.
35648
+ */
35649
+ constructor(values, { documentLoader, contextLoader, } = {}) {
35650
+ super(values, { documentLoader, contextLoader });
35651
+ }
35652
+ /**
35653
+ * Clones this instance, optionally updating it with the given values.
35654
+ * @param values The values to update the clone with.
35655
+ * @options The options to use for cloning.
35656
+ * @returns The cloned instance.
35657
+ */
35658
+ clone(values = {}, options = {}) {
35659
+ const clone = super.clone(values, options);
35660
+ return clone;
35661
+ }
35662
+ /**
35663
+ * Converts this object to a JSON-LD structure.
35664
+ * @param options The options to use.
35665
+ * - `format`: The format of the output: `compact` or
35666
+ `expand`.
35667
+ * - `contextLoader`: The loader for remote JSON-LD contexts.
35668
+ * - `context`: The JSON-LD context to use. Not applicable
35669
+ when `format` is set to `'expand'`.
35670
+ * @returns The JSON-LD representation of this object.
35671
+ */
35672
+ async toJsonLd(options = {}) {
35673
+ if (options.format == null && this.#cachedJsonLd != null) {
35674
+ return this.#cachedJsonLd;
36302
35675
  }
35676
+ if (options.format !== "compact" && options.context != null) {
35677
+ throw new TypeError("The context option can only be used when the format option is set " +
35678
+ "to 'compact'.");
35679
+ }
35680
+ options = {
35681
+ ...options,
35682
+ contextLoader: options.contextLoader ?? fetchDocumentLoader,
35683
+ };
36303
35684
  // deno-lint-ignore no-unused-vars prefer-const
36304
35685
  let array;
36305
35686
  const baseValues = await super.toJsonLd({
@@ -36316,9 +35697,9 @@ export class TentativeReject extends Reject {
36316
35697
  }
36317
35698
  const docContext = options.context ??
36318
35699
  [
35700
+ "https://w3id.org/identity/v1",
36319
35701
  "https://www.w3.org/ns/activitystreams",
36320
35702
  "https://w3id.org/security/data-integrity/v1",
36321
- "https://w3id.org/identity/v1",
36322
35703
  ];
36323
35704
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
36324
35705
  if (docContext != null) {
@@ -36371,7 +35752,8 @@ export class TentativeReject extends Reject {
36371
35752
  // deno-lint-ignore no-explicit-any
36372
35753
  (expanded[0] ?? {});
36373
35754
  }
36374
- if ("@type" in values) {
35755
+ if ("@type" in values &&
35756
+ !values["@type"].every((t) => t.startsWith("_:"))) {
36375
35757
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#TentativeReject")) {
36376
35758
  throw new TypeError("Invalid type: " + values["@type"]);
36377
35759
  }
@@ -36600,7 +35982,8 @@ export class Tombstone extends Object {
36600
35982
  // deno-lint-ignore no-explicit-any
36601
35983
  (expanded[0] ?? {});
36602
35984
  }
36603
- if ("@type" in values) {
35985
+ if ("@type" in values &&
35986
+ !values["@type"].every((t) => t.startsWith("_:"))) {
36604
35987
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Tombstone")) {
36605
35988
  throw new TypeError("Invalid type: " + values["@type"]);
36606
35989
  }
@@ -36716,24 +36099,6 @@ export class Travel extends IntransitiveActivity {
36716
36099
  ...options,
36717
36100
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
36718
36101
  };
36719
- if (options.format == null && this.isCompactable()) {
36720
- const result = await super.toJsonLd({
36721
- ...options,
36722
- format: undefined,
36723
- context: undefined,
36724
- });
36725
- // deno-lint-ignore no-unused-vars
36726
- let compactItems;
36727
- result["type"] = "Travel";
36728
- if (this.id != null)
36729
- result["id"] = this.id.href;
36730
- result["@context"] = [
36731
- "https://www.w3.org/ns/activitystreams",
36732
- "https://w3id.org/security/data-integrity/v1",
36733
- "https://w3id.org/identity/v1",
36734
- ];
36735
- return result;
36736
- }
36737
36102
  // deno-lint-ignore no-unused-vars prefer-const
36738
36103
  let array;
36739
36104
  const baseValues = await super.toJsonLd({
@@ -36750,9 +36115,9 @@ export class Travel extends IntransitiveActivity {
36750
36115
  }
36751
36116
  const docContext = options.context ??
36752
36117
  [
36118
+ "https://w3id.org/identity/v1",
36753
36119
  "https://www.w3.org/ns/activitystreams",
36754
36120
  "https://w3id.org/security/data-integrity/v1",
36755
- "https://w3id.org/identity/v1",
36756
36121
  ];
36757
36122
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
36758
36123
  if (docContext != null) {
@@ -36805,7 +36170,8 @@ export class Travel extends IntransitiveActivity {
36805
36170
  // deno-lint-ignore no-explicit-any
36806
36171
  (expanded[0] ?? {});
36807
36172
  }
36808
- if ("@type" in values) {
36173
+ if ("@type" in values &&
36174
+ !values["@type"].every((t) => t.startsWith("_:"))) {
36809
36175
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Travel")) {
36810
36176
  throw new TypeError("Invalid type: " + values["@type"]);
36811
36177
  }
@@ -36898,24 +36264,6 @@ export class Undo extends Activity {
36898
36264
  ...options,
36899
36265
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
36900
36266
  };
36901
- if (options.format == null && this.isCompactable()) {
36902
- const result = await super.toJsonLd({
36903
- ...options,
36904
- format: undefined,
36905
- context: undefined,
36906
- });
36907
- // deno-lint-ignore no-unused-vars
36908
- let compactItems;
36909
- result["type"] = "Undo";
36910
- if (this.id != null)
36911
- result["id"] = this.id.href;
36912
- result["@context"] = [
36913
- "https://www.w3.org/ns/activitystreams",
36914
- "https://w3id.org/security/data-integrity/v1",
36915
- "https://w3id.org/identity/v1",
36916
- ];
36917
- return result;
36918
- }
36919
36267
  // deno-lint-ignore no-unused-vars prefer-const
36920
36268
  let array;
36921
36269
  const baseValues = await super.toJsonLd({
@@ -36932,9 +36280,9 @@ export class Undo extends Activity {
36932
36280
  }
36933
36281
  const docContext = options.context ??
36934
36282
  [
36283
+ "https://w3id.org/identity/v1",
36935
36284
  "https://www.w3.org/ns/activitystreams",
36936
36285
  "https://w3id.org/security/data-integrity/v1",
36937
- "https://w3id.org/identity/v1",
36938
36286
  ];
36939
36287
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
36940
36288
  if (docContext != null) {
@@ -36987,7 +36335,8 @@ export class Undo extends Activity {
36987
36335
  // deno-lint-ignore no-explicit-any
36988
36336
  (expanded[0] ?? {});
36989
36337
  }
36990
- if ("@type" in values) {
36338
+ if ("@type" in values &&
36339
+ !values["@type"].every((t) => t.startsWith("_:"))) {
36991
36340
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Undo")) {
36992
36341
  throw new TypeError("Invalid type: " + values["@type"]);
36993
36342
  }
@@ -37078,47 +36427,6 @@ export class Update extends Activity {
37078
36427
  ...options,
37079
36428
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
37080
36429
  };
37081
- if (options.format == null && this.isCompactable()) {
37082
- const result = await super.toJsonLd({
37083
- ...options,
37084
- format: undefined,
37085
- context: undefined,
37086
- });
37087
- // deno-lint-ignore no-unused-vars
37088
- let compactItems;
37089
- result["type"] = "Update";
37090
- if (this.id != null)
37091
- result["id"] = this.id.href;
37092
- result["@context"] = [
37093
- "https://www.w3.org/ns/activitystreams",
37094
- "https://w3id.org/security/data-integrity/v1",
37095
- "https://w3id.org/identity/v1",
37096
- {
37097
- "toot": "http://joinmastodon.org/ns#",
37098
- "schema": "http://schema.org#",
37099
- "misskey": "https://misskey-hub.net/ns#",
37100
- "fedibird": "http://fedibird.com/ns#",
37101
- "PropertyValue": "schema:PropertyValue",
37102
- "value": "schema:value",
37103
- "sensitive": "as:sensitive",
37104
- "votersCount": "toot:votersCount",
37105
- "featured": { "@id": "toot:featured", "@type": "@id" },
37106
- "featuredTags": { "@id": "toot:featuredTags", "@type": "@id" },
37107
- "discoverable": "toot:discoverable",
37108
- "suspended": "toot:suspended",
37109
- "memorial": "toot:memorial",
37110
- "indexable": "toot:indexable",
37111
- "Emoji": "toot:Emoji",
37112
- "Hashtag": "as:Hashtag",
37113
- "ChatMessage": "http://litepub.social/ns#ChatMessage",
37114
- "quoteUrl": "as:quoteUrl",
37115
- "_misskey_quote": "misskey:_misskey_quote",
37116
- "quoteUri": "fedibird:quoteUri",
37117
- "isCat": "misskey:isCat",
37118
- },
37119
- ];
37120
- return result;
37121
- }
37122
36430
  // deno-lint-ignore no-unused-vars prefer-const
37123
36431
  let array;
37124
36432
  const baseValues = await super.toJsonLd({
@@ -37135,9 +36443,9 @@ export class Update extends Activity {
37135
36443
  }
37136
36444
  const docContext = options.context ??
37137
36445
  [
36446
+ "https://w3id.org/identity/v1",
37138
36447
  "https://www.w3.org/ns/activitystreams",
37139
36448
  "https://w3id.org/security/data-integrity/v1",
37140
- "https://w3id.org/identity/v1",
37141
36449
  {
37142
36450
  "toot": "http://joinmastodon.org/ns#",
37143
36451
  "schema": "http://schema.org#",
@@ -37213,7 +36521,8 @@ export class Update extends Activity {
37213
36521
  // deno-lint-ignore no-explicit-any
37214
36522
  (expanded[0] ?? {});
37215
36523
  }
37216
- if ("@type" in values) {
36524
+ if ("@type" in values &&
36525
+ !values["@type"].every((t) => t.startsWith("_:"))) {
37217
36526
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Update")) {
37218
36527
  throw new TypeError("Invalid type: " + values["@type"]);
37219
36528
  }
@@ -37387,7 +36696,8 @@ export class Video extends Document {
37387
36696
  // deno-lint-ignore no-explicit-any
37388
36697
  (expanded[0] ?? {});
37389
36698
  }
37390
- if ("@type" in values) {
36699
+ if ("@type" in values &&
36700
+ !values["@type"].every((t) => t.startsWith("_:"))) {
37391
36701
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#Video")) {
37392
36702
  throw new TypeError("Invalid type: " + values["@type"]);
37393
36703
  }
@@ -37474,24 +36784,6 @@ export class View extends Activity {
37474
36784
  ...options,
37475
36785
  contextLoader: options.contextLoader ?? fetchDocumentLoader,
37476
36786
  };
37477
- if (options.format == null && this.isCompactable()) {
37478
- const result = await super.toJsonLd({
37479
- ...options,
37480
- format: undefined,
37481
- context: undefined,
37482
- });
37483
- // deno-lint-ignore no-unused-vars
37484
- let compactItems;
37485
- result["type"] = "View";
37486
- if (this.id != null)
37487
- result["id"] = this.id.href;
37488
- result["@context"] = [
37489
- "https://www.w3.org/ns/activitystreams",
37490
- "https://w3id.org/security/data-integrity/v1",
37491
- "https://w3id.org/identity/v1",
37492
- ];
37493
- return result;
37494
- }
37495
36787
  // deno-lint-ignore no-unused-vars prefer-const
37496
36788
  let array;
37497
36789
  const baseValues = await super.toJsonLd({
@@ -37508,9 +36800,9 @@ export class View extends Activity {
37508
36800
  }
37509
36801
  const docContext = options.context ??
37510
36802
  [
36803
+ "https://w3id.org/identity/v1",
37511
36804
  "https://www.w3.org/ns/activitystreams",
37512
36805
  "https://w3id.org/security/data-integrity/v1",
37513
- "https://w3id.org/identity/v1",
37514
36806
  ];
37515
36807
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
37516
36808
  if (docContext != null) {
@@ -37563,7 +36855,8 @@ export class View extends Activity {
37563
36855
  // deno-lint-ignore no-explicit-any
37564
36856
  (expanded[0] ?? {});
37565
36857
  }
37566
- if ("@type" in values) {
36858
+ if ("@type" in values &&
36859
+ !values["@type"].every((t) => t.startsWith("_:"))) {
37567
36860
  if (!values["@type"].includes("https://www.w3.org/ns/activitystreams#View")) {
37568
36861
  throw new TypeError("Invalid type: " + values["@type"]);
37569
36862
  }