nestjs-query-mikro-orm 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +174 -0
  3. package/dist/index.cjs +1575 -0
  4. package/dist/index.cjs.map +7 -0
  5. package/dist/index.d.ts +5 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +1530 -0
  8. package/dist/index.js.map +7 -0
  9. package/dist/lib/common/index.d.ts +2 -0
  10. package/dist/lib/common/index.d.ts.map +1 -0
  11. package/dist/lib/common/randomString.d.ts +2 -0
  12. package/dist/lib/common/randomString.d.ts.map +1 -0
  13. package/dist/lib/nest-query-mikro-orm.module.d.ts +6 -0
  14. package/dist/lib/nest-query-mikro-orm.module.d.ts.map +1 -0
  15. package/dist/lib/providers.d.ts +4 -0
  16. package/dist/lib/providers.d.ts.map +1 -0
  17. package/dist/lib/query/aggregate.builder.d.ts +40 -0
  18. package/dist/lib/query/aggregate.builder.d.ts.map +1 -0
  19. package/dist/lib/query/filter-query.builder.d.ts +84 -0
  20. package/dist/lib/query/filter-query.builder.d.ts.map +1 -0
  21. package/dist/lib/query/index.d.ts +6 -0
  22. package/dist/lib/query/index.d.ts.map +1 -0
  23. package/dist/lib/query/relation-query.builder.d.ts +36 -0
  24. package/dist/lib/query/relation-query.builder.d.ts.map +1 -0
  25. package/dist/lib/query/sql-comparison.builder.d.ts +27 -0
  26. package/dist/lib/query/sql-comparison.builder.d.ts.map +1 -0
  27. package/dist/lib/query/where.builder.d.ts +39 -0
  28. package/dist/lib/query/where.builder.d.ts.map +1 -0
  29. package/dist/lib/services/index.d.ts +3 -0
  30. package/dist/lib/services/index.d.ts.map +1 -0
  31. package/dist/lib/services/mikro-orm-query.service.d.ts +180 -0
  32. package/dist/lib/services/mikro-orm-query.service.d.ts.map +1 -0
  33. package/dist/lib/services/relation-query.service.d.ts +132 -0
  34. package/dist/lib/services/relation-query.service.d.ts.map +1 -0
  35. package/dist/tsconfig.lib.tsbuildinfo +1 -0
  36. package/package.json +109 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Manuel Antunes
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,174 @@
1
+ # nestjs-query-mikro-orm
2
+
3
+ A [NestJS Query](https://github.com/tripss/nestjs-query) adapter for [MikroORM](https://mikro-orm.io/).
4
+
5
+ This library provides a seamless integration between NestJS Query and MikroORM, allowing you to build powerful GraphQL APIs with minimal boilerplate.
6
+
7
+ ## Features
8
+
9
+ - 🚀 Full NestJS Query support with MikroORM
10
+ - 📦 Type-safe query building
11
+ - 🔍 Advanced filtering and sorting
12
+ - 🔗 Relation query support
13
+ - 📊 Aggregation queries
14
+ - 🎯 Soft delete support
15
+ - ✨ Built with TypeScript
16
+ - 📦 Dual-format support (ESM & CommonJS)
17
+
18
+ ## Compatibility
19
+
20
+ This package supports both **ES Modules (ESM)** and **CommonJS (CJS)** for maximum compatibility across different Node.js environments and bundlers.
21
+
22
+ - **ESM**: `import { MikroOrmQueryService } from 'nestjs-query-mikro-orm'`
23
+ - **CommonJS**: `const { MikroOrmQueryService } = require('nestjs-query-mikro-orm')`
24
+
25
+ The package automatically detects the import method and serves the appropriate format.
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ pnpm add nestjs-query-mikro-orm
31
+
32
+ # Install peer dependencies if you haven't already
33
+ pnpm add @mikro-orm/core @nestjs/common @nestjs/core @nestjs-query/core reflect-metadata rxjs
34
+ ```
35
+
36
+ ## Quick Start
37
+
38
+ ### 1. Setup MikroORM Module
39
+
40
+ ```typescript
41
+ import { NestQueryMikroOrmModule } from 'nestjs-query-mikro-orm';
42
+ import { Module } from '@nestjs/common';
43
+ import { UserEntity } from './user.entity';
44
+
45
+ @Module({
46
+ imports: [NestQueryMikroOrmModule.forFeature([UserEntity])],
47
+ })
48
+ export class UserModule {}
49
+ ```
50
+
51
+ ### 2. Create Your Entity
52
+
53
+ ```typescript
54
+ import { Entity, PrimaryKey, Property } from '@mikro-orm/core';
55
+
56
+ @Entity()
57
+ export class UserEntity {
58
+ @PrimaryKey()
59
+ id!: number;
60
+
61
+ @Property()
62
+ name!: string;
63
+
64
+ @Property()
65
+ email!: string;
66
+
67
+ @Property()
68
+ createdAt: Date = new Date();
69
+ }
70
+ ```
71
+
72
+ ### 3. Use the Query Service
73
+
74
+ ```typescript
75
+ import { Injectable } from '@nestjs/common';
76
+ import { MikroOrmQueryService } from 'nestjs-query-mikro-orm';
77
+ import { UserEntity } from './user.entity';
78
+
79
+ @Injectable()
80
+ export class UserService extends MikroOrmQueryService<UserEntity> {
81
+ // Your custom methods here
82
+ }
83
+ ```
84
+
85
+ ## Development
86
+
87
+ ### Prerequisites
88
+
89
+ - Node.js >= 18
90
+ - pnpm >= 9
91
+
92
+ ### Setup
93
+
94
+ ```bash
95
+ # Install dependencies
96
+ pnpm install
97
+
98
+ # Setup git hooks
99
+ pnpm prepare
100
+ ```
101
+
102
+ ### Available Scripts
103
+
104
+ ```bash
105
+ # Build the library
106
+ pnpm build
107
+
108
+ # Build in watch mode
109
+ pnpm dev
110
+
111
+ # Run tests
112
+ pnpm test
113
+
114
+ # Run tests in watch mode
115
+ pnpm test:watch
116
+
117
+ # Run tests with coverage
118
+ pnpm test:coverage
119
+
120
+ # Lint code
121
+ pnpm lint
122
+
123
+ # Fix lint issues
124
+ pnpm lint:fix
125
+
126
+ # Format code
127
+ pnpm format
128
+
129
+ # Check formatting
130
+ pnpm format:check
131
+
132
+ # Type check
133
+ pnpm typecheck
134
+ ```
135
+
136
+ ### Git Hooks
137
+
138
+ This project uses Husky for git hooks:
139
+
140
+ - **pre-commit**: Runs lint-staged to format and lint staged files
141
+ - **pre-push**: Runs lint, typecheck, and tests before pushing
142
+ - **commit-msg**: Validates commit messages using commitlint
143
+
144
+ ### Commit Convention
145
+
146
+ This project follows [Conventional Commits](https://www.conventionalcommits.org/):
147
+
148
+ ```bash
149
+ feat: add new feature
150
+ fix: fix bug
151
+ docs: update documentation
152
+ style: format code
153
+ refactor: refactor code
154
+ test: add tests
155
+ chore: update dependencies
156
+ ```
157
+
158
+ ## License
159
+
160
+ MIT
161
+
162
+ ## Author
163
+
164
+ Manuel Antunes
165
+
166
+ ## Contributing
167
+
168
+ Contributions are welcome! Please feel free to submit a Pull Request.
169
+
170
+ 1. Fork the repository
171
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
172
+ 3. Commit your changes (`git commit -m 'feat: add amazing feature'`)
173
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
174
+ 5. Open a Pull Request