@@ -24,12 +24,19 @@ abstract class BomLinkBase implements Stringable, Comparable<Stringable> {
2424 /* @ts -expect-error TS2564 */
2525 #value: string
2626
27+ /** @internal */
2728 protected abstract _isValid ( value : any ) : boolean
2829
30+ /**
31+ * @throws {@link RangeError } if value is invalid
32+ */
2933 constructor ( value : string ) {
3034 this . value = value
3135 }
3236
37+ /**
38+ * @throws {@link RangeError } if value is invalid
39+ */
3340 set value ( value : string ) {
3441 if ( ! this . _isValid ( value ) ) {
3542 throw new RangeError ( 'invalid value' )
@@ -51,41 +58,54 @@ abstract class BomLinkBase implements Stringable, Comparable<Stringable> {
5158}
5259
5360/**
61+ * Descriptor for another BOM document.
62+ *
5463 * See [the docs](https://cyclonedx.org/capabilities/bomlink/)
5564 */
5665export class BomLinkDocument extends BomLinkBase {
5766 /* regular expressions were taken from the CycloneDX schema definitions. */
5867 static #pattern = / ^ u r n : c d x : [ 0 - 9 a - f ] { 8 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 12 } \/ [ 1 - 9 ] [ 0 - 9 ] * $ /
5968
69+ /**
70+ * Whether the `value` is a valid descriptor for another BOM document.
71+ */
6072 static isValid ( value : any ) : boolean {
6173 return typeof value === 'string' &&
62- BomLinkDocument . #pattern. test ( value )
74+ this . #pattern. test ( value )
6375 }
6476
77+ /** @internal */
6578 protected _isValid ( value : any ) : boolean {
6679 return BomLinkDocument . isValid ( value )
6780 }
6881}
6982
7083/**
84+ * Descriptor for an element in a BOM document.
85+ *
7186 * See [the docs](https://cyclonedx.org/capabilities/bomlink/)
7287 */
7388export class BomLinkElement extends BomLinkBase {
7489 /* regular expressions were taken from the CycloneDX schema definitions. */
7590 static #pattern = / ^ u r n : c d x : [ 0 - 9 a - f ] { 8 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 12 } \/ [ 1 - 9 ] [ 0 - 9 ] * # .+ $ /
7691
92+ /**
93+ * Whether the `value` is a valid descriptor for an element in a BOM document.
94+ */
7795 static isValid ( value : any ) : boolean {
7896 return typeof value === 'string' &&
79- BomLinkElement . #pattern. test ( value )
97+ this . #pattern. test ( value )
8098 }
8199
100+ /** @internal */
82101 protected _isValid ( value : any ) : boolean {
83102 return BomLinkElement . isValid ( value )
84103 }
85104}
86105
87106/**
107+ * Either {@link BomLinkDocument} or {@link BomLinkElement}.
108+ *
88109 * See [the docs](https://cyclonedx.org/capabilities/bomlink/)
89- * @see {@link isBomLink }
90110 */
91111export type BomLink = BomLinkDocument | BomLinkElement
0 commit comments