manifest.json
manifest.json holds what other parties rely on: the types of arguments, results, catalog rows
and events, the catalogs, the required modules and the pages in the Dashboard. The Go types are
generated from it; never write a contract type by hand.
{ "module": "battlepass", "version": "0.2.0", "title": "Battle pass", "description": "Seasons of tiers players climb with experience.", "icon": "award", "requires": {"stores": "^1.0"}, "types": { "Season": { "type": "object", "required": ["key", "window"], "properties": { "key": {"type": "string"}, "window": {"$ref": "rudder:window"} } }, "Tier": { "type": "object", "required": ["season", "level", "xp", "reward"], "properties": { "season": {"type": "string"}, "level": {"type": "integer"}, "xp": {"type": "integer"}, "reward": {"$ref": "rudder:amount"}, "premiumReward": {"$ref": "rudder:amount", "nullable": true} } }, "Reached": { "type": "object", "required": ["season", "level"], "properties": { "season": {"type": "string"}, "level": {"type": "integer"} } } }, "content": { "seasons": {"row": "Season", "key": "key", "window": "window", "exclusive": true}, "tiers": {"row": "Tier", "indexes": ["season"]} }, "events": {"reached": "Reached"}}Fields
Section titled “Fields”| Field | Meaning |
|---|---|
module | The name of the module, lowercase letters and digits starting with a letter, such as battlepass. The client calls it by this name. admin, ledger, rudder and session are taken. |
version | A semantic version, such as 0.2.0. A published version never changes. |
title, description, icon | The card of the module in the Dashboard. icon is one of the page icons. |
requires | The modules this one calls or listens to, each with a caret range (see Calls and events). |
types | The named types of the contract. |
content | The catalogs (see Catalogs). |
events | The events the module emits, each naming an object type of types. |
admin | The pages of the module in the Dashboard (see Dashboard pages). |
An entry of types is a JSON Schema of a small subset: an object, an enum of strings
({"type": "string", "enum": ["day", "week"]}) or any other value schema. Its name is an
exported Go identifier.
- A property is a scalar, an array, a map (
additionalProperties) or a$ref. An object or an enum used as a property is always a named entry oftypes. $refis#/types/<name>or one of the built-in types below.allOfwith one$refto an object type embeds it, and adds the properties of its own.- The keywords are
type,properties,required,items,additionalProperties,enum,format: date-time,$ref,allOf,nullable,titleanddescription. Any other keyword fails generation. Value constraints such asminimumorpatternare not supported yet: check values in code. - Types are not recursive.
| Built-in type | JSON | Go |
|---|---|---|
rudder:amount | {"asset": "gems", "amount": 10} | rudder.Amount |
rudder:window | {"start": "...", "end": "..."}, either bound optional | rudder.Window |
rudder:regen | {"every": 300, "max": 5} | rudder.RegenRule |
rudder:regen-state | {"value", "max", "every", "nextAt", "fullAt", "at"} | rudder.RegenState |
From JSON to Go
Section titled “From JSON to Go”| Schema | Go |
|---|---|
integer | int64 |
number | float64 |
boolean, string | bool, string |
string with format: date-time | time.Time |
array | a slice |
object with additionalProperties | map[string]T |
$ref: #/types/<name> | the generated type |
| an object | a struct, fields sorted by name |
a property not in required | a field that is omitted when zero |
nullable: true | a pointer |
| an enum of strings | a named string type with constants <Type><Value> (PeriodDay) |
A field is named after its property with the first letter in upper case and a trailing Id
or Url in capitals: id is ID, premiumPrice is PremiumPrice, imageUrl is ImageURL.
Zero and absent are told apart only with nullable.
title and description label the fields of a form in the Dashboard.
What the CLI writes
Section titled “What the CLI writes”| File | What it is | Commit it |
|---|---|---|
rudder_gen.go | The types, the catalogs, the wiring of the fields and functions. | yes |
rudder_gen_test.go | The test client (NewGame). | yes |
rudder.lock.json | The fields, functions, events and timers of the module as published, for the compatibility check. | yes |
requires/<module>.json and requires/<module>/ | The contract of a required module and its generated package. | yes |
<module>.wasm, <module>.manifest.json | The build and the built manifest. | no |
The built manifest is the source manifest plus what comes from the code: the functions with their kinds, the fields, the timers and the errors. Rudder reads only the built manifest.