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

rename some things in the sdk #2809

Merged
merged 3 commits into from
Jan 15, 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
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class DockerProcedureContainer {
) {
const subcontainer = await SubContainer.of(
effects,
{ id: data.image },
{ imageId: data.image },
name,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const polyfillEffects = (
return startSdk
.runCommand(
effects,
{ id: manifest.main.image },
{ imageId: manifest.main.image },
commands,
{},
commands.join(" "),
Expand Down Expand Up @@ -165,7 +165,7 @@ export const polyfillEffects = (
await startSdk
.runCommand(
effects,
{ id: manifest.main.image },
{ imageId: manifest.main.image },
commands,
{
mounts: [
Expand Down Expand Up @@ -207,7 +207,7 @@ export const polyfillEffects = (
await startSdk
.runCommand(
effects,
{ id: manifest.main.image },
{ imageId: manifest.main.image },
commands,
{
mounts: [
Expand Down
8 changes: 7 additions & 1 deletion core/startos/src/net/host/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ use crate::net::acme::AcmeProvider;
use crate::prelude::*;
use crate::util::serde::{display_serializable, HandlerExtSerde};

#[derive(Clone, Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all_fields = "camelCase")]
#[serde(tag = "kind")]
#[ts(export)]
pub enum HostAddress {
Onion {
#[ts(type = "string")]
address: OnionAddressV3,
},
Domain {
#[ts(type = "string")]
address: InternedString,
public: bool,
acme: Option<AcmeProvider>,
Expand Down
9 changes: 5 additions & 4 deletions core/startos/src/net/host/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,20 +221,21 @@ pub async fn list_bindings(
.de()
}

#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
pub struct SetPublicParams {
#[ts(export)]
pub struct BindingSetPublicParams {
internal_port: u16,
#[arg(long)]
public: Option<bool>,
}

pub async fn set_public(
ctx: RpcContext,
SetPublicParams {
BindingSetPublicParams {
internal_port,
public,
}: SetPublicParams,
}: BindingSetPublicParams,
(package, host): (PackageId, HostId),
) -> Result<(), Error> {
ctx.db
Expand Down
4 changes: 2 additions & 2 deletions core/startos/src/net/network_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ async fn list_interfaces(

#[derive(Debug, Clone, Deserialize, Serialize, Parser, TS)]
#[ts(export)]
struct SetPublicParams {
struct NetworkInterfaceSetPublicParams {
#[ts(type = "string")]
interface: InternedString,
public: Option<bool>,
}

async fn set_public(
ctx: RpcContext,
SetPublicParams { interface, public }: SetPublicParams,
NetworkInterfaceSetPublicParams { interface, public }: NetworkInterfaceSetPublicParams,
) -> Result<(), Error> {
ctx.net_controller
.net_iface
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type SetPublicParams = { interface: string; public: boolean | null }
export type BindingSetPublicParams = {
internalPort: number
public: boolean | null
}
11 changes: 11 additions & 0 deletions sdk/base/lib/osBindings/HostAddress.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { AcmeProvider } from "./AcmeProvider"

export type HostAddress =
| { kind: "onion"; address: string }
| {
kind: "domain"
address: string
public: boolean
acme: AcmeProvider | null
}
6 changes: 6 additions & 0 deletions sdk/base/lib/osBindings/NetworkInterfaceSetPublicParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export type NetworkInterfaceSetPublicParams = {
interface: string
public: boolean | null
}
4 changes: 3 additions & 1 deletion sdk/base/lib/osBindings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export { BackupTargetFS } from "./BackupTargetFS"
export { Base64 } from "./Base64"
export { BindId } from "./BindId"
export { BindInfo } from "./BindInfo"
export { BindingSetPublicParams } from "./BindingSetPublicParams"
export { BindOptions } from "./BindOptions"
export { BindParams } from "./BindParams"
export { Blake3Commitment } from "./Blake3Commitment"
Expand Down Expand Up @@ -97,6 +98,7 @@ export { Governor } from "./Governor"
export { Guid } from "./Guid"
export { HardwareRequirements } from "./HardwareRequirements"
export { HealthCheckId } from "./HealthCheckId"
export { HostAddress } from "./HostAddress"
export { HostId } from "./HostId"
export { HostKind } from "./HostKind"
export { HostnameInfo } from "./HostnameInfo"
Expand Down Expand Up @@ -131,6 +133,7 @@ export { NamedHealthCheckResult } from "./NamedHealthCheckResult"
export { NamedProgress } from "./NamedProgress"
export { NetInfo } from "./NetInfo"
export { NetworkInterfaceInfo } from "./NetworkInterfaceInfo"
export { NetworkInterfaceSetPublicParams } from "./NetworkInterfaceSetPublicParams"
export { NetworkInterfaceType } from "./NetworkInterfaceType"
export { OnionHostname } from "./OnionHostname"
export { OsIndex } from "./OsIndex"
Expand Down Expand Up @@ -176,7 +179,6 @@ export { SetIconParams } from "./SetIconParams"
export { SetMainStatusStatus } from "./SetMainStatusStatus"
export { SetMainStatus } from "./SetMainStatus"
export { SetNameParams } from "./SetNameParams"
export { SetPublicParams } from "./SetPublicParams"
export { SetStoreParams } from "./SetStoreParams"
export { SetupExecuteParams } from "./SetupExecuteParams"
export { SetupProgress } from "./SetupProgress"
Expand Down
18 changes: 7 additions & 11 deletions sdk/package/lib/StartSdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,14 @@ export class StartSdk<Manifest extends T.SDKManifest, Store> {
}),
},

host: {
// static: (effects: Effects, id: string) =>
// new StaticHost({ id, effects }),
// single: (effects: Effects, id: string) =>
// new SingleHost({ id, effects }),
multi: (effects: Effects, id: string) => new MultiHost({ id, effects }),
MultiHost: {
of: (effects: Effects, id: string) => new MultiHost({ id, effects }),
},
nullIfEmpty,
runCommand: async <A extends string>(
effects: Effects,
image: {
id: keyof Manifest["images"] & T.ImageId
imageId: keyof Manifest["images"] & T.ImageId
sharedRun?: boolean
},
command: T.CommandType,
Expand Down Expand Up @@ -548,7 +544,7 @@ export class StartSdk<Manifest extends T.SDKManifest, Store> {
inputSpecSpec,
async ({ effects, input }) => {
// ** UI multi-host **
const uiMulti = sdk.host.multi(effects, 'ui-multi')
const uiMulti = sdk.MultiHost.of(effects, 'ui-multi')
const uiMultiOrigin = await uiMulti.bindPort(80, {
protocol: 'http',
})
Expand Down Expand Up @@ -580,7 +576,7 @@ export class StartSdk<Manifest extends T.SDKManifest, Store> {
const uiReceipt = await uiMultiOrigin.export([primaryUi, adminUi])

// ** API multi-host **
const apiMulti = sdk.host.multi(effects, 'api-multi')
const apiMulti = sdk.MultiHost.of(effects, 'api-multi')
const apiMultiOrigin = await apiMulti.bindPort(5959, {
protocol: 'http',
})
Expand Down Expand Up @@ -685,7 +681,7 @@ export class StartSdk<Manifest extends T.SDKManifest, Store> {
of(
effects: Effects,
image: {
id: T.ImageId & keyof Manifest["images"]
imageId: T.ImageId & keyof Manifest["images"]
sharedRun?: boolean
},
name: string,
Expand Down Expand Up @@ -1414,7 +1410,7 @@ export class StartSdk<Manifest extends T.SDKManifest, Store> {

export async function runCommand<Manifest extends T.SDKManifest>(
effects: Effects,
image: { id: keyof Manifest["images"] & T.ImageId; sharedRun?: boolean },
image: { imageId: keyof Manifest["images"] & T.ImageId; sharedRun?: boolean },
command: string | [string, ...string[]],
options: CommandOptions & {
mounts?: { path: string; options: MountOptions }[]
Expand Down
2 changes: 1 addition & 1 deletion sdk/package/lib/mainFn/CommandController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class CommandController {
effects: T.Effects,
subcontainer:
| {
id: keyof Manifest["images"] & T.ImageId
imageId: keyof Manifest["images"] & T.ImageId
sharedRun?: boolean
}
| SubContainer,
Expand Down
2 changes: 1 addition & 1 deletion sdk/package/lib/mainFn/Daemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class Daemon {
effects: T.Effects,
subcontainer:
| {
id: keyof Manifest["images"] & T.ImageId
imageId: keyof Manifest["images"] & T.ImageId
sharedRun?: boolean
}
| SubContainer,
Expand Down
2 changes: 1 addition & 1 deletion sdk/package/lib/mainFn/Daemons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type DaemonsParams<
subcontainer:
| {
/** The ID of the image. Must be one of the image IDs declared in the manifest */
id: keyof Manifest["images"] & T.ImageId
imageId: keyof Manifest["images"] & T.ImageId
/**
* Whether or not to share the `/run` directory with the parent container.
* This is useful if you are trying to connect to a service that exposes a unix domain socket or auth cookie via the `/run` directory
Expand Down
2 changes: 1 addition & 1 deletion sdk/package/lib/test/host.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { sdk } from "../test/output.sdk"
describe("host", () => {
test("Testing that the types work", () => {
async function test(effects: Effects) {
const foo = sdk.host.multi(effects, "foo")
const foo = sdk.MultiHost.of(effects, "foo")
const fooOrigin = await foo.bindPort(80, {
protocol: "http" as const,
preferredExternalPort: 80,
Expand Down
10 changes: 5 additions & 5 deletions sdk/package/lib/util/SubContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ export class SubContainer implements ExecSpawnable {
}
static async of(
effects: T.Effects,
image: { id: T.ImageId; sharedRun?: boolean },
image: { imageId: T.ImageId; sharedRun?: boolean },
name: string,
) {
const { id, sharedRun } = image
const { imageId, sharedRun } = image
const [rootfs, guid] = await effects.subcontainer.createFs({
imageId: id as string,
imageId,
name,
})

Expand All @@ -111,12 +111,12 @@ export class SubContainer implements ExecSpawnable {
await execFile("mount", ["--rbind", from, to])
}

return new SubContainer(effects, id, rootfs, guid)
return new SubContainer(effects, imageId, rootfs, guid)
}

static async with<T>(
effects: T.Effects,
image: { id: T.ImageId; sharedRun?: boolean },
image: { imageId: T.ImageId; sharedRun?: boolean },
mounts: { options: MountOptions; path: string }[],
name: string,
fn: (subContainer: SubContainer) => Promise<T>,
Expand Down
4 changes: 2 additions & 2 deletions sdk/package/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk/package/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@start9labs/start-sdk",
"version": "0.3.6-beta.3",
"version": "0.3.6-beta.4",
"description": "Software development kit to facilitate packaging services for StartOS",
"main": "./package/lib/index.js",
"types": "./package/lib/index.d.ts",
Expand Down