diff --git a/README.md b/README.md index 019b25f..ec853e1 100644 --- a/README.md +++ b/README.md @@ -1 +1,40 @@ -# Common +# @alveojs/common + +Internal shared library for the Alveo Dependency Injection framework. + +## Description + +This package contains the common types, decorators, interfaces, and utilities used by the Alveo ecosystem. It is designed to be a lightweight dependency that allows third-party packages or plugins to integrate with Alveo without requiring the full DI engine. + +## Contents + +- **Decorators**: `@Injectable()`, `@Module()`, `@Inject()` +- **Lifecycle Interfaces**: `OnModuleInit`, `OnApplicationBootstrap`, `OnModuleDestroy`, etc. +- **Provider Interfaces**: Definitions for Class, Value, Factory, and Existing providers. +- **Utilities**: `forwardRef()` for circular dependency resolution. +- **Base Classes**: Core error classes and base types. + +## Installation + +```bash +bun add @alveojs/common +# or +npm install @alveojs/common +``` + +## Usage + +This package is typically used when building libraries or modules that will be consumed by an Alveo application. + +```typescript +import { Injectable } from '@alveojs/common'; + +@Injectable() +export class MyService { + // ... +} +``` + +## License + +MIT \ No newline at end of file diff --git a/biome.json b/biome.json new file mode 100644 index 0000000..0a785b7 --- /dev/null +++ b/biome.json @@ -0,0 +1,68 @@ +{ + "$schema": "https://biomejs.dev/schemas/2.3.11/schema.json", + "vcs": { + "enabled": true, + "clientKind": "git", + "useIgnoreFile": true + }, + "files": { + "ignoreUnknown": false + }, + "formatter": { + "enabled": true, + "formatWithErrors": true, + "indentStyle": "tab", + "indentWidth": 4, + "lineEnding": "lf", + "lineWidth": 80, + "attributePosition": "auto" + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "complexity": { + "noStaticOnlyClass": "off", + "noBannedTypes": "off" + }, + "correctness": { + "noUnusedVariables": "error", + "noUnusedPrivateClassMembers": "error", + "noUnusedFunctionParameters": "off" + }, + "style": { + "useImportType": "off", + "useNodejsImportProtocol": "off", + "useTemplate": "off", + "noNonNullAssertion": "off", + "useLiteralEnumMembers": "off" + }, + "suspicious": { + "noExplicitAny": "error", + "noImplicitAnyLet": "off", + "noAssignInExpressions": "off", + "useIterableCallbackReturn": "off", + "noShadowRestrictedNames": "off" + } + } + }, + "javascript": { + "formatter": { + "quoteStyle": "double" + }, + "parser": { + "unsafeParameterDecoratorsEnabled": true + } + }, + "overrides": [ + { + "includes": ["dist/**", "node_modules/**"], + "linter": { + "enabled": false + }, + "formatter": { + "enabled": false + } + } + ] +} diff --git a/bun.lock b/bun.lock new file mode 100644 index 0000000..020709f --- /dev/null +++ b/bun.lock @@ -0,0 +1,52 @@ +{ + "lockfileVersion": 1, + "configVersion": 1, + "workspaces": { + "": { + "name": "@alveojs/common", + "dependencies": { + "reflect-metadata": "^0.2.2", + }, + "devDependencies": { + "@biomejs/biome": "^2.3.11", + "@types/bun": "latest", + "typescript": "^5.0.0", + }, + "peerDependencies": { + "reflect-metadata": "^0.2.2", + "typescript": "^5", + }, + }, + }, + "packages": { + "@biomejs/biome": ["@biomejs/biome@2.3.11", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "2.3.11", "@biomejs/cli-darwin-x64": "2.3.11", "@biomejs/cli-linux-arm64": "2.3.11", "@biomejs/cli-linux-arm64-musl": "2.3.11", "@biomejs/cli-linux-x64": "2.3.11", "@biomejs/cli-linux-x64-musl": "2.3.11", "@biomejs/cli-win32-arm64": "2.3.11", "@biomejs/cli-win32-x64": "2.3.11" }, "bin": { "biome": "bin/biome" } }, "sha512-/zt+6qazBWguPG6+eWmiELqO+9jRsMZ/DBU3lfuU2ngtIQYzymocHhKiZRyrbra4aCOoyTg/BmY+6WH5mv9xmQ=="], + + "@biomejs/cli-darwin-arm64": ["@biomejs/cli-darwin-arm64@2.3.11", "", { "os": "darwin", "cpu": "arm64" }, "sha512-/uXXkBcPKVQY7rc9Ys2CrlirBJYbpESEDme7RKiBD6MmqR2w3j0+ZZXRIL2xiaNPsIMMNhP1YnA+jRRxoOAFrA=="], + + "@biomejs/cli-darwin-x64": ["@biomejs/cli-darwin-x64@2.3.11", "", { "os": "darwin", "cpu": "x64" }, "sha512-fh7nnvbweDPm2xEmFjfmq7zSUiox88plgdHF9OIW4i99WnXrAC3o2P3ag9judoUMv8FCSUnlwJCM1B64nO5Fbg=="], + + "@biomejs/cli-linux-arm64": ["@biomejs/cli-linux-arm64@2.3.11", "", { "os": "linux", "cpu": "arm64" }, "sha512-l4xkGa9E7Uc0/05qU2lMYfN1H+fzzkHgaJoy98wO+b/7Gl78srbCRRgwYSW+BTLixTBrM6Ede5NSBwt7rd/i6g=="], + + "@biomejs/cli-linux-arm64-musl": ["@biomejs/cli-linux-arm64-musl@2.3.11", "", { "os": "linux", "cpu": "arm64" }, "sha512-XPSQ+XIPZMLaZ6zveQdwNjbX+QdROEd1zPgMwD47zvHV+tCGB88VH+aynyGxAHdzL+Tm/+DtKST5SECs4iwCLg=="], + + "@biomejs/cli-linux-x64": ["@biomejs/cli-linux-x64@2.3.11", "", { "os": "linux", "cpu": "x64" }, "sha512-/1s9V/H3cSe0r0Mv/Z8JryF5x9ywRxywomqZVLHAoa/uN0eY7F8gEngWKNS5vbbN/BsfpCG5yeBT5ENh50Frxg=="], + + "@biomejs/cli-linux-x64-musl": ["@biomejs/cli-linux-x64-musl@2.3.11", "", { "os": "linux", "cpu": "x64" }, "sha512-vU7a8wLs5C9yJ4CB8a44r12aXYb8yYgBn+WeyzbMjaCMklzCv1oXr8x+VEyWodgJt9bDmhiaW/I0RHbn7rsNmw=="], + + "@biomejs/cli-win32-arm64": ["@biomejs/cli-win32-arm64@2.3.11", "", { "os": "win32", "cpu": "arm64" }, "sha512-PZQ6ElCOnkYapSsysiTy0+fYX+agXPlWugh6+eQ6uPKI3vKAqNp6TnMhoM3oY2NltSB89hz59o8xIfOdyhi9Iw=="], + + "@biomejs/cli-win32-x64": ["@biomejs/cli-win32-x64@2.3.11", "", { "os": "win32", "cpu": "x64" }, "sha512-43VrG813EW+b5+YbDbz31uUsheX+qFKCpXeY9kfdAx+ww3naKxeVkTD9zLIWxUPfJquANMHrmW3wbe/037G0Qg=="], + + "@types/bun": ["@types/bun@1.3.5", "", { "dependencies": { "bun-types": "1.3.5" } }, "sha512-RnygCqNrd3srIPEWBd5LFeUYG7plCoH2Yw9WaZGyNmdTEei+gWaHqydbaIRkIkcbXwhBT94q78QljxN0Sk838w=="], + + "@types/node": ["@types/node@25.0.6", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-NNu0sjyNxpoiW3YuVFfNz7mxSQ+S4X2G28uqg2s+CzoqoQjLPsWSbsFFyztIAqt2vb8kfEAsJNepMGPTxFDx3Q=="], + + "bun-types": ["bun-types@1.3.5", "", { "dependencies": { "@types/node": "*" } }, "sha512-inmAYe2PFLs0SUbFOWSVD24sg1jFlMPxOjOSSCYqUgn4Hsc3rDc7dFvfVYjFPNHtov6kgUeulV4SxbuIV/stPw=="], + + "reflect-metadata": ["reflect-metadata@0.2.2", "", {}, "sha512-urBwgfrvVP/eAyXx4hluJivBKzuEbSQs9rKWCrCkbSxNv8mxPcUZKeuoF3Uy4mJl3Lwprp6yy5/39VWigZ4K6Q=="], + + "typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="], + + "undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="], + } +} diff --git a/package.json b/package.json index c2d7216..22a5a3d 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,22 @@ "name": "@alveojs/common", "version": "0.0.1", "description": "Common types, decorators and interfaces for Alveo DI container", - "module": "src/index.ts", - "types": "src/index.ts", + "main": "./dist/index.js", + "module": "./dist/index.mjs", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.mjs", + "require": "./dist/index.js", + "default": "./dist/index.mjs" + } + }, + "files": [ + "dist" + ], "type": "module", - "private": true, + "private": false, "peerDependencies": { "reflect-metadata": "^0.2.2", "typescript": "^5" @@ -15,9 +27,11 @@ }, "devDependencies": { "@biomejs/biome": "^2.3.11", - "@types/bun": "latest" + "@types/bun": "latest", + "typescript": "^5.0.0" }, "scripts": { + "build": "rm -rf dist && bun build ./src/index.ts --outfile ./dist/index.mjs && bun build ./src/index.ts --outfile ./dist/index.js && tsc --project tsconfig.build.json", "format": "biome format", "lint": "biome lint", "typecheck": "tsc --noEmit" diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 0000000..822fe43 --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "target": "ESNext", + "module": "ESNext", + "moduleResolution": "bundler", + "declaration": true, + "emitDeclarationOnly": true, + "outDir": "./dist", + "strict": true, + "skipLibCheck": true, + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "baseUrl": ".", + "paths": { + "@alveojs/common": ["./src/index.ts"] + } + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "dist"] +} diff --git a/tsconfig.json b/tsconfig.json index 1881086..fe3c341 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,10 +1,23 @@ { - "extends": "../tsconfig.json", - "compilerOptions": { - "experimentalDecorators": true, - "emitDecoratorMetadata": true, - "verbatimModuleSyntax": true, - "noEmit": true - }, - "include": ["src/**/*"] + "compilerOptions": { + "lib": ["ESNext"], + "target": "ESNext", + "module": "Preserve", + "moduleDetection": "force", + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + "strict": true, + "skipLibCheck": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedIndexedAccess": true, + "noImplicitOverride": true, + "noUnusedLocals": false, + "noUnusedParameters": false, + "noPropertyAccessFromIndexSignature": false, + }, + "include": ["src/**/*"], }