diff --git a/packages/utils/legacy/package.json b/packages/utils/legacy/package.json deleted file mode 100644 index 67008c9843f..00000000000 --- a/packages/utils/legacy/package.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "@tsed/legacy", - "description": "Core module for Ts.ED Framework", - "type": "module", - "private": true, - "version": "8.0.0-beta.5", - "source": "./src/index.ts", - "main": "./lib/esm/index.js", - "module": "./lib/esm/index.js", - "typings": "./lib/types/index.d.ts", - "browser": "./lib/browser/core.umd.min.js", - "exports": { - ".": { - "types": "./lib/types/index.d.ts", - "browser": "./lib/browser/core.umd.min.js", - "import": "./lib/esm/index.js", - "default": "./lib/esm/index.js" - } - }, - "scripts": { - "build": "yarn barrels && yarn build:ts && yarn run build:browser", - "barrels": "barrels", - "build:browser": "webpack", - "build:ts": "tsc --build tsconfig.json", - "test": "vitest run", - "test:ci": "vitest run --coverage.thresholds.autoUpdate=true" - }, - "dependencies": { - "reflect-metadata": "^0.2.2", - "tslib": "2.7.0" - }, - "devDependencies": { - "@tsed/barrels": "workspace:*", - "@tsed/monorepo-utils": "2.3.5", - "@tsed/typescript": "workspace:*", - "@tsed/vitest": "workspace:*", - "@vitest/coverage-v8": "^2.1.2", - "eslint": "9.12.0", - "typescript": "5.4.5", - "vite": "^5.4.8", - "vitest": "2.1.2", - "webpack": "^5.75.0" - } -} diff --git a/packages/utils/legacy/src/decorators/configurable.spec.ts b/packages/utils/legacy/src/decorators/configurable.spec.ts deleted file mode 100644 index 33dfb1c3e86..00000000000 --- a/packages/utils/legacy/src/decorators/configurable.spec.ts +++ /dev/null @@ -1,17 +0,0 @@ -import {Configurable, descriptorOf, NotConfigurable} from "../../../../core/src/index.js"; - -class Test { - test: string; -} - -describe("Configurable", () => { - it("should set attribut as configurable", () => { - Configurable()(Test, "test"); - expect(descriptorOf(Test, "test").configurable).toBe(true); - }); - - it("should set attribut as not configurable", () => { - NotConfigurable()(Test, "test"); - expect(descriptorOf(Test, "test").configurable).toBe(false); - }); -}); diff --git a/packages/utils/legacy/src/decorators/configurable.ts b/packages/utils/legacy/src/decorators/configurable.ts deleted file mode 100644 index bf8e913f52c..00000000000 --- a/packages/utils/legacy/src/decorators/configurable.ts +++ /dev/null @@ -1,11 +0,0 @@ -import {descriptorOf} from "@tsed/core"; - -export function Configurable(value: boolean = true): Function { - return (target: any, propertyKey: string) => { - const descriptor = descriptorOf(target, propertyKey) || {writable: true, enumerable: true}; - descriptor.configurable = value; - Object.defineProperty((target && target.prototype) || target, propertyKey, descriptor); - - return descriptor; - }; -} diff --git a/packages/utils/legacy/src/decorators/deprecated.spec.ts b/packages/utils/legacy/src/decorators/deprecated.spec.ts deleted file mode 100644 index 5c9ecce87d9..00000000000 --- a/packages/utils/legacy/src/decorators/deprecated.spec.ts +++ /dev/null @@ -1,47 +0,0 @@ -import {Deprecated} from "./deprecated.js"; - -describe("Deprecated", () => { - beforeEach(() => { - vi.spyOn(console, "error").mockReturnValue(); - vi.spyOn(console, "warn").mockReturnValue(); - }); - it("should wrap method as deprecated", () => { - class Test { - @Deprecated("test") - test() {} - } - - new Test().test(); - - expect(console.error).toHaveBeenCalledWith("test"); - }); - it("should wrap method as deprecated (throwDeprecation)", () => { - class Test { - @Deprecated("test") - test() {} - } - - (process as any).throwDeprecation = true; - - try { - new Test().test(); - } catch (er) { - expect(er.message).toEqual("test"); - } finally { - (process as any).throwDeprecation = false; - } - }); - it("should wrap method as deprecated (traceDeprecation)", () => { - class Test { - @Deprecated("test") - test() {} - } - - (process as any).traceDeprecation = true; - new Test().test(); - - expect(console.error).toHaveBeenCalled(); - - (process as any).traceDeprecation = false; - }); -}); diff --git a/packages/utils/legacy/src/decorators/deprecated.ts b/packages/utils/legacy/src/decorators/deprecated.ts deleted file mode 100644 index 751bd005072..00000000000 --- a/packages/utils/legacy/src/decorators/deprecated.ts +++ /dev/null @@ -1,73 +0,0 @@ -import {Type} from "@tsed/core"; - -function deprecate(fn: any, msg: string) { - if (typeof process !== "undefined" && (process as any).noDeprecation === true) { - return fn; - } - - // Allow for deprecating things in the process of starting up. - if (typeof process === "undefined") { - return function (...args: any[]) { - return deprecate(fn, msg).apply(this, args); - }; - } - - let warned = false; - - function deprecated(...args: any[]) { - if (!warned) { - if ((process as any).throwDeprecation) { - throw new Error(msg); - } else if (process.traceDeprecation) { - console.trace(msg); - } else { - console.error(msg); - } - warned = true; - } - return fn.apply(this, args); - } - - return deprecated; -} - -/** - * The `@Deprecated()` decorators wraps the given method in such a way that it is marked as deprecated. - * - * ```typescript - * provide Foo { - * - * @Deprecated("Foo.method: Use Foo.method2 instead") - * public method() { - * - * } - * ``` - * - * When called, @Deprecated() will return a function that will emit a `DeprecationWarning` using the `process.on('warning')` event. - * By default, this warning will be emitted and printed to `stderr` exactly once, the first time it is called. After the warning is emitted, the wrapped method is called. - * - * If either the `--no-deprecation` or `--no-warnings` command line flags are used, or if the `process.noDeprecation` - * property is set to `true` prior to the first deprecation warning, the `@Deprecated()` decorators does nothing. - * - * If the `--trace-deprecation` or `--trace-warnings` command line flags are set, or the `process.traceDeprecation` - * property is set to `true`, a warning and a stack trace are printed to stderr the first time the deprecated function is called. - * - * If the `--throw-deprecation` command line flag is set, or the `process.throwDeprecation` property is set to `true`, - * then an exception will be thrown when the deprecated function is called. - * - * The `--throw-deprecation` command line flag and `process.throwDeprecation` property take precedence over `--trace-deprecation` - * and `process.traceDeprecation`. - * - * @param message - * @returns {Function} - * @decorator - */ -export function Deprecated(message: string): Function { - return (target: Type, targetKey: string, descriptor: TypedPropertyDescriptor) => { - const originalMethod = descriptor.value; - - descriptor.value = deprecate(originalMethod, message); - - return descriptor; - }; -} diff --git a/packages/utils/legacy/src/decorators/enumerable.spec.ts b/packages/utils/legacy/src/decorators/enumerable.spec.ts deleted file mode 100644 index 427b319c00d..00000000000 --- a/packages/utils/legacy/src/decorators/enumerable.spec.ts +++ /dev/null @@ -1,61 +0,0 @@ -import {Enumerable, getEnumerableKeys, NotEnumerable} from "../../../../core/src/index.js"; - -class Test1 { - test: string = "test"; - - @Enumerable() - name?: string = undefined; - - get first() { - return this.test + " " + this.name; - } -} - -class Parent1 { - @Enumerable() - parentProp: string; -} - -class Test2 extends Parent1 { - prop: string = "test"; - - @Enumerable() - test: string = "test"; - - @Enumerable() - name: string = ""; - - @NotEnumerable() - private _privateTest: string = "private"; - - @Enumerable(true) - get first() { - return this.test + " " + this.name; - } - - get privateTest(): string { - return this._privateTest; - } - - @Enumerable(true) - set privateTest(value: string) { - this._privateTest = value; - } -} - -describe("Enumerable", () => { - it("should have some keys with Test1", () => { - expect(getEnumerableKeys(new Test1())).toEqual(["test", "name"]); - expect(Object.keys(new Test1())).toEqual(["test", "name"]); - expect(Object.getOwnPropertyNames(new Test1())).toEqual(["test", "name"]); - expect(Reflect.ownKeys(new Test2())).toEqual(["prop", "test", "name", "_privateTest"]); - }); - - it("should have some keys with Test2", () => { - expect(getEnumerableKeys(new Test2())).toEqual(["prop", "test", "name", "first", "privateTest", "parentProp"]); - expect(Object.keys(new Test2())).toEqual(["prop", "test", "name", "_privateTest"]); - expect(Object.getOwnPropertyNames(new Test2())).toEqual(["prop", "test", "name", "_privateTest"]); - expect(Reflect.ownKeys(new Test2())).toEqual(["prop", "test", "name", "_privateTest"]); - expect(Reflect.ownKeys(new Test2())).toEqual(["prop", "test", "name", "_privateTest"]); - }); -}); diff --git a/packages/utils/legacy/src/decorators/enumerable.ts b/packages/utils/legacy/src/decorators/enumerable.ts deleted file mode 100644 index f519686f121..00000000000 --- a/packages/utils/legacy/src/decorators/enumerable.ts +++ /dev/null @@ -1,11 +0,0 @@ -import {descriptorOf} from "@tsed/core"; - -export function Enumerable(value: boolean = true): Function { - return (target: any, propertyKey: string) => { - const descriptor = descriptorOf(target, propertyKey) || {writable: true, configurable: true}; - descriptor.enumerable = value; - Object.defineProperty((target && target.prototype) || target, propertyKey, descriptor); - - return descriptor; - }; -} diff --git a/packages/utils/legacy/src/decorators/notConfigurable.ts b/packages/utils/legacy/src/decorators/notConfigurable.ts deleted file mode 100644 index aaa53af1bbd..00000000000 --- a/packages/utils/legacy/src/decorators/notConfigurable.ts +++ /dev/null @@ -1,5 +0,0 @@ -import {Configurable} from "./configurable.js"; - -export function NotConfigurable(): Function { - return Configurable(false); -} diff --git a/packages/utils/legacy/src/decorators/notEnumerable.ts b/packages/utils/legacy/src/decorators/notEnumerable.ts deleted file mode 100644 index 24a1e6ec872..00000000000 --- a/packages/utils/legacy/src/decorators/notEnumerable.ts +++ /dev/null @@ -1,5 +0,0 @@ -import {Enumerable} from "./enumerable.js"; - -export function NotEnumerable(): Function { - return Enumerable(false); -} diff --git a/packages/utils/legacy/src/decorators/readOnly.ts b/packages/utils/legacy/src/decorators/readOnly.ts deleted file mode 100644 index 7c562c94a12..00000000000 --- a/packages/utils/legacy/src/decorators/readOnly.ts +++ /dev/null @@ -1,5 +0,0 @@ -import {Writable} from "./writable.js"; - -export function Readonly(): Function { - return Writable(false); -} diff --git a/packages/utils/legacy/src/decorators/writable.spec.ts b/packages/utils/legacy/src/decorators/writable.spec.ts deleted file mode 100644 index 5a42e551df0..00000000000 --- a/packages/utils/legacy/src/decorators/writable.spec.ts +++ /dev/null @@ -1,14 +0,0 @@ -import {descriptorOf, Readonly, Writable} from "../../../../core/src/index.js"; - -class Test {} - -describe("Writable", () => { - it("should set attribut as writable", () => { - Writable()(Test, "test"); - expect(descriptorOf(Test, "test").writable).toBe(true); - }); - it("should set attribut as readonly", () => { - Readonly()(Test, "test"); - expect(descriptorOf(Test, "test").writable).toBe(false); - }); -}); diff --git a/packages/utils/legacy/src/decorators/writable.ts b/packages/utils/legacy/src/decorators/writable.ts deleted file mode 100644 index 90b92105ab4..00000000000 --- a/packages/utils/legacy/src/decorators/writable.ts +++ /dev/null @@ -1,11 +0,0 @@ -import {descriptorOf} from "@tsed/core"; - -export function Writable(value: boolean = true): Function { - return (target: any, propertyKey: string) => { - const descriptor = descriptorOf(target, propertyKey) || {configurable: true, enumerable: true}; - descriptor.writable = value; - Object.defineProperty((target && target.prototype) || target, propertyKey, descriptor); - - return descriptor; - }; -} diff --git a/packages/utils/legacy/src/utils/getEnumerableKeys.spec.ts b/packages/utils/legacy/src/utils/getEnumerableKeys.spec.ts deleted file mode 100644 index 6217dc1bc5c..00000000000 --- a/packages/utils/legacy/src/utils/getEnumerableKeys.spec.ts +++ /dev/null @@ -1,23 +0,0 @@ -import {getEnumerableKeys} from "./getEnumerableKeys.js"; - -describe("getEnumerableKeys", () => { - it("should return enumerable keys", () => { - class Test { - test: string; - test2: string; - - constructor() { - this.test = "test"; - this.test2 = "test2"; - } - } - - expect(getEnumerableKeys(new Test())).toEqual(["test", "test2"]); - }); - it("should return enumerable keys (security test)", () => { - const obj = JSON.parse('{"__proto__": {"a": "vulnerable"}, "test": "test"}'); - - expect(getEnumerableKeys(obj)).toEqual(["test"]); - expect(({} as any).a).toBeUndefined(); - }); -}); diff --git a/packages/utils/legacy/src/utils/getEnumerableKeys.ts b/packages/utils/legacy/src/utils/getEnumerableKeys.ts deleted file mode 100644 index 48288723a06..00000000000 --- a/packages/utils/legacy/src/utils/getEnumerableKeys.ts +++ /dev/null @@ -1,18 +0,0 @@ -import {isEnumerable} from "../../../../core/src/utils/objects/isEnumerable.js"; -import {isProtectedKey} from "../../../../core/src/utils/objects/isProtectedKey.js"; - -/** - * Return all enumerable keys of the given object - * @param obj - */ -export function getEnumerableKeys(obj: any) { - const keys: string[] = []; - - for (const key in obj) { - if (!isProtectedKey(key) && isEnumerable(obj, key)) { - keys.push(key); - } - } - - return keys; -} diff --git a/packages/utils/legacy/tsconfig.esm.json b/packages/utils/legacy/tsconfig.esm.json deleted file mode 100644 index ccf3df0d458..00000000000 --- a/packages/utils/legacy/tsconfig.esm.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "extends": "@tsed/typescript/tsconfig.node.json", - "compilerOptions": { - "baseUrl": "./", - "rootDir": "src", - "outDir": "./lib/esm", - "declarationDir": "./lib/types", - "declaration": true, - "composite": true, - "noEmit": false - }, - "include": ["src/**/*.ts", "src/**/*.json"], - "exclude": [ - "node_modules", - "test", - "lib", - "benchmark", - "coverage", - "spec", - "**/*.benchmark.ts", - "**/*.spec.ts", - "keys", - "**/__mock__/**", - "webpack.config.js" - ] -} diff --git a/packages/utils/legacy/tsconfig.json b/packages/utils/legacy/tsconfig.json deleted file mode 100644 index cbf69c6b937..00000000000 --- a/packages/utils/legacy/tsconfig.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "extends": "@tsed/typescript/tsconfig.node.json", - "compilerOptions": { - "baseUrl": "./", - "noEmit": true - }, - "include": [], - "references": [ - { - "path": "./tsconfig.esm.json" - }, - { - "path": "./tsconfig.spec.json" - } - ] -} diff --git a/packages/utils/legacy/tsconfig.spec.json b/packages/utils/legacy/tsconfig.spec.json deleted file mode 100644 index ec7db70b9d8..00000000000 --- a/packages/utils/legacy/tsconfig.spec.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "extends": "@tsed/typescript/tsconfig.node.json", - "compilerOptions": { - "baseUrl": "./", - "rootDir": "..", - "declaration": false, - "composite": false, - "noEmit": true, - "paths": { - "@tsed/openspec": ["../specs/openspec/src/index.ts"], - "@tsed/schema": ["../specs/schema/src/index.ts"], - "@tsed/di": ["../di/src/index.ts"], - "@tsed/exceptions": ["../specs/exceptions/src/index.ts"], - "@tsed/json-mapper": ["../specs/json-mapper/src/index.ts"], - "@tsed/platform-exceptions": ["../platform/platform-exceptions/src/index.ts"], - "@tsed/platform-middlewares": ["../platform/platform-middlewares/src/index.ts"], - "@tsed/platform-params": ["../platform/platform-params/src/index.ts"], - "@tsed/platform-log-middleware": ["../platform/platform-log-middleware/src/index.ts"], - "@tsed/platform-response-filter": ["../platform/platform-response-filter/src/index.ts"], - "@tsed/platform-router": ["../platform/platform-router/src/index.ts"], - "@tsed/platform-views": ["../platform/platform-views/src/index.ts"], - "@tsed/normalize-path": ["../utils/normalize-path/src/index.ts"], - "@tsed/components-scan": ["../third-parties/components-scan/src/index.ts"], - "@tsed/platform-http": ["../platform/platform-http/src/common/index.ts"], - "@tsed/ajv": ["../specs/ajv/src/index.ts"], - "@tsed/platform-cache": ["../platform/platform-cache/src/index.ts"], - "@tsed/swagger": ["../specs/swagger/src/index.ts"], - "@tsed/platform-test-sdk": ["../platform/platform-test-sdk/src/index.ts"], - "@tsed/platform-express": ["../platform/platform-express/src/index.ts"], - "@tsed/platform-koa": ["../platform/platform-koa/src/index.ts"] - }, - "types": ["vite/client", "vitest/globals"] - }, - "include": ["src/**/*.spec.ts", "test/**/*.spec.ts", "vitest.config.mts"], - "exclude": ["node_modules", "lib", "benchmark", "coverage"] -} diff --git a/yarn.lock b/yarn.lock index 48eed7c0d25..8011d9825ca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7066,25 +7066,6 @@ __metadata: languageName: unknown linkType: soft -"@tsed/legacy@workspace:packages/utils/legacy": - version: 0.0.0-use.local - resolution: "@tsed/legacy@workspace:packages/utils/legacy" - dependencies: - "@tsed/barrels": "workspace:*" - "@tsed/monorepo-utils": "npm:2.3.5" - "@tsed/typescript": "workspace:*" - "@tsed/vitest": "workspace:*" - "@vitest/coverage-v8": "npm:^2.1.2" - eslint: "npm:9.12.0" - reflect-metadata: "npm:^0.2.2" - tslib: "npm:2.7.0" - typescript: "npm:5.4.5" - vite: "npm:^5.4.8" - vitest: "npm:2.1.2" - webpack: "npm:^5.75.0" - languageName: unknown - linkType: soft - "@tsed/logger-file@npm:^6.7.8": version: 6.7.8 resolution: "@tsed/logger-file@npm:6.7.8"