@fedify/fedify 1.1.0-dev.428 → 1.1.0-dev.429

Sign up to get free protection for your applications and to get access to all the features.
@@ -7844,6 +7844,420 @@ export class PropertyValue {
7844
7844
  return "PropertyValue " + inspect(proxy, options);
7845
7845
  }
7846
7846
  }
7847
+ /** Means of communicating or interacting with the DID subject or associated
7848
+ * entities via one or more service endpoints. Examples include discovery
7849
+ * services, agent services, social networking services, file storage services,
7850
+ * and verifiable credential repository services.
7851
+ */
7852
+ export class DidService {
7853
+ #documentLoader;
7854
+ #contextLoader;
7855
+ id;
7856
+ get _documentLoader() {
7857
+ return this.#documentLoader;
7858
+ }
7859
+ get _contextLoader() {
7860
+ return this.#contextLoader;
7861
+ }
7862
+ #cachedJsonLd;
7863
+ /**
7864
+ * The type URI of {@link DidService}: `https://www.w3.org/ns/did#Service`.
7865
+ */
7866
+ static get typeId() {
7867
+ return new URL("https://www.w3.org/ns/did#Service");
7868
+ }
7869
+ #_2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint = [];
7870
+ /**
7871
+ * Constructs a new instance of DidService with the given values.
7872
+ * @param values The values to initialize the instance with.
7873
+ * @param options The options to use for initialization.
7874
+ */
7875
+ constructor(values, { documentLoader, contextLoader, } = {}) {
7876
+ this.#documentLoader = documentLoader;
7877
+ this.#contextLoader = contextLoader;
7878
+ if (values.id == null || values.id instanceof URL) {
7879
+ this.id = values.id ?? null;
7880
+ }
7881
+ else {
7882
+ throw new TypeError("The id must be a URL.");
7883
+ }
7884
+ if ("endpoint" in values && values.endpoint != null) {
7885
+ if (values.endpoint instanceof URL) {
7886
+ // @ts-ignore: type is checked above.
7887
+ this.#_2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint = [values.endpoint];
7888
+ }
7889
+ else {
7890
+ throw new TypeError("The endpoint must be of type " +
7891
+ "URL" + ".");
7892
+ }
7893
+ }
7894
+ if ("endpoints" in values && values.endpoints != null) {
7895
+ if ("endpoint" in values &&
7896
+ values.endpoint != null) {
7897
+ throw new TypeError("Cannot initialize both endpoint and " +
7898
+ "endpoints at the same time.");
7899
+ }
7900
+ if (Array.isArray(values.endpoints) &&
7901
+ values.endpoints.every((v) => v instanceof URL)) {
7902
+ // @ts-ignore: type is checked above.
7903
+ this.#_2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint = values.endpoints;
7904
+ }
7905
+ else {
7906
+ throw new TypeError("The endpoints must be an array of type " +
7907
+ "URL" + ".");
7908
+ }
7909
+ }
7910
+ }
7911
+ /**
7912
+ * Clones this instance, optionally updating it with the given values.
7913
+ * @param values The values to update the clone with.
7914
+ * @options The options to use for cloning.
7915
+ * @returns The cloned instance.
7916
+ */
7917
+ clone(values = {}, options = {}) {
7918
+ // @ts-ignore: this.constructor is not recognized as a constructor, but it is.
7919
+ const clone = new this.constructor({ id: values.id ?? this.id }, options);
7920
+ clone.#_2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint =
7921
+ this.#_2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint;
7922
+ if ("endpoint" in values && values.endpoint != null) {
7923
+ if (values.endpoint instanceof URL) {
7924
+ // @ts-ignore: type is checked above.
7925
+ clone.#_2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint = [
7926
+ values.endpoint,
7927
+ ];
7928
+ }
7929
+ else {
7930
+ throw new TypeError("The endpoint must be of type " +
7931
+ "URL" + ".");
7932
+ }
7933
+ }
7934
+ if ("endpoints" in values && values.endpoints != null) {
7935
+ if ("endpoint" in values &&
7936
+ values.endpoint != null) {
7937
+ throw new TypeError("Cannot update both endpoint and " +
7938
+ "endpoints at the same time.");
7939
+ }
7940
+ if (Array.isArray(values.endpoints) &&
7941
+ values.endpoints.every((v) => v instanceof URL)) {
7942
+ // @ts-ignore: type is checked above.
7943
+ clone.#_2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint = values.endpoints;
7944
+ }
7945
+ else {
7946
+ throw new TypeError("The endpoints must be an array of type " +
7947
+ "URL" + ".");
7948
+ }
7949
+ }
7950
+ return clone;
7951
+ }
7952
+ /** A network address, such as an HTTP URL, at which services operate on behalf
7953
+ * of a DID subject.
7954
+ */
7955
+ get endpoint() {
7956
+ if (this.#_2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint.length < 1) {
7957
+ return null;
7958
+ }
7959
+ return this.#_2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint[0];
7960
+ }
7961
+ /** A network address, such as an HTTP URL, at which services operate on behalf
7962
+ * of a DID subject.
7963
+ */
7964
+ get endpoints() {
7965
+ return this.#_2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint;
7966
+ }
7967
+ /**
7968
+ * Converts this object to a JSON-LD structure.
7969
+ * @param options The options to use.
7970
+ * - `format`: The format of the output: `compact` or
7971
+ `expand`.
7972
+ * - `contextLoader`: The loader for remote JSON-LD contexts.
7973
+ * - `context`: The JSON-LD context to use. Not applicable
7974
+ when `format` is set to `'expand'`.
7975
+ * @returns The JSON-LD representation of this object.
7976
+ */
7977
+ async toJsonLd(options = {}) {
7978
+ if (options.format == null && this.#cachedJsonLd != null) {
7979
+ return this.#cachedJsonLd;
7980
+ }
7981
+ if (options.format !== "compact" && options.context != null) {
7982
+ throw new TypeError("The context option can only be used when the format option is set " +
7983
+ "to 'compact'.");
7984
+ }
7985
+ options = {
7986
+ ...options,
7987
+ contextLoader: options.contextLoader ?? fetchDocumentLoader,
7988
+ };
7989
+ // deno-lint-ignore no-unused-vars prefer-const
7990
+ let array;
7991
+ const values = {};
7992
+ array = [];
7993
+ for (const v of this.#_2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint) {
7994
+ const element = { "@id": v.href };
7995
+ array.push(element);
7996
+ }
7997
+ if (array.length > 0) {
7998
+ const propValue = array;
7999
+ values["https://www.w3.org/ns/did#serviceEndpoint"] = propValue;
8000
+ }
8001
+ values["@type"] = ["https://www.w3.org/ns/did#Service"];
8002
+ if (this.id != null)
8003
+ values["@id"] = this.id.href;
8004
+ if (options.format === "expand") {
8005
+ return await jsonld.expand(values, { documentLoader: options.contextLoader });
8006
+ }
8007
+ const docContext = options.context ??
8008
+ "https://www.w3.org/ns/did/v1";
8009
+ const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
8010
+ if (docContext != null) {
8011
+ // Embed context
8012
+ }
8013
+ return compacted;
8014
+ }
8015
+ isCompactable() {
8016
+ return true;
8017
+ }
8018
+ /**
8019
+ * Converts a JSON-LD structure to an object of this type.
8020
+ * @param json The JSON-LD structure to convert.
8021
+ * @returns The object of this type.
8022
+ * @throws {TypeError} If the given `json` is invalid.
8023
+ */
8024
+ static async fromJsonLd(json, options = {}) {
8025
+ if (typeof json === "undefined") {
8026
+ throw new TypeError("Invalid JSON-LD: undefined.");
8027
+ }
8028
+ else if (json === null)
8029
+ throw new TypeError("Invalid JSON-LD: null.");
8030
+ options = {
8031
+ ...options,
8032
+ documentLoader: options.documentLoader ?? fetchDocumentLoader,
8033
+ contextLoader: options.contextLoader ?? fetchDocumentLoader,
8034
+ };
8035
+ // deno-lint-ignore no-explicit-any
8036
+ let values;
8037
+ if (globalThis.Object.keys(json).length == 0) {
8038
+ values = {};
8039
+ }
8040
+ else {
8041
+ const expanded = await jsonld.expand(json, {
8042
+ documentLoader: options.contextLoader,
8043
+ keepFreeFloatingNodes: true,
8044
+ });
8045
+ values =
8046
+ // deno-lint-ignore no-explicit-any
8047
+ (expanded[0] ?? {});
8048
+ }
8049
+ if ("@type" in values) {
8050
+ if (values["@type"].includes("https://w3id.org/fep/9091#Export")) {
8051
+ return await Export.fromJsonLd(json, options);
8052
+ }
8053
+ if (!values["@type"].includes("https://www.w3.org/ns/did#Service")) {
8054
+ throw new TypeError("Invalid type: " + values["@type"]);
8055
+ }
8056
+ }
8057
+ const instance = new this({ id: "@id" in values ? new URL(values["@id"]) : undefined }, options);
8058
+ const _2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint = [];
8059
+ let _2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint__array = values["https://www.w3.org/ns/did#serviceEndpoint"];
8060
+ for (const v of _2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint__array == null
8061
+ ? []
8062
+ : _2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint__array.length === 1 &&
8063
+ "@list" in _2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint__array[0]
8064
+ ? _2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint__array[0]["@list"]
8065
+ : _2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint__array) {
8066
+ if (v == null)
8067
+ continue;
8068
+ _2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint.push(new URL(v["@id"]));
8069
+ }
8070
+ instance.#_2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint =
8071
+ _2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint;
8072
+ if (!("_fromSubclass" in options) || !options._fromSubclass) {
8073
+ try {
8074
+ instance.#cachedJsonLd = structuredClone(json);
8075
+ }
8076
+ catch {
8077
+ getLogger(["fedify", "vocab"]).warn("Failed to cache JSON-LD: {json}", { json });
8078
+ }
8079
+ }
8080
+ return instance;
8081
+ }
8082
+ _getCustomInspectProxy() {
8083
+ const proxy = {};
8084
+ if (this.id != null) {
8085
+ proxy.id = {
8086
+ [Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(this.id.href, options),
8087
+ [Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(this.id.href, options),
8088
+ };
8089
+ }
8090
+ const _2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint = this
8091
+ .#_2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint
8092
+ // deno-lint-ignore no-explicit-any
8093
+ .map((v) => v instanceof URL
8094
+ ? {
8095
+ [Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
8096
+ [Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
8097
+ }
8098
+ : v);
8099
+ if (_2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint.length == 1) {
8100
+ proxy.endpoint = _2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint[0];
8101
+ }
8102
+ if (_2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint.length > 1 ||
8103
+ !("endpoint" in proxy) &&
8104
+ _2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint.length > 0) {
8105
+ proxy.endpoints = _2KM4fetG6FTJ1cphj76rzJ8Dyv7p_serviceEndpoint;
8106
+ }
8107
+ return proxy;
8108
+ }
8109
+ [Symbol.for("Deno.customInspect")](inspect, options) {
8110
+ const proxy = this._getCustomInspectProxy();
8111
+ return "DidService " + inspect(proxy, options);
8112
+ }
8113
+ [Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
8114
+ const proxy = this._getCustomInspectProxy();
8115
+ return "DidService " + inspect(proxy, options);
8116
+ }
8117
+ }
8118
+ /** "Export Actor" service.
8119
+ */
8120
+ export class Export extends DidService {
8121
+ #cachedJsonLd;
8122
+ /**
8123
+ * The type URI of {@link Export}: `https://w3id.org/fep/9091#Export`.
8124
+ */
8125
+ static get typeId() {
8126
+ return new URL("https://w3id.org/fep/9091#Export");
8127
+ }
8128
+ /**
8129
+ * Constructs a new instance of Export with the given values.
8130
+ * @param values The values to initialize the instance with.
8131
+ * @param options The options to use for initialization.
8132
+ */
8133
+ constructor(values, { documentLoader, contextLoader, } = {}) {
8134
+ super(values, { documentLoader, contextLoader });
8135
+ }
8136
+ /**
8137
+ * Clones this instance, optionally updating it with the given values.
8138
+ * @param values The values to update the clone with.
8139
+ * @options The options to use for cloning.
8140
+ * @returns The cloned instance.
8141
+ */
8142
+ clone(values = {}, options = {}) {
8143
+ const clone = super.clone(values, options);
8144
+ return clone;
8145
+ }
8146
+ /**
8147
+ * Converts this object to a JSON-LD structure.
8148
+ * @param options The options to use.
8149
+ * - `format`: The format of the output: `compact` or
8150
+ `expand`.
8151
+ * - `contextLoader`: The loader for remote JSON-LD contexts.
8152
+ * - `context`: The JSON-LD context to use. Not applicable
8153
+ when `format` is set to `'expand'`.
8154
+ * @returns The JSON-LD representation of this object.
8155
+ */
8156
+ async toJsonLd(options = {}) {
8157
+ if (options.format == null && this.#cachedJsonLd != null) {
8158
+ return this.#cachedJsonLd;
8159
+ }
8160
+ if (options.format !== "compact" && options.context != null) {
8161
+ throw new TypeError("The context option can only be used when the format option is set " +
8162
+ "to 'compact'.");
8163
+ }
8164
+ options = {
8165
+ ...options,
8166
+ contextLoader: options.contextLoader ?? fetchDocumentLoader,
8167
+ };
8168
+ // deno-lint-ignore no-unused-vars prefer-const
8169
+ let array;
8170
+ const baseValues = await super.toJsonLd({
8171
+ ...options,
8172
+ format: "expand",
8173
+ context: undefined,
8174
+ });
8175
+ const values = baseValues[0];
8176
+ values["@type"] = ["https://w3id.org/fep/9091#Export"];
8177
+ if (this.id != null)
8178
+ values["@id"] = this.id.href;
8179
+ if (options.format === "expand") {
8180
+ return await jsonld.expand(values, { documentLoader: options.contextLoader });
8181
+ }
8182
+ const docContext = options.context ??
8183
+ "https://www.w3.org/ns/did/v1";
8184
+ const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
8185
+ if (docContext != null) {
8186
+ // Embed context
8187
+ }
8188
+ return compacted;
8189
+ }
8190
+ isCompactable() {
8191
+ return super.isCompactable();
8192
+ }
8193
+ /**
8194
+ * Converts a JSON-LD structure to an object of this type.
8195
+ * @param json The JSON-LD structure to convert.
8196
+ * @returns The object of this type.
8197
+ * @throws {TypeError} If the given `json` is invalid.
8198
+ */
8199
+ static async fromJsonLd(json, options = {}) {
8200
+ if (typeof json === "undefined") {
8201
+ throw new TypeError("Invalid JSON-LD: undefined.");
8202
+ }
8203
+ else if (json === null)
8204
+ throw new TypeError("Invalid JSON-LD: null.");
8205
+ options = {
8206
+ ...options,
8207
+ documentLoader: options.documentLoader ?? fetchDocumentLoader,
8208
+ contextLoader: options.contextLoader ?? fetchDocumentLoader,
8209
+ };
8210
+ // deno-lint-ignore no-explicit-any
8211
+ let values;
8212
+ if (globalThis.Object.keys(json).length == 0) {
8213
+ values = {};
8214
+ }
8215
+ else {
8216
+ const expanded = await jsonld.expand(json, {
8217
+ documentLoader: options.contextLoader,
8218
+ keepFreeFloatingNodes: true,
8219
+ });
8220
+ values =
8221
+ // deno-lint-ignore no-explicit-any
8222
+ (expanded[0] ?? {});
8223
+ }
8224
+ if ("@type" in values) {
8225
+ if (!values["@type"].includes("https://w3id.org/fep/9091#Export")) {
8226
+ throw new TypeError("Invalid type: " + values["@type"]);
8227
+ }
8228
+ }
8229
+ delete values["@type"];
8230
+ const instance = await super.fromJsonLd(values, {
8231
+ ...options,
8232
+ // @ts-ignore: an internal option
8233
+ _fromSubclass: true,
8234
+ });
8235
+ if (!(instance instanceof Export)) {
8236
+ throw new TypeError("Unexpected type: " + instance.constructor.name);
8237
+ }
8238
+ if (!("_fromSubclass" in options) || !options._fromSubclass) {
8239
+ try {
8240
+ instance.#cachedJsonLd = structuredClone(json);
8241
+ }
8242
+ catch {
8243
+ getLogger(["fedify", "vocab"]).warn("Failed to cache JSON-LD: {json}", { json });
8244
+ }
8245
+ }
8246
+ return instance;
8247
+ }
8248
+ _getCustomInspectProxy() {
8249
+ const proxy = super._getCustomInspectProxy();
8250
+ return proxy;
8251
+ }
8252
+ [Symbol.for("Deno.customInspect")](inspect, options) {
8253
+ const proxy = this._getCustomInspectProxy();
8254
+ return "Export " + inspect(proxy, options);
8255
+ }
8256
+ [Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
8257
+ const proxy = this._getCustomInspectProxy();
8258
+ return "Export " + inspect(proxy, options);
8259
+ }
8260
+ }
7847
8261
  /** A proof that can be added to any activity or object, allowing recipients to
7848
8262
  * verify the identity of the actor and the integrity of the data.
7849
8263
  */
@@ -9911,6 +10325,7 @@ export class Application extends Object {
9911
10325
  #_79S8K4f5J9MWUgCxziRyUe6PTHZ_memorial = [];
9912
10326
  #_2diCorzqPGQQqftp6e4SrCEwEnyk_indexable = [];
9913
10327
  #_3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs = [];
10328
+ #_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = [];
9914
10329
  #_2xEU4QtkC53RAun67T81Egqt9vmL_isCat = [];
9915
10330
  /**
9916
10331
  * Constructs a new instance of Application with the given values.
@@ -10187,6 +10602,32 @@ export class Application extends Object {
10187
10602
  "Application | Group | Organization | Person | Service | URL" + ".");
10188
10603
  }
10189
10604
  }
10605
+ if ("service" in values && values.service != null) {
10606
+ if (values.service instanceof DidService || values.service instanceof URL) {
10607
+ // @ts-ignore: type is checked above.
10608
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = [values.service];
10609
+ }
10610
+ else {
10611
+ throw new TypeError("The service must be of type " +
10612
+ "DidService | URL" + ".");
10613
+ }
10614
+ }
10615
+ if ("services" in values && values.services != null) {
10616
+ if ("service" in values &&
10617
+ values.service != null) {
10618
+ throw new TypeError("Cannot initialize both service and " +
10619
+ "services at the same time.");
10620
+ }
10621
+ if (Array.isArray(values.services) &&
10622
+ values.services.every((v) => v instanceof DidService || v instanceof URL)) {
10623
+ // @ts-ignore: type is checked above.
10624
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = values.services;
10625
+ }
10626
+ else {
10627
+ throw new TypeError("The services must be an array of type " +
10628
+ "DidService | URL" + ".");
10629
+ }
10630
+ }
10190
10631
  if ("cat" in values && values.cat != null) {
10191
10632
  if (typeof values.cat === "boolean") {
10192
10633
  // @ts-ignore: type is checked above.
@@ -10512,6 +10953,34 @@ export class Application extends Object {
10512
10953
  "Application | Group | Organization | Person | Service | URL" + ".");
10513
10954
  }
10514
10955
  }
10956
+ clone.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service =
10957
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service;
10958
+ if ("service" in values && values.service != null) {
10959
+ if (values.service instanceof DidService || values.service instanceof URL) {
10960
+ // @ts-ignore: type is checked above.
10961
+ clone.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = [values.service];
10962
+ }
10963
+ else {
10964
+ throw new TypeError("The service must be of type " +
10965
+ "DidService | URL" + ".");
10966
+ }
10967
+ }
10968
+ if ("services" in values && values.services != null) {
10969
+ if ("service" in values &&
10970
+ values.service != null) {
10971
+ throw new TypeError("Cannot update both service and " +
10972
+ "services at the same time.");
10973
+ }
10974
+ if (Array.isArray(values.services) &&
10975
+ values.services.every((v) => v instanceof DidService || v instanceof URL)) {
10976
+ // @ts-ignore: type is checked above.
10977
+ clone.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = values.services;
10978
+ }
10979
+ else {
10980
+ throw new TypeError("The services must be an array of type " +
10981
+ "DidService | URL" + ".");
10982
+ }
10983
+ }
10515
10984
  clone.#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat =
10516
10985
  this.#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat;
10517
10986
  if ("cat" in values && values.cat != null) {
@@ -11365,6 +11834,92 @@ export class Application extends Object {
11365
11834
  yield v;
11366
11835
  }
11367
11836
  }
11837
+ async #fetchService(url, options = {}) {
11838
+ const documentLoader = options.documentLoader ?? this._documentLoader ??
11839
+ fetchDocumentLoader;
11840
+ const contextLoader = options.contextLoader ?? this._contextLoader ??
11841
+ fetchDocumentLoader;
11842
+ let fetchResult;
11843
+ try {
11844
+ fetchResult = await documentLoader(url.href);
11845
+ }
11846
+ catch (error) {
11847
+ if (options.suppressError) {
11848
+ getLogger(["fedify", "vocab"]).error("Failed to fetch {url}: {error}", { error, url: url.href });
11849
+ return null;
11850
+ }
11851
+ throw error;
11852
+ }
11853
+ const { document } = fetchResult;
11854
+ try {
11855
+ return await DidService.fromJsonLd(document, { documentLoader, contextLoader });
11856
+ }
11857
+ catch (e) {
11858
+ if (!(e instanceof TypeError))
11859
+ throw e;
11860
+ }
11861
+ throw new TypeError("Expected an object of any type of: " +
11862
+ ["https://www.w3.org/ns/did#Service"].join(", "));
11863
+ }
11864
+ /**
11865
+ * Similar to
11866
+ * {@link Application.getService},
11867
+ * but returns its `@id` URL instead of the object itself.
11868
+ */
11869
+ get serviceId() {
11870
+ if (this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length < 1)
11871
+ return null;
11872
+ const v = this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service[0];
11873
+ if (v instanceof URL)
11874
+ return v;
11875
+ return v.id;
11876
+ }
11877
+ /** Means of communicating or interacting with the DID subject or associated
11878
+ * entities via one or more service endpoints. Examples include discovery
11879
+ * services, agent services, social networking services, file storage services,
11880
+ * and verifiable credential repository services.
11881
+ */
11882
+ async getService(options = {}) {
11883
+ if (this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length < 1)
11884
+ return null;
11885
+ const v = this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service[0];
11886
+ if (v instanceof URL) {
11887
+ const fetched = await this.#fetchService(v, options);
11888
+ if (fetched == null)
11889
+ return null;
11890
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service[0] = fetched;
11891
+ return fetched;
11892
+ }
11893
+ return v;
11894
+ }
11895
+ /**
11896
+ * Similar to
11897
+ * {@link Application.getServices},
11898
+ * but returns their `@id`s instead of the objects themselves.
11899
+ */
11900
+ get serviceIds() {
11901
+ return this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.map((v) => v instanceof URL ? v : v.id).filter((id) => id !== null);
11902
+ }
11903
+ /** Means of communicating or interacting with the DID subject or associated
11904
+ * entities via one or more service endpoints. Examples include discovery
11905
+ * services, agent services, social networking services, file storage services,
11906
+ * and verifiable credential repository services.
11907
+ */
11908
+ async *getServices(options = {}) {
11909
+ const vs = this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service;
11910
+ for (let i = 0; i < vs.length; i++) {
11911
+ const v = vs[i];
11912
+ if (v instanceof URL) {
11913
+ const fetched = await this.#fetchService(v, options);
11914
+ if (fetched == null)
11915
+ continue;
11916
+ vs[i] = fetched;
11917
+ yield fetched;
11918
+ continue;
11919
+ }
11920
+ yield v;
11921
+ }
11922
+ }
11368
11923
  /** Used on actors to indicate that they in some way identify as a cat,
11369
11924
  * expressed as a boolean value. If this property is set to `true`,
11370
11925
  * displaying the actor or their notes will have some special effects
@@ -11663,6 +12218,20 @@ export class Application extends Object {
11663
12218
  : compactItems[0];
11664
12219
  }
11665
12220
  compactItems = [];
12221
+ for (const v of this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service) {
12222
+ const item = v instanceof URL ? v.href : await v.toJsonLd({
12223
+ ...options,
12224
+ format: undefined,
12225
+ context: undefined,
12226
+ });
12227
+ compactItems.push(item);
12228
+ }
12229
+ if (compactItems.length > 0) {
12230
+ result["service"] = compactItems.length > 1
12231
+ ? compactItems
12232
+ : compactItems[0];
12233
+ }
12234
+ compactItems = [];
11666
12235
  for (const v of this.#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat) {
11667
12236
  const item = v;
11668
12237
  compactItems.push(item);
@@ -11901,7 +12470,18 @@ export class Application extends Object {
11901
12470
  }
11902
12471
  if (array.length > 0) {
11903
12472
  const propValue = array;
11904
- values["https://www.w3.org/ns/activitystreams#alsoKnownAs"] = propValue;
12473
+ values["https://www.w3.org/ns/activitystreams#alsoKnownAs"] = propValue;
12474
+ }
12475
+ array = [];
12476
+ for (const v of this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service) {
12477
+ const element = v instanceof URL
12478
+ ? { "@id": v.href }
12479
+ : await v.toJsonLd(options);
12480
+ array.push(element);
12481
+ }
12482
+ if (array.length > 0) {
12483
+ const propValue = array;
12484
+ values["https://www.w3.org/ns/did#service"] = propValue;
11905
12485
  }
11906
12486
  array = [];
11907
12487
  for (const v of this.#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat) {
@@ -11962,6 +12542,9 @@ export class Application extends Object {
11962
12542
  if (this.#_3isuDgRAKSntq9XdbjiNxjwyPZAf_preferredUsername != null &&
11963
12543
  this.#_3isuDgRAKSntq9XdbjiNxjwyPZAf_preferredUsername.length > 0)
11964
12544
  return false;
12545
+ if (this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service != null &&
12546
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length > 0)
12547
+ return false;
11965
12548
  return super.isCompactable();
11966
12549
  }
11967
12550
  /**
@@ -12351,6 +12934,25 @@ export class Application extends Object {
12351
12934
  }
12352
12935
  instance.#_3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs =
12353
12936
  _3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs;
12937
+ const _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = [];
12938
+ let _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array = values["https://www.w3.org/ns/did#service"];
12939
+ for (const v of _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array == null
12940
+ ? []
12941
+ : _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array.length === 1 &&
12942
+ "@list" in _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array[0]
12943
+ ? _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array[0]["@list"]
12944
+ : _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array) {
12945
+ if (v == null)
12946
+ continue;
12947
+ if (typeof v === "object" && "@id" in v && !("@type" in v) &&
12948
+ globalThis.Object.keys(v).length === 1) {
12949
+ _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.push(new URL(v["@id"]));
12950
+ continue;
12951
+ }
12952
+ _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.push(await DidService.fromJsonLd(v, options));
12953
+ }
12954
+ instance.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service =
12955
+ _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service;
12354
12956
  const _2xEU4QtkC53RAun67T81Egqt9vmL_isCat = [];
12355
12957
  let _2xEU4QtkC53RAun67T81Egqt9vmL_isCat__array = values["https://misskey-hub.net/ns#isCat"];
12356
12958
  for (const v of _2xEU4QtkC53RAun67T81Egqt9vmL_isCat__array == null
@@ -12618,6 +13220,23 @@ export class Application extends Object {
12618
13220
  _3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs.length > 0) {
12619
13221
  proxy.aliases = _3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs;
12620
13222
  }
13223
+ const _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = this
13224
+ .#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service
13225
+ // deno-lint-ignore no-explicit-any
13226
+ .map((v) => v instanceof URL
13227
+ ? {
13228
+ [Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
13229
+ [Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
13230
+ }
13231
+ : v);
13232
+ if (_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length == 1) {
13233
+ proxy.service = _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service[0];
13234
+ }
13235
+ if (_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length > 1 ||
13236
+ !("service" in proxy) &&
13237
+ _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length > 0) {
13238
+ proxy.services = _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service;
13239
+ }
12621
13240
  const _2xEU4QtkC53RAun67T81Egqt9vmL_isCat = this
12622
13241
  .#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat
12623
13242
  // deno-lint-ignore no-explicit-any
@@ -17316,6 +17935,7 @@ export class Group extends Object {
17316
17935
  #_79S8K4f5J9MWUgCxziRyUe6PTHZ_memorial = [];
17317
17936
  #_2diCorzqPGQQqftp6e4SrCEwEnyk_indexable = [];
17318
17937
  #_3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs = [];
17938
+ #_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = [];
17319
17939
  #_2xEU4QtkC53RAun67T81Egqt9vmL_isCat = [];
17320
17940
  /**
17321
17941
  * Constructs a new instance of Group with the given values.
@@ -17592,6 +18212,32 @@ export class Group extends Object {
17592
18212
  "Application | Group | Organization | Person | Service | URL" + ".");
17593
18213
  }
17594
18214
  }
18215
+ if ("service" in values && values.service != null) {
18216
+ if (values.service instanceof DidService || values.service instanceof URL) {
18217
+ // @ts-ignore: type is checked above.
18218
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = [values.service];
18219
+ }
18220
+ else {
18221
+ throw new TypeError("The service must be of type " +
18222
+ "DidService | URL" + ".");
18223
+ }
18224
+ }
18225
+ if ("services" in values && values.services != null) {
18226
+ if ("service" in values &&
18227
+ values.service != null) {
18228
+ throw new TypeError("Cannot initialize both service and " +
18229
+ "services at the same time.");
18230
+ }
18231
+ if (Array.isArray(values.services) &&
18232
+ values.services.every((v) => v instanceof DidService || v instanceof URL)) {
18233
+ // @ts-ignore: type is checked above.
18234
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = values.services;
18235
+ }
18236
+ else {
18237
+ throw new TypeError("The services must be an array of type " +
18238
+ "DidService | URL" + ".");
18239
+ }
18240
+ }
17595
18241
  if ("cat" in values && values.cat != null) {
17596
18242
  if (typeof values.cat === "boolean") {
17597
18243
  // @ts-ignore: type is checked above.
@@ -17917,6 +18563,34 @@ export class Group extends Object {
17917
18563
  "Application | Group | Organization | Person | Service | URL" + ".");
17918
18564
  }
17919
18565
  }
18566
+ clone.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service =
18567
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service;
18568
+ if ("service" in values && values.service != null) {
18569
+ if (values.service instanceof DidService || values.service instanceof URL) {
18570
+ // @ts-ignore: type is checked above.
18571
+ clone.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = [values.service];
18572
+ }
18573
+ else {
18574
+ throw new TypeError("The service must be of type " +
18575
+ "DidService | URL" + ".");
18576
+ }
18577
+ }
18578
+ if ("services" in values && values.services != null) {
18579
+ if ("service" in values &&
18580
+ values.service != null) {
18581
+ throw new TypeError("Cannot update both service and " +
18582
+ "services at the same time.");
18583
+ }
18584
+ if (Array.isArray(values.services) &&
18585
+ values.services.every((v) => v instanceof DidService || v instanceof URL)) {
18586
+ // @ts-ignore: type is checked above.
18587
+ clone.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = values.services;
18588
+ }
18589
+ else {
18590
+ throw new TypeError("The services must be an array of type " +
18591
+ "DidService | URL" + ".");
18592
+ }
18593
+ }
17920
18594
  clone.#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat =
17921
18595
  this.#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat;
17922
18596
  if ("cat" in values && values.cat != null) {
@@ -18770,6 +19444,92 @@ export class Group extends Object {
18770
19444
  yield v;
18771
19445
  }
18772
19446
  }
19447
+ async #fetchService(url, options = {}) {
19448
+ const documentLoader = options.documentLoader ?? this._documentLoader ??
19449
+ fetchDocumentLoader;
19450
+ const contextLoader = options.contextLoader ?? this._contextLoader ??
19451
+ fetchDocumentLoader;
19452
+ let fetchResult;
19453
+ try {
19454
+ fetchResult = await documentLoader(url.href);
19455
+ }
19456
+ catch (error) {
19457
+ if (options.suppressError) {
19458
+ getLogger(["fedify", "vocab"]).error("Failed to fetch {url}: {error}", { error, url: url.href });
19459
+ return null;
19460
+ }
19461
+ throw error;
19462
+ }
19463
+ const { document } = fetchResult;
19464
+ try {
19465
+ return await DidService.fromJsonLd(document, { documentLoader, contextLoader });
19466
+ }
19467
+ catch (e) {
19468
+ if (!(e instanceof TypeError))
19469
+ throw e;
19470
+ }
19471
+ throw new TypeError("Expected an object of any type of: " +
19472
+ ["https://www.w3.org/ns/did#Service"].join(", "));
19473
+ }
19474
+ /**
19475
+ * Similar to
19476
+ * {@link Group.getService},
19477
+ * but returns its `@id` URL instead of the object itself.
19478
+ */
19479
+ get serviceId() {
19480
+ if (this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length < 1)
19481
+ return null;
19482
+ const v = this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service[0];
19483
+ if (v instanceof URL)
19484
+ return v;
19485
+ return v.id;
19486
+ }
19487
+ /** Means of communicating or interacting with the DID subject or associated
19488
+ * entities via one or more service endpoints. Examples include discovery
19489
+ * services, agent services, social networking services, file storage services,
19490
+ * and verifiable credential repository services.
19491
+ */
19492
+ async getService(options = {}) {
19493
+ if (this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length < 1)
19494
+ return null;
19495
+ const v = this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service[0];
19496
+ if (v instanceof URL) {
19497
+ const fetched = await this.#fetchService(v, options);
19498
+ if (fetched == null)
19499
+ return null;
19500
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service[0] = fetched;
19501
+ return fetched;
19502
+ }
19503
+ return v;
19504
+ }
19505
+ /**
19506
+ * Similar to
19507
+ * {@link Group.getServices},
19508
+ * but returns their `@id`s instead of the objects themselves.
19509
+ */
19510
+ get serviceIds() {
19511
+ return this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.map((v) => v instanceof URL ? v : v.id).filter((id) => id !== null);
19512
+ }
19513
+ /** Means of communicating or interacting with the DID subject or associated
19514
+ * entities via one or more service endpoints. Examples include discovery
19515
+ * services, agent services, social networking services, file storage services,
19516
+ * and verifiable credential repository services.
19517
+ */
19518
+ async *getServices(options = {}) {
19519
+ const vs = this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service;
19520
+ for (let i = 0; i < vs.length; i++) {
19521
+ const v = vs[i];
19522
+ if (v instanceof URL) {
19523
+ const fetched = await this.#fetchService(v, options);
19524
+ if (fetched == null)
19525
+ continue;
19526
+ vs[i] = fetched;
19527
+ yield fetched;
19528
+ continue;
19529
+ }
19530
+ yield v;
19531
+ }
19532
+ }
18773
19533
  /** Used on actors to indicate that they in some way identify as a cat,
18774
19534
  * expressed as a boolean value. If this property is set to `true`,
18775
19535
  * displaying the actor or their notes will have some special effects
@@ -19068,6 +19828,20 @@ export class Group extends Object {
19068
19828
  : compactItems[0];
19069
19829
  }
19070
19830
  compactItems = [];
19831
+ for (const v of this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service) {
19832
+ const item = v instanceof URL ? v.href : await v.toJsonLd({
19833
+ ...options,
19834
+ format: undefined,
19835
+ context: undefined,
19836
+ });
19837
+ compactItems.push(item);
19838
+ }
19839
+ if (compactItems.length > 0) {
19840
+ result["service"] = compactItems.length > 1
19841
+ ? compactItems
19842
+ : compactItems[0];
19843
+ }
19844
+ compactItems = [];
19071
19845
  for (const v of this.#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat) {
19072
19846
  const item = v;
19073
19847
  compactItems.push(item);
@@ -19309,6 +20083,17 @@ export class Group extends Object {
19309
20083
  values["https://www.w3.org/ns/activitystreams#alsoKnownAs"] = propValue;
19310
20084
  }
19311
20085
  array = [];
20086
+ for (const v of this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service) {
20087
+ const element = v instanceof URL
20088
+ ? { "@id": v.href }
20089
+ : await v.toJsonLd(options);
20090
+ array.push(element);
20091
+ }
20092
+ if (array.length > 0) {
20093
+ const propValue = array;
20094
+ values["https://www.w3.org/ns/did#service"] = propValue;
20095
+ }
20096
+ array = [];
19312
20097
  for (const v of this.#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat) {
19313
20098
  const element = { "@value": v };
19314
20099
  array.push(element);
@@ -19367,6 +20152,9 @@ export class Group extends Object {
19367
20152
  if (this.#_3isuDgRAKSntq9XdbjiNxjwyPZAf_preferredUsername != null &&
19368
20153
  this.#_3isuDgRAKSntq9XdbjiNxjwyPZAf_preferredUsername.length > 0)
19369
20154
  return false;
20155
+ if (this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service != null &&
20156
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length > 0)
20157
+ return false;
19370
20158
  return super.isCompactable();
19371
20159
  }
19372
20160
  /**
@@ -19756,6 +20544,25 @@ export class Group extends Object {
19756
20544
  }
19757
20545
  instance.#_3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs =
19758
20546
  _3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs;
20547
+ const _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = [];
20548
+ let _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array = values["https://www.w3.org/ns/did#service"];
20549
+ for (const v of _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array == null
20550
+ ? []
20551
+ : _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array.length === 1 &&
20552
+ "@list" in _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array[0]
20553
+ ? _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array[0]["@list"]
20554
+ : _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array) {
20555
+ if (v == null)
20556
+ continue;
20557
+ if (typeof v === "object" && "@id" in v && !("@type" in v) &&
20558
+ globalThis.Object.keys(v).length === 1) {
20559
+ _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.push(new URL(v["@id"]));
20560
+ continue;
20561
+ }
20562
+ _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.push(await DidService.fromJsonLd(v, options));
20563
+ }
20564
+ instance.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service =
20565
+ _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service;
19759
20566
  const _2xEU4QtkC53RAun67T81Egqt9vmL_isCat = [];
19760
20567
  let _2xEU4QtkC53RAun67T81Egqt9vmL_isCat__array = values["https://misskey-hub.net/ns#isCat"];
19761
20568
  for (const v of _2xEU4QtkC53RAun67T81Egqt9vmL_isCat__array == null
@@ -20023,6 +20830,23 @@ export class Group extends Object {
20023
20830
  _3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs.length > 0) {
20024
20831
  proxy.aliases = _3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs;
20025
20832
  }
20833
+ const _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = this
20834
+ .#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service
20835
+ // deno-lint-ignore no-explicit-any
20836
+ .map((v) => v instanceof URL
20837
+ ? {
20838
+ [Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
20839
+ [Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
20840
+ }
20841
+ : v);
20842
+ if (_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length == 1) {
20843
+ proxy.service = _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service[0];
20844
+ }
20845
+ if (_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length > 1 ||
20846
+ !("service" in proxy) &&
20847
+ _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length > 0) {
20848
+ proxy.services = _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service;
20849
+ }
20026
20850
  const _2xEU4QtkC53RAun67T81Egqt9vmL_isCat = this
20027
20851
  .#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat
20028
20852
  // deno-lint-ignore no-explicit-any
@@ -23949,6 +24773,7 @@ export class Organization extends Object {
23949
24773
  #_79S8K4f5J9MWUgCxziRyUe6PTHZ_memorial = [];
23950
24774
  #_2diCorzqPGQQqftp6e4SrCEwEnyk_indexable = [];
23951
24775
  #_3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs = [];
24776
+ #_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = [];
23952
24777
  #_2xEU4QtkC53RAun67T81Egqt9vmL_isCat = [];
23953
24778
  /**
23954
24779
  * Constructs a new instance of Organization with the given values.
@@ -24225,6 +25050,32 @@ export class Organization extends Object {
24225
25050
  "Application | Group | Organization | Person | Service | URL" + ".");
24226
25051
  }
24227
25052
  }
25053
+ if ("service" in values && values.service != null) {
25054
+ if (values.service instanceof DidService || values.service instanceof URL) {
25055
+ // @ts-ignore: type is checked above.
25056
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = [values.service];
25057
+ }
25058
+ else {
25059
+ throw new TypeError("The service must be of type " +
25060
+ "DidService | URL" + ".");
25061
+ }
25062
+ }
25063
+ if ("services" in values && values.services != null) {
25064
+ if ("service" in values &&
25065
+ values.service != null) {
25066
+ throw new TypeError("Cannot initialize both service and " +
25067
+ "services at the same time.");
25068
+ }
25069
+ if (Array.isArray(values.services) &&
25070
+ values.services.every((v) => v instanceof DidService || v instanceof URL)) {
25071
+ // @ts-ignore: type is checked above.
25072
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = values.services;
25073
+ }
25074
+ else {
25075
+ throw new TypeError("The services must be an array of type " +
25076
+ "DidService | URL" + ".");
25077
+ }
25078
+ }
24228
25079
  if ("cat" in values && values.cat != null) {
24229
25080
  if (typeof values.cat === "boolean") {
24230
25081
  // @ts-ignore: type is checked above.
@@ -24550,6 +25401,34 @@ export class Organization extends Object {
24550
25401
  "Application | Group | Organization | Person | Service | URL" + ".");
24551
25402
  }
24552
25403
  }
25404
+ clone.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service =
25405
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service;
25406
+ if ("service" in values && values.service != null) {
25407
+ if (values.service instanceof DidService || values.service instanceof URL) {
25408
+ // @ts-ignore: type is checked above.
25409
+ clone.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = [values.service];
25410
+ }
25411
+ else {
25412
+ throw new TypeError("The service must be of type " +
25413
+ "DidService | URL" + ".");
25414
+ }
25415
+ }
25416
+ if ("services" in values && values.services != null) {
25417
+ if ("service" in values &&
25418
+ values.service != null) {
25419
+ throw new TypeError("Cannot update both service and " +
25420
+ "services at the same time.");
25421
+ }
25422
+ if (Array.isArray(values.services) &&
25423
+ values.services.every((v) => v instanceof DidService || v instanceof URL)) {
25424
+ // @ts-ignore: type is checked above.
25425
+ clone.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = values.services;
25426
+ }
25427
+ else {
25428
+ throw new TypeError("The services must be an array of type " +
25429
+ "DidService | URL" + ".");
25430
+ }
25431
+ }
24553
25432
  clone.#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat =
24554
25433
  this.#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat;
24555
25434
  if ("cat" in values && values.cat != null) {
@@ -25403,6 +26282,92 @@ export class Organization extends Object {
25403
26282
  yield v;
25404
26283
  }
25405
26284
  }
26285
+ async #fetchService(url, options = {}) {
26286
+ const documentLoader = options.documentLoader ?? this._documentLoader ??
26287
+ fetchDocumentLoader;
26288
+ const contextLoader = options.contextLoader ?? this._contextLoader ??
26289
+ fetchDocumentLoader;
26290
+ let fetchResult;
26291
+ try {
26292
+ fetchResult = await documentLoader(url.href);
26293
+ }
26294
+ catch (error) {
26295
+ if (options.suppressError) {
26296
+ getLogger(["fedify", "vocab"]).error("Failed to fetch {url}: {error}", { error, url: url.href });
26297
+ return null;
26298
+ }
26299
+ throw error;
26300
+ }
26301
+ const { document } = fetchResult;
26302
+ try {
26303
+ return await DidService.fromJsonLd(document, { documentLoader, contextLoader });
26304
+ }
26305
+ catch (e) {
26306
+ if (!(e instanceof TypeError))
26307
+ throw e;
26308
+ }
26309
+ throw new TypeError("Expected an object of any type of: " +
26310
+ ["https://www.w3.org/ns/did#Service"].join(", "));
26311
+ }
26312
+ /**
26313
+ * Similar to
26314
+ * {@link Organization.getService},
26315
+ * but returns its `@id` URL instead of the object itself.
26316
+ */
26317
+ get serviceId() {
26318
+ if (this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length < 1)
26319
+ return null;
26320
+ const v = this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service[0];
26321
+ if (v instanceof URL)
26322
+ return v;
26323
+ return v.id;
26324
+ }
26325
+ /** Means of communicating or interacting with the DID subject or associated
26326
+ * entities via one or more service endpoints. Examples include discovery
26327
+ * services, agent services, social networking services, file storage services,
26328
+ * and verifiable credential repository services.
26329
+ */
26330
+ async getService(options = {}) {
26331
+ if (this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length < 1)
26332
+ return null;
26333
+ const v = this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service[0];
26334
+ if (v instanceof URL) {
26335
+ const fetched = await this.#fetchService(v, options);
26336
+ if (fetched == null)
26337
+ return null;
26338
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service[0] = fetched;
26339
+ return fetched;
26340
+ }
26341
+ return v;
26342
+ }
26343
+ /**
26344
+ * Similar to
26345
+ * {@link Organization.getServices},
26346
+ * but returns their `@id`s instead of the objects themselves.
26347
+ */
26348
+ get serviceIds() {
26349
+ return this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.map((v) => v instanceof URL ? v : v.id).filter((id) => id !== null);
26350
+ }
26351
+ /** Means of communicating or interacting with the DID subject or associated
26352
+ * entities via one or more service endpoints. Examples include discovery
26353
+ * services, agent services, social networking services, file storage services,
26354
+ * and verifiable credential repository services.
26355
+ */
26356
+ async *getServices(options = {}) {
26357
+ const vs = this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service;
26358
+ for (let i = 0; i < vs.length; i++) {
26359
+ const v = vs[i];
26360
+ if (v instanceof URL) {
26361
+ const fetched = await this.#fetchService(v, options);
26362
+ if (fetched == null)
26363
+ continue;
26364
+ vs[i] = fetched;
26365
+ yield fetched;
26366
+ continue;
26367
+ }
26368
+ yield v;
26369
+ }
26370
+ }
25406
26371
  /** Used on actors to indicate that they in some way identify as a cat,
25407
26372
  * expressed as a boolean value. If this property is set to `true`,
25408
26373
  * displaying the actor or their notes will have some special effects
@@ -25701,6 +26666,20 @@ export class Organization extends Object {
25701
26666
  : compactItems[0];
25702
26667
  }
25703
26668
  compactItems = [];
26669
+ for (const v of this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service) {
26670
+ const item = v instanceof URL ? v.href : await v.toJsonLd({
26671
+ ...options,
26672
+ format: undefined,
26673
+ context: undefined,
26674
+ });
26675
+ compactItems.push(item);
26676
+ }
26677
+ if (compactItems.length > 0) {
26678
+ result["service"] = compactItems.length > 1
26679
+ ? compactItems
26680
+ : compactItems[0];
26681
+ }
26682
+ compactItems = [];
25704
26683
  for (const v of this.#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat) {
25705
26684
  const item = v;
25706
26685
  compactItems.push(item);
@@ -25942,6 +26921,17 @@ export class Organization extends Object {
25942
26921
  values["https://www.w3.org/ns/activitystreams#alsoKnownAs"] = propValue;
25943
26922
  }
25944
26923
  array = [];
26924
+ for (const v of this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service) {
26925
+ const element = v instanceof URL
26926
+ ? { "@id": v.href }
26927
+ : await v.toJsonLd(options);
26928
+ array.push(element);
26929
+ }
26930
+ if (array.length > 0) {
26931
+ const propValue = array;
26932
+ values["https://www.w3.org/ns/did#service"] = propValue;
26933
+ }
26934
+ array = [];
25945
26935
  for (const v of this.#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat) {
25946
26936
  const element = { "@value": v };
25947
26937
  array.push(element);
@@ -26000,6 +26990,9 @@ export class Organization extends Object {
26000
26990
  if (this.#_3isuDgRAKSntq9XdbjiNxjwyPZAf_preferredUsername != null &&
26001
26991
  this.#_3isuDgRAKSntq9XdbjiNxjwyPZAf_preferredUsername.length > 0)
26002
26992
  return false;
26993
+ if (this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service != null &&
26994
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length > 0)
26995
+ return false;
26003
26996
  return super.isCompactable();
26004
26997
  }
26005
26998
  /**
@@ -26385,10 +27378,29 @@ export class Organization extends Object {
26385
27378
  : undefined;
26386
27379
  if (typeof decoded === "undefined")
26387
27380
  continue;
26388
- _3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs.push(decoded);
27381
+ _3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs.push(decoded);
27382
+ }
27383
+ instance.#_3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs =
27384
+ _3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs;
27385
+ const _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = [];
27386
+ let _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array = values["https://www.w3.org/ns/did#service"];
27387
+ for (const v of _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array == null
27388
+ ? []
27389
+ : _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array.length === 1 &&
27390
+ "@list" in _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array[0]
27391
+ ? _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array[0]["@list"]
27392
+ : _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array) {
27393
+ if (v == null)
27394
+ continue;
27395
+ if (typeof v === "object" && "@id" in v && !("@type" in v) &&
27396
+ globalThis.Object.keys(v).length === 1) {
27397
+ _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.push(new URL(v["@id"]));
27398
+ continue;
27399
+ }
27400
+ _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.push(await DidService.fromJsonLd(v, options));
26389
27401
  }
26390
- instance.#_3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs =
26391
- _3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs;
27402
+ instance.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service =
27403
+ _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service;
26392
27404
  const _2xEU4QtkC53RAun67T81Egqt9vmL_isCat = [];
26393
27405
  let _2xEU4QtkC53RAun67T81Egqt9vmL_isCat__array = values["https://misskey-hub.net/ns#isCat"];
26394
27406
  for (const v of _2xEU4QtkC53RAun67T81Egqt9vmL_isCat__array == null
@@ -26656,6 +27668,23 @@ export class Organization extends Object {
26656
27668
  _3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs.length > 0) {
26657
27669
  proxy.aliases = _3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs;
26658
27670
  }
27671
+ const _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = this
27672
+ .#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service
27673
+ // deno-lint-ignore no-explicit-any
27674
+ .map((v) => v instanceof URL
27675
+ ? {
27676
+ [Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
27677
+ [Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
27678
+ }
27679
+ : v);
27680
+ if (_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length == 1) {
27681
+ proxy.service = _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service[0];
27682
+ }
27683
+ if (_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length > 1 ||
27684
+ !("service" in proxy) &&
27685
+ _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length > 0) {
27686
+ proxy.services = _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service;
27687
+ }
26659
27688
  const _2xEU4QtkC53RAun67T81Egqt9vmL_isCat = this
26660
27689
  .#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat
26661
27690
  // deno-lint-ignore no-explicit-any
@@ -26882,6 +27911,7 @@ export class Person extends Object {
26882
27911
  #_79S8K4f5J9MWUgCxziRyUe6PTHZ_memorial = [];
26883
27912
  #_2diCorzqPGQQqftp6e4SrCEwEnyk_indexable = [];
26884
27913
  #_3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs = [];
27914
+ #_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = [];
26885
27915
  #_2xEU4QtkC53RAun67T81Egqt9vmL_isCat = [];
26886
27916
  /**
26887
27917
  * Constructs a new instance of Person with the given values.
@@ -27158,6 +28188,32 @@ export class Person extends Object {
27158
28188
  "Application | Group | Organization | Person | Service | URL" + ".");
27159
28189
  }
27160
28190
  }
28191
+ if ("service" in values && values.service != null) {
28192
+ if (values.service instanceof DidService || values.service instanceof URL) {
28193
+ // @ts-ignore: type is checked above.
28194
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = [values.service];
28195
+ }
28196
+ else {
28197
+ throw new TypeError("The service must be of type " +
28198
+ "DidService | URL" + ".");
28199
+ }
28200
+ }
28201
+ if ("services" in values && values.services != null) {
28202
+ if ("service" in values &&
28203
+ values.service != null) {
28204
+ throw new TypeError("Cannot initialize both service and " +
28205
+ "services at the same time.");
28206
+ }
28207
+ if (Array.isArray(values.services) &&
28208
+ values.services.every((v) => v instanceof DidService || v instanceof URL)) {
28209
+ // @ts-ignore: type is checked above.
28210
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = values.services;
28211
+ }
28212
+ else {
28213
+ throw new TypeError("The services must be an array of type " +
28214
+ "DidService | URL" + ".");
28215
+ }
28216
+ }
27161
28217
  if ("cat" in values && values.cat != null) {
27162
28218
  if (typeof values.cat === "boolean") {
27163
28219
  // @ts-ignore: type is checked above.
@@ -27483,6 +28539,34 @@ export class Person extends Object {
27483
28539
  "Application | Group | Organization | Person | Service | URL" + ".");
27484
28540
  }
27485
28541
  }
28542
+ clone.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service =
28543
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service;
28544
+ if ("service" in values && values.service != null) {
28545
+ if (values.service instanceof DidService || values.service instanceof URL) {
28546
+ // @ts-ignore: type is checked above.
28547
+ clone.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = [values.service];
28548
+ }
28549
+ else {
28550
+ throw new TypeError("The service must be of type " +
28551
+ "DidService | URL" + ".");
28552
+ }
28553
+ }
28554
+ if ("services" in values && values.services != null) {
28555
+ if ("service" in values &&
28556
+ values.service != null) {
28557
+ throw new TypeError("Cannot update both service and " +
28558
+ "services at the same time.");
28559
+ }
28560
+ if (Array.isArray(values.services) &&
28561
+ values.services.every((v) => v instanceof DidService || v instanceof URL)) {
28562
+ // @ts-ignore: type is checked above.
28563
+ clone.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = values.services;
28564
+ }
28565
+ else {
28566
+ throw new TypeError("The services must be an array of type " +
28567
+ "DidService | URL" + ".");
28568
+ }
28569
+ }
27486
28570
  clone.#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat =
27487
28571
  this.#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat;
27488
28572
  if ("cat" in values && values.cat != null) {
@@ -28336,6 +29420,92 @@ export class Person extends Object {
28336
29420
  yield v;
28337
29421
  }
28338
29422
  }
29423
+ async #fetchService(url, options = {}) {
29424
+ const documentLoader = options.documentLoader ?? this._documentLoader ??
29425
+ fetchDocumentLoader;
29426
+ const contextLoader = options.contextLoader ?? this._contextLoader ??
29427
+ fetchDocumentLoader;
29428
+ let fetchResult;
29429
+ try {
29430
+ fetchResult = await documentLoader(url.href);
29431
+ }
29432
+ catch (error) {
29433
+ if (options.suppressError) {
29434
+ getLogger(["fedify", "vocab"]).error("Failed to fetch {url}: {error}", { error, url: url.href });
29435
+ return null;
29436
+ }
29437
+ throw error;
29438
+ }
29439
+ const { document } = fetchResult;
29440
+ try {
29441
+ return await DidService.fromJsonLd(document, { documentLoader, contextLoader });
29442
+ }
29443
+ catch (e) {
29444
+ if (!(e instanceof TypeError))
29445
+ throw e;
29446
+ }
29447
+ throw new TypeError("Expected an object of any type of: " +
29448
+ ["https://www.w3.org/ns/did#Service"].join(", "));
29449
+ }
29450
+ /**
29451
+ * Similar to
29452
+ * {@link Person.getService},
29453
+ * but returns its `@id` URL instead of the object itself.
29454
+ */
29455
+ get serviceId() {
29456
+ if (this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length < 1)
29457
+ return null;
29458
+ const v = this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service[0];
29459
+ if (v instanceof URL)
29460
+ return v;
29461
+ return v.id;
29462
+ }
29463
+ /** Means of communicating or interacting with the DID subject or associated
29464
+ * entities via one or more service endpoints. Examples include discovery
29465
+ * services, agent services, social networking services, file storage services,
29466
+ * and verifiable credential repository services.
29467
+ */
29468
+ async getService(options = {}) {
29469
+ if (this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length < 1)
29470
+ return null;
29471
+ const v = this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service[0];
29472
+ if (v instanceof URL) {
29473
+ const fetched = await this.#fetchService(v, options);
29474
+ if (fetched == null)
29475
+ return null;
29476
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service[0] = fetched;
29477
+ return fetched;
29478
+ }
29479
+ return v;
29480
+ }
29481
+ /**
29482
+ * Similar to
29483
+ * {@link Person.getServices},
29484
+ * but returns their `@id`s instead of the objects themselves.
29485
+ */
29486
+ get serviceIds() {
29487
+ return this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.map((v) => v instanceof URL ? v : v.id).filter((id) => id !== null);
29488
+ }
29489
+ /** Means of communicating or interacting with the DID subject or associated
29490
+ * entities via one or more service endpoints. Examples include discovery
29491
+ * services, agent services, social networking services, file storage services,
29492
+ * and verifiable credential repository services.
29493
+ */
29494
+ async *getServices(options = {}) {
29495
+ const vs = this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service;
29496
+ for (let i = 0; i < vs.length; i++) {
29497
+ const v = vs[i];
29498
+ if (v instanceof URL) {
29499
+ const fetched = await this.#fetchService(v, options);
29500
+ if (fetched == null)
29501
+ continue;
29502
+ vs[i] = fetched;
29503
+ yield fetched;
29504
+ continue;
29505
+ }
29506
+ yield v;
29507
+ }
29508
+ }
28339
29509
  /** Used on actors to indicate that they in some way identify as a cat,
28340
29510
  * expressed as a boolean value. If this property is set to `true`,
28341
29511
  * displaying the actor or their notes will have some special effects
@@ -28634,6 +29804,20 @@ export class Person extends Object {
28634
29804
  : compactItems[0];
28635
29805
  }
28636
29806
  compactItems = [];
29807
+ for (const v of this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service) {
29808
+ const item = v instanceof URL ? v.href : await v.toJsonLd({
29809
+ ...options,
29810
+ format: undefined,
29811
+ context: undefined,
29812
+ });
29813
+ compactItems.push(item);
29814
+ }
29815
+ if (compactItems.length > 0) {
29816
+ result["service"] = compactItems.length > 1
29817
+ ? compactItems
29818
+ : compactItems[0];
29819
+ }
29820
+ compactItems = [];
28637
29821
  for (const v of this.#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat) {
28638
29822
  const item = v;
28639
29823
  compactItems.push(item);
@@ -28875,6 +30059,17 @@ export class Person extends Object {
28875
30059
  values["https://www.w3.org/ns/activitystreams#alsoKnownAs"] = propValue;
28876
30060
  }
28877
30061
  array = [];
30062
+ for (const v of this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service) {
30063
+ const element = v instanceof URL
30064
+ ? { "@id": v.href }
30065
+ : await v.toJsonLd(options);
30066
+ array.push(element);
30067
+ }
30068
+ if (array.length > 0) {
30069
+ const propValue = array;
30070
+ values["https://www.w3.org/ns/did#service"] = propValue;
30071
+ }
30072
+ array = [];
28878
30073
  for (const v of this.#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat) {
28879
30074
  const element = { "@value": v };
28880
30075
  array.push(element);
@@ -28933,6 +30128,9 @@ export class Person extends Object {
28933
30128
  if (this.#_3isuDgRAKSntq9XdbjiNxjwyPZAf_preferredUsername != null &&
28934
30129
  this.#_3isuDgRAKSntq9XdbjiNxjwyPZAf_preferredUsername.length > 0)
28935
30130
  return false;
30131
+ if (this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service != null &&
30132
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length > 0)
30133
+ return false;
28936
30134
  return super.isCompactable();
28937
30135
  }
28938
30136
  /**
@@ -29322,6 +30520,25 @@ export class Person extends Object {
29322
30520
  }
29323
30521
  instance.#_3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs =
29324
30522
  _3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs;
30523
+ const _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = [];
30524
+ let _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array = values["https://www.w3.org/ns/did#service"];
30525
+ for (const v of _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array == null
30526
+ ? []
30527
+ : _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array.length === 1 &&
30528
+ "@list" in _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array[0]
30529
+ ? _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array[0]["@list"]
30530
+ : _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array) {
30531
+ if (v == null)
30532
+ continue;
30533
+ if (typeof v === "object" && "@id" in v && !("@type" in v) &&
30534
+ globalThis.Object.keys(v).length === 1) {
30535
+ _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.push(new URL(v["@id"]));
30536
+ continue;
30537
+ }
30538
+ _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.push(await DidService.fromJsonLd(v, options));
30539
+ }
30540
+ instance.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service =
30541
+ _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service;
29325
30542
  const _2xEU4QtkC53RAun67T81Egqt9vmL_isCat = [];
29326
30543
  let _2xEU4QtkC53RAun67T81Egqt9vmL_isCat__array = values["https://misskey-hub.net/ns#isCat"];
29327
30544
  for (const v of _2xEU4QtkC53RAun67T81Egqt9vmL_isCat__array == null
@@ -29589,6 +30806,23 @@ export class Person extends Object {
29589
30806
  _3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs.length > 0) {
29590
30807
  proxy.aliases = _3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs;
29591
30808
  }
30809
+ const _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = this
30810
+ .#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service
30811
+ // deno-lint-ignore no-explicit-any
30812
+ .map((v) => v instanceof URL
30813
+ ? {
30814
+ [Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
30815
+ [Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
30816
+ }
30817
+ : v);
30818
+ if (_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length == 1) {
30819
+ proxy.service = _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service[0];
30820
+ }
30821
+ if (_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length > 1 ||
30822
+ !("service" in proxy) &&
30823
+ _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length > 0) {
30824
+ proxy.services = _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service;
30825
+ }
29592
30826
  const _2xEU4QtkC53RAun67T81Egqt9vmL_isCat = this
29593
30827
  .#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat
29594
30828
  // deno-lint-ignore no-explicit-any
@@ -32491,6 +33725,7 @@ export class Service extends Object {
32491
33725
  #_79S8K4f5J9MWUgCxziRyUe6PTHZ_memorial = [];
32492
33726
  #_2diCorzqPGQQqftp6e4SrCEwEnyk_indexable = [];
32493
33727
  #_3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs = [];
33728
+ #_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = [];
32494
33729
  #_2xEU4QtkC53RAun67T81Egqt9vmL_isCat = [];
32495
33730
  /**
32496
33731
  * Constructs a new instance of Service with the given values.
@@ -32767,6 +34002,32 @@ export class Service extends Object {
32767
34002
  "Application | Group | Organization | Person | Service | URL" + ".");
32768
34003
  }
32769
34004
  }
34005
+ if ("service" in values && values.service != null) {
34006
+ if (values.service instanceof DidService || values.service instanceof URL) {
34007
+ // @ts-ignore: type is checked above.
34008
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = [values.service];
34009
+ }
34010
+ else {
34011
+ throw new TypeError("The service must be of type " +
34012
+ "DidService | URL" + ".");
34013
+ }
34014
+ }
34015
+ if ("services" in values && values.services != null) {
34016
+ if ("service" in values &&
34017
+ values.service != null) {
34018
+ throw new TypeError("Cannot initialize both service and " +
34019
+ "services at the same time.");
34020
+ }
34021
+ if (Array.isArray(values.services) &&
34022
+ values.services.every((v) => v instanceof DidService || v instanceof URL)) {
34023
+ // @ts-ignore: type is checked above.
34024
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = values.services;
34025
+ }
34026
+ else {
34027
+ throw new TypeError("The services must be an array of type " +
34028
+ "DidService | URL" + ".");
34029
+ }
34030
+ }
32770
34031
  if ("cat" in values && values.cat != null) {
32771
34032
  if (typeof values.cat === "boolean") {
32772
34033
  // @ts-ignore: type is checked above.
@@ -33092,6 +34353,34 @@ export class Service extends Object {
33092
34353
  "Application | Group | Organization | Person | Service | URL" + ".");
33093
34354
  }
33094
34355
  }
34356
+ clone.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service =
34357
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service;
34358
+ if ("service" in values && values.service != null) {
34359
+ if (values.service instanceof DidService || values.service instanceof URL) {
34360
+ // @ts-ignore: type is checked above.
34361
+ clone.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = [values.service];
34362
+ }
34363
+ else {
34364
+ throw new TypeError("The service must be of type " +
34365
+ "DidService | URL" + ".");
34366
+ }
34367
+ }
34368
+ if ("services" in values && values.services != null) {
34369
+ if ("service" in values &&
34370
+ values.service != null) {
34371
+ throw new TypeError("Cannot update both service and " +
34372
+ "services at the same time.");
34373
+ }
34374
+ if (Array.isArray(values.services) &&
34375
+ values.services.every((v) => v instanceof DidService || v instanceof URL)) {
34376
+ // @ts-ignore: type is checked above.
34377
+ clone.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = values.services;
34378
+ }
34379
+ else {
34380
+ throw new TypeError("The services must be an array of type " +
34381
+ "DidService | URL" + ".");
34382
+ }
34383
+ }
33095
34384
  clone.#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat =
33096
34385
  this.#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat;
33097
34386
  if ("cat" in values && values.cat != null) {
@@ -33945,6 +35234,92 @@ export class Service extends Object {
33945
35234
  yield v;
33946
35235
  }
33947
35236
  }
35237
+ async #fetchService(url, options = {}) {
35238
+ const documentLoader = options.documentLoader ?? this._documentLoader ??
35239
+ fetchDocumentLoader;
35240
+ const contextLoader = options.contextLoader ?? this._contextLoader ??
35241
+ fetchDocumentLoader;
35242
+ let fetchResult;
35243
+ try {
35244
+ fetchResult = await documentLoader(url.href);
35245
+ }
35246
+ catch (error) {
35247
+ if (options.suppressError) {
35248
+ getLogger(["fedify", "vocab"]).error("Failed to fetch {url}: {error}", { error, url: url.href });
35249
+ return null;
35250
+ }
35251
+ throw error;
35252
+ }
35253
+ const { document } = fetchResult;
35254
+ try {
35255
+ return await DidService.fromJsonLd(document, { documentLoader, contextLoader });
35256
+ }
35257
+ catch (e) {
35258
+ if (!(e instanceof TypeError))
35259
+ throw e;
35260
+ }
35261
+ throw new TypeError("Expected an object of any type of: " +
35262
+ ["https://www.w3.org/ns/did#Service"].join(", "));
35263
+ }
35264
+ /**
35265
+ * Similar to
35266
+ * {@link Service.getService},
35267
+ * but returns its `@id` URL instead of the object itself.
35268
+ */
35269
+ get serviceId() {
35270
+ if (this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length < 1)
35271
+ return null;
35272
+ const v = this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service[0];
35273
+ if (v instanceof URL)
35274
+ return v;
35275
+ return v.id;
35276
+ }
35277
+ /** Means of communicating or interacting with the DID subject or associated
35278
+ * entities via one or more service endpoints. Examples include discovery
35279
+ * services, agent services, social networking services, file storage services,
35280
+ * and verifiable credential repository services.
35281
+ */
35282
+ async getService(options = {}) {
35283
+ if (this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length < 1)
35284
+ return null;
35285
+ const v = this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service[0];
35286
+ if (v instanceof URL) {
35287
+ const fetched = await this.#fetchService(v, options);
35288
+ if (fetched == null)
35289
+ return null;
35290
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service[0] = fetched;
35291
+ return fetched;
35292
+ }
35293
+ return v;
35294
+ }
35295
+ /**
35296
+ * Similar to
35297
+ * {@link Service.getServices},
35298
+ * but returns their `@id`s instead of the objects themselves.
35299
+ */
35300
+ get serviceIds() {
35301
+ return this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.map((v) => v instanceof URL ? v : v.id).filter((id) => id !== null);
35302
+ }
35303
+ /** Means of communicating or interacting with the DID subject or associated
35304
+ * entities via one or more service endpoints. Examples include discovery
35305
+ * services, agent services, social networking services, file storage services,
35306
+ * and verifiable credential repository services.
35307
+ */
35308
+ async *getServices(options = {}) {
35309
+ const vs = this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service;
35310
+ for (let i = 0; i < vs.length; i++) {
35311
+ const v = vs[i];
35312
+ if (v instanceof URL) {
35313
+ const fetched = await this.#fetchService(v, options);
35314
+ if (fetched == null)
35315
+ continue;
35316
+ vs[i] = fetched;
35317
+ yield fetched;
35318
+ continue;
35319
+ }
35320
+ yield v;
35321
+ }
35322
+ }
33948
35323
  /** Used on actors to indicate that they in some way identify as a cat,
33949
35324
  * expressed as a boolean value. If this property is set to `true`,
33950
35325
  * displaying the actor or their notes will have some special effects
@@ -34243,6 +35618,20 @@ export class Service extends Object {
34243
35618
  : compactItems[0];
34244
35619
  }
34245
35620
  compactItems = [];
35621
+ for (const v of this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service) {
35622
+ const item = v instanceof URL ? v.href : await v.toJsonLd({
35623
+ ...options,
35624
+ format: undefined,
35625
+ context: undefined,
35626
+ });
35627
+ compactItems.push(item);
35628
+ }
35629
+ if (compactItems.length > 0) {
35630
+ result["service"] = compactItems.length > 1
35631
+ ? compactItems
35632
+ : compactItems[0];
35633
+ }
35634
+ compactItems = [];
34246
35635
  for (const v of this.#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat) {
34247
35636
  const item = v;
34248
35637
  compactItems.push(item);
@@ -34484,6 +35873,17 @@ export class Service extends Object {
34484
35873
  values["https://www.w3.org/ns/activitystreams#alsoKnownAs"] = propValue;
34485
35874
  }
34486
35875
  array = [];
35876
+ for (const v of this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service) {
35877
+ const element = v instanceof URL
35878
+ ? { "@id": v.href }
35879
+ : await v.toJsonLd(options);
35880
+ array.push(element);
35881
+ }
35882
+ if (array.length > 0) {
35883
+ const propValue = array;
35884
+ values["https://www.w3.org/ns/did#service"] = propValue;
35885
+ }
35886
+ array = [];
34487
35887
  for (const v of this.#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat) {
34488
35888
  const element = { "@value": v };
34489
35889
  array.push(element);
@@ -34542,6 +35942,9 @@ export class Service extends Object {
34542
35942
  if (this.#_3isuDgRAKSntq9XdbjiNxjwyPZAf_preferredUsername != null &&
34543
35943
  this.#_3isuDgRAKSntq9XdbjiNxjwyPZAf_preferredUsername.length > 0)
34544
35944
  return false;
35945
+ if (this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service != null &&
35946
+ this.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length > 0)
35947
+ return false;
34545
35948
  return super.isCompactable();
34546
35949
  }
34547
35950
  /**
@@ -34931,6 +36334,25 @@ export class Service extends Object {
34931
36334
  }
34932
36335
  instance.#_3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs =
34933
36336
  _3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs;
36337
+ const _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = [];
36338
+ let _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array = values["https://www.w3.org/ns/did#service"];
36339
+ for (const v of _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array == null
36340
+ ? []
36341
+ : _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array.length === 1 &&
36342
+ "@list" in _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array[0]
36343
+ ? _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array[0]["@list"]
36344
+ : _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service__array) {
36345
+ if (v == null)
36346
+ continue;
36347
+ if (typeof v === "object" && "@id" in v && !("@type" in v) &&
36348
+ globalThis.Object.keys(v).length === 1) {
36349
+ _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.push(new URL(v["@id"]));
36350
+ continue;
36351
+ }
36352
+ _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.push(await DidService.fromJsonLd(v, options));
36353
+ }
36354
+ instance.#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service =
36355
+ _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service;
34934
36356
  const _2xEU4QtkC53RAun67T81Egqt9vmL_isCat = [];
34935
36357
  let _2xEU4QtkC53RAun67T81Egqt9vmL_isCat__array = values["https://misskey-hub.net/ns#isCat"];
34936
36358
  for (const v of _2xEU4QtkC53RAun67T81Egqt9vmL_isCat__array == null
@@ -35198,6 +36620,23 @@ export class Service extends Object {
35198
36620
  _3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs.length > 0) {
35199
36621
  proxy.aliases = _3NV7TGNhuABbryNjNi4wib4DgNpY_alsoKnownAs;
35200
36622
  }
36623
+ const _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service = this
36624
+ .#_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service
36625
+ // deno-lint-ignore no-explicit-any
36626
+ .map((v) => v instanceof URL
36627
+ ? {
36628
+ [Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
36629
+ [Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
36630
+ }
36631
+ : v);
36632
+ if (_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length == 1) {
36633
+ proxy.service = _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service[0];
36634
+ }
36635
+ if (_4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length > 1 ||
36636
+ !("service" in proxy) &&
36637
+ _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service.length > 0) {
36638
+ proxy.services = _4Q6NrKH6bazBGtxwG8vyG77ir7Tg_service;
36639
+ }
35201
36640
  const _2xEU4QtkC53RAun67T81Egqt9vmL_isCat = this
35202
36641
  .#_2xEU4QtkC53RAun67T81Egqt9vmL_isCat
35203
36642
  // deno-lint-ignore no-explicit-any