Mari's guided journal software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
mari-guided-journal/src/datatypes/GuidedEmpathy.ts

52 lines
2.3 KiB

import {isPopulatedArray} from "../utils/Arrays.js";
import {
Persona,
personaName,
personaPronoun,
personaPronounObject,
personaPronounPossessive,
personaVerb
} from "./Persona.js";
import chalk from "chalk";
import {schema} from "../schemata/SchemaData.js";
import capitalize from "capitalize";
export interface GuidedEmpathy {
readonly feelings?: readonly string[]
readonly needs?: readonly string[]
readonly events?: readonly string[]
readonly requests?: readonly string[]
}
export type GuidedEmpathyJTD = typeof GuidedEmpathyJTD
export const GuidedEmpathyJTD = schema({
schema: {
optionalProperties: {
feelings: { elements: { type: "string" } },
needs: { elements: { type: "string" } },
events: { elements: { type: "string" } },
requests: { elements: { type: "string" } },
}
},
typeHint: null as GuidedEmpathy|null,
key: "guidedEmpathy",
references: [],
})
export function isPopulatedGuidedEmpathy(empathy: GuidedEmpathy | undefined): boolean {
return !!empathy && (isPopulatedArray(empathy.feelings)
|| isPopulatedArray(empathy.needs)
|| isPopulatedArray(empathy.events)
|| isPopulatedArray(empathy.requests))
}
export function guidedEmpathyToString(empathy: GuidedEmpathy, persona: Persona | undefined): string {
return (`${(capitalize(personaName(persona), true))} ${personaVerb(persona, "feel", "feels")}: ${empathy.feelings?.join(", ") || chalk.dim("(???)")}...\n`
+ `Because ${personaPronoun(persona)} ${personaVerb(persona, "need", "needs")}: ${empathy.needs?.join(", ") || chalk.dim("(???)")}...\n`
+ `And ${personaPronounPossessive(persona)} needs were affected when: ${empathy.events?.join("; ") || chalk.dim("(???)")}...\n`
+ `So to get good outcomes for ${personaPronounObject(persona)} in the future, can we try: ${empathy.requests?.join("; ") || chalk.dim("(???)")}?`)
}
export function guidedEmpathyToStringShort(empathy: GuidedEmpathy): string {
return `Feeling ${empathy.feelings?.join(", ") || chalk.dim("(none)")} // Because ${empathy.needs?.join(", ") || chalk.dim("(none)")} // When ${empathy.events?.join("; ") || chalk.dim("(none)")} // So ${empathy.requests?.join("; ") || chalk.dim("(none)")}`
}