@rolster/invertly 1.2.0 → 1.3.1

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.
Files changed (48) hide show
  1. package/dist/cjs/index.js +241 -237
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/es/index.js +241 -237
  4. package/dist/es/index.js.map +1 -1
  5. package/dist/esm/decorators/index.d.ts +2 -2
  6. package/dist/esm/decorators/index.js +2 -2
  7. package/dist/esm/decorators/inject.decorator.d.ts +4 -4
  8. package/dist/esm/decorators/inject.decorator.js +15 -16
  9. package/dist/esm/decorators/inject.decorator.js.map +1 -1
  10. package/dist/esm/decorators/injectable.decorator.d.ts +6 -6
  11. package/dist/esm/decorators/injectable.decorator.js +10 -10
  12. package/dist/esm/factories/container.factory.d.ts +8 -9
  13. package/dist/esm/factories/container.factory.js +105 -105
  14. package/dist/esm/factories/container.factory.js.map +1 -1
  15. package/dist/esm/factories/index.d.ts +21 -21
  16. package/dist/esm/factories/index.js +32 -34
  17. package/dist/esm/factories/index.js.map +1 -1
  18. package/dist/esm/index.d.ts +6 -6
  19. package/dist/esm/index.js +5 -5
  20. package/dist/esm/index.js.map +1 -1
  21. package/dist/esm/stores/context.store.d.ts +7 -7
  22. package/dist/esm/stores/context.store.js +14 -14
  23. package/dist/esm/stores/index.d.ts +5 -5
  24. package/dist/esm/stores/index.js +5 -5
  25. package/dist/esm/stores/inject.store.d.ts +7 -6
  26. package/dist/esm/stores/inject.store.js +13 -19
  27. package/dist/esm/stores/inject.store.js.map +1 -1
  28. package/dist/esm/stores/injectable.store.d.ts +8 -8
  29. package/dist/esm/stores/injectable.store.js +11 -11
  30. package/dist/esm/stores/locator.store.d.ts +7 -7
  31. package/dist/esm/stores/locator.store.js +31 -32
  32. package/dist/esm/stores/locator.store.js.map +1 -1
  33. package/dist/esm/stores/scope.store.d.ts +6 -7
  34. package/dist/esm/stores/scope.store.js +11 -11
  35. package/dist/esm/stores/scope.store.js.map +1 -1
  36. package/dist/esm/types/constructable.type.d.ts +1 -1
  37. package/dist/esm/types/constructable.type.js +1 -1
  38. package/dist/esm/types/context.type.d.ts +5 -5
  39. package/dist/esm/types/context.type.js +1 -1
  40. package/dist/esm/types/index.d.ts +5 -5
  41. package/dist/esm/types/index.js +5 -5
  42. package/dist/esm/types/inject.type.d.ts +9 -9
  43. package/dist/esm/types/inject.type.js +1 -1
  44. package/dist/esm/types/injectable.type.d.ts +12 -12
  45. package/dist/esm/types/injectable.type.js +1 -1
  46. package/dist/esm/types/locator.type.d.ts +8 -8
  47. package/dist/esm/types/locator.type.js +1 -1
  48. package/package.json +5 -4
