@fedify/vocab 2.3.0-dev.1372 → 2.3.0-dev.1404
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deno.json +1 -1
- package/dist/mod.cjs +629 -1
- package/dist/mod.d.cts +310 -2
- package/dist/mod.d.ts +310 -2
- package/dist/mod.js +628 -2
- package/dist-tests/{actor-cK6SaGHS.mjs → actor-C8afdVf-.mjs} +2 -2
- package/dist-tests/actor.test.mjs +2 -2
- package/dist-tests/agreement.yaml +68 -0
- package/dist-tests/commitment.yaml +47 -0
- package/dist-tests/lookup.test.mjs +2 -2
- package/dist-tests/type.test.mjs +1 -1
- package/dist-tests/{vocab-BBRml5cy.mjs → vocab-DPq6zc4j.mjs} +629 -1
- package/dist-tests/vocab.test.mjs +208 -1
- package/package.json +4 -4
- package/src/__snapshots__/vocab.test.ts.snap +159 -0
- package/src/agreement.yaml +68 -0
- package/src/commitment.yaml +47 -0
- package/src/vocab.test.ts +342 -1
package/dist/mod.js
CHANGED
|
@@ -9,7 +9,7 @@ import { isTemporalDuration, isTemporalInstant } from "@fedify/vocab-runtime/tem
|
|
|
9
9
|
import { delay } from "es-toolkit";
|
|
10
10
|
//#region deno.json
|
|
11
11
|
var name = "@fedify/vocab";
|
|
12
|
-
var version = "2.3.0-dev.
|
|
12
|
+
var version = "2.3.0-dev.1404+275c2d11";
|
|
13
13
|
//#endregion
|
|
14
14
|
//#region src/type.ts
|
|
15
15
|
function getTypeId(object) {
|
|
@@ -5206,6 +5206,7 @@ var Object$1 = class Object$1 {
|
|
|
5206
5206
|
if (values["@type"].includes("https://gotosocial.org/ns#LikeApproval")) return await LikeAuthorization.fromJsonLd(json, options);
|
|
5207
5207
|
if (values["@type"].includes("https://gotosocial.org/ns#ReplyAuthorization")) return await ReplyAuthorization.fromJsonLd(json, options);
|
|
5208
5208
|
if (values["@type"].includes("https://w3id.org/fep/044f#QuoteAuthorization")) return await QuoteAuthorization.fromJsonLd(json, options);
|
|
5209
|
+
if (values["@type"].includes("https://w3id.org/valueflows/ont/vf#Agreement")) return await Agreement.fromJsonLd(json, options);
|
|
5209
5210
|
if (values["@type"].includes("https://w3id.org/valueflows/ont/vf#Proposal")) return await Proposal.fromJsonLd(json, options);
|
|
5210
5211
|
if (values["@type"].includes("https://www.w3.org/ns/activitystreams#Activity")) return await Activity.fromJsonLd(json, options);
|
|
5211
5212
|
if (values["@type"].includes("http://litepub.social/ns#EmojiReact")) return await EmojiReact.fromJsonLd(json, options);
|
|
@@ -5283,6 +5284,7 @@ var Object$1 = class Object$1 {
|
|
|
5283
5284
|
"https://gotosocial.org/ns#LikeApproval",
|
|
5284
5285
|
"https://gotosocial.org/ns#ReplyAuthorization",
|
|
5285
5286
|
"https://w3id.org/fep/044f#QuoteAuthorization",
|
|
5287
|
+
"https://w3id.org/valueflows/ont/vf#Agreement",
|
|
5286
5288
|
"https://w3id.org/valueflows/ont/vf#Proposal",
|
|
5287
5289
|
"https://www.w3.org/ns/activitystreams#Activity",
|
|
5288
5290
|
"http://litepub.social/ns#EmojiReact",
|
|
@@ -5430,6 +5432,7 @@ var Object$1 = class Object$1 {
|
|
|
5430
5432
|
"https://gotosocial.org/ns#LikeApproval",
|
|
5431
5433
|
"https://gotosocial.org/ns#ReplyAuthorization",
|
|
5432
5434
|
"https://w3id.org/fep/044f#QuoteAuthorization",
|
|
5435
|
+
"https://w3id.org/valueflows/ont/vf#Agreement",
|
|
5433
5436
|
"https://w3id.org/valueflows/ont/vf#Proposal",
|
|
5434
5437
|
"https://www.w3.org/ns/activitystreams#Activity",
|
|
5435
5438
|
"http://litepub.social/ns#EmojiReact",
|
|
@@ -5537,6 +5540,7 @@ var Object$1 = class Object$1 {
|
|
|
5537
5540
|
"https://gotosocial.org/ns#LikeApproval",
|
|
5538
5541
|
"https://gotosocial.org/ns#ReplyAuthorization",
|
|
5539
5542
|
"https://w3id.org/fep/044f#QuoteAuthorization",
|
|
5543
|
+
"https://w3id.org/valueflows/ont/vf#Agreement",
|
|
5540
5544
|
"https://w3id.org/valueflows/ont/vf#Proposal",
|
|
5541
5545
|
"https://www.w3.org/ns/activitystreams#Activity",
|
|
5542
5546
|
"http://litepub.social/ns#EmojiReact",
|
|
@@ -5694,6 +5698,7 @@ var Object$1 = class Object$1 {
|
|
|
5694
5698
|
"https://gotosocial.org/ns#LikeApproval",
|
|
5695
5699
|
"https://gotosocial.org/ns#ReplyAuthorization",
|
|
5696
5700
|
"https://w3id.org/fep/044f#QuoteAuthorization",
|
|
5701
|
+
"https://w3id.org/valueflows/ont/vf#Agreement",
|
|
5697
5702
|
"https://w3id.org/valueflows/ont/vf#Proposal",
|
|
5698
5703
|
"https://www.w3.org/ns/activitystreams#Activity",
|
|
5699
5704
|
"http://litepub.social/ns#EmojiReact",
|
|
@@ -5783,6 +5788,7 @@ var Object$1 = class Object$1 {
|
|
|
5783
5788
|
"https://gotosocial.org/ns#LikeApproval",
|
|
5784
5789
|
"https://gotosocial.org/ns#ReplyAuthorization",
|
|
5785
5790
|
"https://w3id.org/fep/044f#QuoteAuthorization",
|
|
5791
|
+
"https://w3id.org/valueflows/ont/vf#Agreement",
|
|
5786
5792
|
"https://w3id.org/valueflows/ont/vf#Proposal",
|
|
5787
5793
|
"https://www.w3.org/ns/activitystreams#Activity",
|
|
5788
5794
|
"http://litepub.social/ns#EmojiReact",
|
|
@@ -5879,6 +5885,7 @@ var Object$1 = class Object$1 {
|
|
|
5879
5885
|
"https://gotosocial.org/ns#LikeApproval",
|
|
5880
5886
|
"https://gotosocial.org/ns#ReplyAuthorization",
|
|
5881
5887
|
"https://w3id.org/fep/044f#QuoteAuthorization",
|
|
5888
|
+
"https://w3id.org/valueflows/ont/vf#Agreement",
|
|
5882
5889
|
"https://w3id.org/valueflows/ont/vf#Proposal",
|
|
5883
5890
|
"https://www.w3.org/ns/activitystreams#Activity",
|
|
5884
5891
|
"http://litepub.social/ns#EmojiReact",
|
|
@@ -6056,6 +6063,7 @@ var Object$1 = class Object$1 {
|
|
|
6056
6063
|
"https://gotosocial.org/ns#LikeApproval",
|
|
6057
6064
|
"https://gotosocial.org/ns#ReplyAuthorization",
|
|
6058
6065
|
"https://w3id.org/fep/044f#QuoteAuthorization",
|
|
6066
|
+
"https://w3id.org/valueflows/ont/vf#Agreement",
|
|
6059
6067
|
"https://w3id.org/valueflows/ont/vf#Proposal",
|
|
6060
6068
|
"https://www.w3.org/ns/activitystreams#Activity",
|
|
6061
6069
|
"http://litepub.social/ns#EmojiReact",
|
|
@@ -14856,6 +14864,618 @@ Multikey.prototype[Symbol.for("Deno.customInspect")] = function(inspect, options
|
|
|
14856
14864
|
Multikey.prototype[Symbol.for("nodejs.util.inspect.custom")] = function(_depth, options, inspect) {
|
|
14857
14865
|
return "Multikey " + inspect(this._getCustomInspectProxy(), options);
|
|
14858
14866
|
};
|
|
14867
|
+
/** The agreement reached between parties responding to a {@link Proposal}.
|
|
14868
|
+
*
|
|
14869
|
+
* An interested party sends an `Agreement` wrapped in an {@link Offer}
|
|
14870
|
+
* activity. The proposing party then either finalizes the agreement by
|
|
14871
|
+
* sending an {@link Accept} activity with the finalized `Agreement` as
|
|
14872
|
+
* its `result`, or sends a {@link Reject} activity.
|
|
14873
|
+
*
|
|
14874
|
+
* Note: This type extends ActivityStreams `Object` for practical
|
|
14875
|
+
* interoperability within ActivityPub federation, even though FEP-0837
|
|
14876
|
+
* defines `Agreement` as a pure ValueFlows type. Extending `Object`
|
|
14877
|
+
* provides useful inherited properties such as `id`, `attributedTo`,
|
|
14878
|
+
* `url`, `to`, and `published` without needing to redefine them.
|
|
14879
|
+
*/
|
|
14880
|
+
var Agreement = class Agreement extends Object$1 {
|
|
14881
|
+
/**
|
|
14882
|
+
* The type URI of {@link Agreement}: `https://w3id.org/valueflows/ont/vf#Agreement`.
|
|
14883
|
+
*/
|
|
14884
|
+
static get typeId() {
|
|
14885
|
+
return new URL("https://w3id.org/valueflows/ont/vf#Agreement");
|
|
14886
|
+
}
|
|
14887
|
+
#_37zeAJ2NVyecrDdP8os69FGAn9Q6_stipulates = [];
|
|
14888
|
+
#_4Vhx9DcywF65XWUQ4KZ35475FaJm_stipulatesReciprocal = [];
|
|
14889
|
+
/**
|
|
14890
|
+
* Constructs a new instance of Agreement with the given values.
|
|
14891
|
+
* @param values The values to initialize the instance with.
|
|
14892
|
+
* @param options The options to use for initialization.
|
|
14893
|
+
*/
|
|
14894
|
+
constructor(values, options = {}) {
|
|
14895
|
+
super(values, options);
|
|
14896
|
+
if ("stipulates" in values && values.stipulates != null) if (values.stipulates instanceof Commitment) this.#_37zeAJ2NVyecrDdP8os69FGAn9Q6_stipulates = [values.stipulates];
|
|
14897
|
+
else throw new TypeError("The stipulates must be of type Commitment.");
|
|
14898
|
+
if ("stipulatesReciprocal" in values && values.stipulatesReciprocal != null) if (values.stipulatesReciprocal instanceof Commitment) this.#_4Vhx9DcywF65XWUQ4KZ35475FaJm_stipulatesReciprocal = [values.stipulatesReciprocal];
|
|
14899
|
+
else throw new TypeError("The stipulatesReciprocal must be of type Commitment.");
|
|
14900
|
+
}
|
|
14901
|
+
/**
|
|
14902
|
+
* Clones this instance, optionally updating it with the given values.
|
|
14903
|
+
* @param values The values to update the clone with.
|
|
14904
|
+
* @param options The options to use for cloning.
|
|
14905
|
+
* @returns The cloned instance.
|
|
14906
|
+
*/
|
|
14907
|
+
clone(values = {}, options = {}) {
|
|
14908
|
+
if (this._warning != null) {
|
|
14909
|
+
getLogger(this._warning.category).warn(this._warning.message, this._warning.values);
|
|
14910
|
+
options = {
|
|
14911
|
+
...options,
|
|
14912
|
+
$warning: this._warning
|
|
14913
|
+
};
|
|
14914
|
+
}
|
|
14915
|
+
const clone = super.clone(values, options);
|
|
14916
|
+
clone.#_37zeAJ2NVyecrDdP8os69FGAn9Q6_stipulates = this.#_37zeAJ2NVyecrDdP8os69FGAn9Q6_stipulates;
|
|
14917
|
+
if ("stipulates" in values && values.stipulates != null) if (values.stipulates instanceof Commitment) clone.#_37zeAJ2NVyecrDdP8os69FGAn9Q6_stipulates = [values.stipulates];
|
|
14918
|
+
else throw new TypeError("The stipulates must be of type Commitment.");
|
|
14919
|
+
clone.#_4Vhx9DcywF65XWUQ4KZ35475FaJm_stipulatesReciprocal = this.#_4Vhx9DcywF65XWUQ4KZ35475FaJm_stipulatesReciprocal;
|
|
14920
|
+
if ("stipulatesReciprocal" in values && values.stipulatesReciprocal != null) if (values.stipulatesReciprocal instanceof Commitment) clone.#_4Vhx9DcywF65XWUQ4KZ35475FaJm_stipulatesReciprocal = [values.stipulatesReciprocal];
|
|
14921
|
+
else throw new TypeError("The stipulatesReciprocal must be of type Commitment.");
|
|
14922
|
+
return clone;
|
|
14923
|
+
}
|
|
14924
|
+
/** The primary {@link Commitment} associated with the agreement. This
|
|
14925
|
+
* commitment satisfies the primary {@link Intent} of the corresponding
|
|
14926
|
+
* {@link Proposal}.
|
|
14927
|
+
*/
|
|
14928
|
+
get stipulates() {
|
|
14929
|
+
if (this._warning != null) getLogger(this._warning.category).warn(this._warning.message, this._warning.values);
|
|
14930
|
+
if (this.#_37zeAJ2NVyecrDdP8os69FGAn9Q6_stipulates.length < 1) return null;
|
|
14931
|
+
return this.#_37zeAJ2NVyecrDdP8os69FGAn9Q6_stipulates[0];
|
|
14932
|
+
}
|
|
14933
|
+
/** The reciprocal {@link Commitment} associated with the agreement.
|
|
14934
|
+
* Required if the corresponding {@link Proposal} has a reciprocal
|
|
14935
|
+
* {@link Intent}.
|
|
14936
|
+
*/
|
|
14937
|
+
get stipulatesReciprocal() {
|
|
14938
|
+
if (this._warning != null) getLogger(this._warning.category).warn(this._warning.message, this._warning.values);
|
|
14939
|
+
if (this.#_4Vhx9DcywF65XWUQ4KZ35475FaJm_stipulatesReciprocal.length < 1) return null;
|
|
14940
|
+
return this.#_4Vhx9DcywF65XWUQ4KZ35475FaJm_stipulatesReciprocal[0];
|
|
14941
|
+
}
|
|
14942
|
+
/**
|
|
14943
|
+
* Converts this object to a JSON-LD structure.
|
|
14944
|
+
* @param options The options to use.
|
|
14945
|
+
* - `format`: The format of the output: `compact` or
|
|
14946
|
+
`expand`.
|
|
14947
|
+
* - `contextLoader`: The loader for remote JSON-LD contexts.
|
|
14948
|
+
* - `context`: The JSON-LD context to use. Not applicable
|
|
14949
|
+
when `format` is set to `'expand'`.
|
|
14950
|
+
* @returns The JSON-LD representation of this object.
|
|
14951
|
+
*/
|
|
14952
|
+
async toJsonLd(options = {}) {
|
|
14953
|
+
if (options.format == null && this._cachedJsonLd != null) return this._cachedJsonLd;
|
|
14954
|
+
if (options.format !== "compact" && options.context != null) throw new TypeError("The context option can only be used when the format option is set to 'compact'.");
|
|
14955
|
+
options = {
|
|
14956
|
+
...options,
|
|
14957
|
+
contextLoader: options.contextLoader ?? getDocumentLoader()
|
|
14958
|
+
};
|
|
14959
|
+
if (options.format == null && this.isCompactable()) {
|
|
14960
|
+
const result = await super.toJsonLd({
|
|
14961
|
+
...options,
|
|
14962
|
+
format: void 0,
|
|
14963
|
+
context: void 0
|
|
14964
|
+
});
|
|
14965
|
+
let compactItems = [];
|
|
14966
|
+
for (const v of this.#_37zeAJ2NVyecrDdP8os69FGAn9Q6_stipulates) {
|
|
14967
|
+
const item = await v.toJsonLd({
|
|
14968
|
+
...options,
|
|
14969
|
+
format: void 0,
|
|
14970
|
+
context: void 0
|
|
14971
|
+
});
|
|
14972
|
+
compactItems.push(item);
|
|
14973
|
+
}
|
|
14974
|
+
if (compactItems.length > 0) result["stipulates"] = compactItems.length > 1 ? compactItems : compactItems[0];
|
|
14975
|
+
compactItems = [];
|
|
14976
|
+
for (const v of this.#_4Vhx9DcywF65XWUQ4KZ35475FaJm_stipulatesReciprocal) {
|
|
14977
|
+
const item = await v.toJsonLd({
|
|
14978
|
+
...options,
|
|
14979
|
+
format: void 0,
|
|
14980
|
+
context: void 0
|
|
14981
|
+
});
|
|
14982
|
+
compactItems.push(item);
|
|
14983
|
+
}
|
|
14984
|
+
if (compactItems.length > 0) result["stipulatesReciprocal"] = compactItems.length > 1 ? compactItems : compactItems[0];
|
|
14985
|
+
result["type"] = "Agreement";
|
|
14986
|
+
if (this.id != null) result["id"] = this.id.href;
|
|
14987
|
+
result["@context"] = [
|
|
14988
|
+
"https://www.w3.org/ns/activitystreams",
|
|
14989
|
+
"https://w3id.org/security/data-integrity/v1",
|
|
14990
|
+
"https://gotosocial.org/ns",
|
|
14991
|
+
{
|
|
14992
|
+
"vf": "https://w3id.org/valueflows/ont/vf#",
|
|
14993
|
+
"om2": "http://www.ontology-of-units-of-measure.org/resource/om-2/",
|
|
14994
|
+
"fedibird": "http://fedibird.com/ns#",
|
|
14995
|
+
"sensitive": "as:sensitive",
|
|
14996
|
+
"emojiReactions": {
|
|
14997
|
+
"@id": "fedibird:emojiReactions",
|
|
14998
|
+
"@type": "@id"
|
|
14999
|
+
},
|
|
15000
|
+
"Agreement": "vf:Agreement",
|
|
15001
|
+
"Commitment": "vf:Commitment",
|
|
15002
|
+
"stipulates": "vf:stipulates",
|
|
15003
|
+
"stipulatesReciprocal": "vf:stipulatesReciprocal",
|
|
15004
|
+
"satisfies": {
|
|
15005
|
+
"@id": "vf:satisfies",
|
|
15006
|
+
"@type": "@id"
|
|
15007
|
+
},
|
|
15008
|
+
"resourceQuantity": "vf:resourceQuantity",
|
|
15009
|
+
"hasUnit": "om2:hasUnit",
|
|
15010
|
+
"hasNumericalValue": "om2:hasNumericalValue"
|
|
15011
|
+
}
|
|
15012
|
+
];
|
|
15013
|
+
return result;
|
|
15014
|
+
}
|
|
15015
|
+
let array;
|
|
15016
|
+
const values = (await super.toJsonLd({
|
|
15017
|
+
...options,
|
|
15018
|
+
format: "expand",
|
|
15019
|
+
context: void 0
|
|
15020
|
+
}))[0];
|
|
15021
|
+
array = [];
|
|
15022
|
+
for (const v of this.#_37zeAJ2NVyecrDdP8os69FGAn9Q6_stipulates) {
|
|
15023
|
+
const element = await v.toJsonLd(options);
|
|
15024
|
+
array.push(element);
|
|
15025
|
+
}
|
|
15026
|
+
if (array.length > 0) values["https://w3id.org/valueflows/ont/vf#stipulates"] = array;
|
|
15027
|
+
array = [];
|
|
15028
|
+
for (const v of this.#_4Vhx9DcywF65XWUQ4KZ35475FaJm_stipulatesReciprocal) {
|
|
15029
|
+
const element = await v.toJsonLd(options);
|
|
15030
|
+
array.push(element);
|
|
15031
|
+
}
|
|
15032
|
+
if (array.length > 0) values["https://w3id.org/valueflows/ont/vf#stipulatesReciprocal"] = array;
|
|
15033
|
+
values["@type"] = ["https://w3id.org/valueflows/ont/vf#Agreement"];
|
|
15034
|
+
if (this.id != null) values["@id"] = this.id.href;
|
|
15035
|
+
if (options.format === "expand") return await jsonld.expand(values, { documentLoader: options.contextLoader });
|
|
15036
|
+
const docContext = options.context ?? [
|
|
15037
|
+
"https://www.w3.org/ns/activitystreams",
|
|
15038
|
+
"https://w3id.org/security/data-integrity/v1",
|
|
15039
|
+
"https://gotosocial.org/ns",
|
|
15040
|
+
{
|
|
15041
|
+
"vf": "https://w3id.org/valueflows/ont/vf#",
|
|
15042
|
+
"om2": "http://www.ontology-of-units-of-measure.org/resource/om-2/",
|
|
15043
|
+
"fedibird": "http://fedibird.com/ns#",
|
|
15044
|
+
"sensitive": "as:sensitive",
|
|
15045
|
+
"emojiReactions": {
|
|
15046
|
+
"@id": "fedibird:emojiReactions",
|
|
15047
|
+
"@type": "@id"
|
|
15048
|
+
},
|
|
15049
|
+
"Agreement": "vf:Agreement",
|
|
15050
|
+
"Commitment": "vf:Commitment",
|
|
15051
|
+
"stipulates": "vf:stipulates",
|
|
15052
|
+
"stipulatesReciprocal": "vf:stipulatesReciprocal",
|
|
15053
|
+
"satisfies": {
|
|
15054
|
+
"@id": "vf:satisfies",
|
|
15055
|
+
"@type": "@id"
|
|
15056
|
+
},
|
|
15057
|
+
"resourceQuantity": "vf:resourceQuantity",
|
|
15058
|
+
"hasUnit": "om2:hasUnit",
|
|
15059
|
+
"hasNumericalValue": "om2:hasNumericalValue"
|
|
15060
|
+
}
|
|
15061
|
+
];
|
|
15062
|
+
const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
|
|
15063
|
+
if (docContext != null) {
|
|
15064
|
+
if ("proof" in compacted && compacted.proof != null) if (Array.isArray(compacted.proof)) for (const element of compacted.proof) element["@context"] = docContext;
|
|
15065
|
+
else compacted.proof["@context"] = docContext;
|
|
15066
|
+
}
|
|
15067
|
+
return compacted;
|
|
15068
|
+
}
|
|
15069
|
+
isCompactable() {
|
|
15070
|
+
return super.isCompactable();
|
|
15071
|
+
}
|
|
15072
|
+
/**
|
|
15073
|
+
* Converts a JSON-LD structure to an object of this type.
|
|
15074
|
+
* @param json The JSON-LD structure to convert.
|
|
15075
|
+
* @param options The options to use.
|
|
15076
|
+
* - `documentLoader`: The loader for remote JSON-LD documents.
|
|
15077
|
+
* - `contextLoader`: The loader for remote JSON-LD contexts.
|
|
15078
|
+
* - `tracerProvider`: The OpenTelemetry tracer provider to use.
|
|
15079
|
+
* If omitted, the global tracer provider is used.
|
|
15080
|
+
* @returns The object of this type.
|
|
15081
|
+
* @throws {TypeError} If the given `json` is invalid.
|
|
15082
|
+
*/
|
|
15083
|
+
static async fromJsonLd(json, options = {}) {
|
|
15084
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer("@fedify/vocab-tools", "2.3.0").startActiveSpan("activitypub.parse_object", async (span) => {
|
|
15085
|
+
try {
|
|
15086
|
+
const object = await this.__fromJsonLd__Agreement__(json, span, options);
|
|
15087
|
+
if (object.id != null) span.setAttribute("activitypub.object.id", object.id.href);
|
|
15088
|
+
return object;
|
|
15089
|
+
} catch (error) {
|
|
15090
|
+
span.setStatus({
|
|
15091
|
+
code: SpanStatusCode.ERROR,
|
|
15092
|
+
message: String(error)
|
|
15093
|
+
});
|
|
15094
|
+
throw error;
|
|
15095
|
+
} finally {
|
|
15096
|
+
span.end();
|
|
15097
|
+
}
|
|
15098
|
+
});
|
|
15099
|
+
}
|
|
15100
|
+
static async __fromJsonLd__Agreement__(json, span, options = {}) {
|
|
15101
|
+
if (typeof json === "undefined") throw new TypeError("Invalid JSON-LD: undefined.");
|
|
15102
|
+
else if (json === null) throw new TypeError("Invalid JSON-LD: null.");
|
|
15103
|
+
options = {
|
|
15104
|
+
...options,
|
|
15105
|
+
documentLoader: options.documentLoader ?? getDocumentLoader(),
|
|
15106
|
+
contextLoader: options.contextLoader ?? getDocumentLoader(),
|
|
15107
|
+
tracerProvider: options.tracerProvider ?? trace.getTracerProvider()
|
|
15108
|
+
};
|
|
15109
|
+
let values;
|
|
15110
|
+
if (globalThis.Object.keys(json).length == 0) values = {};
|
|
15111
|
+
else values = (await jsonld.expand(json, {
|
|
15112
|
+
documentLoader: options.contextLoader,
|
|
15113
|
+
keepFreeFloatingNodes: true
|
|
15114
|
+
}))[0] ?? {};
|
|
15115
|
+
if (values["@id"] != null && !values["@id"].startsWith("_:") && !URL.canParse(values["@id"], options.baseUrl)) throw new TypeError("Invalid @id: " + values["@id"]);
|
|
15116
|
+
if (options.baseUrl == null && values["@id"] != null && !values["@id"].startsWith("_:") && URL.canParse(values["@id"])) options = {
|
|
15117
|
+
...options,
|
|
15118
|
+
baseUrl: new URL(values["@id"])
|
|
15119
|
+
};
|
|
15120
|
+
if ("@type" in values) span.setAttribute("activitypub.object.type", values["@type"]);
|
|
15121
|
+
if ("@type" in values && !values["@type"].every((t) => t.startsWith("_:"))) {
|
|
15122
|
+
if (!values["@type"].includes("https://w3id.org/valueflows/ont/vf#Agreement")) throw new TypeError("Invalid type: " + values["@type"]);
|
|
15123
|
+
}
|
|
15124
|
+
delete values["@type"];
|
|
15125
|
+
const instance = await super.fromJsonLd(values, {
|
|
15126
|
+
...options,
|
|
15127
|
+
_fromSubclass: true
|
|
15128
|
+
});
|
|
15129
|
+
if (!(instance instanceof Agreement)) throw new TypeError("Unexpected type: " + instance.constructor.name);
|
|
15130
|
+
const _37zeAJ2NVyecrDdP8os69FGAn9Q6_stipulates = [];
|
|
15131
|
+
let _37zeAJ2NVyecrDdP8os69FGAn9Q6_stipulates__array = values["https://w3id.org/valueflows/ont/vf#stipulates"];
|
|
15132
|
+
for (const v of _37zeAJ2NVyecrDdP8os69FGAn9Q6_stipulates__array == null ? [] : _37zeAJ2NVyecrDdP8os69FGAn9Q6_stipulates__array.length === 1 && "@list" in _37zeAJ2NVyecrDdP8os69FGAn9Q6_stipulates__array[0] ? _37zeAJ2NVyecrDdP8os69FGAn9Q6_stipulates__array[0]["@list"] : _37zeAJ2NVyecrDdP8os69FGAn9Q6_stipulates__array) {
|
|
15133
|
+
if (v == null) continue;
|
|
15134
|
+
const decoded = await Commitment.fromJsonLd(v, {
|
|
15135
|
+
...options,
|
|
15136
|
+
baseUrl: options.baseUrl
|
|
15137
|
+
});
|
|
15138
|
+
if (typeof decoded === "undefined") continue;
|
|
15139
|
+
_37zeAJ2NVyecrDdP8os69FGAn9Q6_stipulates.push(decoded);
|
|
15140
|
+
}
|
|
15141
|
+
instance.#_37zeAJ2NVyecrDdP8os69FGAn9Q6_stipulates = _37zeAJ2NVyecrDdP8os69FGAn9Q6_stipulates;
|
|
15142
|
+
const _4Vhx9DcywF65XWUQ4KZ35475FaJm_stipulatesReciprocal = [];
|
|
15143
|
+
let _4Vhx9DcywF65XWUQ4KZ35475FaJm_stipulatesReciprocal__array = values["https://w3id.org/valueflows/ont/vf#stipulatesReciprocal"];
|
|
15144
|
+
for (const v of _4Vhx9DcywF65XWUQ4KZ35475FaJm_stipulatesReciprocal__array == null ? [] : _4Vhx9DcywF65XWUQ4KZ35475FaJm_stipulatesReciprocal__array.length === 1 && "@list" in _4Vhx9DcywF65XWUQ4KZ35475FaJm_stipulatesReciprocal__array[0] ? _4Vhx9DcywF65XWUQ4KZ35475FaJm_stipulatesReciprocal__array[0]["@list"] : _4Vhx9DcywF65XWUQ4KZ35475FaJm_stipulatesReciprocal__array) {
|
|
15145
|
+
if (v == null) continue;
|
|
15146
|
+
const decoded = await Commitment.fromJsonLd(v, {
|
|
15147
|
+
...options,
|
|
15148
|
+
baseUrl: options.baseUrl
|
|
15149
|
+
});
|
|
15150
|
+
if (typeof decoded === "undefined") continue;
|
|
15151
|
+
_4Vhx9DcywF65XWUQ4KZ35475FaJm_stipulatesReciprocal.push(decoded);
|
|
15152
|
+
}
|
|
15153
|
+
instance.#_4Vhx9DcywF65XWUQ4KZ35475FaJm_stipulatesReciprocal = _4Vhx9DcywF65XWUQ4KZ35475FaJm_stipulatesReciprocal;
|
|
15154
|
+
if (!("_fromSubclass" in options) || !options._fromSubclass) try {
|
|
15155
|
+
instance._cachedJsonLd = structuredClone(json);
|
|
15156
|
+
} catch {
|
|
15157
|
+
getLogger(["fedify", "vocab"]).warn("Failed to cache JSON-LD: {json}", { json });
|
|
15158
|
+
}
|
|
15159
|
+
return instance;
|
|
15160
|
+
}
|
|
15161
|
+
_getCustomInspectProxy() {
|
|
15162
|
+
const proxy = super._getCustomInspectProxy();
|
|
15163
|
+
const _37zeAJ2NVyecrDdP8os69FGAn9Q6_stipulates = this.#_37zeAJ2NVyecrDdP8os69FGAn9Q6_stipulates.map((v) => v instanceof URL ? {
|
|
15164
|
+
[Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
|
|
15165
|
+
[Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options)
|
|
15166
|
+
} : v);
|
|
15167
|
+
if (_37zeAJ2NVyecrDdP8os69FGAn9Q6_stipulates.length == 1) proxy.stipulates = _37zeAJ2NVyecrDdP8os69FGAn9Q6_stipulates[0];
|
|
15168
|
+
const _4Vhx9DcywF65XWUQ4KZ35475FaJm_stipulatesReciprocal = this.#_4Vhx9DcywF65XWUQ4KZ35475FaJm_stipulatesReciprocal.map((v) => v instanceof URL ? {
|
|
15169
|
+
[Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
|
|
15170
|
+
[Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options)
|
|
15171
|
+
} : v);
|
|
15172
|
+
if (_4Vhx9DcywF65XWUQ4KZ35475FaJm_stipulatesReciprocal.length == 1) proxy.stipulatesReciprocal = _4Vhx9DcywF65XWUQ4KZ35475FaJm_stipulatesReciprocal[0];
|
|
15173
|
+
return proxy;
|
|
15174
|
+
}
|
|
15175
|
+
};
|
|
15176
|
+
Agreement.prototype[Symbol.for("Deno.customInspect")] = function(inspect, options) {
|
|
15177
|
+
return "Agreement " + inspect(this._getCustomInspectProxy(), options);
|
|
15178
|
+
};
|
|
15179
|
+
Agreement.prototype[Symbol.for("nodejs.util.inspect.custom")] = function(_depth, options, inspect) {
|
|
15180
|
+
return "Agreement " + inspect(this._getCustomInspectProxy(), options);
|
|
15181
|
+
};
|
|
15182
|
+
/** A promised economic transaction, referenced by an {@link Agreement}.
|
|
15183
|
+
*
|
|
15184
|
+
* A commitment satisfies an {@link Intent} of a {@link Proposal} and
|
|
15185
|
+
* specifies the actual amount of the economic resource being committed.
|
|
15186
|
+
*/
|
|
15187
|
+
var Commitment = class {
|
|
15188
|
+
#documentLoader;
|
|
15189
|
+
#contextLoader;
|
|
15190
|
+
#tracerProvider;
|
|
15191
|
+
#warning;
|
|
15192
|
+
#cachedJsonLd;
|
|
15193
|
+
#_baseUrl;
|
|
15194
|
+
id;
|
|
15195
|
+
get _documentLoader() {
|
|
15196
|
+
return this.#documentLoader;
|
|
15197
|
+
}
|
|
15198
|
+
get _contextLoader() {
|
|
15199
|
+
return this.#contextLoader;
|
|
15200
|
+
}
|
|
15201
|
+
get _tracerProvider() {
|
|
15202
|
+
return this.#tracerProvider;
|
|
15203
|
+
}
|
|
15204
|
+
get _warning() {
|
|
15205
|
+
return this.#warning;
|
|
15206
|
+
}
|
|
15207
|
+
get _cachedJsonLd() {
|
|
15208
|
+
return this.#cachedJsonLd;
|
|
15209
|
+
}
|
|
15210
|
+
set _cachedJsonLd(value) {
|
|
15211
|
+
this.#cachedJsonLd = value;
|
|
15212
|
+
}
|
|
15213
|
+
get _baseUrl() {
|
|
15214
|
+
return this.#_baseUrl;
|
|
15215
|
+
}
|
|
15216
|
+
/**
|
|
15217
|
+
* The type URI of {@link Commitment}: `https://w3id.org/valueflows/ont/vf#Commitment`.
|
|
15218
|
+
*/
|
|
15219
|
+
static get typeId() {
|
|
15220
|
+
return new URL("https://w3id.org/valueflows/ont/vf#Commitment");
|
|
15221
|
+
}
|
|
15222
|
+
#_aCyzDK9TkXtLxrZs7JC8emuYisv_satisfies = [];
|
|
15223
|
+
#_2dLfqTbbRiggEcMQWbHpxkQrtmrc_resourceQuantity = [];
|
|
15224
|
+
/**
|
|
15225
|
+
* Constructs a new instance of Commitment with the given values.
|
|
15226
|
+
* @param values The values to initialize the instance with.
|
|
15227
|
+
* @param options The options to use for initialization.
|
|
15228
|
+
*/
|
|
15229
|
+
constructor(values, options = {}) {
|
|
15230
|
+
this.#documentLoader = options.documentLoader;
|
|
15231
|
+
this.#contextLoader = options.contextLoader;
|
|
15232
|
+
this.#tracerProvider = options.tracerProvider;
|
|
15233
|
+
const baseUrl = options.baseUrl;
|
|
15234
|
+
this.#_baseUrl = baseUrl == null ? void 0 : new URL(baseUrl.href);
|
|
15235
|
+
if ("$warning" in options) this.#warning = options.$warning;
|
|
15236
|
+
if (values.id == null || values.id instanceof URL) this.id = values.id ?? null;
|
|
15237
|
+
else throw new TypeError("The id must be a URL.");
|
|
15238
|
+
if ("satisfies" in values && values.satisfies != null) if (values.satisfies instanceof URL) this.#_aCyzDK9TkXtLxrZs7JC8emuYisv_satisfies = [values.satisfies];
|
|
15239
|
+
else throw new TypeError("The satisfies must be of type URL.");
|
|
15240
|
+
if ("resourceQuantity" in values && values.resourceQuantity != null) if (values.resourceQuantity instanceof Measure) this.#_2dLfqTbbRiggEcMQWbHpxkQrtmrc_resourceQuantity = [values.resourceQuantity];
|
|
15241
|
+
else throw new TypeError("The resourceQuantity must be of type Measure.");
|
|
15242
|
+
}
|
|
15243
|
+
/**
|
|
15244
|
+
* Clones this instance, optionally updating it with the given values.
|
|
15245
|
+
* @param values The values to update the clone with.
|
|
15246
|
+
* @param options The options to use for cloning.
|
|
15247
|
+
* @returns The cloned instance.
|
|
15248
|
+
*/
|
|
15249
|
+
clone(values = {}, options = {}) {
|
|
15250
|
+
if (this._warning != null) {
|
|
15251
|
+
getLogger(this._warning.category).warn(this._warning.message, this._warning.values);
|
|
15252
|
+
options = {
|
|
15253
|
+
...options,
|
|
15254
|
+
$warning: this._warning
|
|
15255
|
+
};
|
|
15256
|
+
}
|
|
15257
|
+
const clone = new this.constructor({ id: values.id ?? this.id }, options);
|
|
15258
|
+
clone.#_aCyzDK9TkXtLxrZs7JC8emuYisv_satisfies = this.#_aCyzDK9TkXtLxrZs7JC8emuYisv_satisfies;
|
|
15259
|
+
if ("satisfies" in values && values.satisfies != null) if (values.satisfies instanceof URL) clone.#_aCyzDK9TkXtLxrZs7JC8emuYisv_satisfies = [values.satisfies];
|
|
15260
|
+
else throw new TypeError("The satisfies must be of type URL.");
|
|
15261
|
+
clone.#_2dLfqTbbRiggEcMQWbHpxkQrtmrc_resourceQuantity = this.#_2dLfqTbbRiggEcMQWbHpxkQrtmrc_resourceQuantity;
|
|
15262
|
+
if ("resourceQuantity" in values && values.resourceQuantity != null) if (values.resourceQuantity instanceof Measure) clone.#_2dLfqTbbRiggEcMQWbHpxkQrtmrc_resourceQuantity = [values.resourceQuantity];
|
|
15263
|
+
else throw new TypeError("The resourceQuantity must be of type Measure.");
|
|
15264
|
+
return clone;
|
|
15265
|
+
}
|
|
15266
|
+
/** The {@link Intent} of a {@link Proposal} that this commitment
|
|
15267
|
+
* satisfies. The value is the proposal's URI with a
|
|
15268
|
+
* [fragment](https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Fragment)
|
|
15269
|
+
* appended to identify the intent. Recommended fragments are
|
|
15270
|
+
* `primary` and `reciprocal`.
|
|
15271
|
+
*/
|
|
15272
|
+
get satisfies() {
|
|
15273
|
+
if (this._warning != null) getLogger(this._warning.category).warn(this._warning.message, this._warning.values);
|
|
15274
|
+
if (this.#_aCyzDK9TkXtLxrZs7JC8emuYisv_satisfies.length < 1) return null;
|
|
15275
|
+
return this.#_aCyzDK9TkXtLxrZs7JC8emuYisv_satisfies[0];
|
|
15276
|
+
}
|
|
15277
|
+
/** The amount and unit of the economic resource being committed. The
|
|
15278
|
+
* unit must match the unit specified in the corresponding {@link Intent}
|
|
15279
|
+
* of the proposal.
|
|
15280
|
+
*/
|
|
15281
|
+
get resourceQuantity() {
|
|
15282
|
+
if (this._warning != null) getLogger(this._warning.category).warn(this._warning.message, this._warning.values);
|
|
15283
|
+
if (this.#_2dLfqTbbRiggEcMQWbHpxkQrtmrc_resourceQuantity.length < 1) return null;
|
|
15284
|
+
return this.#_2dLfqTbbRiggEcMQWbHpxkQrtmrc_resourceQuantity[0];
|
|
15285
|
+
}
|
|
15286
|
+
/**
|
|
15287
|
+
* Converts this object to a JSON-LD structure.
|
|
15288
|
+
* @param options The options to use.
|
|
15289
|
+
* - `format`: The format of the output: `compact` or
|
|
15290
|
+
`expand`.
|
|
15291
|
+
* - `contextLoader`: The loader for remote JSON-LD contexts.
|
|
15292
|
+
* - `context`: The JSON-LD context to use. Not applicable
|
|
15293
|
+
when `format` is set to `'expand'`.
|
|
15294
|
+
* @returns The JSON-LD representation of this object.
|
|
15295
|
+
*/
|
|
15296
|
+
async toJsonLd(options = {}) {
|
|
15297
|
+
if (options.format == null && this._cachedJsonLd != null) return this._cachedJsonLd;
|
|
15298
|
+
if (options.format !== "compact" && options.context != null) throw new TypeError("The context option can only be used when the format option is set to 'compact'.");
|
|
15299
|
+
options = {
|
|
15300
|
+
...options,
|
|
15301
|
+
contextLoader: options.contextLoader ?? getDocumentLoader()
|
|
15302
|
+
};
|
|
15303
|
+
if (options.format == null && this.isCompactable()) {
|
|
15304
|
+
const result = {};
|
|
15305
|
+
let compactItems = [];
|
|
15306
|
+
for (const v of this.#_aCyzDK9TkXtLxrZs7JC8emuYisv_satisfies) {
|
|
15307
|
+
const item = v.href;
|
|
15308
|
+
compactItems.push(item);
|
|
15309
|
+
}
|
|
15310
|
+
if (compactItems.length > 0) result["satisfies"] = compactItems.length > 1 ? compactItems : compactItems[0];
|
|
15311
|
+
compactItems = [];
|
|
15312
|
+
for (const v of this.#_2dLfqTbbRiggEcMQWbHpxkQrtmrc_resourceQuantity) {
|
|
15313
|
+
const item = await v.toJsonLd({
|
|
15314
|
+
...options,
|
|
15315
|
+
format: void 0,
|
|
15316
|
+
context: void 0
|
|
15317
|
+
});
|
|
15318
|
+
compactItems.push(item);
|
|
15319
|
+
}
|
|
15320
|
+
if (compactItems.length > 0) result["resourceQuantity"] = compactItems.length > 1 ? compactItems : compactItems[0];
|
|
15321
|
+
result["type"] = "Commitment";
|
|
15322
|
+
if (this.id != null) result["id"] = this.id.href;
|
|
15323
|
+
result["@context"] = ["https://www.w3.org/ns/activitystreams", {
|
|
15324
|
+
"vf": "https://w3id.org/valueflows/ont/vf#",
|
|
15325
|
+
"om2": "http://www.ontology-of-units-of-measure.org/resource/om-2/",
|
|
15326
|
+
"Commitment": "vf:Commitment",
|
|
15327
|
+
"satisfies": {
|
|
15328
|
+
"@id": "vf:satisfies",
|
|
15329
|
+
"@type": "@id"
|
|
15330
|
+
},
|
|
15331
|
+
"resourceQuantity": "vf:resourceQuantity",
|
|
15332
|
+
"hasUnit": "om2:hasUnit",
|
|
15333
|
+
"hasNumericalValue": "om2:hasNumericalValue"
|
|
15334
|
+
}];
|
|
15335
|
+
return result;
|
|
15336
|
+
}
|
|
15337
|
+
let array;
|
|
15338
|
+
const values = {};
|
|
15339
|
+
array = [];
|
|
15340
|
+
for (const v of this.#_aCyzDK9TkXtLxrZs7JC8emuYisv_satisfies) {
|
|
15341
|
+
const element = { "@id": v.href };
|
|
15342
|
+
array.push(element);
|
|
15343
|
+
}
|
|
15344
|
+
if (array.length > 0) values["https://w3id.org/valueflows/ont/vf#satisfies"] = array;
|
|
15345
|
+
array = [];
|
|
15346
|
+
for (const v of this.#_2dLfqTbbRiggEcMQWbHpxkQrtmrc_resourceQuantity) {
|
|
15347
|
+
const element = await v.toJsonLd(options);
|
|
15348
|
+
array.push(element);
|
|
15349
|
+
}
|
|
15350
|
+
if (array.length > 0) values["https://w3id.org/valueflows/ont/vf#resourceQuantity"] = array;
|
|
15351
|
+
values["@type"] = ["https://w3id.org/valueflows/ont/vf#Commitment"];
|
|
15352
|
+
if (this.id != null) values["@id"] = this.id.href;
|
|
15353
|
+
if (options.format === "expand") return await jsonld.expand(values, { documentLoader: options.contextLoader });
|
|
15354
|
+
const docContext = options.context ?? ["https://www.w3.org/ns/activitystreams", {
|
|
15355
|
+
"vf": "https://w3id.org/valueflows/ont/vf#",
|
|
15356
|
+
"om2": "http://www.ontology-of-units-of-measure.org/resource/om-2/",
|
|
15357
|
+
"Commitment": "vf:Commitment",
|
|
15358
|
+
"satisfies": {
|
|
15359
|
+
"@id": "vf:satisfies",
|
|
15360
|
+
"@type": "@id"
|
|
15361
|
+
},
|
|
15362
|
+
"resourceQuantity": "vf:resourceQuantity",
|
|
15363
|
+
"hasUnit": "om2:hasUnit",
|
|
15364
|
+
"hasNumericalValue": "om2:hasNumericalValue"
|
|
15365
|
+
}];
|
|
15366
|
+
const compacted = await jsonld.compact(values, docContext, { documentLoader: options.contextLoader });
|
|
15367
|
+
if (docContext != null) {}
|
|
15368
|
+
return compacted;
|
|
15369
|
+
}
|
|
15370
|
+
isCompactable() {
|
|
15371
|
+
return true;
|
|
15372
|
+
}
|
|
15373
|
+
/**
|
|
15374
|
+
* Converts a JSON-LD structure to an object of this type.
|
|
15375
|
+
* @param json The JSON-LD structure to convert.
|
|
15376
|
+
* @param options The options to use.
|
|
15377
|
+
* - `documentLoader`: The loader for remote JSON-LD documents.
|
|
15378
|
+
* - `contextLoader`: The loader for remote JSON-LD contexts.
|
|
15379
|
+
* - `tracerProvider`: The OpenTelemetry tracer provider to use.
|
|
15380
|
+
* If omitted, the global tracer provider is used.
|
|
15381
|
+
* @returns The object of this type.
|
|
15382
|
+
* @throws {TypeError} If the given `json` is invalid.
|
|
15383
|
+
*/
|
|
15384
|
+
static async fromJsonLd(json, options = {}) {
|
|
15385
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer("@fedify/vocab-tools", "2.3.0").startActiveSpan("activitypub.parse_object", async (span) => {
|
|
15386
|
+
try {
|
|
15387
|
+
const object = await this.__fromJsonLd__Commitment__(json, span, options);
|
|
15388
|
+
if (object.id != null) span.setAttribute("activitypub.object.id", object.id.href);
|
|
15389
|
+
return object;
|
|
15390
|
+
} catch (error) {
|
|
15391
|
+
span.setStatus({
|
|
15392
|
+
code: SpanStatusCode.ERROR,
|
|
15393
|
+
message: String(error)
|
|
15394
|
+
});
|
|
15395
|
+
throw error;
|
|
15396
|
+
} finally {
|
|
15397
|
+
span.end();
|
|
15398
|
+
}
|
|
15399
|
+
});
|
|
15400
|
+
}
|
|
15401
|
+
static async __fromJsonLd__Commitment__(json, span, options = {}) {
|
|
15402
|
+
if (typeof json === "undefined") throw new TypeError("Invalid JSON-LD: undefined.");
|
|
15403
|
+
else if (json === null) throw new TypeError("Invalid JSON-LD: null.");
|
|
15404
|
+
options = {
|
|
15405
|
+
...options,
|
|
15406
|
+
documentLoader: options.documentLoader ?? getDocumentLoader(),
|
|
15407
|
+
contextLoader: options.contextLoader ?? getDocumentLoader(),
|
|
15408
|
+
tracerProvider: options.tracerProvider ?? trace.getTracerProvider()
|
|
15409
|
+
};
|
|
15410
|
+
let values;
|
|
15411
|
+
if (globalThis.Object.keys(json).length == 0) values = {};
|
|
15412
|
+
else values = (await jsonld.expand(json, {
|
|
15413
|
+
documentLoader: options.contextLoader,
|
|
15414
|
+
keepFreeFloatingNodes: true
|
|
15415
|
+
}))[0] ?? {};
|
|
15416
|
+
if (values["@id"] != null && !values["@id"].startsWith("_:") && !URL.canParse(values["@id"], options.baseUrl)) throw new TypeError("Invalid @id: " + values["@id"]);
|
|
15417
|
+
if (options.baseUrl == null && values["@id"] != null && !values["@id"].startsWith("_:") && URL.canParse(values["@id"])) options = {
|
|
15418
|
+
...options,
|
|
15419
|
+
baseUrl: new URL(values["@id"])
|
|
15420
|
+
};
|
|
15421
|
+
if ("@type" in values) span.setAttribute("activitypub.object.type", values["@type"]);
|
|
15422
|
+
if ("@type" in values && !values["@type"].every((t) => t.startsWith("_:"))) {
|
|
15423
|
+
if (!values["@type"].includes("https://w3id.org/valueflows/ont/vf#Commitment")) throw new TypeError("Invalid type: " + values["@type"]);
|
|
15424
|
+
}
|
|
15425
|
+
const instance = new this({ id: values["@id"] != null && !values["@id"].startsWith("_:") && URL.canParse(values["@id"], options.baseUrl) ? new URL(values["@id"], options.baseUrl) : void 0 }, options);
|
|
15426
|
+
const _aCyzDK9TkXtLxrZs7JC8emuYisv_satisfies = [];
|
|
15427
|
+
let _aCyzDK9TkXtLxrZs7JC8emuYisv_satisfies__array = values["https://w3id.org/valueflows/ont/vf#satisfies"];
|
|
15428
|
+
for (const v of _aCyzDK9TkXtLxrZs7JC8emuYisv_satisfies__array == null ? [] : _aCyzDK9TkXtLxrZs7JC8emuYisv_satisfies__array.length === 1 && "@list" in _aCyzDK9TkXtLxrZs7JC8emuYisv_satisfies__array[0] ? _aCyzDK9TkXtLxrZs7JC8emuYisv_satisfies__array[0]["@list"] : _aCyzDK9TkXtLxrZs7JC8emuYisv_satisfies__array) {
|
|
15429
|
+
if (v == null) continue;
|
|
15430
|
+
const decoded = v["@id"].startsWith("at://") ? new URL("at://" + encodeURIComponent(v["@id"].includes("/", 5) ? v["@id"].slice(5, v["@id"].indexOf("/", 5)) : v["@id"].slice(5)) + (v["@id"].includes("/", 5) ? v["@id"].slice(v["@id"].indexOf("/", 5)) : "")) : URL.canParse(v["@id"]) && options.baseUrl ? new URL(v["@id"]) : new URL(v["@id"], options.baseUrl);
|
|
15431
|
+
if (typeof decoded === "undefined") continue;
|
|
15432
|
+
_aCyzDK9TkXtLxrZs7JC8emuYisv_satisfies.push(decoded);
|
|
15433
|
+
}
|
|
15434
|
+
instance.#_aCyzDK9TkXtLxrZs7JC8emuYisv_satisfies = _aCyzDK9TkXtLxrZs7JC8emuYisv_satisfies;
|
|
15435
|
+
const _2dLfqTbbRiggEcMQWbHpxkQrtmrc_resourceQuantity = [];
|
|
15436
|
+
let _2dLfqTbbRiggEcMQWbHpxkQrtmrc_resourceQuantity__array = values["https://w3id.org/valueflows/ont/vf#resourceQuantity"];
|
|
15437
|
+
for (const v of _2dLfqTbbRiggEcMQWbHpxkQrtmrc_resourceQuantity__array == null ? [] : _2dLfqTbbRiggEcMQWbHpxkQrtmrc_resourceQuantity__array.length === 1 && "@list" in _2dLfqTbbRiggEcMQWbHpxkQrtmrc_resourceQuantity__array[0] ? _2dLfqTbbRiggEcMQWbHpxkQrtmrc_resourceQuantity__array[0]["@list"] : _2dLfqTbbRiggEcMQWbHpxkQrtmrc_resourceQuantity__array) {
|
|
15438
|
+
if (v == null) continue;
|
|
15439
|
+
const decoded = await Measure.fromJsonLd(v, {
|
|
15440
|
+
...options,
|
|
15441
|
+
baseUrl: options.baseUrl
|
|
15442
|
+
});
|
|
15443
|
+
if (typeof decoded === "undefined") continue;
|
|
15444
|
+
_2dLfqTbbRiggEcMQWbHpxkQrtmrc_resourceQuantity.push(decoded);
|
|
15445
|
+
}
|
|
15446
|
+
instance.#_2dLfqTbbRiggEcMQWbHpxkQrtmrc_resourceQuantity = _2dLfqTbbRiggEcMQWbHpxkQrtmrc_resourceQuantity;
|
|
15447
|
+
if (!("_fromSubclass" in options) || !options._fromSubclass) try {
|
|
15448
|
+
instance._cachedJsonLd = structuredClone(json);
|
|
15449
|
+
} catch {
|
|
15450
|
+
getLogger(["fedify", "vocab"]).warn("Failed to cache JSON-LD: {json}", { json });
|
|
15451
|
+
}
|
|
15452
|
+
return instance;
|
|
15453
|
+
}
|
|
15454
|
+
_getCustomInspectProxy() {
|
|
15455
|
+
const proxy = {};
|
|
15456
|
+
if (this.id != null) proxy.id = {
|
|
15457
|
+
[Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(this.id.href, options),
|
|
15458
|
+
[Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(this.id.href, options)
|
|
15459
|
+
};
|
|
15460
|
+
const _aCyzDK9TkXtLxrZs7JC8emuYisv_satisfies = this.#_aCyzDK9TkXtLxrZs7JC8emuYisv_satisfies.map((v) => v instanceof URL ? {
|
|
15461
|
+
[Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
|
|
15462
|
+
[Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options)
|
|
15463
|
+
} : v);
|
|
15464
|
+
if (_aCyzDK9TkXtLxrZs7JC8emuYisv_satisfies.length == 1) proxy.satisfies = _aCyzDK9TkXtLxrZs7JC8emuYisv_satisfies[0];
|
|
15465
|
+
const _2dLfqTbbRiggEcMQWbHpxkQrtmrc_resourceQuantity = this.#_2dLfqTbbRiggEcMQWbHpxkQrtmrc_resourceQuantity.map((v) => v instanceof URL ? {
|
|
15466
|
+
[Symbol.for("Deno.customInspect")]: (inspect, options) => "URL " + inspect(v.href, options),
|
|
15467
|
+
[Symbol.for("nodejs.util.inspect.custom")]: (_depth, options, inspect) => "URL " + inspect(v.href, options)
|
|
15468
|
+
} : v);
|
|
15469
|
+
if (_2dLfqTbbRiggEcMQWbHpxkQrtmrc_resourceQuantity.length == 1) proxy.resourceQuantity = _2dLfqTbbRiggEcMQWbHpxkQrtmrc_resourceQuantity[0];
|
|
15470
|
+
return proxy;
|
|
15471
|
+
}
|
|
15472
|
+
};
|
|
15473
|
+
Commitment.prototype[Symbol.for("Deno.customInspect")] = function(inspect, options) {
|
|
15474
|
+
return "Commitment " + inspect(this._getCustomInspectProxy(), options);
|
|
15475
|
+
};
|
|
15476
|
+
Commitment.prototype[Symbol.for("nodejs.util.inspect.custom")] = function(_depth, options, inspect) {
|
|
15477
|
+
return "Commitment " + inspect(this._getCustomInspectProxy(), options);
|
|
15478
|
+
};
|
|
14859
15479
|
/** A proposed economic transaction describing what is being offered or requested
|
|
14860
15480
|
* in a {@link Proposal}.
|
|
14861
15481
|
*/
|
|
@@ -23335,6 +23955,7 @@ var Collection = class Collection extends Object$1 {
|
|
|
23335
23955
|
"https://gotosocial.org/ns#LikeApproval",
|
|
23336
23956
|
"https://gotosocial.org/ns#ReplyAuthorization",
|
|
23337
23957
|
"https://w3id.org/fep/044f#QuoteAuthorization",
|
|
23958
|
+
"https://w3id.org/valueflows/ont/vf#Agreement",
|
|
23338
23959
|
"https://w3id.org/valueflows/ont/vf#Proposal",
|
|
23339
23960
|
"https://www.w3.org/ns/activitystreams#Activity",
|
|
23340
23961
|
"http://litepub.social/ns#EmojiReact",
|
|
@@ -29809,6 +30430,7 @@ var Link = class Link {
|
|
|
29809
30430
|
"https://gotosocial.org/ns#LikeApproval",
|
|
29810
30431
|
"https://gotosocial.org/ns#ReplyAuthorization",
|
|
29811
30432
|
"https://w3id.org/fep/044f#QuoteAuthorization",
|
|
30433
|
+
"https://w3id.org/valueflows/ont/vf#Agreement",
|
|
29812
30434
|
"https://w3id.org/valueflows/ont/vf#Proposal",
|
|
29813
30435
|
"https://www.w3.org/ns/activitystreams#Activity",
|
|
29814
30436
|
"http://litepub.social/ns#EmojiReact",
|
|
@@ -32474,6 +33096,7 @@ var OrderedCollection = class OrderedCollection extends Collection {
|
|
|
32474
33096
|
"https://gotosocial.org/ns#LikeApproval",
|
|
32475
33097
|
"https://gotosocial.org/ns#ReplyAuthorization",
|
|
32476
33098
|
"https://w3id.org/fep/044f#QuoteAuthorization",
|
|
33099
|
+
"https://w3id.org/valueflows/ont/vf#Agreement",
|
|
32477
33100
|
"https://w3id.org/valueflows/ont/vf#Proposal",
|
|
32478
33101
|
"https://www.w3.org/ns/activitystreams#Activity",
|
|
32479
33102
|
"http://litepub.social/ns#EmojiReact",
|
|
@@ -32987,6 +33610,7 @@ var OrderedCollectionPage = class OrderedCollectionPage extends CollectionPage {
|
|
|
32987
33610
|
"https://gotosocial.org/ns#LikeApproval",
|
|
32988
33611
|
"https://gotosocial.org/ns#ReplyAuthorization",
|
|
32989
33612
|
"https://w3id.org/fep/044f#QuoteAuthorization",
|
|
33613
|
+
"https://w3id.org/valueflows/ont/vf#Agreement",
|
|
32990
33614
|
"https://w3id.org/valueflows/ont/vf#Proposal",
|
|
32991
33615
|
"https://www.w3.org/ns/activitystreams#Activity",
|
|
32992
33616
|
"http://litepub.social/ns#EmojiReact",
|
|
@@ -48092,6 +48716,7 @@ const entityTypeSet = new Set([
|
|
|
48092
48716
|
DataIntegrityProof,
|
|
48093
48717
|
CryptographicKey,
|
|
48094
48718
|
Multikey,
|
|
48719
|
+
Agreement,
|
|
48095
48720
|
Proposal,
|
|
48096
48721
|
Accept,
|
|
48097
48722
|
Add,
|
|
@@ -48163,6 +48788,7 @@ const entityTypeIds = new Map([
|
|
|
48163
48788
|
["https://w3id.org/security#DataIntegrityProof", DataIntegrityProof],
|
|
48164
48789
|
["https://w3id.org/security#Key", CryptographicKey],
|
|
48165
48790
|
["https://w3id.org/security#Multikey", Multikey],
|
|
48791
|
+
["https://w3id.org/valueflows/ont/vf#Agreement", Agreement],
|
|
48166
48792
|
["https://w3id.org/valueflows/ont/vf#Proposal", Proposal],
|
|
48167
48793
|
["https://www.w3.org/ns/activitystreams#Accept", Accept],
|
|
48168
48794
|
["https://www.w3.org/ns/activitystreams#Add", Add],
|
|
@@ -48706,4 +49332,4 @@ async function* traverseCollection(collection, options = {}) {
|
|
|
48706
49332
|
}
|
|
48707
49333
|
}
|
|
48708
49334
|
//#endregion
|
|
48709
|
-
export { Accept, Activity, Add, Announce, AnnounceAuthorization, AnnounceRequest, Application, Arrive, Article, Audio, Block, ChatMessage, Collection, CollectionPage, Create, CryptographicKey, DataIntegrityProof, Delete, DidService, Dislike, Document, Emoji, EmojiReact, Endpoints, Event, Export, Flag, Follow, Group, Hashtag, Ignore, Image, Intent, InteractionPolicy, InteractionRule, IntransitiveActivity, Invite, Join, LanguageString, Leave, Like, LikeAuthorization, LikeRequest, Link, Listen, Measure, Mention, Move, Multikey, Note, Object$1 as Object, Offer, OrderedCollection, OrderedCollectionPage, Organization, PUBLIC_COLLECTION, Page, Person, Place, Profile, PropertyValue, Proposal, Question, QuoteAuthorization, QuoteRequest, Read, Reject, Relationship, Remove, ReplyAuthorization, ReplyRequest, Service, Source, TentativeAccept, TentativeReject, Tombstone, Travel, Undo, Update, Video, View, getActorClassByTypeName, getActorHandle, getActorTypeName, getEntityTypeById, getTypeId, isActor, isEntityType, isFediverseHandle, lookupObject, normalizeActorHandle, normalizeLinkToImage, parseFediverseHandle, toAcctUrl, traverseCollection };
|
|
49335
|
+
export { Accept, Activity, Add, Agreement, Announce, AnnounceAuthorization, AnnounceRequest, Application, Arrive, Article, Audio, Block, ChatMessage, Collection, CollectionPage, Commitment, Create, CryptographicKey, DataIntegrityProof, Delete, DidService, Dislike, Document, Emoji, EmojiReact, Endpoints, Event, Export, Flag, Follow, Group, Hashtag, Ignore, Image, Intent, InteractionPolicy, InteractionRule, IntransitiveActivity, Invite, Join, LanguageString, Leave, Like, LikeAuthorization, LikeRequest, Link, Listen, Measure, Mention, Move, Multikey, Note, Object$1 as Object, Offer, OrderedCollection, OrderedCollectionPage, Organization, PUBLIC_COLLECTION, Page, Person, Place, Profile, PropertyValue, Proposal, Question, QuoteAuthorization, QuoteRequest, Read, Reject, Relationship, Remove, ReplyAuthorization, ReplyRequest, Service, Source, TentativeAccept, TentativeReject, Tombstone, Travel, Undo, Update, Video, View, getActorClassByTypeName, getActorHandle, getActorTypeName, getEntityTypeById, getTypeId, isActor, isEntityType, isFediverseHandle, lookupObject, normalizeActorHandle, normalizeLinkToImage, parseFediverseHandle, toAcctUrl, traverseCollection };
|