Effects

Status: implemented

effects/schema describes data-shaped effect requests and results, such as the entries readdir answers, for validation. Its types.ts checks the corresponding handwritten TypeScript declarations against the types Ts<> derives from the schemas.

These schemas are not a native runner ABI or the complete native effect set; that set follows effects/node/ within the native scope.

Examples

The demo on this page offers one schema, a directory entry, with a value it accepts. It is defined in sample.f.mjs, and the module page's demo lists it among all the others.

Where it is implemented

effects/schema.

Demo

An entry readdir answers, described by a data-validation schema in effects/schema. The corresponding handwritten TypeScript operation declarations are checked against schema-derived types.

import { dirent } from 'functionalscript/fjs/effects/schema/module.f.mjs'
{}nameparentPathisFileisDirectorystringstringbooleanboolean

TypeScript:

{readonly"isDirectory":boolean,readonly"isFile":boolean,readonly"name":string,readonly"parentPath":string}

JSON Schema:

{"type":"object","properties":{"isDirectory":{"type":"boolean"},"isFile":{"type":"boolean"},"name":{"type":"string"},"parentPath":{"type":"string"}},"required":["isDirectory","isFile","name","parentPath"],"additionalProperties":{"not":{}}}
Canonical form (toData)
export default [{},{"object":[{"props":{"isDirectory":{"unit":12},"isFile":{"unit":12},"name":{"string":true},"parentPath":{"string":true}},"rest":{}}]}];

parse · ok

export default {"name":"module.f.mjs","parentPath":"fjs/rtti","isFile":true,"isDirectory":false};

validate · ok

export default {"name":"module.f.mjs","parentPath":"fjs/rtti","isFile":true,"isDirectory":false};

Emergent Testing

Idle. Press Run to start the suite.

  • ./proof.f.mjs