@remotehost/apps
v0.1.0
Published
The RemoteHost App SDK: schemas, validators, declared views and their engine, and actions in TypeScript, built to Wasm components against wit/app.wit.
Downloads
273
Maintainers
Readme
RemoteHost App SDK
@remotehost/apps is how a RemoteHost app is written, built and tested: its
schema, validators, declared views and actions in TypeScript, built to
WebAssembly components against the app contract (wit/app.wit, package
remotehost:[email protected]). Licensed under the
Apache License, Version 2.0 (LICENSE.md, NOTICE).
The guide is docs.remotehost.ai/docs/apps.
Install
In the app's folder:
npm install --save-dev @remotehost/appsIt needs Node.js 22.18 or newer, and nothing else: no Rust and no
WebAssembly toolchain. npm installs the two programs the build runs
(esbuild and
componentize-qjs) with the
SDK, each as an optional dependency for your platform (both publish builds
for macOS, Linux and Windows, on x64 and arm64), so do not install with
--omit=optional. If one is missing, remotehost-app build says which.
Build and test
npx @remotehost/apps build [dir] # the app in dir (default ".") to dir/dist
npx @remotehost/apps test [dir] [-t pattern] # build, then run test/*.test.ts on a fake host
npx @remotehost/apps --version
npx @remotehost/apps --helpnpx @remotehost/apps runs remotehost-app, this package's one command, so a
package.json script can name it: "build": "remotehost-app build". It was
remote app in the remote CLI.
An app is a folder:
checklist/
schema.ts the backend: types, fields, rules, seed
rules.ts validators and afterWrite (optional)
views.ts declared views: lists, boards, detail pages (optional)
client.ts actions a declaration cannot say (optional)
app.toml the install manifest
test/*.test.tsbuild writes dist/backend/backend.json, dist/backend/backend.wasm (when
there is a rules.ts), dist/views.json (when there is a views.ts),
dist/client.wasm (when client.ts has an action or an onEvent) and
dist/app.toml.
Use
// schema.ts
import { bool, defineSchema, text } from "@remotehost/apps";
export default defineSchema({
backend: "checklist",
title: "Checklist",
types: {
item: { fields: { text: text({ max: 280 }), done: bool().default(false) } },
},
});// test/checklist.test.ts
import assert from "node:assert/strict";
import { test } from "node:test";
import { loadApp, refusal } from "@remotehost/apps/testing";
test("a blank item is refused", async () => {
const app = await loadApp(new URL("..", import.meta.url));
assert.throws(() => app.person("ann").put("item", { text: " " }), refusal("blank_text", "text"));
});| Import | Holds |
|---|---|
| @remotehost/apps | defineSchema and the field types, defineRules, defineClient, defineView and defineViews |
| @remotehost/apps/testing | loadApp, the fake host an app's tests run on, and refusal |
| @remotehost/apps/tooling | build and test, for a script that builds or tests an app itself |
| @remotehost/apps/view | the declared views' spec |
| @remotehost/apps/wit/app.wit | the app contract |
