diff --git a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-organization-item-element.ts b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-organization-item-element.ts index 6db8b90fd26..53b1cf19ff9 100644 --- a/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-organization-item-element.ts +++ b/apps/server/src/modules/learnroom/common-cartridge/common-cartridge-organization-item-element.ts @@ -8,10 +8,46 @@ export type ICommonCartridgeOrganizationProps = { version: string; } & ({ children: ICommonCartridgeOrganizationProps[] } | { resources: ICommonCartridgeResourceProps[] }); +type OrganizationItemCollection = { + title: string; + children: OrganizationItemCollection[] | OrganizationResourceCollection; + _tag: 'itemCollection'; +}; + +type OrganizationResourceCollection = { + identifier: string; + title: string; + version: string; + resources: ICommonCartridgeResourceProps[]; + _tag: 'resourceCollection'; +}; + +export type CommonCartridgeOrganizationItemElementProps = OrganizationItemCollection | OrganizationResourceCollection; + +function isOrganizationItemCollection( + item: CommonCartridgeOrganizationItemElementProps +): item is OrganizationItemCollection { + return item._tag === 'itemCollection'; +} + +function isOrganizationResourceCollection( + item: CommonCartridgeOrganizationItemElementProps +): item is OrganizationResourceCollection { + return item._tag === 'resourceCollection'; +} + export class CommonCartridgeOrganizationItemElement implements ICommonCartridgeElement { - constructor(private readonly props: ICommonCartridgeOrganizationProps) {} + constructor(private readonly props: CommonCartridgeOrganizationItemElementProps) {} transform(): Record { + if (isOrganizationItemCollection(this.props)) { + return {}; + } + + if (isOrganizationResourceCollection(this.props)) { + return {}; + } + return { $: { identifier: this.props.identifier,