Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul SDK docs #89

Merged
merged 22 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ lint:
- linters: [ALL]
paths:
- styles
- snippets
- linters: [checkov]
paths:
- mint.json
Expand Down
18 changes: 9 additions & 9 deletions getting-started-with-hyper-commerce.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ In the Hypermode console, you’ll see several key components of your project:
- **[Functions](/modus):** These are serverless functions written in
AssemblyScript (a TypeScript-like language) that are automatically exposed as
GraphQL APIs. Once deployed, you can query these functions within your app.
- **[Collections](/modus/sdk/collections):** Hypermode offers built-in key-value
storage, known as collections, with support for vector embeddings. This allows
you to store and retrieve data efficiently, without requiring a database for
basic use cases.
- **[Models](/modus/sdk/models):** This section represents the AI models defined
for your project. These models handle tasks like embedding text into vectors
for search. Hypermode provides open source shared and dedicated model hosting
for rapid experimentation. You can also connect to your preferred large
language model, including OpenAI, Anthropic, and Gemini.
- **[Collections](/modus/sdk/assemblyscript/collections):** Hypermode offers
built-in key-value storage, known as collections, with support for vector
embeddings. This allows you to store and retrieve data efficiently, without
requiring a database for basic use cases.
- **[Models](/modus/sdk/assemblyscript/models):** This section represents the AI
models defined for your project. These models handle tasks like embedding text
into vectors for search. Hypermode provides open source shared and dedicated
model hosting for rapid experimentation. You can also connect to your
preferred large language model, including OpenAI, Anthropic, and Gemini.
- **[Connections](/modus/app-manifest#connections):** You define all external
connections, with the runtime denying all other egress for secure-by-default
processing.
Expand Down
2 changes: 0 additions & 2 deletions introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ description: "Build Intelligent APIs."
mode: "wide"
---

---

## What is Hypermode? {/* <!-- vale Google.Contractions = NO --> */}

Hypermode is a managed service that provides the workbench and infrastructure to
Expand Down
84 changes: 75 additions & 9 deletions mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,48 @@
"url": "modus"
}
],
"redirects": [
{
"source": "/modus/sdk/collections",
"destination": "/modus/sdk/assemblyscript/collections"
},
{
"source": "/modus/sdk/console",
"destination": "/modus/sdk/assemblyscript/console"
},
{
"source": "/modus/sdk/dgraph",
"destination": "/modus/sdk/assemblyscript/dgraph"
},
{
"source": "/modus/sdk/graphql",
"destination": "/modus/sdk/assemblyscript/graphql"
},
{
"source": "/modus/sdk/http",
"destination": "/modus/sdk/assemblyscript/http"
},
{
"source": "/modus/sdk/localtime",
"destination": "/modus/sdk/assemblyscript/localtime"
},
{
"source": "/modus/sdk/models",
"destination": "/modus/sdk/assemblyscript/models"
},
{
"source": "/modus/sdk/mysql",
"destination": "/modus/sdk/assemblyscript/mysql"
},
{
"source": "/modus/sdk/neo4j",
"destination": "/modus/sdk/assemblyscript/neo4j"
},
{
"source": "/modus/sdk/postgresql",
"destination": "/modus/sdk/assemblyscript/postgresql"
}
],
"navigation": [
{
"group": "Getting Started",
Expand Down Expand Up @@ -96,16 +138,40 @@
"pages": ["modus/deepseek-model"]
},
{
"group": "API Reference",
"group": "SDK Reference",
"pages": [
"modus/sdk/collections",
"modus/sdk/console",
"modus/sdk/dgraph",
"modus/sdk/graphql",
"modus/sdk/http",
"modus/sdk/neo4j",
"modus/sdk/models",
"modus/sdk/postgresql"
{
"group": "AssemblyScript SDK",
"pages": [
"modus/sdk/assemblyscript/overview",
"modus/sdk/assemblyscript/collections",
"modus/sdk/assemblyscript/console",
"modus/sdk/assemblyscript/dgraph",
"modus/sdk/assemblyscript/graphql",
"modus/sdk/assemblyscript/http",
"modus/sdk/assemblyscript/localtime",
"modus/sdk/assemblyscript/models",
"modus/sdk/assemblyscript/mysql",
"modus/sdk/assemblyscript/neo4j",
"modus/sdk/assemblyscript/postgresql"
]
},
{
"group": "Go SDK",
"pages": [
"modus/sdk/go/overview",
"modus/sdk/go/collections",
"modus/sdk/go/console",
"modus/sdk/go/dgraph",
"modus/sdk/go/graphql",
"modus/sdk/go/http",
"modus/sdk/go/localtime",
"modus/sdk/go/models",
"modus/sdk/go/mysql",
"modus/sdk/go/neo4j",
"modus/sdk/go/postgresql"
]
}
]
},
{
Expand Down
161 changes: 107 additions & 54 deletions modus/app-manifest.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,10 @@ connection types:
| Type | Purpose | Function Classes |
| :----------- | :------------------------------- | :-------------------------- |
| `http` | Connect to an HTTP(S) web server | `http`, `graphql`, `models` |
| `postgresql` | Connect to a PostgreSQL database | `postgresql` |
| `dgraph` | Connect to a Dgraph database | `dgraph` |
| `mysql` | Connect to a MySQL database | `mysql` |
| `neo4j` | Connect to a Neo4j database | `neo4j` |
| `postgresql` | Connect to a PostgreSQL database | `postgresql` |

<Warning>
**Don't include secrets directly in the manifest!**
Expand All @@ -130,11 +131,12 @@ where they're securely stored until needed.
### HTTP connection

This connection type supports the HTTP and HTTPS protocols to communicate with
external hosts. You can use the [HTTP APIs](/modus/sdk/http) in the Modus SDK to
interact with the host.
external hosts. You can use the [HTTP APIs](/modus/sdk/assemblyscript/http) in
the Modus SDK to interact with the host.

This connection type is also used for [GraphQL APIs](/modus/sdk/graphql) and to
invoke externally hosted AI [models](/modus/sdk/models).
This connection type is also used for
[GraphQL APIs](/modus/sdk/assemblyscript/graphql) and to invoke externally
hosted AI [models](/modus/sdk/assemblyscript/models).

**Example:**

Expand Down Expand Up @@ -246,94 +248,92 @@ This example specifies a query parameter named `key` provided by a secret named
</Accordion>
</ResponseField>

### PostgreSQL connection
### Dgraph connection

This connection type supports connecting to PostgreSQL databases. You can use
the [PostgreSQL APIs](/modus/sdk/postgresql) in the Modus SDK to interact with
the database.
This connection type supports connecting to Dgraph databases. You can use the
[Dgraph APIs](/modus/sdk/assemblyscript/dgraph) in the Modus SDK to interact
with the database.

**Example:**

```json modus.json
{
"connections": {
"my-database": {
"type": "postgresql",
"connString": "postgresql://{{PG_USER}}:{{PG_PASSWORD}}@db.example.com:5432/data?sslmode=require"
"my-dgraph": {
"type": "dgraph",
"grpcTarget": "frozen-mango.grpc.eu-central-1.aws.cloud.dgraph.io:443",
"key": "{{DGRAPH_API_KEY}}"
}
}
}
```

<ResponseField name="type" type="string" required>
Always set to `"postgresql"` for this connection type.
Always set to `"dgraph"` for this connection type.
</ResponseField>

<ResponseField name="connString" type="string" required>
The connection string for the PostgreSQL database.

Values may include variables using the `{{VARIABLE}}` template syntax, which
resolve at runtime to secrets provided for each connection, via the Hypermode
Console.

The connection string in the preceding example includes:

- A username and password provided by secrets named `PG_USER` & `PG_PASSWORD`
- A host named `db.example.com` on port `5432`
- A database named `data`
- SSL mode set to `require` - which is highly recommended for secure connections

Refer to
[the PostgreSQL documentation](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING)
for more details on connection strings.

<Tip>

Managed PostgreSQL providers often provide a pre-made connection string for you
to copy. Check your provider's documentation for details.

For example, if using Neon, refer to the
[Neon documentation](https://neon.tech/docs/connect/connect-from-any-app).

</Tip>
<ResponseField name="grpcTarget" type="string" required>
The gRPC target for the Dgraph database.
</ResponseField>

<ResponseField name="key" type="string" required>
The API key for the Dgraph database.
</ResponseField>

### Dgraph connection
### MySQL connection

This connection type supports connecting to Dgraph databases. You can use the
[Dgraph APIs](/modus/sdk/dgraph) in the Modus SDK to interact with the database.
This connection type supports connecting to MySQL databases. You can use the
[MySQL APIs](/modus/sdk/assemblyscript/mysql) in the Modus SDK to interact with
the database.

**Example:**

```json modus.json
{
"connections": {
"my-dgraph": {
"type": "dgraph",
"grpcTarget": "frozen-mango.grpc.eu-central-1.aws.cloud.dgraph.io:443",
"key": "{{DGRAPH_API_KEY}}"
"my-database": {
"type": "mysql",
"connString": "mysql://{{USERNAME}}:{{PASSWORD}}@db.example.com:3306/dbname?tls=true"
}
}
}
```

<ResponseField name="type" type="string" required>
Always set to `"dgraph"` for this connection type.
Always set to `"mysql"` for this connection type.
</ResponseField>

<ResponseField name="grpcTarget" type="string" required>
The gRPC target for the Dgraph database.
</ResponseField>
<ResponseField name="connString" type="string" required>
The connection string for the MySQL database.

Values may include variables using the `{{VARIABLE}}` template syntax, which
resolve at runtime to secrets provided for each connection, via the Hypermode
Console.

The connection string in the preceding example includes:

- A username and password provided by secrets named `USERNAME` & `PASSWORD`
- A host named `db.example.com` on port `3306`
- A database named `dbname`
- Encryption enabled via `tls=true` - which is highly recommended for secure
connections

Set the connection string using a URI format
[as described in the MySQL documentation](https://dev.mysql.com/doc/refman/8.4/en/connecting-using-uri-or-key-value-pairs.html#connecting-using-uri).

However, any optional parameters provided should be in the form specified by the
Go MySQL driver used by the Modus Runtime,
[as described here](https://github.com/go-sql-driver/mysql/blob/master/README.md#parameters)

For example, use `tls=true` to enable encryption (not `sslmode=require`).

<ResponseField name="key" type="string" required>
The API key for the Dgraph database.
</ResponseField>

### Neo4j connection

This connection type supports connecting to Neo4j databases. You can use the
[Neo4j APIs](/modus/sdk/neo4j) in the Modus SDK to interact with the database.
[Neo4j APIs](/modus/sdk/assemblyscript/neo4j) in the Modus SDK to interact with
the database.

**Example:**

Expand Down Expand Up @@ -366,6 +366,59 @@ This connection type supports connecting to Neo4j databases. You can use the
The password for the Neo4j database.
</ResponseField>

### PostgreSQL connection

This connection type supports connecting to PostgreSQL databases. You can use
the [PostgreSQL APIs](/modus/sdk/assemblyscript/postgresql) in the Modus SDK to
interact with the database.

**Example:**

```json modus.json
{
"connections": {
"my-database": {
"type": "postgresql",
"connString": "postgresql://{{PG_USER}}:{{PG_PASSWORD}}@db.example.com:5432/data?sslmode=require"
}
}
}
```

<ResponseField name="type" type="string" required>
Always set to `"postgresql"` for this connection type.
</ResponseField>

<ResponseField name="connString" type="string" required>
The connection string for the PostgreSQL database.

Values may include variables using the `{{VARIABLE}}` template syntax, which
resolve at runtime to secrets provided for each connection, via the Hypermode
Console.

The connection string in the preceding example includes:

- A username and password provided by secrets named `PG_USER` & `PG_PASSWORD`
- A host named `db.example.com` on port `5432`
- A database named `data`
- SSL mode set to `require` - which is highly recommended for secure connections

Refer to
[the PostgreSQL documentation](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING)
for more details on connection strings.

<Tip>

Managed PostgreSQL providers often provide a pre-made connection string for you
to copy. Check your provider's documentation for details.

For example, if using Neon, refer to the
[Neon documentation](https://neon.tech/docs/connect/connect-from-any-app).

</Tip>

</ResponseField>

### Working locally with secrets

When you run your app locally using `modus dev`, the runtime replaces the
Expand Down
Loading
Loading