Skip to content

Commit

Permalink
fixup udpate readme
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanKiral committed Sep 27, 2024
1 parent f26165d commit 844aa45
Showing 1 changed file with 7 additions and 28 deletions.
35 changes: 7 additions & 28 deletions src/commands/syncModel/run/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
> - Deletion of content by deleting elements from a content type
> - Deletion of used taxonomies
The `sync-model run` command synchronizes the **source content model** into the **target environment** via [Kontent.ai Management API](https://kontent.ai/learn/docs/apis/openapi/management-api-v2/). The source content can be obtained from an existing Kontent.ai environment (considering you have access to the required credentials) or a folder structure in a required format (see [sync-model export](../export/README.md) command for more information).
The `sync-model run` command synchronizes the **source content model** into the **target environment** via [Kontent.ai Management API](https://kontent.ai/learn/docs/apis/openapi/management-api-v2/). The source content can be obtained from an existing Kontent.ai environment (considering you have access to the required credentials) or a folder structure in a required format (see [sync-model export](../export/README.md) command for more information). Using the CLI command, you can filter data by entity type with the `--entities` parameter. Additionally, you can specify an array of codenames to be synced using the `--codenames` parameter, which will apply the codename filter across all synced entities. For more advanced filtering, you can use the `filter` parameter through [programmatic sync](#sync-model-programmatically), where you can define custom filter predicate functions for each entity. These functions are optional, and if not provided, the entity won't be synced by default.

> [!CAUTION]
> Partial sync requires that all dependent entities are either already present in the environment or included in the sync process. Otherwise, the partial sync may fail, leaving your environment in an incomplete state.
In the context of this command, the content model is represented by the following entities: `Taxonomies`, `Content Types`, `Content Type Snippets`, `Web Spotlight`, and `Asset Folders`. The command begins by comparing the provided content models and generates patch operations, which are then printed as the **environment diff**.

Expand All @@ -27,13 +30,13 @@ To successfully synchronize the content model, we introduced a couple of conditi

## Usage
```bash
npx @kontent-ai/data-ops@latest sync-model run --targetEnvironmentId=<target-environment-id> --targetApiKey=<target-management-API-key> --sourceEnvironmentId=<source-environment-id>
npx @kontent-ai/data-ops@latest sync-model run --targetEnvironmentId=<target-environment-id> --targetApiKey=<target-management-API-key> --sourceEnvironmentId=<source-environment-id> --entities contentTypes contentTypeSnippets taxonomies
--sourceApiKey=<source-api-key>
```
OR

```bash
npx @kontent-ai/data-ops@latest sync-model run --targetEnvironmentId=<target-environment-id> --targetApiKey=<target-management-API-key> --folderName=<path-to-content-folder>
npx @kontent-ai/data-ops@latest sync-model run --targetEnvironmentId=<target-environment-id> --targetApiKey=<target-management-API-key> --folderName=<path-to-content-folder> --entities contentTypes contentTypeSnippets taxonomies
```

> [!NOTE]
Expand All @@ -56,36 +59,12 @@ To sync model in environments in your scripts, use `syncModelRun` function:
```ts
import { syncModelRun, SyncModelRunParams } from "@kontent-ai/data-ops";
const params: SyncModelRunParams = {
sourceEnvironmentId: "<source-env-id>",
sourceApiKey: "<source-mapi-key>",
targetEnvironmentId: "<target-env-id>",
targetApiKey: "<target-mapi-key>"
};
await syncModelRun(params);
```
### Partial Sync

The tool allows you to control which data from your environment gets synced. Using the CLI command, you can filter data by entity type with the `--include` or `--exclude` parameters. Additionally, you can specify an array of codenames to be synced using the `--codenames` parameter, which will apply the codename filter across all synced entities. For more advanced filtering, you can use the `filter` parameter through [programmatic sync](#sync-model-programmatically), where you can define custom filter predicate functions for each entity. These functions are optional, and if not provided, the entity will be synced by default.

> [!CAUTION]
> Partial sync requires that all dependent entities are either already present in the environment or included in the sync process. Otherwise, the partial sync may fail, leaving your environment in an incomplete state.
```bash
npx @kontent-ai/data-ops@latest sync-model run --targetEnvironmentId=<target-environment-id> --targetApiKey=<target-management-API-key> --folderName=<path-to-content-folder> --include contentTypes contentTypeSnippets taxonomies --codenames codename1 codename2
```

```ts
import { syncModelRun, SyncModelRunParams } from "@kontent-ai/data-ops";

const params: SyncModelRunParams = {
sourceEnvironmentId: "<source-env-id>",
sourceApiKey: "<source-mapi-key>",
targetEnvironmentId: "<target-env-id>",
targetApiKey: "<target-mapi-key>",
filter: {
entities: {
contentTypes: () => true, // will sync
taxonomies: () => false, // won't sync
languages: (lang) => lang.codename === "default" // will sync only codename with default codename
Expand Down

0 comments on commit 844aa45

Please sign in to comment.