@decohere/crucible 0.0.1-dev.29 → 0.0.1-dev.3

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 (45) hide show
  1. package/package.json +3 -3
  2. package/{es6/src → src}/decorators/inject.decorator.js +2 -2
  3. package/src/services/crucible.js +133 -0
  4. package/tests/container.spec.js +259 -0
  5. package/commonjs/src/const.js +0 -33
  6. package/commonjs/src/decorators/index.js +0 -21
  7. package/commonjs/src/decorators/inject.decorator.js +0 -27
  8. package/commonjs/src/decorators/injectable.dectorator.js +0 -16
  9. package/commonjs/src/index.js +0 -22
  10. package/commonjs/src/models/registration-key.model.js +0 -31
  11. package/commonjs/src/models/service-registration.model.js +0 -30
  12. package/commonjs/src/services/crucible-builder.js +0 -68
  13. package/commonjs/src/services/crucible.js +0 -165
  14. package/commonjs/src/services/index.js +0 -21
  15. package/commonjs/src/services/service-registry.js +0 -50
  16. package/commonjs/src/types/errors.js +0 -29
  17. package/commonjs/src/types/index.js +0 -20
  18. package/commonjs/src/types/types.js +0 -6
  19. package/es6/src/services/crucible.js +0 -155
  20. package/types/src/const.d.ts +0 -9
  21. package/types/src/decorators/index.d.ts +0 -2
  22. package/types/src/decorators/inject.decorator.d.ts +0 -5
  23. package/types/src/decorators/injectable.dectorator.d.ts +0 -1
  24. package/types/src/index.d.ts +0 -3
  25. package/types/src/models/registration-key.model.d.ts +0 -7
  26. package/types/src/models/service-registration.model.d.ts +0 -11
  27. package/types/src/services/crucible-builder.d.ts +0 -26
  28. package/types/src/services/crucible.d.ts +0 -31
  29. package/types/src/services/index.d.ts +0 -2
  30. package/types/src/services/service-registry.d.ts +0 -16
  31. package/types/src/types/errors.d.ts +0 -6
  32. package/types/src/types/index.d.ts +0 -1
  33. package/types/src/types/types.d.ts +0 -1
  34. /package/{es6/src → src}/const.js +0 -0
  35. /package/{es6/src → src}/decorators/index.js +0 -0
  36. /package/{es6/src → src}/decorators/injectable.dectorator.js +0 -0
  37. /package/{es6/src → src}/index.js +0 -0
  38. /package/{es6/src → src}/models/registration-key.model.js +0 -0
  39. /package/{es6/src → src}/models/service-registration.model.js +0 -0
  40. /package/{es6/src → src}/services/crucible-builder.js +0 -0
  41. /package/{es6/src → src}/services/index.js +0 -0
  42. /package/{es6/src → src}/services/service-registry.js +0 -0
  43. /package/{es6/src → src}/types/errors.js +0 -0
  44. /package/{es6/src → src}/types/index.js +0 -0
  45. /package/{es6/src → src}/types/types.js +0 -0
