Added site to this repo and Gitlab to build it

This commit is contained in:
Leon Mika 2025-10-26 09:25:36 +11:00
parent 8dafa6fa8f
commit c474b18232
50 changed files with 1812 additions and 1 deletions

View file

@ -0,0 +1,75 @@
module: ext
docs: |
Provides access to the extension points scripts can used to extend the functionality of Dynamo-Browse.
This module is only available for scripts loaded using the [load-script]() command.
symbols:
- name: command
syntax: ext.command(name, fn)
docs: |
Defines a new command, which can be invoked by entering _name_ within the main view mode.
The parameter _fn_ must be a function, which will be executed when the _name_ command is entered
while in view mode.
The command can accept arguments, which will be passed in to the parameters of _fn_. The number
of command arguments must match the number of parameters, except for any function arguments with
a default value.
example: |
ext.command("add", func(x, y) {
sum := x + y
ui.print("x + y = ", sum)
})
- name: related_items
syntax: ext.related_items(table, fn)
docs: |
Defines a "related item" for a table. These act as quick jumps between tables.
When the user presses Shift+O, all the related item functions that match the given
table will be evaluated. Each one is to return zero or more related queries, which are presented
to the user as a list. When the user selects one, the query will be evaluated and the result set will
be shown.
The _table_ parameter is the name of the table of the related items managed by this function.
If the last character of the table is `*`, then _table_ will be treated as a name prefix.
The _fn_ will produce a list of queries that are related to a given item. The function takes the currently
selected item as the argument, and is expected to produce a list of maps, with each map having the following
fields:
- `label`: The label to use for the picker option
- `query`: The query expression that will run when the option is chosen
- `table`: The table to run the query over. If not set, the current table will be used
- `args`: A map of query placeholder values
- `on_select`: An optional function that will run in place of a predefined query. If set, the `query` field will
be ignored.
example: |
ext.related_items("user-account", func(item) {
return [
{
"label": "Customer",
"table": "billing",
"query": "email=$email",
"args": {"email": item.attr("email")},
},
]
})
- name: key_binding
syntax: ext.key_binding(name, options, fn)
docs: |
Defines a new key binding, which can be invoked while viewing the table.
The _name_ parameter defines the binding name. The binding names will be prefixed with
`ext.<script_basename>`. This name can be used with the [rebind]() command.
The _option_ parameter defines a map of options. The only valid option is
`default`, which is the default key to use for this binding. If unset, the binding will
have no key binding and can only be bound using the [rebind]() command.
The _fn_ parameter is the function that will be invoked when the key is pressed.
It must accept no parameters.
example: |
// Script name: sayhello.tm
//
// This binding can be rebound with the command "rebind ext.sayhello.hello <key>"
ext.key_binding("hello", {"default": "H"}, func() {
ui.print("Hello")
})

View file

@ -0,0 +1,44 @@
module: item
type: type
docs: |
A single record from a DynamoDB table.
Item values are converted to tamarin types using the following:
| Attribute Type | Tamarin Type |
|:---------------|:-------------|
| S | string |
| N | int, float \[1\] |
| BOOL | bool |
| NULL | nil |
| L | list |
| M | map |
| SS | set, with string values |
| NS | set, with number values |
Notes:
- \[1\]: int will be used if the value can be parsed as an integer, otherwise it will be returned as a float.
- Byte array (B or BS) values are currently not supported.
symbols:
- name: resultset
syntax: item.resultset
docs: |
Returns the result-set this item is a member of.
- name: index
syntax: item.index
docs: |
Returns the index of this item within the result set.
- name: attr
syntax: item.attr(expression)
docs: |
Returns the attribute value from the query expression.
- name: set_attr
syntax: item.set_attr(expression, value)
docs: |
Sets the value of the attribute.
- name: delete_attr
syntax: item.delete_attr(expression)
docs: |
Delete the attribute.

View file

