@fedify/fedify 0.14.0-dev.338 → 0.14.0-dev.339
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGES.md +33 -0
- package/esm/vocab/application.yaml +17 -0
- package/esm/vocab/group.yaml +17 -0
- package/esm/vocab/organization.yaml +17 -0
- package/esm/vocab/person.yaml +17 -0
- package/esm/vocab/service.yaml +17 -0
- package/esm/vocab/vocab.js +1528 -23
- package/package.json +1 -1
- package/types/vocab/vocab.d.ts +180 -0
- package/types/vocab/vocab.d.ts.map +1 -1
package/esm/vocab/vocab.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
var _a, _b, _c;
|
1
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
2
2
|
// deno-lint-ignore-file ban-unused-ignore prefer-const
|
3
3
|
import * as dntShim from "../_dnt.shims.js";
|
4
4
|
// @ts-ignore TS7016
|
@@ -9684,6 +9684,7 @@ export class Application extends Object {
|
|
9684
9684
|
#_2kGKkJtoFWg8c18PaVSqj9NKP4t7 = [];
|
9685
9685
|
#_79S8K4f5J9MWUgCxziRyUe6PTHZ = [];
|
9686
9686
|
#_2diCorzqPGQQqftp6e4SrCEwEnyk = [];
|
9687
|
+
#_3NV7TGNhuABbryNjNi4wib4DgNpY = [];
|
9687
9688
|
/**
|
9688
9689
|
* Constructs a new instance of Application with the given values.
|
9689
9690
|
* @param values The values to initialize the instance with.
|
@@ -9918,6 +9919,37 @@ export class Application extends Object {
|
|
9918
9919
|
"boolean" + ".");
|
9919
9920
|
}
|
9920
9921
|
}
|
9922
|
+
if ("alias" in values && values.alias != null) {
|
9923
|
+
if (values.alias instanceof _b || values.alias instanceof Group ||
|
9924
|
+
values.alias instanceof Organization ||
|
9925
|
+
values.alias instanceof Person || values.alias instanceof Service ||
|
9926
|
+
values.alias instanceof URL) {
|
9927
|
+
// @ts-ignore: type is checked above.
|
9928
|
+
this.#_3NV7TGNhuABbryNjNi4wib4DgNpY = [values.alias];
|
9929
|
+
}
|
9930
|
+
else {
|
9931
|
+
throw new TypeError("The alias must be of type " +
|
9932
|
+
"Application | Group | Organization | Person | Service | URL" + ".");
|
9933
|
+
}
|
9934
|
+
}
|
9935
|
+
if ("aliases" in values && values.aliases != null) {
|
9936
|
+
if ("alias" in values &&
|
9937
|
+
values.alias != null) {
|
9938
|
+
throw new TypeError("Cannot initialize both alias and " +
|
9939
|
+
"aliases at the same time.");
|
9940
|
+
}
|
9941
|
+
if (Array.isArray(values.aliases) &&
|
9942
|
+
values.aliases.every((v) => v instanceof _b || v instanceof Group ||
|
9943
|
+
v instanceof Organization || v instanceof Person ||
|
9944
|
+
v instanceof Service || v instanceof URL)) {
|
9945
|
+
// @ts-ignore: type is checked above.
|
9946
|
+
this.#_3NV7TGNhuABbryNjNi4wib4DgNpY = values.aliases;
|
9947
|
+
}
|
9948
|
+
else {
|
9949
|
+
throw new TypeError("The aliases must be an array of type " +
|
9950
|
+
"Application | Group | Organization | Person | Service | URL" + ".");
|
9951
|
+
}
|
9952
|
+
}
|
9921
9953
|
}
|
9922
9954
|
/**
|
9923
9955
|
* Clones this instance, optionally updating it with the given values.
|
@@ -10173,6 +10205,38 @@ export class Application extends Object {
|
|
10173
10205
|
"boolean" + ".");
|
10174
10206
|
}
|
10175
10207
|
}
|
10208
|
+
clone.#_3NV7TGNhuABbryNjNi4wib4DgNpY = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY;
|
10209
|
+
if ("alias" in values && values.alias != null) {
|
10210
|
+
if (values.alias instanceof _b || values.alias instanceof Group ||
|
10211
|
+
values.alias instanceof Organization ||
|
10212
|
+
values.alias instanceof Person || values.alias instanceof Service ||
|
10213
|
+
values.alias instanceof URL) {
|
10214
|
+
// @ts-ignore: type is checked above.
|
10215
|
+
clone.#_3NV7TGNhuABbryNjNi4wib4DgNpY = [values.alias];
|
10216
|
+
}
|
10217
|
+
else {
|
10218
|
+
throw new TypeError("The alias must be of type " +
|
10219
|
+
"Application | Group | Organization | Person | Service | URL" + ".");
|
10220
|
+
}
|
10221
|
+
}
|
10222
|
+
if ("aliases" in values && values.aliases != null) {
|
10223
|
+
if ("alias" in values &&
|
10224
|
+
values.alias != null) {
|
10225
|
+
throw new TypeError("Cannot update both alias and " +
|
10226
|
+
"aliases at the same time.");
|
10227
|
+
}
|
10228
|
+
if (Array.isArray(values.aliases) &&
|
10229
|
+
values.aliases.every((v) => v instanceof _b || v instanceof Group ||
|
10230
|
+
v instanceof Organization || v instanceof Person ||
|
10231
|
+
v instanceof Service || v instanceof URL)) {
|
10232
|
+
// @ts-ignore: type is checked above.
|
10233
|
+
clone.#_3NV7TGNhuABbryNjNi4wib4DgNpY = values.aliases;
|
10234
|
+
}
|
10235
|
+
else {
|
10236
|
+
throw new TypeError("The aliases must be an array of type " +
|
10237
|
+
"Application | Group | Organization | Person | Service | URL" + ".");
|
10238
|
+
}
|
10239
|
+
}
|
10176
10240
|
return clone;
|
10177
10241
|
}
|
10178
10242
|
/** A short username which may be used to refer to the actor,
|
@@ -10889,6 +10953,126 @@ export class Application extends Object {
|
|
10889
10953
|
return null;
|
10890
10954
|
return this.#_2diCorzqPGQQqftp6e4SrCEwEnyk[0];
|
10891
10955
|
}
|
10956
|
+
async #fetchAlias(url, options = {}) {
|
10957
|
+
const documentLoader = options.documentLoader ?? this._documentLoader ??
|
10958
|
+
fetchDocumentLoader;
|
10959
|
+
const contextLoader = options.contextLoader ?? this._contextLoader ??
|
10960
|
+
fetchDocumentLoader;
|
10961
|
+
let fetchResult;
|
10962
|
+
try {
|
10963
|
+
fetchResult = await documentLoader(url.href);
|
10964
|
+
}
|
10965
|
+
catch (error) {
|
10966
|
+
if (options.suppressError) {
|
10967
|
+
getLogger(["fedify", "vocab"]).error("Failed to fetch {url}: {error}", { error, url: url.href });
|
10968
|
+
return null;
|
10969
|
+
}
|
10970
|
+
throw error;
|
10971
|
+
}
|
10972
|
+
const { document } = fetchResult;
|
10973
|
+
try {
|
10974
|
+
return await _b.fromJsonLd(document, { documentLoader, contextLoader });
|
10975
|
+
}
|
10976
|
+
catch (e) {
|
10977
|
+
if (!(e instanceof TypeError))
|
10978
|
+
throw e;
|
10979
|
+
}
|
10980
|
+
try {
|
10981
|
+
return await Group.fromJsonLd(document, { documentLoader, contextLoader });
|
10982
|
+
}
|
10983
|
+
catch (e) {
|
10984
|
+
if (!(e instanceof TypeError))
|
10985
|
+
throw e;
|
10986
|
+
}
|
10987
|
+
try {
|
10988
|
+
return await Organization.fromJsonLd(document, { documentLoader, contextLoader });
|
10989
|
+
}
|
10990
|
+
catch (e) {
|
10991
|
+
if (!(e instanceof TypeError))
|
10992
|
+
throw e;
|
10993
|
+
}
|
10994
|
+
try {
|
10995
|
+
return await Person.fromJsonLd(document, { documentLoader, contextLoader });
|
10996
|
+
}
|
10997
|
+
catch (e) {
|
10998
|
+
if (!(e instanceof TypeError))
|
10999
|
+
throw e;
|
11000
|
+
}
|
11001
|
+
try {
|
11002
|
+
return await Service.fromJsonLd(document, { documentLoader, contextLoader });
|
11003
|
+
}
|
11004
|
+
catch (e) {
|
11005
|
+
if (!(e instanceof TypeError))
|
11006
|
+
throw e;
|
11007
|
+
}
|
11008
|
+
throw new TypeError("Expected an object of any type of: " +
|
11009
|
+
[
|
11010
|
+
"https://www.w3.org/ns/activitystreams#Application",
|
11011
|
+
"https://www.w3.org/ns/activitystreams#Group",
|
11012
|
+
"https://www.w3.org/ns/activitystreams#Organization",
|
11013
|
+
"https://www.w3.org/ns/activitystreams#Person",
|
11014
|
+
"https://www.w3.org/ns/activitystreams#Service",
|
11015
|
+
].join(", "));
|
11016
|
+
}
|
11017
|
+
/**
|
11018
|
+
* Similar to
|
11019
|
+
* {@link Application.getAlias},
|
11020
|
+
* but returns its `@id` URL instead of the object itself.
|
11021
|
+
*/
|
11022
|
+
get aliasId() {
|
11023
|
+
if (this.#_3NV7TGNhuABbryNjNi4wib4DgNpY.length < 1)
|
11024
|
+
return null;
|
11025
|
+
const v = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY[0];
|
11026
|
+
if (v instanceof URL)
|
11027
|
+
return v;
|
11028
|
+
return v.id;
|
11029
|
+
}
|
11030
|
+
/** The `aliases` (`alsoKnownAs`) property is used to specify alternative names
|
11031
|
+
* or aliases for an entity. It can be used to provide additional identifiers
|
11032
|
+
* or labels for an entity, which can be useful in scenarios where an entity
|
11033
|
+
* may have multiple names or aliases.
|
11034
|
+
*/
|
11035
|
+
async getAlias(options = {}) {
|
11036
|
+
if (this.#_3NV7TGNhuABbryNjNi4wib4DgNpY.length < 1)
|
11037
|
+
return null;
|
11038
|
+
const v = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY[0];
|
11039
|
+
if (v instanceof URL) {
|
11040
|
+
const fetched = await this.#fetchAlias(v, options);
|
11041
|
+
if (fetched == null)
|
11042
|
+
return null;
|
11043
|
+
this.#_3NV7TGNhuABbryNjNi4wib4DgNpY[0] = fetched;
|
11044
|
+
return fetched;
|
11045
|
+
}
|
11046
|
+
return v;
|
11047
|
+
}
|
11048
|
+
/**
|
11049
|
+
* Similar to
|
11050
|
+
* {@link Application.getAliases},
|
11051
|
+
* but returns their `@id`s instead of the objects themselves.
|
11052
|
+
*/
|
11053
|
+
get aliasIds() {
|
11054
|
+
return this.#_3NV7TGNhuABbryNjNi4wib4DgNpY.map((v) => v instanceof URL ? v : v.id).filter((id) => id !== null);
|
11055
|
+
}
|
11056
|
+
/** The `aliases` (`alsoKnownAs`) property is used to specify alternative names
|
11057
|
+
* or aliases for an entity. It can be used to provide additional identifiers
|
11058
|
+
* or labels for an entity, which can be useful in scenarios where an entity
|
11059
|
+
* may have multiple names or aliases.
|
11060
|
+
*/
|
11061
|
+
async *getAliases(options = {}) {
|
11062
|
+
const vs = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY;
|
11063
|
+
for (let i = 0; i < vs.length; i++) {
|
11064
|
+
const v = vs[i];
|
11065
|
+
if (v instanceof URL) {
|
11066
|
+
const fetched = await this.#fetchAlias(v, options);
|
11067
|
+
if (fetched == null)
|
11068
|
+
continue;
|
11069
|
+
vs[i] = fetched;
|
11070
|
+
yield fetched;
|
11071
|
+
continue;
|
11072
|
+
}
|
11073
|
+
yield v;
|
11074
|
+
}
|
11075
|
+
}
|
10892
11076
|
/**
|
10893
11077
|
* Converts this object to a JSON-LD structure.
|
10894
11078
|
* @param options The options to use.
|
@@ -11163,6 +11347,47 @@ export class Application extends Object {
|
|
11163
11347
|
else if (compactItems.length === 1) {
|
11164
11348
|
result["indexable"] = compactItems[0];
|
11165
11349
|
}
|
11350
|
+
compactItems = [];
|
11351
|
+
for (const v of this.#_3NV7TGNhuABbryNjNi4wib4DgNpY) {
|
11352
|
+
const item = v instanceof URL
|
11353
|
+
? v.href
|
11354
|
+
: v instanceof _b
|
11355
|
+
? await v.toJsonLd({
|
11356
|
+
...options,
|
11357
|
+
format: undefined,
|
11358
|
+
context: undefined,
|
11359
|
+
})
|
11360
|
+
: v instanceof Group
|
11361
|
+
? await v.toJsonLd({
|
11362
|
+
...options,
|
11363
|
+
format: undefined,
|
11364
|
+
context: undefined,
|
11365
|
+
})
|
11366
|
+
: v instanceof Organization
|
11367
|
+
? await v.toJsonLd({
|
11368
|
+
...options,
|
11369
|
+
format: undefined,
|
11370
|
+
context: undefined,
|
11371
|
+
})
|
11372
|
+
: v instanceof Person
|
11373
|
+
? await v.toJsonLd({
|
11374
|
+
...options,
|
11375
|
+
format: undefined,
|
11376
|
+
context: undefined,
|
11377
|
+
})
|
11378
|
+
: await v.toJsonLd({
|
11379
|
+
...options,
|
11380
|
+
format: undefined,
|
11381
|
+
context: undefined,
|
11382
|
+
});
|
11383
|
+
compactItems.push(item);
|
11384
|
+
}
|
11385
|
+
if (compactItems.length > 1) {
|
11386
|
+
result["alsoKnownAs"] = compactItems;
|
11387
|
+
}
|
11388
|
+
else if (compactItems.length === 1) {
|
11389
|
+
result["alsoKnownAs"] = compactItems[0];
|
11390
|
+
}
|
11166
11391
|
result["type"] = "Application";
|
11167
11392
|
if (this.id != null)
|
11168
11393
|
result["id"] = this.id.href;
|
@@ -11355,6 +11580,24 @@ export class Application extends Object {
|
|
11355
11580
|
if (array.length > 0) {
|
11356
11581
|
values["http://joinmastodon.org/ns#indexable"] = array;
|
11357
11582
|
}
|
11583
|
+
array = [];
|
11584
|
+
for (const v of this.#_3NV7TGNhuABbryNjNi4wib4DgNpY) {
|
11585
|
+
const element = v instanceof URL
|
11586
|
+
? { "@id": v.href }
|
11587
|
+
: v instanceof _b
|
11588
|
+
? await v.toJsonLd(options)
|
11589
|
+
: v instanceof Group
|
11590
|
+
? await v.toJsonLd(options)
|
11591
|
+
: v instanceof Organization
|
11592
|
+
? await v.toJsonLd(options)
|
11593
|
+
: v instanceof Person
|
11594
|
+
? await v.toJsonLd(options)
|
11595
|
+
: await v.toJsonLd(options);
|
11596
|
+
array.push(element);
|
11597
|
+
}
|
11598
|
+
if (array.length > 0) {
|
11599
|
+
values["https://www.w3.org/ns/activitystreams#alsoKnownAs"] = array;
|
11600
|
+
}
|
11358
11601
|
values["@type"] = ["https://www.w3.org/ns/activitystreams#Application"];
|
11359
11602
|
if (this.id != null)
|
11360
11603
|
values["@id"] = this.id.href;
|
@@ -11441,7 +11684,7 @@ export class Application extends Object {
|
|
11441
11684
|
// @ts-ignore: an internal option
|
11442
11685
|
_fromSubclass: true,
|
11443
11686
|
});
|
11444
|
-
if (!(instance instanceof
|
11687
|
+
if (!(instance instanceof _b)) {
|
11445
11688
|
throw new TypeError("Unexpected type: " + instance.constructor.name);
|
11446
11689
|
}
|
11447
11690
|
const _3isuDgRAKSntq9XdbjiNxjwyPZAf = [];
|
@@ -11725,6 +11968,47 @@ export class Application extends Object {
|
|
11725
11968
|
_2diCorzqPGQQqftp6e4SrCEwEnyk.push(v["@value"]);
|
11726
11969
|
}
|
11727
11970
|
instance.#_2diCorzqPGQQqftp6e4SrCEwEnyk = _2diCorzqPGQQqftp6e4SrCEwEnyk;
|
11971
|
+
const _3NV7TGNhuABbryNjNi4wib4DgNpY = [];
|
11972
|
+
const _3NV7TGNhuABbryNjNi4wib4DgNpY__array = values["https://www.w3.org/ns/activitystreams#alsoKnownAs"];
|
11973
|
+
for (const v of _3NV7TGNhuABbryNjNi4wib4DgNpY__array == null
|
11974
|
+
? []
|
11975
|
+
: _3NV7TGNhuABbryNjNi4wib4DgNpY__array.length === 1 &&
|
11976
|
+
"@list" in _3NV7TGNhuABbryNjNi4wib4DgNpY__array[0]
|
11977
|
+
? _3NV7TGNhuABbryNjNi4wib4DgNpY__array[0]["@list"]
|
11978
|
+
: _3NV7TGNhuABbryNjNi4wib4DgNpY__array) {
|
11979
|
+
if (v == null)
|
11980
|
+
continue;
|
11981
|
+
if (typeof v === "object" && "@id" in v && !("@type" in v) &&
|
11982
|
+
globalThis.Object.keys(v).length === 1) {
|
11983
|
+
_3NV7TGNhuABbryNjNi4wib4DgNpY.push(new URL(v["@id"]));
|
11984
|
+
continue;
|
11985
|
+
}
|
11986
|
+
const decoded = typeof v === "object" && "@type" in v &&
|
11987
|
+
Array.isArray(v["@type"]) &&
|
11988
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Application")
|
11989
|
+
? await _b.fromJsonLd(v, options)
|
11990
|
+
: typeof v === "object" && "@type" in v &&
|
11991
|
+
Array.isArray(v["@type"]) &&
|
11992
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Group")
|
11993
|
+
? await Group.fromJsonLd(v, options)
|
11994
|
+
: typeof v === "object" && "@type" in v &&
|
11995
|
+
Array.isArray(v["@type"]) &&
|
11996
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Organization")
|
11997
|
+
? await Organization.fromJsonLd(v, options)
|
11998
|
+
: typeof v === "object" && "@type" in v &&
|
11999
|
+
Array.isArray(v["@type"]) &&
|
12000
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Person")
|
12001
|
+
? await Person.fromJsonLd(v, options)
|
12002
|
+
: typeof v === "object" && "@type" in v &&
|
12003
|
+
Array.isArray(v["@type"]) &&
|
12004
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Service")
|
12005
|
+
? await Service.fromJsonLd(v, options)
|
12006
|
+
: undefined;
|
12007
|
+
if (typeof decoded === "undefined")
|
12008
|
+
continue;
|
12009
|
+
_3NV7TGNhuABbryNjNi4wib4DgNpY.push(decoded);
|
12010
|
+
}
|
12011
|
+
instance.#_3NV7TGNhuABbryNjNi4wib4DgNpY = _3NV7TGNhuABbryNjNi4wib4DgNpY;
|
11728
12012
|
if (!("_fromSubclass" in options) || !options._fromSubclass) {
|
11729
12013
|
try {
|
11730
12014
|
instance.#cachedJsonLd = structuredClone(json);
|
@@ -11941,6 +12225,22 @@ export class Application extends Object {
|
|
11941
12225
|
if (_2diCorzqPGQQqftp6e4SrCEwEnyk.length == 1) {
|
11942
12226
|
proxy.indexable = _2diCorzqPGQQqftp6e4SrCEwEnyk[0];
|
11943
12227
|
}
|
12228
|
+
const _3NV7TGNhuABbryNjNi4wib4DgNpY = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY
|
12229
|
+
// deno-lint-ignore no-explicit-any
|
12230
|
+
.map((v) => v instanceof URL
|
12231
|
+
? {
|
12232
|
+
[Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
|
12233
|
+
[Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
|
12234
|
+
}
|
12235
|
+
: v);
|
12236
|
+
if (_3NV7TGNhuABbryNjNi4wib4DgNpY.length == 1) {
|
12237
|
+
proxy.alias = _3NV7TGNhuABbryNjNi4wib4DgNpY[0];
|
12238
|
+
}
|
12239
|
+
if (_3NV7TGNhuABbryNjNi4wib4DgNpY.length > 1 ||
|
12240
|
+
!("alias" in proxy) &&
|
12241
|
+
_3NV7TGNhuABbryNjNi4wib4DgNpY.length > 0) {
|
12242
|
+
proxy.aliases = _3NV7TGNhuABbryNjNi4wib4DgNpY;
|
12243
|
+
}
|
11944
12244
|
return proxy;
|
11945
12245
|
}
|
11946
12246
|
[Symbol.for("Deno.customInspect")](inspect, options) {
|
@@ -11952,6 +12252,7 @@ export class Application extends Object {
|
|
11952
12252
|
return "Application " + inspect(proxy, options);
|
11953
12253
|
}
|
11954
12254
|
}
|
12255
|
+
_b = Application;
|
11955
12256
|
/** Instances of `IntransitiveActivity` are a subtype of {@link Activity}
|
11956
12257
|
* representing intransitive actions. The `object` property is therefore
|
11957
12258
|
* inappropriate for these activities.
|
@@ -14327,7 +14628,7 @@ export class CollectionPage extends Collection {
|
|
14327
14628
|
}
|
14328
14629
|
}
|
14329
14630
|
if ("next" in values && values.next != null) {
|
14330
|
-
if (values.next instanceof
|
14631
|
+
if (values.next instanceof _c || values.next instanceof URL) {
|
14331
14632
|
// @ts-ignore: type is checked above.
|
14332
14633
|
this.#_3BT4kQLcXhHx7TAWaNDKh8nFn9eY = [values.next];
|
14333
14634
|
}
|
@@ -14337,7 +14638,7 @@ export class CollectionPage extends Collection {
|
|
14337
14638
|
}
|
14338
14639
|
}
|
14339
14640
|
if ("prev" in values && values.prev != null) {
|
14340
|
-
if (values.prev instanceof
|
14641
|
+
if (values.prev instanceof _c || values.prev instanceof URL) {
|
14341
14642
|
// @ts-ignore: type is checked above.
|
14342
14643
|
this.#_3b8yG8tDNzQFFEnWhCc13G8eHooA = [values.prev];
|
14343
14644
|
}
|
@@ -14368,7 +14669,7 @@ export class CollectionPage extends Collection {
|
|
14368
14669
|
}
|
14369
14670
|
clone.#_3BT4kQLcXhHx7TAWaNDKh8nFn9eY = this.#_3BT4kQLcXhHx7TAWaNDKh8nFn9eY;
|
14370
14671
|
if ("next" in values && values.next != null) {
|
14371
|
-
if (values.next instanceof
|
14672
|
+
if (values.next instanceof _c || values.next instanceof URL) {
|
14372
14673
|
// @ts-ignore: type is checked above.
|
14373
14674
|
clone.#_3BT4kQLcXhHx7TAWaNDKh8nFn9eY = [values.next];
|
14374
14675
|
}
|
@@ -14379,7 +14680,7 @@ export class CollectionPage extends Collection {
|
|
14379
14680
|
}
|
14380
14681
|
clone.#_3b8yG8tDNzQFFEnWhCc13G8eHooA = this.#_3b8yG8tDNzQFFEnWhCc13G8eHooA;
|
14381
14682
|
if ("prev" in values && values.prev != null) {
|
14382
|
-
if (values.prev instanceof
|
14683
|
+
if (values.prev instanceof _c || values.prev instanceof URL) {
|
14383
14684
|
// @ts-ignore: type is checked above.
|
14384
14685
|
clone.#_3b8yG8tDNzQFFEnWhCc13G8eHooA = [values.prev];
|
14385
14686
|
}
|
@@ -14464,7 +14765,7 @@ export class CollectionPage extends Collection {
|
|
14464
14765
|
}
|
14465
14766
|
const { document } = fetchResult;
|
14466
14767
|
try {
|
14467
|
-
return await
|
14768
|
+
return await _c.fromJsonLd(document, { documentLoader, contextLoader });
|
14468
14769
|
}
|
14469
14770
|
catch (e) {
|
14470
14771
|
if (!(e instanceof TypeError))
|
@@ -14519,7 +14820,7 @@ export class CollectionPage extends Collection {
|
|
14519
14820
|
}
|
14520
14821
|
const { document } = fetchResult;
|
14521
14822
|
try {
|
14522
|
-
return await
|
14823
|
+
return await _c.fromJsonLd(document, { documentLoader, contextLoader });
|
14523
14824
|
}
|
14524
14825
|
catch (e) {
|
14525
14826
|
if (!(e instanceof TypeError))
|
@@ -14771,7 +15072,7 @@ export class CollectionPage extends Collection {
|
|
14771
15072
|
// @ts-ignore: an internal option
|
14772
15073
|
_fromSubclass: true,
|
14773
15074
|
});
|
14774
|
-
if (!(instance instanceof
|
15075
|
+
if (!(instance instanceof _c)) {
|
14775
15076
|
throw new TypeError("Unexpected type: " + instance.constructor.name);
|
14776
15077
|
}
|
14777
15078
|
const _2kWgBhQKjEauxx8C6qF3ZQamK4Le = [];
|
@@ -14807,7 +15108,7 @@ export class CollectionPage extends Collection {
|
|
14807
15108
|
_3BT4kQLcXhHx7TAWaNDKh8nFn9eY.push(new URL(v["@id"]));
|
14808
15109
|
continue;
|
14809
15110
|
}
|
14810
|
-
_3BT4kQLcXhHx7TAWaNDKh8nFn9eY.push(await
|
15111
|
+
_3BT4kQLcXhHx7TAWaNDKh8nFn9eY.push(await _c.fromJsonLd(v, options));
|
14811
15112
|
}
|
14812
15113
|
instance.#_3BT4kQLcXhHx7TAWaNDKh8nFn9eY = _3BT4kQLcXhHx7TAWaNDKh8nFn9eY;
|
14813
15114
|
const _3b8yG8tDNzQFFEnWhCc13G8eHooA = [];
|
@@ -14825,7 +15126,7 @@ export class CollectionPage extends Collection {
|
|
14825
15126
|
_3b8yG8tDNzQFFEnWhCc13G8eHooA.push(new URL(v["@id"]));
|
14826
15127
|
continue;
|
14827
15128
|
}
|
14828
|
-
_3b8yG8tDNzQFFEnWhCc13G8eHooA.push(await
|
15129
|
+
_3b8yG8tDNzQFFEnWhCc13G8eHooA.push(await _c.fromJsonLd(v, options));
|
14829
15130
|
}
|
14830
15131
|
instance.#_3b8yG8tDNzQFFEnWhCc13G8eHooA = _3b8yG8tDNzQFFEnWhCc13G8eHooA;
|
14831
15132
|
if (!("_fromSubclass" in options) || !options._fromSubclass) {
|
@@ -14884,7 +15185,7 @@ export class CollectionPage extends Collection {
|
|
14884
15185
|
return "CollectionPage " + inspect(proxy, options);
|
14885
15186
|
}
|
14886
15187
|
}
|
14887
|
-
|
15188
|
+
_c = CollectionPage;
|
14888
15189
|
/** Indicates that the `actor` has created the `object`.
|
14889
15190
|
*/
|
14890
15191
|
export class Create extends Activity {
|
@@ -16654,6 +16955,7 @@ export class Group extends Object {
|
|
16654
16955
|
#_2kGKkJtoFWg8c18PaVSqj9NKP4t7 = [];
|
16655
16956
|
#_79S8K4f5J9MWUgCxziRyUe6PTHZ = [];
|
16656
16957
|
#_2diCorzqPGQQqftp6e4SrCEwEnyk = [];
|
16958
|
+
#_3NV7TGNhuABbryNjNi4wib4DgNpY = [];
|
16657
16959
|
/**
|
16658
16960
|
* Constructs a new instance of Group with the given values.
|
16659
16961
|
* @param values The values to initialize the instance with.
|
@@ -16888,6 +17190,37 @@ export class Group extends Object {
|
|
16888
17190
|
"boolean" + ".");
|
16889
17191
|
}
|
16890
17192
|
}
|
17193
|
+
if ("alias" in values && values.alias != null) {
|
17194
|
+
if (values.alias instanceof Application || values.alias instanceof _d ||
|
17195
|
+
values.alias instanceof Organization ||
|
17196
|
+
values.alias instanceof Person || values.alias instanceof Service ||
|
17197
|
+
values.alias instanceof URL) {
|
17198
|
+
// @ts-ignore: type is checked above.
|
17199
|
+
this.#_3NV7TGNhuABbryNjNi4wib4DgNpY = [values.alias];
|
17200
|
+
}
|
17201
|
+
else {
|
17202
|
+
throw new TypeError("The alias must be of type " +
|
17203
|
+
"Application | Group | Organization | Person | Service | URL" + ".");
|
17204
|
+
}
|
17205
|
+
}
|
17206
|
+
if ("aliases" in values && values.aliases != null) {
|
17207
|
+
if ("alias" in values &&
|
17208
|
+
values.alias != null) {
|
17209
|
+
throw new TypeError("Cannot initialize both alias and " +
|
17210
|
+
"aliases at the same time.");
|
17211
|
+
}
|
17212
|
+
if (Array.isArray(values.aliases) &&
|
17213
|
+
values.aliases.every((v) => v instanceof Application || v instanceof _d ||
|
17214
|
+
v instanceof Organization || v instanceof Person ||
|
17215
|
+
v instanceof Service || v instanceof URL)) {
|
17216
|
+
// @ts-ignore: type is checked above.
|
17217
|
+
this.#_3NV7TGNhuABbryNjNi4wib4DgNpY = values.aliases;
|
17218
|
+
}
|
17219
|
+
else {
|
17220
|
+
throw new TypeError("The aliases must be an array of type " +
|
17221
|
+
"Application | Group | Organization | Person | Service | URL" + ".");
|
17222
|
+
}
|
17223
|
+
}
|
16891
17224
|
}
|
16892
17225
|
/**
|
16893
17226
|
* Clones this instance, optionally updating it with the given values.
|
@@ -17143,6 +17476,38 @@ export class Group extends Object {
|
|
17143
17476
|
"boolean" + ".");
|
17144
17477
|
}
|
17145
17478
|
}
|
17479
|
+
clone.#_3NV7TGNhuABbryNjNi4wib4DgNpY = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY;
|
17480
|
+
if ("alias" in values && values.alias != null) {
|
17481
|
+
if (values.alias instanceof Application || values.alias instanceof _d ||
|
17482
|
+
values.alias instanceof Organization ||
|
17483
|
+
values.alias instanceof Person || values.alias instanceof Service ||
|
17484
|
+
values.alias instanceof URL) {
|
17485
|
+
// @ts-ignore: type is checked above.
|
17486
|
+
clone.#_3NV7TGNhuABbryNjNi4wib4DgNpY = [values.alias];
|
17487
|
+
}
|
17488
|
+
else {
|
17489
|
+
throw new TypeError("The alias must be of type " +
|
17490
|
+
"Application | Group | Organization | Person | Service | URL" + ".");
|
17491
|
+
}
|
17492
|
+
}
|
17493
|
+
if ("aliases" in values && values.aliases != null) {
|
17494
|
+
if ("alias" in values &&
|
17495
|
+
values.alias != null) {
|
17496
|
+
throw new TypeError("Cannot update both alias and " +
|
17497
|
+
"aliases at the same time.");
|
17498
|
+
}
|
17499
|
+
if (Array.isArray(values.aliases) &&
|
17500
|
+
values.aliases.every((v) => v instanceof Application || v instanceof _d ||
|
17501
|
+
v instanceof Organization || v instanceof Person ||
|
17502
|
+
v instanceof Service || v instanceof URL)) {
|
17503
|
+
// @ts-ignore: type is checked above.
|
17504
|
+
clone.#_3NV7TGNhuABbryNjNi4wib4DgNpY = values.aliases;
|
17505
|
+
}
|
17506
|
+
else {
|
17507
|
+
throw new TypeError("The aliases must be an array of type " +
|
17508
|
+
"Application | Group | Organization | Person | Service | URL" + ".");
|
17509
|
+
}
|
17510
|
+
}
|
17146
17511
|
return clone;
|
17147
17512
|
}
|
17148
17513
|
/** A short username which may be used to refer to the actor,
|
@@ -17859,6 +18224,126 @@ export class Group extends Object {
|
|
17859
18224
|
return null;
|
17860
18225
|
return this.#_2diCorzqPGQQqftp6e4SrCEwEnyk[0];
|
17861
18226
|
}
|
18227
|
+
async #fetchAlias(url, options = {}) {
|
18228
|
+
const documentLoader = options.documentLoader ?? this._documentLoader ??
|
18229
|
+
fetchDocumentLoader;
|
18230
|
+
const contextLoader = options.contextLoader ?? this._contextLoader ??
|
18231
|
+
fetchDocumentLoader;
|
18232
|
+
let fetchResult;
|
18233
|
+
try {
|
18234
|
+
fetchResult = await documentLoader(url.href);
|
18235
|
+
}
|
18236
|
+
catch (error) {
|
18237
|
+
if (options.suppressError) {
|
18238
|
+
getLogger(["fedify", "vocab"]).error("Failed to fetch {url}: {error}", { error, url: url.href });
|
18239
|
+
return null;
|
18240
|
+
}
|
18241
|
+
throw error;
|
18242
|
+
}
|
18243
|
+
const { document } = fetchResult;
|
18244
|
+
try {
|
18245
|
+
return await Application.fromJsonLd(document, { documentLoader, contextLoader });
|
18246
|
+
}
|
18247
|
+
catch (e) {
|
18248
|
+
if (!(e instanceof TypeError))
|
18249
|
+
throw e;
|
18250
|
+
}
|
18251
|
+
try {
|
18252
|
+
return await _d.fromJsonLd(document, { documentLoader, contextLoader });
|
18253
|
+
}
|
18254
|
+
catch (e) {
|
18255
|
+
if (!(e instanceof TypeError))
|
18256
|
+
throw e;
|
18257
|
+
}
|
18258
|
+
try {
|
18259
|
+
return await Organization.fromJsonLd(document, { documentLoader, contextLoader });
|
18260
|
+
}
|
18261
|
+
catch (e) {
|
18262
|
+
if (!(e instanceof TypeError))
|
18263
|
+
throw e;
|
18264
|
+
}
|
18265
|
+
try {
|
18266
|
+
return await Person.fromJsonLd(document, { documentLoader, contextLoader });
|
18267
|
+
}
|
18268
|
+
catch (e) {
|
18269
|
+
if (!(e instanceof TypeError))
|
18270
|
+
throw e;
|
18271
|
+
}
|
18272
|
+
try {
|
18273
|
+
return await Service.fromJsonLd(document, { documentLoader, contextLoader });
|
18274
|
+
}
|
18275
|
+
catch (e) {
|
18276
|
+
if (!(e instanceof TypeError))
|
18277
|
+
throw e;
|
18278
|
+
}
|
18279
|
+
throw new TypeError("Expected an object of any type of: " +
|
18280
|
+
[
|
18281
|
+
"https://www.w3.org/ns/activitystreams#Application",
|
18282
|
+
"https://www.w3.org/ns/activitystreams#Group",
|
18283
|
+
"https://www.w3.org/ns/activitystreams#Organization",
|
18284
|
+
"https://www.w3.org/ns/activitystreams#Person",
|
18285
|
+
"https://www.w3.org/ns/activitystreams#Service",
|
18286
|
+
].join(", "));
|
18287
|
+
}
|
18288
|
+
/**
|
18289
|
+
* Similar to
|
18290
|
+
* {@link Group.getAlias},
|
18291
|
+
* but returns its `@id` URL instead of the object itself.
|
18292
|
+
*/
|
18293
|
+
get aliasId() {
|
18294
|
+
if (this.#_3NV7TGNhuABbryNjNi4wib4DgNpY.length < 1)
|
18295
|
+
return null;
|
18296
|
+
const v = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY[0];
|
18297
|
+
if (v instanceof URL)
|
18298
|
+
return v;
|
18299
|
+
return v.id;
|
18300
|
+
}
|
18301
|
+
/** The `aliases` (`alsoKnownAs`) property is used to specify alternative names
|
18302
|
+
* or aliases for an entity. It can be used to provide additional identifiers
|
18303
|
+
* or labels for an entity, which can be useful in scenarios where an entity
|
18304
|
+
* may have multiple names or aliases.
|
18305
|
+
*/
|
18306
|
+
async getAlias(options = {}) {
|
18307
|
+
if (this.#_3NV7TGNhuABbryNjNi4wib4DgNpY.length < 1)
|
18308
|
+
return null;
|
18309
|
+
const v = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY[0];
|
18310
|
+
if (v instanceof URL) {
|
18311
|
+
const fetched = await this.#fetchAlias(v, options);
|
18312
|
+
if (fetched == null)
|
18313
|
+
return null;
|
18314
|
+
this.#_3NV7TGNhuABbryNjNi4wib4DgNpY[0] = fetched;
|
18315
|
+
return fetched;
|
18316
|
+
}
|
18317
|
+
return v;
|
18318
|
+
}
|
18319
|
+
/**
|
18320
|
+
* Similar to
|
18321
|
+
* {@link Group.getAliases},
|
18322
|
+
* but returns their `@id`s instead of the objects themselves.
|
18323
|
+
*/
|
18324
|
+
get aliasIds() {
|
18325
|
+
return this.#_3NV7TGNhuABbryNjNi4wib4DgNpY.map((v) => v instanceof URL ? v : v.id).filter((id) => id !== null);
|
18326
|
+
}
|
18327
|
+
/** The `aliases` (`alsoKnownAs`) property is used to specify alternative names
|
18328
|
+
* or aliases for an entity. It can be used to provide additional identifiers
|
18329
|
+
* or labels for an entity, which can be useful in scenarios where an entity
|
18330
|
+
* may have multiple names or aliases.
|
18331
|
+
*/
|
18332
|
+
async *getAliases(options = {}) {
|
18333
|
+
const vs = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY;
|
18334
|
+
for (let i = 0; i < vs.length; i++) {
|
18335
|
+
const v = vs[i];
|
18336
|
+
if (v instanceof URL) {
|
18337
|
+
const fetched = await this.#fetchAlias(v, options);
|
18338
|
+
if (fetched == null)
|
18339
|
+
continue;
|
18340
|
+
vs[i] = fetched;
|
18341
|
+
yield fetched;
|
18342
|
+
continue;
|
18343
|
+
}
|
18344
|
+
yield v;
|
18345
|
+
}
|
18346
|
+
}
|
17862
18347
|
/**
|
17863
18348
|
* Converts this object to a JSON-LD structure.
|
17864
18349
|
* @param options The options to use.
|
@@ -18133,6 +18618,47 @@ export class Group extends Object {
|
|
18133
18618
|
else if (compactItems.length === 1) {
|
18134
18619
|
result["indexable"] = compactItems[0];
|
18135
18620
|
}
|
18621
|
+
compactItems = [];
|
18622
|
+
for (const v of this.#_3NV7TGNhuABbryNjNi4wib4DgNpY) {
|
18623
|
+
const item = v instanceof URL
|
18624
|
+
? v.href
|
18625
|
+
: v instanceof Application
|
18626
|
+
? await v.toJsonLd({
|
18627
|
+
...options,
|
18628
|
+
format: undefined,
|
18629
|
+
context: undefined,
|
18630
|
+
})
|
18631
|
+
: v instanceof _d
|
18632
|
+
? await v.toJsonLd({
|
18633
|
+
...options,
|
18634
|
+
format: undefined,
|
18635
|
+
context: undefined,
|
18636
|
+
})
|
18637
|
+
: v instanceof Organization
|
18638
|
+
? await v.toJsonLd({
|
18639
|
+
...options,
|
18640
|
+
format: undefined,
|
18641
|
+
context: undefined,
|
18642
|
+
})
|
18643
|
+
: v instanceof Person
|
18644
|
+
? await v.toJsonLd({
|
18645
|
+
...options,
|
18646
|
+
format: undefined,
|
18647
|
+
context: undefined,
|
18648
|
+
})
|
18649
|
+
: await v.toJsonLd({
|
18650
|
+
...options,
|
18651
|
+
format: undefined,
|
18652
|
+
context: undefined,
|
18653
|
+
});
|
18654
|
+
compactItems.push(item);
|
18655
|
+
}
|
18656
|
+
if (compactItems.length > 1) {
|
18657
|
+
result["alsoKnownAs"] = compactItems;
|
18658
|
+
}
|
18659
|
+
else if (compactItems.length === 1) {
|
18660
|
+
result["alsoKnownAs"] = compactItems[0];
|
18661
|
+
}
|
18136
18662
|
result["type"] = "Group";
|
18137
18663
|
if (this.id != null)
|
18138
18664
|
result["id"] = this.id.href;
|
@@ -18325,6 +18851,24 @@ export class Group extends Object {
|
|
18325
18851
|
if (array.length > 0) {
|
18326
18852
|
values["http://joinmastodon.org/ns#indexable"] = array;
|
18327
18853
|
}
|
18854
|
+
array = [];
|
18855
|
+
for (const v of this.#_3NV7TGNhuABbryNjNi4wib4DgNpY) {
|
18856
|
+
const element = v instanceof URL
|
18857
|
+
? { "@id": v.href }
|
18858
|
+
: v instanceof Application
|
18859
|
+
? await v.toJsonLd(options)
|
18860
|
+
: v instanceof _d
|
18861
|
+
? await v.toJsonLd(options)
|
18862
|
+
: v instanceof Organization
|
18863
|
+
? await v.toJsonLd(options)
|
18864
|
+
: v instanceof Person
|
18865
|
+
? await v.toJsonLd(options)
|
18866
|
+
: await v.toJsonLd(options);
|
18867
|
+
array.push(element);
|
18868
|
+
}
|
18869
|
+
if (array.length > 0) {
|
18870
|
+
values["https://www.w3.org/ns/activitystreams#alsoKnownAs"] = array;
|
18871
|
+
}
|
18328
18872
|
values["@type"] = ["https://www.w3.org/ns/activitystreams#Group"];
|
18329
18873
|
if (this.id != null)
|
18330
18874
|
values["@id"] = this.id.href;
|
@@ -18411,7 +18955,7 @@ export class Group extends Object {
|
|
18411
18955
|
// @ts-ignore: an internal option
|
18412
18956
|
_fromSubclass: true,
|
18413
18957
|
});
|
18414
|
-
if (!(instance instanceof
|
18958
|
+
if (!(instance instanceof _d)) {
|
18415
18959
|
throw new TypeError("Unexpected type: " + instance.constructor.name);
|
18416
18960
|
}
|
18417
18961
|
const _3isuDgRAKSntq9XdbjiNxjwyPZAf = [];
|
@@ -18695,6 +19239,47 @@ export class Group extends Object {
|
|
18695
19239
|
_2diCorzqPGQQqftp6e4SrCEwEnyk.push(v["@value"]);
|
18696
19240
|
}
|
18697
19241
|
instance.#_2diCorzqPGQQqftp6e4SrCEwEnyk = _2diCorzqPGQQqftp6e4SrCEwEnyk;
|
19242
|
+
const _3NV7TGNhuABbryNjNi4wib4DgNpY = [];
|
19243
|
+
const _3NV7TGNhuABbryNjNi4wib4DgNpY__array = values["https://www.w3.org/ns/activitystreams#alsoKnownAs"];
|
19244
|
+
for (const v of _3NV7TGNhuABbryNjNi4wib4DgNpY__array == null
|
19245
|
+
? []
|
19246
|
+
: _3NV7TGNhuABbryNjNi4wib4DgNpY__array.length === 1 &&
|
19247
|
+
"@list" in _3NV7TGNhuABbryNjNi4wib4DgNpY__array[0]
|
19248
|
+
? _3NV7TGNhuABbryNjNi4wib4DgNpY__array[0]["@list"]
|
19249
|
+
: _3NV7TGNhuABbryNjNi4wib4DgNpY__array) {
|
19250
|
+
if (v == null)
|
19251
|
+
continue;
|
19252
|
+
if (typeof v === "object" && "@id" in v && !("@type" in v) &&
|
19253
|
+
globalThis.Object.keys(v).length === 1) {
|
19254
|
+
_3NV7TGNhuABbryNjNi4wib4DgNpY.push(new URL(v["@id"]));
|
19255
|
+
continue;
|
19256
|
+
}
|
19257
|
+
const decoded = typeof v === "object" && "@type" in v &&
|
19258
|
+
Array.isArray(v["@type"]) &&
|
19259
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Application")
|
19260
|
+
? await Application.fromJsonLd(v, options)
|
19261
|
+
: typeof v === "object" && "@type" in v &&
|
19262
|
+
Array.isArray(v["@type"]) &&
|
19263
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Group")
|
19264
|
+
? await _d.fromJsonLd(v, options)
|
19265
|
+
: typeof v === "object" && "@type" in v &&
|
19266
|
+
Array.isArray(v["@type"]) &&
|
19267
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Organization")
|
19268
|
+
? await Organization.fromJsonLd(v, options)
|
19269
|
+
: typeof v === "object" && "@type" in v &&
|
19270
|
+
Array.isArray(v["@type"]) &&
|
19271
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Person")
|
19272
|
+
? await Person.fromJsonLd(v, options)
|
19273
|
+
: typeof v === "object" && "@type" in v &&
|
19274
|
+
Array.isArray(v["@type"]) &&
|
19275
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Service")
|
19276
|
+
? await Service.fromJsonLd(v, options)
|
19277
|
+
: undefined;
|
19278
|
+
if (typeof decoded === "undefined")
|
19279
|
+
continue;
|
19280
|
+
_3NV7TGNhuABbryNjNi4wib4DgNpY.push(decoded);
|
19281
|
+
}
|
19282
|
+
instance.#_3NV7TGNhuABbryNjNi4wib4DgNpY = _3NV7TGNhuABbryNjNi4wib4DgNpY;
|
18698
19283
|
if (!("_fromSubclass" in options) || !options._fromSubclass) {
|
18699
19284
|
try {
|
18700
19285
|
instance.#cachedJsonLd = structuredClone(json);
|
@@ -18911,6 +19496,22 @@ export class Group extends Object {
|
|
18911
19496
|
if (_2diCorzqPGQQqftp6e4SrCEwEnyk.length == 1) {
|
18912
19497
|
proxy.indexable = _2diCorzqPGQQqftp6e4SrCEwEnyk[0];
|
18913
19498
|
}
|
19499
|
+
const _3NV7TGNhuABbryNjNi4wib4DgNpY = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY
|
19500
|
+
// deno-lint-ignore no-explicit-any
|
19501
|
+
.map((v) => v instanceof URL
|
19502
|
+
? {
|
19503
|
+
[Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
|
19504
|
+
[Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
|
19505
|
+
}
|
19506
|
+
: v);
|
19507
|
+
if (_3NV7TGNhuABbryNjNi4wib4DgNpY.length == 1) {
|
19508
|
+
proxy.alias = _3NV7TGNhuABbryNjNi4wib4DgNpY[0];
|
19509
|
+
}
|
19510
|
+
if (_3NV7TGNhuABbryNjNi4wib4DgNpY.length > 1 ||
|
19511
|
+
!("alias" in proxy) &&
|
19512
|
+
_3NV7TGNhuABbryNjNi4wib4DgNpY.length > 0) {
|
19513
|
+
proxy.aliases = _3NV7TGNhuABbryNjNi4wib4DgNpY;
|
19514
|
+
}
|
18914
19515
|
return proxy;
|
18915
19516
|
}
|
18916
19517
|
[Symbol.for("Deno.customInspect")](inspect, options) {
|
@@ -18922,6 +19523,7 @@ export class Group extends Object {
|
|
18922
19523
|
return "Group " + inspect(proxy, options);
|
18923
19524
|
}
|
18924
19525
|
}
|
19526
|
+
_d = Group;
|
18925
19527
|
/** A Link is an indirect, qualified reference to a resource identified by a URL.
|
18926
19528
|
* The fundamental model for links is established by RFC 5988. Many of the
|
18927
19529
|
* properties defined by the Activity Vocabulary allow values that are either
|
@@ -19076,7 +19678,7 @@ export class Link {
|
|
19076
19678
|
}
|
19077
19679
|
if ("previews" in values && values.previews != null) {
|
19078
19680
|
if (Array.isArray(values.previews) &&
|
19079
|
-
values.previews.every((v) => v instanceof
|
19681
|
+
values.previews.every((v) => v instanceof _e || v instanceof Object || v instanceof URL)) {
|
19080
19682
|
// @ts-ignore: type is checked above.
|
19081
19683
|
this.#_gCVTegXxWWCw6wWRxa1QF65zusg = values.previews;
|
19082
19684
|
}
|
@@ -19209,7 +19811,7 @@ export class Link {
|
|
19209
19811
|
clone.#_gCVTegXxWWCw6wWRxa1QF65zusg = this.#_gCVTegXxWWCw6wWRxa1QF65zusg;
|
19210
19812
|
if ("previews" in values && values.previews != null) {
|
19211
19813
|
if (Array.isArray(values.previews) &&
|
19212
|
-
values.previews.every((v) => v instanceof
|
19814
|
+
values.previews.every((v) => v instanceof _e || v instanceof Object || v instanceof URL)) {
|
19213
19815
|
// @ts-ignore: type is checked above.
|
19214
19816
|
clone.#_gCVTegXxWWCw6wWRxa1QF65zusg = values.previews;
|
19215
19817
|
}
|
@@ -19315,7 +19917,7 @@ export class Link {
|
|
19315
19917
|
}
|
19316
19918
|
const { document } = fetchResult;
|
19317
19919
|
try {
|
19318
|
-
return await
|
19920
|
+
return await _e.fromJsonLd(document, { documentLoader, contextLoader });
|
19319
19921
|
}
|
19320
19922
|
catch (e) {
|
19321
19923
|
if (!(e instanceof TypeError))
|
@@ -19479,7 +20081,7 @@ export class Link {
|
|
19479
20081
|
for (const v of this.#_gCVTegXxWWCw6wWRxa1QF65zusg) {
|
19480
20082
|
const item = v instanceof URL
|
19481
20083
|
? v.href
|
19482
|
-
: v instanceof
|
20084
|
+
: v instanceof _e
|
19483
20085
|
? await v.toJsonLd({
|
19484
20086
|
...options,
|
19485
20087
|
format: undefined,
|
@@ -19576,7 +20178,7 @@ export class Link {
|
|
19576
20178
|
for (const v of this.#_gCVTegXxWWCw6wWRxa1QF65zusg) {
|
19577
20179
|
const element = v instanceof URL
|
19578
20180
|
? { "@id": v.href }
|
19579
|
-
: v instanceof
|
20181
|
+
: v instanceof _e
|
19580
20182
|
? await v.toJsonLd(options)
|
19581
20183
|
: await v.toJsonLd(options);
|
19582
20184
|
array.push(element);
|
@@ -19764,7 +20366,7 @@ export class Link {
|
|
19764
20366
|
"https://www.w3.org/ns/activitystreams#Hashtag",
|
19765
20367
|
"https://www.w3.org/ns/activitystreams#Mention",
|
19766
20368
|
].some((t) => v["@type"].includes(t))
|
19767
|
-
? await
|
20369
|
+
? await _e.fromJsonLd(v, options)
|
19768
20370
|
: typeof v === "object" && "@type" in v &&
|
19769
20371
|
Array.isArray(v["@type"]) &&
|
19770
20372
|
[
|
@@ -19959,7 +20561,7 @@ export class Link {
|
|
19959
20561
|
return "Link " + inspect(proxy, options);
|
19960
20562
|
}
|
19961
20563
|
}
|
19962
|
-
|
20564
|
+
_e = Link;
|
19963
20565
|
/** A specialized {@link Link} that represents an #hashtag.
|
19964
20566
|
*
|
19965
20567
|
* See also <https://swicg.github.io/miscellany/#Hashtag>.
|
@@ -22857,6 +23459,7 @@ export class Organization extends Object {
|
|
22857
23459
|
#_2kGKkJtoFWg8c18PaVSqj9NKP4t7 = [];
|
22858
23460
|
#_79S8K4f5J9MWUgCxziRyUe6PTHZ = [];
|
22859
23461
|
#_2diCorzqPGQQqftp6e4SrCEwEnyk = [];
|
23462
|
+
#_3NV7TGNhuABbryNjNi4wib4DgNpY = [];
|
22860
23463
|
/**
|
22861
23464
|
* Constructs a new instance of Organization with the given values.
|
22862
23465
|
* @param values The values to initialize the instance with.
|
@@ -23091,6 +23694,37 @@ export class Organization extends Object {
|
|
23091
23694
|
"boolean" + ".");
|
23092
23695
|
}
|
23093
23696
|
}
|
23697
|
+
if ("alias" in values && values.alias != null) {
|
23698
|
+
if (values.alias instanceof Application || values.alias instanceof Group ||
|
23699
|
+
values.alias instanceof _f ||
|
23700
|
+
values.alias instanceof Person || values.alias instanceof Service ||
|
23701
|
+
values.alias instanceof URL) {
|
23702
|
+
// @ts-ignore: type is checked above.
|
23703
|
+
this.#_3NV7TGNhuABbryNjNi4wib4DgNpY = [values.alias];
|
23704
|
+
}
|
23705
|
+
else {
|
23706
|
+
throw new TypeError("The alias must be of type " +
|
23707
|
+
"Application | Group | Organization | Person | Service | URL" + ".");
|
23708
|
+
}
|
23709
|
+
}
|
23710
|
+
if ("aliases" in values && values.aliases != null) {
|
23711
|
+
if ("alias" in values &&
|
23712
|
+
values.alias != null) {
|
23713
|
+
throw new TypeError("Cannot initialize both alias and " +
|
23714
|
+
"aliases at the same time.");
|
23715
|
+
}
|
23716
|
+
if (Array.isArray(values.aliases) &&
|
23717
|
+
values.aliases.every((v) => v instanceof Application || v instanceof Group ||
|
23718
|
+
v instanceof _f || v instanceof Person ||
|
23719
|
+
v instanceof Service || v instanceof URL)) {
|
23720
|
+
// @ts-ignore: type is checked above.
|
23721
|
+
this.#_3NV7TGNhuABbryNjNi4wib4DgNpY = values.aliases;
|
23722
|
+
}
|
23723
|
+
else {
|
23724
|
+
throw new TypeError("The aliases must be an array of type " +
|
23725
|
+
"Application | Group | Organization | Person | Service | URL" + ".");
|
23726
|
+
}
|
23727
|
+
}
|
23094
23728
|
}
|
23095
23729
|
/**
|
23096
23730
|
* Clones this instance, optionally updating it with the given values.
|
@@ -23346,6 +23980,38 @@ export class Organization extends Object {
|
|
23346
23980
|
"boolean" + ".");
|
23347
23981
|
}
|
23348
23982
|
}
|
23983
|
+
clone.#_3NV7TGNhuABbryNjNi4wib4DgNpY = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY;
|
23984
|
+
if ("alias" in values && values.alias != null) {
|
23985
|
+
if (values.alias instanceof Application || values.alias instanceof Group ||
|
23986
|
+
values.alias instanceof _f ||
|
23987
|
+
values.alias instanceof Person || values.alias instanceof Service ||
|
23988
|
+
values.alias instanceof URL) {
|
23989
|
+
// @ts-ignore: type is checked above.
|
23990
|
+
clone.#_3NV7TGNhuABbryNjNi4wib4DgNpY = [values.alias];
|
23991
|
+
}
|
23992
|
+
else {
|
23993
|
+
throw new TypeError("The alias must be of type " +
|
23994
|
+
"Application | Group | Organization | Person | Service | URL" + ".");
|
23995
|
+
}
|
23996
|
+
}
|
23997
|
+
if ("aliases" in values && values.aliases != null) {
|
23998
|
+
if ("alias" in values &&
|
23999
|
+
values.alias != null) {
|
24000
|
+
throw new TypeError("Cannot update both alias and " +
|
24001
|
+
"aliases at the same time.");
|
24002
|
+
}
|
24003
|
+
if (Array.isArray(values.aliases) &&
|
24004
|
+
values.aliases.every((v) => v instanceof Application || v instanceof Group ||
|
24005
|
+
v instanceof _f || v instanceof Person ||
|
24006
|
+
v instanceof Service || v instanceof URL)) {
|
24007
|
+
// @ts-ignore: type is checked above.
|
24008
|
+
clone.#_3NV7TGNhuABbryNjNi4wib4DgNpY = values.aliases;
|
24009
|
+
}
|
24010
|
+
else {
|
24011
|
+
throw new TypeError("The aliases must be an array of type " +
|
24012
|
+
"Application | Group | Organization | Person | Service | URL" + ".");
|
24013
|
+
}
|
24014
|
+
}
|
23349
24015
|
return clone;
|
23350
24016
|
}
|
23351
24017
|
/** A short username which may be used to refer to the actor,
|
@@ -24062,6 +24728,126 @@ export class Organization extends Object {
|
|
24062
24728
|
return null;
|
24063
24729
|
return this.#_2diCorzqPGQQqftp6e4SrCEwEnyk[0];
|
24064
24730
|
}
|
24731
|
+
async #fetchAlias(url, options = {}) {
|
24732
|
+
const documentLoader = options.documentLoader ?? this._documentLoader ??
|
24733
|
+
fetchDocumentLoader;
|
24734
|
+
const contextLoader = options.contextLoader ?? this._contextLoader ??
|
24735
|
+
fetchDocumentLoader;
|
24736
|
+
let fetchResult;
|
24737
|
+
try {
|
24738
|
+
fetchResult = await documentLoader(url.href);
|
24739
|
+
}
|
24740
|
+
catch (error) {
|
24741
|
+
if (options.suppressError) {
|
24742
|
+
getLogger(["fedify", "vocab"]).error("Failed to fetch {url}: {error}", { error, url: url.href });
|
24743
|
+
return null;
|
24744
|
+
}
|
24745
|
+
throw error;
|
24746
|
+
}
|
24747
|
+
const { document } = fetchResult;
|
24748
|
+
try {
|
24749
|
+
return await Application.fromJsonLd(document, { documentLoader, contextLoader });
|
24750
|
+
}
|
24751
|
+
catch (e) {
|
24752
|
+
if (!(e instanceof TypeError))
|
24753
|
+
throw e;
|
24754
|
+
}
|
24755
|
+
try {
|
24756
|
+
return await Group.fromJsonLd(document, { documentLoader, contextLoader });
|
24757
|
+
}
|
24758
|
+
catch (e) {
|
24759
|
+
if (!(e instanceof TypeError))
|
24760
|
+
throw e;
|
24761
|
+
}
|
24762
|
+
try {
|
24763
|
+
return await _f.fromJsonLd(document, { documentLoader, contextLoader });
|
24764
|
+
}
|
24765
|
+
catch (e) {
|
24766
|
+
if (!(e instanceof TypeError))
|
24767
|
+
throw e;
|
24768
|
+
}
|
24769
|
+
try {
|
24770
|
+
return await Person.fromJsonLd(document, { documentLoader, contextLoader });
|
24771
|
+
}
|
24772
|
+
catch (e) {
|
24773
|
+
if (!(e instanceof TypeError))
|
24774
|
+
throw e;
|
24775
|
+
}
|
24776
|
+
try {
|
24777
|
+
return await Service.fromJsonLd(document, { documentLoader, contextLoader });
|
24778
|
+
}
|
24779
|
+
catch (e) {
|
24780
|
+
if (!(e instanceof TypeError))
|
24781
|
+
throw e;
|
24782
|
+
}
|
24783
|
+
throw new TypeError("Expected an object of any type of: " +
|
24784
|
+
[
|
24785
|
+
"https://www.w3.org/ns/activitystreams#Application",
|
24786
|
+
"https://www.w3.org/ns/activitystreams#Group",
|
24787
|
+
"https://www.w3.org/ns/activitystreams#Organization",
|
24788
|
+
"https://www.w3.org/ns/activitystreams#Person",
|
24789
|
+
"https://www.w3.org/ns/activitystreams#Service",
|
24790
|
+
].join(", "));
|
24791
|
+
}
|
24792
|
+
/**
|
24793
|
+
* Similar to
|
24794
|
+
* {@link Organization.getAlias},
|
24795
|
+
* but returns its `@id` URL instead of the object itself.
|
24796
|
+
*/
|
24797
|
+
get aliasId() {
|
24798
|
+
if (this.#_3NV7TGNhuABbryNjNi4wib4DgNpY.length < 1)
|
24799
|
+
return null;
|
24800
|
+
const v = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY[0];
|
24801
|
+
if (v instanceof URL)
|
24802
|
+
return v;
|
24803
|
+
return v.id;
|
24804
|
+
}
|
24805
|
+
/** The `aliases` (`alsoKnownAs`) property is used to specify alternative names
|
24806
|
+
* or aliases for an entity. It can be used to provide additional identifiers
|
24807
|
+
* or labels for an entity, which can be useful in scenarios where an entity
|
24808
|
+
* may have multiple names or aliases.
|
24809
|
+
*/
|
24810
|
+
async getAlias(options = {}) {
|
24811
|
+
if (this.#_3NV7TGNhuABbryNjNi4wib4DgNpY.length < 1)
|
24812
|
+
return null;
|
24813
|
+
const v = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY[0];
|
24814
|
+
if (v instanceof URL) {
|
24815
|
+
const fetched = await this.#fetchAlias(v, options);
|
24816
|
+
if (fetched == null)
|
24817
|
+
return null;
|
24818
|
+
this.#_3NV7TGNhuABbryNjNi4wib4DgNpY[0] = fetched;
|
24819
|
+
return fetched;
|
24820
|
+
}
|
24821
|
+
return v;
|
24822
|
+
}
|
24823
|
+
/**
|
24824
|
+
* Similar to
|
24825
|
+
* {@link Organization.getAliases},
|
24826
|
+
* but returns their `@id`s instead of the objects themselves.
|
24827
|
+
*/
|
24828
|
+
get aliasIds() {
|
24829
|
+
return this.#_3NV7TGNhuABbryNjNi4wib4DgNpY.map((v) => v instanceof URL ? v : v.id).filter((id) => id !== null);
|
24830
|
+
}
|
24831
|
+
/** The `aliases` (`alsoKnownAs`) property is used to specify alternative names
|
24832
|
+
* or aliases for an entity. It can be used to provide additional identifiers
|
24833
|
+
* or labels for an entity, which can be useful in scenarios where an entity
|
24834
|
+
* may have multiple names or aliases.
|
24835
|
+
*/
|
24836
|
+
async *getAliases(options = {}) {
|
24837
|
+
const vs = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY;
|
24838
|
+
for (let i = 0; i < vs.length; i++) {
|
24839
|
+
const v = vs[i];
|
24840
|
+
if (v instanceof URL) {
|
24841
|
+
const fetched = await this.#fetchAlias(v, options);
|
24842
|
+
if (fetched == null)
|
24843
|
+
continue;
|
24844
|
+
vs[i] = fetched;
|
24845
|
+
yield fetched;
|
24846
|
+
continue;
|
24847
|
+
}
|
24848
|
+
yield v;
|
24849
|
+
}
|
24850
|
+
}
|
24065
24851
|
/**
|
24066
24852
|
* Converts this object to a JSON-LD structure.
|
24067
24853
|
* @param options The options to use.
|
@@ -24336,6 +25122,47 @@ export class Organization extends Object {
|
|
24336
25122
|
else if (compactItems.length === 1) {
|
24337
25123
|
result["indexable"] = compactItems[0];
|
24338
25124
|
}
|
25125
|
+
compactItems = [];
|
25126
|
+
for (const v of this.#_3NV7TGNhuABbryNjNi4wib4DgNpY) {
|
25127
|
+
const item = v instanceof URL
|
25128
|
+
? v.href
|
25129
|
+
: v instanceof Application
|
25130
|
+
? await v.toJsonLd({
|
25131
|
+
...options,
|
25132
|
+
format: undefined,
|
25133
|
+
context: undefined,
|
25134
|
+
})
|
25135
|
+
: v instanceof Group
|
25136
|
+
? await v.toJsonLd({
|
25137
|
+
...options,
|
25138
|
+
format: undefined,
|
25139
|
+
context: undefined,
|
25140
|
+
})
|
25141
|
+
: v instanceof _f
|
25142
|
+
? await v.toJsonLd({
|
25143
|
+
...options,
|
25144
|
+
format: undefined,
|
25145
|
+
context: undefined,
|
25146
|
+
})
|
25147
|
+
: v instanceof Person
|
25148
|
+
? await v.toJsonLd({
|
25149
|
+
...options,
|
25150
|
+
format: undefined,
|
25151
|
+
context: undefined,
|
25152
|
+
})
|
25153
|
+
: await v.toJsonLd({
|
25154
|
+
...options,
|
25155
|
+
format: undefined,
|
25156
|
+
context: undefined,
|
25157
|
+
});
|
25158
|
+
compactItems.push(item);
|
25159
|
+
}
|
25160
|
+
if (compactItems.length > 1) {
|
25161
|
+
result["alsoKnownAs"] = compactItems;
|
25162
|
+
}
|
25163
|
+
else if (compactItems.length === 1) {
|
25164
|
+
result["alsoKnownAs"] = compactItems[0];
|
25165
|
+
}
|
24339
25166
|
result["type"] = "Organization";
|
24340
25167
|
if (this.id != null)
|
24341
25168
|
result["id"] = this.id.href;
|
@@ -24528,6 +25355,24 @@ export class Organization extends Object {
|
|
24528
25355
|
if (array.length > 0) {
|
24529
25356
|
values["http://joinmastodon.org/ns#indexable"] = array;
|
24530
25357
|
}
|
25358
|
+
array = [];
|
25359
|
+
for (const v of this.#_3NV7TGNhuABbryNjNi4wib4DgNpY) {
|
25360
|
+
const element = v instanceof URL
|
25361
|
+
? { "@id": v.href }
|
25362
|
+
: v instanceof Application
|
25363
|
+
? await v.toJsonLd(options)
|
25364
|
+
: v instanceof Group
|
25365
|
+
? await v.toJsonLd(options)
|
25366
|
+
: v instanceof _f
|
25367
|
+
? await v.toJsonLd(options)
|
25368
|
+
: v instanceof Person
|
25369
|
+
? await v.toJsonLd(options)
|
25370
|
+
: await v.toJsonLd(options);
|
25371
|
+
array.push(element);
|
25372
|
+
}
|
25373
|
+
if (array.length > 0) {
|
25374
|
+
values["https://www.w3.org/ns/activitystreams#alsoKnownAs"] = array;
|
25375
|
+
}
|
24531
25376
|
values["@type"] = ["https://www.w3.org/ns/activitystreams#Organization"];
|
24532
25377
|
if (this.id != null)
|
24533
25378
|
values["@id"] = this.id.href;
|
@@ -24614,7 +25459,7 @@ export class Organization extends Object {
|
|
24614
25459
|
// @ts-ignore: an internal option
|
24615
25460
|
_fromSubclass: true,
|
24616
25461
|
});
|
24617
|
-
if (!(instance instanceof
|
25462
|
+
if (!(instance instanceof _f)) {
|
24618
25463
|
throw new TypeError("Unexpected type: " + instance.constructor.name);
|
24619
25464
|
}
|
24620
25465
|
const _3isuDgRAKSntq9XdbjiNxjwyPZAf = [];
|
@@ -24898,6 +25743,47 @@ export class Organization extends Object {
|
|
24898
25743
|
_2diCorzqPGQQqftp6e4SrCEwEnyk.push(v["@value"]);
|
24899
25744
|
}
|
24900
25745
|
instance.#_2diCorzqPGQQqftp6e4SrCEwEnyk = _2diCorzqPGQQqftp6e4SrCEwEnyk;
|
25746
|
+
const _3NV7TGNhuABbryNjNi4wib4DgNpY = [];
|
25747
|
+
const _3NV7TGNhuABbryNjNi4wib4DgNpY__array = values["https://www.w3.org/ns/activitystreams#alsoKnownAs"];
|
25748
|
+
for (const v of _3NV7TGNhuABbryNjNi4wib4DgNpY__array == null
|
25749
|
+
? []
|
25750
|
+
: _3NV7TGNhuABbryNjNi4wib4DgNpY__array.length === 1 &&
|
25751
|
+
"@list" in _3NV7TGNhuABbryNjNi4wib4DgNpY__array[0]
|
25752
|
+
? _3NV7TGNhuABbryNjNi4wib4DgNpY__array[0]["@list"]
|
25753
|
+
: _3NV7TGNhuABbryNjNi4wib4DgNpY__array) {
|
25754
|
+
if (v == null)
|
25755
|
+
continue;
|
25756
|
+
if (typeof v === "object" && "@id" in v && !("@type" in v) &&
|
25757
|
+
globalThis.Object.keys(v).length === 1) {
|
25758
|
+
_3NV7TGNhuABbryNjNi4wib4DgNpY.push(new URL(v["@id"]));
|
25759
|
+
continue;
|
25760
|
+
}
|
25761
|
+
const decoded = typeof v === "object" && "@type" in v &&
|
25762
|
+
Array.isArray(v["@type"]) &&
|
25763
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Application")
|
25764
|
+
? await Application.fromJsonLd(v, options)
|
25765
|
+
: typeof v === "object" && "@type" in v &&
|
25766
|
+
Array.isArray(v["@type"]) &&
|
25767
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Group")
|
25768
|
+
? await Group.fromJsonLd(v, options)
|
25769
|
+
: typeof v === "object" && "@type" in v &&
|
25770
|
+
Array.isArray(v["@type"]) &&
|
25771
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Organization")
|
25772
|
+
? await _f.fromJsonLd(v, options)
|
25773
|
+
: typeof v === "object" && "@type" in v &&
|
25774
|
+
Array.isArray(v["@type"]) &&
|
25775
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Person")
|
25776
|
+
? await Person.fromJsonLd(v, options)
|
25777
|
+
: typeof v === "object" && "@type" in v &&
|
25778
|
+
Array.isArray(v["@type"]) &&
|
25779
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Service")
|
25780
|
+
? await Service.fromJsonLd(v, options)
|
25781
|
+
: undefined;
|
25782
|
+
if (typeof decoded === "undefined")
|
25783
|
+
continue;
|
25784
|
+
_3NV7TGNhuABbryNjNi4wib4DgNpY.push(decoded);
|
25785
|
+
}
|
25786
|
+
instance.#_3NV7TGNhuABbryNjNi4wib4DgNpY = _3NV7TGNhuABbryNjNi4wib4DgNpY;
|
24901
25787
|
if (!("_fromSubclass" in options) || !options._fromSubclass) {
|
24902
25788
|
try {
|
24903
25789
|
instance.#cachedJsonLd = structuredClone(json);
|
@@ -25114,6 +26000,22 @@ export class Organization extends Object {
|
|
25114
26000
|
if (_2diCorzqPGQQqftp6e4SrCEwEnyk.length == 1) {
|
25115
26001
|
proxy.indexable = _2diCorzqPGQQqftp6e4SrCEwEnyk[0];
|
25116
26002
|
}
|
26003
|
+
const _3NV7TGNhuABbryNjNi4wib4DgNpY = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY
|
26004
|
+
// deno-lint-ignore no-explicit-any
|
26005
|
+
.map((v) => v instanceof URL
|
26006
|
+
? {
|
26007
|
+
[Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
|
26008
|
+
[Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
|
26009
|
+
}
|
26010
|
+
: v);
|
26011
|
+
if (_3NV7TGNhuABbryNjNi4wib4DgNpY.length == 1) {
|
26012
|
+
proxy.alias = _3NV7TGNhuABbryNjNi4wib4DgNpY[0];
|
26013
|
+
}
|
26014
|
+
if (_3NV7TGNhuABbryNjNi4wib4DgNpY.length > 1 ||
|
26015
|
+
!("alias" in proxy) &&
|
26016
|
+
_3NV7TGNhuABbryNjNi4wib4DgNpY.length > 0) {
|
26017
|
+
proxy.aliases = _3NV7TGNhuABbryNjNi4wib4DgNpY;
|
26018
|
+
}
|
25117
26019
|
return proxy;
|
25118
26020
|
}
|
25119
26021
|
[Symbol.for("Deno.customInspect")](inspect, options) {
|
@@ -25125,6 +26027,7 @@ export class Organization extends Object {
|
|
25125
26027
|
return "Organization " + inspect(proxy, options);
|
25126
26028
|
}
|
25127
26029
|
}
|
26030
|
+
_f = Organization;
|
25128
26031
|
/** Represents a Web Page.
|
25129
26032
|
*/
|
25130
26033
|
export class Page extends Document {
|
@@ -25331,6 +26234,7 @@ export class Person extends Object {
|
|
25331
26234
|
#_2kGKkJtoFWg8c18PaVSqj9NKP4t7 = [];
|
25332
26235
|
#_79S8K4f5J9MWUgCxziRyUe6PTHZ = [];
|
25333
26236
|
#_2diCorzqPGQQqftp6e4SrCEwEnyk = [];
|
26237
|
+
#_3NV7TGNhuABbryNjNi4wib4DgNpY = [];
|
25334
26238
|
/**
|
25335
26239
|
* Constructs a new instance of Person with the given values.
|
25336
26240
|
* @param values The values to initialize the instance with.
|
@@ -25565,6 +26469,37 @@ export class Person extends Object {
|
|
25565
26469
|
"boolean" + ".");
|
25566
26470
|
}
|
25567
26471
|
}
|
26472
|
+
if ("alias" in values && values.alias != null) {
|
26473
|
+
if (values.alias instanceof Application || values.alias instanceof Group ||
|
26474
|
+
values.alias instanceof Organization ||
|
26475
|
+
values.alias instanceof _g || values.alias instanceof Service ||
|
26476
|
+
values.alias instanceof URL) {
|
26477
|
+
// @ts-ignore: type is checked above.
|
26478
|
+
this.#_3NV7TGNhuABbryNjNi4wib4DgNpY = [values.alias];
|
26479
|
+
}
|
26480
|
+
else {
|
26481
|
+
throw new TypeError("The alias must be of type " +
|
26482
|
+
"Application | Group | Organization | Person | Service | URL" + ".");
|
26483
|
+
}
|
26484
|
+
}
|
26485
|
+
if ("aliases" in values && values.aliases != null) {
|
26486
|
+
if ("alias" in values &&
|
26487
|
+
values.alias != null) {
|
26488
|
+
throw new TypeError("Cannot initialize both alias and " +
|
26489
|
+
"aliases at the same time.");
|
26490
|
+
}
|
26491
|
+
if (Array.isArray(values.aliases) &&
|
26492
|
+
values.aliases.every((v) => v instanceof Application || v instanceof Group ||
|
26493
|
+
v instanceof Organization || v instanceof _g ||
|
26494
|
+
v instanceof Service || v instanceof URL)) {
|
26495
|
+
// @ts-ignore: type is checked above.
|
26496
|
+
this.#_3NV7TGNhuABbryNjNi4wib4DgNpY = values.aliases;
|
26497
|
+
}
|
26498
|
+
else {
|
26499
|
+
throw new TypeError("The aliases must be an array of type " +
|
26500
|
+
"Application | Group | Organization | Person | Service | URL" + ".");
|
26501
|
+
}
|
26502
|
+
}
|
25568
26503
|
}
|
25569
26504
|
/**
|
25570
26505
|
* Clones this instance, optionally updating it with the given values.
|
@@ -25820,6 +26755,38 @@ export class Person extends Object {
|
|
25820
26755
|
"boolean" + ".");
|
25821
26756
|
}
|
25822
26757
|
}
|
26758
|
+
clone.#_3NV7TGNhuABbryNjNi4wib4DgNpY = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY;
|
26759
|
+
if ("alias" in values && values.alias != null) {
|
26760
|
+
if (values.alias instanceof Application || values.alias instanceof Group ||
|
26761
|
+
values.alias instanceof Organization ||
|
26762
|
+
values.alias instanceof _g || values.alias instanceof Service ||
|
26763
|
+
values.alias instanceof URL) {
|
26764
|
+
// @ts-ignore: type is checked above.
|
26765
|
+
clone.#_3NV7TGNhuABbryNjNi4wib4DgNpY = [values.alias];
|
26766
|
+
}
|
26767
|
+
else {
|
26768
|
+
throw new TypeError("The alias must be of type " +
|
26769
|
+
"Application | Group | Organization | Person | Service | URL" + ".");
|
26770
|
+
}
|
26771
|
+
}
|
26772
|
+
if ("aliases" in values && values.aliases != null) {
|
26773
|
+
if ("alias" in values &&
|
26774
|
+
values.alias != null) {
|
26775
|
+
throw new TypeError("Cannot update both alias and " +
|
26776
|
+
"aliases at the same time.");
|
26777
|
+
}
|
26778
|
+
if (Array.isArray(values.aliases) &&
|
26779
|
+
values.aliases.every((v) => v instanceof Application || v instanceof Group ||
|
26780
|
+
v instanceof Organization || v instanceof _g ||
|
26781
|
+
v instanceof Service || v instanceof URL)) {
|
26782
|
+
// @ts-ignore: type is checked above.
|
26783
|
+
clone.#_3NV7TGNhuABbryNjNi4wib4DgNpY = values.aliases;
|
26784
|
+
}
|
26785
|
+
else {
|
26786
|
+
throw new TypeError("The aliases must be an array of type " +
|
26787
|
+
"Application | Group | Organization | Person | Service | URL" + ".");
|
26788
|
+
}
|
26789
|
+
}
|
25823
26790
|
return clone;
|
25824
26791
|
}
|
25825
26792
|
/** A short username which may be used to refer to the actor,
|
@@ -26536,6 +27503,126 @@ export class Person extends Object {
|
|
26536
27503
|
return null;
|
26537
27504
|
return this.#_2diCorzqPGQQqftp6e4SrCEwEnyk[0];
|
26538
27505
|
}
|
27506
|
+
async #fetchAlias(url, options = {}) {
|
27507
|
+
const documentLoader = options.documentLoader ?? this._documentLoader ??
|
27508
|
+
fetchDocumentLoader;
|
27509
|
+
const contextLoader = options.contextLoader ?? this._contextLoader ??
|
27510
|
+
fetchDocumentLoader;
|
27511
|
+
let fetchResult;
|
27512
|
+
try {
|
27513
|
+
fetchResult = await documentLoader(url.href);
|
27514
|
+
}
|
27515
|
+
catch (error) {
|
27516
|
+
if (options.suppressError) {
|
27517
|
+
getLogger(["fedify", "vocab"]).error("Failed to fetch {url}: {error}", { error, url: url.href });
|
27518
|
+
return null;
|
27519
|
+
}
|
27520
|
+
throw error;
|
27521
|
+
}
|
27522
|
+
const { document } = fetchResult;
|
27523
|
+
try {
|
27524
|
+
return await Application.fromJsonLd(document, { documentLoader, contextLoader });
|
27525
|
+
}
|
27526
|
+
catch (e) {
|
27527
|
+
if (!(e instanceof TypeError))
|
27528
|
+
throw e;
|
27529
|
+
}
|
27530
|
+
try {
|
27531
|
+
return await Group.fromJsonLd(document, { documentLoader, contextLoader });
|
27532
|
+
}
|
27533
|
+
catch (e) {
|
27534
|
+
if (!(e instanceof TypeError))
|
27535
|
+
throw e;
|
27536
|
+
}
|
27537
|
+
try {
|
27538
|
+
return await Organization.fromJsonLd(document, { documentLoader, contextLoader });
|
27539
|
+
}
|
27540
|
+
catch (e) {
|
27541
|
+
if (!(e instanceof TypeError))
|
27542
|
+
throw e;
|
27543
|
+
}
|
27544
|
+
try {
|
27545
|
+
return await _g.fromJsonLd(document, { documentLoader, contextLoader });
|
27546
|
+
}
|
27547
|
+
catch (e) {
|
27548
|
+
if (!(e instanceof TypeError))
|
27549
|
+
throw e;
|
27550
|
+
}
|
27551
|
+
try {
|
27552
|
+
return await Service.fromJsonLd(document, { documentLoader, contextLoader });
|
27553
|
+
}
|
27554
|
+
catch (e) {
|
27555
|
+
if (!(e instanceof TypeError))
|
27556
|
+
throw e;
|
27557
|
+
}
|
27558
|
+
throw new TypeError("Expected an object of any type of: " +
|
27559
|
+
[
|
27560
|
+
"https://www.w3.org/ns/activitystreams#Application",
|
27561
|
+
"https://www.w3.org/ns/activitystreams#Group",
|
27562
|
+
"https://www.w3.org/ns/activitystreams#Organization",
|
27563
|
+
"https://www.w3.org/ns/activitystreams#Person",
|
27564
|
+
"https://www.w3.org/ns/activitystreams#Service",
|
27565
|
+
].join(", "));
|
27566
|
+
}
|
27567
|
+
/**
|
27568
|
+
* Similar to
|
27569
|
+
* {@link Person.getAlias},
|
27570
|
+
* but returns its `@id` URL instead of the object itself.
|
27571
|
+
*/
|
27572
|
+
get aliasId() {
|
27573
|
+
if (this.#_3NV7TGNhuABbryNjNi4wib4DgNpY.length < 1)
|
27574
|
+
return null;
|
27575
|
+
const v = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY[0];
|
27576
|
+
if (v instanceof URL)
|
27577
|
+
return v;
|
27578
|
+
return v.id;
|
27579
|
+
}
|
27580
|
+
/** The `aliases` (`alsoKnownAs`) property is used to specify alternative names
|
27581
|
+
* or aliases for an entity. It can be used to provide additional identifiers
|
27582
|
+
* or labels for an entity, which can be useful in scenarios where an entity
|
27583
|
+
* may have multiple names or aliases.
|
27584
|
+
*/
|
27585
|
+
async getAlias(options = {}) {
|
27586
|
+
if (this.#_3NV7TGNhuABbryNjNi4wib4DgNpY.length < 1)
|
27587
|
+
return null;
|
27588
|
+
const v = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY[0];
|
27589
|
+
if (v instanceof URL) {
|
27590
|
+
const fetched = await this.#fetchAlias(v, options);
|
27591
|
+
if (fetched == null)
|
27592
|
+
return null;
|
27593
|
+
this.#_3NV7TGNhuABbryNjNi4wib4DgNpY[0] = fetched;
|
27594
|
+
return fetched;
|
27595
|
+
}
|
27596
|
+
return v;
|
27597
|
+
}
|
27598
|
+
/**
|
27599
|
+
* Similar to
|
27600
|
+
* {@link Person.getAliases},
|
27601
|
+
* but returns their `@id`s instead of the objects themselves.
|
27602
|
+
*/
|
27603
|
+
get aliasIds() {
|
27604
|
+
return this.#_3NV7TGNhuABbryNjNi4wib4DgNpY.map((v) => v instanceof URL ? v : v.id).filter((id) => id !== null);
|
27605
|
+
}
|
27606
|
+
/** The `aliases` (`alsoKnownAs`) property is used to specify alternative names
|
27607
|
+
* or aliases for an entity. It can be used to provide additional identifiers
|
27608
|
+
* or labels for an entity, which can be useful in scenarios where an entity
|
27609
|
+
* may have multiple names or aliases.
|
27610
|
+
*/
|
27611
|
+
async *getAliases(options = {}) {
|
27612
|
+
const vs = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY;
|
27613
|
+
for (let i = 0; i < vs.length; i++) {
|
27614
|
+
const v = vs[i];
|
27615
|
+
if (v instanceof URL) {
|
27616
|
+
const fetched = await this.#fetchAlias(v, options);
|
27617
|
+
if (fetched == null)
|
27618
|
+
continue;
|
27619
|
+
vs[i] = fetched;
|
27620
|
+
yield fetched;
|
27621
|
+
continue;
|
27622
|
+
}
|
27623
|
+
yield v;
|
27624
|
+
}
|
27625
|
+
}
|
26539
27626
|
/**
|
26540
27627
|
* Converts this object to a JSON-LD structure.
|
26541
27628
|
* @param options The options to use.
|
@@ -26810,6 +27897,47 @@ export class Person extends Object {
|
|
26810
27897
|
else if (compactItems.length === 1) {
|
26811
27898
|
result["indexable"] = compactItems[0];
|
26812
27899
|
}
|
27900
|
+
compactItems = [];
|
27901
|
+
for (const v of this.#_3NV7TGNhuABbryNjNi4wib4DgNpY) {
|
27902
|
+
const item = v instanceof URL
|
27903
|
+
? v.href
|
27904
|
+
: v instanceof Application
|
27905
|
+
? await v.toJsonLd({
|
27906
|
+
...options,
|
27907
|
+
format: undefined,
|
27908
|
+
context: undefined,
|
27909
|
+
})
|
27910
|
+
: v instanceof Group
|
27911
|
+
? await v.toJsonLd({
|
27912
|
+
...options,
|
27913
|
+
format: undefined,
|
27914
|
+
context: undefined,
|
27915
|
+
})
|
27916
|
+
: v instanceof Organization
|
27917
|
+
? await v.toJsonLd({
|
27918
|
+
...options,
|
27919
|
+
format: undefined,
|
27920
|
+
context: undefined,
|
27921
|
+
})
|
27922
|
+
: v instanceof _g
|
27923
|
+
? await v.toJsonLd({
|
27924
|
+
...options,
|
27925
|
+
format: undefined,
|
27926
|
+
context: undefined,
|
27927
|
+
})
|
27928
|
+
: await v.toJsonLd({
|
27929
|
+
...options,
|
27930
|
+
format: undefined,
|
27931
|
+
context: undefined,
|
27932
|
+
});
|
27933
|
+
compactItems.push(item);
|
27934
|
+
}
|
27935
|
+
if (compactItems.length > 1) {
|
27936
|
+
result["alsoKnownAs"] = compactItems;
|
27937
|
+
}
|
27938
|
+
else if (compactItems.length === 1) {
|
27939
|
+
result["alsoKnownAs"] = compactItems[0];
|
27940
|
+
}
|
26813
27941
|
result["type"] = "Person";
|
26814
27942
|
if (this.id != null)
|
26815
27943
|
result["id"] = this.id.href;
|
@@ -27002,6 +28130,24 @@ export class Person extends Object {
|
|
27002
28130
|
if (array.length > 0) {
|
27003
28131
|
values["http://joinmastodon.org/ns#indexable"] = array;
|
27004
28132
|
}
|
28133
|
+
array = [];
|
28134
|
+
for (const v of this.#_3NV7TGNhuABbryNjNi4wib4DgNpY) {
|
28135
|
+
const element = v instanceof URL
|
28136
|
+
? { "@id": v.href }
|
28137
|
+
: v instanceof Application
|
28138
|
+
? await v.toJsonLd(options)
|
28139
|
+
: v instanceof Group
|
28140
|
+
? await v.toJsonLd(options)
|
28141
|
+
: v instanceof Organization
|
28142
|
+
? await v.toJsonLd(options)
|
28143
|
+
: v instanceof _g
|
28144
|
+
? await v.toJsonLd(options)
|
28145
|
+
: await v.toJsonLd(options);
|
28146
|
+
array.push(element);
|
28147
|
+
}
|
28148
|
+
if (array.length > 0) {
|
28149
|
+
values["https://www.w3.org/ns/activitystreams#alsoKnownAs"] = array;
|
28150
|
+
}
|
27005
28151
|
values["@type"] = ["https://www.w3.org/ns/activitystreams#Person"];
|
27006
28152
|
if (this.id != null)
|
27007
28153
|
values["@id"] = this.id.href;
|
@@ -27088,7 +28234,7 @@ export class Person extends Object {
|
|
27088
28234
|
// @ts-ignore: an internal option
|
27089
28235
|
_fromSubclass: true,
|
27090
28236
|
});
|
27091
|
-
if (!(instance instanceof
|
28237
|
+
if (!(instance instanceof _g)) {
|
27092
28238
|
throw new TypeError("Unexpected type: " + instance.constructor.name);
|
27093
28239
|
}
|
27094
28240
|
const _3isuDgRAKSntq9XdbjiNxjwyPZAf = [];
|
@@ -27372,6 +28518,47 @@ export class Person extends Object {
|
|
27372
28518
|
_2diCorzqPGQQqftp6e4SrCEwEnyk.push(v["@value"]);
|
27373
28519
|
}
|
27374
28520
|
instance.#_2diCorzqPGQQqftp6e4SrCEwEnyk = _2diCorzqPGQQqftp6e4SrCEwEnyk;
|
28521
|
+
const _3NV7TGNhuABbryNjNi4wib4DgNpY = [];
|
28522
|
+
const _3NV7TGNhuABbryNjNi4wib4DgNpY__array = values["https://www.w3.org/ns/activitystreams#alsoKnownAs"];
|
28523
|
+
for (const v of _3NV7TGNhuABbryNjNi4wib4DgNpY__array == null
|
28524
|
+
? []
|
28525
|
+
: _3NV7TGNhuABbryNjNi4wib4DgNpY__array.length === 1 &&
|
28526
|
+
"@list" in _3NV7TGNhuABbryNjNi4wib4DgNpY__array[0]
|
28527
|
+
? _3NV7TGNhuABbryNjNi4wib4DgNpY__array[0]["@list"]
|
28528
|
+
: _3NV7TGNhuABbryNjNi4wib4DgNpY__array) {
|
28529
|
+
if (v == null)
|
28530
|
+
continue;
|
28531
|
+
if (typeof v === "object" && "@id" in v && !("@type" in v) &&
|
28532
|
+
globalThis.Object.keys(v).length === 1) {
|
28533
|
+
_3NV7TGNhuABbryNjNi4wib4DgNpY.push(new URL(v["@id"]));
|
28534
|
+
continue;
|
28535
|
+
}
|
28536
|
+
const decoded = typeof v === "object" && "@type" in v &&
|
28537
|
+
Array.isArray(v["@type"]) &&
|
28538
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Application")
|
28539
|
+
? await Application.fromJsonLd(v, options)
|
28540
|
+
: typeof v === "object" && "@type" in v &&
|
28541
|
+
Array.isArray(v["@type"]) &&
|
28542
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Group")
|
28543
|
+
? await Group.fromJsonLd(v, options)
|
28544
|
+
: typeof v === "object" && "@type" in v &&
|
28545
|
+
Array.isArray(v["@type"]) &&
|
28546
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Organization")
|
28547
|
+
? await Organization.fromJsonLd(v, options)
|
28548
|
+
: typeof v === "object" && "@type" in v &&
|
28549
|
+
Array.isArray(v["@type"]) &&
|
28550
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Person")
|
28551
|
+
? await _g.fromJsonLd(v, options)
|
28552
|
+
: typeof v === "object" && "@type" in v &&
|
28553
|
+
Array.isArray(v["@type"]) &&
|
28554
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Service")
|
28555
|
+
? await Service.fromJsonLd(v, options)
|
28556
|
+
: undefined;
|
28557
|
+
if (typeof decoded === "undefined")
|
28558
|
+
continue;
|
28559
|
+
_3NV7TGNhuABbryNjNi4wib4DgNpY.push(decoded);
|
28560
|
+
}
|
28561
|
+
instance.#_3NV7TGNhuABbryNjNi4wib4DgNpY = _3NV7TGNhuABbryNjNi4wib4DgNpY;
|
27375
28562
|
if (!("_fromSubclass" in options) || !options._fromSubclass) {
|
27376
28563
|
try {
|
27377
28564
|
instance.#cachedJsonLd = structuredClone(json);
|
@@ -27588,6 +28775,22 @@ export class Person extends Object {
|
|
27588
28775
|
if (_2diCorzqPGQQqftp6e4SrCEwEnyk.length == 1) {
|
27589
28776
|
proxy.indexable = _2diCorzqPGQQqftp6e4SrCEwEnyk[0];
|
27590
28777
|
}
|
28778
|
+
const _3NV7TGNhuABbryNjNi4wib4DgNpY = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY
|
28779
|
+
// deno-lint-ignore no-explicit-any
|
28780
|
+
.map((v) => v instanceof URL
|
28781
|
+
? {
|
28782
|
+
[Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
|
28783
|
+
[Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
|
28784
|
+
}
|
28785
|
+
: v);
|
28786
|
+
if (_3NV7TGNhuABbryNjNi4wib4DgNpY.length == 1) {
|
28787
|
+
proxy.alias = _3NV7TGNhuABbryNjNi4wib4DgNpY[0];
|
28788
|
+
}
|
28789
|
+
if (_3NV7TGNhuABbryNjNi4wib4DgNpY.length > 1 ||
|
28790
|
+
!("alias" in proxy) &&
|
28791
|
+
_3NV7TGNhuABbryNjNi4wib4DgNpY.length > 0) {
|
28792
|
+
proxy.aliases = _3NV7TGNhuABbryNjNi4wib4DgNpY;
|
28793
|
+
}
|
27591
28794
|
return proxy;
|
27592
28795
|
}
|
27593
28796
|
[Symbol.for("Deno.customInspect")](inspect, options) {
|
@@ -27599,6 +28802,7 @@ export class Person extends Object {
|
|
27599
28802
|
return "Person " + inspect(proxy, options);
|
27600
28803
|
}
|
27601
28804
|
}
|
28805
|
+
_g = Person;
|
27602
28806
|
/** Represents a logical or physical location. See [5.3 Representing
|
27603
28807
|
* Places](https://www.w3.org/TR/activitystreams-vocabulary/#places)
|
27604
28808
|
* for additional information.
|
@@ -30489,6 +31693,7 @@ export class Service extends Object {
|
|
30489
31693
|
#_2kGKkJtoFWg8c18PaVSqj9NKP4t7 = [];
|
30490
31694
|
#_79S8K4f5J9MWUgCxziRyUe6PTHZ = [];
|
30491
31695
|
#_2diCorzqPGQQqftp6e4SrCEwEnyk = [];
|
31696
|
+
#_3NV7TGNhuABbryNjNi4wib4DgNpY = [];
|
30492
31697
|
/**
|
30493
31698
|
* Constructs a new instance of Service with the given values.
|
30494
31699
|
* @param values The values to initialize the instance with.
|
@@ -30723,6 +31928,37 @@ export class Service extends Object {
|
|
30723
31928
|
"boolean" + ".");
|
30724
31929
|
}
|
30725
31930
|
}
|
31931
|
+
if ("alias" in values && values.alias != null) {
|
31932
|
+
if (values.alias instanceof Application || values.alias instanceof Group ||
|
31933
|
+
values.alias instanceof Organization ||
|
31934
|
+
values.alias instanceof Person || values.alias instanceof _h ||
|
31935
|
+
values.alias instanceof URL) {
|
31936
|
+
// @ts-ignore: type is checked above.
|
31937
|
+
this.#_3NV7TGNhuABbryNjNi4wib4DgNpY = [values.alias];
|
31938
|
+
}
|
31939
|
+
else {
|
31940
|
+
throw new TypeError("The alias must be of type " +
|
31941
|
+
"Application | Group | Organization | Person | Service | URL" + ".");
|
31942
|
+
}
|
31943
|
+
}
|
31944
|
+
if ("aliases" in values && values.aliases != null) {
|
31945
|
+
if ("alias" in values &&
|
31946
|
+
values.alias != null) {
|
31947
|
+
throw new TypeError("Cannot initialize both alias and " +
|
31948
|
+
"aliases at the same time.");
|
31949
|
+
}
|
31950
|
+
if (Array.isArray(values.aliases) &&
|
31951
|
+
values.aliases.every((v) => v instanceof Application || v instanceof Group ||
|
31952
|
+
v instanceof Organization || v instanceof Person ||
|
31953
|
+
v instanceof _h || v instanceof URL)) {
|
31954
|
+
// @ts-ignore: type is checked above.
|
31955
|
+
this.#_3NV7TGNhuABbryNjNi4wib4DgNpY = values.aliases;
|
31956
|
+
}
|
31957
|
+
else {
|
31958
|
+
throw new TypeError("The aliases must be an array of type " +
|
31959
|
+
"Application | Group | Organization | Person | Service | URL" + ".");
|
31960
|
+
}
|
31961
|
+
}
|
30726
31962
|
}
|
30727
31963
|
/**
|
30728
31964
|
* Clones this instance, optionally updating it with the given values.
|
@@ -30978,6 +32214,38 @@ export class Service extends Object {
|
|
30978
32214
|
"boolean" + ".");
|
30979
32215
|
}
|
30980
32216
|
}
|
32217
|
+
clone.#_3NV7TGNhuABbryNjNi4wib4DgNpY = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY;
|
32218
|
+
if ("alias" in values && values.alias != null) {
|
32219
|
+
if (values.alias instanceof Application || values.alias instanceof Group ||
|
32220
|
+
values.alias instanceof Organization ||
|
32221
|
+
values.alias instanceof Person || values.alias instanceof _h ||
|
32222
|
+
values.alias instanceof URL) {
|
32223
|
+
// @ts-ignore: type is checked above.
|
32224
|
+
clone.#_3NV7TGNhuABbryNjNi4wib4DgNpY = [values.alias];
|
32225
|
+
}
|
32226
|
+
else {
|
32227
|
+
throw new TypeError("The alias must be of type " +
|
32228
|
+
"Application | Group | Organization | Person | Service | URL" + ".");
|
32229
|
+
}
|
32230
|
+
}
|
32231
|
+
if ("aliases" in values && values.aliases != null) {
|
32232
|
+
if ("alias" in values &&
|
32233
|
+
values.alias != null) {
|
32234
|
+
throw new TypeError("Cannot update both alias and " +
|
32235
|
+
"aliases at the same time.");
|
32236
|
+
}
|
32237
|
+
if (Array.isArray(values.aliases) &&
|
32238
|
+
values.aliases.every((v) => v instanceof Application || v instanceof Group ||
|
32239
|
+
v instanceof Organization || v instanceof Person ||
|
32240
|
+
v instanceof _h || v instanceof URL)) {
|
32241
|
+
// @ts-ignore: type is checked above.
|
32242
|
+
clone.#_3NV7TGNhuABbryNjNi4wib4DgNpY = values.aliases;
|
32243
|
+
}
|
32244
|
+
else {
|
32245
|
+
throw new TypeError("The aliases must be an array of type " +
|
32246
|
+
"Application | Group | Organization | Person | Service | URL" + ".");
|
32247
|
+
}
|
32248
|
+
}
|
30981
32249
|
return clone;
|
30982
32250
|
}
|
30983
32251
|
/** A short username which may be used to refer to the actor,
|
@@ -31694,6 +32962,126 @@ export class Service extends Object {
|
|
31694
32962
|
return null;
|
31695
32963
|
return this.#_2diCorzqPGQQqftp6e4SrCEwEnyk[0];
|
31696
32964
|
}
|
32965
|
+
async #fetchAlias(url, options = {}) {
|
32966
|
+
const documentLoader = options.documentLoader ?? this._documentLoader ??
|
32967
|
+
fetchDocumentLoader;
|
32968
|
+
const contextLoader = options.contextLoader ?? this._contextLoader ??
|
32969
|
+
fetchDocumentLoader;
|
32970
|
+
let fetchResult;
|
32971
|
+
try {
|
32972
|
+
fetchResult = await documentLoader(url.href);
|
32973
|
+
}
|
32974
|
+
catch (error) {
|
32975
|
+
if (options.suppressError) {
|
32976
|
+
getLogger(["fedify", "vocab"]).error("Failed to fetch {url}: {error}", { error, url: url.href });
|
32977
|
+
return null;
|
32978
|
+
}
|
32979
|
+
throw error;
|
32980
|
+
}
|
32981
|
+
const { document } = fetchResult;
|
32982
|
+
try {
|
32983
|
+
return await Application.fromJsonLd(document, { documentLoader, contextLoader });
|
32984
|
+
}
|
32985
|
+
catch (e) {
|
32986
|
+
if (!(e instanceof TypeError))
|
32987
|
+
throw e;
|
32988
|
+
}
|
32989
|
+
try {
|
32990
|
+
return await Group.fromJsonLd(document, { documentLoader, contextLoader });
|
32991
|
+
}
|
32992
|
+
catch (e) {
|
32993
|
+
if (!(e instanceof TypeError))
|
32994
|
+
throw e;
|
32995
|
+
}
|
32996
|
+
try {
|
32997
|
+
return await Organization.fromJsonLd(document, { documentLoader, contextLoader });
|
32998
|
+
}
|
32999
|
+
catch (e) {
|
33000
|
+
if (!(e instanceof TypeError))
|
33001
|
+
throw e;
|
33002
|
+
}
|
33003
|
+
try {
|
33004
|
+
return await Person.fromJsonLd(document, { documentLoader, contextLoader });
|
33005
|
+
}
|
33006
|
+
catch (e) {
|
33007
|
+
if (!(e instanceof TypeError))
|
33008
|
+
throw e;
|
33009
|
+
}
|
33010
|
+
try {
|
33011
|
+
return await _h.fromJsonLd(document, { documentLoader, contextLoader });
|
33012
|
+
}
|
33013
|
+
catch (e) {
|
33014
|
+
if (!(e instanceof TypeError))
|
33015
|
+
throw e;
|
33016
|
+
}
|
33017
|
+
throw new TypeError("Expected an object of any type of: " +
|
33018
|
+
[
|
33019
|
+
"https://www.w3.org/ns/activitystreams#Application",
|
33020
|
+
"https://www.w3.org/ns/activitystreams#Group",
|
33021
|
+
"https://www.w3.org/ns/activitystreams#Organization",
|
33022
|
+
"https://www.w3.org/ns/activitystreams#Person",
|
33023
|
+
"https://www.w3.org/ns/activitystreams#Service",
|
33024
|
+
].join(", "));
|
33025
|
+
}
|
33026
|
+
/**
|
33027
|
+
* Similar to
|
33028
|
+
* {@link Service.getAlias},
|
33029
|
+
* but returns its `@id` URL instead of the object itself.
|
33030
|
+
*/
|
33031
|
+
get aliasId() {
|
33032
|
+
if (this.#_3NV7TGNhuABbryNjNi4wib4DgNpY.length < 1)
|
33033
|
+
return null;
|
33034
|
+
const v = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY[0];
|
33035
|
+
if (v instanceof URL)
|
33036
|
+
return v;
|
33037
|
+
return v.id;
|
33038
|
+
}
|
33039
|
+
/** The `aliases` (`alsoKnownAs`) property is used to specify alternative names
|
33040
|
+
* or aliases for an entity. It can be used to provide additional identifiers
|
33041
|
+
* or labels for an entity, which can be useful in scenarios where an entity
|
33042
|
+
* may have multiple names or aliases.
|
33043
|
+
*/
|
33044
|
+
async getAlias(options = {}) {
|
33045
|
+
if (this.#_3NV7TGNhuABbryNjNi4wib4DgNpY.length < 1)
|
33046
|
+
return null;
|
33047
|
+
const v = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY[0];
|
33048
|
+
if (v instanceof URL) {
|
33049
|
+
const fetched = await this.#fetchAlias(v, options);
|
33050
|
+
if (fetched == null)
|
33051
|
+
return null;
|
33052
|
+
this.#_3NV7TGNhuABbryNjNi4wib4DgNpY[0] = fetched;
|
33053
|
+
return fetched;
|
33054
|
+
}
|
33055
|
+
return v;
|
33056
|
+
}
|
33057
|
+
/**
|
33058
|
+
* Similar to
|
33059
|
+
* {@link Service.getAliases},
|
33060
|
+
* but returns their `@id`s instead of the objects themselves.
|
33061
|
+
*/
|
33062
|
+
get aliasIds() {
|
33063
|
+
return this.#_3NV7TGNhuABbryNjNi4wib4DgNpY.map((v) => v instanceof URL ? v : v.id).filter((id) => id !== null);
|
33064
|
+
}
|
33065
|
+
/** The `aliases` (`alsoKnownAs`) property is used to specify alternative names
|
33066
|
+
* or aliases for an entity. It can be used to provide additional identifiers
|
33067
|
+
* or labels for an entity, which can be useful in scenarios where an entity
|
33068
|
+
* may have multiple names or aliases.
|
33069
|
+
*/
|
33070
|
+
async *getAliases(options = {}) {
|
33071
|
+
const vs = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY;
|
33072
|
+
for (let i = 0; i < vs.length; i++) {
|
33073
|
+
const v = vs[i];
|
33074
|
+
if (v instanceof URL) {
|
33075
|
+
const fetched = await this.#fetchAlias(v, options);
|
33076
|
+
if (fetched == null)
|
33077
|
+
continue;
|
33078
|
+
vs[i] = fetched;
|
33079
|
+
yield fetched;
|
33080
|
+
continue;
|
33081
|
+
}
|
33082
|
+
yield v;
|
33083
|
+
}
|
33084
|
+
}
|
31697
33085
|
/**
|
31698
33086
|
* Converts this object to a JSON-LD structure.
|
31699
33087
|
* @param options The options to use.
|
@@ -31968,6 +33356,47 @@ export class Service extends Object {
|
|
31968
33356
|
else if (compactItems.length === 1) {
|
31969
33357
|
result["indexable"] = compactItems[0];
|
31970
33358
|
}
|
33359
|
+
compactItems = [];
|
33360
|
+
for (const v of this.#_3NV7TGNhuABbryNjNi4wib4DgNpY) {
|
33361
|
+
const item = v instanceof URL
|
33362
|
+
? v.href
|
33363
|
+
: v instanceof Application
|
33364
|
+
? await v.toJsonLd({
|
33365
|
+
...options,
|
33366
|
+
format: undefined,
|
33367
|
+
context: undefined,
|
33368
|
+
})
|
33369
|
+
: v instanceof Group
|
33370
|
+
? await v.toJsonLd({
|
33371
|
+
...options,
|
33372
|
+
format: undefined,
|
33373
|
+
context: undefined,
|
33374
|
+
})
|
33375
|
+
: v instanceof Organization
|
33376
|
+
? await v.toJsonLd({
|
33377
|
+
...options,
|
33378
|
+
format: undefined,
|
33379
|
+
context: undefined,
|
33380
|
+
})
|
33381
|
+
: v instanceof Person
|
33382
|
+
? await v.toJsonLd({
|
33383
|
+
...options,
|
33384
|
+
format: undefined,
|
33385
|
+
context: undefined,
|
33386
|
+
})
|
33387
|
+
: await v.toJsonLd({
|
33388
|
+
...options,
|
33389
|
+
format: undefined,
|
33390
|
+
context: undefined,
|
33391
|
+
});
|
33392
|
+
compactItems.push(item);
|
33393
|
+
}
|
33394
|
+
if (compactItems.length > 1) {
|
33395
|
+
result["alsoKnownAs"] = compactItems;
|
33396
|
+
}
|
33397
|
+
else if (compactItems.length === 1) {
|
33398
|
+
result["alsoKnownAs"] = compactItems[0];
|
33399
|
+
}
|
31971
33400
|
result["type"] = "Service";
|
31972
33401
|
if (this.id != null)
|
31973
33402
|
result["id"] = this.id.href;
|
@@ -32160,6 +33589,24 @@ export class Service extends Object {
|
|
32160
33589
|
if (array.length > 0) {
|
32161
33590
|
values["http://joinmastodon.org/ns#indexable"] = array;
|
32162
33591
|
}
|
33592
|
+
array = [];
|
33593
|
+
for (const v of this.#_3NV7TGNhuABbryNjNi4wib4DgNpY) {
|
33594
|
+
const element = v instanceof URL
|
33595
|
+
? { "@id": v.href }
|
33596
|
+
: v instanceof Application
|
33597
|
+
? await v.toJsonLd(options)
|
33598
|
+
: v instanceof Group
|
33599
|
+
? await v.toJsonLd(options)
|
33600
|
+
: v instanceof Organization
|
33601
|
+
? await v.toJsonLd(options)
|
33602
|
+
: v instanceof Person
|
33603
|
+
? await v.toJsonLd(options)
|
33604
|
+
: await v.toJsonLd(options);
|
33605
|
+
array.push(element);
|
33606
|
+
}
|
33607
|
+
if (array.length > 0) {
|
33608
|
+
values["https://www.w3.org/ns/activitystreams#alsoKnownAs"] = array;
|
33609
|
+
}
|
32163
33610
|
values["@type"] = ["https://www.w3.org/ns/activitystreams#Service"];
|
32164
33611
|
if (this.id != null)
|
32165
33612
|
values["@id"] = this.id.href;
|
@@ -32246,7 +33693,7 @@ export class Service extends Object {
|
|
32246
33693
|
// @ts-ignore: an internal option
|
32247
33694
|
_fromSubclass: true,
|
32248
33695
|
});
|
32249
|
-
if (!(instance instanceof
|
33696
|
+
if (!(instance instanceof _h)) {
|
32250
33697
|
throw new TypeError("Unexpected type: " + instance.constructor.name);
|
32251
33698
|
}
|
32252
33699
|
const _3isuDgRAKSntq9XdbjiNxjwyPZAf = [];
|
@@ -32530,6 +33977,47 @@ export class Service extends Object {
|
|
32530
33977
|
_2diCorzqPGQQqftp6e4SrCEwEnyk.push(v["@value"]);
|
32531
33978
|
}
|
32532
33979
|
instance.#_2diCorzqPGQQqftp6e4SrCEwEnyk = _2diCorzqPGQQqftp6e4SrCEwEnyk;
|
33980
|
+
const _3NV7TGNhuABbryNjNi4wib4DgNpY = [];
|
33981
|
+
const _3NV7TGNhuABbryNjNi4wib4DgNpY__array = values["https://www.w3.org/ns/activitystreams#alsoKnownAs"];
|
33982
|
+
for (const v of _3NV7TGNhuABbryNjNi4wib4DgNpY__array == null
|
33983
|
+
? []
|
33984
|
+
: _3NV7TGNhuABbryNjNi4wib4DgNpY__array.length === 1 &&
|
33985
|
+
"@list" in _3NV7TGNhuABbryNjNi4wib4DgNpY__array[0]
|
33986
|
+
? _3NV7TGNhuABbryNjNi4wib4DgNpY__array[0]["@list"]
|
33987
|
+
: _3NV7TGNhuABbryNjNi4wib4DgNpY__array) {
|
33988
|
+
if (v == null)
|
33989
|
+
continue;
|
33990
|
+
if (typeof v === "object" && "@id" in v && !("@type" in v) &&
|
33991
|
+
globalThis.Object.keys(v).length === 1) {
|
33992
|
+
_3NV7TGNhuABbryNjNi4wib4DgNpY.push(new URL(v["@id"]));
|
33993
|
+
continue;
|
33994
|
+
}
|
33995
|
+
const decoded = typeof v === "object" && "@type" in v &&
|
33996
|
+
Array.isArray(v["@type"]) &&
|
33997
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Application")
|
33998
|
+
? await Application.fromJsonLd(v, options)
|
33999
|
+
: typeof v === "object" && "@type" in v &&
|
34000
|
+
Array.isArray(v["@type"]) &&
|
34001
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Group")
|
34002
|
+
? await Group.fromJsonLd(v, options)
|
34003
|
+
: typeof v === "object" && "@type" in v &&
|
34004
|
+
Array.isArray(v["@type"]) &&
|
34005
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Organization")
|
34006
|
+
? await Organization.fromJsonLd(v, options)
|
34007
|
+
: typeof v === "object" && "@type" in v &&
|
34008
|
+
Array.isArray(v["@type"]) &&
|
34009
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Person")
|
34010
|
+
? await Person.fromJsonLd(v, options)
|
34011
|
+
: typeof v === "object" && "@type" in v &&
|
34012
|
+
Array.isArray(v["@type"]) &&
|
34013
|
+
v["@type"].includes("https://www.w3.org/ns/activitystreams#Service")
|
34014
|
+
? await _h.fromJsonLd(v, options)
|
34015
|
+
: undefined;
|
34016
|
+
if (typeof decoded === "undefined")
|
34017
|
+
continue;
|
34018
|
+
_3NV7TGNhuABbryNjNi4wib4DgNpY.push(decoded);
|
34019
|
+
}
|
34020
|
+
instance.#_3NV7TGNhuABbryNjNi4wib4DgNpY = _3NV7TGNhuABbryNjNi4wib4DgNpY;
|
32533
34021
|
if (!("_fromSubclass" in options) || !options._fromSubclass) {
|
32534
34022
|
try {
|
32535
34023
|
instance.#cachedJsonLd = structuredClone(json);
|
@@ -32746,6 +34234,22 @@ export class Service extends Object {
|
|
32746
34234
|
if (_2diCorzqPGQQqftp6e4SrCEwEnyk.length == 1) {
|
32747
34235
|
proxy.indexable = _2diCorzqPGQQqftp6e4SrCEwEnyk[0];
|
32748
34236
|
}
|
34237
|
+
const _3NV7TGNhuABbryNjNi4wib4DgNpY = this.#_3NV7TGNhuABbryNjNi4wib4DgNpY
|
34238
|
+
// deno-lint-ignore no-explicit-any
|
34239
|
+
.map((v) => v instanceof URL
|
34240
|
+
? {
|
34241
|
+
[Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
|
34242
|
+
[Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options),
|
34243
|
+
}
|
34244
|
+
: v);
|
34245
|
+
if (_3NV7TGNhuABbryNjNi4wib4DgNpY.length == 1) {
|
34246
|
+
proxy.alias = _3NV7TGNhuABbryNjNi4wib4DgNpY[0];
|
34247
|
+
}
|
34248
|
+
if (_3NV7TGNhuABbryNjNi4wib4DgNpY.length > 1 ||
|
34249
|
+
!("alias" in proxy) &&
|
34250
|
+
_3NV7TGNhuABbryNjNi4wib4DgNpY.length > 0) {
|
34251
|
+
proxy.aliases = _3NV7TGNhuABbryNjNi4wib4DgNpY;
|
34252
|
+
}
|
32749
34253
|
return proxy;
|
32750
34254
|
}
|
32751
34255
|
[Symbol.for("Deno.customInspect")](inspect, options) {
|
@@ -32757,6 +34261,7 @@ export class Service extends Object {
|
|
32757
34261
|
return "Service " + inspect(proxy, options);
|
32758
34262
|
}
|
32759
34263
|
}
|
34264
|
+
_h = Service;
|
32760
34265
|
/** Contents of {@link Object}'s `source`.
|
32761
34266
|
*/
|
32762
34267
|
export class Source {
|