@breadstone/archipel-mcp 0.0.46 → 0.0.47
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/data/guides/composition-context.md +462 -0
- package/data/guides/index.md +1 -0
- package/data/packages/platform-blob-storage/api/Class.BlobStorageStrategyBase.md +1 -0
- package/data/packages/platform-blob-storage/api/Class.EmptyBlobStorageStrategy.md +183 -0
- package/data/packages/platform-blob-storage/api/Variable.AWS_S3_ACCESS_KEY_ID.md +1 -1
- package/data/packages/platform-blob-storage/api/Variable.AWS_S3_BUCKET.md +1 -1
- package/data/packages/platform-blob-storage/api/Variable.AWS_S3_CONFIG_ENTRIES.md +1 -1
- package/data/packages/platform-blob-storage/api/Variable.AWS_S3_ENDPOINT.md +1 -1
- package/data/packages/platform-blob-storage/api/Variable.AWS_S3_REGION.md +1 -1
- package/data/packages/platform-blob-storage/api/Variable.AWS_S3_SECRET_ACCESS_KEY.md +1 -1
- package/data/packages/platform-blob-storage/api/Variable.LOCAL_BLOB_BASE_PATH.md +1 -1
- package/data/packages/platform-blob-storage/api/Variable.LOCAL_BLOB_BUCKET.md +1 -1
- package/data/packages/platform-blob-storage/api/Variable.LOCAL_CONFIG_ENTRIES.md +1 -1
- package/data/packages/platform-blob-storage/api/Variable.PLATFORM_BLOB_STORAGE_CONFIG_ENTRIES.md +1 -1
- package/data/packages/platform-blob-storage/api/index.md +1 -0
- package/data/packages/platform-blob-storage/index.md +21 -1
- package/data/packages/platform-bootstrap/api/Class.CompositionContext.md +226 -0
- package/data/packages/platform-bootstrap/api/Class.CompositionModule.md +56 -0
- package/data/packages/platform-bootstrap/api/Class.CompositionResolver.md +206 -0
- package/data/packages/platform-bootstrap/api/Class.PlatformApplicationBuilder.md +75 -8
- package/data/packages/platform-bootstrap/api/Function.createCompositionContext.md +56 -0
- package/data/packages/platform-bootstrap/api/Interface.ICompositionContext.md +179 -0
- package/data/packages/platform-bootstrap/api/Interface.ICreateCompositionContextOptions.md +54 -0
- package/data/packages/platform-bootstrap/api/Interface.ICreateWithCompositionOptions.md +128 -0
- package/data/packages/platform-bootstrap/api/Interface.IProviderDecision.md +36 -0
- package/data/packages/platform-bootstrap/api/TypeAlias.CompositionImport.md +20 -0
- package/data/packages/platform-bootstrap/api/TypeAlias.ProviderComposer.md +53 -0
- package/data/packages/platform-bootstrap/api/index.md +10 -0
- package/data/packages/platform-mailing/api/Class.DeliveryStrategyBase.md +0 -1
- package/data/packages/platform-mailing/api/index.md +0 -1
- package/package.json +1 -1
- package/data/packages/platform-mailing/api/Class.LogDeliveryStrategy.md +0 -71
|
@@ -9,6 +9,6 @@ editUrl: false
|
|
|
9
9
|
const AWS_S3_REGION: IConfigKey<string>;
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
Defined in: [strategies/aws-s3/env.ts:
|
|
12
|
+
Defined in: [strategies/aws-s3/env.ts:12](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-blob-storage/src/strategies/aws-s3/env.ts#L12)
|
|
13
13
|
|
|
14
14
|
AWS S3 region.
|
|
@@ -9,6 +9,6 @@ editUrl: false
|
|
|
9
9
|
const AWS_S3_SECRET_ACCESS_KEY: IConfigKey<string>;
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
Defined in: [strategies/aws-s3/env.ts:
|
|
12
|
+
Defined in: [strategies/aws-s3/env.ts:33](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-blob-storage/src/strategies/aws-s3/env.ts#L33)
|
|
13
13
|
|
|
14
14
|
AWS S3 secret access key.
|
|
@@ -9,6 +9,6 @@ editUrl: false
|
|
|
9
9
|
const LOCAL_BLOB_BASE_PATH: IConfigKey<string>;
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
Defined in: [strategies/local/env.ts:
|
|
12
|
+
Defined in: [strategies/local/env.ts:12](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-blob-storage/src/strategies/local/env.ts#L12)
|
|
13
13
|
|
|
14
14
|
Local blob storage base path.
|
|
@@ -9,6 +9,6 @@ editUrl: false
|
|
|
9
9
|
const LOCAL_BLOB_BUCKET: IConfigKey<string>;
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
Defined in: [strategies/local/env.ts:
|
|
12
|
+
Defined in: [strategies/local/env.ts:19](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-blob-storage/src/strategies/local/env.ts#L19)
|
|
13
13
|
|
|
14
14
|
Local blob storage bucket (subdirectory).
|
|
@@ -9,6 +9,6 @@ editUrl: false
|
|
|
9
9
|
const LOCAL_CONFIG_ENTRIES: ReadonlyArray<Omit<IConfigRegistryEntry, "module">>;
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
Defined in: [strategies/local/env.ts:
|
|
12
|
+
Defined in: [strategies/local/env.ts:26](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-blob-storage/src/strategies/local/env.ts#L26)
|
|
13
13
|
|
|
14
14
|
Configuration entries required by the local blob storage strategy.
|
package/data/packages/platform-blob-storage/api/Variable.PLATFORM_BLOB_STORAGE_CONFIG_ENTRIES.md
CHANGED
|
@@ -9,6 +9,6 @@ editUrl: false
|
|
|
9
9
|
const PLATFORM_BLOB_STORAGE_CONFIG_ENTRIES: ReadonlyArray<Omit<IConfigRegistryEntry, "module">>;
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
Defined in: [env.ts:
|
|
12
|
+
Defined in: [env.ts:21](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-blob-storage/src/env.ts#L21)
|
|
13
13
|
|
|
14
14
|
All configuration entries for `platform-blob-storage`. All keys are optional at the aggregate level.
|
|
@@ -17,6 +17,7 @@ editUrl: false
|
|
|
17
17
|
| [BlobService](Class.BlobService) | Provides a generic abstraction for blob storage operations independent of the underlying provider. |
|
|
18
18
|
| [BlobStorageStrategyBase](Class.BlobStorageStrategyBase) | Abstract base class for blob storage strategies. Every concrete provider (AWS S3, Azure, Vercel, Local, etc.) must extend this class. Serves as both the type contract and the NestJS DI token type reference. |
|
|
19
19
|
| [BlobVariantPersistencePort](Class.BlobVariantPersistencePort) | Abstract port for persisting blob variant metadata. Consuming projects must provide a concrete implementation and register it via `BlobModule.forRoot({ variantPersistence: MyAdapter })`. |
|
|
20
|
+
| [EmptyBlobStorageStrategy](Class.EmptyBlobStorageStrategy) | Provides a blob storage strategy backed by the local filesystem. |
|
|
20
21
|
| [LocalBlobStorageStrategy](Class.LocalBlobStorageStrategy) | Provides a blob storage strategy backed by the local filesystem. |
|
|
21
22
|
| [VercelBlobStorageStrategy](Class.VercelBlobStorageStrategy) | Provides a blob storage strategy backed by the Vercel Blob API. |
|
|
22
23
|
|
|
@@ -8,7 +8,7 @@ package: '@breadstone/archipel-platform-blob-storage'
|
|
|
8
8
|
|
|
9
9
|
# platform-blob-storage
|
|
10
10
|
|
|
11
|
-
Cloud file storage abstraction supporting pluggable strategies and optional metadata persistence via ports. Ships with Vercel Blob, Azure Blob Storage, AWS S3,
|
|
11
|
+
Cloud file storage abstraction supporting pluggable strategies and optional metadata persistence via ports. Ships with Vercel Blob, Azure Blob Storage, AWS S3, local filesystem, and an empty/mock strategy out of the box.
|
|
12
12
|
|
|
13
13
|
**Package:** `@breadstone/archipel-platform-blob-storage`
|
|
14
14
|
|
|
@@ -63,6 +63,7 @@ import { VercelBlobStorageStrategy, VERCEL_CONFIG_ENTRIES } from '@breadstone/ar
|
|
|
63
63
|
import { AzureBlobStorageStrategy, AZURE_CONFIG_ENTRIES } from '@breadstone/archipel-platform-blob-storage/strategies/azure';
|
|
64
64
|
import { AwsS3BlobStorageStrategy, AWS_S3_CONFIG_ENTRIES } from '@breadstone/archipel-platform-blob-storage/strategies/aws-s3';
|
|
65
65
|
import { LocalBlobStorageStrategy, LOCAL_CONFIG_ENTRIES } from '@breadstone/archipel-platform-blob-storage/strategies/local';
|
|
66
|
+
import { EmptyBlobStorageStrategy } from '@breadstone/archipel-platform-blob-storage/strategies/empty';
|
|
66
67
|
|
|
67
68
|
// Vercel Blob
|
|
68
69
|
BlobModule.register({ storageStrategy: VercelBlobStorageStrategy, configEntries: VERCEL_CONFIG_ENTRIES });
|
|
@@ -76,6 +77,9 @@ BlobModule.register({ storageStrategy: AwsS3BlobStorageStrategy, configEntries:
|
|
|
76
77
|
// Local filesystem
|
|
77
78
|
BlobModule.register({ storageStrategy: LocalBlobStorageStrategy, configEntries: LOCAL_CONFIG_ENTRIES });
|
|
78
79
|
|
|
80
|
+
// Empty/mock strategy (for development and testing — logs operations, returns mock data)
|
|
81
|
+
BlobModule.register({ storageStrategy: EmptyBlobStorageStrategy });
|
|
82
|
+
|
|
79
83
|
// Custom strategy — extend BlobStorageStrategyBase
|
|
80
84
|
BlobModule.register({ storageStrategy: MyCustomStrategy });
|
|
81
85
|
```
|
|
@@ -307,6 +311,20 @@ BlobModule.register({
|
|
|
307
311
|
| `LOCAL_BLOB_BASE_PATH` | No | `./blob-data` | Base directory for local file storage |
|
|
308
312
|
| `LOCAL_BLOB_BUCKET` | No | `default` | Default bucket subdirectory |
|
|
309
313
|
|
|
314
|
+
### EmptyBlobStorageStrategy
|
|
315
|
+
|
|
316
|
+
A no-op storage strategy for development and testing. Logs all operations to the NestJS logger and returns mock results. No actual storage occurs.
|
|
317
|
+
|
|
318
|
+
```typescript
|
|
319
|
+
import { EmptyBlobStorageStrategy } from '@breadstone/archipel-platform-blob-storage/strategies/empty';
|
|
320
|
+
|
|
321
|
+
BlobModule.register({
|
|
322
|
+
storageStrategy: EmptyBlobStorageStrategy,
|
|
323
|
+
});
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
No environment variables required.
|
|
327
|
+
|
|
310
328
|
### Custom Strategy
|
|
311
329
|
|
|
312
330
|
Extend `BlobStorageStrategyBase` for any other storage backend (GCS, MinIO, etc.):
|
|
@@ -375,6 +393,7 @@ Each strategy is tree-shakeable via sub-path imports:
|
|
|
375
393
|
| `@breadstone/archipel-platform-blob-storage/strategies/azure` | AzureBlobStorageStrategy, AZURE_CONFIG_ENTRIES |
|
|
376
394
|
| `@breadstone/archipel-platform-blob-storage/strategies/aws-s3` | AwsS3BlobStorageStrategy, AWS_S3_CONFIG_ENTRIES |
|
|
377
395
|
| `@breadstone/archipel-platform-blob-storage/strategies/local` | LocalBlobStorageStrategy, LOCAL_CONFIG_ENTRIES |
|
|
396
|
+
| `@breadstone/archipel-platform-blob-storage/strategies/empty` | EmptyBlobStorageStrategy (mock/logging) |
|
|
378
397
|
| `@breadstone/archipel-platform-blob-storage/health` | BlobHealthIndicator |
|
|
379
398
|
|
|
380
399
|
---
|
|
@@ -392,5 +411,6 @@ Each strategy is tree-shakeable via sub-path imports:
|
|
|
392
411
|
| `AzureBlobStorageStrategy` | Strategy | Azure Blob Storage implementation (sub-path) |
|
|
393
412
|
| `AwsS3BlobStorageStrategy` | Strategy | AWS S3 implementation (sub-path) |
|
|
394
413
|
| `LocalBlobStorageStrategy` | Strategy | Local filesystem implementation (sub-path) |
|
|
414
|
+
| `EmptyBlobStorageStrategy` | Strategy | Mock/logging implementation (sub-path) |
|
|
395
415
|
| `BlobHealthIndicator` | Health | Blob storage health check (`/health` subpath) |
|
|
396
416
|
| `BlobDownloadResponseTypes` | Constant | `'arraybuffer'` \| `'json'` \| `'stream'` \| `'text'` |
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Class: CompositionContext'
|
|
3
|
+
generated: true
|
|
4
|
+
editUrl: false
|
|
5
|
+
---
|
|
6
|
+
# Class: CompositionContext
|
|
7
|
+
|
|
8
|
+
Defined in: composition/context/CompositionContext.ts:17
|
|
9
|
+
|
|
10
|
+
Default implementation of the composition context.
|
|
11
|
+
|
|
12
|
+
Wraps a temporary NestJS application context and provides convenient
|
|
13
|
+
access to configuration values during module composition.
|
|
14
|
+
|
|
15
|
+
## Implements
|
|
16
|
+
|
|
17
|
+
- [`ICompositionContext`](Interface.ICompositionContext)
|
|
18
|
+
|
|
19
|
+
## Constructors
|
|
20
|
+
|
|
21
|
+
### Constructor
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
new CompositionContext(context, config): CompositionContext;
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Defined in: composition/context/CompositionContext.ts:35
|
|
28
|
+
|
|
29
|
+
Constructs a new composition context.
|
|
30
|
+
|
|
31
|
+
#### Parameters
|
|
32
|
+
|
|
33
|
+
| Parameter | Type | Description |
|
|
34
|
+
| ------ | ------ | ------ |
|
|
35
|
+
| `context` | `INestApplicationContext` | The temporary NestJS application context. |
|
|
36
|
+
| `config` | `ConfigService` | The configuration service instance. |
|
|
37
|
+
|
|
38
|
+
#### Returns
|
|
39
|
+
|
|
40
|
+
`CompositionContext`
|
|
41
|
+
|
|
42
|
+
## Accessors
|
|
43
|
+
|
|
44
|
+
### config
|
|
45
|
+
|
|
46
|
+
#### Get Signature
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
get config(): ConfigService;
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Defined in: composition/context/CompositionContext.ts:54
|
|
53
|
+
|
|
54
|
+
The Archipel configuration service.
|
|
55
|
+
|
|
56
|
+
Provides typed access to environment configuration values.
|
|
57
|
+
|
|
58
|
+
##### Returns
|
|
59
|
+
|
|
60
|
+
`ConfigService`
|
|
61
|
+
|
|
62
|
+
The Archipel configuration service.
|
|
63
|
+
|
|
64
|
+
Provides typed access to environment configuration values.
|
|
65
|
+
|
|
66
|
+
#### Implementation of
|
|
67
|
+
|
|
68
|
+
[`ICompositionContext`](Interface.ICompositionContext).[`config`](Interface.ICompositionContext#config)
|
|
69
|
+
|
|
70
|
+
***
|
|
71
|
+
|
|
72
|
+
### context
|
|
73
|
+
|
|
74
|
+
#### Get Signature
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
get context(): INestApplicationContext;
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Defined in: composition/context/CompositionContext.ts:47
|
|
81
|
+
|
|
82
|
+
The temporary NestJS application context.
|
|
83
|
+
|
|
84
|
+
Used only for dependency injection resolution during composition.
|
|
85
|
+
Do not use this context for runtime services.
|
|
86
|
+
|
|
87
|
+
##### Returns
|
|
88
|
+
|
|
89
|
+
`INestApplicationContext`
|
|
90
|
+
|
|
91
|
+
The temporary NestJS application context.
|
|
92
|
+
|
|
93
|
+
Used only for dependency injection resolution during composition.
|
|
94
|
+
Do not use this context for runtime services.
|
|
95
|
+
|
|
96
|
+
#### Implementation of
|
|
97
|
+
|
|
98
|
+
[`ICompositionContext`](Interface.ICompositionContext).[`context`](Interface.ICompositionContext#context)
|
|
99
|
+
|
|
100
|
+
## Methods
|
|
101
|
+
|
|
102
|
+
### close()
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
close(): Promise<void>;
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Defined in: composition/context/CompositionContext.ts:86
|
|
109
|
+
|
|
110
|
+
Closes the temporary composition context.
|
|
111
|
+
|
|
112
|
+
Must be called after the real application has been created to release
|
|
113
|
+
resources held by the composition context.
|
|
114
|
+
|
|
115
|
+
#### Returns
|
|
116
|
+
|
|
117
|
+
`Promise`\<`void`\>
|
|
118
|
+
|
|
119
|
+
A promise that resolves when the context is closed.
|
|
120
|
+
|
|
121
|
+
#### Implementation of
|
|
122
|
+
|
|
123
|
+
[`ICompositionContext`](Interface.ICompositionContext).[`close`](Interface.ICompositionContext#close)
|
|
124
|
+
|
|
125
|
+
***
|
|
126
|
+
|
|
127
|
+
### getConfigValue()
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
getConfigValue<T>(key): T;
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Defined in: composition/context/CompositionContext.ts:65
|
|
134
|
+
|
|
135
|
+
Reads a required configuration value.
|
|
136
|
+
|
|
137
|
+
#### Type Parameters
|
|
138
|
+
|
|
139
|
+
| Type Parameter | Description |
|
|
140
|
+
| ------ | ------ |
|
|
141
|
+
| `T` | The expected type of the configuration value. |
|
|
142
|
+
|
|
143
|
+
#### Parameters
|
|
144
|
+
|
|
145
|
+
| Parameter | Type | Description |
|
|
146
|
+
| ------ | ------ | ------ |
|
|
147
|
+
| `key` | `IConfigKey`\<`T`\> | The typed configuration key. |
|
|
148
|
+
|
|
149
|
+
#### Returns
|
|
150
|
+
|
|
151
|
+
`T`
|
|
152
|
+
|
|
153
|
+
The typed configuration value.
|
|
154
|
+
|
|
155
|
+
#### Implementation of
|
|
156
|
+
|
|
157
|
+
[`ICompositionContext`](Interface.ICompositionContext).[`getConfigValue`](Interface.ICompositionContext#getconfigvalue)
|
|
158
|
+
|
|
159
|
+
***
|
|
160
|
+
|
|
161
|
+
### getService()
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
getService<T>(token): T;
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Defined in: composition/context/CompositionContext.ts:79
|
|
168
|
+
|
|
169
|
+
Resolves a provider from the composition context.
|
|
170
|
+
|
|
171
|
+
#### Type Parameters
|
|
172
|
+
|
|
173
|
+
| Type Parameter | Description |
|
|
174
|
+
| ------ | ------ |
|
|
175
|
+
| `T` | The type of the provider. |
|
|
176
|
+
|
|
177
|
+
#### Parameters
|
|
178
|
+
|
|
179
|
+
| Parameter | Type | Description |
|
|
180
|
+
| ------ | ------ | ------ |
|
|
181
|
+
| `token` | (...`args`) => `T` | The provider token (class, string, or symbol). |
|
|
182
|
+
|
|
183
|
+
#### Returns
|
|
184
|
+
|
|
185
|
+
`T`
|
|
186
|
+
|
|
187
|
+
The resolved provider instance.
|
|
188
|
+
|
|
189
|
+
#### Implementation of
|
|
190
|
+
|
|
191
|
+
[`ICompositionContext`](Interface.ICompositionContext).[`getService`](Interface.ICompositionContext#getservice)
|
|
192
|
+
|
|
193
|
+
***
|
|
194
|
+
|
|
195
|
+
### tryGetConfigValue()
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
tryGetConfigValue<T>(key, fallback): T;
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Defined in: composition/context/CompositionContext.ts:72
|
|
202
|
+
|
|
203
|
+
Reads an optional configuration value with a fallback.
|
|
204
|
+
|
|
205
|
+
#### Type Parameters
|
|
206
|
+
|
|
207
|
+
| Type Parameter | Description |
|
|
208
|
+
| ------ | ------ |
|
|
209
|
+
| `T` | The expected type of the configuration value. |
|
|
210
|
+
|
|
211
|
+
#### Parameters
|
|
212
|
+
|
|
213
|
+
| Parameter | Type | Description |
|
|
214
|
+
| ------ | ------ | ------ |
|
|
215
|
+
| `key` | `IConfigKey`\<`T`\> | The typed configuration key. |
|
|
216
|
+
| `fallback` | `T` | The fallback value when the key is absent. |
|
|
217
|
+
|
|
218
|
+
#### Returns
|
|
219
|
+
|
|
220
|
+
`T`
|
|
221
|
+
|
|
222
|
+
The typed configuration value or the fallback.
|
|
223
|
+
|
|
224
|
+
#### Implementation of
|
|
225
|
+
|
|
226
|
+
[`ICompositionContext`](Interface.ICompositionContext).[`tryGetConfigValue`](Interface.ICompositionContext#trygetconfigvalue)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Class: CompositionModule'
|
|
3
|
+
generated: true
|
|
4
|
+
editUrl: false
|
|
5
|
+
---
|
|
6
|
+
# Class: CompositionModule
|
|
7
|
+
|
|
8
|
+
Defined in: composition/module/CompositionModule.ts:53
|
|
9
|
+
|
|
10
|
+
Minimal module providing configuration access for composition.
|
|
11
|
+
|
|
12
|
+
This module is used by [createCompositionContext](Function.createCompositionContext) to create a
|
|
13
|
+
lightweight NestJS application context for module composition decisions.
|
|
14
|
+
|
|
15
|
+
## Remarks
|
|
16
|
+
|
|
17
|
+
The composition module intentionally does **not** import heavy infrastructure
|
|
18
|
+
such as database, queues, cron, or external API clients. It only provides
|
|
19
|
+
configuration access.
|
|
20
|
+
|
|
21
|
+
To add custom composition services (e.g., a custom [CompositionResolver](Class.CompositionResolver)),
|
|
22
|
+
create a custom module extending this pattern and pass it to
|
|
23
|
+
[createCompositionContext](Function.createCompositionContext).
|
|
24
|
+
|
|
25
|
+
## Example
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
// Custom composition module with application-specific resolver
|
|
29
|
+
@Module({
|
|
30
|
+
imports: [
|
|
31
|
+
ConfigModule.forRoot({
|
|
32
|
+
strategyFactory: () => new EnvironmentConfigStrategy()
|
|
33
|
+
})
|
|
34
|
+
],
|
|
35
|
+
providers: [AppCompositionResolver],
|
|
36
|
+
exports: [ConfigModule, AppCompositionResolver]
|
|
37
|
+
})
|
|
38
|
+
export class AppCompositionModule {}
|
|
39
|
+
|
|
40
|
+
// Usage
|
|
41
|
+
const context = await createCompositionContext({
|
|
42
|
+
module: AppCompositionModule
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Constructors
|
|
47
|
+
|
|
48
|
+
### Constructor
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
new CompositionModule(): CompositionModule;
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
#### Returns
|
|
55
|
+
|
|
56
|
+
`CompositionModule`
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Abstract Class: CompositionResolver'
|
|
3
|
+
generated: true
|
|
4
|
+
editUrl: false
|
|
5
|
+
---
|
|
6
|
+
# Abstract Class: CompositionResolver
|
|
7
|
+
|
|
8
|
+
Defined in: composition/services/CompositionResolver.ts:46
|
|
9
|
+
|
|
10
|
+
Abstract base class for composition-time feature resolution.
|
|
11
|
+
|
|
12
|
+
Applications extend this class to define their own composition logic,
|
|
13
|
+
determining which modules and providers should be imported based on
|
|
14
|
+
configuration, stage, or other criteria.
|
|
15
|
+
|
|
16
|
+
## Remarks
|
|
17
|
+
|
|
18
|
+
The resolver is instantiated within a lightweight composition context
|
|
19
|
+
before the main application module graph is built. It should only
|
|
20
|
+
depend on configuration and other composition-safe services.
|
|
21
|
+
|
|
22
|
+
Do not inject heavy infrastructure services (database, queues, etc.)
|
|
23
|
+
into the resolver as they are not available during composition.
|
|
24
|
+
|
|
25
|
+
## Example
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
@Injectable()
|
|
29
|
+
export class AppCompositionResolver extends CompositionResolver {
|
|
30
|
+
public constructor(configService: ConfigService) {
|
|
31
|
+
super(configService);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public shouldImportSmtpMail(): boolean {
|
|
35
|
+
const driver = this.tryGetConfigValue(MAIL_DRIVER, 'log');
|
|
36
|
+
return driver === 'smtp' || this.isProductionLike();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public isProductionLike(): boolean {
|
|
40
|
+
const stage = this.tryGetConfigValue(NODE_ENV, 'development');
|
|
41
|
+
return stage === 'production' || stage === 'staging';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Constructors
|
|
47
|
+
|
|
48
|
+
### Constructor
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
protected new CompositionResolver(configService): CompositionResolver;
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Defined in: composition/services/CompositionResolver.ts:62
|
|
55
|
+
|
|
56
|
+
Constructs a new composition resolver.
|
|
57
|
+
|
|
58
|
+
#### Parameters
|
|
59
|
+
|
|
60
|
+
| Parameter | Type | Description |
|
|
61
|
+
| ------ | ------ | ------ |
|
|
62
|
+
| `configService` | `ConfigService` | The configuration service for reading environment values. |
|
|
63
|
+
|
|
64
|
+
#### Returns
|
|
65
|
+
|
|
66
|
+
`CompositionResolver`
|
|
67
|
+
|
|
68
|
+
## Accessors
|
|
69
|
+
|
|
70
|
+
### configService
|
|
71
|
+
|
|
72
|
+
#### Get Signature
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
get protected configService(): ConfigService;
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Defined in: composition/services/CompositionResolver.ts:75
|
|
79
|
+
|
|
80
|
+
The underlying configuration service.
|
|
81
|
+
|
|
82
|
+
##### Returns
|
|
83
|
+
|
|
84
|
+
`ConfigService`
|
|
85
|
+
|
|
86
|
+
## Methods
|
|
87
|
+
|
|
88
|
+
### compareConfigValue()
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
protected compareConfigValue<T>(key, value): boolean;
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Defined in: composition/services/CompositionResolver.ts:133
|
|
95
|
+
|
|
96
|
+
Compares a configuration value against an expected value.
|
|
97
|
+
|
|
98
|
+
#### Type Parameters
|
|
99
|
+
|
|
100
|
+
| Type Parameter | Description |
|
|
101
|
+
| ------ | ------ |
|
|
102
|
+
| `T` | The expected type of the configuration value. |
|
|
103
|
+
|
|
104
|
+
#### Parameters
|
|
105
|
+
|
|
106
|
+
| Parameter | Type | Description |
|
|
107
|
+
| ------ | ------ | ------ |
|
|
108
|
+
| `key` | `IConfigKey`\<`T`\> | The typed configuration key. |
|
|
109
|
+
| `value` | `T` | The value to compare against. |
|
|
110
|
+
|
|
111
|
+
#### Returns
|
|
112
|
+
|
|
113
|
+
`boolean`
|
|
114
|
+
|
|
115
|
+
`true` if the configuration value matches; otherwise, `false`.
|
|
116
|
+
|
|
117
|
+
***
|
|
118
|
+
|
|
119
|
+
### getConfigValue()
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
protected getConfigValue<T>(key): T;
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Defined in: composition/services/CompositionResolver.ts:105
|
|
126
|
+
|
|
127
|
+
Gets a required configuration value.
|
|
128
|
+
|
|
129
|
+
#### Type Parameters
|
|
130
|
+
|
|
131
|
+
| Type Parameter | Description |
|
|
132
|
+
| ------ | ------ |
|
|
133
|
+
| `T` | The expected type of the configuration value. |
|
|
134
|
+
|
|
135
|
+
#### Parameters
|
|
136
|
+
|
|
137
|
+
| Parameter | Type | Description |
|
|
138
|
+
| ------ | ------ | ------ |
|
|
139
|
+
| `key` | `IConfigKey`\<`T`\> | The typed configuration key. |
|
|
140
|
+
|
|
141
|
+
#### Returns
|
|
142
|
+
|
|
143
|
+
`T`
|
|
144
|
+
|
|
145
|
+
The typed configuration value.
|
|
146
|
+
|
|
147
|
+
#### Throws
|
|
148
|
+
|
|
149
|
+
When the configuration key is not found.
|
|
150
|
+
|
|
151
|
+
***
|
|
152
|
+
|
|
153
|
+
### shouldImportProvider()
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
abstract shouldImportProvider(providerKey): boolean;
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Defined in: composition/services/CompositionResolver.ts:93
|
|
160
|
+
|
|
161
|
+
Determines whether a specific provider should be imported.
|
|
162
|
+
|
|
163
|
+
Override this method to implement custom provider resolution logic.
|
|
164
|
+
|
|
165
|
+
#### Parameters
|
|
166
|
+
|
|
167
|
+
| Parameter | Type | Description |
|
|
168
|
+
| ------ | ------ | ------ |
|
|
169
|
+
| `providerKey` | `string` | A unique key identifying the provider (e.g., `'mail'`, `'blob-storage'`). |
|
|
170
|
+
|
|
171
|
+
#### Returns
|
|
172
|
+
|
|
173
|
+
`boolean`
|
|
174
|
+
|
|
175
|
+
`true` if the provider should be imported; otherwise, `false`.
|
|
176
|
+
|
|
177
|
+
***
|
|
178
|
+
|
|
179
|
+
### tryGetConfigValue()
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
protected tryGetConfigValue<T>(key, fallback): T;
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Defined in: composition/services/CompositionResolver.ts:119
|
|
186
|
+
|
|
187
|
+
Gets an optional configuration value with a fallback.
|
|
188
|
+
|
|
189
|
+
#### Type Parameters
|
|
190
|
+
|
|
191
|
+
| Type Parameter | Description |
|
|
192
|
+
| ------ | ------ |
|
|
193
|
+
| `T` | The expected type of the configuration value. |
|
|
194
|
+
|
|
195
|
+
#### Parameters
|
|
196
|
+
|
|
197
|
+
| Parameter | Type | Description |
|
|
198
|
+
| ------ | ------ | ------ |
|
|
199
|
+
| `key` | `IConfigKey`\<`T`\> | The typed configuration key. |
|
|
200
|
+
| `fallback` | `T` | The fallback value when the key is absent. |
|
|
201
|
+
|
|
202
|
+
#### Returns
|
|
203
|
+
|
|
204
|
+
`T`
|
|
205
|
+
|
|
206
|
+
The typed configuration value or the fallback.
|