@sentzunhat/zacatl 0.0.21 β 0.0.23
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 +20 -7
- package/build/index.d.ts +3 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -2
- package/build/index.js.map +1 -1
- package/build/orm/mongoose.d.ts +3 -0
- package/build/orm/mongoose.d.ts.map +1 -0
- package/build/orm/mongoose.js +2 -0
- package/build/orm/mongoose.js.map +1 -0
- package/build/orm/sequelize.d.ts +3 -0
- package/build/orm/sequelize.d.ts.map +1 -0
- package/build/orm/sequelize.js +2 -0
- package/build/orm/sequelize.js.map +1 -0
- package/build/service/architecture/application/application.d.ts +1 -0
- package/build/service/architecture/application/application.d.ts.map +1 -1
- package/build/service/architecture/application/application.js +6 -1
- package/build/service/architecture/application/application.js.map +1 -1
- package/build/service/architecture/application/index.d.ts +1 -0
- package/build/service/architecture/application/index.d.ts.map +1 -1
- package/build/service/architecture/application/index.js +1 -0
- package/build/service/architecture/application/index.js.map +1 -1
- package/build/service/architecture/domain/domain.d.ts +1 -0
- package/build/service/architecture/domain/domain.d.ts.map +1 -1
- package/build/service/architecture/domain/domain.js +6 -1
- package/build/service/architecture/domain/domain.js.map +1 -1
- package/build/service/architecture/infrastructure/index.d.ts +0 -4
- package/build/service/architecture/infrastructure/index.d.ts.map +1 -1
- package/build/service/architecture/infrastructure/index.js +0 -2
- package/build/service/architecture/infrastructure/index.js.map +1 -1
- package/build/service/architecture/infrastructure/infrastructure.d.ts +1 -0
- package/build/service/architecture/infrastructure/infrastructure.d.ts.map +1 -1
- package/build/service/architecture/infrastructure/infrastructure.js +6 -1
- package/build/service/architecture/infrastructure/infrastructure.js.map +1 -1
- package/build/service/architecture/infrastructure/orm/adapter-loader.d.ts +2 -2
- package/build/service/architecture/infrastructure/orm/adapter-loader.d.ts.map +1 -1
- package/build/service/architecture/infrastructure/orm/adapter-loader.js +8 -6
- package/build/service/architecture/infrastructure/orm/adapter-loader.js.map +1 -1
- package/build/service/architecture/infrastructure/repositories/abstract.d.ts +5 -1
- package/build/service/architecture/infrastructure/repositories/abstract.d.ts.map +1 -1
- package/build/service/architecture/infrastructure/repositories/abstract.js +34 -5
- package/build/service/architecture/infrastructure/repositories/abstract.js.map +1 -1
- package/build/service/architecture/infrastructure/repositories/types.d.ts +2 -2
- package/build/service/architecture/infrastructure/repositories/types.d.ts.map +1 -1
- package/build/service/architecture/infrastructure/repositories/types.js.map +1 -1
- package/build/test/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -3
- package/src/index.ts +5 -11
- package/src/orm/mongoose.ts +22 -0
- package/src/orm/sequelize.ts +14 -0
- package/src/service/architecture/application/application.ts +12 -3
- package/src/service/architecture/application/index.ts +1 -0
- package/src/service/architecture/domain/domain.ts +10 -1
- package/src/service/architecture/infrastructure/index.ts +0 -46
- package/src/service/architecture/infrastructure/infrastructure.ts +10 -1
- package/src/service/architecture/infrastructure/orm/adapter-loader.ts +16 -22
- package/src/service/architecture/infrastructure/repositories/abstract.ts +61 -25
- package/src/service/architecture/infrastructure/repositories/types.ts +3 -44
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://opensource.org/licenses/MIT)
|
|
6
6
|
[](https://www.typescriptlang.org/)
|
|
7
7
|
[](https://nodejs.org/)
|
|
8
|
-
[](#testing)
|
|
9
9
|
[](#testing)
|
|
10
10
|
|
|
11
11
|
**Production-ready TypeScript framework for building scalable microservices, APIs, and distributed systems.**
|
|
@@ -21,7 +21,7 @@ Zacatl enforces clean, layered architecture with dependency injection, validatio
|
|
|
21
21
|
- **ποΈ Pluggable ORM Adapters** - Sequelize, Mongoose, or build your own
|
|
22
22
|
- **π Multi-Language Support** - Pluggable i18n with filesystem/memory adapters
|
|
23
23
|
- **π Adapter Pattern** - Easy integration with any database or service
|
|
24
|
-
- **π§ͺ Comprehensive Testing** -
|
|
24
|
+
- **π§ͺ Comprehensive Testing** - 169 tests, 79% coverage, Vitest
|
|
25
25
|
- **β‘ Runtime Detection** - Works with Node.js 22+ and Bun
|
|
26
26
|
- **π Production Ready** - Structured logging, monitoring, and error tracking
|
|
27
27
|
|
|
@@ -47,16 +47,29 @@ 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
|
|
50
|
+
## π¦ Import Options (v0.0.23+)
|
|
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)
|
|
51
53
|
|
|
52
54
|
```typescript
|
|
53
|
-
//
|
|
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)
|
|
65
|
+
import { Service } from "@sentzunhat/zacatl";
|
|
66
|
+
import { mongoose, Schema } from "@sentzunhat/zacatl/orm/mongoose";
|
|
67
|
+
import { resolveDependency } from "@sentzunhat/zacatl/application";
|
|
68
|
+
|
|
69
|
+
// Subpath shortcuts
|
|
54
70
|
import { BaseRepository, ORMType } from "@sentzunhat/zacatl/infrastructure";
|
|
55
71
|
import { CustomError } from "@sentzunhat/zacatl/errors";
|
|
56
72
|
import { loadConfig } from "@sentzunhat/zacatl/config";
|
|
57
|
-
|
|
58
|
-
// Or full path (still works)
|
|
59
|
-
import { BaseRepository } from "@sentzunhat/zacatl/build/service/architecture/infrastructure/repositories/abstract";
|
|
60
73
|
```
|
|
61
74
|
|
|
62
75
|
### Hello World HTTP Service
|
package/build/index.d.ts
CHANGED
|
@@ -12,9 +12,10 @@ export * from "./localization";
|
|
|
12
12
|
export * from "./service/architecture/infrastructure";
|
|
13
13
|
export { ServerType, ServerVendor, DatabaseVendor, HandlersType, } from "./service/architecture/platform/server/server";
|
|
14
14
|
export type { ConfigServer } from "./service/architecture/platform/server/server";
|
|
15
|
-
export { container } from "tsyringe";
|
|
15
|
+
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
|
|
19
|
+
export * from "./orm/mongoose.js";
|
|
20
|
+
export * from "./orm/sequelize.js";
|
|
20
21
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -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;
|
|
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"}
|
package/build/index.js
CHANGED
|
@@ -10,7 +10,8 @@ export * from "./runtime";
|
|
|
10
10
|
export * from "./localization";
|
|
11
11
|
export * from "./service/architecture/infrastructure";
|
|
12
12
|
export { ServerType, ServerVendor, DatabaseVendor, HandlersType, } from "./service/architecture/platform/server/server";
|
|
13
|
-
export { container } from "tsyringe";
|
|
13
|
+
export { container, singleton, inject } from "tsyringe";
|
|
14
14
|
export { z } from "zod";
|
|
15
|
-
export * from "./orm
|
|
15
|
+
export * from "./orm/mongoose.js";
|
|
16
|
+
export * from "./orm/sequelize.js";
|
|
16
17
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -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;
|
|
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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongoose.d.ts","sourceRoot":"./src/","sources":["orm/mongoose.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,OAAO,IAAI,QAAQ,EACnB,QAAQ,EACR,MAAM,EACN,KAAK,EACL,QAAQ,EACR,OAAO,EACP,UAAU,GACX,MAAM,UAAU,CAAC;AAGlB,YAAY,EAAE,KAAK,IAAI,aAAa,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongoose.js","sourceRoot":"./src/","sources":["orm/mongoose.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,OAAO,IAAI,QAAQ,EACnB,QAAQ,EACR,MAAM,EACN,KAAK,EACL,QAAQ,EACR,OAAO,EACP,UAAU,GACX,MAAM,UAAU,CAAC","sourcesContent":["/**\n * Mongoose ORM exports\n *\n * @example Minimal bundle (tree-shakeable)\n * import { mongoose, Schema } from \"@sentzunhat/zacatl/orm/mongoose\";\n *\n * @example Convenience (from main package)\n * import { mongoose, Schema } from \"@sentzunhat/zacatl\";\n */\n\nexport {\n default as mongoose,\n Mongoose,\n Schema,\n Model,\n Document,\n connect,\n connection,\n} from \"mongoose\";\n\n// Type-only exports\nexport type { Model as MongooseModel } from \"mongoose\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sequelize.d.ts","sourceRoot":"./src/","sources":["orm/sequelize.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,SAAS,EAAE,KAAK,IAAI,cAAc,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAG9E,YAAY,EAAE,WAAW,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sequelize.js","sourceRoot":"./src/","sources":["orm/sequelize.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,SAAS,EAAE,KAAK,IAAI,cAAc,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC","sourcesContent":["/**\n * Sequelize ORM exports\n *\n * @example Minimal bundle (tree-shakeable)\n * import { Sequelize, DataTypes } from \"@sentzunhat/zacatl/orm/sequelize\";\n *\n * @example Convenience (from main package)\n * import { Sequelize, DataTypes } from \"@sentzunhat/zacatl\";\n */\n\nexport { Sequelize, Model as SequelizeModel, DataTypes, Op } from \"sequelize\";\n\n// Type-only exports\nexport type { ModelStatic, Options as SequelizeOptions } from \"sequelize\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.d.ts","sourceRoot":"./src/","sources":["service/architecture/application/application.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEhE,MAAM,MAAM,uBAAuB,GAAG,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC;AACtE,MAAM,MAAM,wBAAwB,GAAG,KAAK,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;AAExE,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE;QAEJ,YAAY,EAAE,uBAAuB,CAAC;QAEtC,aAAa,EAAE,wBAAwB,CAAC;KACzC,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW,EAAE,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"application.d.ts","sourceRoot":"./src/","sources":["service/architecture/application/application.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEhE,MAAM,MAAM,uBAAuB,GAAG,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC;AACtE,MAAM,MAAM,wBAAwB,GAAG,KAAK,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;AAExE,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE;QAEJ,YAAY,EAAE,uBAAuB,CAAC;QAEtC,aAAa,EAAE,wBAAwB,CAAC;KACzC,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW,EAAE,sBAAsB,CAAC;IACpC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,qBAAa,WAAY,SAAQ,oBAAoB;IACnD,OAAO,CAAC,MAAM,CAAoB;IAE3B,YAAY,EAAE,WAAW,EAAE,CAAM;IACjC,aAAa,EAAE,YAAY,EAAE,CAAM;gBAE9B,MAAM,EAAE,iBAAiB;IAoBrC,OAAO,CAAC,YAAY;IAYb,KAAK,IAAI,IAAI;CAMrB"}
|
|
@@ -13,13 +13,18 @@ export class Application extends AbstractArchitecture {
|
|
|
13
13
|
directory: path.join(process.cwd(), "src/locales"),
|
|
14
14
|
});
|
|
15
15
|
this.config = config;
|
|
16
|
+
if (config.autoRegister) {
|
|
17
|
+
this.registerRest();
|
|
18
|
+
}
|
|
16
19
|
}
|
|
17
20
|
registerRest() {
|
|
18
21
|
this.registerAndStoreDependencies(this.config.entryPoints.rest.hookHandlers, this.hookHandlers);
|
|
19
22
|
this.registerAndStoreDependencies(this.config.entryPoints.rest.routeHandlers, this.routeHandlers);
|
|
20
23
|
}
|
|
21
24
|
start() {
|
|
22
|
-
this.
|
|
25
|
+
if (!this.config.autoRegister) {
|
|
26
|
+
this.registerRest();
|
|
27
|
+
}
|
|
23
28
|
}
|
|
24
29
|
}
|
|
25
30
|
//# sourceMappingURL=application.js.map
|
|
@@ -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;
|
|
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":"index.d.ts","sourceRoot":"./src/","sources":["service/architecture/application/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"./src/","sources":["service/architecture/application/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,+BAA+B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"./src/","sources":["service/architecture/application/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC","sourcesContent":["export * from \"./entry-points\";\nexport * from \"./application\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"./src/","sources":["service/architecture/application/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,+BAA+B,CAAC","sourcesContent":["export * from \"./entry-points\";\nexport * from \"./application\";\nexport * from \"../../../dependency-injection\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain.d.ts","sourceRoot":"./src/","sources":["service/architecture/domain/domain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAIpE,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"domain.d.ts","sourceRoot":"./src/","sources":["service/architecture/domain/domain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAIpE,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,qBAAa,MAAO,SAAQ,oBAAoB;IAC9C,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,SAAS,CAAuB;gBAE5B,MAAM,EAAE,YAAY;IAWnB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAoBpC"}
|
|
@@ -7,9 +7,14 @@ export class Domain extends AbstractArchitecture {
|
|
|
7
7
|
constructor(config) {
|
|
8
8
|
super();
|
|
9
9
|
this.config = config;
|
|
10
|
+
if (config.autoRegister) {
|
|
11
|
+
this.registerDependencies(this.config.providers);
|
|
12
|
+
}
|
|
10
13
|
}
|
|
11
14
|
async start() {
|
|
12
|
-
|
|
15
|
+
if (!this.config.autoRegister) {
|
|
16
|
+
this.registerDependencies(this.config.providers);
|
|
17
|
+
}
|
|
13
18
|
for (const ProviderClass of this.config.providers) {
|
|
14
19
|
if (container.isRegistered(ProviderClass.name)) {
|
|
15
20
|
const provider = container.resolve(ProviderClass.name);
|
|
@@ -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;
|
|
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,7 +1,3 @@
|
|
|
1
1
|
export * from "./repositories";
|
|
2
2
|
export * from "./infrastructure";
|
|
3
|
-
export { Schema, Model, Types, connect, connection, createConnection, } from "mongoose";
|
|
4
|
-
export type { Document, SchemaDefinition, SchemaOptions, SchemaTypeOptions, Connection, Mongoose, ObjectId, UpdateQuery, QueryOptions, PopulateOptions, HydratedDocument, InferSchemaType, } from "mongoose";
|
|
5
|
-
export { DataTypes, Sequelize, Model as SequelizeModelClass } from "sequelize";
|
|
6
|
-
export type { ModelStatic, QueryInterface, Transaction, Options as SequelizeOptions, ModelAttributes, ModelOptions, FindOptions, CreateOptions, UpdateOptions, DestroyOptions, WhereOptions, Order, Includeable, } from "sequelize";
|
|
7
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"./src/","sources":["service/architecture/infrastructure/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"./src/","sources":["service/architecture/infrastructure/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
export * from "./repositories";
|
|
2
2
|
export * from "./infrastructure";
|
|
3
|
-
export { Schema, Model, Types, connect, connection, createConnection, } from "mongoose";
|
|
4
|
-
export { DataTypes, Sequelize, Model as SequelizeModelClass } from "sequelize";
|
|
5
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"./src/","sources":["service/architecture/infrastructure/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"./src/","sources":["service/architecture/infrastructure/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC","sourcesContent":["export * from \"./repositories\";\nexport * from \"./infrastructure\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infrastructure.d.ts","sourceRoot":"./src/","sources":["service/architecture/infrastructure/infrastructure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEpE,MAAM,MAAM,oBAAoB,GAAG;IACjC,YAAY,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"infrastructure.d.ts","sourceRoot":"./src/","sources":["service/architecture/infrastructure/infrastructure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEpE,MAAM,MAAM,oBAAoB,GAAG;IACjC,YAAY,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IACjC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,qBAAa,cAAe,SAAQ,oBAAoB;IACtD,OAAO,CAAC,MAAM,CAAuB;gBAEzB,MAAM,EAAE,oBAAoB;IAWjC,KAAK,IAAI,IAAI;CAMrB"}
|
|
@@ -4,9 +4,14 @@ export class Infrastructure extends AbstractArchitecture {
|
|
|
4
4
|
constructor(config) {
|
|
5
5
|
super();
|
|
6
6
|
this.config = config;
|
|
7
|
+
if (config.autoRegister) {
|
|
8
|
+
this.registerDependencies(this.config.repositories);
|
|
9
|
+
}
|
|
7
10
|
}
|
|
8
11
|
start() {
|
|
9
|
-
|
|
12
|
+
if (!this.config.autoRegister) {
|
|
13
|
+
this.registerDependencies(this.config.repositories);
|
|
14
|
+
}
|
|
10
15
|
}
|
|
11
16
|
}
|
|
12
17
|
//# sourceMappingURL=infrastructure.js.map
|
|
@@ -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;
|
|
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,5 +1,5 @@
|
|
|
1
1
|
import type { Model } from "sequelize";
|
|
2
2
|
import type { MongooseRepositoryConfig, SequelizeRepositoryConfig, ORMAdapter } from "../repositories/types";
|
|
3
|
-
export declare function loadMongooseAdapter<D, I, O>(config: MongooseRepositoryConfig<D>): ORMAdapter<D, I, O
|
|
4
|
-
export declare function loadSequelizeAdapter<D extends Model, I, O>(config: SequelizeRepositoryConfig<D>): ORMAdapter<D, I, O
|
|
3
|
+
export declare function loadMongooseAdapter<D, I, O>(config: MongooseRepositoryConfig<D>): Promise<ORMAdapter<D, I, O>>;
|
|
4
|
+
export declare function loadSequelizeAdapter<D extends Model, I, O>(config: SequelizeRepositoryConfig<D>): Promise<ORMAdapter<D, I, O>>;
|
|
5
5
|
//# sourceMappingURL=adapter-loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter-loader.d.ts","sourceRoot":"./src/","sources":["service/architecture/infrastructure/orm/adapter-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EACV,wBAAwB,EACxB,yBAAyB,EACzB,UAAU,EACX,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"adapter-loader.d.ts","sourceRoot":"./src/","sources":["service/architecture/infrastructure/orm/adapter-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EACV,wBAAwB,EACxB,yBAAyB,EACzB,UAAU,EACX,MAAM,uBAAuB,CAAC;AAG/B,wBAAsB,mBAAmB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAC/C,MAAM,EAAE,wBAAwB,CAAC,CAAC,CAAC,GAClC,OAAO,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAe9B;AAGD,wBAAsB,oBAAoB,CAAC,CAAC,SAAS,KAAK,EAAE,CAAC,EAAE,CAAC,EAC9D,MAAM,EAAE,yBAAyB,CAAC,CAAC,CAAC,GACnC,OAAO,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAe9B"}
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
export function loadMongooseAdapter(config) {
|
|
1
|
+
export async function loadMongooseAdapter(config) {
|
|
2
2
|
try {
|
|
3
|
-
const adapters =
|
|
3
|
+
const adapters = await import("./adapters/mongoose-adapter");
|
|
4
4
|
return new adapters.MongooseAdapter(config);
|
|
5
5
|
}
|
|
6
6
|
catch (error) {
|
|
7
|
-
if (error.code === "
|
|
7
|
+
if (error.code === "ERR_MODULE_NOT_FOUND" ||
|
|
8
|
+
error.code === "MODULE_NOT_FOUND") {
|
|
8
9
|
throw new Error("Mongoose is not installed. Install it with: npm install mongoose");
|
|
9
10
|
}
|
|
10
11
|
throw error;
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
|
-
export function loadSequelizeAdapter(config) {
|
|
14
|
+
export async function loadSequelizeAdapter(config) {
|
|
14
15
|
try {
|
|
15
|
-
const adapters =
|
|
16
|
+
const adapters = await import("./adapters/sequelize-adapter");
|
|
16
17
|
return new adapters.SequelizeAdapter(config);
|
|
17
18
|
}
|
|
18
19
|
catch (error) {
|
|
19
|
-
if (error.code === "
|
|
20
|
+
if (error.code === "ERR_MODULE_NOT_FOUND" ||
|
|
21
|
+
error.code === "MODULE_NOT_FOUND") {
|
|
20
22
|
throw new Error("Sequelize is not installed. Install it with: npm install sequelize");
|
|
21
23
|
}
|
|
22
24
|
throw error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter-loader.js","sourceRoot":"./src/","sources":["service/architecture/infrastructure/orm/adapter-loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"adapter-loader.js","sourceRoot":"./src/","sources":["service/architecture/infrastructure/orm/adapter-loader.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,MAAmC;IAEnC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,6BAA6B,CAAC,CAAC;QAC7D,OAAO,IAAI,QAAQ,CAAC,eAAe,CAAU,MAAM,CAAC,CAAC;IACvD,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,IACE,KAAK,CAAC,IAAI,KAAK,sBAAsB;YACrC,KAAK,CAAC,IAAI,KAAK,kBAAkB,EACjC,CAAC;YACD,MAAM,IAAI,KAAK,CACb,kEAAkE,CACnE,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAGD,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAAoC;IAEpC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,8BAA8B,CAAC,CAAC;QAC9D,OAAO,IAAI,QAAQ,CAAC,gBAAgB,CAAU,MAAM,CAAC,CAAC;IACxD,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,IACE,KAAK,CAAC,IAAI,KAAK,sBAAsB;YACrC,KAAK,CAAC,IAAI,KAAK,kBAAkB,EACjC,CAAC;YACD,MAAM,IAAI,KAAK,CACb,oEAAoE,CACrE,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import type { Model } from \"sequelize\";\nimport type {\n MongooseRepositoryConfig,\n SequelizeRepositoryConfig,\n ORMAdapter,\n} from \"../repositories/types\";\n\n/** Lazy-loads MongooseAdapter when needed */\nexport async function loadMongooseAdapter<D, I, O>(\n config: MongooseRepositoryConfig<D>,\n): Promise<ORMAdapter<D, I, O>> {\n try {\n const adapters = await import(\"./adapters/mongoose-adapter\");\n return new adapters.MongooseAdapter<D, I, O>(config);\n } catch (error: any) {\n if (\n error.code === \"ERR_MODULE_NOT_FOUND\" ||\n error.code === \"MODULE_NOT_FOUND\"\n ) {\n throw new Error(\n \"Mongoose is not installed. Install it with: npm install mongoose\",\n );\n }\n throw error;\n }\n}\n\n/** Lazy-loads SequelizeAdapter when needed */\nexport async function loadSequelizeAdapter<D extends Model, I, O>(\n config: SequelizeRepositoryConfig<D>,\n): Promise<ORMAdapter<D, I, O>> {\n try {\n const adapters = await import(\"./adapters/sequelize-adapter\");\n return new adapters.SequelizeAdapter<D, I, O>(config);\n } catch (error: any) {\n if (\n error.code === \"ERR_MODULE_NOT_FOUND\" ||\n error.code === \"MODULE_NOT_FOUND\"\n ) {\n throw new Error(\n \"Sequelize is not installed. Install it with: npm install sequelize\",\n );\n }\n throw error;\n }\n}\n"]}
|
|
@@ -3,9 +3,13 @@ import type { ModelStatic } from "sequelize";
|
|
|
3
3
|
import { BaseRepositoryConfig, Repository } from "./types";
|
|
4
4
|
export * from "./types";
|
|
5
5
|
export declare abstract class BaseRepository<D, I, O> implements Repository<D, I, O> {
|
|
6
|
-
private adapter
|
|
6
|
+
private adapter?;
|
|
7
7
|
private readonly ormType;
|
|
8
|
+
private readonly config;
|
|
9
|
+
private initPromise?;
|
|
8
10
|
constructor(config: BaseRepositoryConfig<D>);
|
|
11
|
+
private ensureInitialized;
|
|
12
|
+
private loadAdapter;
|
|
9
13
|
get model(): MongooseModel<D> | ModelStatic<any>;
|
|
10
14
|
isMongoose(): boolean;
|
|
11
15
|
isSequelize(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.d.ts","sourceRoot":"./src/","sources":["service/architecture/infrastructure/repositories/abstract.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"abstract.d.ts","sourceRoot":"./src/","sources":["service/architecture/infrastructure/repositories/abstract.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,IAAI,aAAa,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,KAAK,EAAS,WAAW,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EACL,oBAAoB,EACpB,UAAU,EAKX,MAAM,SAAS,CAAC;AAMjB,cAAc,SAAS,CAAC;AAkBxB,8BAAsB,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAE,YAAW,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAC1E,OAAO,CAAC,OAAO,CAAC,CAAsB;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;IACjD,OAAO,CAAC,WAAW,CAAC,CAAgB;gBAExB,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC;YAS7B,iBAAiB;YAajB,WAAW;IAgBzB,IAAI,KAAK,IAAI,aAAa,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAO/C;IAEM,UAAU,IAAI,OAAO;IAIrB,WAAW,IAAI,OAAO;IAItB,gBAAgB,IAAI,aAAa,CAAC,CAAC,CAAC;IAYpC,iBAAiB,IAAI,WAAW,CAAC,GAAG,CAAC;IAYrC,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,CAAC,GAAG,IAAI;IASjC,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAKvC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAK7B,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAKzD,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;CAI5C"}
|
|
@@ -10,20 +10,36 @@ const isSequelizeConfig = (config) => {
|
|
|
10
10
|
export class BaseRepository {
|
|
11
11
|
adapter;
|
|
12
12
|
ormType;
|
|
13
|
+
config;
|
|
14
|
+
initPromise;
|
|
13
15
|
constructor(config) {
|
|
14
16
|
this.ormType = config.type;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
this.config = config;
|
|
18
|
+
}
|
|
19
|
+
async ensureInitialized() {
|
|
20
|
+
if (this.adapter)
|
|
21
|
+
return;
|
|
22
|
+
if (!this.initPromise) {
|
|
23
|
+
this.initPromise = this.loadAdapter();
|
|
24
|
+
}
|
|
25
|
+
await this.initPromise;
|
|
26
|
+
}
|
|
27
|
+
async loadAdapter() {
|
|
28
|
+
if (isMongooseConfig(this.config)) {
|
|
29
|
+
this.adapter = await loadMongooseAdapter(this.config);
|
|
17
30
|
}
|
|
18
|
-
else if (isSequelizeConfig(config)) {
|
|
19
|
-
this.adapter = loadSequelizeAdapter(config);
|
|
31
|
+
else if (isSequelizeConfig(this.config)) {
|
|
32
|
+
this.adapter = (await loadSequelizeAdapter(this.config));
|
|
20
33
|
}
|
|
21
34
|
else {
|
|
22
|
-
const exhaustive = config;
|
|
35
|
+
const exhaustive = this.config;
|
|
23
36
|
throw new Error(`Invalid repository configuration. Received: ${JSON.stringify(exhaustive)}`);
|
|
24
37
|
}
|
|
25
38
|
}
|
|
26
39
|
get model() {
|
|
40
|
+
if (!this.adapter) {
|
|
41
|
+
throw new Error("Repository not initialized. Call an async method first or await repository.ensureInitialized()");
|
|
42
|
+
}
|
|
27
43
|
return this.adapter.model;
|
|
28
44
|
}
|
|
29
45
|
isMongoose() {
|
|
@@ -33,30 +49,43 @@ export class BaseRepository {
|
|
|
33
49
|
return this.ormType === ORMType.Sequelize;
|
|
34
50
|
}
|
|
35
51
|
getMongooseModel() {
|
|
52
|
+
if (!this.adapter) {
|
|
53
|
+
throw new Error("Repository not initialized. Call an async method first or await repository.ensureInitialized()");
|
|
54
|
+
}
|
|
36
55
|
if (!this.isMongoose()) {
|
|
37
56
|
throw new Error("Repository is not using Mongoose");
|
|
38
57
|
}
|
|
39
58
|
return this.adapter.model;
|
|
40
59
|
}
|
|
41
60
|
getSequelizeModel() {
|
|
61
|
+
if (!this.adapter) {
|
|
62
|
+
throw new Error("Repository not initialized. Call an async method first or await repository.ensureInitialized()");
|
|
63
|
+
}
|
|
42
64
|
if (!this.isSequelize()) {
|
|
43
65
|
throw new Error("Repository is not using Sequelize");
|
|
44
66
|
}
|
|
45
67
|
return this.adapter.model;
|
|
46
68
|
}
|
|
47
69
|
toLean(input) {
|
|
70
|
+
if (!this.adapter) {
|
|
71
|
+
throw new Error("Repository not initialized. Call an async method first or await repository.ensureInitialized()");
|
|
72
|
+
}
|
|
48
73
|
return this.adapter.toLean(input);
|
|
49
74
|
}
|
|
50
75
|
async findById(id) {
|
|
76
|
+
await this.ensureInitialized();
|
|
51
77
|
return this.adapter.findById(id);
|
|
52
78
|
}
|
|
53
79
|
async create(entity) {
|
|
80
|
+
await this.ensureInitialized();
|
|
54
81
|
return this.adapter.create(entity);
|
|
55
82
|
}
|
|
56
83
|
async update(id, update) {
|
|
84
|
+
await this.ensureInitialized();
|
|
57
85
|
return this.adapter.update(id, update);
|
|
58
86
|
}
|
|
59
87
|
async delete(id) {
|
|
88
|
+
await this.ensureInitialized();
|
|
60
89
|
return this.adapter.delete(id);
|
|
61
90
|
}
|
|
62
91
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.js","sourceRoot":"./src/","sources":["service/architecture/infrastructure/repositories/abstract.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"abstract.js","sourceRoot":"./src/","sources":["service/architecture/infrastructure/repositories/abstract.ts"],"names":[],"mappings":"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","sourcesContent":["// Type-only imports prevent eager loading in ESM\nimport type { Model as MongooseModel } from \"mongoose\";\nimport type { Model, ModelStatic } from \"sequelize\";\nimport {\n BaseRepositoryConfig,\n Repository,\n MongooseRepositoryConfig,\n SequelizeRepositoryConfig,\n ORMAdapter,\n ORMType,\n} from \"./types\";\nimport {\n loadMongooseAdapter,\n loadSequelizeAdapter,\n} from \"../orm/adapter-loader\";\n\nexport * from \"./types\";\n\nconst isMongooseConfig = <D>(\n config: BaseRepositoryConfig<D>,\n): config is MongooseRepositoryConfig<D> => {\n return config.type === ORMType.Mongoose;\n};\n\nconst isSequelizeConfig = <D extends Model>(\n config: BaseRepositoryConfig<D>,\n): config is SequelizeRepositoryConfig<D> => {\n return config.type === ORMType.Sequelize;\n};\n\n/**\n * Abstract base repository supporting multiple ORMs via adapter pattern.\n * Adapters are lazy-loaded for optimal bundle size.\n */\nexport abstract class BaseRepository<D, I, O> implements Repository<D, I, O> {\n private adapter?: ORMAdapter<D, I, O>;\n private readonly ormType: ORMType;\n private readonly config: BaseRepositoryConfig<D>;\n private initPromise?: Promise<void>;\n\n constructor(config: BaseRepositoryConfig<D>) {\n this.ormType = config.type;\n this.config = config;\n }\n\n /**\n * Ensures the adapter is initialized before any operation\n * Uses a promise to prevent multiple concurrent initializations\n */\n private async ensureInitialized(): Promise<void> {\n if (this.adapter) return;\n\n if (!this.initPromise) {\n this.initPromise = this.loadAdapter();\n }\n\n await this.initPromise;\n }\n\n /**\n * Loads the appropriate ORM adapter based on configuration\n */\n private async loadAdapter(): Promise<void> {\n if (isMongooseConfig<D>(this.config)) {\n this.adapter = await loadMongooseAdapter<D, I, O>(this.config);\n } else if (isSequelizeConfig(this.config)) {\n // Type assertion needed here because D could be either Mongoose or Sequelize model\n this.adapter = (await loadSequelizeAdapter<Model, I, O>(\n this.config,\n )) as ORMAdapter<D, I, O>;\n } else {\n const exhaustive: never = this.config;\n throw new Error(\n `Invalid repository configuration. Received: ${JSON.stringify(exhaustive)}`,\n );\n }\n }\n\n get model(): MongooseModel<D> | ModelStatic<any> {\n if (!this.adapter) {\n throw new Error(\n \"Repository not initialized. Call an async method first or await repository.ensureInitialized()\",\n );\n }\n return this.adapter.model;\n }\n\n public isMongoose(): boolean {\n return this.ormType === ORMType.Mongoose;\n }\n\n public isSequelize(): boolean {\n return this.ormType === ORMType.Sequelize;\n }\n\n public getMongooseModel(): MongooseModel<D> {\n if (!this.adapter) {\n throw new Error(\n \"Repository not initialized. Call an async method first or await repository.ensureInitialized()\",\n );\n }\n if (!this.isMongoose()) {\n throw new Error(\"Repository is not using Mongoose\");\n }\n return this.adapter.model as MongooseModel<D>;\n }\n\n public getSequelizeModel(): ModelStatic<any> {\n if (!this.adapter) {\n throw new Error(\n \"Repository not initialized. Call an async method first or await repository.ensureInitialized()\",\n );\n }\n if (!this.isSequelize()) {\n throw new Error(\"Repository is not using Sequelize\");\n }\n return this.adapter.model as ModelStatic<any>;\n }\n\n public toLean(input: unknown): O | null {\n if (!this.adapter) {\n throw new Error(\n \"Repository not initialized. Call an async method first or await repository.ensureInitialized()\",\n );\n }\n return this.adapter.toLean(input);\n }\n\n async findById(id: string): Promise<O | null> {\n await this.ensureInitialized();\n return this.adapter!.findById(id);\n }\n\n async create(entity: I): Promise<O> {\n await this.ensureInitialized();\n return this.adapter!.create(entity);\n }\n\n async update(id: string, update: Partial<I>): Promise<O | null> {\n await this.ensureInitialized();\n return this.adapter!.update(id, update);\n }\n\n async delete(id: string): Promise<O | null> {\n await this.ensureInitialized();\n return this.adapter!.delete(id);\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Document, Model as MongooseModel, Schema, Default__v, Require_id, ObjectId, IfAny } from "mongoose";
|
|
2
|
-
import { Model as SequelizeModel, ModelStatic, Model } from "sequelize";
|
|
1
|
+
import type { Document, Model as MongooseModel, Schema, Default__v, Require_id, ObjectId, IfAny } from "mongoose";
|
|
2
|
+
import type { Model as SequelizeModel, ModelStatic, Model } from "sequelize";
|
|
3
3
|
export declare enum ORMType {
|
|
4
4
|
Mongoose = "mongoose",
|
|
5
5
|
Sequelize = "sequelize"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"./src/","sources":["service/architecture/infrastructure/repositories/types.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"./src/","sources":["service/architecture/infrastructure/repositories/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"./src/","sources":["service/architecture/infrastructure/repositories/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"./src/","sources":["service/architecture/infrastructure/repositories/types.ts"],"names":[],"mappings":"AAWA,MAAM,CAAN,IAAY,OAGX;AAHD,WAAY,OAAO;IACjB,gCAAqB,CAAA;IACrB,kCAAuB,CAAA;AACzB,CAAC,EAHW,OAAO,KAAP,OAAO,QAGlB","sourcesContent":["import type {\n Document,\n Model as MongooseModel,\n Schema,\n Default__v,\n Require_id,\n ObjectId,\n IfAny,\n} from \"mongoose\";\nimport type { Model as SequelizeModel, ModelStatic, Model } from \"sequelize\";\n\nexport enum ORMType {\n Mongoose = \"mongoose\",\n Sequelize = \"sequelize\",\n}\n\nexport type WithMongooseMeta<T> = Default__v<Require_id<T>>;\n\nexport type MongooseDocument<Db> = Document<\n ObjectId,\n {},\n Db,\n Record<string, string>\n> &\n WithMongooseMeta<Db>;\n\nexport type LeanWithMeta<T> = WithMongooseMeta<T> & {\n id: string;\n createdAt: Date;\n updatedAt: Date;\n};\n\nexport type LeanDocument<T> = T & {\n id: string;\n createdAt: Date;\n updatedAt: Date;\n};\n\nexport type MongooseDoc<Db> = IfAny<\n MongooseDocument<Db>,\n MongooseDocument<Db>,\n MongooseDocument<Db>\n>;\n\nexport type ToLeanInput<D, T> =\n | MongooseDoc<D>\n | LeanDocument<T>\n | null\n | undefined;\n\nexport type MongooseRepositoryConfig<D = unknown> = {\n readonly type: ORMType.Mongoose;\n readonly name?: string;\n readonly schema: Schema<D>;\n};\n\nexport type SequelizeRepositoryConfig<D extends Model = Model> = {\n readonly type: ORMType.Sequelize;\n readonly model: ModelStatic<D>;\n};\n\nexport type BaseRepositoryConfig<D = unknown> =\n | MongooseRepositoryConfig<D>\n | SequelizeRepositoryConfig<Model>;\n\nexport type Repository<D, I, O> = {\n model: MongooseModel<D> | ModelStatic<SequelizeModel<any, any>>;\n\n toLean(input: unknown): O | null;\n findById(id: string): Promise<O | null>;\n create(entity: I): Promise<O>;\n update(id: string, update: Partial<I>): Promise<O | null>;\n delete(id: string): Promise<O | null>;\n};\n\n/** ORM adapter interface for pluggable ORM implementations */\nexport interface ORMAdapter<D, I, O> {\n readonly model: MongooseModel<D> | ModelStatic<any>;\n toLean(input: unknown): O | null;\n findById(id: string): Promise<O | null>;\n create(entity: I): Promise<O>;\n update(id: string, update: Partial<I>): Promise<O | null>;\n delete(id: string): Promise<O | null>;\n}\n"]}
|