nest-hex 0.4.0 → 0.4.2

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
@@ -1,7 +1,6 @@
1
- </br>
2
- <img src="https://raw.githubusercontent.com/LiorVainer/nest-hex/main/assets/icon.png">
3
- </br>
4
- </br>
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/LiorVainer/nest-hex/main/assets/icon.png" width="150">
3
+ </p>
5
4
 
6
5
  ## nest-hex
7
6
 
@@ -71,7 +70,7 @@ export interface StoragePort {
71
70
  import type { AdapterConfig } from 'nest-hex'
72
71
  import type { STORAGE_PORT, StoragePort } from './storage.port'
73
72
 
74
- export interface S3Options {
73
+ export interface S3ConfigOptions {
75
74
  bucket: string
76
75
  region: string
77
76
  }
@@ -83,11 +82,11 @@ export type S3AdapterConfig = AdapterConfig<StorageToken, StoragePort>
83
82
  // s3.service.ts - Implementation service
84
83
  import { Injectable } from '@nestjs/common'
85
84
  import type { StoragePort } from './storage.port'
86
- import type { S3Options } from './s3.types'
85
+ import type { S3ConfigOptions } from './s3.types'
87
86
 
88
87
  @Injectable()
89
88
  export class S3Service implements StoragePort {
90
- constructor(private options: S3Options) {}
89
+ constructor(private options: S3ConfigOptions) {}
91
90
 
92
91
  async upload(key: string, data: Buffer): Promise<string> {
93
92
  // AWS S3 upload logic here
@@ -104,14 +103,14 @@ export class S3Service implements StoragePort {
104
103
  import { Adapter, AdapterBase } from 'nest-hex'
105
104
  import { STORAGE_PORT } from './storage.port'
106
105
  import { S3Service } from './s3.service'
107
- import type { S3AdapterConfig, S3Options } from './s3.types'
106
+ import type { S3AdapterConfig, S3ConfigOptions } from './s3.types'
108
107
 
109
108
  // Single decorator with type safety!
110
109
  @Adapter<S3AdapterConfig>({
111
110
  portToken: STORAGE_PORT,
112
111
  implementation: S3Service
113
112
  })
114
- export class S3Adapter extends AdapterBase<S3Options> {}
113
+ export class S3Adapter extends AdapterBase<S3ConfigOptions> {}
115
114
  ```
116
115
 
117
116
  ### 3. Create a Domain Service
@@ -136,16 +135,16 @@ export class FileService {
136
135
  }
137
136
  ```
138
137
 
139
- ### 4. Create a Port Module
138
+ ### 4. Create a Domain Module
140
139
 
141
140
  ```typescript
142
141
  // file.module.ts
143
142
  import { Module } from '@nestjs/common'
144
- import { PortModule } from 'nest-hex'
143
+ import { DomainModule } from 'nest-hex'
145
144
  import { FileService } from './file.service'
146
145
 
147
146
  @Module({})
148
- export class FileModule extends PortModule {}
147
+ export class FileModule extends DomainModule {}
149
148
  ```
150
149
 
151
150
  ### 5. Wire It Up
@@ -224,7 +223,7 @@ export type S3AdapterConfig = AdapterConfig<StorageToken, StoragePort>
224
223
  portToken: STORAGE_PORT,
225
224
  implementation: S3StorageService
226
225
  })
227
- export class S3Adapter extends AdapterBase<S3Options> {}
226
+ export class S3Adapter extends AdapterBase<S3ConfigOptions> {}
228
227
  ```
229
228
 
230
229
  ## Swappable Infrastructure
@@ -283,7 +282,7 @@ export type AxiosAdapterConfig = AdapterConfig<HttpClientToken, HttpClientPort>
283
282
  { provide: 'HTTP_CONFIG', useValue: { timeout: 5000 } }
284
283
  ]
285
284
  })
286
- export class AxiosAdapter extends AdapterBase<AxiosOptions> {}
285
+ export class AxiosAdapter extends AdapterBase<AxiosConfigOptions> {}
287
286
  ```
288
287
 
289
288
  ### Mock Adapters for Testing
@@ -17,7 +17,7 @@ import { DynamicModule, Provider } from "@nestjs/common";
17
17
  * imports: [HttpModule],
18
18
  * providers: [{ provide: 'CONFIG', useValue: {...} }]
19
19
  * })
20
- * class S3Adapter extends AdapterBase<S3Options> {}
20
+ * class S3Adapter extends AdapterBase<S3ConfigOptions> {}
21
21
  * ```
22
22
  *
23
23
  * Advanced adapter with dynamic configuration:
@@ -26,12 +26,12 @@ import { DynamicModule, Provider } from "@nestjs/common";
26
26
  * portToken: STORAGE_PORT,
27
27
  * implementation: S3Service
28
28
  * })
29
- * class S3Adapter extends AdapterBase<S3Options> {
30
- * protected imports(options: S3Options) {
29
+ * class S3Adapter extends AdapterBase<S3ConfigOptions> {
30
+ * protected imports(options: S3ConfigOptions) {
31
31
  * return [HttpModule.register({ timeout: options.timeout })]
32
32
  * }
33
33
  *
34
- * protected extraProviders(options: S3Options) {
34
+ * protected extraProviders(options: S3ConfigOptions) {
35
35
  * return [{ provide: 'S3_CONFIG', useValue: options }]
36
36
  * }
37
37
  * }
@@ -114,7 +114,7 @@ type AdapterConfig<
114
114
  * portToken: OBJECT_STORAGE_PORT,
115
115
  * implementation: S3ObjectStorageService
116
116
  * })
117
- * class S3Adapter extends AdapterBase<S3Options> {}
117
+ * class S3Adapter extends AdapterBase<S3ConfigOptions> {}
118
118
  * ```
119
119
  *
120
120
  * @example
@@ -154,9 +154,9 @@ declare function Adapter<Config extends AdapterConfig<any, any>>(config: {
154
154
  */
155
155
  declare function InjectPort<TToken>(token: TToken): ParameterDecorator;
156
156
  import { DynamicModule as DynamicModule3 } from "@nestjs/common";
157
- declare class PortModule {
157
+ declare class DomainModule {
158
158
  /**
159
- * Registers the port module with an adapter.
159
+ * Registers the domain module with an adapter.
160
160
  *
161
161
  * @param config - Configuration object containing the adapter module
162
162
  * @param config.adapter - An adapter module that provides a port implementation
@@ -166,4 +166,4 @@ declare class PortModule {
166
166
  adapter?: DynamicModule3;
167
167
  }): DynamicModule3;
168
168
  }
169
- export { PortModule, InjectPort, AdapterConfig, AdapterBase, Adapter };
169
+ export { InjectPort, DomainModule, AdapterConfig, AdapterBase, Adapter };
package/dist/src/index.js CHANGED
@@ -90,23 +90,23 @@ function Adapter(config) {
90
90
  function InjectPort(token) {
91
91
  return Inject(token);
92
92
  }
93
- // src/core/port-module.base.ts
93
+ // src/core/domain-module.base.ts
94
94
  import"reflect-metadata";
95
95
  import { Module } from "@nestjs/common";
96
- class PortModule {
96
+ class DomainModule {
97
97
  static register(config) {
98
98
  return {
99
- module: PortModule,
99
+ module: DomainModule,
100
100
  imports: config.adapter ? [config.adapter] : []
101
101
  };
102
102
  }
103
103
  }
104
- PortModule = __legacyDecorateClassTS([
104
+ DomainModule = __legacyDecorateClassTS([
105
105
  Module({})
106
- ], PortModule);
106
+ ], DomainModule);
107
107
  export {
108
- PortModule,
109
108
  InjectPort,
109
+ DomainModule,
110
110
  AdapterBase,
111
111
  Adapter
112
112
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nest-hex",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "type": "module",
5
5
  "description": "A tiny NestJS-native library for building pluggable adapters (Ports & Adapters / Hexagonal) using class-based Dynamic Modules, with great DX and strong type safety.",
6
6
  "homepage": "https://github.com/LiorVainer/nest-hex#readme",