diff --git a/.changeset/wet-rice-tie.md b/.changeset/wet-rice-tie.md new file mode 100644 index 0000000000..d1b18310ed --- /dev/null +++ b/.changeset/wet-rice-tie.md @@ -0,0 +1,5 @@ +--- +"@learncard/vc-templates-plugin": patch +--- + +[LC-1350] - Add OBv3 Support to Boost Templates: evidence, alignment, source diff --git a/packages/plugins/vc-templates/src/templates.ts b/packages/plugins/vc-templates/src/templates.ts index ecf6e36e7f..2b25da6e17 100644 --- a/packages/plugins/vc-templates/src/templates.ts +++ b/packages/plugins/vc-templates/src/templates.ts @@ -119,6 +119,9 @@ export const VC_TEMPLATES: { familyTitles, skills, groupID = '', + evidence, + alignment, + source, } = {}, crypto ) => ({ @@ -146,8 +149,11 @@ export const VC_TEMPLATES: { criteria: { narrative: achievementNarrative, }, + ...(alignment && { alignment }), }, + ...(source && { source }), }, + ...(Array.isArray(evidence) && evidence.length > 0 && { evidence }), display, familyTitles, image: boostImage, @@ -176,6 +182,9 @@ export const VC_TEMPLATES: { familyTitles, boostID, groupID = '', + evidence, + alignment, + source, } = {}, crypto ) => ({ @@ -204,8 +213,11 @@ export const VC_TEMPLATES: { criteria: { narrative: achievementNarrative, }, + ...(alignment && { alignment }), }, + ...(source && { source }), }, + ...(Array.isArray(evidence) && evidence.length > 0 && { evidence }), ...(address ? { address: { diff --git a/packages/plugins/vc-templates/src/types.ts b/packages/plugins/vc-templates/src/types.ts index 1f4b1f5c14..dbdda4263d 100644 --- a/packages/plugins/vc-templates/src/types.ts +++ b/packages/plugins/vc-templates/src/types.ts @@ -80,6 +80,39 @@ export type AddressSpec = { longitude?: number | undefined; }; }; + +export type Source = { + type: string[]; + id?: string; + name?: string; + description?: string; + url?: string; + image?: string; + address?: { + type?: string[]; + addressLocality?: string; + addressRegion?: string; + addressCountry?: string; + }; +}; + +export type Alignment = { + type: string[]; + targetName?: string; // https://purl.imsglobal.org/spec/vc/ob/vocab.html#targetName + targetType?: string; // https://purl.imsglobal.org/spec/vc/ob/vocab.html#targetType + targetFramework?: string; // https://purl.imsglobal.org/spec/vc/ob/vocab.html#targetFramework +}; + +export interface Evidence { + id?: string; + type: [string, ...string[]]; // Changed from string[] to ensure at least one element + name?: string; + narrative?: string; + description?: string; + genre?: string; + audience?: string; +} + export type BoostTemplate = { did?: string; subject?: string; @@ -101,6 +134,9 @@ export type BoostTemplate = { boostID?: BoostID; address?: AddressSpec; groupID?: string; + evidence?: Evidence[]; + alignment?: Alignment[]; + source?: Source; }; /** @group VC Templates Plugin */