@uipath/uipath-extensions-sdk 0.1.23 → 0.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -23
- package/dist/adopt.js +105 -79
- package/dist/adopt.js.map +1 -1
- package/dist/cli.d.ts +0 -3
- package/dist/cli.js +3 -41
- package/dist/cli.js.map +1 -1
- package/dist/commands/check-project.d.ts +17 -0
- package/dist/commands/check-project.js +67 -0
- package/dist/commands/check-project.js.map +1 -0
- package/dist/commands/new.js +3 -5
- package/dist/commands/new.js.map +1 -1
- package/dist/commands/pack.d.ts +2 -1
- package/dist/commands/pack.js +90 -98
- package/dist/commands/pack.js.map +1 -1
- package/dist/commands/submit.d.ts +0 -1
- package/dist/commands/submit.js +10 -13
- package/dist/commands/submit.js.map +1 -1
- package/dist/commands/upload.d.ts +6 -1
- package/dist/commands/upload.js +95 -19
- package/dist/commands/upload.js.map +1 -1
- package/dist/commands/validate-python.js +34 -8
- package/dist/commands/validate-python.js.map +1 -1
- package/dist/commands/validate.d.ts +1 -0
- package/dist/commands/validate.js +2 -1
- package/dist/commands/validate.js.map +1 -1
- package/dist/github.d.ts +1 -1
- package/dist/github.js +7 -4
- package/dist/github.js.map +1 -1
- package/dist/lib.d.ts +6 -2
- package/dist/lib.js +8 -10
- package/dist/lib.js.map +1 -1
- package/dist/python-source.js +28 -15
- package/dist/python-source.js.map +1 -1
- package/dist/registrationFile.js +2 -2
- package/dist/registrationFile.js.map +1 -1
- package/dist/uip.d.ts +1 -0
- package/dist/uip.js +11 -2
- package/dist/uip.js.map +1 -1
- package/package.json +2 -2
- package/dist/commands/build-check.d.ts +0 -34
- package/dist/commands/build-check.js +0 -146
- package/dist/commands/build-check.js.map +0 -1
package/README.md
CHANGED
|
@@ -4,20 +4,21 @@ The author-facing SDK for community Maestro nodes. It holds the `new`, `init`, `
|
|
|
4
4
|
|
|
5
5
|
## Commands
|
|
6
6
|
|
|
7
|
-
None of the commands logs in to UiPath.
|
|
7
|
+
None of the commands logs in to UiPath. The commands run on Linux and macOS only. On Windows, `new`, `pack` and `upload` exit 1 with `Windows is not supported yet`.
|
|
8
|
+
|
|
8
9
|
- `uipath-extensions new <publisher/name> [--kind function|agent] [--dir <parent dir>] [--skip-install]` runs `uip function new <name> --language ts` in the parent directory (the current one by default). It keeps the layout `uip` writes: the functions stay in `functions/`, and `tsconfig.json` and the `uipath.json` function entries are not changed. The Maestro files go in `maestro/`. It removes `method` and `path` from every `defineFunction` call, sets the `name` in `package.json` to the package id `uipath-extensions.<publisher>.<name>` and the `version` to `0.1.0`, deletes the `.env.example` that `uip` writes (`submit` refuses it, and it holds credential placeholders), adds `tests` to `packOptions.directoriesExcluded` in `uipath.json` (`submit` accepts a `tests` folder, but the package gate does not accept it inside the package), keeps `@uipath/coded-functions-js-sdk` in `devDependencies`, adds `@types/node` to `devDependencies` (the connection helper reads `process.env`, so `validate` needs the Node types), writes the script `pack: uip function pack` and no `validate` script, replaces `functions/hello.ts` with a starter function whose input and output are JSON Schema literals, and writes the template `uipath-extensions.json` at the project root, the connection helper `maestro/connection.ts` and a starter fixture `fixtures/example.json` (`{ "operation": "run", "input": { "name": "World" } }`, a placeholder to replace with real cases). The project does not depend on this SDK, so `pack: uip function pack` is the only script. It then runs `npm install --include=dev` in the new project, so the type packages are ready for `validate` even when `NODE_ENV=production` or `omit=dev` is set. `--skip-install` leaves that step out, and `new` then prints `npm install` as the first of the next steps. If that `npm install` fails, `new` keeps the project, prints the npm error and exits with code 1. The starter template has no `repository`, because the node folder goes to the index repo as one pull request and no author repo exists. It writes `author` with the publisher as the name, in title case, and `https://github.com/<publisher>` as the url, for the author to correct. If any step before that `npm install` fails after `uip` ran, `new` deletes the project directory it created. `uip function new` runs its own install first, before the SDK is added, and it has no option to skip that install. When that install fails, `uip` removes the project and `new` reports the `uip` error.
|
|
9
10
|
With `--kind agent`, `new` runs `uip codedagent new <name> --dir <name>` instead (run `uip codedagent setup` first, in an environment with an agent framework package such as `uipath-langchain` installed: without one `uip codedagent new` exits 1 with "No agent framework is installed"), sets `name` in the `[project]` table of `pyproject.toml` to the package id and `version` to `0.1.0`, replaces the scaffold's placeholder `authors` with the publisher name, and writes the template `uipath-extensions.json`. It writes no `package.json` and no connection helper, and runs no install. `--kind` takes `function` (the default) or `agent`. The next steps for an agent are `uip codedagent init`, `uipath-extensions init --yes` and `uipath-extensions validate`.
|
|
10
|
-
- `uipath-extensions init [--id <publisher>.<name>] [--kind function|agent] [--yes] [--dir <project dir>] [--index <owner/repo>]` calls the library `init`. It plans the adopt (see Adopt) and prints the plan as a diff. Without `--yes` it writes nothing and exits 1. With `--yes` it writes the plan and prints the files it wrote and the defaults it generated. A project that needs no write prints `Nothing to write, the project is already adopted.` and exits 0, so a second run changes nothing. `--id` names the node when the `package.json` name is not a package id and the command does not run in a terminal. In a terminal `init` asks for it. `--index` picks the repository whose `policy/gate-library.yaml` sets the schema of a new template. It needs `uip` because it packs. It also needs `gh` signed in when the project has no `uipath-extensions.json`, because it reads that policy file from the index repo.
|
|
11
|
-
For a Python coded function with one entry in `uipath.json.functions`, run `uip function init` first, then `extension init` and `uv lock`. `init` decides whether the project is a `function` or an `agent` and records it in `pyproject.toml` as `kind` under `[tool.uipath-extensions]`, which `submit` copies into a new registration. It decides in this order: `--kind`, then a `kind` already in `pyproject.toml`, then `entry-points.json` (every entry has `type` `function`, as `uip function init` writes, or `agent`), then `uipath.json` (a `.py` entry under `functions` means a function). It prints the kind and where it came from. `--kind` or a recorded kind that disagrees with `entry-points.json` or `uipath.json` fails. When nothing decides, `init` asks in a terminal and fails off one with `pass --kind function|agent`. The kind is a write, so it needs `--yes`. On a coded agent project (no Python function in `uipath.json`), `--kind agent` is accepted and nothing is recorded, because the index reads a `pyproject.toml` folder with no kind as an agent, and `--kind function` fails. `--kind` on a project with no `pyproject.toml` fails. `extension validate` checks a fresh native package from an isolated source snapshot. It uses `uv lock --check` offline and does not refresh the lock, install dependencies, run the user function, or approve catalog publishing. `extension submit --dry-run` validates the files and previews the registry submission without writing to GitHub. `extension upload` sends the checked archive only to your personal workspace, using the version in `pyproject.toml`; bump that version and refresh `uv.lock` before re-uploading. Shared release upload and
|
|
12
|
-
- `uipath-extensions validate [--dir <project dir>]` calls the library `validate`. It plans the adopt (see Adopt) on the project folder with `offline: true`, with no call to `gh` or the index. When the plan holds any write, or its only error is the missing id, `validate` stops. It runs no gate, writes nothing, exits 1 and tells the author to run `init` on that folder. Any other plan error exits 1 with the error. For a JavaScript coded function, when the plan holds no write, `validate` loads `uipath-extensions.json`, packs the project folder and runs the registered JavaScript gates in local mode on the completed manifest, which it builds in memory from the template and the package. It prints one line per gate and exits 1 when a gate fails. A gate that needs an input a local run does not have prints `skipped`. A skipped gate has not checked anything. It needs `uip` because it packs,
|
|
11
|
+
- `uipath-extensions init [--id <publisher>.<name>] [--kind function|agent] [--yes] [--dir <project dir>] [--index <owner/repo>]` calls the library `init`. It plans the adopt (see Adopt) and prints the plan as a diff. Without `--yes` it writes nothing and exits 1. With `--yes` it writes the plan and prints the files it wrote and the defaults it generated. A project that needs no write prints `Nothing to write, the project is already adopted.` and exits 0, so a second run changes nothing. `--id` names the node when the `package.json` name is not a package id and the command does not run in a terminal. In a terminal `init` asks for it. When the project already has a package id, an `--id` that names another id fails and writes nothing. `--index` picks the repository whose `policy/gate-library.yaml` sets the schema of a new template. It needs `uip` because it packs. It also needs `gh` signed in when the project has no `uipath-extensions.json`, because it reads that policy file from the index repo.
|
|
12
|
+
For a Python coded function with one entry in `uipath.json.functions`, run `uip function init` first, then `extension init` and `uv lock`. `init` sets `packOptions.includeUvLock` to `true` and `packOptions.directoriesExcluded` to `["fixtures"]` in `uipath.json`, because the index packs the committed file, and writes a starter `fixtures/example.json` when the project has no fixture. `submit` sends the `fixtures/*.json` files at the top of that folder and refuses a project with no fixture that is not a `.fault.json`. The package leaves `fixtures/` out. `init` decides whether the project is a `function` or an `agent` and records it in `pyproject.toml` as `kind` under `[tool.uipath-extensions]`, which `submit` copies into a new registration. It decides in this order: `--kind`, then a `kind` already in `pyproject.toml`, then `entry-points.json` (every entry has `type` `function`, as `uip function init` writes, or `agent`), then `uipath.json` (a `.py` entry under `functions` means a function). It prints the kind and where it came from. `--kind` or a recorded kind that disagrees with `entry-points.json` or `uipath.json` fails. When nothing decides, `init` asks in a terminal and fails off one with `pass --kind function|agent`. The kind is a write, so it needs `--yes`. On a coded agent project (no Python function in `uipath.json`), `--kind agent` is accepted and nothing is recorded, because the index reads a `pyproject.toml` folder with no kind as an agent, and `--kind function` fails. `--kind` on a project with no `pyproject.toml` fails. `extension validate` checks a fresh native package from an isolated source snapshot. Its source scan parses the Python files with the interpreter `uv python find` returns for the project, and with `python3` on the PATH when uv finds none, so syntax the project's Python accepts is not reported because an older `python3` comes first. The scan fails with a message that names both versions when that interpreter is older than `requires-python`, and a file it cannot parse names the Python version that parsed it. The index CI parses with its own pinned Python. It uses `uv lock --check` offline and does not refresh the lock, install dependencies, run the user function, or approve catalog publishing. `extension submit --dry-run` validates the files and previews the registry submission without writing to GitHub. `extension upload` sends the checked archive only to your personal workspace, using the version in `pyproject.toml`; bump that version and refresh `uv.lock` before re-uploading. `extension submit` opens the registry pull request the same way as for a Node function, with `kind: function` in a new registration. Shared release upload stays blocked. `extension validate` also runs `python-source-scan` and `python-function-shape` locally and prints each finding as `file:line: message`. The scan allows only a built-in list of standard library modules (`abc`, `collections`, `dataclasses`, `datetime`, `json`, `logging`, `os`, `pathlib`, `re`, `typing` and similar; `os`, `sys`, `asyncio`, `io`, `logging`, `typing`, `inspect`, `types` and `urllib` also have member lists, so `os.listdir`, `sys.exit` and `urllib.request` are refused) and refuses any other standard library import such as `timeit`, `pdb` or `unittest.mock`; the registry policy `pythonAllowedStdlib` can only add modules. It also bans risky calls, undeclared third-party imports and hard-coded URLs, and it also bans network access, because connector support for Python functions is a planned follow-up; the ban is a source scan and cannot see a call built at run time. The registry's allow list of dependencies and bans is not read locally. It is enforced only in CI, so a function that passes `validate` can still be refused there.
|
|
13
|
+
- `uipath-extensions validate [--dir <project dir>]` calls the library `validate`. It plans the adopt (see Adopt) on the project folder with `offline: true`, with no call to `gh` or the index. When the plan holds any write, or its only error is the missing id, `validate` stops. It runs no gate, writes nothing, exits 1 and tells the author to run `init` on that folder. Any other plan error exits 1 with the error. For a JavaScript coded function, when the plan holds no write, `validate` loads `uipath-extensions.json`, packs the project folder and runs the registered JavaScript gates in local mode on the completed manifest, which it builds in memory from the template and the package. It prints one line per gate and exits 1 when a gate fails. A gate that needs an input a local run does not have prints `skipped`. A skipped gate has not checked anything. It needs `uip` because it packs. The pack runs in a temporary copy, so it leaves only the nupkg in the project folder.
|
|
13
14
|
- `uipath-extensions pack [--dir <project dir>]` runs the `pack` steps below.
|
|
14
15
|
|
|
15
|
-
For an adopted Python coded function, `validate` and `pack` use a private copy of the checked project files and verify the resulting archive, rather than running the JavaScript gates. `validate` discards its working files; `pack` returns the path to the checked archive. These commands need `uv` and the Python-capable `uip`. The lockfile must pass an offline consistency check. Python upload uses the checked archive and requires a uniquely mapped Personal workspace feed; Python does not support an explicit `--feed-id`. Upload starts a job only if you pass `--run`. Python `submit --dry-run` is read-only; live submit
|
|
16
|
+
For an adopted Python coded function, `validate` and `pack` use a private copy of the checked project files and verify the resulting archive, rather than running the JavaScript gates. `validate` discards its working files; `pack` returns the path to the checked archive. These commands need `uv` and the Python-capable `uip`. The lockfile must pass an offline consistency check. Python upload uses the checked archive and requires a uniquely mapped Personal workspace feed; Python does not support an explicit `--feed-id`. Upload starts a job only if you pass `--run`. Python `submit --dry-run` is read-only; live submit is not enabled for Python coded functions.
|
|
16
17
|
|
|
17
18
|
The private copy normalizes CRLF and CR line endings to LF in text, matching the native packer. It does not change the original files or icon bytes. The archive must contain well-formed NuGet metadata with the project's name and version.
|
|
18
|
-
|
|
19
|
-
- `uipath-extensions
|
|
20
|
-
- `uipath-extensions
|
|
19
|
+
|
|
20
|
+
- `uipath-extensions upload [--id <publisher>.<name>] [--yes] [--dir <project dir>] [--input <json>] [--run] [--feed-id <id>]` calls the library `uploadWithResult` in its default mode and runs the `upload` steps below. On a project that is not adopted it plans the adopt first, as `submit` does (see Adopt). `--yes` applies the adopt writes and then goes on to the upload in the same run. Without it a plan with writes prints as a diff and the command exits 1 and writes none of the adopt files. Running `init` first writes the same files without the upload. `--id` names the node when the `package.json` name is not a package id and the command does not run in a terminal. It needs `uip login`. It starts a job only with `--run`.
|
|
21
|
+
- `uipath-extensions submit [--id <publisher>.<name>] [--yes] [--security-contact <email>] [--dir <project dir>] [--index <owner/repo>] [--dry-run]` calls the library `submitWithResult` and runs the `submit` steps below after the adopt step. `--id` names the node when the `package.json` name is not a package id and the command does not run in a terminal. In a terminal `submit` asks for it. `--yes` applies the adopt writes and then goes on to the checks and the pull request in the same run. Without it a plan with writes prints as a diff and exits 1. `--security-contact` is needed for a first registration and replaces the stored contact on a later version. `--index` defaults to `UiPath/uipath-extensions`, and a sandbox index repo can stand in for it. `--dry-run` prints what `submit` would do and writes nothing to GitHub.
|
|
21
22
|
|
|
22
23
|
Each command accepts only its own options. An option of another command exits 2 and prints the usage text.
|
|
23
24
|
|
|
@@ -62,7 +63,7 @@ The display fields are bounded. The SDK and the `contract` gate enforce these ru
|
|
|
62
63
|
|
|
63
64
|
The template holds no schema. The function in `functions/` is the one source of the input and output schemas.
|
|
64
65
|
|
|
65
|
-
`pack` runs `uip function pack` and does not change the nupkg. The package holds the template as `uipath-extensions.json`. `validate`
|
|
66
|
+
`pack` runs `uip function pack` and does not change the nupkg. The package holds the template as `uipath-extensions.json`. `validate` reads `content/entry-points.json` from the nupkg and requires exactly one entry point. They copy that entry point's `input` and `output` into `operations[0]` of the completed manifest, and they list each `Connection` input in `credential.inputs`. They build the manifest in memory with the `version` from `package.json`, so the gates read the schemas that the package holds.
|
|
66
67
|
|
|
67
68
|
Flow reads the same schemas. It takes the input and output schemas of a Function from the entry point of the release (flow-workbench `fb24f7e`, `packages/flow-core/src/manifest/shared/argument-utils.ts`). The `entry-points-match` gate still compares the shape of the schemas in the manifest with `entry-points.json` in the package.
|
|
68
69
|
|
|
@@ -79,7 +80,7 @@ The `name` in `package.json` names a node. It is `uipath-extensions.<publisher>.
|
|
|
79
80
|
|
|
80
81
|
The node id `publisher/name` comes from the package name. The template and the manifest hold no node type, so there is no second copy of the identity to keep in step. Flow builds its own node type from the id.
|
|
81
82
|
|
|
82
|
-
A rename makes a new node. Saved flows keep pointing at the old id.
|
|
83
|
+
A rename makes a new node. Saved flows keep pointing at the old id. A new version, including a major one, keeps the id.
|
|
83
84
|
|
|
84
85
|
These rules about renames describe planned Flow behavior and are not shipped yet. Flow has no community node support on its `develop` branch (flow-workbench `fb24f7e` has no reference to `uipath-extensions`). That support is in the open pull request #6081.
|
|
85
86
|
|
|
@@ -166,10 +167,12 @@ A node may depend only on npm packages that are on the allow list. The `dependen
|
|
|
166
167
|
The list exists in two places.
|
|
167
168
|
|
|
168
169
|
- The index repo `UiPath/uipath-extensions` holds `policy/allowed-dependencies.yaml`. The index CI uses this file, so it decides whether a node is accepted.
|
|
169
|
-
- The gates package holds a copy as `DEFAULT_POLICY` in `packages/gates/src/policy.ts`. `validate`
|
|
170
|
+
- The gates package holds a copy as `DEFAULT_POLICY` in `packages/gates/src/policy.ts`. `validate` uses this copy, because it cannot read the index file.
|
|
170
171
|
|
|
171
172
|
The two lists can differ. A package that passes `validate` can still fail in the index CI, and a package that the index later allows still fails `validate` until a new SDK release carries the change. For a blocked name outside `@uipath/`, the gate message names the package and these two locations.
|
|
172
173
|
|
|
174
|
+
`submit` sets `deferAllowList` on the gate context. In that mode, `dependency-policy` reports a name that is not on the SDK copy of a list as a `review` finding. The finding names the package and says that the index CI decides. A `review` finding does not stop `submit`. The version spec checks still fail, for example an npm alias or a git or file spec. A change to the list cannot fix them. The index CI does not set `deferAllowList`, so it fails a name that is not in the index file. A reviewer then decides about the package on the pull request. `validate` does not set it, so it fails on the SDK copy as before.
|
|
175
|
+
|
|
173
176
|
Any other `@uipath/` package needs a publisher that the policy trusts, and no publisher is trusted by default. The `dependency-tree` and `license-cve` gates then check every package in the lockfile, not only the direct ones. `validate` skips both of them, and the index CI runs them. So a package on the allow list can still be refused for its own dependencies.
|
|
174
177
|
|
|
175
178
|
To ask for a new package, open a pull request against `UiPath/uipath-extensions` that adds the package name to `policy/allowed-dependencies.yaml`. Say in the description which node needs it and why no allowed package or plain code can do the job. The owners in the `CODEOWNERS` entry for `/policy/` review it. The SDK copy follows the index file in a later SDK release, and an author cannot change it from a node repo.
|
|
@@ -179,19 +182,21 @@ Check the list before you pick a library for a node. If the package is not on it
|
|
|
179
182
|
## Pack
|
|
180
183
|
|
|
181
184
|
`pack({ projectDir })` does these steps in order.
|
|
185
|
+
|
|
182
186
|
1. Loads `uipath-extensions.json` and checks it.
|
|
183
187
|
2. Fails unless the `name` in `package.json` is a package id `uipath-extensions.<publisher>.<name>`, which the packer turns into the nuspec id, and the `version` is a string.
|
|
184
|
-
3.
|
|
188
|
+
3. Copies the files the source scan selects into a temporary folder `uipath-pack-XXXX` under the system temp directory, and links the project's `node_modules` into it. A `node_modules` folder is not copied, and `.git`, `dist`, `.env` and `.uipath` are left out.
|
|
189
|
+
4. Runs `uip function pack` in that copy, then copies the nupkg back into the project (`.uipath/` or the project root, where `uip` wrote it) and removes the copy.
|
|
185
190
|
|
|
186
|
-
It returns the nupkg path, the version, the package id and the kind (`function` or `agent`). It does not read or write the nupkg, so it injects no manifest. The package holds the template file as it is. It writes no manifest into the project and does not change `package.json`. `
|
|
191
|
+
It returns the nupkg path, the version, the package id and the kind (`function` or `agent`). It does not read or write the nupkg, so it injects no manifest. The package holds the template file as it is. It writes no manifest into the project and does not change `package.json` or `uipath.json`. A folder that holds `registration.yaml` gets the file added to `packOptions.filesExcluded` in the copy's `uipath.json` only. `validate` reads the entry point from the nupkg and fails unless it lists exactly one.
|
|
187
192
|
|
|
188
|
-
`pack({ projectDir, version })` packs under a different semver while `uip function pack` runs. It sets `version` in `package.json
|
|
193
|
+
`pack({ projectDir, version })` packs under a different semver while `uip function pack` runs. It sets `version` in the copy's `package.json`, so the project's `package.json` is never edited, also when `uip` fails or the process is killed. The template is not changed, and a schema 2 template holds no version to differ.
|
|
189
194
|
|
|
190
195
|
### Agents
|
|
191
196
|
|
|
192
197
|
A folder with a `pyproject.toml` and no `package.json` is an agent project (`projectKind`). The same commands then take the agent path.
|
|
193
198
|
|
|
194
|
-
- **`pack`** reads `name` and `version` from the `[project]` table of `pyproject.toml` and runs `uip codedagent pack`, which writes `.uipath/<package id>.<version>.nupkg`.
|
|
199
|
+
- **`pack`** reads `name` and `version` from the `[project]` table of `pyproject.toml` and runs `uip codedagent pack`, which writes `.uipath/<package id>.<version>.nupkg`. It packs in a temporary copy, so `uv lock` (which `uip codedagent pack` runs) cannot change the project's `uv.lock`. With a `version`, it sets the `[project]` version in the copy only.
|
|
195
200
|
- **`init`** (adopt) runs `uip codedagent init` first when `uipath.json` or `entry-points.json` is missing, and `uv lock` when `uv.lock` is missing (so it needs `uv` on the path), with yes only: without yes it stops with `ConfirmationRequired` and changes nothing. `validate` does not run it and stops until `init` has. `upload` and `submit` run it as part of their adopt step. It reads the single entry point from the source file and runs no pack. It sets `[project].name` from `--id` when the name is not a package id, writes the template and a default icon when they are missing, lists the icon the template names in `packOptions.filesIncluded` (`assets/icon.png` unless the template names another file, from SDK 0.1.23), and sets `packOptions.includeUvLock`. It writes no fixture and no connection helper.
|
|
196
201
|
- **`validate`** runs `PYTHON_AGENT_GATES` (`uv-lockfile`, `pack-options`, `pypi-dependency-tree`, `agent-shape`, `package-id`) on a manifest built from the template and `content/entry-points.json` of the nupkg.
|
|
197
202
|
- **`upload`** packs under the dev version, sends the nupkg with `uip or packages upload --feed-id <feed>`, then creates or moves the release and starts the job as for a function.
|
|
@@ -200,6 +205,7 @@ A folder with a `pyproject.toml` and no `package.json` is an agent project (`pro
|
|
|
200
205
|
## Upload
|
|
201
206
|
|
|
202
207
|
`upload({ projectDir })` tests a node in the personal workspace of the logged in tenant. It never writes to GitHub or to the index. It does these steps in order.
|
|
208
|
+
|
|
203
209
|
1. Checks `uip login status`, and stops with `Run: uip login` when there is no session.
|
|
204
210
|
2. Finds the process feed whose name contains "Personal Workspace". `--feed-id` skips the lookup.
|
|
205
211
|
3. Packs with the version `<node version>-dev.<UTC time as YYYYMMDDHHmmss>`, so a feed that refuses a repeated version never blocks a second run.
|
|
@@ -209,6 +215,7 @@ A folder with a `pyproject.toml` and no `package.json` is an agent project (`pro
|
|
|
209
215
|
7. Looks in the personal folder for the process that Orchestrator created for the package id (see Limits), and prints its key in the note below.
|
|
210
216
|
|
|
211
217
|
The output ends with the destination.
|
|
218
|
+
|
|
212
219
|
- `Destination:` is `personal workspace feed, only you can see this build`, or `feed <id> (from --feed-id)` when you passed `--feed-id`.
|
|
213
220
|
- `Release:` names the release and says `in your personal workspace`, because the release always goes to the personal folder, whatever the feed.
|
|
214
221
|
- `Run:` is the exact `uip or jobs start <release key> --folder-key <folder key>` command. With `--run` the job result lines take its place.
|
|
@@ -220,14 +227,16 @@ The `@uipath/uipath-extensions-sdk/lib` export runs four commands from code. Eac
|
|
|
220
227
|
|
|
221
228
|
- `init({ dir, id, index, kind, yes })` plans the adopt writes, as `submit` does, and prints the diff once. For a Python function project it also decides and records the kind (see `init` under Commands). It asks for the id in a terminal when the `package.json` name is not a package id, and off a terminal a missing id returns `Failed` with the plan and `pass <publisher>.<name>`. A template that exists and is malformed returns `Failed` with the message in `instructions`, before any diff or write. A plan with writes needs `yes` (else `ConfirmationRequired` with the plan, and nothing is written). With `yes` it applies the writes and returns `Success` with `{ written, generated }`. A file that changed after the plan returns `Failed` with the plan and the instruction to run `init` again, and nothing is written. A project whose plan holds no write returns `Success` with both lists empty. There is no confirmation prompt.
|
|
222
229
|
- `validate({ dir })` plans the adopt writes on the project folder with `offline: true`. It returns `Failed` with the plan in `data` and the instruction to run `init` on the project folder when the plan holds any write or its only error is the missing id. It writes nothing and runs no gate in that case. Any other plan error returns `Failed` with the plan and the errors. A plan with no write and no error runs the gates in local mode on the project folder and returns `Success` or `GatesFailed` with the report. A malformed template, a package that cannot be packed or read, and a missing `uip` return `Failed` with the message in `instructions`, in all four commands.
|
|
223
|
-
- `
|
|
224
|
-
- `
|
|
230
|
+
- `uploadWithResult({ dir, id, yes, run, input, feedId })` plans the adopt writes when the project has no template or its `package.json` name is not a package id, as `submit` does. It never reads the index, so it needs no `gh` and writes schema 2. A plan with writes needs `yes` (else `ConfirmationRequired`). With `yes` it applies the writes and then runs the `upload` steps below in the same call. Any other template or `package.json` problem returns `Failed` before any write. The release input checks below run before the adopt writes. A run whose job does not end `Successful` returns `Failed` with the upload result and the job in `data`. With `release: true` it needs exactly one of `folderPath` and `folderKey` (else `InputRequired`), rejects `feedId`, packs once and runs the gates on that package (`GatesFailed` uploads nothing), needs `yes` (else `ConfirmationRequired`), then runs `uip or packages upload <nupkg>` with the folder flag on the package that passed the gates, under the `package.json` version.
|
|
231
|
+
- `submitWithResult({ dir, id, yes, securityContact, index, dryRun })` plans the adopt writes. A plan with writes needs `yes` (else `ConfirmationRequired`). With `yes` it applies the writes and then runs the `submit` steps below in the same call. `index` also picks the repository whose `policy/gate-library.yaml` sets the schema of a new template. The pull request body lists the fields that the adopt step generated in this run (the license when `package.json` declares none, the label, both descriptions, the operation name and the tags), and ends with the line `Gate library: <version>`. A project that an earlier run adopted has no such list.
|
|
225
232
|
|
|
226
233
|
The `release` command and its exports (`release`, `ReleaseError`, `ReleaseOptions`, `ReleaseResult`, `GatesFailedError`) are gone from the root export. A gates failure is the result code `GatesFailed`.
|
|
227
234
|
|
|
235
|
+
The root export also has `submit` and `upload`, which take other options and throw on a failure, so the two result-returning functions here are named `submitWithResult` and `uploadWithResult`. Version 0.1.23 and earlier exported them as `submit` and `upload`. This release keeps those two names as deprecated aliases of the new functions, and the next release removes them.
|
|
236
|
+
|
|
228
237
|
## Adopt
|
|
229
238
|
|
|
230
|
-
A project is adopted when it has a template, a package name that is a package id and the files its node needs. `planAdopt` reads the project and lists what is missing. It writes none of the adopt files, but it runs `uip function pack` in the project folder. That leaves the
|
|
239
|
+
A project is adopted when it has a template, a package name that is a package id and the files its node needs. `planAdopt` reads the project and lists what is missing. It writes none of the adopt files, but it runs `uip function pack` in a temporary copy of the project folder. That leaves only the nupkg in the project folder (`.uipath/` or the project root), and no field that `uip` adds to `uipath.json` reaches the project. `init`, `submit` and `upload` apply a plan to the project folder. `validate` never applies one, it stops and names `init` when the plan holds a write. When the plan holds the template or the package name, a write that fails halfway leaves the project looking unadopted, because `package.json` and the template are written last, so the next run plans everything again.
|
|
231
240
|
|
|
232
241
|
- It needs `uipath.json`, and it stops with `not a uip project, run uip function new or uip codedagent new first` when that file is missing.
|
|
233
242
|
- A `package.json` name that is not `uipath-extensions.<publisher>.<name>` becomes a write of the name from `id`, or the error `pass <publisher>.<name>` when there is no `id`.
|
|
@@ -242,22 +251,24 @@ A project is adopted when it has a template, a package name that is a package id
|
|
|
242
251
|
- A file named `.DS_Store`, `.env.example`, `.env.local`, `Thumbs.db` or `desktop.ini`, or a folder named `.idea` or `.vscode`, at any depth, becomes one write of `uipath.json` that adds the name to `packOptions.filesExcluded` or `packOptions.directoriesExcluded`. `uip function pack` and `submit` skip an entry by its bare name, and a `uip function new` project holds `.env.example`. `.env.local` can hold secrets, and the package check rejects any env file other than `.env.example`. The write keeps every other key, the indent and the trailing newline of `uipath.json`. Adopt deletes no file. When `packOptions` is not an object or the list it needs is not a list, the plan gets the error `uipath.json packOptions.<list> is not a list` and no write.
|
|
243
252
|
- Files outside the source list and an input with no description are reports, not writes. Each report names its remedy. An input with no description does not stop `submit`, because `validate` lists it as a `review` finding. A file or folder outside the source list can be deleted or added to `packOptions.filesExcluded` or `packOptions.directoriesExcluded` in `uipath.json`, and `submit` names the same remedy when it refuses to send one. An input needs a JSON Schema literal in `defineFunction({ input })` or a `.describe()` call on the validator, because `defineSchema<T>()` drops every description.
|
|
244
253
|
|
|
245
|
-
`submit` with writes in the plan and no `--yes` prints the diff, returns `ConfirmationRequired`, exits 1 and writes none of the adopt files. With `--yes` it writes the files and goes on to the checks and the pull request in the same run, so a fresh project needs one `submit --yes` and no second run. Use `--dry-run` with `--yes` to adopt the project and see the plan without opening a pull request. Replace the default license, label and descriptions with your own before the pull request is merged. `upload` on an unadopted project does the same with its own `--yes`. It prints the diff, writes the files and goes on to the upload in the same run, and it reads no index, so it needs no `gh`. The `submit` pull request body lists each field that the adopt step generated, so a reviewer can tell tool text from author text. That list covers only the run that adopts.
|
|
254
|
+
`submit` with writes in the plan and no `--yes` prints the diff, returns `ConfirmationRequired`, exits 1 and writes none of the adopt files. With `--yes` it writes the files and goes on to the checks and the pull request in the same run, so a fresh project needs one `submit --yes` and no second run. Use `--dry-run` with `--yes` to adopt the project and see the plan without opening a pull request. Replace the default license, label and descriptions with your own before the pull request is merged. `validate` shows a description that still holds the generated text as a `review` finding of the `contract` gate, and does not fail. `upload` on an unadopted project does the same with its own `--yes`. It prints the diff, writes the files and goes on to the upload in the same run, and it reads no index, so it needs no `gh`. The `submit` pull request body lists each field that the adopt step generated, so a reviewer can tell tool text from author text. That list covers only the run that adopts.
|
|
246
255
|
|
|
247
256
|
## Submit
|
|
248
257
|
|
|
249
258
|
`submit({ projectDir, github, securityContact })` sends the node folder to the index repo as one pull request. It needs no author repo, no release and no App or org secret. It uses the token of the signed-in `gh` account, so the account must be allowed to create `register/**` branches in the index repo. It does every check before it writes anything, and it runs every check that does not depend on a failed one, so one run lists every failure, one per line. When a gate failed, the result code is `GatesFailed`, with the gate report as `data` and the other lines in `instructions`. When only other checks failed, the code is `Failed` and `instructions` holds every line.
|
|
259
|
+
|
|
250
260
|
1. Plans the adopt writes (see Adopt). It stops when the plan has an error, or has a write and no `--yes`. With `--yes` it applies the writes and goes on. When it then needs `--security-contact` and has none, it returns `InputRequired` and says the adopt files were written. Loads `uipath-extensions.json`. Takes the version and the node id from the sent `package.json`, and fails when its `name` is not a package id or its `version` is not a string.
|
|
251
261
|
2. Runs `validate` in local mode. It packs the project, so `uip` must be on the PATH. A `fail` stops `submit` before it writes anything, after the checks below have run. A `review` or `skipped` result is printed and does not stop it. The index CI runs every gate with more inputs than a local run has, so a pass here is not a pass there.
|
|
252
262
|
3. Reads the index repo and checks that the signed-in account can push to it. Without that right it stops before it writes anything, with `you cannot push branches to <index>. Ask in #feat-maestro-community-node for write access, then run submit again.`
|
|
253
263
|
4. Collects the files of the project folder. Only the allow list is sent: `uipath-extensions.json`, `package.json`, `package-lock.json`, `uipath.json`, `tsconfig.json`, `tsconfig.typecheck.json`, `project.uiproj`, `README.md`, `LICENSE`, one icon at `assets/<name>.png` (the name is free from SDK 0.1.23, and `assets/icon.png` before it), `maestro/connection.ts`, `functions/**/*.ts`, `tests/**/*.ts` and `fixtures/**/*.json`. Names under the last three must use only letters, digits, `_`, `-` and `.`, and may not start with a dot. A file under a folder whose name starts with a dot, such as `fixtures/.vscode/tasks.json`, is not on the list, because the index refuses it. Local files that the index refuses or that a build writes are left out and listed in the output. They are `node_modules/`, `dist/`, `.git/`, `.uipath/`, `.github/`, `docs/`, `.gitignore`, `.npmrc`, `biome.json`, `commitlint.config.mjs`, `AGENTS.md`, `CHANGELOG.md`, `CLAUDE.md`, `entry-points.json`, `bindings_v2.json`, `registration.yaml` and `*.nupkg`. A `registration.yaml` in the folder, for example one copied from the index, is never sent: submit writes the registration from the index copy plus the new version. The same checks as in `validate` run on it, and a problem is a warning in the output. At any depth the collector also skips an entry whose name is in `packOptions.filesExcluded` or `packOptions.directoriesExcluded` of `uipath.json`, and the names `node_modules`, `.git`, `.env`, `.deno`, `dist` and `.uipath`, as `uip function pack` does. A source folder of the allow list at the project root (`tests`, `fixtures`) is still collected when `packOptions` excludes it, because `new` excludes `tests` only to keep it out of the package, and the index keeps those files. A `uip function pack` run writes the last three, and `validate`, `pack` and `upload` all start one, so they can sit in the folder when you submit. Any other file, a second file under `assets/`, a symlink, a file over 5 MiB, more than 200 files with `registration.yaml`, or more than 20 MiB in all stops submit with the list of paths and the reason for each. In `package-lock.json`, every package that is not `@uipath/uipath-extensions-sdk` or `@uipath/uipath-extensions-gates` and whose `resolved` URL is on `npm.pkg.github.com` is sent with the matching `registry.npmjs.org` tarball URL, because the index gate takes everything but those two from the public registry. The `integrity` value is not changed, and the file on disk is not touched.
|
|
254
264
|
5. Refuses when the index holds both the flat file `nodes/<publisher>/<name>.yaml` and the folder for the node, or when the version is already in the registration file. It then looks for an open pull request from the branch `register/<publisher>__<name>`. When there is one, it updates that pull request (see below). When there is none, it refuses if the branch already exists in the index repo.
|
|
255
|
-
6. Reads the default branch head of the index repo, and builds one tree commit on it through the git data API. The commit holds the files under `nodes/<publisher>/<name>/` and `registration.yaml` with the new version as a `listed` entry dated today (UTC). A first registration writes `id`, `package`, `security_contact`, `
|
|
265
|
+
6. Reads the default branch head of the index repo, and builds one tree commit on it through the git data API. The commit holds the files under `nodes/<publisher>/<name>/` and `registration.yaml` with the new version as a `listed` entry dated today (UTC). A first registration writes `id`, `package`, `security_contact`, `approved` and `maintainers`, and `id` and `package` come from the `name` in `package.json`. `maintainers` holds one entry, the signed-in `gh` account, with its login in lowercase and its numeric GitHub id. The index lets only a listed maintainer, or someone with write access to the index repo, submit new versions of the node. When the signed-in account is not a normal user, `submit` writes no `maintainers` block and does not fail. That happens when the login has brackets or another shape that the index schema refuses, when the account type is not `User`, and when GitHub does not answer the identity or the user lookup. A node without the list is not checked by the index. A later version keeps every field of the existing file, `maintainers` included, appends the entry and never adds the submitter. To add people, edit `maintainers` in the registration file by hand in a pull request. The list holds 1 to 20 entries and the index checks the shape of each one. It deletes files that the index folder holds and your folder no longer has. When the node is still a flat file `nodes/<publisher>/<name>.yaml`, the same commit deletes that file and writes the folder, so the pull request never holds both. The commit touches nothing outside `nodes/<publisher>/<name>/`.
|
|
256
266
|
7. Creates the branch `register/<publisher>__<name>` at that commit, so a failure before this step leaves no branch. It opens the pull request with the body of the index `.github/PULL_REQUEST_TEMPLATE.md`. It fills the `Node id` and `Version` lines and ticks "Registers a new node" or "Adds a version to an existing node". It then tries to add the `registration` label, and warns when it cannot. The pull request title and the commit message are both `Register <id> <version>`, because the index lints every commit and the title with the same rule.
|
|
257
267
|
|
|
258
268
|
The version comes from the folder.
|
|
259
269
|
|
|
260
270
|
When a pull request from that branch is already open, `submit` updates it instead of opening a second one.
|
|
271
|
+
|
|
261
272
|
- It updates only a pull request that the signed-in `gh` user opened. For another author it stops before any write with `<url> was opened by <author>, and gh is signed in as <you>. Run submit as <author> (gh auth switch), or ask them to update it.`
|
|
262
273
|
- It builds the tree from the default branch head exactly as for a new pull request. A file you deleted since the last submit is gone, a version bump leaves the pull request registering only the new version, and a resubmit of the same version is allowed.
|
|
263
274
|
- The new commit has the current branch head as its first parent, so the branch moves forward and keeps its history. When the default branch head is not yet in the branch, it is the second parent. Without it the file list of the pull request would show files that other registrations changed, and the index refuses a source pull request that touches anything outside the node folder.
|
|
@@ -279,7 +290,7 @@ A connector node is an Integration Service connector, not a function. Its folder
|
|
|
279
290
|
- **Identity.** A connector has no `package.json`, so pass the node id with `--id <publisher>.<name>`, or type it at the prompt. Publisher and name hold lowercase letters and digits only, at most 70 characters together. The package id is `uipath-extensions.<publisher>.<name>`.
|
|
280
291
|
- **Key.** The key comes from the node id. `uipath.<name>` is the shared connector of a vendor, key `custom-community-<name>`, which UiPath builds first and anyone improves with a pull request. Any other publisher makes a fork, key `custom-community-<name>_<publisher>`, and submit refuses a fork until `nodes/uipath/<name>` is in the index as a connector. A shared function or agent, or a legacy flat `nodes/uipath/<name>.yaml`, does not count, because submit decides the shared node's kind from its files the same way it does for the node it sends. validate and submit rewrite every copy of the folder's key as text in the copy they check and send: `key`, the `design-` twin in `metadata.key`, the `metadata.image` path, every `elementKey` and any other JSON value that holds it. The folder is not changed, and init writes only the template and the icon.
|
|
281
292
|
- **Version.** The index holds the version history. The first submit of a node is `1.0.0`. After that, pass `--bump patch|minor|major`, and submit takes the highest approved version in `registration.yaml`, yanked and blocked ones included, adds the bump, and writes it to `latestVersion` in `element-metadata.json` and to the top-level `version` in `element.json` of the files it sends. The folder keeps the version it had, which is the one your tenant publishes, so the two versions count separately. A pull request that is still open adds no approved version, so running submit again with the same `--bump` sends the same version. A connector version only goes up, so submit refuses one that is not higher than every approved version. `--bump` takes only `patch`, `minor` or `major`, and submit refuses it for a function or agent, which takes its version from `package.json`.
|
|
282
|
-
- **Validate.** `validate --dir <folder> [--id <publisher>.<name>]` runs the connector gates, without packing, on a copy of the files submit would send, with the community key of the node id. Without `--id` it checks the folder as the shared connector `uipath.<name>`, taking `<name>` from the last part of the folder's key, and a folder that already holds a community key is checked as it is. A file the folder walk refuses, such as one off the allow list, is reported under `connector-contents`. Fix every finding in the folder. When `uipath-extensions.json` or `assets/icon.png` is missing, validate stops and asks you to run init.
|
|
293
|
+
- **Validate.** `validate --dir <folder> [--id <publisher>.<name>]` runs the connector gates, without packing, on a copy of the files submit would send, with the community key of the node id. Without `--id` it checks the folder as the shared connector `uipath.<name>`, taking `<name>` from the last part of the folder's key, and a folder that already holds a community key is checked as it is. A file the folder walk refuses, such as one off the allow list, is reported under `connector-contents`. A local run has no registered version and no packed archive, so `connector-version` and `connector-package` show as `skipped`. Fix every finding in the folder. When `uipath-extensions.json` or `assets/icon.png` is missing, validate stops and asks you to run init.
|
|
283
294
|
- **Submit.** `submit --dir <folder> --id <publisher>.<name> --yes [--bump patch|minor|major]` writes the generated template and the default icon on the first run, runs the connector gates on the exact bytes it sends, with the node id and the earlier versions, and opens the `register/<publisher>__<name>` pull request as for a function. It sends `uipath-extensions.json`, `README.md`, `LICENSE`, `assets/icon.png` and the allowed `app/element/**` files. A `registration.yaml` in the folder is not sent and is checked as for a function.
|
|
284
295
|
- **Kind.** submit refuses a connector whose id is already registered as a function or agent, including a legacy flat file, and a function or agent whose id is already a connector. Use a new id.
|
|
285
296
|
- **Upload.** `upload` takes functions and agents only.
|
|
@@ -289,11 +300,10 @@ A connector node is an Integration Service connector, not a function. Its folder
|
|
|
289
300
|
- For an agent, `validate` runs four Python gates only. Nothing checks the Python source for risky calls, imports, secrets in logs or a vendor host, and there is no contract, license or CVE gate, so a reviewer reads those. `pypi-dependency-tree` is skipped locally, because `validate` has no PyPI client. `validate` does not run `uip codedagent init`, so it does not catch an `entry-points.json` that is stale against the code. The index CI regenerates it and refuses a difference.
|
|
290
301
|
- For an agent, `uip codedagent init` writes `AGENTS.md`, `CLAUDE.md` and `agent.mermaid` into the project, and `uip codedagent pack` puts them in the nupkg. `submit` does not send them, so the package that the index builds holds its own copies from its `init` run.
|
|
291
302
|
- `new --kind agent` replaces the scaffold's placeholder `authors` (`John Doe`), which would otherwise go into the nuspec. `init` does not change `authors`, so a project made with `uip codedagent new` directly keeps the placeholder until the author edits it.
|
|
292
|
-
- `build-check` supports functions only. On an agent it runs the function build gates, which fail.
|
|
293
303
|
- The agent paths were run by hand against `uip` 1.208.0-dev.10110 on 2026-11-25: `new`, `init`, `validate`, `pack`, `upload --run` (a job on alpha returned its output) and `submit --dry-run`. The tests use a fake `uip`.
|
|
294
304
|
- `repository` is optional. A template that sets it must write `owner/repo`, not a URL, and the completed manifest then lists it as a `https://github.com/` URL. A template without it gets no `repository` in the manifest. The `release`, `attestation` and `identity-match` gates fail in `ci` mode for such a manifest when a caller gives them every input, because they look up the author repository, and `source` mode skips them. Nothing else in the gate library or the SDK reads the field.
|
|
295
305
|
- `author` is checked for shape only. The gates do not check that the name belongs to the publisher or that the url is theirs, so a reviewer reads it. The index can later refuse a name that impersonates another publisher.
|
|
296
|
-
- `pack` and `upload` do not compare a legacy template `version` with `package.json`. `validate`
|
|
306
|
+
- `pack` and `upload` do not compare a legacy template `version` with `package.json`. `validate` does, because it builds the manifest. `template-match` compares bytes only, so it cannot tell a stale template from a new one, it only proves that the package carries the source file.
|
|
297
307
|
- `credential.inputs` lists each top-level operation input whose schema, or the local `$ref` target of its schema, has `x-uipath-resource-kind: "Connection"`, as an `ICredentialType` input. A nested property, a `$ref` chain and an asset kind are not listed.
|
|
298
308
|
- The connection helper calls Integration Service only from a UiPath cloud host (`uipath.com` or a subdomain). It does not run on Automation Suite. A node can pass a fixed connection id to `connection()` instead of its input, and the gates do not catch that. The helper only reaches connections the job's robot can already read.
|
|
299
309
|
- The manifest follows the shape in the registry design. The Flow node contract owner has not confirmed it yet, so it can still change.
|
package/dist/adopt.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { lstat, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { isDeepStrictEqual } from "node:util";
|
|
4
|
-
import { assetsProblem, CONNECTION_HELPER_PATH, CONNECTION_HELPER_SOURCE, connectionInputNames, FIXTURES_DIR, fixtureProblem, ICON_PATH, ICON_PATH_PATTERN, iconPathOf, isAllowedSourceDir, isAllowedSourcePath, isLocalOnlySource, MANIFEST_FILE, PackedArchiveError, PYPROJECT, packageNameProblem, packedName, parsePacked, parseTomlText, readPackedEntries, readTomlFile, templateProblems, UV_LOCK, } from "@uipath/uipath-extensions-gates";
|
|
4
|
+
import { assetsProblem, CONNECTION_HELPER_PATH, CONNECTION_HELPER_SOURCE, connectionInputNames, DEFAULT_NODE_DESCRIPTION, DEFAULT_OPERATION_DESCRIPTION, FIXTURES_DIR, fixtureProblem, ICON_PATH, ICON_PATH_PATTERN, iconPathOf, isAllowedSourceDir, isAllowedSourcePath, isLocalOnlySource, MANIFEST_FILE, MAX_PACKAGE_NAME_LENGTH, PackedArchiveError, PYPROJECT, packageNameProblem, packedName, parsePacked, parseTomlText, readPackedEntries, readTomlFile, templateProblems, UV_LOCK, } from "@uipath/uipath-extensions-gates";
|
|
5
5
|
import { strFromU8 } from "fflate";
|
|
6
6
|
import { parse } from "yaml";
|
|
7
7
|
import { labelOf, TYPES_NODE_PACKAGE, TYPES_NODE_VERSION, } from "./commands/new.js";
|
|
@@ -21,6 +21,31 @@ const POLICY_FILE = "policy/gate-library.yaml";
|
|
|
21
21
|
const SCHEMA_KEY = "template_schema";
|
|
22
22
|
export const NAME_PREFIX = "uipath-extensions.";
|
|
23
23
|
export const MISSING_ID_ERROR = "pass <publisher>.<name>";
|
|
24
|
+
function idProblem(id) {
|
|
25
|
+
if (packageNameProblem(`${NAME_PREFIX}${id}`) === undefined)
|
|
26
|
+
return undefined;
|
|
27
|
+
return `id "${id}" is not valid. The package name must be ${NAME_PREFIX}<publisher>.<name> in lowercase letters, digits and single hyphens, up to ${MAX_PACKAGE_NAME_LENGTH} characters. Pass the id as <publisher>.<name>`;
|
|
28
|
+
}
|
|
29
|
+
function chooseName(current, id) {
|
|
30
|
+
const adopted = typeof current === "string" && packageNameProblem(current) === undefined;
|
|
31
|
+
if (id === undefined) {
|
|
32
|
+
return adopted
|
|
33
|
+
? { name: current, write: false }
|
|
34
|
+
: { error: MISSING_ID_ERROR };
|
|
35
|
+
}
|
|
36
|
+
const problem = idProblem(id);
|
|
37
|
+
if (problem !== undefined)
|
|
38
|
+
return { error: problem };
|
|
39
|
+
const name = `${NAME_PREFIX}${id}`;
|
|
40
|
+
if (!adopted)
|
|
41
|
+
return { name, write: true };
|
|
42
|
+
if (current === name)
|
|
43
|
+
return { name, write: false };
|
|
44
|
+
const currentId = current.slice(NAME_PREFIX.length);
|
|
45
|
+
return {
|
|
46
|
+
error: `the project already has the id ${currentId}, not ${id}. Pass ${currentId} or no id`,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
24
49
|
export class StaleAdoptPlanError extends Error {
|
|
25
50
|
path;
|
|
26
51
|
constructor(path) {
|
|
@@ -30,8 +55,6 @@ export class StaleAdoptPlanError extends Error {
|
|
|
30
55
|
}
|
|
31
56
|
}
|
|
32
57
|
const DEFAULT_LICENSE = "MIT";
|
|
33
|
-
const NODE_DESCRIPTION = "Describe what this node does in one sentence.";
|
|
34
|
-
const OPERATION_DESCRIPTION = "Describe what this operation does.";
|
|
35
58
|
const ICON_NAMES = ICON_PATH.split("/");
|
|
36
59
|
const iconExcludedProblem = (name) => `uipath.json packOptions excludes ${name}, so ${ICON_PATH} would not be packed, remove ${name} from packOptions, then run again`;
|
|
37
60
|
const iconReferenceGenerated = () => ({
|
|
@@ -62,6 +85,7 @@ const notAList = (key) => `uipath.json packOptions.${key} is not a list`;
|
|
|
62
85
|
const isJunk = (key, name) => JUNK[key].includes(name);
|
|
63
86
|
const LOGIN = "log in with gh auth login, then run again";
|
|
64
87
|
const INSTALL_GH = "install gh from https://cli.github.com, then run again";
|
|
88
|
+
const noAccess = (index) => `the gh account cannot read ${index}. Check gh auth status, or switch to an account that has access, then run again`;
|
|
65
89
|
const UPGRADE = "upgrade uip, then run again";
|
|
66
90
|
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
67
91
|
const json = (value) => `${JSON.stringify(value, null, 2)}\n`;
|
|
@@ -225,7 +249,7 @@ async function templateSchema(deps, index) {
|
|
|
225
249
|
let text;
|
|
226
250
|
try {
|
|
227
251
|
if ((await github.repository(index)) === undefined) {
|
|
228
|
-
return { error:
|
|
252
|
+
return { error: noAccess(index) };
|
|
229
253
|
}
|
|
230
254
|
text = await github.fileText(index, POLICY_FILE);
|
|
231
255
|
}
|
|
@@ -259,20 +283,25 @@ function newTemplate(schema, version, packageName, operation, icon, declaredLice
|
|
|
259
283
|
license: declaredLicense === undefined ? DEFAULT_LICENSE : declaredLicense,
|
|
260
284
|
display: {
|
|
261
285
|
label,
|
|
262
|
-
description:
|
|
286
|
+
description: DEFAULT_NODE_DESCRIPTION,
|
|
263
287
|
...(icon !== "none" && { icon: ICON_PATH }),
|
|
264
288
|
},
|
|
265
289
|
tags: [],
|
|
266
|
-
operations: [
|
|
290
|
+
operations: [
|
|
291
|
+
{ name: operation, description: DEFAULT_OPERATION_DESCRIPTION },
|
|
292
|
+
],
|
|
267
293
|
});
|
|
268
294
|
const generated = [
|
|
269
295
|
...(declaredLicense === undefined
|
|
270
296
|
? [{ field: "license", value: DEFAULT_LICENSE }]
|
|
271
297
|
: []),
|
|
272
298
|
{ field: "display.label", value: label },
|
|
273
|
-
{ field: "display.description", value:
|
|
299
|
+
{ field: "display.description", value: DEFAULT_NODE_DESCRIPTION },
|
|
274
300
|
{ field: "operations[0].name", value: operation },
|
|
275
|
-
{
|
|
301
|
+
{
|
|
302
|
+
field: "operations[0].description",
|
|
303
|
+
value: DEFAULT_OPERATION_DESCRIPTION,
|
|
304
|
+
},
|
|
276
305
|
{ field: "tags", value: "[]" },
|
|
277
306
|
...(icon === "default"
|
|
278
307
|
? [iconReferenceGenerated(), iconFileGenerated()]
|
|
@@ -438,14 +467,11 @@ async function planPythonFunction(opts, deps, uipath, uipathText, functions) {
|
|
|
438
467
|
return fail(error.message);
|
|
439
468
|
throw error;
|
|
440
469
|
}
|
|
441
|
-
|
|
442
|
-
if (
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
const problem = packageNameProblem(name);
|
|
447
|
-
if (problem !== undefined)
|
|
448
|
-
return fail(problem.replace("package.json name", "pyproject.toml [project].name"));
|
|
470
|
+
const chosen = chooseName(project.name, opts.id);
|
|
471
|
+
if ("error" in chosen)
|
|
472
|
+
return fail(chosen.error);
|
|
473
|
+
const name = chosen.name;
|
|
474
|
+
if (chosen.write) {
|
|
449
475
|
const after = replaceProjectName(before, name);
|
|
450
476
|
if (after === undefined) {
|
|
451
477
|
return fail('place the project name on one standalone name = "..." line in [project]');
|
|
@@ -503,26 +529,42 @@ async function planPythonFunction(opts, deps, uipath, uipathText, functions) {
|
|
|
503
529
|
if (problems.length > 0)
|
|
504
530
|
return fail(`invalid ${MANIFEST_FILE}: ${problems.join("; ")}`);
|
|
505
531
|
const display = isRecord(parsedManifest) ? parsedManifest.display : undefined;
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
532
|
+
const options = uipath.packOptions;
|
|
533
|
+
if (options !== undefined && !isRecord(options)) {
|
|
534
|
+
return fail("uipath.json packOptions must be an object");
|
|
535
|
+
}
|
|
536
|
+
const files = options?.filesIncluded ?? [];
|
|
537
|
+
if (!Array.isArray(files) ||
|
|
538
|
+
!files.every((entry) => typeof entry === "string")) {
|
|
539
|
+
return fail("uipath.json packOptions.filesIncluded must be a list of filenames");
|
|
540
|
+
}
|
|
541
|
+
// The index packs the committed uipath.json, so it must keep uv.lock in and fixtures out.
|
|
542
|
+
const nextOptions = {
|
|
543
|
+
...options,
|
|
544
|
+
...(isRecord(display) &&
|
|
545
|
+
display.icon === ICON_PATH &&
|
|
546
|
+
!files.includes(ICON_PATH) && {
|
|
547
|
+
filesIncluded: [...files, ICON_PATH],
|
|
548
|
+
}),
|
|
549
|
+
includeUvLock: true,
|
|
550
|
+
directoriesExcluded: [FIXTURES_DIR],
|
|
551
|
+
};
|
|
552
|
+
if (!isDeepStrictEqual(nextOptions, options)) {
|
|
553
|
+
plan.writes.push({
|
|
554
|
+
path: "uipath.json",
|
|
555
|
+
before: uipathText,
|
|
556
|
+
after: jsonWriter(uipathText)({ ...uipath, packOptions: nextOptions }),
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
if ((await fixtureProblem(opts.dir)) !== undefined) {
|
|
560
|
+
const blocked = await starterFixtureBlocked(opts.dir);
|
|
561
|
+
if (blocked !== undefined)
|
|
562
|
+
return fail(blocked);
|
|
563
|
+
plan.writes.push({
|
|
564
|
+
path: FIXTURE_PATH,
|
|
565
|
+
before: null,
|
|
566
|
+
after: starterFixtureText(templateOperation(plannedManifest) ?? operationName(main)),
|
|
567
|
+
});
|
|
526
568
|
}
|
|
527
569
|
for (const { path } of plan.writes) {
|
|
528
570
|
const problem = await symlinkProblem(opts.dir, path, "adopt");
|
|
@@ -669,31 +711,23 @@ async function planAgentAdopt(opts, deps, plan) {
|
|
|
669
711
|
return fail(`${PYPROJECT} needs a [project] table with a version`);
|
|
670
712
|
}
|
|
671
713
|
let packageName = String(project.name);
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
714
|
+
const chosen = chooseName(project.name, opts.id);
|
|
715
|
+
if ("error" in chosen) {
|
|
716
|
+
plan.errors.push(chosen.error);
|
|
717
|
+
}
|
|
718
|
+
else if (chosen.write) {
|
|
719
|
+
const after = setProjectField(pyprojectText, "name", chosen.name);
|
|
720
|
+
if (after === undefined) {
|
|
721
|
+
plan.errors.push(`${PYPROJECT} has no [project] name line to set`);
|
|
675
722
|
}
|
|
676
723
|
else {
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
}
|
|
685
|
-
else if (after === undefined) {
|
|
686
|
-
plan.errors.push(`${PYPROJECT} has no [project] name line to set`);
|
|
687
|
-
}
|
|
688
|
-
else {
|
|
689
|
-
packageName = name;
|
|
690
|
-
plan.writes.push({
|
|
691
|
-
path: PYPROJECT,
|
|
692
|
-
before: pyprojectText,
|
|
693
|
-
after,
|
|
694
|
-
identity: true,
|
|
695
|
-
});
|
|
696
|
-
}
|
|
724
|
+
packageName = chosen.name;
|
|
725
|
+
plan.writes.push({
|
|
726
|
+
path: PYPROJECT,
|
|
727
|
+
before: pyprojectText,
|
|
728
|
+
after,
|
|
729
|
+
identity: true,
|
|
730
|
+
});
|
|
697
731
|
}
|
|
698
732
|
}
|
|
699
733
|
const manifestText = await readText(join(opts.dir, MANIFEST_FILE));
|
|
@@ -761,26 +795,18 @@ export async function planAdopt(opts, deps) {
|
|
|
761
795
|
}
|
|
762
796
|
const serialize = jsonWriter(packageText);
|
|
763
797
|
let nextPkg = pkg;
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
plan.writes.push({
|
|
777
|
-
path: "package.json",
|
|
778
|
-
before: packageText,
|
|
779
|
-
after: serialize(nextPkg),
|
|
780
|
-
identity: true,
|
|
781
|
-
});
|
|
782
|
-
}
|
|
783
|
-
}
|
|
798
|
+
const chosen = chooseName(pkg.name, opts.id);
|
|
799
|
+
if ("error" in chosen) {
|
|
800
|
+
plan.errors.push(chosen.error);
|
|
801
|
+
}
|
|
802
|
+
else if (chosen.write) {
|
|
803
|
+
nextPkg = { ...pkg, name: chosen.name };
|
|
804
|
+
plan.writes.push({
|
|
805
|
+
path: "package.json",
|
|
806
|
+
before: packageText,
|
|
807
|
+
after: serialize(nextPkg),
|
|
808
|
+
identity: true,
|
|
809
|
+
});
|
|
784
810
|
}
|
|
785
811
|
const packed = await runPack(deps, opts.dir, `${String(pkg.name)}.${pkg.version}.nupkg`);
|
|
786
812
|
if ("error" in packed)
|