@zudojs/container 0.1.0 → 1.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.
Files changed (86) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +221 -8
  3. package/dist/containerCore/containerCore.core.d.ts +112 -14
  4. package/dist/containerCore/containerCore.core.js +228 -46
  5. package/dist/containerCore/containerCore.scope.d.ts +66 -18
  6. package/dist/containerCore/containerCore.scope.js +120 -31
  7. package/dist/containerCore/containerCore.type.d.ts +22 -16
  8. package/dist/containerLifecycle/containerLifecycle.core.d.ts +59 -9
  9. package/dist/containerLifecycle/containerLifecycle.core.js +60 -15
  10. package/dist/containerOptions/containerOptions.type.d.ts +7 -17
  11. package/dist/containerOptions/containerOptions.type.js +0 -19
  12. package/dist/containerProvider/containerProvider.core.d.ts +11 -3
  13. package/dist/containerProvider/containerProvider.core.js +11 -5
  14. package/dist/containerRegistration/containerRegistration.core.d.ts +9 -3
  15. package/dist/containerRegistration/containerRegistration.core.js +0 -6
  16. package/dist/containerRegistry/containerRegistry.core.d.ts +23 -9
  17. package/dist/containerRegistry/containerRegistry.core.js +50 -47
  18. package/dist/containerRegistry/containerRegistry.type.d.ts +3 -1
  19. package/dist/containerRegistry/containerRegistry.type.js +2 -0
  20. package/dist/containerRegistry/index.d.ts +0 -1
  21. package/dist/containerRegistry/index.js +0 -1
  22. package/dist/containerResolution/containerResolution.core.d.ts +51 -10
  23. package/dist/containerResolution/containerResolution.core.js +255 -64
  24. package/dist/containerResolution/containerResolution.error.d.ts +68 -3
  25. package/dist/containerResolution/containerResolution.error.js +107 -3
  26. package/dist/containerResolution/containerResolution.type.d.ts +35 -3
  27. package/dist/containerResolution/index.d.ts +1 -0
  28. package/dist/containerResolution/index.js +1 -0
  29. package/dist/containerToken/containerToken.type.d.ts +26 -1
  30. package/dist/containerToken/containerToken.type.js +18 -0
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.js +3 -0
  33. package/package.json +25 -12
  34. package/dist/.tsbuildinfo +0 -1
  35. package/dist/containerCore/containerCore.core.d.ts.map +0 -1
  36. package/dist/containerCore/containerCore.core.js.map +0 -1
  37. package/dist/containerCore/containerCore.scope.d.ts.map +0 -1
  38. package/dist/containerCore/containerCore.scope.js.map +0 -1
  39. package/dist/containerCore/containerCore.type.d.ts.map +0 -1
  40. package/dist/containerCore/containerCore.type.js.map +0 -1
  41. package/dist/containerCore/index.d.ts.map +0 -1
  42. package/dist/containerCore/index.js.map +0 -1
  43. package/dist/containerLifecycle/containerLifecycle.core.d.ts.map +0 -1
  44. package/dist/containerLifecycle/containerLifecycle.core.js.map +0 -1
  45. package/dist/containerLifecycle/index.d.ts.map +0 -1
  46. package/dist/containerLifecycle/index.js.map +0 -1
  47. package/dist/containerOptions/containerOptions.type.d.ts.map +0 -1
  48. package/dist/containerOptions/containerOptions.type.js.map +0 -1
  49. package/dist/containerOptions/index.d.ts.map +0 -1
  50. package/dist/containerOptions/index.js.map +0 -1
  51. package/dist/containerProvider/containerProvider.core.d.ts.map +0 -1
  52. package/dist/containerProvider/containerProvider.core.js.map +0 -1
  53. package/dist/containerProvider/index.d.ts.map +0 -1
  54. package/dist/containerProvider/index.js.map +0 -1
  55. package/dist/containerRegistration/containerRegistration.core.d.ts.map +0 -1
  56. package/dist/containerRegistration/containerRegistration.core.js.map +0 -1
  57. package/dist/containerRegistration/index.d.ts.map +0 -1
  58. package/dist/containerRegistration/index.js.map +0 -1
  59. package/dist/containerRegistry/containerRegistry.core.d.ts.map +0 -1
  60. package/dist/containerRegistry/containerRegistry.core.js.map +0 -1
  61. package/dist/containerRegistry/containerRegistry.error.d.ts +0 -12
  62. package/dist/containerRegistry/containerRegistry.error.d.ts.map +0 -1
  63. package/dist/containerRegistry/containerRegistry.error.js +0 -22
  64. package/dist/containerRegistry/containerRegistry.error.js.map +0 -1
  65. package/dist/containerRegistry/containerRegistry.type.d.ts.map +0 -1
  66. package/dist/containerRegistry/containerRegistry.type.js.map +0 -1
  67. package/dist/containerRegistry/index.d.ts.map +0 -1
  68. package/dist/containerRegistry/index.js.map +0 -1
  69. package/dist/containerResolution/containerResolution.core.d.ts.map +0 -1
  70. package/dist/containerResolution/containerResolution.core.js.map +0 -1
  71. package/dist/containerResolution/containerResolution.error.d.ts.map +0 -1
  72. package/dist/containerResolution/containerResolution.error.js.map +0 -1
  73. package/dist/containerResolution/containerResolution.type.d.ts.map +0 -1
  74. package/dist/containerResolution/containerResolution.type.js.map +0 -1
  75. package/dist/containerResolution/index.d.ts.map +0 -1
  76. package/dist/containerResolution/index.js.map +0 -1
  77. package/dist/containerScope/containerScope.type.d.ts.map +0 -1
  78. package/dist/containerScope/containerScope.type.js.map +0 -1
  79. package/dist/containerScope/index.d.ts.map +0 -1
  80. package/dist/containerScope/index.js.map +0 -1
  81. package/dist/containerToken/containerToken.type.d.ts.map +0 -1
  82. package/dist/containerToken/containerToken.type.js.map +0 -1
  83. package/dist/containerToken/index.d.ts.map +0 -1
  84. package/dist/containerToken/index.js.map +0 -1
  85. package/dist/index.d.ts.map +0 -1
  86. package/dist/index.js.map +0 -1
