diff --git a/HISTORY.md b/HISTORY.md index 5319b41d0..d918c9115 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -6,6 +6,16 @@ All notable changes to this project will be documented in this file. +* Added + * New type `Models.Copyright` and class `Models.CopyrightRepository` (via [#1202]) + * New type `Models.AttachmentContent` (via [#1202]) +* Changed + * Replaced usage of internal types `Stringable`/ `SortableStringables` with public aliases API ([#1192] via [#1202]) + This is considered a non-breaking change, as the types are not changed, but made publicly available. + +[#1192]: https://github.com/CycloneDX/cyclonedx-javascript-library/issues/1192 +[#1202]: https://github.com/CycloneDX/cyclonedx-javascript-library/pull/1202 + ## 7.0.0 -- 2024-11-26 * BREAKING changes diff --git a/src/models/attachment.ts b/src/models/attachment.ts index ab7603214..5ce977fd9 100644 --- a/src/models/attachment.ts +++ b/src/models/attachment.ts @@ -25,9 +25,11 @@ export interface OptionalAttachmentProperties { encoding?: Attachment['encoding'] } +export type AttachmentContent = Stringable + export class Attachment { contentType?: string - content: Stringable + content: AttachmentContent encoding?: AttachmentEncoding constructor (content: Attachment['content'], op: OptionalAttachmentProperties = {}) { diff --git a/src/models/component.ts b/src/models/component.ts index 796436e40..a07c96388 100644 --- a/src/models/component.ts +++ b/src/models/component.ts @@ -20,13 +20,14 @@ Copyright (c) OWASP Foundation. All Rights Reserved. import type { PackageURL } from 'packageurl-js' import type { Comparable } from '../_helpers/sortable' -import { SortableComparables, SortableStringables } from '../_helpers/sortable' -import type { Stringable } from '../_helpers/stringable' +import { SortableComparables } from '../_helpers/sortable' import { treeIteratorSymbol } from '../_helpers/tree' import type { ComponentScope, ComponentType } from '../enums' import type { CPE } from '../types/cpe' import { isCPE } from '../types/cpe' import { BomRef, BomRefRepository } from './bomRef' +import type { Copyright } from './copyright' +import { CopyrightRepository} from './copyright' import { ExternalReferenceRepository } from './externalReference' import { HashDictionary } from './hash' import { LicenseRepository } from './license' @@ -61,7 +62,7 @@ export class Component implements Comparable { type: ComponentType name: string author?: string - copyright?: Stringable + copyright?: Copyright description?: string externalReferences: ExternalReferenceRepository group?: string @@ -167,10 +168,10 @@ export interface OptionalComponentEvidenceProperties { export class ComponentEvidence { licenses: LicenseRepository - copyright: SortableStringables + copyright: CopyrightRepository constructor (op: OptionalComponentEvidenceProperties = {}) { this.licenses = op.licenses ?? new LicenseRepository() - this.copyright = op.copyright ?? new SortableStringables() + this.copyright = op.copyright ?? new CopyrightRepository() } } diff --git a/src/models/copyright.ts b/src/models/copyright.ts new file mode 100644 index 000000000..883e7bc28 --- /dev/null +++ b/src/models/copyright.ts @@ -0,0 +1,26 @@ +/*! +This file is part of CycloneDX JavaScript Library. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +SPDX-License-Identifier: Apache-2.0 +Copyright (c) OWASP Foundation. All Rights Reserved. +*/ + +import { SortableStringables } from '../_helpers/sortable' +import type { Stringable } from '../_helpers/stringable' + +export type Copyright = Stringable + +/* eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments -- for docs reasons */ +export class CopyrightRepository extends SortableStringables {} diff --git a/src/models/index.ts b/src/models/index.ts index ad508c0ab..d55989e73 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -22,6 +22,7 @@ export * from './bom' export * from './bomLink' export * from './bomRef' export * from './component' +export * from './copyright' export * from './externalReference' export * from './hash' export * from './license'