Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .changeset/silver-tips-serve.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@

# Requires Node.js v18 or later

This releases migrates packages to require Node.js v18 or later. Ideally you should be already using Node.js v20 or later. According to [Node.js Releases](https://nodejs.org/en/about/previous-releases) Node.js v18 will be in maintenance and reach End of Life by the end of April.
This releases migrates packages to require Node.js v18 or later. Ideally you should be already using Node.js v20 or later. According to [Node.js Releases](https://nodejs.org/en/about/previous-releases) Node.js v18 will be in maintenance and reach End of Life by the end of April.

Other than requiring Node.js v18 packages with this releases do not contain any internal breaking changes.
Other than requiring Node.js v18 packages with this releases do not contain any internal breaking changes.
38 changes: 38 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: ci
on:
workflow_dispatch:

permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# Get GitHub token via the CT Changesets App
- name: Generate GitHub token (via CT Changesets App)
id: generate_github_token
uses: tibdex/github-app-token@v2.1.0
with:
app_id: ${{ secrets.CT_CHANGESETS_APP_ID }}
private_key: ${{ secrets.CT_CHANGESETS_APP_PEM }}

- name: Checkout
uses: actions/checkout@v4
with:
# Pass a personal access token (using our CT Changesets App) to be able to trigger other workflows
# https://help.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token
# https://github.community/t/action-does-not-trigger-another-on-push-tag-action/17148/8
token: ${{ steps.generate_github_token.outputs.token }}

- uses: actions/setup-python@v5
with:
python-version: 3.x
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- run: pip install mkdocs-material
- run: mkdocs gh-deploy -d temp
33 changes: 0 additions & 33 deletions book.json

This file was deleted.

46 changes: 0 additions & 46 deletions docs/SUMMARY.md

This file was deleted.

36 changes: 18 additions & 18 deletions docs/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ Our CLI tools perform various functions from importing and exporting to syncing

### modules

- [Category Exporter](/cli/category-exporter.md)
- [CSV Discount Code Parser](/cli/csv-parser-discount-code.md)
- [CSV Price Parser](/cli/csv-parser-price.md)
- [CSV Order Parser](/cli/csv-parser-orders.md)
- [CSV State Parser](/cli/csv-parser-state.md)
- [Custom Objects Exporter](/cli/custom-objects-exporter.md)
- [Custom Objects Importer](/cli/custom-objects-importer.md)
- [Customer Groups Exporter](/cli/customer-groups-exporter.md)
- [Personal Data Erasure](/cli/personal-data-erasure.md)
- [Discount Code Generator](/cli/discount-code-generator.md)
- [Discount Code Exporter](/cli/discount-code-exporter.md)
- [Discount Code Importer](/cli/discount-code-importer.md)
- [Inventories Exporter](/cli/inventories-exporter.md)
- [Price Exporter](/cli/price-exporter.md)
- [Product Exporter](/cli/product-exporter.md)
- [Product JSON to CSV](/cli/product-json-to-csv.md)
- [Resource Deleter](/cli/resource-deleter.md)
- [State importer](/cli/state-importer.md)
- [Category Exporter](/cli/category-exporter)
- [CSV Discount Code Parser](/cli/csv-parser-discount-code)
- [CSV Price Parser](/cli/csv-parser-price)
- [CSV Order Parser](/cli/csv-parser-orders)
- [CSV State Parser](/cli/csv-parser-state)
- [Custom Objects Exporter](/cli/custom-objects-exporter)
- [Custom Objects Importer](/cli/custom-objects-importer)
- [Customer Groups Exporter](/cli/customer-groups-exporter)
- [Personal Data Erasure](/cli/personal-data-erasure)
- [Discount Code Generator](/cli/discount-code-generator)
- [Discount Code Exporter](/cli/discount-code-exporter)
- [Discount Code Importer](/cli/discount-code-importer)
- [Inventories Exporter](/cli/inventories-exporter)
- [Price Exporter](/cli/price-exporter)
- [Product Exporter](/cli/product-exporter)
- [Product JSON to CSV](/cli/product-json-to-csv)
- [Resource Deleter](/cli/resource-deleter)
- [State importer](/cli/state-importer)
File renamed without changes.
6 changes: 3 additions & 3 deletions docs/sdk/Glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type ClientRequest = {
}
```

A _ClientRequest_ is an object describing the request that needs to be executed by the `sdk-client`. This is also the signature of the **request** object passed to a [middleware](/sdk/Middlewares.md).
A _ClientRequest_ is an object describing the request that needs to be executed by the `sdk-client`. This is also the signature of the **request** object passed to a [middleware](/sdk/Middlewares).

## ClientResponse

Expand All @@ -27,7 +27,7 @@ type ClientResponse = {
}
```

A _ClientResponse_ is an object describing the **response** object passed to a [middleware](/sdk/Middlewares.md).
A _ClientResponse_ is an object describing the **response** object passed to a [middleware](/sdk/Middlewares).

## Middleware

Expand All @@ -50,7 +50,7 @@ type Middleware = (next: Dispatch) => Dispatch

A _Middleware_ is a higher-order function that composes a _dispatch function_ to return a new _dispatch function_.

Middleware is composable using function composition. It is used for authentication, making http requests, logging requests, etc. See section about [middlewares](/sdk/Middlewares.md) for more information.
Middleware is composable using function composition. It is used for authentication, making http requests, logging requests, etc. See section about [middlewares](/sdk/Middlewares) for more information.

## Client

Expand Down
6 changes: 3 additions & 3 deletions docs/sdk/Middlewares.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ If you've used libraries like [Express](http://expressjs.com/) and [Koa](http://
The SDK middlewares work similarly to those concepts. Given an initial `request` and `response` definition, each middleware can do "side effects" and "transform" those objects, passing them to the next middleware in the chain. **This provides a third-party extension point for handling HTTP requests.**
For example, there are middlewares for doing authentication, for logging, for actually making the HTTP request, for retrying failed requests, etc.

The most important thing is the **contract** the middlewares have between each other: the [`request`](/sdk/Glossary.md#clientrequest) and [`response`](/sdk/Glossary.md#clientresponse) objects passed to each middleware have a _well predefined shape_, known to each middleware. This is important to ensure that middlewares can do side effects on those objects.
The most important thing is the **contract** the middlewares have between each other: the [`request`](/sdk/Glossary#clientrequest) and [`response`](/sdk/Glossary#clientresponse) objects passed to each middleware have a _well predefined shape_, known to each middleware. This is important to ensure that middlewares can do side effects on those objects.

## Middlewares API

Expand All @@ -15,7 +15,7 @@ A _Middleware_ is a higher-order function that composes a _dispatch function_ to
const middleware = (next) => (request, response) => next(request, response)
```

The dispatch function accepts 2 arguments: [`request`](/sdk/Glossary.md#clientrequest) and [`response`](/sdk/Glossary.md#clientresponse) objects.
The dispatch function accepts 2 arguments: [`request`](/sdk/Glossary#clientrequest) and [`response`](/sdk/Glossary#clientresponse) objects.
After doing the side effects, the middleware should call `next`, passing the (mutated) `request` and `response` to the next middleware.

## Implement a logging middleware
Expand All @@ -31,4 +31,4 @@ const loggerMiddleware = (next) => (request, response) => {
}
```

See [official middlewares](/sdk/api/README.md#middlewares) for more advanced examples.
See [official middlewares](/sdk/api/README#middlewares) for more advanced examples.
10 changes: 5 additions & 5 deletions docs/sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

This section contains all information about the sdk-related packages.

> If you are looking to migrate from the `sphere-node-sdk` package, please read the [migration guide](/sdk/upgrading-from-sphere-node-sdk.md).
> If you are looking to migrate from the `sphere-node-sdk` package, please read the [migration guide](/sdk/upgrading-from-sphere-node-sdk).

## Design architecture

The SDK is now split into multiple little packages, think about it as a _microservice_ architecture. This is by choice and it provides several different advantages:

- flexibility: choose the packages that fits best your use case
- extensibility: developers can potentially build their own packages to extend / replace pieces of the SDK packages (e.g. custom [middlewares](/sdk/Middlewares.md))
- extensibility: developers can potentially build their own packages to extend / replace pieces of the SDK packages (e.g. custom [middlewares](/sdk/Middlewares))
- maintainability: easier to maintain each single little package instead of one big library. This is also one of the reasons to use a [monorepo](https://github.com/lerna/lerna)

The core of the SDK lies within its [middlewares](/sdk/Middlewares.md) implementation.
The core of the SDK lies within its [middlewares](/sdk/Middlewares) implementation.
Middlewares do specific things and can be replaced by other middlewares depending on the use case, allowing many possible combinations.

The [SDK _client_](/sdk/api/README.md#sdk-client) itself is in fact really simple and somehow even agnostic of the specific commercetools platform API that can be used as a generic HTTP client.
The [SDK _client_](/sdk/api/README#sdk-client) itself is in fact really simple and somehow even agnostic of the specific commercetools platform API that can be used as a generic HTTP client.

If we take a step back and look at the general requirement, at the end we simply want to **execute a request**. It just happens to be that we want to make specific requests to the commercetools platform API but it might be as well any other API. That's where the [middlewares](/sdk/Middlewares.md) come in, which provide the _side effects_ of the given request.
If we take a step back and look at the general requirement, at the end we simply want to **execute a request**. It just happens to be that we want to make specific requests to the commercetools platform API but it might be as well any other API. That's where the [middlewares](/sdk/Middlewares) come in, which provide the _side effects_ of the given request.

## Usage example

Expand Down
Loading