@@ -2,8 +2,15 @@
2
2
  * Dependency injection token definitions for Zudojs.
3
3
  * Tokens identify dependencies within the container.
4
4
  */
5
+ /**
6
+ * A class constructor usable as a token or provider implementation.
7
+ *
8
+ * The parameter list is intentionally loose (`any[]`) so classes with typed
9
+ * constructor parameters are accepted; the container supplies arguments via
10
+ * the provider's `inject` list (or none for zero-arg constructors).
11
+ */
5
12
  export interface Constructor<T = unknown> {
6
- new (...args: unknown[]): T;
13
+ new (...args: any[]): T;
7
14
  }
8
15
  export type TokenSymbol = symbol;
9
16
  export type TokenString = string;
@@ -12,7 +19,25 @@ export interface InjectionToken<T = unknown> {
12
19
  readonly token: Token<T>;
13
20
  readonly description?: string;
14
21
  }
22
+ /**
23
+ * Creates a unique, typed injection token backed by a fresh `Symbol`.
24
+ *
25
+ * Note on typing: plain string and symbol tokens are *untyped casts* — the
26
+ * container cannot verify at compile time that the value registered under a
27
+ * string/symbol actually has type `T`. Prefer `InjectionToken`s created here
28
+ * (or constructor tokens) so the association between token and type lives in
29
+ * one place.
30
+ */
15
31
  export declare function createToken<T>(description: string): InjectionToken<T>;
32
+ /**
33
+ * Creates a typed injection token backed by `Symbol.for(key)`.
34
+ *
35
+ * Because `Symbol.for` uses the process-wide global symbol registry, two
36
+ * independent calls (even from different packages) with the same `key`
37
+ * produce the SAME token and will collide in the container — this is by
38
+ * design for cross-package sharing, but means keys must be namespaced
39
+ * (e.g. `"myapp:db"`). Use {@link createToken} for collision-free tokens.
40
+ */
16
41
  export declare function createGlobalToken<T>(key: string): InjectionToken<T>;
17
42
  export declare function unwrapToken<T>(token: Token<T> | InjectionToken<T>): Token<T>;
18
43
  export declare function isInjectionToken<T = unknown>(value: unknown): value is InjectionToken<T>;
@@ -2,9 +2,27 @@
2
2
  * Dependency injection token definitions for Zudojs.
3
3
  * Tokens identify dependencies within the container.
4
4
  */
