diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 11da553df..35aaadf10 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -352,6 +352,9 @@ jobs: - name: run example run: node -- 'example.${{ matrix.js-type }}' working-directory: ${{ env.EXAMPLE_DIR }} + - name: run deprecated + run: node -- 'deprecated.${{ matrix.js-type }}' + working-directory: ${{ env.EXAMPLE_DIR }} example-TS: needs: [ 'build' ] diff --git a/HISTORY.md b/HISTORY.md index eb29c9df4..d3235cd3b 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -6,6 +6,17 @@ All notable changes to this project will be documented in this file. +* Fixed + * Type declarations for deprecated symbols support usage as types ([#1350] via [#1351]) +* Refactor + * Deprecated symbols turned from re-exports into re-declares (via [#1351]) + Note: this change adds runtime overhead for the sake of documentation. + +[#1350]: https://github.com/CycloneDX/cyclonedx-javascript-library/issues/1350 +[#1351]: https://github.com/CycloneDX/cyclonedx-javascript-library/pull/1351 + +## 9.4.0 -- 2025-12-02 + * Added * New entry points for `/Contrib` and known submodules (via [#1343]) See `package.json::exports` for details. diff --git a/examples/node/javascript/.gitignore b/examples/node/javascript/.gitignore index 2594a7fd7..cb76925c5 100644 --- a/examples/node/javascript/.gitignore +++ b/examples/node/javascript/.gitignore @@ -2,5 +2,8 @@ !/.gitignore !/example.mjs !/example.cjs +!/deprecated.cjs +!/deprecated.mjs !/package.json +!/jsconfig.json !/.npmrc diff --git a/examples/node/javascript/deprecated.cjs b/examples/node/javascript/deprecated.cjs new file mode 100644 index 000000000..c9523545e --- /dev/null +++ b/examples/node/javascript/deprecated.cjs @@ -0,0 +1,57 @@ +/*! +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. +*/ + +/** + * Example showcasing the deprecated symbols still work. + * @see https://github.com/CycloneDX/cyclonedx-javascript-library/issues/1350 + */ + +const fs = require('node:fs') +const path = require('node:path') + +const CDX = require('@cyclonedx/cyclonedx-library') +// full Library is available as `CDX`, now + +const dBU1 = CDX.Utils.BomUtility.randomSerialNumber() +console.log(dBU1) + +const dNU1 = CDX.Utils.NpmjsUtility.defaultRegistryMatcher.test('foo') +const dNU2 = CDX.Utils.NpmjsUtility.parsePackageIntegrity('sha1-aSbRsZT7xze47tUTdW3i/Np+pAg=') +console.log(dNU1, dNU2) + +const dLU1 = new CDX.Utils.LicenseUtility.LicenseEvidenceGatherer({fs, path}) +console.log(dLU1) + +/** @type {CDX.Types.NodePackageJson} */ +const dTnpj1 = {} +// const dTnpj2 =CDX.Types.isNodePackageJson(dTnpj1) +try { CDX.Types.assertNodePackageJson(dTnpj1) } catch { /* pass */ } +console.log(dTnpj1) + +const dF1 = new CDX.Factories.PackageUrlFactory('generic') +const dF2 = new CDX.Factories.LicenseFactory() +console.log(dF1, dF2) + +const dFnpj3 = new CDX.Factories.FromNodePackageJson.PackageUrlFactory('npm') +const dFnpj4 = new CDX.Factories.FromNodePackageJson.ExternalReferenceFactory() +console.log(dFnpj3, dFnpj4) + +const dBnpj1 = new CDX.Builders.FromNodePackageJson.ComponentBuilder(dFnpj4, dF2) +const dBnpj2 = new CDX.Builders.FromNodePackageJson.ToolBuilder(dFnpj4) +console.log(dBnpj1, dBnpj2) diff --git a/examples/node/javascript/deprecated.mjs b/examples/node/javascript/deprecated.mjs new file mode 100644 index 000000000..6dce55e72 --- /dev/null +++ b/examples/node/javascript/deprecated.mjs @@ -0,0 +1,57 @@ +/*! +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. +*/ + +/** + * Example showcasing the deprecated symbols still work. + * @see https://github.com/CycloneDX/cyclonedx-javascript-library/issues/1350 + */ + +import * as fs from 'node:fs' +import * as path from 'node:path' + +import * as CDX from '@cyclonedx/cyclonedx-library' +// full Library is available as `CDX`, now + +const dBU1 = CDX.Utils.BomUtility.randomSerialNumber() +console.log(dBU1) + +const dNU1 = CDX.Utils.NpmjsUtility.defaultRegistryMatcher.test('foo') +const dNU2 = CDX.Utils.NpmjsUtility.parsePackageIntegrity('sha1-aSbRsZT7xze47tUTdW3i/Np+pAg=') +console.log(dNU1, dNU2) + +const dLU1 = new CDX.Utils.LicenseUtility.LicenseEvidenceGatherer({fs, path}) +console.log(dLU1) + +/** @type {CDX.Types.NodePackageJson} */ +const dTnpj1 = {} +// const dTnpj2 =CDX.Types.isNodePackageJson(dTnpj1) +try { CDX.Types.assertNodePackageJson(dTnpj1) } catch { /* pass */ } +console.log(dTnpj1) + +const dF1 = new CDX.Factories.PackageUrlFactory('generic') +const dF2 = new CDX.Factories.LicenseFactory() +console.log(dF1, dF2) + +const dFnpj3 = new CDX.Factories.FromNodePackageJson.PackageUrlFactory('npm') +const dFnpj4 = new CDX.Factories.FromNodePackageJson.ExternalReferenceFactory() +console.log(dFnpj3, dFnpj4) + +const dBnpj1 = new CDX.Builders.FromNodePackageJson.ComponentBuilder(dFnpj4, dF2) +const dBnpj2 = new CDX.Builders.FromNodePackageJson.ToolBuilder(dFnpj4) +console.log(dBnpj1, dBnpj2) diff --git a/examples/node/javascript/jsconfig.json b/examples/node/javascript/jsconfig.json new file mode 100644 index 000000000..28b719e3f --- /dev/null +++ b/examples/node/javascript/jsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "checkJs": true, + "target": "ESNext", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "types": ["node"], + "lib": ["esnext"], + "strict": true + }, + "exclude": ["node_modules"] +} diff --git a/examples/node/javascript/package.json b/examples/node/javascript/package.json index 28458d277..afab53392 100644 --- a/examples/node/javascript/package.json +++ b/examples/node/javascript/package.json @@ -2,11 +2,12 @@ "private": true, "name": "@cyclonedx/cyclonedx-library-examples-node-javascript", "license": "Apache-2.0", + "type": "module", "engines": { "node": ">=20.18.0" }, "dependencies": { - "@cyclonedx/cyclonedx-library": "../../..", + "@cyclonedx/cyclonedx-library": "file:../../..", "xmlbuilder2": "^3.0.2||^4.0.0" }, "optionalDependencies": { @@ -14,5 +15,8 @@ "ajv-formats": "^3.0.1", "ajv-formats-draft2019": "^1.6.1", "libxmljs2": "^0.35||^0.37" + }, + "devDependencies": { + "@types/node": ">=20.18.0" } } diff --git a/examples/node/typescript/example.cjs/package.json b/examples/node/typescript/example.cjs/package.json index d9c1885b5..5531d618b 100644 --- a/examples/node/typescript/example.cjs/package.json +++ b/examples/node/typescript/example.cjs/package.json @@ -23,6 +23,6 @@ "scripts": { "prebuild": "tsc -b --clean", "build": "tsc -b", - "example": "node dist/example.js" + "example": "node dist/example.js && node dist/deprecated.js" } } diff --git a/examples/node/typescript/example.cjs/src/deprecated.ts b/examples/node/typescript/example.cjs/src/deprecated.ts new file mode 100644 index 000000000..9dc930bd6 --- /dev/null +++ b/examples/node/typescript/example.cjs/src/deprecated.ts @@ -0,0 +1,65 @@ +/*! +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. +*/ + +/** + * Example showcasing the deprecated symbols still work. + * @see https://github.com/CycloneDX/cyclonedx-javascript-library/issues/1350 + */ + +import * as fs from 'node:fs' +import * as path from 'node:path' + +import * as CDX from '@cyclonedx/cyclonedx-library' +// full Library is available as `CDX`, now + +const dBU1 = CDX.Utils.BomUtility.randomSerialNumber() +console.log(dBU1) + +const dNU1 = CDX.Utils.NpmjsUtility.defaultRegistryMatcher.test('foo') +const dNU2 = CDX.Utils.NpmjsUtility.parsePackageIntegrity('sha1-aSbRsZT7xze47tUTdW3i/Np+pAg=') +console.log(dNU1, dNU2) + +type dLU1_T = CDX.Utils.LicenseUtility.LicenseEvidenceGatherer +const fsU: CDX.Utils.LicenseUtility.FsUtils = fs +const pathU: CDX.Utils.LicenseUtility.PathUtils = path +const dLU1: dLU1_T = new CDX.Utils.LicenseUtility.LicenseEvidenceGatherer({fs: fsU, path: pathU}) +console.log(dLU1) + +const dTnpj1: CDX.Types.NodePackageJson = {} +// const dTnpj2 =CDX.Types.isNodePackageJson(dTnpj1) +try { CDX.Types.assertNodePackageJson(dTnpj1) } catch { /* pass */ } +console.log(dTnpj1) + +type dF1_T = CDX.Factories.PackageUrlFactory +type dF2_T = CDX.Factories.LicenseFactory +const dF1: dF1_T = new CDX.Factories.PackageUrlFactory('generic') +const dF2: dF2_T = new CDX.Factories.LicenseFactory() +console.log(dF1, dF2) + +type dFnpj3_T = CDX.Factories.FromNodePackageJson.PackageUrlFactory +const dFnpj3: dFnpj3_T = new CDX.Factories.FromNodePackageJson.PackageUrlFactory('npm') +type dFnpj4_T = CDX.Factories.FromNodePackageJson.ExternalReferenceFactory +const dFnpj4: dFnpj4_T = new CDX.Factories.FromNodePackageJson.ExternalReferenceFactory() +console.log(dFnpj3, dFnpj4) + +type dBnpj1_T = CDX.Builders.FromNodePackageJson.ComponentBuilder +const dBnpj1: dBnpj1_T = new CDX.Builders.FromNodePackageJson.ComponentBuilder(dFnpj4, dF2) +type dBnpj2_T = CDX.Builders.FromNodePackageJson.ToolBuilder +const dBnpj2: dBnpj2_T = new CDX.Builders.FromNodePackageJson.ToolBuilder(dFnpj4) +console.log(dBnpj1, dBnpj2) diff --git a/examples/node/typescript/example.cjs/tsconfig.json b/examples/node/typescript/example.cjs/tsconfig.json index 85d4ea238..e459a37b0 100644 --- a/examples/node/typescript/example.cjs/tsconfig.json +++ b/examples/node/typescript/example.cjs/tsconfig.json @@ -3,13 +3,14 @@ "compilerOptions": { "target": "ES2016", "module": "CommonJS", + "moduleResolution": "node", + "types": ["node"], + "lib": ["esnext"], + "sourceMap": true, "outDir": "./dist", "strict": true, "forceConsistentCasingInFileNames": true, "disableSourceOfProjectReferenceRedirect": false, "rootDir": "src" - }, - "files": [ - "./src/example.ts" - ] + } } diff --git a/examples/node/typescript/example.mjs/package.json b/examples/node/typescript/example.mjs/package.json index 742e6753d..6404c5d98 100644 --- a/examples/node/typescript/example.mjs/package.json +++ b/examples/node/typescript/example.mjs/package.json @@ -23,6 +23,6 @@ "scripts": { "prebuild": "tsc -b --clean", "build": "tsc -b", - "example": "node dist/example.js" + "example": "node dist/example.js && node dist/deprecated.js" } } diff --git a/examples/node/typescript/example.mjs/src/deprecated.ts b/examples/node/typescript/example.mjs/src/deprecated.ts new file mode 100644 index 000000000..9dc930bd6 --- /dev/null +++ b/examples/node/typescript/example.mjs/src/deprecated.ts @@ -0,0 +1,65 @@ +/*! +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. +*/ + +/** + * Example showcasing the deprecated symbols still work. + * @see https://github.com/CycloneDX/cyclonedx-javascript-library/issues/1350 + */ + +import * as fs from 'node:fs' +import * as path from 'node:path' + +import * as CDX from '@cyclonedx/cyclonedx-library' +// full Library is available as `CDX`, now + +const dBU1 = CDX.Utils.BomUtility.randomSerialNumber() +console.log(dBU1) + +const dNU1 = CDX.Utils.NpmjsUtility.defaultRegistryMatcher.test('foo') +const dNU2 = CDX.Utils.NpmjsUtility.parsePackageIntegrity('sha1-aSbRsZT7xze47tUTdW3i/Np+pAg=') +console.log(dNU1, dNU2) + +type dLU1_T = CDX.Utils.LicenseUtility.LicenseEvidenceGatherer +const fsU: CDX.Utils.LicenseUtility.FsUtils = fs +const pathU: CDX.Utils.LicenseUtility.PathUtils = path +const dLU1: dLU1_T = new CDX.Utils.LicenseUtility.LicenseEvidenceGatherer({fs: fsU, path: pathU}) +console.log(dLU1) + +const dTnpj1: CDX.Types.NodePackageJson = {} +// const dTnpj2 =CDX.Types.isNodePackageJson(dTnpj1) +try { CDX.Types.assertNodePackageJson(dTnpj1) } catch { /* pass */ } +console.log(dTnpj1) + +type dF1_T = CDX.Factories.PackageUrlFactory +type dF2_T = CDX.Factories.LicenseFactory +const dF1: dF1_T = new CDX.Factories.PackageUrlFactory('generic') +const dF2: dF2_T = new CDX.Factories.LicenseFactory() +console.log(dF1, dF2) + +type dFnpj3_T = CDX.Factories.FromNodePackageJson.PackageUrlFactory +const dFnpj3: dFnpj3_T = new CDX.Factories.FromNodePackageJson.PackageUrlFactory('npm') +type dFnpj4_T = CDX.Factories.FromNodePackageJson.ExternalReferenceFactory +const dFnpj4: dFnpj4_T = new CDX.Factories.FromNodePackageJson.ExternalReferenceFactory() +console.log(dFnpj3, dFnpj4) + +type dBnpj1_T = CDX.Builders.FromNodePackageJson.ComponentBuilder +const dBnpj1: dBnpj1_T = new CDX.Builders.FromNodePackageJson.ComponentBuilder(dFnpj4, dF2) +type dBnpj2_T = CDX.Builders.FromNodePackageJson.ToolBuilder +const dBnpj2: dBnpj2_T = new CDX.Builders.FromNodePackageJson.ToolBuilder(dFnpj4) +console.log(dBnpj1, dBnpj2) diff --git a/examples/node/typescript/example.mjs/tsconfig.json b/examples/node/typescript/example.mjs/tsconfig.json index 04210e251..e528ad96c 100644 --- a/examples/node/typescript/example.mjs/tsconfig.json +++ b/examples/node/typescript/example.mjs/tsconfig.json @@ -3,13 +3,13 @@ "compilerOptions": { "target": "ES2021", "module": "Node16", + "types": ["node"], + "lib": ["esnext"], + "sourceMap": true, "outDir": "./dist", "strict": true, "forceConsistentCasingInFileNames": true, "disableSourceOfProjectReferenceRedirect": false, "rootDir": "src" - }, - "files": [ - "./src/example.ts" - ] + } } diff --git a/package.json b/package.json index 26302877b..c5e4fc746 100644 --- a/package.json +++ b/package.json @@ -137,9 +137,11 @@ ".": { "types": { "browser": "./dist.d/index.web.d.ts", + "node": "./dist.d/index.node.d.ts", "default": "./dist.d/index.node.d.ts" }, "browser": "./dist.web/lib.js", + "node": "./dist.node/index.node.js", "default": "./dist.node/index.node.js" }, "./package.json": "./package.json", diff --git a/src/builders/fromNodePackageJson.node.ts b/src/builders/fromNodePackageJson.node.ts new file mode 100644 index 000000000..9d931195c --- /dev/null +++ b/src/builders/fromNodePackageJson.node.ts @@ -0,0 +1,44 @@ +/*! +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. +*/ + +/** + * Node-specifics. + * + * Intended to run on normalized data structures + * based on [PackageJson spec](https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/package.json) + * and explained by [PackageJson description](https://docs.npmjs.com/cli/v9/configuring-npm/package-json). + * Normalization should be done downstream, for example via [`normalize-package-data`](https://www.npmjs.com/package/normalize-package-data). + */ + +import {ComponentBuilder as _ComponentBuilder, ToolBuilder as _ToolBuilder} from '../contrib/fromNodePackageJson/builders' + + +/** + * Deprecated — Alias of {@link Contrib.FromNodePackageJson.Builders.ToolBuilder}. + * + * @deprecated Use `Contrib.FromNodePackageJson.Builders.ToolBuilder` instead. + */ +export class ToolBuilder extends _ToolBuilder {} + +/** + * Deprecated — Alias of {@link Contrib.FromNodePackageJson.Builders.ComponentBuilder}. + * + * @deprecated Use `Contrib.FromNodePackageJson.Builders.ComponentBuilder` instead. + */ +export class ComponentBuilder extends _ComponentBuilder {} diff --git a/src/builders/index.node.ts b/src/builders/index.node.ts index 7ce7055ea..966982a9e 100644 --- a/src/builders/index.node.ts +++ b/src/builders/index.node.ts @@ -17,18 +17,5 @@ SPDX-License-Identifier: Apache-2.0 Copyright (c) OWASP Foundation. All Rights Reserved. */ -import * as _FromNodePackageJson from '../contrib/fromNodePackageJson/builders' - - -// region deprecated re-exports - -/** - * Deprecated — Alias of {@link Contrib.FromNodePackageJson.Builders}. - * - * @deprecated This re-export location is deprecated. - * Import `Contrib.FromNodePackageJson.Builders` instead. - * The exported symbol itself is NOT deprecated - only this import path. - */ -export const FromNodePackageJson = _FromNodePackageJson - -// endregion deprecated re-exports +/** @deprecated next */ +export * as FromNodePackageJson from './fromNodePackageJson.node' diff --git a/src/factories/fromNodePackageJson.node.ts b/src/factories/fromNodePackageJson.node.ts new file mode 100644 index 000000000..4e3371d09 --- /dev/null +++ b/src/factories/fromNodePackageJson.node.ts @@ -0,0 +1,34 @@ +/*! +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 { ExternalReferenceFactory as _ExternalReferenceFactory, PackageUrlFactory as _PackageUrlFactory } from '../contrib/fromNodePackageJson/factories' + +/** + * Deprecated — Alias of {@link Contrib.FromNodePackageJson.Factories.ExternalReferenceFactory}. + * + * @deprecated Use `Contrib.FromNodePackageJson.Factories.ExternalReferenceFactory` instead. + */ +export class ExternalReferenceFactory extends _ExternalReferenceFactory {} + +/** + * Deprecated — Alias of {@link Contrib.FromNodePackageJson.Factories.PackageUrlFactory}. + * + * @deprecated Use `Contrib.FromNodePackageJson.Factories.PackageUrlFactory` instead. + */ +export class PackageUrlFactory extends _PackageUrlFactory {} diff --git a/src/factories/index.common.ts b/src/factories/index.common.ts index 5569bc76a..3fc5f7029 100644 --- a/src/factories/index.common.ts +++ b/src/factories/index.common.ts @@ -17,28 +17,9 @@ SPDX-License-Identifier: Apache-2.0 Copyright (c) OWASP Foundation. All Rights Reserved. */ -import {LicenseFactory as _LicenseFactory} from '../contrib/license/factories' -import {PackageUrlFactory as _PackageUrlFactory} from '../contrib/packageUrl/factories' +// not everything is public, yet - -// region deprecated re-exports - -/** - * Deprecated — Alias of {@link Contrib.License.Factories.LicenseFactory}. - * - * @deprecated This re-export location is deprecated. - * Import `Contrib.License.Factories.LicenseFactory` instead. - * The exported symbol itself is NOT deprecated - only this import path. - */ -export const LicenseFactory = _LicenseFactory - -/** - * Deprecated — Alias of {@link Contrib.PackageUrl.Factories.PackageUrlFactory}. - * - * @deprecated This re-export location is deprecated. - * Import `Contrib.PackageUrl.Factories.PackageUrlFactory` instead. - * The exported symbol itself is NOT deprecated - only this import path. - */ -export const PackageUrlFactory = _PackageUrlFactory - -// endregion deprecated re-exports +/** @deprecated next */ +export * from './license' +/** @deprecated next */ +export * from './packageUrl' diff --git a/src/factories/index.node.ts b/src/factories/index.node.ts index 99f79a102..2df6c8d2a 100644 --- a/src/factories/index.node.ts +++ b/src/factories/index.node.ts @@ -17,23 +17,11 @@ SPDX-License-Identifier: Apache-2.0 Copyright (c) OWASP Foundation. All Rights Reserved. */ -import * as _FromNodePackageJson from '../contrib/fromNodePackageJson/factories' - export * from './index.common' // region node-specifics -// region deprecated re-exports - -/** - * Deprecated — Alias of {@link Contrib.FromNodePackageJson.Factories}. - * - * @deprecated This re-export location is deprecated. - * Import `Contrib.FromNodePackageJson.Factories` instead. - * The exported symbol itself is NOT deprecated - only this import path. - */ -export const FromNodePackageJson = _FromNodePackageJson - -// endregion deprecated re-exports +/** @deprecated next */ +export * as FromNodePackageJson from './fromNodePackageJson.node' // endregion node-specifics diff --git a/src/factories/license.ts b/src/factories/license.ts new file mode 100644 index 000000000..7765ed4fe --- /dev/null +++ b/src/factories/license.ts @@ -0,0 +1,27 @@ +/*! +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 {LicenseFactory as _LicenseFactory} from '../contrib/license/factories' + +/** + * Deprecated — Alias of {@link Contrib.License.Factories.LicenseFactory}. + * + * @deprecated Use `Contrib.License.Factories.LicenseFactory` instead. + */ +export class LicenseFactory extends _LicenseFactory {} diff --git a/src/factories/packageUrl.ts b/src/factories/packageUrl.ts new file mode 100644 index 000000000..c8ed16131 --- /dev/null +++ b/src/factories/packageUrl.ts @@ -0,0 +1,27 @@ +/*! +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 { PackageUrlFactory as _PackageUrlFactory } from '../contrib/packageUrl/factories' + +/** + * Deprecated — Alias of {@link Contrib.PackageUrl.Factories.PackageUrlFactory}. + * + * @deprecated Use `Contrib.PackageUrl.Factories.PackageUrlFactory` instead. + */ +export class PackageUrlFactory extends _PackageUrlFactory {} diff --git a/src/types/index.ts b/src/types/index.ts index 5a9c94979..31d681610 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -32,29 +32,23 @@ export * from './mimeType' // region deprecated re-exports /** - * Deprecated — Alias of {@link Contrib.FromNodePackageJson.Types.NodePackageJson}. + * Deprecated — TypeAlias of {@link Contrib.FromNodePackageJson.Types.NodePackageJson}. * - * @deprecated This re-export location is deprecated. - * Import `Contrib.FromNodePackageJson.Types.NodePackageJson` instead. - * The exported symbol itself is NOT deprecated - only this import path. + * @deprecated Use `Contrib.FromNodePackageJson.Types.NodePackageJson` instead. */ export type NodePackageJson = _NodePackageJson /** * Deprecated — Alias of {@link Contrib.FromNodePackageJson.Types.assertNodePackageJson}. * - * @deprecated This re-export location is deprecated. - * Import `Contrib.FromNodePackageJson.Types.assertNodePackageJson` instead. - * The exported symbol itself is NOT deprecated - only this import path. + * @deprecated Use `Contrib.FromNodePackageJson.Types.assertNodePackageJson` instead. */ export const assertNodePackageJson = _assertNodePackageJson /** * Deprecated — Alias of {@link Contrib.FromNodePackageJson.Types.isNodePackageJson}. * - * @deprecated This re-export location is deprecated. - * Import `Contrib.FromNodePackageJson.Types.isNodePackageJson` instead. - * The exported symbol itself is NOT deprecated - only this import path. + * @deprecated Use `Contrib.FromNodePackageJson.Types.isNodePackageJson` instead. */ export const isNodePackageJson = _isNodePackageJson diff --git a/src/utils/bomUtility.ts b/src/utils/bomUtility.ts new file mode 100644 index 000000000..9222e160a --- /dev/null +++ b/src/utils/bomUtility.ts @@ -0,0 +1,27 @@ +/*! +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 { randomSerialNumber as _randomSerialNumber } from '../contrib/bom/utils' + +/** + * Deprecated — Alias of {@link Contrib.Bom.Utils.randomSerialNumber}. + * + * @deprecated Use `Contrib.Bom.Utils.randomSerialNumber` instead. + */ +export const randomSerialNumber = _randomSerialNumber diff --git a/src/utils/index.common.ts b/src/utils/index.common.ts index 540e99673..f4078895a 100644 --- a/src/utils/index.common.ts +++ b/src/utils/index.common.ts @@ -17,18 +17,5 @@ SPDX-License-Identifier: Apache-2.0 Copyright (c) OWASP Foundation. All Rights Reserved. */ -// region deprecated re-exports - -import * as _BomUtils from '../contrib/bom/utils' - -/** - * Deprecated — Alias of {@link Contrib.Bom.Utils}. - * - * @deprecated This re-export location is deprecated. - * Import `Contrib.Bom.Utils` instead. - * The exported symbol itself is NOT deprecated - only this import path. - */ -export const BomUtility = _BomUtils - -// endregion deprecated re-exports - +/** @deprecated next */ +export * as BomUtility from './bomUtility' diff --git a/src/utils/index.node.ts b/src/utils/index.node.ts index fbd9dbd99..d427df44f 100644 --- a/src/utils/index.node.ts +++ b/src/utils/index.node.ts @@ -17,34 +17,13 @@ SPDX-License-Identifier: Apache-2.0 Copyright (c) OWASP Foundation. All Rights Reserved. */ -import * as _NpmjsUtility from '../contrib/fromNodePackageJson/utils' -import * as _LicenseUtility from '../contrib/license/utils.node' - - export * from './index.common' // region node-specifics -// region deprecated re-exports - -/** - * Deprecated — Alias of {@link Contrib.FromNodePackageJson.Utils}. - * - * @deprecated This re-export location is deprecated. - * Import `Contrib.FromNodePackageJson.Utils` instead. - * The exported symbol itself is NOT deprecated - only this import path. - */ -export const NpmjsUtility = _NpmjsUtility - -/** - * Deprecated — Alias of {@link Contrib.License.Utils}. - * - * @deprecated This re-export location is deprecated. - * Import `Contrib.License.Utils` instead. - * The exported symbol itself is NOT deprecated - only this import path. - */ -export const LicenseUtility = _LicenseUtility - -// endregion deprecated re-exports +/** @deprecated next */ +export * as LicenseUtility from './licenseUtility.node' +/** @deprecated next */ +export * as NpmjsUtility from './npmjsUtility.node' // endregion node-specifics diff --git a/src/utils/licenseUtility.node.ts b/src/utils/licenseUtility.node.ts new file mode 100644 index 000000000..7e31d89ec --- /dev/null +++ b/src/utils/licenseUtility.node.ts @@ -0,0 +1,64 @@ +/*! +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. +*/ + +/** + * This module tries to be as compatible as possible, it only uses basic methods that are known to be working in all FileSystem abstraction-layers. + * In addition, we use type parameters for all `PathLike`s, so downstream users can utilize their implementations accordingly. + * + * @module + */ + +import type { ErrorReporter as _ErrorReporter, FileAttachment as _FileAttachment, FsUtils as _FsUtils, PathUtils as _PathUtils} from '../contrib/license/utils.node'; +import { LicenseEvidenceGatherer as _LicenseEvidenceGatherer } from '../contrib/license/utils.node'; + + +/** + * Deprecated — TypeAlias of {@link Contrib.License.Utils.FsUtils}. + * + * @deprecated Use `Contrib.License.Utils.FsUtils` instead. + */ +export interface FsUtils

extends _FsUtils

{} + +/** + * Deprecated — TypeAlias of {@link Contrib.License.Utils.PathUtils}. + * + * @deprecated Use `Contrib.License.Utils.PathUtils` instead. + */ +export interface PathUtils

extends _PathUtils

{} + +/** + * Deprecated — TypeAlias of {@link Contrib.License.Utils.FileAttachment}. + * + * @deprecated Use `Contrib.License.Utils.FileAttachment` instead. + */ +export interface FileAttachment

extends _FileAttachment

{} + +/** + * Deprecated — TypeAlias of {@link Contrib.License.Utils.ErrorReporter}. + * + * @deprecated Use `Contrib.License.Utils.ErrorReporter` instead. + */ +export type ErrorReporter = _ErrorReporter + +/** + * Deprecated — Alias of {@link Contrib.License.Utils.LicenseEvidenceGatherer}. + * + * @deprecated Use `Contrib.License.Utils.LicenseEvidenceGatherer` instead. + */ +export class LicenseEvidenceGatherer extends _LicenseEvidenceGatherer {} diff --git a/src/utils/npmjsUtility.node.ts b/src/utils/npmjsUtility.node.ts new file mode 100644 index 000000000..0b1fce4f3 --- /dev/null +++ b/src/utils/npmjsUtility.node.ts @@ -0,0 +1,34 @@ +/*! +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 {defaultRegistryMatcher as _defaultRegistryMatcher, parsePackageIntegrity as _parsePackageIntegrity} from '../contrib/fromNodePackageJson/utils' + +/** + * Deprecated — Alias of {@link Contrib.FromNodePackageJson.Utils.parsePackageIntegrity}. + * + * @deprecated Use `Contrib.FromNodePackageJson.Utils.parsePackageIntegrity` instead. + */ +export const parsePackageIntegrity = _parsePackageIntegrity + +/** + * Deprecated — Alias of {@link Contrib.FromNodePackageJson.Utils.defaultRegistryMatcher}. + * + * @deprecated Use `Contrib.FromNodePackageJson.Utils.defaultRegistryMatcher` instead. + */ +export const defaultRegistryMatcher = _defaultRegistryMatcher