Skip to content

dont use internal types/classes in public API #1202

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

Merged
merged 1 commit into from
Jan 9, 2025
Merged
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
10 changes: 10 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ All notable changes to this project will be documented in this file.

<!-- add unreleased items here -->

* Added
* New type `Models.Copyright` and class `Models.CopyrightRepository` (via [#1202])
* New type `Models.AttachmentContent` (via [#1202])
* Changed
* Replace usage of internals `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
Expand Down
4 changes: 3 additions & 1 deletion src/models/attachment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}) {
Expand Down
11 changes: 6 additions & 5 deletions src/models/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -61,7 +62,7 @@ export class Component implements Comparable<Component> {
type: ComponentType
name: string
author?: string
copyright?: Stringable
copyright?: Copyright
description?: string
externalReferences: ExternalReferenceRepository
group?: string
Expand Down Expand Up @@ -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()
}
}
26 changes: 26 additions & 0 deletions src/models/copyright.ts
Original file line number Diff line number Diff line change
@@ -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<Copyright> {}
1 change: 1 addition & 0 deletions src/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Loading