Skip to content

Commit bdb845b

Browse files
docs: updated switching integrations chapter
1 parent 8ac0de9 commit bdb845b

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

apps/docs/docs/guides/integrations/switching-integrations.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,25 @@ sidebar_position: 100
44

55
# Switching integrations
66

7-
An integral feature of O2S are the integrations, therefore a mechanism for replacing one integration with another also had to be in place.
7+
An integral feature of O2S are the integrations, therefore, a mechanism for replacing one integration with another also had to be in place.
88

9-
Switching between integrations is a process that is not done often - it usually happens during the initial project configuration - but still our aim was for it to be relatively easy. It happens entirely within the API Harmonization server - so inside the `api-harmonization` application.
9+
Switching between integrations is a process that is not done often - it usually happens during the initial project configuration - but still our aim was for it to be relatively easy. It happens entirely within the configuration, inside the `@o2s/configs.integrations` package that is shared across other apps.
1010

1111
:::note
1212
Thanks to the normalized data model, replacing an integration is completely transparent to the frontend application.
1313
:::
1414

1515
## Integration config
1616

17-
Inside the `apps/api-harmonization/models` there are a number of files that represent all the framework modules of the `@o2s/framework` package. Inside each of them are local exports that define which integration is used for that module.
17+
Inside the `packages/configs/integrations/src/models` there are a number of files that represent all the framework modules of the `@o2s/framework` package. Inside each of them are local exports that define which integration is used for that module.
1818

19-
For example the `apps/api-harmonization/models/cms.ts` file that is pre-configured with a [mocked integration](../../integrations/mocked/mocked.md) looks like this:
19+
For example, the `packages/configs/integrations/src/models/cms.ts` file that is pre-configured with a [mocked integration](../../integrations/mocked/mocked.md) looks like this:
2020

2121
```typescript title="integration config for the cms module"
22-
import { ApiConfig } from '@o2s/framework/modules';
2322
import { Config, Integration } from '@o2s/integrations.mocked/integration';
2423

24+
import { ApiConfig } from '@o2s/framework/modules';
25+
2526
export const CmsIntegrationConfig: ApiConfig['integrations']['cms'] = Config.cms!;
2627

2728
export import Service = Integration.CMS.Service;
@@ -34,32 +35,32 @@ These files export four things:
3435
1. Integration config, that is then propagated to the framework modules to let them know what implementation to actually use. This is done via the `apps/api-harmonization/app.config.ts` file that does not have to be modified at all when switching integrations.
3536
2. A service, that is used in other blocks and modules:
3637

37-
```typescript title="usage of CMS.Service within ticket-list.service.ts"
38-
import { CMS, Tickets } from '../../models';
38+
```typescript title="usage of services within page.service.ts"
39+
import { Articles, Auth, CMS } from '@o2s/configs.integrations';
3940

4041
@Injectable()
4142
export class TicketListService {
4243
constructor (
4344
private readonly cmsService: CMS.Service,
44-
private readonly ticketService: Tickets.Service,
45+
private readonly articlesService: Articles.Service,
46+
private readonly authService: Auth.Service,
4547
) {}
4648

4749
...
4850
}
4951
```
5052

51-
3. Requests and Models that can be used e.g. in a mapper to provide correct typings:
53+
3. Requests and Models that can be used, e.g. in a mapper to provide correct typings:
5254

53-
```typescript title="using models from CMS.Model in the ticket-list.mapper.ts"
54-
import { CMS, Tickets } from '../../models';
55+
```typescript title="using models in the page.mapper.ts"
56+
import { Articles, CMS } from '@o2s/configs.integrations';
5557
56-
export const mapTicketList = (
57-
tickets: Tickets.Model.Tickets,
58-
cms: CMS.Model.TicketListBlock.TicketListBlock,
59-
locale: string,
60-
): TicketListBlock => {
61-
...
62-
};
58+
export const mapPage = (page: CMS.Model.Page.Page): Page => {...};
59+
60+
export const mapArticle = (
61+
article: Articles.Model.Article,
62+
category: Articles.Model.Category,
63+
): Page => {...};
6364
```
6465

6566
## Replacing an integration package
@@ -69,10 +70,10 @@ In order to switch an integration for a given framework module (like a CMS) all
6970
1. Install a new integration as a dependency of the `api-harmonization` app:
7071

7172
```shell
72-
npm install @o2s/integrations.strapi-cms --workspace=@o2s/api
73+
npm install @o2s/integrations.strapi-cms --workspace=@o2s/configs.integrations
7374
```
7475

75-
2. Replace the previous import with the newly installed package:
76+
2. Replace the previous import with the newly installed package in ``packages/configs/integrations/src/models/cms.ts` (or any other module):
7677
7778
```typescript
7879
import { Config, Integration } from '@o2s/integrations.mocked/integration';
@@ -84,7 +85,7 @@ In order to switch an integration for a given framework module (like a CMS) all
8485
import { Config, Integration } from '@o2s/integrations.strapi-cms/integration';
8586
```
8687

87-
Once that is done, the `api-harmonization` application will start using the new integration.
88+
Once that is done, the application will start using the new integration.
8889

8990
:::note
9091
Replacing an integration **does not** require any restarts, and can be done during runtime, e.g. in the middle the development process.

0 commit comments

Comments
 (0)