@dv4resi/dvss-backend-module-offering-im 0.0.14 → 0.0.15

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,72 +1,316 @@
1
- # dvss-backend-module-offering-im
1
+ # @dv4resi/dvss-backend-module-offering-im
2
2
 
3
- Offering Integration Manager module for UIF. This app consumes shared
4
- integration packages and provides the offering integration runtime.
3
+ Offering Integration Manager module for UIF. This app aggregates and bundles the internal integration packages into a single publishable npm package that consuming microservices install.
5
4
 
6
- ## Dependencies
5
+ ---
6
+
7
+ ## Table of Contents
8
+
9
+ - [Overview](#overview)
10
+ - [What Gets Bundled](#what-gets-bundled)
11
+ - [How Consuming Microservices Use This](#how-consuming-microservices-use-this)
12
+ - [Bundling Configuration](#bundling-configuration)
13
+ - [Scripts](#scripts)
14
+ - [Local Development](#local-development)
15
+ - [Local Linking with yarn link](#local-linking-with-yarn-link)
16
+ - [Release Checklist](#release-checklist)
17
+ - [Dependencies](#dependencies)
18
+
19
+ ---
20
+
21
+ ## Overview
7
22
 
8
- Development dependencies include:
23
+ This is the **published app** for the offering integration domain. It acts as an aggregator module that:
9
24
 
10
- - `@dvss/dvss-integration-libs`
11
- - `@dvss/dvss-integration-trybe`
25
+ 1. Imports `IntegrationLibsModule` and `IntegrationTrybeModule`
26
+ 2. Re-exports both modules and all their public APIs
27
+ 3. Bundles the internal packages into `dist/` using `tsup` so consumers only install this single package
28
+
29
+ ```mermaid
30
+ graph TB
31
+ subgraph "UIF Monorepo (Internal)"
32
+ libs["@dvss/dvss-integration-libs"]
33
+ trybe["@dvss/dvss-integration-trybe"]
34
+ end
35
+
36
+ subgraph "This Package"
37
+ offering["@dv4resi/dvss-backend-module-offering-im<br/><b>OfferingIntegrationManager</b>"]
38
+ end
39
+
40
+ subgraph "Consuming Microservices"
41
+ booking["dvss-backend-capability-offering-booking-ms"]
42
+ hooks["dvss-backend-hooks-ms"]
43
+ others["Other microservices"]
44
+ end
45
+
46
+ libs -->|bundled into| offering
47
+ trybe -->|bundled into| offering
48
+ offering -->|"npm install"| booking
49
+ offering -->|"npm install"| hooks
50
+ offering -->|"npm install"| others
51
+ ```
12
52
 
13
- ## Build output
53
+ ---
14
54
 
15
- - Compiled artifacts are emitted to `dist/` via `tsup`
16
- - Internal UIF packages are bundled into `dist/` so consumers only install
17
- `@dv4resi/dvss-backend-module-offering-im`
55
+ ## What Gets Bundled
18
56
 
19
- ## Bundling behavior
57
+ At build time, `tsup` bundles the following internal packages into `dist/`:
58
+
59
+ | Internal Package | What It Provides |
60
+ | ------------------------------ | ---------------------------------------------------- |
61
+ | `@dvss/dvss-integration-libs` | Base classes, DAOs, traffic router, common utilities |
62
+ | `@dvss/dvss-integration-trybe` | Trybe-specific capability implementations |
63
+
64
+ The following are kept **external** (not bundled) and must be present in the consuming microservice:
65
+
66
+ - `@nestjs/*` packages
67
+ - `@dv4resi/dvss-backend-module-datastore`
68
+ - `@dv4resi/dvss-backend-module-utility`
69
+ - `rxjs`, `reflect-metadata`, `class-transformer`, `class-validator`
70
+ - `drizzle-orm`
71
+
72
+ ---
73
+
74
+ ## How Consuming Microservices Use This
75
+
76
+ ### Installation
77
+
78
+ ```bash
79
+ # Install in the consuming microservice
80
+ npm install @dv4resi/dvss-backend-module-offering-im
81
+ # or
82
+ yarn add @dv4resi/dvss-backend-module-offering-im
83
+ ```
84
+
85
+ ### Importing `OfferingIntegrationManager`
86
+
87
+ The primary export is `OfferingIntegrationManager` -- a NestJS module that wraps and re-exports both `IntegrationTrybeModule` and `IntegrationLibsModule`. Consuming microservices only need this single import to get access to all integration services:
88
+
89
+ ```typescript
90
+ import { OfferingIntegrationManager } from '@dv4resi/dvss-backend-module-offering-im';
91
+
92
+ @Module({
93
+ imports: [
94
+ OfferingIntegrationManager, // brings in all Trybe + Libs services
95
+ // ... other modules
96
+ ],
97
+ })
98
+ export class SomeFeatureModule {}
99
+ ```
100
+
101
+ Once imported, all exported services from both internal packages are available for injection:
102
+
103
+ ```typescript
104
+ import {
105
+ TrybeAuthService,
106
+ TrybeCustomerManagement,
107
+ TrybeCreditBooking,
108
+ TrybeWellnessManagement,
109
+ TrybeIntegrationConfigurationService,
110
+ TrybeIntegrationResourceManagementService,
111
+ // ... any other exported service or model
112
+ } from '@dv4resi/dvss-backend-module-offering-im';
113
+ ```
114
+
115
+ ### What `OfferingIntegrationManager` provides under the hood
116
+
117
+ ```typescript
118
+ // apps/dvss-backend-module-offering-im/src/app.module.ts
119
+ @Module({
120
+ imports: [IntegrationTrybeModule, IntegrationLibsModule],
121
+ exports: [IntegrationTrybeModule, IntegrationLibsModule],
122
+ })
123
+ export class OfferingIntegrationManager {}
124
+ ```
125
+
126
+ ```typescript
127
+ // apps/dvss-backend-module-offering-im/src/index.ts
128
+ export { AppModule as OfferingIntegrationManager } from './app.module';
129
+ export { IntegrationTrybeModule } from '@dvss/dvss-integration-trybe';
130
+ export { IntegrationLibsModule } from '@dvss/dvss-integration-libs';
131
+ export * from '@dvss/dvss-integration-libs'; // all libs services, models, utils
132
+ export * from '@dvss/dvss-integration-trybe'; // all trybe services, models, utils
133
+ ```
134
+
135
+ ### Real-world example
136
+
137
+ Here is how `dvss-backend-capability-offering-configuration-ms` uses it:
138
+
139
+ ```typescript
140
+ import { OfferingIntegrationManager } from '@dv4resi/dvss-backend-module-offering-im';
141
+
142
+ @Module({
143
+ imports: [
144
+ LoggerModule,
145
+ DatastoreModule,
146
+ GraphQLIntercommunicationModule,
147
+ HttpModule,
148
+ PubSubModule,
149
+ OfferingIntegrationManager, // <-- single import for all integration services
150
+ forwardRef(() => IntegrationsModule),
151
+ forwardRef(() => OfferingIntegrationManagementModule),
152
+ ],
153
+ // ...
154
+ })
155
+ export class OfferingManagementModule {}
156
+ ```
20
157
 
21
- - Bundled: `@dvss/dvss-integration-libs`, `@dvss/dvss-integration-trybe`
22
- - Externalized: NestJS, RxJS, and other runtime dependencies listed in
23
- `package.json`
24
- - Build-time requirement: `@swc/core` (installed at the monorepo root)
158
+ ```mermaid
159
+ graph TB
160
+ subgraph "OfferingIntegrationManager (single import)"
161
+ direction TB
162
+ TrybeModule["IntegrationTrybeModule"]
163
+ LibsModule["IntegrationLibsModule"]
164
+ end
165
+
166
+ subgraph "Trybe Services (available for injection)"
167
+ TrybeAuth["TrybeAuthService"]
168
+ TrybeCust["TrybeCustomerManagement"]
169
+ TrybeCredit["TrybeCreditBooking"]
170
+ TrybeWellness["TrybeWellnessManagement"]
171
+ TrybeConfig["TrybeIntegrationConfigurationService"]
172
+ TrybeResource["TrybeIntegrationResourceManagementService"]
173
+ end
174
+
175
+ subgraph "Libs Services (available for injection)"
176
+ Gateway["TrafficGatewayService"]
177
+ Logger["IntegrationRequestLoggerService"]
178
+ ConfigDao["IntegrationConfigurationDao"]
179
+ ResourceDao["IntegrationResourceManagementDao"]
180
+ end
181
+
182
+ TrybeModule --> TrybeAuth
183
+ TrybeModule --> TrybeCust
184
+ TrybeModule --> TrybeCredit
185
+ TrybeModule --> TrybeWellness
186
+ TrybeModule --> TrybeConfig
187
+ TrybeModule --> TrybeResource
188
+ LibsModule --> Gateway
189
+ LibsModule --> Logger
190
+ LibsModule --> ConfigDao
191
+ LibsModule --> ResourceDao
192
+ ```
193
+
194
+ ---
195
+
196
+ ## Bundling Configuration
197
+
198
+ The `tsup.config.ts` handles:
199
+
200
+ - **Internal package resolution** - Resolves `@dvss/dvss-integration-libs` and `@dvss/dvss-integration-trybe` to their source files and bundles them
201
+ - **Path resolution** - Fixes `__dirname` references for `.env` file resolution so it works in both monorepo and installed contexts
202
+ - **Output format** - CommonJS (for NestJS compatibility)
203
+ - **Type declarations** - Generates `.d.ts` files for TypeScript consumers
204
+ - **Source maps** - Enabled for debugging
205
+ - **SWC** - Used for decorator metadata support
206
+ - **Tree-shaking** - Enabled to remove unused code
207
+
208
+ ---
25
209
 
26
210
  ## Scripts
27
211
 
28
212
  ```bash
29
213
  # Start in dev mode with watch on dependent packages
30
- # This picks up changes from libs and trybe
214
+ # Watches: ./src, ../../packages/dvss-integration-libs/src, ../../packages/dvss-integration-trybe/src
31
215
  yarn run start:dev
32
216
 
33
- # Build the package
217
+ # Build the package (tsup)
34
218
  yarn run build
35
219
 
36
220
  # Watch builds (tsup)
37
221
  yarn run build:dev
38
222
 
39
- # Build all local dependencies before building
223
+ # Build all local dependencies first, then build this package
40
224
  yarn run build:with-deps
41
225
 
42
226
  # Tests
43
227
  yarn run test
228
+ yarn run test:cov
229
+ yarn run test:watch
44
230
  ```
45
231
 
46
- ## Local usage
232
+ ---
233
+
234
+ ## Local Development
47
235
 
48
236
  From the monorepo root:
49
237
 
50
238
  ```bash
51
- yarn --cwd apps/dvss-backend-module-offering-im run build
239
+ # Build this app with all its internal deps in order
240
+ yarn --cwd apps/dvss-backend-module-offering-im run build:with-deps
241
+
242
+ # Watch mode - auto-rebuilds when libs or trybe source files change
243
+ yarn --cwd apps/dvss-backend-module-offering-im run start:dev
244
+ ```
245
+
246
+ The `start:dev` script uses `nodemon` to watch source files across three locations:
247
+
248
+ - `./src` (this app)
249
+ - `../../packages/dvss-integration-libs/src`
250
+ - `../../packages/dvss-integration-trybe/src`
251
+
252
+ Any `.ts` file change in these directories triggers a `tsup` rebuild.
253
+
254
+ ---
255
+
256
+ ## Local Linking with yarn link
257
+
258
+ To test local changes in a consuming microservice without publishing:
259
+
260
+ ```bash
261
+ # 1. Build with deps
262
+ yarn --cwd apps/dvss-backend-module-offering-im run build:with-deps
263
+
264
+ # 2. Register the link (from the app directory)
265
+ cd apps/dvss-backend-module-offering-im
266
+ yarn link
267
+
268
+ # 3. Use the link in the consuming microservice
269
+ cd /path/to/consuming-microservice
270
+ yarn link "@dv4resi/dvss-backend-module-offering-im"
271
+
272
+ # 4. Unlink when done
273
+ yarn unlink "@dv4resi/dvss-backend-module-offering-im"
274
+ yarn install --force
52
275
  ```
53
276
 
54
- ## Setup notes
55
-
56
- - Install all workspace dependencies from the repo root with `yarn install`
57
- - When working on dependent packages (e.g., trybe or libs), use `yarn run start:dev` here to pick up their changes
58
-
59
- ## Release checklist
60
-
61
- - Bump `package.json` version in `apps/dvss-backend-module-offering-im` before release
62
- - Lint and tests run automatically on commit via Husky
63
- - Merge to `master` to trigger the initial lint/build pipeline
64
- - After the initial pipeline passes, trigger the publish pipeline from the latest
65
- merged commit on `master`
66
- - Tag format must match the version script in `scripts/validate-tag-and-publish.sh`:
67
- - Tag pattern: `dvss-backend-module-offering-im-vX.Y.Z`
68
- - Version must be exactly the next patch/minor/major from npm (no skipping)
69
- - The tag prefix must be allowlisted in `ALLOWED_APP_NAMES`
70
- - Example: if current published version is `0.0.3`, valid tags are
71
- `dvss-backend-module-offering-im-v0.0.4`, `...-v0.1.0`, or `...-v1.0.0`
72
- - Also the package.json version should be the next valid version.
277
+ > **Tip:** Run `start:dev` in the UIF monorepo while linked so changes to `libs` or `trybe` automatically rebuild this package, and the consuming microservice picks them up.
278
+
279
+ ---
280
+
281
+ ## Release Checklist
282
+
283
+ 1. Bump the `version` field in this app's `package.json`
284
+ 2. Lint and tests run automatically on commit via Husky
285
+ 3. Merge to `master` to trigger the CI lint/build pipeline
286
+ 4. After the pipeline passes, trigger the publish pipeline from the latest merged commit on `master`
287
+ 5. Tag format: `dvss-backend-module-offering-im-vX.Y.Z`
288
+ - Version must be exactly the next patch/minor/major from npm (no skipping)
289
+ - The tag prefix must be in the `ALLOWED_APP_NAMES` allowlist in `scripts/validate-tag-and-publish.sh`
290
+
291
+ **Example:** If current published version is `0.0.14`, valid next versions are:
292
+
293
+ - `dvss-backend-module-offering-im-v0.0.15` (patch)
294
+ - `dvss-backend-module-offering-im-v0.1.0` (minor)
295
+ - `dvss-backend-module-offering-im-v1.0.0` (major)
296
+
297
+ > The `package.json` version must match the tag version.
298
+
299
+ ---
300
+
301
+ ## Dependencies
302
+
303
+ **Runtime** (must be present in consuming microservice):
304
+
305
+ | Dependency | Purpose |
306
+ | ------------------------------------------------------------ | ------------------- |
307
+ | `@nestjs/common`, `@nestjs/core`, `@nestjs/platform-express` | NestJS framework |
308
+ | `rxjs` | Reactive extensions |
309
+ | `reflect-metadata` | Decorator metadata |
310
+
311
+ **Dev / Bundled** (bundled into `dist/`, not required by consumers):
312
+
313
+ | Dependency | Purpose |
314
+ | ------------------------------ | -------------------------------------------- |
315
+ | `@dvss/dvss-integration-libs` | Internal: base classes, DAOs, traffic router |
316
+ | `@dvss/dvss-integration-trybe` | Internal: Trybe capability implementations |