@@ -1,7 +1,7 @@
1
- import { InjectableToken, InjectToken, LocatorOptions } from '../types';
2
- type Reference = string | symbol | LocatorOptions;
3
- type Config<T> = Undefined<LocatorOptions<T>>;
4
- export declare function saveInLocator(dependencies: LocatorOptions[]): void;
5
- export declare function pushInLocator(reference: Reference, token?: InjectableToken): void;
6
- export declare function requestInLocator<T = any>(token: InjectToken<T>): Config<T>;
7
- export {};
1
+ import { InjectableToken, InjectToken, LocatorOptions } from '../types';
2
+ type Reference = string | symbol | LocatorOptions;
3
+ type Options<T> = Undefined<LocatorOptions<T>>;
4
+ export declare function saveInLocator(dependencies: LocatorOptions[]): void;
5
+ export declare function pushInLocator(reference: Reference, token?: InjectableToken): void;
6
+ export declare function requestInLocator<T = any>(token: InjectToken<T>): Options<T>;
7
+ export {};
@@ -1,33 +1,32 @@
1
- class LocatorStore {
2
- constructor() {
3
- this.collection = new Map();
4
- }
5
- save(dependencies) {
6
- dependencies.forEach((config) => {
7
- this.collection.set(config.token, config);
8
- });
9
- }
10
- push(reference, token) {
11
- if (typeof reference !== 'string' && typeof reference !== 'symbol') {
12
- const { token, useClass } = reference;
13
- this.collection.set(token, { token, useClass });
14
- }
15
- else if (token) {
16
- this.collection.set(reference, { token, useClass: token });
17
- }
18
- }
19
- request(token) {
20
- return this.collection.get(token);
21
- }
22
- }
23
- const locatorStore = new LocatorStore();
24
- export function saveInLocator(dependencies) {
25
- locatorStore.save(dependencies);
26
- }
27
- export function pushInLocator(reference, token) {
28
- locatorStore.push(reference, token);
29
- }
30
- export function requestInLocator(token) {
31
- return locatorStore.request(token);
32
- }
1
+ class LocatorStore {
2
+ constructor() {
3
+ this.collection = new Map();
4
+ }
5
+ save(options) {
6
+ options.forEach((option) => {
7
+ this.collection.set(option.token, option);
8
+ });
9
+ }
10
+ push(reference, token) {
11
+ if (typeof reference !== 'string' && typeof reference !== 'symbol') {
12
+ this.collection.set(reference.token, reference);
13
+ }
14
+ else if (token) {
15
+ this.collection.set(reference, { token, useClass: token });
16
+ }
17
+ }
18
+ request(token) {
19
+ return this.collection.get(token);
20
+ }
21
+ }
22
+ const LOCATOR_STORE = new LocatorStore();
23
+ export function saveInLocator(dependencies) {
24
+ LOCATOR_STORE.save(dependencies);
25
+ }
26
+ export function pushInLocator(reference, token) {
27
+ LOCATOR_STORE.push(reference, token);
28
+ }
29
+ export function requestInLocator(token) {
30
+ return LOCATOR_STORE.request(token);
31
+ }
33
32
  //# sourceMappingURL=locator.store.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"locator.store.js","sourceRoot":"","sources":["../../../src/stores/locator.store.ts"],"names":[],"mappings":"AAKA,MAAM,YAAY;IAGhB;QACE,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;IAC9B,CAAC;IAEM,IAAI,CAAC,YAA8B;QACxC,YAAY,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YAC9B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,IAAI,CAAC,SAAoB,EAAE,KAAuB;QACvD,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;YAClE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,SAAS,C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IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAClD,CAAC;aAAM,IAAI,KAAK,EAAE,CAAC;YACjB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAEM,OAAO,CAAc,KAAqB;QAC/C,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;CACF;AAED,MAAM,aAAa,GAAG,IAAI,YAAY,EAAE,CAAC;AAEzC,MAAM,UAAU,aAAa,CAAC,YAA8B;IAC1D,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,SAAoB,EACpB,KAAuB;IAEvB,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAU,KAAqB;IAC7D,OAAO,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACtC,CAAC"}
@@ -1,7 +1,6 @@
1
- import { InjectableToken } from '../types';
2
- export declare class ScopeStore {
3
- private readonly collection;
4
- constructor();
5
- push(token: InjectableToken, value: any): void;
6
- request<T = any>(token: InjectableToken): T;
7
- }
1
+ import { InjectableToken } from '../types';
2
+ export declare class ScopeStore {
3
+ private readonly collection;
4
+ push(token: InjectableToken, value: any): void;
5
+ request<T = any>(token: InjectableToken): T;
6
+ }
@@ -1,12 +1,12 @@
1
- export class ScopeStore {
2
- constructor() {
3
- this.collection = new Map();
4
- }
5
- push(token, value) {
6
- this.collection.set(token, value);
7
- }
8
- request(token) {
9
- return this.collection.get(token);
10
- }
11
- }
1
+ export class ScopeStore {
2
+ constructor() {
3
+ this.collection = new Map();
4
+ }
5
+ push(token, value) {
6
+ this.collection.set(token, value);
7
+ }
8
+ request(token) {
9
+ return this.collection.get(token);
10
+ }
11
+ }
12
12
  //# sourceMappingURL=scope.store.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scope.store.js","sourceRoot":"","sources":["../../../src/stores/scope.store.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,UAAU;IAGrB;QACE,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;IAC9B,CAAC;IAEM,IAAI,CAAC,KAAsB,EAAE,KAAU;QAC5C,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IAEM,OAAO,CAAU,KAAsB;QAC5C,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAM,CAAC;IACzC,CAAC;CACF"}
