@breadstone/archipel-mcp 0.0.45 → 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/ai-text-generation.md +2 -2
- package/data/guides/authentication-and-authorization.md +2 -2
- package/data/guides/blob-storage.md +3 -3
- package/data/guides/caching.md +2 -2
- package/data/guides/composition-context.md +462 -0
- package/data/guides/database-setup.md +4 -4
- package/data/guides/email-delivery.md +6 -6
- package/data/guides/index.md +1 -0
- package/data/guides/openapi-and-feature-discovery.md +1 -1
- package/data/guides/queue-infrastructure.md +4 -4
- package/data/guides/telemetry-and-observability.md +1 -1
- 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-cryptography/api/Class.OtpService.md +6 -6
- package/data/packages/platform-cryptography/api/Variable.TOTP_EPOCH_TOLERANCE.md +1 -1
- package/data/packages/platform-feature-flags/index.md +103 -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
|
@@ -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.
|
|
@@ -5,7 +5,7 @@ editUrl: false
|
|
|
5
5
|
---
|
|
6
6
|
# Class: PlatformApplicationBuilder\<TApplication\>
|
|
7
7
|
|
|
8
|
-
Defined in: [application/PlatformApplicationBuilder.ts:
|
|
8
|
+
Defined in: [application/PlatformApplicationBuilder.ts:99](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/application/PlatformApplicationBuilder.ts#L99)
|
|
9
9
|
|
|
10
10
|
Fluent builder that composes NestJS bootstrap steps and executes them once.
|
|
11
11
|
|
|
@@ -23,7 +23,7 @@ Fluent builder that composes NestJS bootstrap steps and executes them once.
|
|
|
23
23
|
new PlatformApplicationBuilder<TApplication>(app, options?): PlatformApplicationBuilder<TApplication>;
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
Defined in: [application/PlatformApplicationBuilder.ts:
|
|
26
|
+
Defined in: [application/PlatformApplicationBuilder.ts:111](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/application/PlatformApplicationBuilder.ts#L111)
|
|
27
27
|
|
|
28
28
|
#### Parameters
|
|
29
29
|
|
|
@@ -46,7 +46,7 @@ Defined in: [application/PlatformApplicationBuilder.ts:28](https://github.com/Ru
|
|
|
46
46
|
get app(): TApplication;
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
Defined in: [application/PlatformApplicationBuilder.ts:
|
|
49
|
+
Defined in: [application/PlatformApplicationBuilder.ts:205](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/application/PlatformApplicationBuilder.ts#L205)
|
|
50
50
|
|
|
51
51
|
The wrapped NestJS application.
|
|
52
52
|
|
|
@@ -56,13 +56,80 @@ The wrapped NestJS application.
|
|
|
56
56
|
|
|
57
57
|
## Methods
|
|
58
58
|
|
|
59
|
+
### createWithComposition()
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
static createWithComposition<TApp>(composer, options?): Promise<PlatformApplicationBuilder<TApp>>;
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Defined in: [application/PlatformApplicationBuilder.ts:163](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/application/PlatformApplicationBuilder.ts#L163)
|
|
66
|
+
|
|
67
|
+
Creates a new application builder using composition-based module assembly.
|
|
68
|
+
|
|
69
|
+
This factory bootstraps a lightweight composition context to read configuration
|
|
70
|
+
values, then invokes the provided composer function to determine which modules
|
|
71
|
+
to import. The resulting modules are assembled into a dynamic root module
|
|
72
|
+
and a NestJS application is created from it.
|
|
73
|
+
|
|
74
|
+
The composition context is automatically closed after the composer function completes.
|
|
75
|
+
|
|
76
|
+
#### Type Parameters
|
|
77
|
+
|
|
78
|
+
| Type Parameter | Default type | Description |
|
|
79
|
+
| ------ | ------ | ------ |
|
|
80
|
+
| `TApp` *extends* `INestApplication`\<`any`\> | `INestApplication`\<`any`\> | The NestJS application type. Defaults to INestApplication. |
|
|
81
|
+
|
|
82
|
+
#### Parameters
|
|
83
|
+
|
|
84
|
+
| Parameter | Type | Description |
|
|
85
|
+
| ------ | ------ | ------ |
|
|
86
|
+
| `composer` | (`context`) => \| [`CompositionImport`](TypeAlias.CompositionImport)[] \| `Promise`\<[`CompositionImport`](TypeAlias.CompositionImport)[]\> | A function that receives the composition context and returns an array of modules to import. |
|
|
87
|
+
| `options?` | [`ICreateWithCompositionOptions`](Interface.ICreateWithCompositionOptions)\<`TApp`\> | Options for creating the composed application. |
|
|
88
|
+
|
|
89
|
+
#### Returns
|
|
90
|
+
|
|
91
|
+
`Promise`\<`PlatformApplicationBuilder`\<`TApp`\>\>
|
|
92
|
+
|
|
93
|
+
A promise that resolves to a configured PlatformApplicationBuilder.
|
|
94
|
+
|
|
95
|
+
#### Example
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
import { PlatformApplicationBuilder } from '@breadstone/archipel-platform-bootstrap';
|
|
99
|
+
import { ExpressAdapter, NestExpressApplication } from '@nestjs/platform-express';
|
|
100
|
+
|
|
101
|
+
const builder = await PlatformApplicationBuilder.createWithComposition<NestExpressApplication>(
|
|
102
|
+
async (context) => {
|
|
103
|
+
const imports: CompositionImport[] = [AppModule];
|
|
104
|
+
|
|
105
|
+
const driver = context.tryGetConfigValue({ key: 'MAIL_DRIVER' }, 'log');
|
|
106
|
+
if (driver === 'smtp') {
|
|
107
|
+
const { MailModule } = await import('@breadstone/archipel-platform-mailing');
|
|
108
|
+
const { SmtpDeliveryStrategy } = await import('@breadstone/archipel-platform-mailing/delivering/smtp');
|
|
109
|
+
imports.push(MailModule.register({ deliveryStrategy: SmtpDeliveryStrategy }));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return imports;
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
appFactory: (module) => NestFactory.create<NestExpressApplication>(module, new ExpressAdapter()),
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
await builder
|
|
120
|
+
.use(useApi({ prefix: 'api' }))
|
|
121
|
+
.listenFromConfig({ fallbackPort: 3000 });
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
***
|
|
125
|
+
|
|
59
126
|
### initialize()
|
|
60
127
|
|
|
61
128
|
```ts
|
|
62
129
|
initialize(): Promise<TApplication>;
|
|
63
130
|
```
|
|
64
131
|
|
|
65
|
-
Defined in: [application/PlatformApplicationBuilder.ts:
|
|
132
|
+
Defined in: [application/PlatformApplicationBuilder.ts:231](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/application/PlatformApplicationBuilder.ts#L231)
|
|
66
133
|
|
|
67
134
|
Executes the configured bootstrap pipeline and initializes the NestJS application.
|
|
68
135
|
|
|
@@ -80,7 +147,7 @@ The wrapped NestJS application.
|
|
|
80
147
|
listen(port, hostname?): Promise<TApplication>;
|
|
81
148
|
```
|
|
82
149
|
|
|
83
|
-
Defined in: [application/PlatformApplicationBuilder.ts:
|
|
150
|
+
Defined in: [application/PlatformApplicationBuilder.ts:255](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/application/PlatformApplicationBuilder.ts#L255)
|
|
84
151
|
|
|
85
152
|
Executes the pipeline and starts the NestJS listener on the given port.
|
|
86
153
|
|
|
@@ -105,7 +172,7 @@ The wrapped NestJS application.
|
|
|
105
172
|
listenFromConfig(options?): Promise<TApplication>;
|
|
106
173
|
```
|
|
107
174
|
|
|
108
|
-
Defined in: [application/PlatformApplicationBuilder.ts:
|
|
175
|
+
Defined in: [application/PlatformApplicationBuilder.ts:274](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/application/PlatformApplicationBuilder.ts#L274)
|
|
109
176
|
|
|
110
177
|
Executes the pipeline and starts the listener using typed configuration keys.
|
|
111
178
|
|
|
@@ -129,7 +196,7 @@ The wrapped NestJS application.
|
|
|
129
196
|
run(): Promise<PlatformBootstrapContext<TApplication>>;
|
|
130
197
|
```
|
|
131
198
|
|
|
132
|
-
Defined in: [application/PlatformApplicationBuilder.ts:
|
|
199
|
+
Defined in: [application/PlatformApplicationBuilder.ts:243](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/application/PlatformApplicationBuilder.ts#L243)
|
|
133
200
|
|
|
134
201
|
Executes the configured bootstrap pipeline without starting a listener.
|
|
135
202
|
|
|
@@ -147,7 +214,7 @@ The bootstrap context used for the execution.
|
|
|
147
214
|
use(step): this;
|
|
148
215
|
```
|
|
149
216
|
|
|
150
|
-
Defined in: [application/PlatformApplicationBuilder.ts:
|
|
217
|
+
Defined in: [application/PlatformApplicationBuilder.ts:220](https://github.com/RueDeRennes/archipel/blob/main/libs/platform-bootstrap/src/application/PlatformApplicationBuilder.ts#L220)
|
|
151
218
|
|
|
152
219
|
Adds a bootstrap step to the application pipeline.
|
|
153
220
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Function: createCompositionContext()'
|
|
3
|
+
generated: true
|
|
4
|
+
editUrl: false
|
|
5
|
+
---
|
|
6
|
+
# Function: createCompositionContext()
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
function createCompositionContext(options?): Promise<ICompositionContext>;
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Defined in: composition/factory/createCompositionContext.ts:88
|
|
13
|
+
|
|
14
|
+
Creates a temporary NestJS context for stage-aware module composition.
|
|
15
|
+
|
|
16
|
+
This function bootstraps a minimal NestJS application context that provides
|
|
17
|
+
access to configuration. Use this context to make decisions about which
|
|
18
|
+
modules should be dynamically imported into the real application.
|
|
19
|
+
|
|
20
|
+
## Parameters
|
|
21
|
+
|
|
22
|
+
| Parameter | Type | Description |
|
|
23
|
+
| ------ | ------ | ------ |
|
|
24
|
+
| `options?` | [`ICreateCompositionContextOptions`](Interface.ICreateCompositionContextOptions) | Optional configuration for the composition context. |
|
|
25
|
+
|
|
26
|
+
## Returns
|
|
27
|
+
|
|
28
|
+
`Promise`\<[`ICompositionContext`](Interface.ICompositionContext)\>
|
|
29
|
+
|
|
30
|
+
A promise that resolves to the composition context.
|
|
31
|
+
|
|
32
|
+
## Remarks
|
|
33
|
+
|
|
34
|
+
The composition context must be closed after the real application has been
|
|
35
|
+
created by calling [ICompositionContext.close](Interface.ICompositionContext#close). Use a try/finally block
|
|
36
|
+
to ensure proper cleanup.
|
|
37
|
+
|
|
38
|
+
## Example
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
async function bootstrap(): Promise<void> {
|
|
42
|
+
const composition = await createCompositionContext();
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
const appModule = await createAppModule(composition);
|
|
46
|
+
const app = await NestFactory.create(appModule);
|
|
47
|
+
|
|
48
|
+
await PlatformApplicationBuilder
|
|
49
|
+
.from(app)
|
|
50
|
+
.use(useApi({ ... }))
|
|
51
|
+
.listenFromConfig();
|
|
52
|
+
} finally {
|
|
53
|
+
await composition.close();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Interface: ICompositionContext'
|
|
3
|
+
generated: true
|
|
4
|
+
editUrl: false
|
|
5
|
+
---
|
|
6
|
+
# Interface: ICompositionContext
|
|
7
|
+
|
|
8
|
+
Defined in: composition/context/ICompositionContext.ts:35
|
|
9
|
+
|
|
10
|
+
Pre-bootstrap context for stage-aware module composition.
|
|
11
|
+
|
|
12
|
+
This context is created before the main application module graph is built.
|
|
13
|
+
It provides access to configuration and lightweight composition services
|
|
14
|
+
that help determine which modules should be dynamically imported.
|
|
15
|
+
|
|
16
|
+
## Remarks
|
|
17
|
+
|
|
18
|
+
The composition context uses a temporary NestJS application context internally.
|
|
19
|
+
This context must be closed after the real application has been created by
|
|
20
|
+
calling [ICompositionContext.close](#close).
|
|
21
|
+
|
|
22
|
+
## Example
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
const composition = await createCompositionContext();
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
const appModule = await createAppModule(composition);
|
|
29
|
+
const app = await NestFactory.create(appModule);
|
|
30
|
+
await app.listen(3000);
|
|
31
|
+
} finally {
|
|
32
|
+
await composition.close();
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Properties
|
|
37
|
+
|
|
38
|
+
### config
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
readonly config: ConfigService;
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Defined in: composition/context/ICompositionContext.ts:53
|
|
45
|
+
|
|
46
|
+
The Archipel configuration service.
|
|
47
|
+
|
|
48
|
+
Provides typed access to environment configuration values.
|
|
49
|
+
|
|
50
|
+
***
|
|
51
|
+
|
|
52
|
+
### context
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
readonly context: INestApplicationContext;
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Defined in: composition/context/ICompositionContext.ts:44
|
|
59
|
+
|
|
60
|
+
The temporary NestJS application context.
|
|
61
|
+
|
|
62
|
+
Used only for dependency injection resolution during composition.
|
|
63
|
+
Do not use this context for runtime services.
|
|
64
|
+
|
|
65
|
+
## Methods
|
|
66
|
+
|
|
67
|
+
### close()
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
close(): Promise<void>;
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Defined in: composition/context/ICompositionContext.ts:100
|
|
74
|
+
|
|
75
|
+
Closes the temporary composition context.
|
|
76
|
+
|
|
77
|
+
Must be called after the real application has been created to release
|
|
78
|
+
resources held by the composition context.
|
|
79
|
+
|
|
80
|
+
#### Returns
|
|
81
|
+
|
|
82
|
+
`Promise`\<`void`\>
|
|
83
|
+
|
|
84
|
+
A promise that resolves when the context is closed.
|
|
85
|
+
|
|
86
|
+
***
|
|
87
|
+
|
|
88
|
+
### getConfigValue()
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
getConfigValue<T>(key): T;
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Defined in: composition/context/ICompositionContext.ts:65
|
|
95
|
+
|
|
96
|
+
Reads a required configuration 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
|
+
|
|
110
|
+
#### Returns
|
|
111
|
+
|
|
112
|
+
`T`
|
|
113
|
+
|
|
114
|
+
The typed configuration value.
|
|
115
|
+
|
|
116
|
+
#### Throws
|
|
117
|
+
|
|
118
|
+
When the configuration key is not found.
|
|
119
|
+
|
|
120
|
+
***
|
|
121
|
+
|
|
122
|
+
### getService()
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
getService<T>(token): T;
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Defined in: composition/context/ICompositionContext.ts:88
|
|
129
|
+
|
|
130
|
+
Resolves a provider from the composition context.
|
|
131
|
+
|
|
132
|
+
#### Type Parameters
|
|
133
|
+
|
|
134
|
+
| Type Parameter | Description |
|
|
135
|
+
| ------ | ------ |
|
|
136
|
+
| `T` | The type of the provider. |
|
|
137
|
+
|
|
138
|
+
#### Parameters
|
|
139
|
+
|
|
140
|
+
| Parameter | Type | Description |
|
|
141
|
+
| ------ | ------ | ------ |
|
|
142
|
+
| `token` | (...`args`) => `T` | The provider token (class, string, or symbol). |
|
|
143
|
+
|
|
144
|
+
#### Returns
|
|
145
|
+
|
|
146
|
+
`T`
|
|
147
|
+
|
|
148
|
+
The resolved provider instance.
|
|
149
|
+
|
|
150
|
+
***
|
|
151
|
+
|
|
152
|
+
### tryGetConfigValue()
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
tryGetConfigValue<T>(key, fallback): T;
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Defined in: composition/context/ICompositionContext.ts:77
|
|
159
|
+
|
|
160
|
+
Reads an optional configuration value with a fallback.
|
|
161
|
+
|
|
162
|
+
#### Type Parameters
|
|
163
|
+
|
|
164
|
+
| Type Parameter | Description |
|
|
165
|
+
| ------ | ------ |
|
|
166
|
+
| `T` | The expected type of the configuration value. |
|
|
167
|
+
|
|
168
|
+
#### Parameters
|
|
169
|
+
|
|
170
|
+
| Parameter | Type | Description |
|
|
171
|
+
| ------ | ------ | ------ |
|
|
172
|
+
| `key` | `IConfigKey`\<`T`\> | The typed configuration key. |
|
|
173
|
+
| `fallback` | `T` | The fallback value when the key is absent. |
|
|
174
|
+
|
|
175
|
+
#### Returns
|
|
176
|
+
|
|
177
|
+
`T`
|
|
178
|
+
|
|
179
|
+
The typed configuration value or the fallback.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Interface: ICreateCompositionContextOptions'
|
|
3
|
+
generated: true
|
|
4
|
+
editUrl: false
|
|
5
|
+
---
|
|
6
|
+
# Interface: ICreateCompositionContextOptions
|
|
7
|
+
|
|
8
|
+
Defined in: composition/factory/createCompositionContext.ts:17
|
|
9
|
+
|
|
10
|
+
Options for creating the composition context.
|
|
11
|
+
|
|
12
|
+
## Properties
|
|
13
|
+
|
|
14
|
+
### enableLogging?
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
readonly optional enableLogging?: boolean;
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Defined in: composition/factory/createCompositionContext.ts:49
|
|
21
|
+
|
|
22
|
+
Whether to enable logging for the composition context.
|
|
23
|
+
|
|
24
|
+
Defaults to `false` to keep composition silent.
|
|
25
|
+
|
|
26
|
+
***
|
|
27
|
+
|
|
28
|
+
### module?
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
readonly optional module?: Type<unknown>;
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Defined in: composition/factory/createCompositionContext.ts:40
|
|
35
|
+
|
|
36
|
+
Custom composition module to use instead of the default [CompositionModule](Class.CompositionModule).
|
|
37
|
+
|
|
38
|
+
Use this to provide application-specific composition services such as
|
|
39
|
+
custom [CompositionResolver](Class.CompositionResolver) implementations.
|
|
40
|
+
|
|
41
|
+
#### Example
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
@Module({
|
|
45
|
+
imports: [ConfigModule.forRoot({ strategyFactory: () => new EnvironmentConfigStrategy() })],
|
|
46
|
+
providers: [AppCompositionResolver],
|
|
47
|
+
exports: [ConfigModule, AppCompositionResolver]
|
|
48
|
+
})
|
|
49
|
+
export class AppCompositionModule {}
|
|
50
|
+
|
|
51
|
+
const context = await createCompositionContext({
|
|
52
|
+
module: AppCompositionModule
|
|
53
|
+
});
|
|
54
|
+
```
|