> For the complete documentation index, see [llms.txt](https://navixy.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://navixy.com/docs/analytics/id/iot-query/schema-overview/transformation-layer/transformation-builder/workflow-yaml-reference.md). Agents can also search and read this documentation through its [MCP server](https://navixy.com/docs/~gitbook/mcp).

# Referensi YAML alur kerja

Format YAML alur kerja menangkap graf node, parameter, dan tepi Transformation Builder untuk ekspor, impor, dan berbagi antarlingkungan

Halaman ini mendokumentasikan format YAML yang digunakan Transformation Builder untuk menyimpan dan memuat konfigurasi alur kerja. YAML adalah representasi internal Builder untuk desain alur kerja: format ini merekam grafik node, parameter, dan edge agar alur kerja dapat diekspor, disimpan, dibagikan, atau diimpor kembali ke Builder.

Saat Anda menjadwalkan alur kerja, Builder mengompilasi grafik node menjadi satu kueri SQL dan mendaftarkannya sebagai fungsi database terjadwal. Kueri SQL tersebut dan tugas pg\_cron-nya yang dijalankan di database Anda. YAML tidak digunakan saat runtime. Jika Anda ingin membuat atau menjalankan transformasi secara terpisah dari Builder, tulis dan jadwalkan SQL secara langsung di database tanpa menggunakan format ini.

Format ini memiliki dua versi. **Versi 2** adalah format terkini yang dihasilkan Transformation Builder saat ekspor. Format ini menyusun node sebagai array datar dalam urutan topologis (`cte_nodes`) dengan array `edges` terpisah untuk koneksi. **Versi 1** adalah format lama yang menggunakan kunci `nodes` dengan referensi `depends_on` sebaris untuk koneksi. Transformation Builder dapat mengimpor kedua versi, tetapi selalu mengekspor versi 2.

{% columns %}
{% column %}

#### **Ekspor**

Menghasilkan file YAML dalam format versi 2. Anda dapat memulai ekspor dari tombol **Ekspor** di bilah alat Transformation Builder, atau melalui API. File yang diekspor dapat disimpan di repositori, dibagikan dengan kolega, atau diimpor kembali ke Transformation Builder di lingkungan lain.
{% endcolumn %}

{% column %}

#### **Impor**

Menerima versi 2 (format terkini) dan versi 1 (format lama dengan koneksi berbasis `depends_on`). Gunakan fungsi **Impor** di Builder, lalu pilih file `.yaml` atau `.yml` .
{% endcolumn %}
{% endcolumns %}

## Cara ekspor dibuat

Generator ekspor membuat file YAML melalui empat langkah:

1. **Pengurutan topologis node.** Grafik node dan edge diurutkan sehingga node sumber berada di awal, diikuti node transformasi sesuai urutan dependensi, dan terakhir node Output. Jika grafik berisi siklus, urutan pengganti digunakan (berdasarkan posisi dalam daftar node).
2. **Daftar sumber untuk setiap node.** Untuk setiap node, generator mengumpulkan daftar ID node pendahulu yang berurutan dari edge dengan nilai `target` sama dengan ID node saat ini. Misalnya, node SQL Transform dengan dua masukan akan memiliki daftar `sources` yang berisi tepat dua ID dalam urutan yang benar.
3. **Array cte\_nodes.** Setiap node ditulis sebagai rekaman dalam array `cte_nodes` dengan urutan topologis. Lihat [struktur cte\_nodes](#cte_nodes-structure) di bawah untuk detail kolom.
4. **Penyusunan YAML tingkat teratas.** Generator menggabungkan array `cte_nodes` dengan daftar edge, metadata alur kerja, dan kolom opsional (viewport, schedule) menjadi dokumen akhir.

### Kunci tingkat teratas

Akar file YAML versi 2 berisi kunci berikut:

| Kunci            | Kehadiran                    | Deskripsi                                                                                                  |
| ---------------- | ---------------------------- | ---------------------------------------------------------------------------------------------------------- |
| `version`        | Selalu                       | Nomor versi format. Selalu `2` untuk ekspor saat ini.                                                      |
| `name`           | Selalu                       | Nama alur kerja.                                                                                           |
| `description`    | Selalu                       | Deskripsi alur kerja. Dapat berupa string kosong.                                                          |
| `cte_nodes`      | Selalu                       | Array catatan simpul dalam urutan topologis. Lihat [struktur cte\_nodes](#cte_nodes-structure).            |
| `edges`          | Selalu                       | Array objek edge. Lihat [struktur edges](#edges-structure).                                                |
| `output_node_id` | Jika terdapat simpul Output  | ID simpul Output dalam alur kerja.                                                                         |
| `viewport`       | Jika diatur dalam alur kerja | Posisi kanvas dan tingkat zoom: `{ x, y, zoom }`. Digunakan untuk memulihkan tata letak visual saat impor. |
| `schedule`       | Jika jadwal diaktifkan       | Jadwal eksekusi: `{ cron, timezone }`. Cron default adalah `0 0 * * *`, zona waktu default adalah `UTC`.   |

### Struktur cte\_nodes

Setiap entri dalam array `cte_nodes` merepresentasikan satu simpul dalam graf alur kerja.

| Kolom             | Deskripsi                                                                                                                                                                                                                                                                                   |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`              | Pengidentifikasi simpul unik (string).                                                                                                                                                                                                                                                      |
| `type`            | Jenis simpul. Salah satu dari: `telematics`, `business`, `filter`, `resample`, `sql`, `arithmetic`, `custom`, `output`.                                                                                                                                                                     |
| `label`           | Nama tampilan yang ditampilkan di kanvas. Jika tidak diatur, akan menggunakan ID simpul.                                                                                                                                                                                                    |
| `description`     | Deskripsi simpul. Dapat berupa string kosong.                                                                                                                                                                                                                                               |
| `position`        | Koordinat kanvas sebagai `{ x, y }`.                                                                                                                                                                                                                                                        |
| `sources`         | Daftar terurut ID simpul pendahulu, yang berasal dari sisi graf. Kosong untuk simpul sumber.                                                                                                                                                                                                |
| `params`          | Parameter konfigurasi simpul. Kolom spesifik bergantung pada jenis simpul. Lihat dokumentasi [Transformation Builder](https://navixy.com/docs/analytics/id/iot-query/schema-overview/transformation-layer/transformation-builder.md) untuk mengetahui detail parameter setiap jenis simpul. |
| `width`, `height` | Opsional. Dimensi kanvas untuk simpul, hanya disertakan jika ditetapkan secara eksplisit.                                                                                                                                                                                                   |

**Pembersihan parameter.** Kolom `available_tables` dan `available_columns` dihapus dari `params` saat ekspor. Kolom ini diisi saat runtime ketika Builder terhubung ke basis data dan tidak boleh disimpan dalam YAML.

**Jenis SQL dengan beberapa sumber.** Jika simpul dengan jenis `sql` memiliki dua sumber atau lebih, ekspor menambahkan kolom `join_spec` ke rekaman. Ini adalah larik dengan satu elemen yang berisi konfigurasi join:

```yaml
join_spec:
  - type: "left"       # jenis join (huruf kecil): left, inner, right, full
    on_condition: "a_node_telematics_1.device_id = a_node_business_1.device_id"
```

Nilai `type` diambil dari parameter simpul `join_type` (dikonversi menjadi huruf kecil), sedangkan `on_condition` diambil dari `join_condition`. Untuk simpul SQL dengan dua sumber, informasi join muncul di dalam `params` dan `join_spec`.

### Struktur sisi

Larik `edges` menentukan koneksi antar-simpul dalam graf alur kerja.

```yaml
edges:
  - source: "node-telematics-1"
    target: "node-sql-1"
  - source: "node-business-1"
    target: "node-sql-1"
```

Setiap sisi adalah objek dengan dua kolom:

| Kolom    | Deskripsi                     |
| -------- | ----------------------------- |
| `source` | ID node tempat edge berasal.  |
| `target` | ID node tempat edge berakhir. |

ID edge dari antarmuka Builder tidak dipertahankan dalam ekspor. Saat diimpor, ID edge baru dibuat secara otomatis.

## Impor

### Deteksi versi

Builder menentukan versi format YAML menggunakan logika berikut:

* Jika root berisi `version: 2` atau kunci `cte_nodes`, file diproses sebagai **versi 2**.
* Jika tidak, **versi 1** diharapkan.

### Impor versi 2

Builder menelusuri array `cte_nodes` sesuai urutan. Untuk setiap rekaman:

* Nilai `id` dan `type` dibaca. Jenis diubah menjadi huruf kecil. Node dengan jenis `python` dilewati tanpa menimbulkan galat.
* Parameter dibaca dari kunci `params` (atau `config` sebagai pilihan cadangan). Untuk node bertipe `sql`-type, jika kolom `join_spec` ada dalam rekaman, kolom tersebut ditetapkan ke konfigurasi join node.
* Array `edges` diuraikan menjadi pasangan sumber-target, dan ID edge baru dibuat.
* Kolom `viewport` dan `schedule` dipertahankan jika ada dalam YAML.

### Impor versi 1 (kompatibilitas mundur)

File versi 1 menggunakan kunci `nodes` (array atau kamus), dan secara opsional menggunakan array `edges` atau `depends_on` kolom di dalam setiap node.

Builder memproses file versi 1 sebagai berikut:

* Jenis node yang didukung sama seperti pada versi 2: `telematics`, `business`, `filter`, `resample`, `sql`, `arithmetic`, `custom`, `output`.
* Koneksi antar-node dapat ditentukan dengan dua cara: array tingkat teratas `edges` atau daftar `depends_on` di dalam setiap node.
* Kolom `inputs` dan `outputs` pada setiap node dinormalisasi menjadi objek dengan struktur `{ name, type }` .
* Jika edges menyertakan pengenal port `sourceHandle` atau `targetHandle` , proses impor menyesuaikan port node agar ditampilkan dengan benar di antarmuka Builder.

## Templat struktur YAML

Templat berikut menunjukkan struktur lengkap file YAML versi 2 dengan anotasi:

{% code expandable="true" %}

```yaml
version: 2
name: "workflow_name"
description: "Workflow description"

cte_nodes:
  - id: "node-id-1"
    type: telematics    # telematics | business | filter | resample |
                        # sql | arithmetic | custom | output
    label: "Node display name"
    description: ""
    position: { x: 100, y: 100 }
    sources: []         # empty for source nodes
    params:
      table_name: "tracking_data_core"
      time_column: "device_time"
      columns: [device_id, device_time, speed]
      filter_condition: ""
      time_window_minutes: ""

  - id: "node-id-2"
    type: sql
    label: "SQL Transform"
    description: ""
    position: { x: 400, y: 160 }
    sources: ["node-id-1", "node-id-3"]   # ordered predecessor IDs
    params:
      join_type: LEFT
      join_condition: "a_node_id_1.device_id = a_node_id_3.device_id"
      select_columns: ["a_node_id_1.*", "a_node_id_3.sensor_label"]
    join_spec:                             # added for sql nodes with 2+ sources
      - type: "left"
        on_condition: "a_node_id_1.device_id = a_node_id_3.device_id"

    # optional per-node fields:
    # width: 250
    # height: 400

edges:
  - source: "node-id-1"
    target: "node-id-2"
  - source: "node-id-3"
    target: "node-id-2"

# optional top-level fields:
output_node_id: "node-output-1"           # if an Output node exists
viewport: { x: 0, y: 0, zoom: 1 }        # canvas position on import
schedule: { cron: "0 0 * * *", timezone: "UTC" }  # if Penjadwalan is enabled
```

{% endcode %}

### Contoh

Contoh berikut menunjukkan alur kerja versi 2 lengkap yang membaca data sensor telematika, menggabungkannya dengan deskripsi sensor dari skema bisnis, menerapkan transformasi aritmetika untuk mengonversi tipe kolom, dan menulis hasilnya ke tabel output.

{% code expandable="true" %}

```yaml
version: 2
name: enriched_vehicle_metrics
description: "Metrik kendaraan yang diperkaya dari telematika dan deskripsi sensor"

cte_nodes:
  - id: node-telematics-1
    type: telematics
    label: "Data mentah: Telematics"
    description: ""
    position: { x: 100, y: 100 }
    sources: []
    params:
      table_name: inputs
      time_column: device_time
      columns: [device_id, device_time, value]
      filter_condition: ""
      time_window_minutes: ""

  - id: node-business-1
    type: business
    label: "Data mentah: Business"
    description: ""
    position: { x: 100, y: 220 }
    sources: []
    params:
      table_name: sensor_description
      key_column: sensor_id
      columns: [sensor_id, device_id, sensor_label]

  - id: node-sql-1
    type: sql
    label: "SQL Transform"
    description: ""
    position: { x: 400, y: 160 }
    sources: [node-telematics-1, node-business-1]
    params:
      join_type: LEFT
      join_condition: "a_node_telematics_1.device_id = a_node_business_1.device_id"
      select_columns: ["a_node_telematics_1.*", "a_node_business_1.sensor_label"]
    join_spec:
      - type: "left"
        on_condition: "a_node_telematics_1.device_id = a_node_business_1.device_id"

  - id: node-arithmetic-1
    type: arithmetic
    label: "Aritmetika"
    description: ""
    position: { x: 700, y: 160 }
    sources: [node-sql-1]
    params:
      expressions:
        - column: value
          expression: "value::numeric"
          expression_alias: value_num

  - id: node-output-1
    type: output
    label: "Keluaran"
    description: ""
    position: { x: 1000, y: 160 }
    sources: [node-arithmetic-1]
    params:
      table_name: enriched_vehicle_metrics
      time_column: device_time
      primary_key: [device_id, device_time]
      write_mode: append

edges:
  - { source: node-telematics-1, target: node-sql-1 }
  - { source: node-business-1, target: node-sql-1 }
  - { source: node-sql-1, target: node-arithmetic-1 }
  - { source: node-arithmetic-1, target: node-output-1 }

output_node_id: node-output-1
viewport: { x: 0, y: 0, zoom: 1 }
schedule: { cron: "0 0 * * *", timezone: "UTC" }
```

{% endcode %}

Alur kerja ini melakukan langkah-langkah berikut:

1. **node-telematics-1** membaca `device_id`, `device_time`, dan `value` dari kolom `inputs` pada tabel `raw_telematics_data` dalam skema.
2. **node-business-1** membaca `sensor_id`, `device_id`, dan `sensor_label` dari `sensor_description` pada tabel `raw_business_data` dalam skema.
3. **node-sql-1** menggabungkan kedua sumber berdasarkan `device_id` menggunakan `LEFT JOIN`, dengan memilih semua kolom telematika serta kolom `sensor_label` dari sumber data bisnis.
4. **node-arithmetic-1** menambahkan kolom hasil perhitungan `value_num` dengan mengonversi teks pada kolom `value` menjadi tipe numerik.
5. **node-output-1** mengonfigurasi hasil agar ditulis ke tabel `enriched_vehicle_metrics` dengan `mode` , menggunakan `device_id` dan `device_time` sebagai kunci utama.

{% hint style="info" %}
Ekspor tidak menyertakan `available_tables` atau `available_columns` di `params`. Kolom-kolom ini diisi secara dinamis saat Builder terhubung ke database. Untuk node SQL dengan dua sumber, informasi penggabungan muncul di kedua `params` dan `join_spec`.
{% endhint %}

## Langkah selanjutnya

* [**Builder transformasi**](https://navixy.com/docs/analytics/id/iot-query/schema-overview/transformation-layer/transformation-builder.md): Pelajari cara merancang alur kerja menggunakan antarmuka visual.
* [**Templat**](https://navixy.com/docs/analytics/id/iot-query/schema-overview/transformation-layer/transformation-builder/templates.md): Konfigurasi alur kerja siap pakai yang dapat Anda impor dan sesuaikan di Transformation Builder.
* [**Lapisan transformasi**](https://navixy.com/docs/analytics/id/iot-query/schema-overview/transformation-layer.md): Pahami bagaimana data yang telah diproses diatur ke dalam skema dan cara mengkuerinya.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://navixy.com/docs/analytics/id/iot-query/schema-overview/transformation-layer/transformation-builder/workflow-yaml-reference.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
