inversify-typesafe 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ <h1 align="center">inversify-typesafe</h1>
2
+
3
+ <p align="center">
4
+ Boost InversifyJS with Type Safety.
5
+ </p>
6
+
7
+ <p align="center">
8
+ <a href="https://github.com/myeongjae-kim/inversify-typesafe/actions?query=workflow%3ACI">
9
+ <img src="https://github.com/myeongjae-kim/inversify-typesafe/workflows/CI/badge.svg" alt="CI" height="18">
10
+ </a>
11
+ <a href="https://codecov.io/gh/myeongjae-kim/inversify-typesafe">
12
+ <img src="https://img.shields.io/codecov/c/github/myeongjae-kim/inversify-typesafe.svg" alt="Test Coverage" height="18">
13
+ </a>
14
+ <a href="https://www.npmjs.com/package/inversify-typesafe">
15
+ <img src="https://img.shields.io/npm/v/inversify-typesafe.svg" alt="npm version" height="18">
16
+ </a>
17
+ <a href="https://bundlephobia.com/package/inversify-typesafe">
18
+ <img src="https://img.shields.io/bundlephobia/minzip/inversify-typesafe" alt="Bundle Size" height="18">
19
+ </a>
20
+ <a href="https://raw.githubusercontent.com/myeongjae-kim/inversify-typesafe/main/LICENSE">
21
+ <img src="https://img.shields.io/npm/l/inversify-typesafe.svg" alt="MIT license" height="18">
22
+ </a>
23
+ </p>
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ var n=require("inversify");exports.ContainerTypesafe=/*#__PURE__*/function(){function t(t,e){var r=this;this.container=void 0,this.container=new n.Container(e),Object.entries(t).forEach(function(n){var t=n[1];r.container.bind(n[0]).to(t)})}var e=t.prototype;return e.get=function(n){return this.container.get(n)},e.getContainer=function(){return this.container},t}(),exports.returnInjectTypesafe=function(){return function(t){return n.inject(t)}};
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import { Container, ContainerOptions, inject, Newable } from \"inversify\";\n\nexport type TypesafeServiceConfig<S> = {\n [K in keyof S]: Newable<S[K]>;\n};\n\nexport const returnInjectTypesafe = <Name extends string>() => (name: Name) => inject(name);\n\nexport class ContainerTypesafe<S extends Record<string, unknown>> {\n private container: Container;\n constructor(\n serviceConfig: TypesafeServiceConfig<S>,\n options?: ContainerOptions\n ) {\n this.container = new Container(options);\n\n Object.entries(serviceConfig).forEach(([name, service]) => {\n this.container.bind(name).to(service);\n });\n }\n\n public get<T extends keyof S>(serviceName: T): S[T] {\n return this.container.get(serviceName as string);\n }\n\n // only if you need to use inversify features.\n public getContainer() {\n return this.container;\n }\n}"],"names":["ContainerTypesafe","serviceConfig","options","_this","this","container","Container","Object","entries","forEach","_ref","service","bind","to","_proto","prototype","get","serviceName","getContainer","name","inject"],"mappings":"kEAQ8B,WAE5B,SAAAA,EACEC,EACAC,GAA0B,IAAAC,EAAAC,KAAAA,KAHpBC,eAAS,EAKfD,KAAKC,UAAY,IAAIC,EAAAA,UAAUJ,GAE/BK,OAAOC,QAAQP,GAAeQ,QAAQ,SAAAC,OAAQC,EAAOD,EACnDP,GAAAA,EAAKE,UAAUO,KAD2BF,EAAEC,IAClBE,GAAGF,EAC/B,EACF,CAAC,IAAAG,EAAAd,EAAAe,iBAAAD,EAEME,IAAA,SAAuBC,GAC5B,OAAOb,KAAKC,UAAUW,IAAIC,EAC5B,EAACH,EAGMI,aAAA,WACL,OAAWd,KAACC,SACd,EAACL,CAAA,CApB2B,gCAFM,WAA2B,OAAA,SAACmB,GAAU,OAAKC,EAAAA,OAAOD,EAAK,CAAA"}
@@ -0,0 +1,11 @@
1
+ import { Container, ContainerOptions, Newable } from "inversify";
2
+ export type TypesafeServiceConfig<S> = {
3
+ [K in keyof S]: Newable<S[K]>;
4
+ };
5
+ export declare const returnInjectTypesafe: <Name extends string>() => (name: Name) => MethodDecorator & ParameterDecorator & PropertyDecorator;
6
+ export declare class ContainerTypesafe<S extends Record<string, unknown>> {
7
+ private container;
8
+ constructor(serviceConfig: TypesafeServiceConfig<S>, options?: ContainerOptions);
9
+ get<T extends keyof S>(serviceName: T): S[T];
10
+ getContainer(): Container;
11
+ }
@@ -0,0 +1,11 @@
1
+ import { Container, ContainerOptions, Newable } from "inversify";
2
+ export type TypesafeServiceConfig<S> = {
3
+ [K in keyof S]: Newable<S[K]>;
4
+ };
5
+ export declare const returnInjectTypesafe: <Name extends string>() => (name: Name) => MethodDecorator & ParameterDecorator & PropertyDecorator;
6
+ export declare class ContainerTypesafe<S extends Record<string, unknown>> {
7
+ private container;
8
+ constructor(serviceConfig: TypesafeServiceConfig<S>, options?: ContainerOptions);
9
+ get<T extends keyof S>(serviceName: T): S[T];
10
+ getContainer(): Container;
11
+ }
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import{inject as t,Container as n}from"inversify";const r=()=>n=>t(n);class e{constructor(t,r){this.container=void 0,this.container=new n(r),Object.entries(t).forEach(([t,n])=>{this.container.bind(t).to(n)})}get(t){return this.container.get(t)}getContainer(){return this.container}}export{e as ContainerTypesafe,r as returnInjectTypesafe};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { Container, ContainerOptions, inject, Newable } from \"inversify\";\n\nexport type TypesafeServiceConfig<S> = {\n [K in keyof S]: Newable<S[K]>;\n};\n\nexport const returnInjectTypesafe = <Name extends string>() => (name: Name) => inject(name);\n\nexport class ContainerTypesafe<S extends Record<string, unknown>> {\n private container: Container;\n constructor(\n serviceConfig: TypesafeServiceConfig<S>,\n options?: ContainerOptions\n ) {\n this.container = new Container(options);\n\n Object.entries(serviceConfig).forEach(([name, service]) => {\n this.container.bind(name).to(service);\n });\n }\n\n public get<T extends keyof S>(serviceName: T): S[T] {\n return this.container.get(serviceName as string);\n }\n\n // only if you need to use inversify features.\n public getContainer() {\n return this.container;\n }\n}"],"names":["returnInjectTypesafe","name","inject","ContainerTypesafe","constructor","serviceConfig","options","container","this","Container","Object","entries","forEach","service","bind","to","get","serviceName","getContainer"],"mappings":"kDAMa,MAAAA,EAAuBA,IAA4BC,GAAeC,EAAOD,SAEzEE,EAEXC,WAAAA,CACEC,EACAC,GAHMC,KAAAA,eAKN,EAAAC,KAAKD,UAAY,IAAIE,EAAUH,GAE/BI,OAAOC,QAAQN,GAAeO,QAAQ,EAAEX,EAAMY,MAC5CL,KAAKD,UAAUO,KAAKb,GAAMc,GAAGF,IAEjC,CAEOG,GAAAA,CAAuBC,GAC5B,OAAOT,KAAKD,UAAUS,IAAIC,EAC5B,CAGOC,YAAAA,GACL,OAAOV,KAAKD,SACd"}
@@ -0,0 +1,2 @@
1
+ !function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("inversify")):"function"==typeof define&&define.amd?define(["exports","inversify"],e):e((n||self).inversifyTypesafe={},n.inversify)}(this,function(n,e){n.ContainerTypesafe=/*#__PURE__*/function(){function n(n,t){var i=this;this.container=void 0,this.container=new e.Container(t),Object.entries(n).forEach(function(n){var e=n[1];i.container.bind(n[0]).to(e)})}var t=n.prototype;return t.get=function(n){return this.container.get(n)},t.getContainer=function(){return this.container},n}(),n.returnInjectTypesafe=function(){return function(n){return e.inject(n)}}});
2
+ //# sourceMappingURL=index.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.umd.js","sources":["../src/index.ts"],"sourcesContent":["import { Container, ContainerOptions, inject, Newable } from \"inversify\";\n\nexport type TypesafeServiceConfig<S> = {\n [K in keyof S]: Newable<S[K]>;\n};\n\nexport const returnInjectTypesafe = <Name extends string>() => (name: Name) => inject(name);\n\nexport class ContainerTypesafe<S extends Record<string, unknown>> {\n private container: Container;\n constructor(\n serviceConfig: TypesafeServiceConfig<S>,\n options?: ContainerOptions\n ) {\n this.container = new Container(options);\n\n Object.entries(serviceConfig).forEach(([name, service]) => {\n this.container.bind(name).to(service);\n });\n }\n\n public get<T extends keyof S>(serviceName: T): S[T] {\n return this.container.get(serviceName as string);\n }\n\n // only if you need to use inversify features.\n public getContainer() {\n return this.container;\n }\n}"],"names":["ContainerTypesafe","serviceConfig","options","_this","this","container","Container","Object","entries","forEach","_ref","service","bind","to","_proto","prototype","get","serviceName","getContainer","name","inject"],"mappings":"2TAQ8B,WAE5B,SAAAA,EACEC,EACAC,GAA0B,IAAAC,EAAAC,KAAAA,KAHpBC,eAAS,EAKfD,KAAKC,UAAY,IAAIC,EAAAA,UAAUJ,GAE/BK,OAAOC,QAAQP,GAAeQ,QAAQ,SAAAC,OAAQC,EAAOD,EACnDP,GAAAA,EAAKE,UAAUO,KAD2BF,EAAEC,IAClBE,GAAGF,EAC/B,EACF,CAAC,IAAAG,EAAAd,EAAAe,iBAAAD,EAEME,IAAA,SAAuBC,GAC5B,OAAOb,KAAKC,UAAUW,IAAIC,EAC5B,EAACH,EAGMI,aAAA,WACL,OAAWd,KAACC,SACd,EAACL,CAAA,CApB2B,0BAFM,WAA2B,OAAA,SAACmB,GAAU,OAAKC,EAAAA,OAAOD,EAAK,CAAA"}
package/package.json ADDED
@@ -0,0 +1,82 @@
1
+ {
2
+ "name": "inversify-typesafe",
3
+ "type": "module",
4
+ "version": "0.1.0",
5
+ "description": "Boost InversifyJS with Type Safety.",
6
+ "source": "src/index.ts",
7
+ "exports": {
8
+ ".": {
9
+ "require": {
10
+ "types": "./dist/index.d.cts",
11
+ "default": "./dist/index.cjs"
12
+ },
13
+ "import": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ },
17
+ "types": "./dist/index.d.ts",
18
+ "default": "./dist/index.js"
19
+ },
20
+ "./package.json": "./package.json"
21
+ },
22
+ "types": "dist/index.d.ts",
23
+ "main": "dist/index.cjs",
24
+ "module": "dist/index.js",
25
+ "unpkg": "dist/index.umd.js",
26
+ "files": [
27
+ "dist/**/*",
28
+ "package.json"
29
+ ],
30
+ "scripts": {
31
+ "preinstall": "npx only-allow pnpm",
32
+ "setup": "husky install",
33
+ "clean": "rimraf dist",
34
+ "bundle": "microbundle --format modern,cjs,umd",
35
+ "typedoc": "typedoc src/index.ts --out docs/public/docs",
36
+ "build": "pnpm run clean && pnpm run bundle && sh ./scripts/generate-cts.sh && rimraf dist/index.d.ts\\'\\'",
37
+ "dev": "microbundle watch",
38
+ "prepublishOnly": "pnpm run test && pnpm run build",
39
+ "watch": "pnpm run clean && tsc -w",
40
+ "test": "vitest run --dir tests",
41
+ "test:watch": "vitest --dir tests",
42
+ "coverage": "vitest run --coverage --dir tests",
43
+ "prettier": "prettier . --write",
44
+ "lint": "eslint src/**",
45
+ "lint-staged": "lint-staged",
46
+ "check": "tsc --strict --noEmit --extendedDiagnostics",
47
+ "set-version": "sh ./scripts/set-version.sh"
48
+ },
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "https://github.com/myeongjae-kim/inversify-typesafe"
52
+ },
53
+ "homepage": "https://github.com/myeongjae-kim/inversify-typesafe",
54
+ "keywords": [
55
+ "inversify",
56
+ "spring",
57
+ "di",
58
+ "dependency injection",
59
+ "container"
60
+ ],
61
+ "author": "Myeongjae Kim",
62
+ "license": "MIT",
63
+ "devDependencies": {
64
+ "@types/inversify": "^2.0.33",
65
+ "@typescript-eslint/eslint-plugin": "^8.50.1",
66
+ "@typescript-eslint/parser": "^8.50.1",
67
+ "@vitest/coverage-v8": "^4.0.16",
68
+ "eslint": "^9.39.2",
69
+ "husky": "^9.1.7",
70
+ "lint-staged": "^16.2.7",
71
+ "microbundle": "^0.15.1",
72
+ "prettier": "3.7.4",
73
+ "rimraf": "^6.1.2",
74
+ "typedoc": "^0.28.15",
75
+ "typescript": "^5.9.3",
76
+ "vitest": "^4.0.16"
77
+ },
78
+ "dependencies": {
79
+ "inversify": "^7.10.8",
80
+ "reflect-metadata": "^0.2.2"
81
+ }
82
+ }