@@ -1 +0,0 @@
1
- export declare function injectable(): ClassDecorator;
@@ -1,3 +0,0 @@
1
- export * from "./const.js";
2
- export * from "./services/index.js";
3
- export * from "./types/index.js";
@@ -1,7 +0,0 @@
1
- import type { Constructable } from "@decohere/nexus/reflection";
2
- export declare class RegistrationKey {
3
- constructor(key: string | symbol | Constructable);
4
- value: string;
5
- private getValue;
6
- toString(): string;
7
- }
@@ -1,11 +0,0 @@
1
- import type { Constructable, FunctionType } from "@decohere/nexus/reflection";
2
- import type { Scope } from "../types/types.js";
3
- import type { RegistrationKey } from "./registration-key.model.js";
4
- export declare class ServiceRegistration {
5
- key: RegistrationKey;
6
- scope: Scope;
7
- type: Constructable | FunctionType | object;
8
- isInstance: boolean;
9
- constructor(key: RegistrationKey, type: Constructable | FunctionType | object, scope: Scope, isInstance: boolean);
10
- isEqual(other: ServiceRegistration): boolean;
11
- }
@@ -1,26 +0,0 @@
1
- import type { Constructable, FunctionType } from "@decohere/nexus/reflection";
2
- import type { ServiceRegistration } from "../models/service-registration.model.js";
3
- import type { ContainerBuilder, Scope } from "../types/types.js";
4
- import { Crucible } from "./crucible.js";
5
- import { ServiceRegistry } from "./service-registry.js";
6
- type ContainerBuilderOptions = {
7
- serviceRegistry: ServiceRegistry;
8
- };
9
- export declare class CrucibleBuilder implements ContainerBuilder {
10
- private serviceRegistry;
11
- constructor(options?: ContainerBuilderOptions);
12
- registerType(type: Constructable, scope?: Scope): ServiceRegistration;
13
- registerTypes(...types: Constructable[]): ServiceRegistration[];
14
- registerTypes(scope: Scope, ...types: Constructable[]): ServiceRegistration[];
15
- registerTransient(key: string | symbol, type: Constructable | FunctionType): ServiceRegistration;
16
- registerTransient(type: Constructable): ServiceRegistration;
17
- registerSingleton(key: string | symbol | Constructable | object, instance: object): ServiceRegistration;
18
- registerSingleton(key: string | symbol, type: Constructable): ServiceRegistration;
19
- registerSingleton(type: Constructable): ServiceRegistration;
20
- registerRequestScoped<T>(type: () => T): ServiceRegistration;
21
- registerRequestScoped<T>(key: string | symbol, type: () => T): ServiceRegistration;
22
- registerRequestScoped(key: string | symbol, type: Constructable): ServiceRegistration;
23
- registerRequestScoped(type: Constructable): ServiceRegistration;
24
- build(): Crucible;
25
- }
26
- export {};
@@ -1,31 +0,0 @@
1
- import type { IContainer, ResolveRequest } from "../types/types.js";
2
- import { ServiceRegistry } from "./service-registry.js";
3
- type CrucibleOptions = {
4
- key?: string;
5
- rootScope?: Crucible;
6
- serviceRegistry: ServiceRegistry;
7
- };
8
- export declare class Crucible implements IContainer {
9
- key: string;
10
- protected instances: Map<unknown, object>;
11
- private serviceRegistry;
12
- private rootScope;
13
- private scopes;
14
- private logger;
15
- private isDisposed;
16
- constructor(options?: CrucibleOptions);
17
- resolveMany<T extends object = object>(resolveRequest: ResolveRequest<T>): T[];
18
- resolve<T extends object | object[]>(resolveRequest: ResolveRequest<T>): T;
19
- beginScope(name?: string): Crucible;
20
- [Symbol.dispose](): void;
21
- [Symbol.asyncDispose](): Promise<void>;
22
- private disposeSync;
23
- private disposeAsync;
24
- private getRegistrationFrom;
25
- private resolveRegistration;
26
- private getOrCreateInstance;
27
- private createInstance;
28
- private resolveDependencies;
29
- private registerLifetimeScope;
30
- }
31
- export {};
@@ -1,2 +0,0 @@
1
- export * from "./crucible.js";
2
- export * from "./crucible-builder.js";
@@ -1,16 +0,0 @@
1
- import type { Constructable, FunctionType } from "@decohere/nexus/reflection";
2
- import { ServiceRegistration } from "../models/service-registration.model.js";
3
- import type { Scope } from "../types/types.js";
4
- export type RegisterTypeOptions = {
5
- typeOrKey: string | symbol | Constructable | FunctionType;
6
- typeOrInstance?: Constructable | FunctionType | object;
7
- };
8
- export declare class ServiceRegistry {
9
- private readonly registrations;
10
- constructor(parent?: ServiceRegistry);
11
- registerType(scope: Scope, options: RegisterTypeOptions): ServiceRegistration;
12
- getRegistration(key: string | symbol | Constructable): ServiceRegistration[];
13
- private createRegistrationFrom;
14
- private getRegistrations;
15
- private setRegistration;
16
- }
@@ -1,6 +0,0 @@
1
- export declare class ResolveError extends Error {
2
- }
3
- export declare class DuplicateScopeError extends Error {
4
- }
5
- export declare class RegistrationError extends Error {
6
- }
@@ -1 +0,0 @@
1
- export * from "./types.js";
@@ -1 +0,0 @@
1
- export type { ContainerBuilder, IContainer, LifetimeScope, ResolveRequest, Scope, ServiceProvider, } from "@decohere/nexus/composition";
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes