Open jsantell opened 5 days ago
I think it's easier to think of and implement structured data traversal one key at a time. For example, instead of writing read("recipe/author")
you would write read("recipe").read("author")
. A library can always create a path sugar over this.
Currently, read
returns a Reference
and a Reference
is an opaque (possibly not even defined) value. A Reference
is also said to have a read
method.
Additionally, it's important to recognize that the "inner" value of a map is not a simple data structure. It is a composite structure that may contain plain data types or references. Similarly, a list may be a list of references. One implication here is that there should be a variant of value
that embodies a Reference
.
Hierarchical data types and optional inputs/outputs seem like separable issues to me.
Currently, module ports support some primitive types (string, number, boolean, buffer). We should support some "structured" type that allows mediated access to data with nested values. These values each have their own value properties and metadata like IFC labels that must be adhered to by the runtime.
Currently value properties are defined via a definition that looks like:
Given an example of an object representing a cake recipe, containing an author, details and timestamp, the input definition could look like:
These properties could be accessed in JS VM module like:
Itemizing the things to implement here:
map
children: Option<Vec<Definition>>
formap
typesoptional: bool
: false by default, specifying whether this input is required to be provided. This has consequences on non-map types as well and could affect graph invocation logicopaque: bool
: false by default, specifying whether this data is accessible from the module. Opaque types should not affect IFC labels, and at runtime,InputOutput
enforces this. Also affects non-map types.InputOutput
's read and write should support nested keys/
a sufficiently OK delimiter? We would restrict/
as a valid character in port names (we should probably constrain port names anyway)map
type should represent itself as anObject
in JS VMs. WRT IFC, amap
type is the summation of all its children's labels.The port definition properties
opaque
andoptional
may be elided in initial implementation.