Skip to content

Latest commit

 

History

History
163 lines (119 loc) · 11.9 KB

File metadata and controls

163 lines (119 loc) · 11.9 KB

Desktop

(desktop)

Overview

Desktop app endpoints

Available Operations

checkUpdate

Returns the latest desktop app version info in Tauri updater format. Download URLs are rewritten to proxy through this API.

Example Usage

import { Midday } from "@midday-ai/sdk";

const midday = new Midday({
  security: {
    oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
  },
});

async function run() {
  const result = await midday.desktop.checkUpdate();

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MiddayCore } from "@midday-ai/sdk/core.js";
import { desktopCheckUpdate } from "@midday-ai/sdk/funcs/desktopCheckUpdate.js";

// Use `MiddayCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const midday = new MiddayCore({
  security: {
    oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
  },
});

async function run() {
  const res = await desktopCheckUpdate(midday);
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("desktopCheckUpdate failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.CheckDesktopUpdateResponse>

Errors

Error Type Status Code Content Type
errors.CheckDesktopUpdateBadGatewayError 502 application/json
errors.APIError 4XX, 5XX */*

downloadUpdate

Proxies the download of a desktop app update artifact from GitHub releases. Only URLs pointing to the midday-ai/midday repository are accepted.

Example Usage

import { Midday } from "@midday-ai/sdk";

const midday = new Midday({
  security: {
    oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
  },
});

async function run() {
  const result = await midday.desktop.downloadUpdate({
    url: "https://github.com/midday-ai/midday/releases/download/midday-v1.0.0/Midday.app.tar.gz",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { MiddayCore } from "@midday-ai/sdk/core.js";
import { desktopDownloadUpdate } from "@midday-ai/sdk/funcs/desktopDownloadUpdate.js";

// Use `MiddayCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const midday = new MiddayCore({
  security: {
    oauth2: process.env["MIDDAY_OAUTH2"] ?? "",
  },
});

async function run() {
  const res = await desktopDownloadUpdate(midday, {
    url: "https://github.com/midday-ai/midday/releases/download/midday-v1.0.0/Midday.app.tar.gz",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("desktopDownloadUpdate failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.DownloadDesktopUpdateRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<ReadableStream>

Errors

Error Type Status Code Content Type
errors.DownloadDesktopUpdateBadRequestError 400 application/json
errors.DownloadDesktopUpdateBadGatewayError 502 application/json
errors.APIError 4XX, 5XX */*