Skip to content

Commit 8932743

Browse files
authored
dont use internal types/classes in public API (#1202)
fixes #1192 since these classes were never public, it is just non-breaking to use public type-aliases instead. Signed-off-by: Jan Kowalleck <[email protected]>
1 parent 0e4e14f commit 8932743

File tree

5 files changed

+46
-6
lines changed

5 files changed

+46
-6
lines changed

HISTORY.md

+10
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ All notable changes to this project will be documented in this file.
66

77
<!-- add unreleased items here -->
88

9+
* Added
10+
* New type `Models.Copyright` and class `Models.CopyrightRepository` (via [#1202])
11+
* New type `Models.AttachmentContent` (via [#1202])
12+
* Changed
13+
* Replace usage of internals `Stringable` &`SortableStringables` with public aliases API ([#1192] via [#1202])
14+
This is considered a non-breaking change, as the types are not changed, but made publicly available.
15+
16+
[#1192]: https://github.com/CycloneDX/cyclonedx-javascript-library/issues/1192
17+
[#1202]: https://github.com/CycloneDX/cyclonedx-javascript-library/pull/1202
18+
919
## 7.0.0 -- 2024-11-26
1020

1121
* BREAKING changes

src/models/attachment.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ export interface OptionalAttachmentProperties {
2525
encoding?: Attachment['encoding']
2626
}
2727

28+
export type AttachmentContent = Stringable
29+
2830
export class Attachment {
2931
contentType?: string
30-
content: Stringable
32+
content: AttachmentContent
3133
encoding?: AttachmentEncoding
3234

3335
constructor (content: Attachment['content'], op: OptionalAttachmentProperties = {}) {

src/models/component.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
2020
import type { PackageURL } from 'packageurl-js'
2121

2222
import type { Comparable } from '../_helpers/sortable'
23-
import { SortableComparables, SortableStringables } from '../_helpers/sortable'
24-
import type { Stringable } from '../_helpers/stringable'
23+
import { SortableComparables } from '../_helpers/sortable'
2524
import { treeIteratorSymbol } from '../_helpers/tree'
2625
import type { ComponentScope, ComponentType } from '../enums'
2726
import type { CPE } from '../types/cpe'
2827
import { isCPE } from '../types/cpe'
2928
import { BomRef, BomRefRepository } from './bomRef'
29+
import type { Copyright } from './copyright'
30+
import { CopyrightRepository} from './copyright'
3031
import { ExternalReferenceRepository } from './externalReference'
3132
import { HashDictionary } from './hash'
3233
import { LicenseRepository } from './license'
@@ -61,7 +62,7 @@ export class Component implements Comparable<Component> {
6162
type: ComponentType
6263
name: string
6364
author?: string
64-
copyright?: Stringable
65+
copyright?: Copyright
6566
description?: string
6667
externalReferences: ExternalReferenceRepository
6768
group?: string
@@ -167,10 +168,10 @@ export interface OptionalComponentEvidenceProperties {
167168

168169
export class ComponentEvidence {
169170
licenses: LicenseRepository
170-
copyright: SortableStringables
171+
copyright: CopyrightRepository
171172

172173
constructor (op: OptionalComponentEvidenceProperties = {}) {
173174
this.licenses = op.licenses ?? new LicenseRepository()
174-
this.copyright = op.copyright ?? new SortableStringables()
175+
this.copyright = op.copyright ?? new CopyrightRepository()
175176
}
176177
}

src/models/copyright.ts

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*!
2+
This file is part of CycloneDX JavaScript Library.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
SPDX-License-Identifier: Apache-2.0
17+
Copyright (c) OWASP Foundation. All Rights Reserved.
18+
*/
19+
20+
import { SortableStringables } from '../_helpers/sortable'
21+
import type { Stringable } from '../_helpers/stringable'
22+
23+
export type Copyright = Stringable
24+
25+
/* eslint-disable-next-line @typescript-eslint/no-unnecessary-type-arguments -- for docs reasons */
26+
export class CopyrightRepository extends SortableStringables<Copyright> {}

src/models/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export * from './bom'
2222
export * from './bomLink'
2323
export * from './bomRef'
2424
export * from './component'
25+
export * from './copyright'
2526
export * from './externalReference'
2627
export * from './hash'
2728
export * from './license'

0 commit comments

Comments
 (0)