@fedify/fedify 0.11.0-dev.260 → 0.12.0-dev.262

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGES.md CHANGED
@@ -3,11 +3,21 @@
3
3
  Fedify changelog
4
4
  ================
5
5
 
6
- Version 0.11.0
6
+ Version 0.12.0
7
7
  --------------
8
8
 
9
9
  To be released.
10
10
 
11
+ - Added `ChatMessage` class to Activity Vocabulary API. [[#85]]
12
+
13
+ [#85]: https://github.com/dahlia/fedify/issues/85
14
+
15
+
16
+ Version 0.11.0
17
+ --------------
18
+
19
+ Released on June 29, 2024.
20
+
11
21
  - Improved runtime type error messages for Activity Vocabulary API. [[#79]]
12
22
 
13
23
  - Added `suppressError` option to dereferencing accessors of Activity
package/README.md CHANGED
@@ -129,7 +129,7 @@ Fedify is an ESM-only package, so you need to add `"type": "module"` to the
129
129
  {
130
130
  "type": "module",
131
131
  "dependencies": {
132
- "@fedify/fedify": "^0.11.0"
132
+ "@fedify/fedify": "^0.12.0"
133
133
  }
134
134
  }
135
135
  ~~~~
@@ -0,0 +1,18 @@
1
+ $schema: ../codegen/schema.yaml
2
+ name: ChatMessage
3
+ uri: "http://litepub.social/ns#ChatMessage"
4
+ extends: "https://www.w3.org/ns/activitystreams#Object"
5
+ entity: true
6
+ description: |
7
+ `ChatMessage`s are the messages sent in 1-on-1 chats. They are similar to
8
+ {@link Note}s, but the addressing is done by having a single AP actor in
9
+ the `to` field. Addressing multiple actors is not allowed. These messages
10
+ are always private, there is no public version of them. They are created with
11
+ a {@link Create} activity.
12
+ defaultContext:
13
+ - "https://www.w3.org/ns/activitystreams"
14
+ - "https://w3id.org/security/data-integrity/v1"
15
+ - toot: "http://joinmastodon.org/ns#"
16
+ Emoji: "toot:Emoji"
17
+ ChatMessage: "http://litepub.social/ns#ChatMessage"
18
+ properties: []
@@ -11,4 +11,5 @@ defaultContext:
11
11
  sensitive: "as:sensitive"
12
12
  Emoji: "toot:Emoji"
13
13
  Hashtag: "as:Hashtag"
14
+ ChatMessage: "http://litepub.social/ns#ChatMessage"
14
15
  properties: []
@@ -9,4 +9,5 @@ description: |
9
9
  defaultContext:
10
10
  - "https://www.w3.org/ns/activitystreams"
11
11
  - "https://w3id.org/security/data-integrity/v1"
12
+ - ChatMessage: "http://litepub.social/ns#ChatMessage"
12
13
  properties: []
@@ -16,4 +16,5 @@ defaultContext:
16
16
  sensitive: "as:sensitive"
17
17
  Emoji: "toot:Emoji"
18
18
  Hashtag: "as:Hashtag"
19
+ ChatMessage: "http://litepub.social/ns#ChatMessage"
19
20
  properties: []
@@ -3102,6 +3102,10 @@ export class Object {
3102
3102
  delete values["@type"];
3103
3103
  return await Emoji.fromJsonLd(values, options);
3104
3104
  }
3105
+ if (values["@type"].includes("http://litepub.social/ns#ChatMessage")) {
3106
+ delete values["@type"];
3107
+ return await ChatMessage.fromJsonLd(values, options);
3108
+ }
3105
3109
  if (values["@type"].includes("https://www.w3.org/ns/activitystreams#Activity")) {
3106
3110
  delete values["@type"];
3107
3111
  return await Activity.fromJsonLd(values, options);
@@ -3307,6 +3311,7 @@ export class Object {
3307
3311
  [
3308
3312
  "https://www.w3.org/ns/activitystreams#Object",
3309
3313
  "http://joinmastodon.org/ns#Emoji",
3314
+ "http://litepub.social/ns#ChatMessage",
3310
3315
  "https://www.w3.org/ns/activitystreams#Activity",
3311
3316
  "https://www.w3.org/ns/activitystreams#Accept",
3312
3317
  "https://www.w3.org/ns/activitystreams#Add",
@@ -3474,6 +3479,7 @@ export class Object {
3474
3479
  [
3475
3480
  "https://www.w3.org/ns/activitystreams#Object",
3476
3481
  "http://joinmastodon.org/ns#Emoji",
3482
+ "http://litepub.social/ns#ChatMessage",
3477
3483
  "https://www.w3.org/ns/activitystreams#Activity",
3478
3484
  "https://www.w3.org/ns/activitystreams#Accept",
3479
3485
  "https://www.w3.org/ns/activitystreams#Add",
@@ -3591,6 +3597,7 @@ export class Object {
3591
3597
  [
3592
3598
  "https://www.w3.org/ns/activitystreams#Object",
3593
3599
  "http://joinmastodon.org/ns#Emoji",
3600
+ "http://litepub.social/ns#ChatMessage",
3594
3601
  "https://www.w3.org/ns/activitystreams#Activity",
3595
3602
  "https://www.w3.org/ns/activitystreams#Accept",
3596
3603
  "https://www.w3.org/ns/activitystreams#Add",
@@ -3708,6 +3715,7 @@ export class Object {
3708
3715
  [
3709
3716
  "https://www.w3.org/ns/activitystreams#Object",
3710
3717
  "http://joinmastodon.org/ns#Emoji",
3718
+ "http://litepub.social/ns#ChatMessage",
3711
3719
  "https://www.w3.org/ns/activitystreams#Activity",
3712
3720
  "https://www.w3.org/ns/activitystreams#Accept",
3713
3721
  "https://www.w3.org/ns/activitystreams#Add",
@@ -3789,6 +3797,7 @@ export class Object {
3789
3797
  [
3790
3798
  "https://www.w3.org/ns/activitystreams#Object",
3791
3799
  "http://joinmastodon.org/ns#Emoji",
3800
+ "http://litepub.social/ns#ChatMessage",
3792
3801
  "https://www.w3.org/ns/activitystreams#Activity",
3793
3802
  "https://www.w3.org/ns/activitystreams#Accept",
3794
3803
  "https://www.w3.org/ns/activitystreams#Add",
@@ -3878,6 +3887,7 @@ export class Object {
3878
3887
  [
3879
3888
  "https://www.w3.org/ns/activitystreams#Object",
3880
3889
  "http://joinmastodon.org/ns#Emoji",
3890
+ "http://litepub.social/ns#ChatMessage",
3881
3891
  "https://www.w3.org/ns/activitystreams#Activity",
3882
3892
  "https://www.w3.org/ns/activitystreams#Accept",
3883
3893
  "https://www.w3.org/ns/activitystreams#Add",
@@ -4018,6 +4028,7 @@ export class Object {
4018
4028
  [
4019
4029
  "https://www.w3.org/ns/activitystreams#Object",
4020
4030
  "http://joinmastodon.org/ns#Emoji",
4031
+ "http://litepub.social/ns#ChatMessage",
4021
4032
  "https://www.w3.org/ns/activitystreams#Activity",
4022
4033
  "https://www.w3.org/ns/activitystreams#Accept",
4023
4034
  "https://www.w3.org/ns/activitystreams#Add",
@@ -4792,6 +4803,141 @@ export class Emoji extends Object {
4792
4803
  return "Emoji " + inspect(proxy, options);
4793
4804
  }
4794
4805
  }
4806
+ /** `ChatMessage`s are the messages sent in 1-on-1 chats. They are similar to
4807
+ * {@link Note}s, but the addressing is done by having a single AP actor in
4808
+ * the `to` field. Addressing multiple actors is not allowed. These messages
4809
+ * are always private, there is no public version of them. They are created with
4810
+ * a {@link Create} activity.
4811
+ */
4812
+ export class ChatMessage extends Object {
4813
+ /**
4814
+ * The type URI of {@link ChatMessage}: `http://litepub.social/ns#ChatMessage`.
4815
+ */
4816
+ static get typeId() {
4817
+ return new URL("http://litepub.social/ns#ChatMessage");
4818
+ }
4819
+ /**
4820
+ * Constructs a new instance of ChatMessage with the given values.
4821
+ * @param values The values to initialize the instance with.
4822
+ * @param options The options to use for initialization.
4823
+ */
4824
+ constructor(values, { documentLoader, contextLoader, } = {}) {
4825
+ super(values, { documentLoader, contextLoader });
4826
+ }
4827
+ /**
4828
+ * Clones this instance, optionally updating it with the given values.
4829
+ * @param values The values to update the clone with.
4830
+ * @options The options to use for cloning.
4831
+ * @returns The cloned instance.
4832
+ */
4833
+ clone(values = {}, options = {}) {
4834
+ const clone = super.clone(values, options);
4835
+ return clone;
4836
+ }
4837
+ /**
4838
+ * Converts this object to a JSON-LD structure.
4839
+ * @returns The JSON-LD representation of this object.
4840
+ */
4841
+ async toJsonLd(options = {}) {
4842
+ options = {
4843
+ ...options,
4844
+ contextLoader: options.contextLoader ?? fetchDocumentLoader,
4845
+ };
4846
+ // deno-lint-ignore no-unused-vars prefer-const
4847
+ let array;
4848
+ const baseValues = await super.toJsonLd({
4849
+ ...options,
4850
+ expand: true,
4851
+ });
4852
+ const values = baseValues[0];
4853
+ values["@type"] = ["http://litepub.social/ns#ChatMessage"];
4854
+ if (this.id)
4855
+ values["@id"] = this.id.href;
4856
+ if (options.expand) {
4857
+ return await jsonld.expand(values, { documentLoader: options.contextLoader });
4858
+ }
4859
+ const docContext = options.context ??
4860
+ [
4861
+ "https://www.w3.org/ns/activitystreams",
4862
+ "https://w3id.org/security/data-integrity/v1",
4863
+ {
4864
+ "toot": "http://joinmastodon.org/ns#",
4865
+ "Emoji": "toot:Emoji",
4866
+ "ChatMessage": "http://litepub.social/ns#ChatMessage",
4867
+ },
4868
+ ];
4869
+ const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
4870
+ if (docContext != null) {
4871
+ // Embed context
4872
+ if ("proof" in compacted &&
4873
+ compacted.proof != null) {
4874
+ if (Array.isArray(compacted.proof)) {
4875
+ for (const element of compacted.proof) {
4876
+ element["@context"] = docContext;
4877
+ }
4878
+ }
4879
+ else {
4880
+ compacted.proof["@context"] = docContext;
4881
+ }
4882
+ }
4883
+ }
4884
+ return compacted;
4885
+ }
4886
+ /**
4887
+ * Converts a JSON-LD structure to an object of this type.
4888
+ * @param json The JSON-LD structure to convert.
4889
+ * @returns The object of this type.
4890
+ * @throws {TypeError} If the given `json` is invalid.
4891
+ */
4892
+ static async fromJsonLd(json, options = {}) {
4893
+ if (typeof json === "undefined") {
4894
+ throw new TypeError("Invalid JSON-LD: undefined.");
4895
+ }
4896
+ else if (json === null)
4897
+ throw new TypeError("Invalid JSON-LD: null.");
4898
+ options = {
4899
+ ...options,
4900
+ documentLoader: options.documentLoader ?? fetchDocumentLoader,
4901
+ contextLoader: options.contextLoader ?? fetchDocumentLoader,
4902
+ };
4903
+ // deno-lint-ignore no-explicit-any
4904
+ let values;
4905
+ if (globalThis.Object.keys(json).length == 0) {
4906
+ values = {};
4907
+ }
4908
+ else {
4909
+ const expanded = await jsonld.expand(json, {
4910
+ documentLoader: options.contextLoader,
4911
+ keepFreeFloatingNodes: true,
4912
+ });
4913
+ values =
4914
+ // deno-lint-ignore no-explicit-any
4915
+ (expanded[0] ?? {});
4916
+ }
4917
+ if ("@type" in values) {
4918
+ if (!values["@type"].includes("http://litepub.social/ns#ChatMessage")) {
4919
+ throw new TypeError("Invalid type: " + values["@type"]);
4920
+ }
4921
+ }
4922
+ const instance = await super.fromJsonLd(values, options);
4923
+ if (!(instance instanceof ChatMessage)) {
4924
+ throw new TypeError("Unexpected type: " + instance.constructor.name);
4925
+ }
4926
+ return instance;
4927
+ }
4928
+ _getCustomInspectProxy() {
4929
+ const proxy = super._getCustomInspectProxy();
4930
+ return proxy;
4931
+ }
4932
+ [Symbol.for("Deno.customInspect")](inspect, options) {
4933
+ const proxy = this._getCustomInspectProxy();
4934
+ return "ChatMessage " + inspect(proxy, options);
4935
+ }
4936
+ [Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
4937
+ const proxy = this._getCustomInspectProxy();
4938
+ return "ChatMessage " + inspect(proxy, options);
4939
+ }
4940
+ }
4795
4941
  /** A pair of property name and value.
4796
4942
  */
4797
4943
  export class PropertyValue {
@@ -11833,6 +11979,7 @@ export class Collection extends Object {
11833
11979
  [
11834
11980
  "https://www.w3.org/ns/activitystreams#Object",
11835
11981
  "http://joinmastodon.org/ns#Emoji",
11982
+ "http://litepub.social/ns#ChatMessage",
11836
11983
  "https://www.w3.org/ns/activitystreams#Activity",
11837
11984
  "https://www.w3.org/ns/activitystreams#Accept",
11838
11985
  "https://www.w3.org/ns/activitystreams#Add",
@@ -12512,6 +12659,7 @@ export class Create extends Activity {
12512
12659
  "sensitive": "as:sensitive",
12513
12660
  "Emoji": "toot:Emoji",
12514
12661
  "Hashtag": "as:Hashtag",
12662
+ "ChatMessage": "http://litepub.social/ns#ChatMessage",
12515
12663
  },
12516
12664
  ];
12517
12665
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
@@ -12640,6 +12788,7 @@ export class Delete extends Activity {
12640
12788
  [
12641
12789
  "https://www.w3.org/ns/activitystreams",
12642
12790
  "https://w3id.org/security/data-integrity/v1",
12791
+ { "ChatMessage": "http://litepub.social/ns#ChatMessage" },
12643
12792
  ];
12644
12793
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
12645
12794
  if (docContext != null) {
@@ -16449,6 +16598,7 @@ export class Link {
16449
16598
  [
16450
16599
  "https://www.w3.org/ns/activitystreams#Object",
16451
16600
  "http://joinmastodon.org/ns#Emoji",
16601
+ "http://litepub.social/ns#ChatMessage",
16452
16602
  "https://www.w3.org/ns/activitystreams#Activity",
16453
16603
  "https://www.w3.org/ns/activitystreams#Accept",
16454
16604
  "https://www.w3.org/ns/activitystreams#Add",
@@ -18113,6 +18263,7 @@ export class OrderedCollection extends Collection {
18113
18263
  [
18114
18264
  "https://www.w3.org/ns/activitystreams#Object",
18115
18265
  "http://joinmastodon.org/ns#Emoji",
18266
+ "http://litepub.social/ns#ChatMessage",
18116
18267
  "https://www.w3.org/ns/activitystreams#Activity",
18117
18268
  "https://www.w3.org/ns/activitystreams#Accept",
18118
18269
  "https://www.w3.org/ns/activitystreams#Add",
@@ -18487,6 +18638,7 @@ export class OrderedCollectionPage extends CollectionPage {
18487
18638
  [
18488
18639
  "https://www.w3.org/ns/activitystreams#Object",
18489
18640
  "http://joinmastodon.org/ns#Emoji",
18641
+ "http://litepub.social/ns#ChatMessage",
18490
18642
  "https://www.w3.org/ns/activitystreams#Activity",
18491
18643
  "https://www.w3.org/ns/activitystreams#Accept",
18492
18644
  "https://www.w3.org/ns/activitystreams#Add",
@@ -27110,6 +27262,7 @@ export class Update extends Activity {
27110
27262
  "sensitive": "as:sensitive",
27111
27263
  "Emoji": "toot:Emoji",
27112
27264
  "Hashtag": "as:Hashtag",
27265
+ "ChatMessage": "http://litepub.social/ns#ChatMessage",
27113
27266
  },
27114
27267
  ];
27115
27268
  const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/fedify",
3
- "version": "0.11.0-dev.260+31b0b19c",
3
+ "version": "0.12.0-dev.262+0b8a9121",
4
4
  "description": "An ActivityPub server framework",
5
5
  "keywords": [
6
6
  "ActivityPub",
@@ -775,6 +775,149 @@ export declare class Emoji extends Object {
775
775
  }): Promise<Emoji>;
776
776
  protected _getCustomInspectProxy(): Record<string, unknown>;
777
777
  }
778
+ /** `ChatMessage`s are the messages sent in 1-on-1 chats. They are similar to
779
+ * {@link Note}s, but the addressing is done by having a single AP actor in
780
+ * the `to` field. Addressing multiple actors is not allowed. These messages
781
+ * are always private, there is no public version of them. They are created with
782
+ * a {@link Create} activity.
783
+ */
784
+ export declare class ChatMessage extends Object {
785
+ /**
786
+ * The type URI of {@link ChatMessage}: `http://litepub.social/ns#ChatMessage`.
787
+ */
788
+ static get typeId(): URL;
789
+ /**
790
+ * Constructs a new instance of ChatMessage with the given values.
791
+ * @param values The values to initialize the instance with.
792
+ * @param options The options to use for initialization.
793
+ */
794
+ constructor(values: {
795
+ id?: URL | null;
796
+ attachments?: (Object | Link | PropertyValue | URL)[];
797
+ attribution?: Application | Group | Organization | Person | Service | URL | null;
798
+ attributions?: (Application | Group | Organization | Person | Service | URL)[];
799
+ audience?: Object | URL | null;
800
+ audiences?: (Object | URL)[];
801
+ content?: string | LanguageString | null;
802
+ contents?: ((string | LanguageString))[];
803
+ contexts?: (Object | Link | URL)[];
804
+ name?: string | LanguageString | null;
805
+ names?: ((string | LanguageString))[];
806
+ endTime?: dntShim.Temporal.Instant | null;
807
+ generators?: (Object | Link | URL)[];
808
+ icon?: Image | URL | null;
809
+ icons?: (Image | URL)[];
810
+ image?: Image | URL | null;
811
+ images?: (Image | URL)[];
812
+ replyTarget?: Object | Link | URL | null;
813
+ replyTargets?: (Object | Link | URL)[];
814
+ location?: Object | Link | URL | null;
815
+ locations?: (Object | Link | URL)[];
816
+ preview?: Link | Object | URL | null;
817
+ previews?: (Link | Object | URL)[];
818
+ published?: dntShim.Temporal.Instant | null;
819
+ replies?: Collection | URL | null;
820
+ startTime?: dntShim.Temporal.Instant | null;
821
+ summary?: string | LanguageString | null;
822
+ summaries?: ((string | LanguageString))[];
823
+ tags?: (Object | Link | URL)[];
824
+ updated?: dntShim.Temporal.Instant | null;
825
+ url?: URL | Link | null;
826
+ urls?: ((URL | Link))[];
827
+ to?: Object | URL | null;
828
+ tos?: (Object | URL)[];
829
+ bto?: Object | URL | null;
830
+ btos?: (Object | URL)[];
831
+ cc?: Object | URL | null;
832
+ ccs?: (Object | URL)[];
833
+ bcc?: Object | URL | null;
834
+ bccs?: (Object | URL)[];
835
+ mediaType?: string | null;
836
+ duration?: dntShim.Temporal.Duration | null;
837
+ sensitive?: boolean | null;
838
+ proof?: DataIntegrityProof | URL | null;
839
+ proofs?: (DataIntegrityProof | URL)[];
840
+ }, { documentLoader, contextLoader, }?: {
841
+ documentLoader?: DocumentLoader;
842
+ contextLoader?: DocumentLoader;
843
+ });
844
+ /**
845
+ * Clones this instance, optionally updating it with the given values.
846
+ * @param values The values to update the clone with.
847
+ * @options The options to use for cloning.
848
+ * @returns The cloned instance.
849
+ */
850
+ clone(values?: {
851
+ id?: URL | null;
852
+ attachments?: (Object | Link | PropertyValue | URL)[];
853
+ attribution?: Application | Group | Organization | Person | Service | URL | null;
854
+ attributions?: (Application | Group | Organization | Person | Service | URL)[];
855
+ audience?: Object | URL | null;
856
+ audiences?: (Object | URL)[];
857
+ content?: string | LanguageString | null;
858
+ contents?: ((string | LanguageString))[];
859
+ contexts?: (Object | Link | URL)[];
860
+ name?: string | LanguageString | null;
861
+ names?: ((string | LanguageString))[];
862
+ endTime?: dntShim.Temporal.Instant | null;
863
+ generators?: (Object | Link | URL)[];
864
+ icon?: Image | URL | null;
865
+ icons?: (Image | URL)[];
866
+ image?: Image | URL | null;
867
+ images?: (Image | URL)[];
868
+ replyTarget?: Object | Link | URL | null;
869
+ replyTargets?: (Object | Link | URL)[];
870
+ location?: Object | Link | URL | null;
871
+ locations?: (Object | Link | URL)[];
872
+ preview?: Link | Object | URL | null;
873
+ previews?: (Link | Object | URL)[];
874
+ published?: dntShim.Temporal.Instant | null;
875
+ replies?: Collection | URL | null;
876
+ startTime?: dntShim.Temporal.Instant | null;
877
+ summary?: string | LanguageString | null;
878
+ summaries?: ((string | LanguageString))[];
879
+ tags?: (Object | Link | URL)[];
880
+ updated?: dntShim.Temporal.Instant | null;
881
+ url?: URL | Link | null;
882
+ urls?: ((URL | Link))[];
883
+ to?: Object | URL | null;
884
+ tos?: (Object | URL)[];
885
+ bto?: Object | URL | null;
886
+ btos?: (Object | URL)[];
887
+ cc?: Object | URL | null;
888
+ ccs?: (Object | URL)[];
889
+ bcc?: Object | URL | null;
890
+ bccs?: (Object | URL)[];
891
+ mediaType?: string | null;
892
+ duration?: dntShim.Temporal.Duration | null;
893
+ sensitive?: boolean | null;
894
+ proof?: DataIntegrityProof | URL | null;
895
+ proofs?: (DataIntegrityProof | URL)[];
896
+ }, options?: {
897
+ documentLoader?: DocumentLoader;
898
+ contextLoader?: DocumentLoader;
899
+ }): ChatMessage;
900
+ /**
901
+ * Converts this object to a JSON-LD structure.
902
+ * @returns The JSON-LD representation of this object.
903
+ */
904
+ toJsonLd(options?: {
905
+ expand?: boolean;
906
+ contextLoader?: DocumentLoader;
907
+ context?: string | Record<string, string> | (string | Record<string, string>)[];
908
+ }): Promise<unknown>;
909
+ /**
910
+ * Converts a JSON-LD structure to an object of this type.
911
+ * @param json The JSON-LD structure to convert.
912
+ * @returns The object of this type.
913
+ * @throws {TypeError} If the given `json` is invalid.
914
+ */
915
+ static fromJsonLd(json: unknown, options?: {
916
+ documentLoader?: DocumentLoader;
917
+ contextLoader?: DocumentLoader;
918
+ }): Promise<ChatMessage>;
919
+ protected _getCustomInspectProxy(): Record<string, unknown>;
920
+ }
778
921
  /** A pair of property name and value.
779
922
  */
780
923
  export declare class PropertyValue {