Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wet-rice-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@learncard/vc-templates-plugin": patch
---

[LC-1350] - Add OBv3 Support to Boost Templates: evidence, alignment, source
12 changes: 12 additions & 0 deletions packages/plugins/vc-templates/src/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ export const VC_TEMPLATES: {
familyTitles,
skills,
groupID = '',
evidence,
alignment,
source,
} = {},
crypto
) => ({
Expand Down Expand Up @@ -146,8 +149,11 @@ export const VC_TEMPLATES: {
criteria: {
narrative: achievementNarrative,
},
...(alignment && { alignment }),
},
...(source && { source }),
Comment on lines +152 to +154
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐞 Bug - Empty Object Spreading: Add checks to ensure alignment and source objects have meaningful content before spreading them, similar to the evidence array check that verifies both existence and length.

Suggested change
...(alignment && { alignment }),
},
...(source && { source }),
...(alignment && Object.keys(alignment).length > 0 && { alignment }),
},
...(source && Object.keys(source).length > 0 && { source }),

},
...(Array.isArray(evidence) && evidence.length > 0 && { evidence }),
display,
familyTitles,
image: boostImage,
Expand Down Expand Up @@ -176,6 +182,9 @@ export const VC_TEMPLATES: {
familyTitles,
boostID,
groupID = '',
evidence,
alignment,
source,
} = {},
crypto
) => ({
Expand Down Expand Up @@ -204,8 +213,11 @@ export const VC_TEMPLATES: {
criteria: {
narrative: achievementNarrative,
},
...(alignment && { alignment }),
},
...(source && { source }),
},
...(Array.isArray(evidence) && evidence.length > 0 && { evidence }),
...(address
? {
address: {
Expand Down
36 changes: 36 additions & 0 deletions packages/plugins/vc-templates/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -101,6 +134,9 @@ export type BoostTemplate = {
boostID?: BoostID;
address?: AddressSpec;
groupID?: string;
evidence?: Evidence[];
alignment?: Alignment[];
source?: Source;
};

/** @group VC Templates Plugin */
Expand Down
Loading