From 05120e88c22d15c65a47929b3c501e9bf7c9237b Mon Sep 17 00:00:00 2001 From: Peter Perlepes Date: Wed, 24 Jul 2024 09:24:13 +0300 Subject: [PATCH] Update for Snowtype 0.8.0 (#964) --- .../code-generation/commands/index.md | 6 ++- .../code-generation/snowtype-config/index.md | 48 +++++++++++++++++++ .../code-generation/using-the-cli/index.md | 5 +- 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/docs/collecting-data/code-generation/commands/index.md b/docs/collecting-data/code-generation/commands/index.md index 01610c5172..1a9a300464 100644 --- a/docs/collecting-data/code-generation/commands/index.md +++ b/docs/collecting-data/code-generation/commands/index.md @@ -28,8 +28,10 @@ Initialize the setup of Snowtype code generation in a project. Creates the confi Generates tracking code based on configuration on the configuration file. Can generate/modify the `.snowtype-lock.json` file. **Options** - - `-is, --instructions` Generate event specification instructions. - - `-va, --validations` Add runtime validation on events. _Currently available for the Browser tracker_. + - `--instructions` Generate event specification instructions. + - `--no-instructions` Generate without instructions. + - `--validations` Add runtime validation on events. _Currently available for the Browser tracker_. + - `--no-validations` Do not add runtime validation on events. - `--disallowDevSchemas` Disallow generation of code using schemas deployed on DEV environment. _Sending events using schemas deployed on DEV, will result in failed events in production pipelines._ (default: false) ### `snowtype update` diff --git a/docs/collecting-data/code-generation/snowtype-config/index.md b/docs/collecting-data/code-generation/snowtype-config/index.md index f9f3e5d615..3f1e6160ea 100644 --- a/docs/collecting-data/code-generation/snowtype-config/index.md +++ b/docs/collecting-data/code-generation/snowtype-config/index.md @@ -44,6 +44,38 @@ The target language to generate the required code for. [See list of available la The outpath relative to the current working directory when running the script. +### `options` + +Options related to Snowtype behavior and are described by the following TypeScript type: + +```ts +options?: { + /* Command related options. */ + commands: { + generate?: { + /* Generate implementation instructions. */ + instructions?: boolean; + /* Add runtime validations. */ + validations?: boolean; + /* Disallow generation of code using schemas only deployed on DEV environment. */ + disallowDevSchemas?: boolean; + } + update?: { + /* Update your configuration file automatically and regenerate the code of the latest available update. */ + regenerateOnUpdate?: boolean + /* The maximum SchemaVer update to show an available update notification for. */ + maximumBump?: "major" | "minor" | "patch" + } + patch?: { + /* Automatically regenerate the code after a successful patch operation. */ + regenerateOnPatch?: boolean + } + } +} +``` + +_Keep in mind that CLI flags take precedence over configuration file options._ + ## Example configuration file @@ -110,6 +142,22 @@ type SnowtypeConfig = { dataStructures?: string[]; eventSpecificationIds?: string[]; dataProductIds?: string[]; + options?: { + commands: { + generate?: { + instructions?: boolean; + validations?: boolean; + disallowDevSchemas?: boolean; + } + update?: { + regenerateOnUpdate?: boolean + maximumBump?: "major" | "minor" | "patch" + } + patch?: { + regenerateOnPatch?: boolean + } + } + } }; const config: SnowtypeConfig = { diff --git a/docs/collecting-data/code-generation/using-the-cli/index.md b/docs/collecting-data/code-generation/using-the-cli/index.md index 7e17a4ffad..76b3feb84d 100644 --- a/docs/collecting-data/code-generation/using-the-cli/index.md +++ b/docs/collecting-data/code-generation/using-the-cli/index.md @@ -330,6 +330,7 @@ By using the `--instructions` option on the `snowtype generate` command, you can This includes: - Trigger description. +- Implementation rules. - Images uploaded on your Event Specification triggers. - App identifiers and URLs this event should be triggered on. - Direct links to the code for this Event Specification. @@ -366,7 +367,7 @@ An example showcasing the flag's behavior: This Data Structure has other deployed versions such as `1-0-1`, `1-1-0` and `2-0-0`. The `update` command will show available updates as follows: -```sh +```bash npx @snowplow/snowtype update --maximumBump=major # Will prompt an update to 2-0-0 or any other available update. @@ -382,4 +383,4 @@ npx @snowplow/snowtype update --maximumBump=patch While developing or testing, it might be useful to use [Snowplow Mini](../../../pipeline-components-and-applications/snowplow-mini/) to validate against your new schemas in your development environment. In this and any other case you are developing a schema and eventually publishing the tracking to production, you need to make sure all the schemas you are using are deployed to the production environment for the pipeline to use. Failing to do that will result in failed events. -Snowtype by default will print a warning when code is generated using schemas only published to development environment. To make sure that there are no schemas not yet deployed to production, you can use the `--disallowDevSchemas` flag when using the `generate` command. Using this flag will make sure each generation attempt will fail, indicating the schemas that are not yet deployed to the production environment. \ No newline at end of file +Snowtype by default will print a warning when code is generated using schemas only published to development environment. To make sure that there are no schemas not yet deployed to production, you can use the `--disallowDevSchemas` flag or option when using the `generate` command. Using this flag will make sure each generation attempt will fail, indicating the schemas that are not yet deployed to the production environment. \ No newline at end of file