1
+ {"version":3,"file":"scope.store.js","sourceRoot":"","sources":["../../../src/stores/scope.store.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,UAAU;IAAvB;QACmB,eAAU,GAA8B,IAAI,GAAG,EAAE,CAAC;IASrE,CAAC;IAPQ,IAAI,CAAC,KAAsB,EAAE,KAAU;QAC5C,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IAEM,OAAO,CAAU,KAAsB;QAC5C,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;CACF"}
@@ -1 +1 @@
1
- export type Constructable<T = any> = new (...args: any[]) => T;
1
+ export type Constructable<T = any> = new (...args: any[]) => T;
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=constructable.type.js.map
@@ -1,5 +1,5 @@
1
- export interface AbstractContext<K = string> {
2
- set(key: K, value?: any): void;
3
- request<T = any>(key: K): Undefined<T>;
4
- has(key: K): boolean;
5
- }
1
+ export interface AbstractContext<K = string> {
2
+ set(key: K, value?: any): void;
3
+ request<T = any>(key: K): Undefined<T>;
4
+ has(key: K): boolean;
5
+ }
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=context.type.js.map
@@ -1,5 +1,5 @@
1
- export * from './constructable.type';
2
- export * from './context.type';
3
- export * from './inject.type';
4
- export * from './injectable.type';
5
- export * from './locator.type';
1
+ export * from './constructable.type';
2
+ export * from './context.type';
3
+ export * from './inject.type';
4
+ export * from './injectable.type';
5
+ export * from './locator.type';
@@ -1,6 +1,6 @@
1
- export * from './constructable.type';
2
- export * from './context.type';
3
- export * from './inject.type';
4
- export * from './injectable.type';
5
- export * from './locator.type';
1
+ export * from './constructable.type';
2
+ export * from './context.type';
3
+ export * from './inject.type';
4
+ export * from './injectable.type';
5
+ export * from './locator.type';
6
6
  //# sourceMappingURL=index.js.map
@@ -1,9 +1,9 @@
1
- import { InjectableToken } from './injectable.type';
2
- export type InjectToken<T = any> = InjectableToken<T> | string | symbol;
3
- export type InjectOptions<T = any> = {
4
- index: number;
5
- parent: InjectableToken;
6
- scopeable: boolean;
7
- singleton: boolean;
8
- token: InjectToken<T>;
9
- };
1
+ import { InjectableToken } from './injectable.type';
2
+ export type InjectToken<T = any> = InjectableToken<T> | string | symbol;
3
+ export type InjectOptions<T = any> = {
4
+ index: number;
5
+ parent: InjectableToken;
6
+ scopeable: boolean;
7
+ singleton: boolean;
8
+ token: InjectToken<T>;
9
+ };
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=inject.type.js.map
@@ -1,12 +1,12 @@
1
- import { Constructable } from './constructable.type';
2
- import { AbstractContext } from './context.type';
3
- export type InjectableToken<T = any> = Object | Function | CallableFunction | Constructable<T>;
4
- export interface InjectableOptions<T = any> {
5
- scopeable: boolean;
6
- singleton: boolean;
7
- token: InjectableToken<T>;
8
- }
9
- export interface InjectionOptions<T> {
10
- token: InjectableToken<T>;
11
- context?: AbstractContext;
12
- }
1
+ import { Constructable } from './constructable.type';
2
+ import { AbstractContext } from './context.type';
3
+ export type InjectableToken<T = any> = Object | Function | CallableFunction | Constructable<T>;
4
+ export interface InjectableOptions<T = any> {
5
+ scopeable: boolean;
6
+ singleton: boolean;
7
+ token: InjectableToken<T>;
8
+ }
9
+ export interface InjectionOptions<T> {
10
+ token: InjectableToken<T>;
11
+ context?: AbstractContext;
12
+ }
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=injectable.type.js.map
@@ -1,8 +1,8 @@
1
- import { InjectToken } from './inject.type';
2
- import { InjectableToken } from './injectable.type';
3
- export type LocatorOptions<T = any> = {
4
- token: InjectToken;
5
- useClass: InjectableToken<T>;
6
- scopeable?: boolean;
7
- singleton?: boolean;
8
- };
1
+ import { InjectToken } from './inject.type';
2
+ import { InjectableToken } from './injectable.type';
3
+ export type LocatorOptions<T = any> = {
4
+ token: InjectToken;
5
+ useClass: InjectableToken<T>;
6
+ scopeable?: boolean;
7
+ singleton?: boolean;
8
+ };
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=locator.type.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rolster/invertly",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "Invertly is a package that allows you to implement class mapping to identify and inject their dependencies.",
5
5
  "module": "dist/esm/index.js",
6
6
  "main": "dist/cjs/index.js",
@@ -26,13 +26,14 @@
26
26
  "prepublishOnly": "npm run build"
27
27
  },
28
28
  "dependencies": {
29
- "reflect-metadata": "^0.1.13"
29
+ "@rolster/commons": "^2.1.0",
30
+ "reflect-metadata": "^0.2.2"
30
31
  },
31
32
  "devDependencies": {
32
33
  "@rollup/plugin-commonjs": "^25.0.4",
33
34
  "@rollup/plugin-node-resolve": "^15.2.1",
34
35
  "@rollup/plugin-typescript": "^11.1.3",
35
- "@rolster/types": "^1.0.9",
36
+ "@rolster/types": "^1.1.0",
36
37
  "@types/jest": "^29.5.1",
37
38
  "jest": "^29.5.0",
38
39
  "prettier": "^3.0.3",
@@ -40,7 +41,7 @@
40
41
  "rollup": "^2.32.0",
41
42
  "ts-jest": "^29.1.0",
42
43
  "tslib": "^2.4.0",
43
- "typescript": "^4.9.3"
44
+ "typescript": "^5.7.2"
44
45
  },
45
46
  "repository": {
46
47
  "type": "git",