From bf32ae795be43d8006f3c7b3febede7aac5aea94 Mon Sep 17 00:00:00 2001 From: Garrett Birkel Date: Tue, 24 Jun 2025 14:28:54 -0700 Subject: [PATCH 1/2] Draft API field for an external links list. --- src/datasets/dto/update-dataset.dto.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/datasets/dto/update-dataset.dto.ts b/src/datasets/dto/update-dataset.dto.ts index 8548647e7..f2cd49e06 100644 --- a/src/datasets/dto/update-dataset.dto.ts +++ b/src/datasets/dto/update-dataset.dto.ts @@ -239,6 +239,19 @@ export class UpdateDatasetDto extends OwnableDto { }) readonly sharedWith?: string[]; + @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(() => ExternalLinkDto) + readonly externalLinks?: ExternalLinkClass[]; + // it needs to be discussed if this fields is managed by the user or by the system @ApiProperty({ type: RelationshipClass, From 7f40649d82cf9c738af9f405de9cadb11522b213 Mon Sep 17 00:00:00 2001 From: Garrett Birkel Date: Wed, 25 Jun 2025 12:27:21 -0700 Subject: [PATCH 2/2] Moving external links property to 'output' version of dataset DTO, since it's neither created nor updated. Adding a class to define it. --- src/datasets/dto/output-dataset.dto.ts | 25 ++++++++++++++++++-- src/datasets/dto/update-dataset.dto.ts | 13 ----------- src/datasets/schemas/externallink.class.ts | 27 ++++++++++++++++++++++ 3 files changed, 50 insertions(+), 15 deletions(-) create mode 100644 src/datasets/schemas/externallink.class.ts diff --git a/src/datasets/dto/output-dataset.dto.ts b/src/datasets/dto/output-dataset.dto.ts index 0a507d395..052bb1008 100644 --- a/src/datasets/dto/output-dataset.dto.ts +++ b/src/datasets/dto/output-dataset.dto.ts @@ -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({ @@ -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, diff --git a/src/datasets/dto/update-dataset.dto.ts b/src/datasets/dto/update-dataset.dto.ts index f2cd49e06..8548647e7 100644 --- a/src/datasets/dto/update-dataset.dto.ts +++ b/src/datasets/dto/update-dataset.dto.ts @@ -239,19 +239,6 @@ export class UpdateDatasetDto extends OwnableDto { }) readonly sharedWith?: string[]; - @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(() => ExternalLinkDto) - readonly externalLinks?: ExternalLinkClass[]; - // it needs to be discussed if this fields is managed by the user or by the system @ApiProperty({ type: RelationshipClass, diff --git a/src/datasets/schemas/externallink.class.ts b/src/datasets/schemas/externallink.class.ts new file mode 100644 index 000000000..3d2420b45 --- /dev/null +++ b/src/datasets/schemas/externallink.class.ts @@ -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; +}