- const activity = {
- "@context": taggingDiscoveryContext,
- "@type": [
- "TagActivity",
- identifier == null ? "Create" : "Update",
- ],
- context: `${system.iri}`,
- object: `${this.iri}`,
- endTime: new Date().toISOString(),
- ...(() => {
- const statements = {
- unstates: [],
- states: [],
- };
- const { unstates, states } = statements;
- if (identifier == null) {
- // This is a Create activity.
- states.push({ predicate: "a", object: `${this.kind}` });
- } else {
- // This is an Update activity.
- /* do nothing */
- }
- for (
- const [term, {
- old: oldValues,
- new: newValues,
- }] of Object.entries(diffs)
- ) {
- // Iterate over the diffs of each term and state/unstate
- // things as needed.
- for (const oldValue of oldValues) {
- // Iterate over removals and unstate them.
- if (LITERAL_TERMS.has(term)) {
- // This is a literal term; push the change wrapped in an
- // object.
- unstates.push({
- predicate: term,
- object: Object(oldValue) === oldValue
- ? { ...langString(oldValue) }
- : { "@value": `${oldValue}` },
- });
- } else {
- // This is a named term; attempt to get its I·R·I and
- // push it.
- try {
- // Attempt to resolve the value and push the change.
- const tag = storage.get(oldValue);
- if (!this.#isTagInStorage(tag)) {
- // The value did not resolve to a tag in storage.
+ if (silent) {
+ // This is a silent persist.
+ return undefined;
+ } else {
+ // This is not a silent persist; an activity needs to be
+ // generated if a change was made.
+ const activity = {
+ "@context": taggingDiscoveryContext,
+ "@type": [
+ "TagActivity",
+ identifier == null ? "Create" : "Update",
+ ],
+ context: `${system.iri}`,
+ object: `${this.iri}`,
+ endTime: new Date().toISOString(),
+ ...(() => {
+ const statements = {
+ unstates: [],
+ states: [],
+ };
+ const { unstates, states } = statements;
+ if (identifier == null) {
+ // This is a Create activity.
+ states.push({ predicate: "a", object: `${this.kind}` });
+ } else {
+ // This is an Update activity.
+ /* do nothing */
+ }
+ for (
+ const [term, {
+ old: oldValues,
+ new: newValues,
+ }] of Object.entries(diffs)
+ ) {
+ // Iterate over the diffs of each term and state/unstate
+ // things as needed.
+ for (const oldValue of oldValues) {
+ // Iterate over removals and unstate them.
+ if (LITERAL_TERMS.has(term)) {
+ // This is a literal term; push the change wrapped in an
+ // object.
+ unstates.push({
+ predicate: term,
+ object: Object(oldValue) === oldValue
+ ? { ...langString(oldValue) }
+ : { "@value": `${oldValue}` },
+ });
+ } else {
+ // This is a named term; attempt to get its I·R·I and
+ // push it.
+ try {
+ // Attempt to resolve the value and push the change.
+ const tag = storage.get(oldValue);
+ if (!this.#isTagInStorage(tag)) {
+ // The value did not resolve to a tag in storage.
+ /* do nothing */
+ } else {
+ // The value resolved; push its I·R·I.
+ unstates.push({
+ predicate: term,
+ object: tag.iri,
+ });
+ }
+ } catch {
+ // Value resolution failed for some reason; perhaps the
+ // tag was deleted.