Skip to content

Commit ff6fe87

Browse files
committed
Documentation updates from Promptless
1 parent 98ee894 commit ff6fe87

File tree

4 files changed

+799
-3
lines changed

4 files changed

+799
-3
lines changed

docs/operate/reference/module-configuration.md

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ The model is configured as a component with the name `myRealsenseCamera1`.
179179
```
180180

181181
{{% /tab %}}
182-
{{% /tabs %}}
182+
{{< /tabs %}}
183183

184184
{{% /tab %}}
185185
{{< /tabs >}}
@@ -227,6 +227,64 @@ For any version type other than **Patch (X.Y.Z)**, the module will upgrade as so
227227
If, for example, the module provides a motor component, and the motor is running, it will stop while the module upgrades.
228228
{{% /alert %}}
229229

230+
#### Module meta.json configuration
231+
232+
When creating a module, you'll need to configure a `meta.json` file that defines the module's properties. This file includes information about the module's ID, visibility, models, and other features.
233+
234+
Here's an example of a `meta.json` file:
235+
236+
```json
237+
{
238+
"module_id": "your-namespace:your-module",
239+
"visibility": "public",
240+
"url": "https://github.com/your-org/your-repo",
241+
"description": "Your module description",
242+
"models": [
243+
{
244+
"api": "rdk:component:base",
245+
"model": "your-namespace:your-module:your-model"
246+
}
247+
],
248+
"entrypoint": "run.sh",
249+
"first_run": "setup.sh"
250+
}
251+
```
252+
253+
For modules that include [Single Page Apps](/operate/reference/single-page-apps/), you can add the `applications` field:
254+
255+
```json
256+
{
257+
"module_id": "your-namespace:your-module",
258+
"visibility": "public",
259+
"url": "https://github.com/your-org/your-repo",
260+
"description": "Your module description",
261+
"models": [
262+
{
263+
"api": "rdk:component:base",
264+
"model": "your-namespace:your-module:your-model"
265+
}
266+
],
267+
"entrypoint": "run.sh",
268+
"applications": [
269+
{
270+
"name": "your-app-name",
271+
"type": "web",
272+
"entrypoint": "dist/index.html"
273+
}
274+
]
275+
}
276+
```
277+
278+
The `applications` field is an array of application objects with the following properties:
279+
280+
| Property | Type | Description |
281+
| --- | --- | --- |
282+
| `name` | string | The name of your application, which will be used in the URL (`name.publicnamespace.viamapps.com`) |
283+
| `type` | string | The type of application (currently only `"web"` is supported) |
284+
| `entrypoint` | string | The path to the HTML entry point for your application |
285+
286+
For more information about Single Page Apps, see the [Single Page Apps documentation](/operate/reference/single-page-apps/).
287+
230288
#### Environment variables
231289

232290
Each module has access to the following default environment variables.
@@ -290,4 +348,4 @@ To set the path to a program or library on a machine, you can set a system varia
290348
}
291349
```
292350

293-
{{% /expand%}}
351+
{{% /expand%}}

docs/operate/reference/naming-modules.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,48 @@ More requirements:
9595

9696
Determine the model name you want to use based on these requirements, then proceed to the next section.
9797

98+
## Valid application identifiers
99+
100+
If your module includes [Single Page Apps](/operate/reference/single-page-apps/), you'll need to define application names in your module's `meta.json` file. Application names have the following requirements:
101+
102+
- Application names must be all-lowercase.
103+
- Application names may only use alphanumeric (`a-z` and `0-9`), hyphen (`-`), and underscore (`_`) characters.
104+
- Application names must be unique within your organization's namespace.
105+
106+
The application name will be used in the URL for accessing your application:
107+
108+
```
109+
https://app-name.your-public-namespace.viamapps.com
110+
```
111+
112+
For example, if your organization namespace is `acme` and your application name is `dashboard`, your application will be accessible at:
113+
114+
```
115+
https://dashboard.acme.viamapps.com
116+
```
117+
118+
Here's an example of how to define applications in your module's `meta.json` file:
119+
120+
```json
121+
{
122+
"module_id": "acme:my-module",
123+
"visibility": "public",
124+
"applications": [
125+
{
126+
"name": "dashboard",
127+
"type": "web",
128+
"entrypoint": "dist/index.html"
129+
}
130+
]
131+
}
132+
```
133+
134+
For more information about Single Page Apps, see the [Single Page Apps documentation](/operate/reference/single-page-apps/).
135+
98136
## Create a namespace for your organization
99137

100138
When uploading modules to the Viam Registry, you must set a unique namespace for your organization to associate your module with.
101139