@ -0,0 +1,20 @@
module: resultset
type: type
docs: |
Holds a collection of items returned from a query, or presented to a user.
A specific item of a result-set can be retrived using the subscript option. For example, `result[21]` will
return the 21st item of the result-set from the first item. A negative index can be used to retrieve an
item from the last item.
There is no guarantee to the ordering of items within the result-set, although items are usually
ordered based on the partition and sort key.
symbols:
- name: length
syntax: resultset.length
docs: |
Returns the number of items within the result set.
- name: table
syntax: resultset.table
docs: |
Returns information about the table this result set belongs to.

View file

@ -0,0 +1,52 @@
module: session
docs: |
Provides access to the currently viewed table and result-set.
symbols:
- name: query
syntax: session.query(expression, [options])
docs: |
Executes a query against a DynamoDB table. This returns a resultset if the query was successful.
A query with no results will be an empty result-set.
The _expression_ is the query expression to execute. This is similar to the type of expressions entered
after pression <kbd>?</kbd>.
The _options_ map can contain the following key/value pairs:
- `table`: the DynamoDB table to execute the query against. Default is the currently displayed table.
- `args`: A map containing names and values that can be used as placeholders in the query expression.
example: |
out := session.query("pk = $key", {
table: "some-table",
args: {
key: "my partition key"
}
}
session.set_result_set(out.unwrap())
- name: current_table
syntax: session.current_table()
docs: |
Returns information about the currently displayed table. This will be returned as a `table` object. If no
table is displayed, this function will return `nil`.
- name: resultset
syntax: session.resultset
docs: |
Returns the currently displayed result set. This is the set of items that are shown to the user in the items
table. This will be returned as a `resultset` object.
Note that this only contains the items of the current result set that exists in memory. As such, it will be
capped to the configured query limit.
- name: selected_item
syntax: session.selected_item()
docs: |
Returns the item currently highlighted in the items table. This will be returned as an `item` object. If no
item is highlighted, it will return `nil`.
- name: set_result_set
syntax: session.set_result_set(new_result_set)
docs: |
Replaces the currently displayed result-set with a new one. This can be used alongside the `query` function
to display the results of a query.
Changing the displayed result-set will trigger a redraw of the viewport and will push a new history record to
the backstack. Therefore, it's not recommended to call this method too often during a script execution session.
At most once with the final result-set you'd like to show the user is considered best practice.

View file

@ -0,0 +1,20 @@
module: table
type: type
docs: |
Provides information about a DynamoDB table.
symbols:
- name: name
syntax: table.name
docs: |
Returns the name of the table.
- name: keys
syntax: table.keys
docs: |
Returns the keys of the table. This will be returned as a map with the following names:
- `hash`: the attribute name of the partition (hash) key
- `range`: the attribute name of the sort (range) key, or `nil` if one is not defined.
- name: gsis
syntax: table.gsis
docs: |
Returns a list of the GSIs used by this table. The elements of the list will have the type table_index

View file

@ -0,0 +1,16 @@
module: table_index
type: type
docs: |
Provides information about an DynamoDB index.
symbols:
- name: name
syntax: table_index.name
docs: |
Returns the name of the index.
- name: keys
syntax: table_index.keys
docs: |
Returns the keys of the index. This will be returned as a map with the following names:
- `hash`: the attribute name of the partition (hash) key
- `range`: the attribute name of the sort (range) key, or `nil` if one is not defined.

View file

@ -0,0 +1,18 @@
module: ui
docs: |
Provides control over the user interface.
symbols:
- name: print
syntax: ui.print(args...)
docs: |
Displays a message in the status bar.
- name: prompt
syntax: ui.prompt(message)
docs: |
Request a line of input from the user, using _message_ as the prompt.
This function will return the user's input as a string, or `nil` if the user cancels
the prompt by pressing <kbd>Esc</kbd>
example: |
line := ui.prompt("What is your name? ")
ui.print("Hello, ", line)