@sentzunhat/zacatl 0.0.23 β†’ 0.0.25

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 CHANGED
@@ -5,8 +5,8 @@
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
6
  [![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-3178c6.svg)](https://www.typescriptlang.org/)
7
7
  [![Node.js 24+](https://img.shields.io/badge/Node.js-24%2B-brightgreen.svg)](https://nodejs.org/)
8
- [![Tests: 180](https://img.shields.io/badge/Tests-180-blue.svg)](#testing)
9
- [![Coverage: 79%](https://img.shields.io/badge/Coverage-79%25-brightgreen.svg)](#testing)
8
+ [![Tests: 188](https://img.shields.io/badge/Tests-188-blue.svg)](#testing)
9
+ [![Coverage: 78%](https://img.shields.io/badge/Coverage-78%25-brightgreen.svg)](#testing)
10
10
 
11
11
  **Production-ready TypeScript framework for building scalable microservices, APIs, and distributed systems.**
12
12
 
@@ -47,29 +47,24 @@ Zacatl is MIT-licensed (permissive). Please don’t use it to harm people.
47
47
  npm install @sentzunhat/zacatl
48
48
  ```
49
49
 
50
- ## πŸ“¦ Import Options (v0.0.23+)
50
+ ## πŸ“¦ Import Strategy (v0.0.24+)
51
51
 
52
- > **New in v0.0.23:** Dual-option import strategy. Choose convenience (main package) or minimal bundles (subpaths). [Import Guide](./docs/guides/orm-import-strategies.md)
52
+ > **⚠️ Breaking Change in v0.0.24:** Main package no longer exports ORMs. Use dedicated subpaths to prevent eager loading. [Migration Guide](./docs/migration/v0.0.24.md)
53
53
 
54
54
  ```typescript
55
- // Option 1: Main package (convenience - everything in one place)
56
- import {
57
- Service,
58
- mongoose,
59
- Schema,
60
- Sequelize,
61
- singleton,
62
- } from "@sentzunhat/zacatl";
63
-
64
- // Option 2: Subpath imports (minimal - tree-shakeable)
55
+ // βœ… Recommended: Subpath imports (tree-shakeable, no eager loading)
65
56
  import { Service } from "@sentzunhat/zacatl";
66
57
  import { mongoose, Schema } from "@sentzunhat/zacatl/orm/mongoose";
58
+ import { Sequelize, DataTypes } from "@sentzunhat/zacatl/orm/sequelize";
67
59
  import { resolveDependency } from "@sentzunhat/zacatl/application";
68
60
 
69
- // Subpath shortcuts
61
+ // Other subpath shortcuts
70
62
  import { BaseRepository, ORMType } from "@sentzunhat/zacatl/infrastructure";
71
63
  import { CustomError } from "@sentzunhat/zacatl/errors";
72
64
  import { loadConfig } from "@sentzunhat/zacatl/config";
65
+
66
+ // ❌ No longer available (removed in v0.0.24)
67
+ // import { mongoose } from "@sentzunhat/zacatl"; // Would cause eager loading
73
68
  ```
74
69
 
75
70
  ### Hello World HTTP Service
@@ -5,5 +5,7 @@ export declare const registerDependency: <T>(token: InjectionToken<T>, implement
5
5
  export declare const registerSingleton: <T>(token: InjectionToken<T>, implementation: new (...args: unknown[]) => T) => void;
6
6
  export declare const registerValue: <T>(token: InjectionToken<T>, value: T) => void;
7
7
  export declare const resolveDependency: <T>(token: InjectionToken<T>) => T;
8
+ export declare const registerWithDependencies: <T>(serviceClass: new (...args: unknown[]) => T, dependencies?: Array<new (...args: unknown[]) => unknown>) => void;
9
+ export declare const registerSingletonWithDependencies: <T>(serviceClass: new (...args: unknown[]) => T, dependencies?: Array<new (...args: unknown[]) => unknown>) => void;
8
10
  export declare const clearContainer: () => void;
9
11
  //# sourceMappingURL=container.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"container.d.ts","sourceRoot":"./src/","sources":["dependency-injection/container.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAiCpE,eAAO,MAAM,YAAY,QAAO,mBAE/B,CAAC;AAQF,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAClC,OAAO,cAAc,CAAC,CAAC,CAAC,EACxB,gBAAgB,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,KAC5C,IAEF,CAAC;AAQF,eAAO,MAAM,iBAAiB,GAAI,CAAC,EACjC,OAAO,cAAc,CAAC,CAAC,CAAC,EACxB,gBAAgB,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,KAC5C,IAEF,CAAC;AAQF,eAAO,MAAM,aAAa,GAAI,CAAC,EAAE,OAAO,cAAc,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,KAAG,IAErE,CAAC;AAQF,eAAO,MAAM,iBAAiB,GAAI,CAAC,EAAE,OAAO,cAAc,CAAC,CAAC,CAAC,KAAG,CAE/D,CAAC;AAKF,eAAO,MAAM,cAAc,QAAO,IAGjC,CAAC"}
1
+ {"version":3,"file":"container.d.ts","sourceRoot":"./src/","sources":["dependency-injection/container.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAiCpE,eAAO,MAAM,YAAY,QAAO,mBAE/B,CAAC;AAQF,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAClC,OAAO,cAAc,CAAC,CAAC,CAAC,EACxB,gBAAgB,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,KAC5C,IAEF,CAAC;AAQF,eAAO,MAAM,iBAAiB,GAAI,CAAC,EACjC,OAAO,cAAc,CAAC,CAAC,CAAC,EACxB,gBAAgB,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,KAC5C,IAEF,CAAC;AAQF,eAAO,MAAM,aAAa,GAAI,CAAC,EAAE,OAAO,cAAc,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,KAAG,IAErE,CAAC;AAQF,eAAO,MAAM,iBAAiB,GAAI,CAAC,EAAE,OAAO,cAAc,CAAC,CAAC,CAAC,KAAG,CAE/D,CAAC;AAoBF,eAAO,MAAM,wBAAwB,GAAI,CAAC,EACxC,cAAc,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,EAC3C,eAAc,KAAK,CAAC,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAM,KAC5D,IAOF,CAAC;AAiBF,eAAO,MAAM,iCAAiC,GAAI,CAAC,EACjD,cAAc,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,EAC3C,eAAc,KAAK,CAAC,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAM,KAC5D,IAOF,CAAC;AAKF,eAAO,MAAM,cAAc,QAAO,IAGjC,CAAC"}
@@ -15,6 +15,22 @@ export const registerValue = (token, value) => {
15
15
  export const resolveDependency = (token) => {
16
16
  return tsyringeContainer.resolve(token);
17
17
  };
18
+ export const registerWithDependencies = (serviceClass, dependencies = []) => {
19
+ tsyringeContainer.register(serviceClass, {
20
+ useFactory: (c) => {
21
+ const resolvedDeps = dependencies.map((dep) => c.resolve(dep));
22
+ return new serviceClass(...resolvedDeps);
23
+ },
24
+ });
25
+ };
26
+ export const registerSingletonWithDependencies = (serviceClass, dependencies = []) => {
27
+ tsyringeContainer.registerSingleton(serviceClass, {
28
+ useFactory: (c) => {
29
+ const resolvedDeps = dependencies.map((dep) => c.resolve(dep));
30
+ return new serviceClass(...resolvedDeps);
31
+ },
32
+ });
33
+ };
18
34
  export const clearContainer = () => {
19
35
  tsyringeContainer.clearInstances();
20
36
  tsyringeContainer.reset();
@@ -1 +1 @@
1
- {"version":3,"file":"container.js","sourceRoot":"./src/","sources":["dependency-injection/container.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,IAAI,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAkC1D,MAAM,CAAC,MAAM,YAAY,GAAG,GAAwB,EAAE;IACpD,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AAQF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,KAAwB,EACxB,cAA6C,EACvC,EAAE;IACR,iBAAiB,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC,CAAC;AAClE,CAAC,CAAC;AAQF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,KAAwB,EACxB,cAA6C,EACvC,EAAE;IACR,iBAAiB,CAAC,iBAAiB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;AAC7D,CAAC,CAAC;AAQF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAI,KAAwB,EAAE,KAAQ,EAAQ,EAAE;IAC3E,iBAAiB,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;AACzD,CAAC,CAAC;AAQF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAI,KAAwB,EAAK,EAAE;IAClE,OAAO,iBAAiB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC1C,CAAC,CAAC;AAKF,MAAM,CAAC,MAAM,cAAc,GAAG,GAAS,EAAE;IACvC,iBAAiB,CAAC,cAAc,EAAE,CAAC;IACnC,iBAAiB,CAAC,KAAK,EAAE,CAAC;AAC5B,CAAC,CAAC","sourcesContent":["import \"reflect-metadata\";\nimport { container as tsyringeContainer } from \"tsyringe\";\nimport type { DependencyContainer, InjectionToken } from \"tsyringe\";\n\n/**\n * Standalone DI container decoupled from microservice architecture.\n * Automatically used by Service architecture - typically no manual registration needed.\n *\n * For advanced use cases, you can register dependencies manually:\n *\n * @example\n * ```typescript\n * import { registerDependency, resolveDependency } from '@sentzunhat/zacatl';\n *\n * // Manual registration (advanced use case)\n * class CustomService { ... }\n * registerDependency('CustomService', CustomService);\n *\n * // Resolve manually\n * const service = resolveDependency<CustomService>('CustomService');\n * ```\n *\n * Preferred approach (automatic registration through Service):\n * ```typescript\n * const service = new Service({\n * architecture: {\n * domain: { providers: [CustomService] }\n * }\n * });\n * ```\n */\n\n/**\n * Get the global DI container instance\n */\nexport const getContainer = (): DependencyContainer => {\n return tsyringeContainer;\n};\n\n/**\n * Register a dependency in the container\n *\n * @param token - Unique identifier for the dependency\n * @param implementation - Class or value to register\n */\nexport const registerDependency = <T>(\n token: InjectionToken<T>,\n implementation: new (...args: unknown[]) => T,\n): void => {\n tsyringeContainer.register(token, { useClass: implementation });\n};\n\n/**\n * Register a singleton dependency (shared instance)\n *\n * @param token - Unique identifier for the dependency\n * @param implementation - Class to register as singleton\n */\nexport const registerSingleton = <T>(\n token: InjectionToken<T>,\n implementation: new (...args: unknown[]) => T,\n): void => {\n tsyringeContainer.registerSingleton(token, implementation);\n};\n\n/**\n * Register a value (instance) in the container\n *\n * @param token - Unique identifier for the dependency\n * @param value - Instance to register\n */\nexport const registerValue = <T>(token: InjectionToken<T>, value: T): void => {\n tsyringeContainer.register(token, { useValue: value });\n};\n\n/**\n * Resolve a dependency from the container\n *\n * @param token - Unique identifier for the dependency\n * @returns Resolved instance\n */\nexport const resolveDependency = <T>(token: InjectionToken<T>): T => {\n return tsyringeContainer.resolve(token);\n};\n\n/**\n * Clear all registrations (useful for testing)\n */\nexport const clearContainer = (): void => {\n tsyringeContainer.clearInstances();\n tsyringeContainer.reset();\n};\n"]}
1
+ {"version":3,"file":"container.js","sourceRoot":"./src/","sources":["dependency-injection/container.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,IAAI,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAkC1D,MAAM,CAAC,MAAM,YAAY,GAAG,GAAwB,EAAE;IACpD,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAC;AAQF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,KAAwB,EACxB,cAA6C,EACvC,EAAE;IACR,iBAAiB,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC,CAAC;AAClE,CAAC,CAAC;AAQF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,KAAwB,EACxB,cAA6C,EACvC,EAAE;IACR,iBAAiB,CAAC,iBAAiB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;AAC7D,CAAC,CAAC;AAQF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAI,KAAwB,EAAE,KAAQ,EAAQ,EAAE;IAC3E,iBAAiB,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;AACzD,CAAC,CAAC;AAQF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAI,KAAwB,EAAK,EAAE;IAClE,OAAO,iBAAiB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC1C,CAAC,CAAC;AAoBF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,YAA2C,EAC3C,eAA2D,EAAE,EACvD,EAAE;IACR,iBAAiB,CAAC,QAAQ,CAAC,YAAY,EAAE;QACvC,UAAU,EAAE,CAAC,CAAsB,EAAE,EAAE;YACrC,MAAM,YAAY,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;YAC/D,OAAO,IAAI,YAAY,CAAC,GAAG,YAAY,CAAC,CAAC;QAC3C,CAAC;KACO,CAAC,CAAC;AACd,CAAC,CAAC;AAiBF,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAC/C,YAA2C,EAC3C,eAA2D,EAAE,EACvD,EAAE;IACR,iBAAiB,CAAC,iBAAiB,CAAC,YAAY,EAAE;QAChD,UAAU,EAAE,CAAC,CAAsB,EAAE,EAAE;YACrC,MAAM,YAAY,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;YAC/D,OAAO,IAAI,YAAY,CAAC,GAAG,YAAY,CAAC,CAAC;QAC3C,CAAC;KACO,CAAC,CAAC;AACd,CAAC,CAAC;AAKF,MAAM,CAAC,MAAM,cAAc,GAAG,GAAS,EAAE;IACvC,iBAAiB,CAAC,cAAc,EAAE,CAAC;IACnC,iBAAiB,CAAC,KAAK,EAAE,CAAC;AAC5B,CAAC,CAAC","sourcesContent":["import \"reflect-metadata\";\nimport { container as tsyringeContainer } from \"tsyringe\";\nimport type { DependencyContainer, InjectionToken } from \"tsyringe\";\n\n/**\n * Standalone DI container decoupled from microservice architecture.\n * Automatically used by Service architecture - typically no manual registration needed.\n *\n * For advanced use cases, you can register dependencies manually:\n *\n * @example\n * ```typescript\n * import { registerDependency, resolveDependency } from '@sentzunhat/zacatl';\n *\n * // Manual registration (advanced use case)\n * class CustomService { ... }\n * registerDependency('CustomService', CustomService);\n *\n * // Resolve manually\n * const service = resolveDependency<CustomService>('CustomService');\n * ```\n *\n * Preferred approach (automatic registration through Service):\n * ```typescript\n * const service = new Service({\n * architecture: {\n * domain: { providers: [CustomService] }\n * }\n * });\n * ```\n */\n\n/**\n * Get the global DI container instance\n */\nexport const getContainer = (): DependencyContainer => {\n return tsyringeContainer;\n};\n\n/**\n * Register a dependency in the container\n *\n * @param token - Unique identifier for the dependency\n * @param implementation - Class or value to register\n */\nexport const registerDependency = <T>(\n token: InjectionToken<T>,\n implementation: new (...args: unknown[]) => T,\n): void => {\n tsyringeContainer.register(token, { useClass: implementation });\n};\n\n/**\n * Register a singleton dependency (shared instance)\n *\n * @param token - Unique identifier for the dependency\n * @param implementation - Class to register as singleton\n */\nexport const registerSingleton = <T>(\n token: InjectionToken<T>,\n implementation: new (...args: unknown[]) => T,\n): void => {\n tsyringeContainer.registerSingleton(token, implementation);\n};\n\n/**\n * Register a value (instance) in the container\n *\n * @param token - Unique identifier for the dependency\n * @param value - Instance to register\n */\nexport const registerValue = <T>(token: InjectionToken<T>, value: T): void => {\n tsyringeContainer.register(token, { useValue: value });\n};\n\n/**\n * Resolve a dependency from the container\n *\n * @param token - Unique identifier for the dependency\n * @returns Resolved instance\n */\nexport const resolveDependency = <T>(token: InjectionToken<T>): T => {\n return tsyringeContainer.resolve(token);\n};\n\n/**\n * Register a dependency with explicit dependencies (no decorator metadata required)\n * Useful for tsx/ts-node/ESM environments where decorator metadata is not available\n *\n * @param serviceClass - Class to register\n * @param dependencies - Array of dependency classes to inject (in constructor order)\n *\n * @example\n * ```typescript\n * import { registerWithDependencies } from '@sentzunhat/zacatl';\n *\n * // Register with no deps\n * registerWithDependencies(MachineRepository, []);\n *\n * // Register with explicit deps\n * registerWithDependencies(MachineService, [MachineRepository]);\n * ```\n */\nexport const registerWithDependencies = <T>(\n serviceClass: new (...args: unknown[]) => T,\n dependencies: Array<new (...args: unknown[]) => unknown> = [],\n): void => {\n tsyringeContainer.register(serviceClass, {\n useFactory: (c: DependencyContainer) => {\n const resolvedDeps = dependencies.map((dep) => c.resolve(dep));\n return new serviceClass(...resolvedDeps);\n },\n } as never);\n};\n\n/**\n * Register a singleton with explicit dependencies (no decorator metadata required)\n * Useful for tsx/ts-node/ESM environments where decorator metadata is not available\n *\n * @param serviceClass - Class to register as singleton\n * @param dependencies - Array of dependency classes to inject (in constructor order)\n *\n * @example\n * ```typescript\n * import { registerSingletonWithDependencies } from '@sentzunhat/zacatl';\n *\n * // Register singleton with deps\n * registerSingletonWithDependencies(MachineService, [MachineRepository]);\n * ```\n */\nexport const registerSingletonWithDependencies = <T>(\n serviceClass: new (...args: unknown[]) => T,\n dependencies: Array<new (...args: unknown[]) => unknown> = [],\n): void => {\n tsyringeContainer.registerSingleton(serviceClass, {\n useFactory: (c: DependencyContainer) => {\n const resolvedDeps = dependencies.map((dep) => c.resolve(dep));\n return new serviceClass(...resolvedDeps);\n },\n } as never);\n};\n\n/**\n * Clear all registrations (useful for testing)\n */\nexport const clearContainer = (): void => {\n tsyringeContainer.clearInstances();\n tsyringeContainer.reset();\n};\n"]}
package/build/index.d.ts CHANGED
@@ -16,6 +16,4 @@ export { container, singleton, inject } from "tsyringe";
16
16
  export type { DependencyContainer } from "tsyringe";
17
17
  export { z } from "zod";
18
18
  export type { ZodSchema, ZodType, ZodError } from "zod";
19
- export * from "./orm/mongoose.js";
20
- export * from "./orm/sequelize.js";
21
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"./src/","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,wBAAwB,CAAC;AACvC,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,uCAAuC,CAAC;AAEtD,OAAO,EACL,UAAU,EACV,YAAY,EACZ,cAAc,EACd,YAAY,GACb,MAAM,+CAA+C,CAAC;AACvD,YAAY,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAGlF,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACxD,YAAY,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAGxD,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"./src/","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,wBAAwB,CAAC;AACvC,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,uCAAuC,CAAC;AAEtD,OAAO,EACL,UAAU,EACV,YAAY,EACZ,cAAc,EACd,YAAY,GACb,MAAM,+CAA+C,CAAC;AACvD,YAAY,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAGlF,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACxD,YAAY,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC"}
package/build/index.js CHANGED
@@ -12,6 +12,4 @@ export * from "./service/architecture/infrastructure";
12
12
  export { ServerType, ServerVendor, DatabaseVendor, HandlersType, } from "./service/architecture/platform/server/server";
13
13
  export { container, singleton, inject } from "tsyringe";
14
14
  export { z } from "zod";
15
- export * from "./orm/mongoose.js";
16
- export * from "./orm/sequelize.js";
17
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"./src/","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,wBAAwB,CAAC;AACvC,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,uCAAuC,CAAC;AAEtD,OAAO,EACL,UAAU,EACV,YAAY,EACZ,cAAc,EACd,YAAY,GACb,MAAM,+CAA+C,CAAC;AAIvD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAExD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./optionals\";\nexport * from \"./configuration\";\nexport * from \"./utils\";\nexport * from \"./error\";\nexport * from \"./dependency-injection\";\nexport * from \"./service\";\nexport { Service } from \"./service\";\nexport type { ConfigService } from \"./service\";\nexport * from \"./logs\";\nexport * from \"./runtime\";\nexport * from \"./localization\";\n\nexport * from \"./service/architecture/infrastructure\";\n\nexport {\n ServerType,\n ServerVendor,\n DatabaseVendor,\n HandlersType,\n} from \"./service/architecture/platform/server/server\";\nexport type { ConfigServer } from \"./service/architecture/platform/server/server\";\n\n// Third-party integrations\nexport { container, singleton, inject } from \"tsyringe\";\nexport type { DependencyContainer } from \"tsyringe\";\nexport { z } from \"zod\";\nexport type { ZodSchema, ZodType, ZodError } from \"zod\";\n\n// Optional ORM exports for convenience (also available via subpath imports)\nexport * from \"./orm/mongoose.js\";\nexport * from \"./orm/sequelize.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"./src/","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,wBAAwB,CAAC;AACvC,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,uCAAuC,CAAC;AAEtD,OAAO,EACL,UAAU,EACV,YAAY,EACZ,cAAc,EACd,YAAY,GACb,MAAM,+CAA+C,CAAC;AAIvD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAExD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC","sourcesContent":["export * from \"./optionals\";\nexport * from \"./configuration\";\nexport * from \"./utils\";\nexport * from \"./error\";\nexport * from \"./dependency-injection\";\nexport * from \"./service\";\nexport { Service } from \"./service\";\nexport type { ConfigService } from \"./service\";\nexport * from \"./logs\";\nexport * from \"./runtime\";\nexport * from \"./localization\";\n\nexport * from \"./service/architecture/infrastructure\";\n\nexport {\n ServerType,\n ServerVendor,\n DatabaseVendor,\n HandlersType,\n} from \"./service/architecture/platform/server/server\";\nexport type { ConfigServer } from \"./service/architecture/platform/server/server\";\n\n// Third-party integrations\nexport { container, singleton, inject } from \"tsyringe\";\nexport type { DependencyContainer } from \"tsyringe\";\nexport { z } from \"zod\";\nexport type { ZodSchema, ZodType, ZodError } from \"zod\";\n\n// ⚠️ ORM exports REMOVED from main package to prevent eager loading\n// Use dedicated subpath imports instead:\n// import { mongoose, Schema } from \"@sentzunhat/zacatl/orm/mongoose\"\n// import { Sequelize, DataTypes } from \"@sentzunhat/zacatl/orm/sequelize\"\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"application.js","sourceRoot":"./src/","sources":["service/architecture/application/application.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAe,MAAM,iBAAiB,CAAC;AAoBpE,MAAM,OAAO,WAAY,SAAQ,oBAAoB;IAC3C,MAAM,CAAoB;IAE3B,YAAY,GAAkB,EAAE,CAAC;IACjC,aAAa,GAAmB,EAAE,CAAC;IAE1C,YAAY,MAAyB;QACnC,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,SAAS,CAAC;YACb,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;YACrB,cAAc,EAAE,IAAI;YACpB,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC;SACnD,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAGrB,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YACxB,IAAI,CAAC,YAAY,EAAE,CAAC;QACtB,CAAC;IACH,CAAC;IAKO,YAAY;QAClB,IAAI,CAAC,4BAA4B,CAC/B,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,EACzC,IAAI,CAAC,YAAY,CAClB,CAAC;QAEF,IAAI,CAAC,4BAA4B,CAC/B,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,EAC1C,IAAI,CAAC,aAAa,CACnB,CAAC;IACJ,CAAC;IAEM,KAAK;QAEV,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YAC9B,IAAI,CAAC,YAAY,EAAE,CAAC;QACtB,CAAC;IACH,CAAC;CACF","sourcesContent":["import i18n from \"i18n\";\nimport path from \"path\";\n\nimport { AbstractArchitecture, Constructor } from \"../architecture\";\nimport { HookHandler, RouteHandler } from \"./entry-points/rest\";\n\nexport type ApplicationHookHandlers = Array<Constructor<HookHandler>>;\nexport type ApplicationRouteHandlers = Array<Constructor<RouteHandler>>;\n\nexport type ApplicationEntryPoints = {\n rest: {\n // Middleware for pre-/post-processing\n hookHandlers: ApplicationHookHandlers;\n // Endpoints (or routes) as the request targets; expect an array of class constructors\n routeHandlers: ApplicationRouteHandlers;\n };\n};\n\nexport type ConfigApplication = {\n entryPoints: ApplicationEntryPoints;\n autoRegister?: boolean; // Auto-register on construction (default: false)\n};\n\nexport class Application extends AbstractArchitecture {\n private config: ConfigApplication;\n\n public hookHandlers: HookHandler[] = [];\n public routeHandlers: RouteHandler[] = [];\n\n constructor(config: ConfigApplication) {\n super();\n\n i18n.configure({\n locales: [\"en\", \"fr\"],\n objectNotation: true,\n directory: path.join(process.cwd(), \"src/locales\"),\n });\n\n this.config = config;\n \n // Auto-register if enabled (useful without Service)\n if (config.autoRegister) {\n this.registerRest();\n }\n }\n\n /**\n * Register and store dependencies for REST entry points\n */\n private registerRest(): void {\n this.registerAndStoreDependencies(\n this.config.entryPoints.rest.hookHandlers,\n this.hookHandlers\n );\n\n this.registerAndStoreDependencies(\n this.config.entryPoints.rest.routeHandlers,\n this.routeHandlers\n );\n }\n\n public start(): void {\n // Register if not already done\n if (!this.config.autoRegister) {\n this.registerRest();\n }\n }\n}\n"]}
1
+ {"version":3,"file":"application.js","sourceRoot":"./src/","sources":["service/architecture/application/application.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAe,MAAM,iBAAiB,CAAC;AAoBpE,MAAM,OAAO,WAAY,SAAQ,oBAAoB;IAC3C,MAAM,CAAoB;IAE3B,YAAY,GAAkB,EAAE,CAAC;IACjC,aAAa,GAAmB,EAAE,CAAC;IAE1C,YAAY,MAAyB;QACnC,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,SAAS,CAAC;YACb,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;YACrB,cAAc,EAAE,IAAI;YACpB,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC;SACnD,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAGrB,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YACxB,IAAI,CAAC,YAAY,EAAE,CAAC;QACtB,CAAC;IACH,CAAC;IAKO,YAAY;QAClB,IAAI,CAAC,4BAA4B,CAC/B,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,EACzC,IAAI,CAAC,YAAY,CAClB,CAAC;QAEF,IAAI,CAAC,4BAA4B,CAC/B,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,EAC1C,IAAI,CAAC,aAAa,CACnB,CAAC;IACJ,CAAC;IAEM,KAAK;QAEV,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YAC9B,IAAI,CAAC,YAAY,EAAE,CAAC;QACtB,CAAC;IACH,CAAC;CACF","sourcesContent":["import i18n from \"i18n\";\nimport path from \"path\";\n\nimport { AbstractArchitecture, Constructor } from \"../architecture\";\nimport { HookHandler, RouteHandler } from \"./entry-points/rest\";\n\nexport type ApplicationHookHandlers = Array<Constructor<HookHandler>>;\nexport type ApplicationRouteHandlers = Array<Constructor<RouteHandler>>;\n\nexport type ApplicationEntryPoints = {\n rest: {\n // Middleware for pre-/post-processing\n hookHandlers: ApplicationHookHandlers;\n // Endpoints (or routes) as the request targets; expect an array of class constructors\n routeHandlers: ApplicationRouteHandlers;\n };\n};\n\nexport type ConfigApplication = {\n entryPoints: ApplicationEntryPoints;\n autoRegister?: boolean; // Auto-register on construction (default: false)\n};\n\nexport class Application extends AbstractArchitecture {\n private config: ConfigApplication;\n\n public hookHandlers: HookHandler[] = [];\n public routeHandlers: RouteHandler[] = [];\n\n constructor(config: ConfigApplication) {\n super();\n\n i18n.configure({\n locales: [\"en\", \"fr\"],\n objectNotation: true,\n directory: path.join(process.cwd(), \"src/locales\"),\n });\n\n this.config = config;\n\n // Auto-register if enabled (useful without Service)\n if (config.autoRegister) {\n this.registerRest();\n }\n }\n\n /**\n * Register and store dependencies for REST entry points\n */\n private registerRest(): void {\n this.registerAndStoreDependencies(\n this.config.entryPoints.rest.hookHandlers,\n this.hookHandlers,\n );\n\n this.registerAndStoreDependencies(\n this.config.entryPoints.rest.routeHandlers,\n this.routeHandlers,\n );\n }\n\n public start(): void {\n // Register if not already done\n if (!this.config.autoRegister) {\n this.registerRest();\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"architecture.d.ts","sourceRoot":"./src/","sources":["service/architecture/architecture.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,WAAW,CAAC,CAAC,GAAG,OAAO,IAAI,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAErE,KAAK,YAAY,GAAG;IAClB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AAEF,8BAAsB,oBAAqB,YAAW,YAAY;IAKhE,SAAS,CAAC,oBAAoB,CAAC,CAAC,EAAE,YAAY,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;IAe5E,SAAS,CAAC,4BAA4B,CAAC,CAAC,EACtC,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,EAChC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,GAChB,IAAI;aAaS,KAAK,IAAI,IAAI;CAC9B"}
1
+ {"version":3,"file":"architecture.d.ts","sourceRoot":"./src/","sources":["service/architecture/architecture.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,WAAW,CAAC,CAAC,GAAG,OAAO,IAAI,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAErE,KAAK,YAAY,GAAG;IAClB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AAEF,8BAAsB,oBAAqB,YAAW,YAAY;IAKhE,SAAS,CAAC,oBAAoB,CAAC,CAAC,EAAE,YAAY,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;IAc5E,SAAS,CAAC,4BAA4B,CAAC,CAAC,EACtC,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,EAChC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,GAChB,IAAI;aAaS,KAAK,IAAI,IAAI;CAC9B"}
@@ -2,7 +2,6 @@ import { container } from "tsyringe";
2
2
  export class AbstractArchitecture {
3
3
  registerDependencies(dependencies) {
4
4
  for (const dependency of dependencies) {
5
- const instance = new dependency();
6
5
  container.register(dependency.name, {
7
6
  useClass: dependency,
8
7
  });
@@ -1 +1 @@
1
- {"version":3,"file":"architecture.js","sourceRoot":"./src/","sources":["service/architecture/architecture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAQrC,MAAM,OAAgB,oBAAoB;IAK9B,oBAAoB,CAAI,YAAmC;QACnE,KAAK,MAAM,UAAU,IAAI,YAAY,EAAE,CAAC;YACtC,MAAM,QAAQ,GAAG,IAAI,UAAU,EAAE,CAAC;YAElC,SAAS,CAAC,QAAQ,CAAkB,UAAU,CAAC,IAAI,EAAE;gBACnD,QAAQ,EAAE,UAAU;aACrB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAOS,4BAA4B,CACpC,YAAgC,EAChC,OAAiB;QAEjB,KAAK,MAAM,UAAU,IAAI,YAAY,EAAE,CAAC;YACtC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;YAE9D,MAAM,QAAQ,GAAG,IAAI,UAAU,EAAE,CAAC;YAElC,MAAM,YAAY,GAAG,SAAS,CAAC,OAAO,CAAkB,UAAU,CAAC,IAAI,CAAC,CAAC;YAEzE,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;CAIF","sourcesContent":["import { container } from \"tsyringe\";\n\nexport type Constructor<T = unknown> = new (...args: unknown[]) => T;\n\ntype Architecture = {\n start: () => void;\n};\n\nexport abstract class AbstractArchitecture implements Architecture {\n /**\n * A generic helper method to register an array of handler classes.\n * @param handlers - An array of class constructors that implement the handler functionality.\n */\n protected registerDependencies<T>(dependencies: Array<Constructor<T>>): void {\n for (const dependency of dependencies) {\n const instance = new dependency();\n\n container.register<typeof instance>(dependency.name, {\n useClass: dependency,\n });\n }\n }\n\n /**\n * A generic helper method to register an array of handler classes.\n * @param handlers - An array of class constructors that implement the handler functionality.\n * @param storage - An array where the resolved instances of handlers will be stored.\n */\n protected registerAndStoreDependencies<T>(\n dependencies: Array<new () => T>,\n storage: Array<T>\n ): void {\n for (const dependency of dependencies) {\n container.register(dependency.name, { useClass: dependency });\n\n const instance = new dependency();\n\n const routeHandler = container.resolve<typeof instance>(dependency.name);\n\n storage.push(routeHandler);\n }\n }\n\n // Abstract start method, to be implemented by subclasses.\n public abstract start(): void;\n}\n"]}
1
+ {"version":3,"file":"architecture.js","sourceRoot":"./src/","sources":["service/architecture/architecture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAQrC,MAAM,OAAgB,oBAAoB;IAK9B,oBAAoB,CAAI,YAAmC;QACnE,KAAK,MAAM,UAAU,IAAI,YAAY,EAAE,CAAC;YAEtC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE;gBAClC,QAAQ,EAAE,UAAU;aACrB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAOS,4BAA4B,CACpC,YAAgC,EAChC,OAAiB;QAEjB,KAAK,MAAM,UAAU,IAAI,YAAY,EAAE,CAAC;YACtC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;YAE9D,MAAM,QAAQ,GAAG,IAAI,UAAU,EAAE,CAAC;YAElC,MAAM,YAAY,GAAG,SAAS,CAAC,OAAO,CAAkB,UAAU,CAAC,IAAI,CAAC,CAAC;YAEzE,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;CAIF","sourcesContent":["import { container } from \"tsyringe\";\n\nexport type Constructor<T = unknown> = new (...args: unknown[]) => T;\n\ntype Architecture = {\n start: () => void;\n};\n\nexport abstract class AbstractArchitecture implements Architecture {\n /**\n * A generic helper method to register an array of handler classes.\n * @param handlers - An array of class constructors that implement the handler functionality.\n */\n protected registerDependencies<T>(dependencies: Array<Constructor<T>>): void {\n for (const dependency of dependencies) {\n // Register class directly - tsyringe handles instantiation with DI\n container.register(dependency.name, {\n useClass: dependency,\n });\n }\n }\n\n /**\n * A generic helper method to register an array of handler classes.\n * @param handlers - An array of class constructors that implement the handler functionality.\n * @param storage - An array where the resolved instances of handlers will be stored.\n */\n protected registerAndStoreDependencies<T>(\n dependencies: Array<new () => T>,\n storage: Array<T>,\n ): void {\n for (const dependency of dependencies) {\n container.register(dependency.name, { useClass: dependency });\n\n const instance = new dependency();\n\n const routeHandler = container.resolve<typeof instance>(dependency.name);\n\n storage.push(routeHandler);\n }\n }\n\n // Abstract start method, to be implemented by subclasses.\n public abstract start(): void;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"domain.js","sourceRoot":"./src/","sources":["service/architecture/domain/domain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAe,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAOrC,MAAM,OAAO,MAAO,SAAQ,oBAAoB;IACtC,MAAM,CAAe;IACrB,SAAS,GAAoB,EAAE,CAAC;IAExC,YAAY,MAAoB;QAC9B,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAGrB,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YACxB,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,KAAK;QAEhB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YAC9B,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACnD,CAAC;QAGD,KAAK,MAAM,aAAa,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;YAClD,IAAI,SAAS,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC/C,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAa,CAAC;gBACnE,IACE,QAAQ,YAAY,QAAQ;oBAC5B,OAAO,QAAQ,CAAC,KAAK,KAAK,UAAU,EACpC,CAAC;oBACD,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC;oBACvB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAChC,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { AbstractArchitecture, Constructor } from \"../architecture\";\nimport { Provider } from \"./provider\";\nimport { container } from \"tsyringe\";\n\nexport type ConfigDomain = {\n providers: Array<Constructor>;\n autoRegister?: boolean; // Auto-register on construction (default: false)\n};\n\nexport class Domain extends AbstractArchitecture {\n private config: ConfigDomain;\n private providers: Array<Provider> = [];\n\n constructor(config: ConfigDomain) {\n super();\n\n this.config = config;\n \n // Auto-register if enabled (useful without Service)\n if (config.autoRegister) {\n this.registerDependencies(this.config.providers);\n }\n }\n\n public async start(): Promise<void> {\n // Register if not already done\n if (!this.config.autoRegister) {\n this.registerDependencies(this.config.providers);\n }\n\n // Auto-start providers that implement the start method\n for (const ProviderClass of this.config.providers) {\n if (container.isRegistered(ProviderClass.name)) {\n const provider = container.resolve(ProviderClass.name) as Provider;\n if (\n provider instanceof Provider &&\n typeof provider.start === \"function\"\n ) {\n await provider.start();\n this.providers.push(provider);\n }\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"domain.js","sourceRoot":"./src/","sources":["service/architecture/domain/domain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAe,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAOrC,MAAM,OAAO,MAAO,SAAQ,oBAAoB;IACtC,MAAM,CAAe;IACrB,SAAS,GAAoB,EAAE,CAAC;IAExC,YAAY,MAAoB;QAC9B,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAGrB,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YACxB,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,KAAK;QAEhB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YAC9B,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACnD,CAAC;QAGD,KAAK,MAAM,aAAa,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;YAClD,IAAI,SAAS,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC/C,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAa,CAAC;gBACnE,IACE,QAAQ,YAAY,QAAQ;oBAC5B,OAAO,QAAQ,CAAC,KAAK,KAAK,UAAU,EACpC,CAAC;oBACD,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC;oBACvB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAChC,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { AbstractArchitecture, Constructor } from \"../architecture\";\nimport { Provider } from \"./provider\";\nimport { container } from \"tsyringe\";\n\nexport type ConfigDomain = {\n providers: Array<Constructor>;\n autoRegister?: boolean; // Auto-register on construction (default: false)\n};\n\nexport class Domain extends AbstractArchitecture {\n private config: ConfigDomain;\n private providers: Array<Provider> = [];\n\n constructor(config: ConfigDomain) {\n super();\n\n this.config = config;\n\n // Auto-register if enabled (useful without Service)\n if (config.autoRegister) {\n this.registerDependencies(this.config.providers);\n }\n }\n\n public async start(): Promise<void> {\n // Register if not already done\n if (!this.config.autoRegister) {\n this.registerDependencies(this.config.providers);\n }\n\n // Auto-start providers that implement the start method\n for (const ProviderClass of this.config.providers) {\n if (container.isRegistered(ProviderClass.name)) {\n const provider = container.resolve(ProviderClass.name) as Provider;\n if (\n provider instanceof Provider &&\n typeof provider.start === \"function\"\n ) {\n await provider.start();\n this.providers.push(provider);\n }\n }\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"infrastructure.js","sourceRoot":"./src/","sources":["service/architecture/infrastructure/infrastructure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAe,MAAM,iBAAiB,CAAC;AAOpE,MAAM,OAAO,cAAe,SAAQ,oBAAoB;IAC9C,MAAM,CAAuB;IAErC,YAAY,MAA4B;QACtC,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAGrB,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YACxB,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAEM,KAAK;QAEV,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YAC9B,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;CACF","sourcesContent":["import { AbstractArchitecture, Constructor } from \"../architecture\";\n\nexport type ConfigInfrastructure = {\n repositories: Array<Constructor>;\n autoRegister?: boolean; // Auto-register on construction (default: false)\n};\n\nexport class Infrastructure extends AbstractArchitecture {\n private config: ConfigInfrastructure;\n\n constructor(config: ConfigInfrastructure) {\n super();\n\n this.config = config;\n \n // Auto-register if enabled (useful without Service)\n if (config.autoRegister) {\n this.registerDependencies(this.config.repositories);\n }\n }\n\n public start(): void {\n // Register if not already done\n if (!this.config.autoRegister) {\n this.registerDependencies(this.config.repositories);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"infrastructure.js","sourceRoot":"./src/","sources":["service/architecture/infrastructure/infrastructure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAe,MAAM,iBAAiB,CAAC;AAOpE,MAAM,OAAO,cAAe,SAAQ,oBAAoB;IAC9C,MAAM,CAAuB;IAErC,YAAY,MAA4B;QACtC,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAGrB,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YACxB,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAEM,KAAK;QAEV,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YAC9B,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;CACF","sourcesContent":["import { AbstractArchitecture, Constructor } from \"../architecture\";\n\nexport type ConfigInfrastructure = {\n repositories: Array<Constructor>;\n autoRegister?: boolean; // Auto-register on construction (default: false)\n};\n\nexport class Infrastructure extends AbstractArchitecture {\n private config: ConfigInfrastructure;\n\n constructor(config: ConfigInfrastructure) {\n super();\n\n this.config = config;\n\n // Auto-register if enabled (useful without Service)\n if (config.autoRegister) {\n this.registerDependencies(this.config.repositories);\n }\n }\n\n public start(): void {\n // Register if not already done\n if (!this.config.autoRegister) {\n this.registerDependencies(this.config.repositories);\n }\n }\n}\n"]}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "main": "build/index.js",
5
5
  "module": "build/index.js",
6
6
  "types": "build/index.d.ts",
7
- "version": "0.0.23",
7
+ "version": "0.0.25",
8
8
  "packageManager": "npm@10.9.0",
9
9
  "exports": {
10
10
  ".": {
@@ -83,6 +83,63 @@ export const resolveDependency = <T>(token: InjectionToken<T>): T => {
83
83
  return tsyringeContainer.resolve(token);
84
84
  };
85
85
 
86
+ /**
87
+ * Register a dependency with explicit dependencies (no decorator metadata required)
88
+ * Useful for tsx/ts-node/ESM environments where decorator metadata is not available
89
+ *
90
+ * @param serviceClass - Class to register
91
+ * @param dependencies - Array of dependency classes to inject (in constructor order)
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * import { registerWithDependencies } from '@sentzunhat/zacatl';
96
+ *
97
+ * // Register with no deps
98
+ * registerWithDependencies(MachineRepository, []);
99
+ *
100
+ * // Register with explicit deps
101
+ * registerWithDependencies(MachineService, [MachineRepository]);
102
+ * ```
103
+ */
104
+ export const registerWithDependencies = <T>(
105
+ serviceClass: new (...args: unknown[]) => T,
106
+ dependencies: Array<new (...args: unknown[]) => unknown> = [],
107
+ ): void => {
108
+ tsyringeContainer.register(serviceClass, {
109
+ useFactory: (c: DependencyContainer) => {
110
+ const resolvedDeps = dependencies.map((dep) => c.resolve(dep));
111
+ return new serviceClass(...resolvedDeps);
112
+ },
113
+ } as never);
114
+ };
115
+
116
+ /**
117
+ * Register a singleton with explicit dependencies (no decorator metadata required)
118
+ * Useful for tsx/ts-node/ESM environments where decorator metadata is not available
119
+ *
120
+ * @param serviceClass - Class to register as singleton
121
+ * @param dependencies - Array of dependency classes to inject (in constructor order)
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * import { registerSingletonWithDependencies } from '@sentzunhat/zacatl';
126
+ *
127
+ * // Register singleton with deps
128
+ * registerSingletonWithDependencies(MachineService, [MachineRepository]);
129
+ * ```
130
+ */
131
+ export const registerSingletonWithDependencies = <T>(
132
+ serviceClass: new (...args: unknown[]) => T,
133
+ dependencies: Array<new (...args: unknown[]) => unknown> = [],
134
+ ): void => {
135
+ tsyringeContainer.registerSingleton(serviceClass, {
136
+ useFactory: (c: DependencyContainer) => {
137
+ const resolvedDeps = dependencies.map((dep) => c.resolve(dep));
138
+ return new serviceClass(...resolvedDeps);
139
+ },
140
+ } as never);
141
+ };
142
+
86
143
  /**
87
144
  * Clear all registrations (useful for testing)
88
145
  */
package/src/index.ts CHANGED
@@ -26,6 +26,7 @@ export type { DependencyContainer } from "tsyringe";
26
26
  export { z } from "zod";
27
27
  export type { ZodSchema, ZodType, ZodError } from "zod";
28
28
 
29
- // Optional ORM exports for convenience (also available via subpath imports)
30
- export * from "./orm/mongoose.js";
31
- export * from "./orm/sequelize.js";
29
+ // ⚠️ ORM exports REMOVED from main package to prevent eager loading
30
+ // Use dedicated subpath imports instead:
31
+ // import { mongoose, Schema } from "@sentzunhat/zacatl/orm/mongoose"
32
+ // import { Sequelize, DataTypes } from "@sentzunhat/zacatl/orm/sequelize"
@@ -13,9 +13,8 @@ export abstract class AbstractArchitecture implements Architecture {
13
13
  */
14
14
  protected registerDependencies<T>(dependencies: Array<Constructor<T>>): void {
15
15
  for (const dependency of dependencies) {
16
- const instance = new dependency();
17
-
18
- container.register<typeof instance>(dependency.name, {
16
+ // Register class directly - tsyringe handles instantiation with DI
17
+ container.register(dependency.name, {
19
18
  useClass: dependency,
20
19
  });
21
20
  }
@@ -28,7 +27,7 @@ export abstract class AbstractArchitecture implements Architecture {
28
27
  */
29
28
  protected registerAndStoreDependencies<T>(
30
29
  dependencies: Array<new () => T>,
31
- storage: Array<T>
30
+ storage: Array<T>,
32
31
  ): void {
33
32
  for (const dependency of dependencies) {
34
33
  container.register(dependency.name, { useClass: dependency });