102140
To create a new namespace for your organization, click on the org's **Settings** in the top right of the navigation bar, then click the **Set a public namespace** button.
103141
Enter a name or use the suggested name for your namespace, and then click **Set namespace**.
104-
A namespace may only contain letters, numbers, and the dash (`-`) character.
142+
A namespace may only contain letters, numbers, and the dash (`-`) character.
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
---
2+
title: "Single Page Apps"
3+
linkTitle: "Single Page Apps"
4+
weight: 45
5+
no_list: true
6+
type: docs
7+
icon: true
8+
description: "Create and deploy single page applications hosted by Viam."
9+
---
10+
11+
Viam Single Page Apps allow you to upload a single page application and access it via a dedicated URL (`appname.publicnamespace.viamapps.com`), with hosting, authentication, and boilerplate logic handled for you. This feature enables you to create custom web interfaces for your machines without having to manage the infrastructure for hosting and authentication.
12+
13+
## Overview
14+
15+
With Viam Single Page Apps, you can:
16+
17+
- Host shared logic for users to choose an organization, location, and single machine
18+
- Render your application once a user has selected a machine
19+
- Store robot owner API key and secret in browser storage
20+
- Proxy requests through the viamapps.com domain to maintain same-origin across pages
21+
- Authenticate users via FusionAuth
22+
- Create and upload apps using the modules framework
23+
24+
## Requirements
25+
26+
To use Viam Single Page Apps, you need:
27+
28+
- A module with a public visibility setting
29+
- A properly configured `meta.json` file with application information
30+
- A built single page application with an HTML entry point
31+
32+
## Creating a Single Page App
33+
34+
### 1. Build your application
35+
36+
Build your single page application using your preferred framework (React, Vue, Angular, etc.). Your application should be built and ready for deployment, with all assets compiled into a distributable format.
37+
38+
### 2. Configure your module's meta.json
39+
40+
Add the `applications` field to your module's `meta.json` file to define your single page app:
41+
42+
```json
43+
{
44+
"module_id": "your-namespace:your-module",
45+
"visibility": "public",
46+
"url": "https://github.com/your-org/your-repo",
47+
"description": "Your module description",
48+
"models": [
49+
{
50+
"api": "rdk:component:base",
51+
"model": "your-namespace:your-module:your-model"
52+
}
53+
],
54+
"entrypoint": "run.sh",
55+
"applications": [
56+
{
57+
"name": "your-app-name",
58+
"type": "web",
59+
"entrypoint": "dist/index.html"
60+
}
61+
]
62+
}
63+
```
64+
65+
The `applications` field is an array of application objects with the following properties:
66+
67+
| Property | Type | Description |
68+
| --- | --- | --- |
69+
| `name` | string | The name of your application, which will be used in the URL (`name.publicnamespace.viamapps.com`) |
70+
| `type` | string | The type of application (currently only `"web"` is supported) |
71+
| `entrypoint` | string | The path to the HTML entry point for your application |
72+
73+
#### Entrypoint examples
74+
75+
The `entrypoint` field specifies the path to your application's entry point. Here are some examples:
76+
77+
- `"dist/index.html"` - Static content rooted at the `dist` directory
78+
- `"dist/foo.html"` - Static content rooted at the `dist` directory, with `foo.html` as the entry point
79+
- `"dist/"` - Static content rooted at the `dist` directory (assumes `dist/index.html` exists)
80+
- `"dist/bar/foo.html"` - Static content rooted at `dist/bar` with `foo.html` as the entry point
81+
82+
### 3. Upload your module
83+
84+
Package your module with your application included and upload it to the Viam Registry:
85+
86+
```bash
87+
viam module build local
88+
viam module upload module.tar.gz
89+
```
90+
91+
## Accessing your Single Page App
92+
93+
Once your module with the application configuration is uploaded and approved, your application will be available at:
94+
95+
```
96+
https://your-app-name.your-public-namespace.viamapps.com
97+
```
98+
99+
Users will be prompted to authenticate with their Viam credentials before accessing your application.
100+
101+
## Application Flow
102+
103+
1. User navigates to `your-app-name.your-public-namespace.viamapps.com`
104+
2. User authenticates with Viam credentials
105+
3. User selects an organization, location, and machine
106+
4. User is redirected to `your-app-name.your-public-namespace.viamapps.com/machine/{machine-id}`
107+
5. Your application is rendered with access to the selected machine
108+
109+
## API Changes
110+
111+
The Single Page Apps feature introduces the following API changes:
112+
113+
### App Object
114+
115+
```protobuf
116+
message App {
117+
string name = 1;
118+
string type = 2;
119+
string entrypoint = 3;
120+
}
121+
```
122+
123+
### UpdateModuleRequest
124+
125+
```protobuf
126+
message UpdateModuleRequest {
127+
string module_id = 1;
128+
Visibility visibility = 2;
129+
string url = 3;
130+
string description = 4;
131+
repeated Model models = 5;
132+
string entrypoint = 6;
133+
optional string first_run = 7;
134+
repeated App apps = 8;
135+
}
136+
```
137+
138+
### GetAppContentRequest/Response
139+
140+
```protobuf
141+
message GetAppContentRequest {
142+
string public_namespace = 1;
143+
string name = 2;
144+
}
145+
146+
message GetAppContentResponse {
147+
string url = 1;
148+
}
149+
```
150+
151+
## Limitations
152+
153+
- Single Page Apps currently only support single-machine applications
154+
- All modules with apps must have public visibility
155+
- There is no versioning or separate deploy step; the page will always render the latest version
156+
- Browsers with cookies disabled are not supported
157+
158+
## Security Considerations
159+
160+
- Customer apps are stored in GCS buckets that are publicly available on the internet
161+
- Avoid uploading sensitive information in your application code or assets
162+
- API keys and secrets are stored in the browser's localStorage or sessionStorage
163+
164+
## Example
165+
166+
Here's a complete example of creating and uploading a simple React application as a Viam Single Page App:
167+
168+
```bash
169+
# Create a new React app
170+
npx create-react-app my-viam-app
171+
cd my-viam-app
172+
173+
# Build the app
174+
npm run build
175+
176+
# Create a module with the app
177+
viam module create --name my-viam-app --public-namespace your-namespace
178+
179+
# Edit meta.json to add the application configuration
180+
# Add the following to meta.json:
181+
# "visibility": "public",
182+
# "applications": [
183+
# {
184+
# "name": "my-app",
185+
# "type": "web",
186+
# "entrypoint": "build/index.html"
187+
# }
188+
# ]
189+
190+
# Copy the build directory to the module directory
191+
cp -r build/ path/to/module/
192+
193+
# Build and upload the module
194+
viam module build local
195+
viam module upload module.tar.gz
196+
```
197+
198+
After the module is approved, your application will be available at `https://my-app.your-public-namespace.viamapps.com`.

0 commit comments

Comments
 (0)