UiPath Documentation
functions
latest
false
Functions ユーザー ガイド
  • 概要
    • Functions について
    • ライセンス
  • JavaScript 関数
  • Python の関数
  • デプロイして実行する
重要 :
このコンテンツは機械翻訳によって処理されています。 新しいコンテンツの翻訳は、およそ 1 ~ 2 週間で公開されます。

スタート アップ ガイド

CLI をインストールし、JavaScript または TypeScript 関数プロジェクトをスキャフォールディングして、最初の関数をローカルで実行します。

このページでは、CLI のインストール、プロジェクトのスキャフォールディング、および最初の JavaScript 関数のローカル実行について説明します。

前提条件​

  • Node.js 20 以降。
  • uip CLI と関数ツール:
npm install -g @uipath/cli
uip tools install @uipath/function-tool
npm install -g @uipath/cli
uip tools install @uipath/function-tool
  • パブリッシュおよび呼び出しに使用する、Orchestrator へのアクセス権を持つ UiPath アカウント。

プロジェクトのスキャフォールディング​

uip function new my-functions --kind http
cd my-functions
uip function new my-functions --kind http
cd my-functions

--kind http creates a project of HTTP functions (targetRuntime javascript-server). --kind job, the default, creates a project of job functions (javascript). TypeScript is the default language; pass -l js for JavaScript, or --empty to skip the sample function.

The project contains:

ファイル目的
functions/hello.tsYour function. Each file directly in functions/ is one function.
functions/_*.tsShared helpers. A file whose name starts with an underscore is not a function.
uipath.jsonThe project's targetRuntime and the list of functions. The CLI keeps the list in sync with functions/.
project.uiprojThe project name and its main function.
package.jsonpackage-lock.json、tsconfig.json標準のプロジェクト ファイル

最初の関数を記述する​

import { defineFunction, defineSchema } from "@uipath/coded-functions-js-sdk";

interface HelloInput {
  name: string;
}

interface HelloOutput {
  message: string;
}

export default defineFunction({
  name: "hello",
  method: "POST",
  path: "/hello",
  input: defineSchema<HelloInput>(),
  output: defineSchema<HelloOutput>(),
  handler: async (input) => ({ message: `Hello, ${input.name}!` }),
});
import { defineFunction, defineSchema } from "@uipath/coded-functions-js-sdk";

interface HelloInput {
  name: string;
}

interface HelloOutput {
  message: string;
}

export default defineFunction({
  name: "hello",
  method: "POST",
  path: "/hello",
  input: defineSchema<HelloInput>(),
  output: defineSchema<HelloOutput>(),
  handler: async (input) => ({ message: `Hello, ${input.name}!` }),
});

defineSchema<T>() は TypeScript インターフェイスから JSON スキーマを派生させるため、同じ型がコントラクトを宣言し、ハンドラーに型付けします。JavaScript プロジェクトでは、代わりに JSON スキーマ オブジェクトを渡します。

The method and path make this an HTTP function. A job function declares neither. See Building JavaScript functions.

ローカルで実行する​

uip function serve
uip function serve

これにより、ホット リロード サーバーが http://localhost:7070で起動します。関数を呼び出します。

curl -X POST http://localhost:7070/hello \
  -H "Content-Type: application/json" \
  -d '{"name":"Alice"}'
# {"message":"Hello, Alice!"}
curl -X POST http://localhost:7070/hello \
  -H "Content-Type: application/json" \
  -d '{"name":"Alice"}'
# {"message":"Hello, Alice!"}

To reach Orchestrator from a local run, put UIPATH_ACCESS_TOKEN, UIPATH_BASE_URL, UIPATH_ORG_ID and UIPATH_TENANT_ID in a .env file at the project root. serve loads it.

次のステップ​

このページは役に立ちましたか?

接続

ヘルプ リソース サポート(opens in new window)

学習する UiPath アカデミー(opens in new window)

質問する UiPath フォーラム(opens in new window)

最新情報を取得