Skip to content

feat: templated external links (draft) #2012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
25 changes: 23 additions & 2 deletions src/datasets/dto/output-dataset.dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { ApiProperty, PartialType } from "@nestjs/swagger";
import { ApiProperty, getSchemaPath, PartialType } from "@nestjs/swagger";
import { CreateDatasetDto } from "./create-dataset.dto";
import { IsDateString, IsString } from "class-validator";
import { Type } from "class-transformer";
import {
IsArray,
IsDateString,
IsOptional,
IsString,
ValidateNested,
} from "class-validator";
import { ExternalLinkClass } from "../schemas/externallink.class";

export class OutputDatasetDto extends CreateDatasetDto {
@ApiProperty({
Expand Down Expand Up @@ -39,6 +47,19 @@ export class OutputDatasetDto extends CreateDatasetDto {
@IsDateString()
updatedAt: Date;

@ApiProperty({
type: "array",
items: { $ref: getSchemaPath(ExternalLinkClass) },
required: false,
default: [],
description: "List of external links that involve this data set.",
})
@IsArray()
@IsOptional()
@ValidateNested({ each: true })
@Type(() => ExternalLinkClass)
readonly externalLinks?: ExternalLinkClass[];

@ApiProperty({
type: String,
required: true,
Expand Down
27 changes: 27 additions & 0 deletions src/datasets/schemas/externallink.class.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { ApiProperty } from "@nestjs/swagger";

// This data is not represented in Mongoose.
// It is generated internally based on the user-defined link templates.

export class ExternalLinkClass {
@ApiProperty({
type: String,
required: true,
description: "URL of the external link.",
})
url: string;

@ApiProperty({
type: String,
required: true,
description: "Text to display representing the external link.",
})
title: string;

@ApiProperty({
type: String,
required: false,
description: "Description of the link destination.",
})
description?: string;
}
Loading