model.rk
Rangka model
Lives in modules/<module>/models/<model>.rk · Schema model.json (source) · first line: # yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
Properties
| Property | Type | Meaning |
|---|---|---|
name required | name | snake_case, never renamed once released pattern ^[a-z][a-z0-9_]{0,62}$ |
label | label | A label in Bahasa Indonesia (required) and optionally English. |
label.id required | string | |
label.en | string | |
icon | string | |
is_submittable | boolean | |
is_child | boolean | |
append_only | boolean | A ledger: rows are written only by flows, hooks and seed; nobody, the owner included, creates them through the API, updates or deletes them. A correction is a reversing row (contract 0026). default false |
naming | string or object | e.g. INV-{YYYY}-{#####} or STRK-{outlet.code}-{YY}{MM}-{####} (a field token, one counter per rendered prefix), or {series: invoice, pattern: 'INV/{ORG}/{YY}/{####}'} (contract 0009) |
naming_on | device | device: the name comes with the write from a paired device and the kernel checks it against the string naming, which carries {device.code}, instead of making it; a write without a device keeps the kernel's numbering with {device.code} left out (contract 0058 §3) |
title_field | name | snake_case, never renamed once released pattern ^[a-z][a-z0-9_]{0,62}$ |
fields required | list of object | at least 1 |
rules | list of object | |
rules[].name required | name | snake_case, never renamed once released pattern ^[a-z][a-z0-9_]{0,62}$ |
rules[].on required | save · submit · cancel | |
rules[].level | error · warn · info | |
rules[].check required | CEL | A CEL expression (plus Rangka helpers) |
rules[].message required | label | A label in Bahasa Indonesia (required) and optionally English. |
rules[].message.id required | string | |
rules[].message.en | string | |
approvals | list of object | |
approvals[].name required | name | snake_case, never renamed once released pattern ^[a-z][a-z0-9_]{0,62}$ |
approvals[].on required | name | submit, cancel or an action name of this model pattern ^[a-z][a-z0-9_]{0,62}$ |
approvals[].when | CEL | Policy applies only when this is true (absent = always) |
approvals[].approvers required | list of name | Roles that may approve; owner always may at least 1 |
approvals[].label | label | A label in Bahasa Indonesia (required) and optionally English. |
approvals[].label.id required | string | |
approvals[].label.en | string | |
on_submit | list of string | |
on_cancel | list of string | |
stock | object | How stock.post_moves moves stock for this model (contract 0021). The six built-in stock documents keep their own rule and may not declare one. |
stock.date | name | Header date field used as posting_date (default: the first required date field) pattern ^[a-z][a-z0-9_]{0,62}$ |
stock.moves required | list of object | at least 1 |
stock.moves[].lines required | name | Table field whose rows move pattern ^[a-z][a-z0-9_]{0,62}$ |
stock.moves[].in | string | Outlet the rows come into: a header link field, or line.<field> pattern ^(line\.)?[a-z][a-z0-9_]{0,62}$ |
stock.moves[].out | string | Outlet the rows leave: a header link field, or line.<field> pattern ^(line\.)?[a-z][a-z0-9_]{0,62}$ |
stock.moves[].item | name | Line link to item (default item) pattern ^[a-z][a-z0-9_]{0,62}$ |
stock.moves[].qty | name | Line quantity in stock uom (default stock_qty when the line has it, else qty) pattern ^[a-z][a-z0-9_]{0,62}$ |
stock.moves[].if | CEL | Per line, with doc and line; false skips the line |
stock.moves[].reason required | name | An option of stock_move.reason pattern ^[a-z][a-z0-9_]{0,62}$ |
stock.moves[].explode | recipe | out: consume through the item's active recipe; in: bring its materials back (cost average or source) |
stock.moves[].cost | average or object or object or object or object | in only: average (default), {unit: f}, {amount: f}, {source: link}, |
stock.moves[].cogs | name | out only: read-only currency line field that gets the value the line took out pattern ^[a-z][a-z0-9_]{0,62}$ |
stock.cogs_total | name | Read-only currency header field that gets the value taken out by all cogs lines pattern ^[a-z][a-z0-9_]{0,62}$ |
stock.negative | allow · refuse | refuse: submit fails when an out move would leave the outlet below zero (default allow) |
actions | list of object | |
actions[].name required | name | snake_case, never renamed once released pattern ^[a-z][a-z0-9_]{0,62}$ |
actions[].description | object | Owner sentence of what this does, conditions included (contract 0060 §1). Changes no behaviour. |
actions[].description.id required | string | |
actions[].description.en | string | |
actions[].label required | label | A label in Bahasa Indonesia (required) and optionally English. |
actions[].label.id required | string | |
actions[].label.en | string | |
actions[].icon | string | |
actions[].hook required | string | pattern ^[a-z_]+\.[a-z_]+$ |
actions[].primary | boolean | |
actions[].if | CEL | A CEL expression (plus Rangka helpers) |
actions[].queue | object | Run in the background (needs system.queue). |
actions[].queue.retries | integer | min 0, max 25 |
actions[].queue.backoff | string | pattern ^[0-9]+(s|m|h)$ |
actions[].queue.timeout | string | pattern ^[0-9]+(s|m|h)$ |
automations | list of object | |
automations[].name required | name | snake_case, never renamed once released pattern ^[a-z][a-z0-9_]{0,62}$ |
automations[].description | object | Owner sentence of what this does, conditions included (contract 0060 §1). Changes no behaviour. |
automations[].description.id required | string | |
automations[].description.en | string | |
automations[].when required | string | |
automations[].if | CEL | A CEL expression (plus Rangka helpers) |
automations[].do required | string | |
permissions | list of object | |
permissions[].role required | name | snake_case, never renamed once released pattern ^[a-z][a-z0-9_]{0,62}$ |
permissions[].if | CEL | A CEL expression (plus Rangka helpers) |
permissions[].read | boolean | |
permissions[].create | boolean | |
permissions[].write | boolean | |
permissions[].delete | boolean | |
permissions[].submit | boolean | |
permissions[].cancel | boolean | |
permissions[].amend | boolean | |
permissions[].export | boolean | |
permissions[].import | boolean | |
permissions[].print | boolean | |
permissions[].customize | boolean | |
views | object | |
views.default | list · kanban · calendar · report | |
views.list | object | |
views.list.columns | list of string | at least 1 |
views.list.filters | list of name | |
views.list.sort | string | pattern ^-?[a-z_]+$ |
views.list.group_by | name | snake_case, never renamed once released pattern ^[a-z][a-z0-9_]{0,62}$ |
views.kanban | object | |
views.kanban.group_by required | name | snake_case, never renamed once released pattern ^[a-z][a-z0-9_]{0,62}$ |
views.kanban.title | name | snake_case, never renamed once released pattern ^[a-z][a-z0-9_]{0,62}$ |
views.kanban.card | list of name | at most 5 |
views.kanban.sum | name | snake_case, never renamed once released pattern ^[a-z][a-z0-9_]{0,62}$ |
views.form | object | |
views.form.layout required | list of or | |
views.form.layout[].section required | label | A label in Bahasa Indonesia (required) and optionally English. |
views.form.layout[].fields | list of name | |
views.form.layout[].columns | list of list of name | at most 2 |
views.form.layout[].tab | label | A label in Bahasa Indonesia (required) and optionally English. |
realtime | boolean | Push record changes to open screens (needs system.realtime). default false |
cache | string | Cache list reads for this long (needs system.cache). pattern ^[0-9]+(s|m|h)$ |
description
An owner sentence or two in Bahasa Indonesia (required) and optionally English (contract 0060 §1).
| Property | Type | Meaning |
|---|---|---|
id required | string | |
en | string |
option
| Property | Type | Meaning |
|---|---|---|
value required | string | pattern ^[a-z0-9_]+$ |
label required | label | A label in Bahasa Indonesia (required) and optionally English. |
label.id required | string | |
label.en | string | |
tone | neutral · info · ok · warn · bad · muted | |
probability | number | min 0, max 100 |
closed | boolean |
field
| Property | Type | Meaning |
|---|---|---|
name required | name | snake_case, never renamed once released pattern ^[a-z][a-z0-9_]{0,62}$ |
type required | data · text · int · float · currency · percent · check · select · multiselect · link · dynamic_link · table · date · daterange · datetime · duration · phone · npwp · attach · image · rating · color · json · signature · money · geo | |
label | label | A label in Bahasa Indonesia (required) and optionally English. |
label.id required | string | |
label.en | string | |
required | boolean | |
default | CEL | A CEL expression (plus Rangka helpers) |
compute | CEL | A CEL expression (plus Rangka helpers) |
depends_on | CEL | A CEL expression (plus Rangka helpers) |
read_only | boolean | |
set_once | boolean | A client may fill the field while it is empty but never change a value it holds (proof: clock-in time, position, photo); flows and other kernel writes may (contract 0030 §4) |
hidden | boolean | |
in_list | boolean | |
in_filter | boolean | |
unique | boolean | |
index | boolean | |
help | label | A label in Bahasa Indonesia (required) and optionally English. |
help.id required | string | |
help.en | string | |
to | name | snake_case, never renamed once released pattern ^[a-z][a-z0-9_]{0,62}$ |
of | name | snake_case, never renamed once released pattern ^[a-z][a-z0-9_]{0,62}$ |
currency_field | name | snake_case, never renamed once released pattern ^[a-z][a-z0-9_]{0,62}$ |
rate_field | name | snake_case, never renamed once released pattern ^[a-z][a-z0-9_]{0,62}$ |
peek | list of name | at most 6 |
options | list of object | at least 1 |
options[].value required | string | pattern ^[a-z0-9_]+$ |
options[].label required | label | A label in Bahasa Indonesia (required) and optionally English. |
options[].label.id required | string | |
options[].label.en | string | |
options[].tone | neutral · info · ok · warn · bad · muted | |
options[].probability | number | min 0, max 100 |
options[].closed | boolean | |
chip | boolean | |
relative_to | name | snake_case, never renamed once released pattern ^[a-z][a-z0-9_]{0,62}$ |
min_rows | integer | min 0 |
read_only_for | list of name | |
hidden_for | list of name | |
money | boolean | Money field (currency fields are money by default). Changes are high risk. |
stock | boolean | Quantity that moves stock. Changes are high risk. |
rule
| Property | Type | Meaning |
|---|---|---|
name required | name | snake_case, never renamed once released pattern ^[a-z][a-z0-9_]{0,62}$ |
on required | save · submit · cancel | |
level | error · warn · info | |
check required | CEL | A CEL expression (plus Rangka helpers) |
message required | label | A label in Bahasa Indonesia (required) and optionally English. |
message.id required | string | |
message.en | string |
permission
| Property | Type | Meaning |
|---|---|---|
role required | name | snake_case, never renamed once released pattern ^[a-z][a-z0-9_]{0,62}$ |
if | CEL | A CEL expression (plus Rangka helpers) |
read | boolean | |
create | boolean | |
write | boolean | |
delete | boolean | |
submit | boolean | |
cancel | boolean | |
amend | boolean | |
export | boolean | |
import | boolean | |
print | boolean | |
customize | boolean |
section
| Property | Type | Meaning |
|---|---|---|
section required | label | A label in Bahasa Indonesia (required) and optionally English. |
section.id required | string | |
section.en | string | |
fields | list of name | |
columns | list of list of name | at most 2 |
tab | label | A label in Bahasa Indonesia (required) and optionally English. |
tab.id required | string | |
tab.en | string |
approval
| Property | Type | Meaning |
|---|---|---|
name required | name | snake_case, never renamed once released pattern ^[a-z][a-z0-9_]{0,62}$ |
on required | name | submit, cancel or an action name of this model pattern ^[a-z][a-z0-9_]{0,62}$ |
when | CEL | Policy applies only when this is true (absent = always) |
approvers required | list of name | Roles that may approve; owner always may at least 1 |
label | label | A label in Bahasa Indonesia (required) and optionally English. |
label.id required | string | |
label.en | string |
stock_rule
| Property | Type | Meaning |
|---|---|---|
lines required | name | Table field whose rows move pattern ^[a-z][a-z0-9_]{0,62}$ |
in | string | Outlet the rows come into: a header link field, or line.<field> pattern ^(line\.)?[a-z][a-z0-9_]{0,62}$ |
out | string | Outlet the rows leave: a header link field, or line.<field> pattern ^(line\.)?[a-z][a-z0-9_]{0,62}$ |
item | name | Line link to item (default item) pattern ^[a-z][a-z0-9_]{0,62}$ |
qty | name | Line quantity in stock uom (default stock_qty when the line has it, else qty) pattern ^[a-z][a-z0-9_]{0,62}$ |
if | CEL | Per line, with doc and line; false skips the line |
reason required | name | An option of stock_move.reason pattern ^[a-z][a-z0-9_]{0,62}$ |
explode | recipe | out: consume through the item's active recipe; in: bring its materials back (cost average or source) |
cost | average or object or object or object or object | in only: average (default), {unit: f}, {amount: f}, {source: link}, |
cogs | name | out only: read-only currency line field that gets the value the line took out pattern ^[a-z][a-z0-9_]{0,62}$ |
Example
From rangka-apps/modules/pipeline/models/deal.rk (first 60 lines):
yaml
# yaml-language-server: $schema=https://rangka-os.github.io/rangka-os/schema/0.5/model.json
name: deal
label: {id: Peluang, en: Deal}
icon: card
naming: DEAL-{#####}
title_field: deal_name
realtime: true
permissions:
- {role: sales_manager, read: true, create: true, write: true, delete: true, submit: true, cancel: true, amend: true, export: true, print: true}
- {role: finance_manager, read: true}
- {role: purchasing_manager, read: true}
- {role: project_admin, read: true}
- {role: head_office, read: true}
- {role: outlet_staff, read: true}
- {role: sales_rep, read: true, create: true, write: true, if: owner == user.name}
fields:
- name: deal_name
type: data
label: {id: Judul peluang}
required: true
in_list: true
- name: customer
type: link
to: customer
label: {id: Pelanggan}
required: true
in_list: true
peek: [outstanding, payment_days]
- name: contact_person
type: data
label: {id: Kontak}
- name: stage
type: select
label: {id: Tahap}
default: "'prospect'"
in_list: true
chip: true
options:
- value: prospect
label: {id: Prospek}
probability: 10
- value: qualified
label: {id: Kualifikasi}
probability: 25
- value: proposal
label: {id: Penawaran}
probability: 50
- value: negotiation
label: {id: Negosiasi}
probability: 75
- value: won
label: {id: Menang}
probability: 100
tone: ok
closed: true
- value: lost
label: {id: Kalah}
probability: 0
tone: bad
closed: trueGenerated from the schema by website/scripts/gen-reference.mjs. Edit the schema, not this page.