Skip to content

Commit

Permalink
feat(content-api): introduce separate proxy-api package (#203)
Browse files Browse the repository at this point in the history
* feat(content-api):  introduce separate proxy-api package to reduce size of client side bundles
  • Loading branch information
spirit-wiegmann authored Apr 9, 2024
1 parent 2aa46d5 commit a70c41c
Show file tree
Hide file tree
Showing 14 changed files with 888 additions and 52 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ validate.js
examples/index.ts
*.tgz
.editorconfig
.npmrc
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# [10.21.0](https://github.com/e-Spirit/fsxa-api/compare/v10.20.0...v10.21.0) (2024-03-13)


### Features

* **shrink proxy:** bundles in fsxa-api are large which causes performance problems ([ffc5658](https://github.com/e-Spirit/fsxa-api/commit/ffc56582473921f8fa4cb334d64b54ffa8d8642c))
* **shrink proxy:** bundles in fsxa-api are large which causes performance problems ([2aaf2b2](https://github.com/e-Spirit/fsxa-api/commit/2aaf2b216b5c0045cdb167f8c661221cf41333d9))
* **shrink proxy:** bundles in fsxa-api are large which causes performance problems ([c8727a3](https://github.com/e-Spirit/fsxa-api/commit/c8727a3eacb433a9ec53721c6398d0d0dd1b02d6))
* **shrink proxy:** bundles in fsxa-api are large which causes performance problems ([f0ad6ff](https://github.com/e-Spirit/fsxa-api/commit/f0ad6ff99a238a451deadf4ab4ad6b1c605f7d8a))
* **shrink proxy:** bundles in fsxa-api are large which causes performance problems ([646c74f](https://github.com/e-Spirit/fsxa-api/commit/646c74f9b10c483f082944157348d44ae5a69639))
* **shrink proxy:** bundles in fsxa-api are large which causes performance problems ([e63157a](https://github.com/e-Spirit/fsxa-api/commit/e63157a8cca5e218b9e2d3222f86867da271e488))
* **shrink proxy:** bundles in fsxa-api are large which causes performance problems ([dc54689](https://github.com/e-Spirit/fsxa-api/commit/dc546898235665109a683922606047fae4243cf1))

# [10.20.0](https://github.com/e-Spirit/fsxa-api/compare/v10.19.1...v10.20.0) (2024-03-04)


Expand Down
54 changes: 27 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# JavaScript Content API Library

The JavaScript Content API Library a.k.a Content API is an interface handling data coming from the FirstSpirit
The JavaScript Content API Library a.k.a. Content API is an interface handling data coming from the FirstSpirit
[CaaS](https://docs.e-spirit.com/module/caas/CaaS_Product_Documentation_EN.html) and the
Navigation Service. The data is processed and transformed so that it can be used in any JavaScript project.

Expand Down Expand Up @@ -88,7 +88,7 @@ You can also include remote projects if you want to use remote media.
> **_Attention_**<br>
> Currently the Content API can only work with the master language of the remote media project.
> You also require a configured CAAS API key with read permissions to both projects.
>
> For this you can add another parameter called `remotes` to the config. This parameter expects an object, which requires a unique name as key and an object as value. This object must have two keys. On the one hand an `id` with the project id as the value and on the other the `locale` with the locale abbreviation. For example:
```typescript
Expand All @@ -115,10 +115,10 @@ import express from 'express'
import cors from 'cors'
import {
FSXAContentMode,
FSXAProxyApi,
LogLevel,
FSXARemoteApi,
} from 'fsxa-api'
import { FSXAProxyApi } from 'fsxa-proxy-api'
import getExpressRouter from 'fsxa-api/dist/lib/integrations/express'
import 'cross-fetch/polyfill'

Expand Down Expand Up @@ -198,7 +198,7 @@ fsxaApi.fetchElement({

Returns the matching CaaS data entries.
It maps the given entries to a more frontend-friendly format.
Unneccessary fields will be omitted and the structure is simpler.
Unnecessary fields will be omitted and the structure is simpler.

Expects as input parameter an array of filters and a language abbreviation.
Optionally a page number, page size, sort and additional parameters can be passed.
Expand Down Expand Up @@ -236,7 +236,7 @@ fsxaApi.fetchByFilter({
})
```

The default sorting is by the id descending. Multisort is possible and the first sort param is prioritized over subsequent. The sorting is happening on the raw data.
The default sorting is by the id descending. MultiSort is possible and the first sort param is prioritized over subsequent. The sorting is happening on the raw data.

> **_Attention_**<br>
> The keys names which are passed to the `fetchByFilter` method (e.g. in the filters or the additionalParams) have to match the key names that are present in the CaaS data.
Expand Down Expand Up @@ -369,7 +369,7 @@ By following these steps, you've successfully extended the API to fetch data fro
These operators can also be found in the [MongoDB Documentation](https://docs.mongodb.com/manual/reference/operator/query-logical/)

| Enum | Operation |
| ---------------------------- | --------- |
|------------------------------|-----------|
| LogicalQueryOperatorEnum.AND | \$and |
| LogicalQueryOperatorEnum.NOT | \$not |
| LogicalQueryOperatorEnum.NOR | \$nor |
Expand All @@ -380,7 +380,7 @@ These operators can also be found in the [MongoDB Documentation](https://docs.mo
These operators can also be found in the [MongoDB Documentation](https://docs.mongodb.com/manual/reference/operator/query-comparison/)

| Enum | Operation |
| ----------------------------------------------- | --------- |
|-------------------------------------------------|-----------|
| ComparisonQueryOperatorEnum.GREATER_THAN_EQUALS | \$gte |
| ComparisonQueryOperatorEnum.GREATER_THAN | \$gt |
| ComparisonQueryOperatorEnum.EQUALS | \$eq |
Expand All @@ -395,15 +395,15 @@ These operators can also be found in the [MongoDB Documentation](https://docs.mo
These operators can also be found in the [MongoDB Documentation](https://docs.mongodb.com/manual/reference/operator/query-evaluation/)

| Enum | Operation |
| --------------------------------- | --------- |
|-----------------------------------|-----------|
| EvaluationQueryOperatorEnum.REGEX | \$regex |

### Array Query Operators

These operators can also be found in the [MongoDB Documentation](https://docs.mongodb.com/manual/reference/operator/query-array/)

| Enum | Operation |
| -------------------------- | --------- |
|----------------------------|-----------|
| ArrayQueryOperatorEnum.ALL | \$all |

## Type Mapping
Expand All @@ -414,25 +414,25 @@ This table gives an overview of the FirstSpirit input components, which can be d
Each input component has a (Java) data type, which has a representation in the CaaS. Those values are [mapped](src/modules/CaaSMapper.ts) to an [interface](src/types.ts) of the Content API.

| <nobr>FirstSpirit Input Component</nobr> | <nobr>CaaS Representation</nobr> | <nobr>Content API [Value](src/types.ts)</nobr> |
| ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- |
| [FS_CATALOG]<br />[`Catalog`][fs-catalog]`<`[`Catalog$Card`][fs-card]`>` | <nobr>= `CaaSApi_FSCatalog`</nobr><br />= `CaaSApi_Card[]` | `Section[]` |
| [CMS_INPUT_CHECKBOX]<br />[`Set`][fs-set]`<`[`Option`][fs-option]`>` | <nobr>= `CaaSApi_CMSInputCheckbox`</nobr><br />= `CaaSApi_Option[]` | `Option[]` |
| [CMS_INPUT_COMBOBOX]<br />[`Option`][fs-option] | <nobr>= `CaaSApi_CMSInputCombobox`</nobr><br />= `CaaSApi_Option`&#124;`null` | `Option` |
| [FS_DATASET]<br />[`DatasetContainer`][fs-datasetcontainer] | <nobr>= `CaaSApi_FSDataset`</nobr><br />= `CaaSApi_Dataset`&#124;`CaaSApi_DataEntry[]`&#124;`null` | `Dataset` |
| [CMS_INPUT_DATE]<br />[`Date`][fs-date] | <nobr>= `CaaSApi_CMSInputDate`</nobr><br />= `string(ISO_8601)`&#124;`null` | [`Date`][js-date] |
| [CMS_INPUT_DOM]<br>[`DomElement`][fs-domelement] | <nobr>= `CaaSApi_CMSInputDOM`</nobr><br />= `string` (FS-XML) | `RichTextElement[]` |
| [CMS_INPUT_DOMTABLE]<br>[`Table`][fs-table] | <nobr>= `CaaSApi_CMSInputDOMTable`</nobr><br />= `string` (FS-XML) | `RichTextElement[]` |
| [CMS_INPUT_IMAGEMAP]<br>[`MappingMedium`][fs-mappingmedium] | <nobr>= `CaaSApi_CMSImageMap`</nobr><br />= `CaaSApi_CMSImageMap` | `ImageMap` |
| [FS_INDEX]<br />[`Index`][fs-index]`<`[`Index$Record`][fs-record]`>` | <nobr>= `CaaSApi_FSIndex`</nobr><br />= `CaaSApi_Record[]` | `DataEntries[]` |
| [CMS_INPUT_LINK]<br />[`Link`][fs-link] | <nobr>= `CaaSApi_CMSInputLink`</nobr><br />= `Object` | `Link` |
| [CMS_INPUT_LIST]<br />[`Set`][fs-set]`<`[`Option`][fs-option]`>` | <nobr>= `CaaSApi_CMSInputList`</nobr><br />= `any[]` | `Option[]` |
| [CMS_INPUT_NUMBER]<br />[`Number`][fs-number] | <nobr>= `CaaSApi_CMSInputNumber`</nobr><br />= `number` | [`number`](js-number) |
| [CMS_INPUT_PERMISSION]<br />[`Permissions`][fs-permissions] | <nobr>= `CaaSApi_CMSInputPermission`</nobr><br />= `CaaSAPI_PermissionActivity[][]` | `Permission` |
| [CMS_INPUT_RADIOBUTTON]<br />[`Option`][fs-option] | <nobr>= `CaaSApi_CMSInputRadioButton`</nobr><br />= `CaaSApi_Option`&#124;`null` | `Option` |
|--------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------|
| [FS_CATALOG]<br />[`Catalog`][fs-catalog]`<`[`Catalog$Card`][fs-card]`>` | <nobr>= `CaaSApi_FSCatalog`</nobr><br />= `CaaSApi_Card[]` | `Section[]` |
| [CMS_INPUT_CHECKBOX]<br />[`Set`][fs-set]`<`[`Option`][fs-option]`>` | <nobr>= `CaaSApi_CMSInputCheckbox`</nobr><br />= `CaaSApi_Option[]` | `Option[]` |
| [CMS_INPUT_COMBOBOX]<br />[`Option`][fs-option] | <nobr>= `CaaSApi_CMSInputCombobox`</nobr><br />= `CaaSApi_Option`&#124;`null` | `Option` |
| [FS_DATASET]<br />[`DatasetContainer`][fs-datasetcontainer] | <nobr>= `CaaSApi_FSDataset`</nobr><br />= `CaaSApi_Dataset`&#124;`CaaSApi_DataEntry[]`&#124;`null` | `Dataset` |
| [CMS_INPUT_DATE]<br />[`Date`][fs-date] | <nobr>= `CaaSApi_CMSInputDate`</nobr><br />= `string(ISO_8601)`&#124;`null` | [`Date`][js-date] |
| [CMS_INPUT_DOM]<br>[`DomElement`][fs-domelement] | <nobr>= `CaaSApi_CMSInputDOM`</nobr><br />= `string` (FS-XML) | `RichTextElement[]` |
| [CMS_INPUT_DOMTABLE]<br>[`Table`][fs-table] | <nobr>= `CaaSApi_CMSInputDOMTable`</nobr><br />= `string` (FS-XML) | `RichTextElement[]` |
| [CMS_INPUT_IMAGEMAP]<br>[`MappingMedium`][fs-mappingmedium] | <nobr>= `CaaSApi_CMSImageMap`</nobr><br />= `CaaSApi_CMSImageMap` | `ImageMap` |
| [FS_INDEX]<br />[`Index`][fs-index]`<`[`Index$Record`][fs-record]`>` | <nobr>= `CaaSApi_FSIndex`</nobr><br />= `CaaSApi_Record[]` | `DataEntries[]` |
| [CMS_INPUT_LINK]<br />[`Link`][fs-link] | <nobr>= `CaaSApi_CMSInputLink`</nobr><br />= `Object` | `Link` |
| [CMS_INPUT_LIST]<br />[`Set`][fs-set]`<`[`Option`][fs-option]`>` | <nobr>= `CaaSApi_CMSInputList`</nobr><br />= `any[]` | `Option[]` |
| [CMS_INPUT_NUMBER]<br />[`Number`][fs-number] | <nobr>= `CaaSApi_CMSInputNumber`</nobr><br />= `number` | [`number`](js-number) |
| [CMS_INPUT_PERMISSION]<br />[`Permissions`][fs-permissions] | <nobr>= `CaaSApi_CMSInputPermission`</nobr><br />= `CaaSAPI_PermissionActivity[][]` | `Permission` |
| [CMS_INPUT_RADIOBUTTON]<br />[`Option`][fs-option] | <nobr>= `CaaSApi_CMSInputRadioButton`</nobr><br />= `CaaSApi_Option`&#124;`null` | `Option` |
| [FS_REFERENCE]<br />[`TargetReference`][fs-targetreference] | <nobr>= `CaaSApi_FSReference`</nobr><br />= `CaaSApi_BaseRef`&#124;`CaaSApi_PageRefRef`&#124;`CaaSApi_GCARef`&#124;`CaaSApi_MediaRef`&#124;`null` |
| [CMS_INPUT_TEXT]<br />[`String`][fs-string] | <nobr>= `CaaSApi_CMSInputText`</nobr><br />= `string` | [`string`][js-string] |
| [CMS_INPUT_TEXTAREA]<br />[`String`][fs-string] | <nobr>= `CaaSApi_CMSInputTextArea`</nobr><br />= `string` | [`string`][js-string] |
| [CMS_INPUT_TOGGLE]<br />[`Boolean`][fs-boolean] | <nobr>= `CaaSApi_CMSInputToggle`</nobr><br />= `boolean`&#124;`null` | [`boolean`][js-boolean] |
| [CMS_INPUT_TEXT]<br />[`String`][fs-string] | <nobr>= `CaaSApi_CMSInputText`</nobr><br />= `string` | [`string`][js-string] |
| [CMS_INPUT_TEXTAREA]<br />[`String`][fs-string] | <nobr>= `CaaSApi_CMSInputTextArea`</nobr><br />= `string` | [`string`][js-string] |
| [CMS_INPUT_TOGGLE]<br />[`Boolean`][fs-boolean] | <nobr>= `CaaSApi_CMSInputToggle`</nobr><br />= `boolean`&#124;`null` | [`boolean`][js-boolean] |

[fs_catalog]: https://docs.e-spirit.com/odfs/template-develo/forms/input-component/catalog/index.html
[fs-catalog]: https://docs.e-spirit.com/odfs/template-develo/template-syntax/data-types/catalog/index.html
Expand Down
4 changes: 2 additions & 2 deletions dev/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { createFile } from './utils'
import dotenv from 'dotenv'
import express from 'express'
import cors from 'cors'
import { FSXAContentMode, FSXAProxyApi, LogLevel, NavigationItem } from '../src'
import { FSXAContentMode, FSXARemoteApi } from '../src'
import { default as expressIntegration } from '../src/integrations/express'
import { FSXARemoteApi } from '../src/modules/FSXARemoteApi'
import { FSXAProxyApi, LogLevel } from 'fsxa-proxy-api'
require('cross-fetch/polyfill')

dotenv.config({ path: './dev/.env' })
Expand Down
1 change: 1 addition & 0 deletions integrationtests/.env.template
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
INTEGRATION_TEST_API_KEY=xxxxxxxx-xxxx-xxxx-xxxxxxxx
INTEGRATION_TEST_CAAS=https://your-caas-api.e-spirit.cloud
INTEGRATION_TEST_NAVIGATION_SERVICE=https://your-navigation-service.e-spirit.cloud
Loading

0 comments on commit a70c41c

Please sign in to comment.