5
+ /**
6
+ * Creates a unique, typed injection token backed by a fresh `Symbol`.
7
+ *
8
+ * Note on typing: plain string and symbol tokens are *untyped casts* — the
9
+ * container cannot verify at compile time that the value registered under a
10
+ * string/symbol actually has type `T`. Prefer `InjectionToken`s created here
11
+ * (or constructor tokens) so the association between token and type lives in
12
+ * one place.
13
+ */
5
14
  export function createToken(description) {
6
15
  return Object.freeze({ token: Symbol(description), description });
7
16
  }
17
+ /**
18
+ * Creates a typed injection token backed by `Symbol.for(key)`.
19
+ *
20
+ * Because `Symbol.for` uses the process-wide global symbol registry, two
21
+ * independent calls (even from different packages) with the same `key`
22
+ * produce the SAME token and will collide in the container — this is by
23
+ * design for cross-package sharing, but means keys must be namespaced
24
+ * (e.g. `"myapp:db"`). Use {@link createToken} for collision-free tokens.
25
+ */
8
26
  export function createGlobalToken(key) {
9
27
  return Object.freeze({ token: Symbol.for(key), description: key });
10
28
  }
package/dist/index.d.ts CHANGED
@@ -12,4 +12,5 @@ export * from "./containerRegistry/index.js";
12
12
  export * from "./containerResolution/index.js";
13
13
  export * from "./containerScope/index.js";
14
14
  export * from "./containerToken/index.js";
15
+ export { CircularDependencyError, DuplicateRegistrationError, RegistrationNotFoundError, ProviderResolutionError, } from "@zudojs/errors";
15
16
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -12,4 +12,7 @@ export * from "./containerRegistry/index.js";
12
12
  export * from "./containerResolution/index.js";
13
13
  export * from "./containerScope/index.js";
14
14
  export * from "./containerToken/index.js";
15
+ // Error classes the container throws but that live in @zudojs/errors,
16
+ // re-exported so `instanceof` checks need only this package.
17
+ export { CircularDependencyError, DuplicateRegistrationError, RegistrationNotFoundError, ProviderResolutionError, } from "@zudojs/errors";
15
18
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zudojs/container",
3
- "version": "0.1.0",
3
+ "version": "1.1.0",
4
4
  "description": "Token-based dependency injection container for managing application dependencies and service lifetimes.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -12,27 +12,29 @@
12
12
  }
13
13
  },
14
14
  "files": [
15
- "dist"
15
+ "dist",
16
+ "!dist/**/*.map",
17
+ "!dist/**/*.tsbuildinfo",
18
+ "!dist/.tsbuildinfo"
16
19
  ],
17
- "scripts": {
18
- "build": "tsc -p tsconfig.json",
19
- "typecheck": "tsc -p tsconfig.json --noEmit",
20
- "clean": "tsc -p tsconfig.json --clean"
21
- },
22
20
  "dependencies": {
23
- "@zudojs/errors": "0.1.0"
21
+ "@zudojs/errors": "1.0.1"
24
22
  },
25
23
  "devDependencies": {
26
- "typescript": "^7.0.2"
24
+ "typescript": "7.0.2",
25
+ "vitest": "^4.1.11"
27
26
  },
28
27
  "license": "MIT",
28
+ "author": {
29
+ "name": "Oluwayemi Oyinlola",
30
+ "url": "https://github.com/oyinlola-tech"
31
+ },
29
32
  "publishConfig": {
30
33
  "access": "public"
31
34
  },
32
35
  "engines": {
33
36
  "node": ">=24.0.0"
34
37
  },
35
- "module": "./dist/index.js",
36
38
  "keywords": [
37
39
  "zudojs",
38
40
  "di",
@@ -40,8 +42,19 @@
40
42
  "container"
41
43
  ],
42
44
  "homepage": "https://github.com/oyinlola-tech/zudo#readme",
45
+ "bugs": {
46
+ "url": "https://github.com/oyinlola-tech/zudo/issues"
47
+ },
43
48
  "repository": {
44
49
  "type": "git",
45
- "url": "https://github.com/oyinlola-tech/zudo"
50
+ "url": "https://github.com/oyinlola-tech/zudo",
51
+ "directory": "packages/container"
52
+ },
53
+ "scripts": {
54
+ "build": "tsc -p tsconfig.json",
55
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json --noEmit",
56
+ "clean": "rm -rf dist",
57
+ "test": "vitest run",
58
+ "test:watch": "vitest"
46
59
  }
47
- }
60
+ }