Metadata-Version: 2.5
Name: gooddata-code-convertors
Version: 11.54.0a3
Summary: GoodData AAC YAML / Declarative API code converters (WASM-powered)
Project-URL: Repository, https://github.com/gooddata/gooddata-ui-sdk
Project-URL: Source, https://github.com/gooddata/gooddata-ui-sdk/tree/master/libs/sdk-code-convertors/python
License: Copyright (c) 2020-2026 GoodData Corporation
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Requires-Dist: pydantic<3.0.0,>=2.11.0
Requires-Dist: typing-extensions>=4.0.0
Requires-Dist: wasmtime<31.0.0,>=25.0.0
Description-Content-Type: text/markdown

# gooddata-code-convertors

GoodData AAC YAML / Declarative API code converters, powered by WebAssembly.

Provides bidirectional conversion between AAC YAML format (used by the
[gdc-analytics-as-code](https://marketplace.visualstudio.com/items?itemName=GoodData.gooddata-code) VSCode plugin)
and GoodData Declarative API format.

## Installation

```bash
pip install gooddata-code-convertors
```

## Usage

YAML-to-Declarative functions accept **parsed YAML dicts** (e.g. from `yaml.safe_load`),
not raw YAML strings.

```python
import yaml
from gooddata_code_convertors import yaml_metric_to_declarative, declarative_metric_to_yaml

# AAC YAML -> Declarative API
with open("metrics/revenue.yaml") as f:
    parsed = yaml.safe_load(f)
declarative = yaml_metric_to_declarative(parsed)

# Declarative API -> AAC YAML
yaml_result = declarative_metric_to_yaml(declarative)
```

## Types: static (`_types`) vs. runtime-validating (`pydantic_models`)

Two parallel sets of Python types are generated from the same AAC JSON Schema:

- **`gooddata_code_convertors._types`** — `TypedDict`s, re-exported at the package top level
  (`from gooddata_code_convertors import Dashboard`). Static typing only, zero runtime cost,
  zero validation.
- **`gooddata_code_convertors.pydantic_models`** — real Pydantic v2 `BaseModel`s (not
  re-exported at the top level, to avoid name collisions with `_types` — import from the
  submodule directly: `from gooddata_code_convertors.pydantic_models import Dashboard`). Use
  these when you need actual runtime validation of a payload, e.g.
  `Dashboard.model_validate(payload)`.

**Gotcha:** shared string-pattern fields (e.g. every entity's `id`) are wrapped in their own
`RootModel[str]` class in `pydantic_models` rather than being plain `str` — access the value
via `.root` (e.g. `dashboard.id.root`). This is a deliberate trade-off: collapsing them into
plain `str` fields breaks import entirely, because pydantic-core's Rust regex engine can't
compile this schema's negative-lookahead patterns once collapsed. `_types`' `TypedDict`s are
unaffected (`Dashboard["id"]` is a plain `str` there, since `TypedDict` has no runtime pattern validation
to trip over).

## Available Converters

### YAML -> Declarative API

- `yaml_dataset_to_declarative`
- `yaml_date_dataset_to_declarative`
- `yaml_metric_to_declarative`
- `yaml_visualisation_to_declarative`
- `yaml_dashboard_to_declarative`
- `yaml_plugin_to_declarative`
- `yaml_attribute_hierarchy_to_declarative`

### Declarative API -> YAML

- `declarative_dataset_to_yaml`
- `declarative_date_instance_to_yaml`
- `declarative_metric_to_yaml`
- `declarative_visualisation_to_yaml`
- `declarative_dashboard_to_yaml`
- `declarative_plugin_to_yaml`
- `declarative_attribute_hierarchy_to_yaml`

### Utilities

- `build_afm_execution`
