@uipath/packager-tool-functions 1.206.1-preview.301 → 1.207.0-preview.305
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 +4 -40
- package/dist/functions-tool.d.ts +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +269 -262
- package/dist/types.d.ts +3 -4
- package/package.json +4 -5
- package/dist/language-detection.d.ts +0 -18
- package/dist/language-detection.js +0 -61
- package/dist/py/build-py-functions-package.d.ts +0 -3
- package/dist/py/constants.d.ts +0 -14
- package/dist/py/index.d.ts +0 -1
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Studio Web publish (JS/TS)
|
|
|
12
12
|
|
|
13
13
|
Studio Web publish (Python)
|
|
14
14
|
→ FunctionsTool.buildAsync() ← this package
|
|
15
|
-
→
|
|
15
|
+
→ buildFunctionsPackage() ← @uipath/coded-functions-py-packager
|
|
16
16
|
|
|
17
17
|
CLI: uip function pack (JS/TS)
|
|
18
18
|
→ uipath-functions pack ← @uipath/uipath-functions CLI
|
|
@@ -26,45 +26,13 @@ CLI: uip function pack (Python)
|
|
|
26
26
|
|
|
27
27
|
`FunctionsTool` implements `ProjectTool` for `ProjectType.Function`. On `buildAsync`:
|
|
28
28
|
|
|
29
|
-
1. Probes the project: its name from `project.uiproj` (`Name`), and its language through `
|
|
29
|
+
1. Probes the project: its name from `project.uiproj` (`Name`), and its language through `detectFunctionsLanguage` from `@uipath/functions-sdk/language` (in this repo, [`packages/functions-sdk`](../../functions-sdk/README.md)), which this package bundles. The browser Functions tool and the `uip function` dispatcher read the same detection from there. A project with no language signal is reported as not initialized, by name, and nothing is built.
|
|
30
30
|
2. **JS/TS**: delegates to `buildFunctionsPackage(fs, options)` from `@uipath/coded-functions-js-packager` (externally-published library, shared with the `uipath-functions` CLI).
|
|
31
|
-
3. **Python**: delegates to
|
|
31
|
+
3. **Python**: delegates to `buildFunctionsPackage(fs, options)` from `@uipath/coded-functions-py-packager` (in this repo, [`../coded-functions-py-packager`](../coded-functions-py-packager/README.md), which also documents the Python build pipeline).
|
|
32
32
|
|
|
33
33
|
### Language detection
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|---|---|
|
|
37
|
-
| `uipath.json` functions map extension `.ts`/`.js`/`.mjs` | javascript |
|
|
38
|
-
| `uipath.json` functions map extension `.py` | python |
|
|
39
|
-
| `package.json` present | javascript (fallback) |
|
|
40
|
-
| `pyproject.toml` present | python (fallback) |
|
|
41
|
-
| None of the above | not initialized — `Function project '<name>' is not initialized: ...` |
|
|
42
|
-
|
|
43
|
-
There is no language in `project.uiproj`, so the files the project's init wrote are the only signal. Build, pack and manifest-generation failures name the project and keep the inner error: `<stage> failed for Function project '<name>' (<language>): <error>`.
|
|
44
|
-
|
|
45
|
-
## Python build pipeline
|
|
46
|
-
|
|
47
|
-
`buildPyFunctionsPackage` produces a fully-formed nupkg content folder from the Python project sources. Pipeline:
|
|
48
|
-
|
|
49
|
-
1. **Validate inputs** — requires `uipath.json` and `entry-points.json` at the project root. Throws a readable error if either is missing.
|
|
50
|
-
2. **Copy source files** to `content/`, filtered by [`EXCLUDED_NAMES`](src/py/constants.ts) (`agent.json`, `project.uiproj`, `bindings.json`, `entry-points.json`, OS metadata) and [`EXCLUDED_DIRECTORIES`](src/py/constants.ts) (virtualenvs, caches, editor dirs, VCS dirs). `bindings.json` and `entry-points.json` are excluded because the packager re-emits canonical versions — see steps 3 and 5.
|
|
51
|
-
3. **Normalize `content/entry-points.json`** — reads the source file and rewrites it with:
|
|
52
|
-
- Canonical `$schema` (`https://cloud.uipath.com/draft/2024-12/entry-point`) and `$id` (`entry-points.json`).
|
|
53
|
-
- Per-entry `uniqueId` — backfilled with `crypto.randomUUID()` when the source is missing it.
|
|
54
|
-
- Per-entry `type` — defaults to `"function"` when missing.
|
|
55
|
-
- All other fields (`filePath`, `input`, `output`, etc.) are passed through.
|
|
56
|
-
4. **Write `content/operate.json`** — `$schema` = `operate`, `contentType` = `"function"`, `targetRuntime` = `"python"`, `main` = first entry-point's `filePath`, `projectId` = the platform-assigned storage id.
|
|
57
|
-
5. **Write `content/bindings_v2.json`** — uses the source `bindings.json` if present and parseable; otherwise emits the default `{ $schema, version: "2.0", resources: [] }`.
|
|
58
|
-
6. **Write `content/package-descriptor.json`** — registers `operate.json`, `entry-points.json`, and `bindings.json` (the latter pointing at `content/bindings_v2.json`).
|
|
59
|
-
|
|
60
|
-
### Expected source-project shape
|
|
61
|
-
|
|
62
|
-
The upstream tool (`uipath init` / Function Builder MFE) is responsible for producing a valid source layout before this packager runs. In particular:
|
|
63
|
-
|
|
64
|
-
- `uipath.json.functions` — map of entrypoint key → `"<file>.py:<python-function>"` (the runtime uses this to resolve the function body).
|
|
65
|
-
- `entry-points.json` — each entry's `filePath` must equal the functions-map key. The packager will fill in `uniqueId` and `type: "function"` if they're missing, but nothing can recover the real function-name mapping — that lives in `uipath.json.functions`.
|
|
66
|
-
- The Python function must take exactly one parameter typed as a dataclass, Pydantic model, or annotated class; the UiPath runtime calls `func(input)` with a single argument and converts the input dict into that type.
|
|
67
|
-
|
|
35
|
+
The languages, their labels and the detection rules are in [`@uipath/functions-sdk/language`](../../functions-sdk/README.md). A project with no language signal fails as `Function project '<name>' is not initialized: ...`. There is no language in `project.uiproj`, so the files the project's init wrote are the only signal. Build, pack and manifest-generation failures name the project and keep the inner error: `<stage> failed for Function project '<name>' (<language>): <error>`.
|
|
68
36
|
|
|
69
37
|
## Project structure
|
|
70
38
|
|
|
@@ -73,10 +41,6 @@ src/
|
|
|
73
41
|
├── functions-tool.ts # ProjectTool implementation (language detection, build/pack lifecycle)
|
|
74
42
|
├── functions-tool-factory.ts # Factory for the tool loader
|
|
75
43
|
├── js/ # JS/TS build path (delegates to @uipath/coded-functions-js-packager)
|
|
76
|
-
├── py/ # Python build path
|
|
77
|
-
│ ├── build-py-functions-package.ts
|
|
78
|
-
│ ├── constants.ts # All Python-packager constants (schemas, file names, exclusions)
|
|
79
|
-
│ └── index.ts
|
|
80
44
|
├── types.ts # BuildPackageOptions, Language enum, labels
|
|
81
45
|
└── index.ts
|
|
82
46
|
```
|
package/dist/functions-tool.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IProjectBuildOptions, IProjectPackOptions, IProjectRestoreOptions, IProjectValidateOptions } from "@uipath/solutionpackager-tool-core";
|
|
2
2
|
import { type IFileSystem, type IToolLogger, ProjectTool, ToolResult } from "@uipath/solutionpackager-tool-core";
|
|
3
|
-
import {
|
|
3
|
+
import type { FunctionsProjectProbe } from "./types.js";
|
|
4
4
|
export declare class FunctionsTool extends ProjectTool {
|
|
5
5
|
private readonly _temporaryStorage;
|
|
6
6
|
constructor(fileSystem: IFileSystem, logger: IToolLogger);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { FunctionsTool } from "./functions-tool.js";
|
|
2
2
|
export { FunctionsToolFactory } from "./functions-tool-factory.js";
|
|
3
|
-
export {
|
|
4
|
-
export { type FunctionsProjectProbe, type Language, Languages, } from "./types.js";
|
|
3
|
+
export type { FunctionsProjectProbe } from "./types.js";
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,262 @@
|
|
|
1
|
-
// src/functions-
|
|
1
|
+
// ../coded-functions-py-packager/src/build-functions-package.ts
|
|
2
|
+
import { NugetConstants, Path } from "@uipath/solutionpackager-tool-core";
|
|
3
|
+
|
|
4
|
+
// ../coded-functions-py-packager/src/constants.ts
|
|
5
|
+
var EXCLUDED_NAMES = new Set([
|
|
6
|
+
"agent.json",
|
|
7
|
+
"project.uiproj",
|
|
8
|
+
"bindings.json",
|
|
9
|
+
"entry-points.json",
|
|
10
|
+
".DS_Store",
|
|
11
|
+
"Thumbs.db"
|
|
12
|
+
]);
|
|
13
|
+
var EXCLUDED_DIRECTORIES = new Set([
|
|
14
|
+
"evaluations",
|
|
15
|
+
".function-builder",
|
|
16
|
+
"node_modules",
|
|
17
|
+
"__pycache__",
|
|
18
|
+
".pytest_cache",
|
|
19
|
+
".venv",
|
|
20
|
+
"venv",
|
|
21
|
+
"env",
|
|
22
|
+
".git",
|
|
23
|
+
".vscode",
|
|
24
|
+
".idea",
|
|
25
|
+
".local"
|
|
26
|
+
]);
|
|
27
|
+
var CONTENT_TYPE = "function";
|
|
28
|
+
var TARGET_RUNTIME = "python";
|
|
29
|
+
var UIPATH_JSON_FILE_NAME = "uipath.json";
|
|
30
|
+
var BINDINGS_SOURCE_FILE_NAME = "bindings.json";
|
|
31
|
+
var BINDINGS_VERSION = "2.0";
|
|
32
|
+
var ENTRY_POINT_TYPE = "function";
|
|
33
|
+
var SCHEMA_BASE_URL = "https://cloud.uipath.com/draft/2024-12";
|
|
34
|
+
var SCHEMAS = {
|
|
35
|
+
Bindings: `${SCHEMA_BASE_URL}/bindings`,
|
|
36
|
+
EntryPoint: `${SCHEMA_BASE_URL}/entry-point`,
|
|
37
|
+
Operate: `${SCHEMA_BASE_URL}/operate`,
|
|
38
|
+
PackageDescriptor: `${SCHEMA_BASE_URL}/package-descriptor`
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// ../coded-functions-py-packager/src/build-functions-package.ts
|
|
42
|
+
async function buildFunctionsPackage(fileSystem, options) {
|
|
43
|
+
const contentFolder = Path.join(options.outputPath, NugetConstants.ContentFolderName);
|
|
44
|
+
await validateProjectFiles(fileSystem, options.projectPath);
|
|
45
|
+
await copyFiles(fileSystem, options.projectPath, contentFolder);
|
|
46
|
+
await writeEntryPointsFile(fileSystem, options.projectPath, contentFolder);
|
|
47
|
+
await createOperateFile(fileSystem, contentFolder, options.projectStorageId);
|
|
48
|
+
await createBindingsFile(fileSystem, options.projectPath, contentFolder);
|
|
49
|
+
await createPackageDescriptor(fileSystem, options.outputPath);
|
|
50
|
+
}
|
|
51
|
+
async function validateProjectFiles(fileSystem, projectPath) {
|
|
52
|
+
const uipathJsonPath = Path.join(projectPath, UIPATH_JSON_FILE_NAME);
|
|
53
|
+
const entryPointsPath = Path.join(projectPath, NugetConstants.EntryPointsFileName);
|
|
54
|
+
if (!await fileSystem.exists(uipathJsonPath)) {
|
|
55
|
+
throw new Error("uipath.json is missing from the project.");
|
|
56
|
+
}
|
|
57
|
+
if (!await fileSystem.exists(entryPointsPath)) {
|
|
58
|
+
throw new Error("entry-points.json is missing from the project.");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async function copyFiles(fileSystem, sourcePath, destinationPath) {
|
|
62
|
+
await fileSystem.mkdir(destinationPath);
|
|
63
|
+
const entries = await fileSystem.readdir(sourcePath);
|
|
64
|
+
for (const entry of entries) {
|
|
65
|
+
const sourceFile = Path.join(sourcePath, entry);
|
|
66
|
+
const destinationFile = Path.join(destinationPath, entry);
|
|
67
|
+
const stat = await fileSystem.stat(sourceFile);
|
|
68
|
+
if (stat?.isFile()) {
|
|
69
|
+
if (EXCLUDED_NAMES.has(entry)) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const content = await fileSystem.readFile(sourceFile);
|
|
73
|
+
if (content) {
|
|
74
|
+
await fileSystem.writeFile(destinationFile, content);
|
|
75
|
+
}
|
|
76
|
+
} else if (stat?.isDirectory()) {
|
|
77
|
+
if (EXCLUDED_DIRECTORIES.has(entry)) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
await copyFiles(fileSystem, sourceFile, destinationFile);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
async function createOperateFile(fileSystem, contentFolder, projectStorageId) {
|
|
85
|
+
const operateJsonFilePath = Path.join(contentFolder, NugetConstants.OperateFileName);
|
|
86
|
+
const exists = await fileSystem.exists(operateJsonFilePath);
|
|
87
|
+
if (exists) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const entryPointsFilePath = Path.join(contentFolder, NugetConstants.EntryPointsFileName);
|
|
91
|
+
let mainPath = "";
|
|
92
|
+
const entryPointsExists = await fileSystem.exists(entryPointsFilePath);
|
|
93
|
+
if (entryPointsExists) {
|
|
94
|
+
const entryPointsContent = await fileSystem.readFile(entryPointsFilePath);
|
|
95
|
+
if (entryPointsContent) {
|
|
96
|
+
try {
|
|
97
|
+
const entryPointsText = new TextDecoder().decode(entryPointsContent);
|
|
98
|
+
const entryPoints = JSON.parse(entryPointsText);
|
|
99
|
+
mainPath = entryPoints.entryPoints?.[0]?.filePath ?? "";
|
|
100
|
+
} catch {}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const operateFileModel = {
|
|
104
|
+
$schema: SCHEMAS.Operate,
|
|
105
|
+
contentType: CONTENT_TYPE,
|
|
106
|
+
projectId: projectStorageId,
|
|
107
|
+
main: mainPath,
|
|
108
|
+
targetFramework: "Portable",
|
|
109
|
+
targetRuntime: TARGET_RUNTIME,
|
|
110
|
+
runtimeOptions: {
|
|
111
|
+
isAttended: false,
|
|
112
|
+
requiresUserInteraction: false,
|
|
113
|
+
isConversational: false
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
const operateJsonString = JSON.stringify(operateFileModel, null, 2);
|
|
117
|
+
await fileSystem.writeFile(operateJsonFilePath, operateJsonString);
|
|
118
|
+
}
|
|
119
|
+
async function writeEntryPointsFile(fileSystem, projectPath, contentFolder) {
|
|
120
|
+
const sourcePath = Path.join(projectPath, NugetConstants.EntryPointsFileName);
|
|
121
|
+
const destinationPath = Path.join(contentFolder, NugetConstants.EntryPointsFileName);
|
|
122
|
+
const raw = await fileSystem.readFile(sourcePath);
|
|
123
|
+
if (!raw) {
|
|
124
|
+
throw new Error("entry-points.json is missing from the project.");
|
|
125
|
+
}
|
|
126
|
+
let parsed;
|
|
127
|
+
try {
|
|
128
|
+
parsed = JSON.parse(new TextDecoder().decode(raw));
|
|
129
|
+
} catch {
|
|
130
|
+
throw new Error("entry-points.json is not valid JSON.");
|
|
131
|
+
}
|
|
132
|
+
const sourceEntries = Array.isArray(parsed.entryPoints) ? parsed.entryPoints : [];
|
|
133
|
+
const normalizedEntries = sourceEntries.map((entry) => ({
|
|
134
|
+
...entry,
|
|
135
|
+
uniqueId: typeof entry.uniqueId === "string" && entry.uniqueId.length > 0 ? entry.uniqueId : crypto.randomUUID(),
|
|
136
|
+
type: typeof entry.type === "string" && entry.type.length > 0 ? entry.type : ENTRY_POINT_TYPE
|
|
137
|
+
}));
|
|
138
|
+
const normalized = {
|
|
139
|
+
$schema: SCHEMAS.EntryPoint,
|
|
140
|
+
$id: NugetConstants.EntryPointsFileName,
|
|
141
|
+
entryPoints: normalizedEntries
|
|
142
|
+
};
|
|
143
|
+
await fileSystem.writeFile(destinationPath, JSON.stringify(normalized, null, 2));
|
|
144
|
+
}
|
|
145
|
+
async function createBindingsFile(fileSystem, projectPath, contentFolder) {
|
|
146
|
+
const bindingsOutputPath = Path.join(contentFolder, NugetConstants.BindingsV2FileName);
|
|
147
|
+
const sourcePath = Path.join(projectPath, BINDINGS_SOURCE_FILE_NAME);
|
|
148
|
+
let bindings = null;
|
|
149
|
+
if (await fileSystem.exists(sourcePath)) {
|
|
150
|
+
const raw = await fileSystem.readFile(sourcePath);
|
|
151
|
+
if (raw) {
|
|
152
|
+
try {
|
|
153
|
+
bindings = JSON.parse(new TextDecoder().decode(raw));
|
|
154
|
+
} catch {
|
|
155
|
+
bindings = null;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (bindings === null) {
|
|
160
|
+
bindings = {
|
|
161
|
+
$schema: SCHEMAS.Bindings,
|
|
162
|
+
version: BINDINGS_VERSION,
|
|
163
|
+
resources: []
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
await fileSystem.writeFile(bindingsOutputPath, JSON.stringify(bindings, null, 2));
|
|
167
|
+
}
|
|
168
|
+
async function createPackageDescriptor(fileSystem, localBuildFolder) {
|
|
169
|
+
const packageDescriptor = {
|
|
170
|
+
files: {}
|
|
171
|
+
};
|
|
172
|
+
addFileToDescriptor(packageDescriptor, NugetConstants.OperateFileName, NugetConstants.OperateFileName);
|
|
173
|
+
addFileToDescriptor(packageDescriptor, NugetConstants.EntryPointsFileName, NugetConstants.EntryPointsFileName);
|
|
174
|
+
addFileToDescriptor(packageDescriptor, NugetConstants.BindingsFileId, NugetConstants.BindingsV2FileName);
|
|
175
|
+
const packageDescriptorPath = Path.join(localBuildFolder, NugetConstants.ContentFolderName, NugetConstants.PackageDescriptorFileName);
|
|
176
|
+
const packageDescriptorJson = JSON.stringify({
|
|
177
|
+
$schema: SCHEMAS.PackageDescriptor,
|
|
178
|
+
...packageDescriptor
|
|
179
|
+
}, null, 2);
|
|
180
|
+
await fileSystem.writeFile(packageDescriptorPath, packageDescriptorJson);
|
|
181
|
+
}
|
|
182
|
+
function addFileToDescriptor(packageDescriptor, key, fileName) {
|
|
183
|
+
const relativePath = Path.join(NugetConstants.ContentFolderName, fileName);
|
|
184
|
+
packageDescriptor.files[key] = relativePath;
|
|
185
|
+
}
|
|
186
|
+
// ../coded-functions-py-packager/src/pack-functions-package.ts
|
|
2
187
|
import {
|
|
3
|
-
ensureProjectId,
|
|
4
188
|
NugetConstants as NugetConstants2,
|
|
5
189
|
NugetPackager,
|
|
6
190
|
Path as Path2,
|
|
191
|
+
TemporaryStorageService
|
|
192
|
+
} from "@uipath/solutionpackager-tool-core";
|
|
193
|
+
// ../../functions-sdk/src/language.ts
|
|
194
|
+
var FunctionsLanguages = {
|
|
195
|
+
JavaScript: "javascript",
|
|
196
|
+
Python: "python"
|
|
197
|
+
};
|
|
198
|
+
var FunctionsLanguageLabels = {
|
|
199
|
+
[FunctionsLanguages.JavaScript]: "JS/TS",
|
|
200
|
+
[FunctionsLanguages.Python]: "Python"
|
|
201
|
+
};
|
|
202
|
+
var LANGUAGE_ALIASES = {
|
|
203
|
+
[FunctionsLanguages.JavaScript]: ["ts", "js", "javascript", "typescript"],
|
|
204
|
+
[FunctionsLanguages.Python]: ["py", "python"]
|
|
205
|
+
};
|
|
206
|
+
var NO_FUNCTIONS_LANGUAGE_SIGNAL = "no uipath.json functions map, no package.json and no pyproject.toml";
|
|
207
|
+
var EXTENSION_TO_LANGUAGE = {
|
|
208
|
+
".ts": FunctionsLanguages.JavaScript,
|
|
209
|
+
".js": FunctionsLanguages.JavaScript,
|
|
210
|
+
".mjs": FunctionsLanguages.JavaScript,
|
|
211
|
+
".py": FunctionsLanguages.Python
|
|
212
|
+
};
|
|
213
|
+
function functionsLanguageFromMap(functions) {
|
|
214
|
+
const firstEntry = Object.values(functions ?? {})[0];
|
|
215
|
+
if (!firstEntry) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const filePath = firstEntry.split(":")[0] ?? "";
|
|
219
|
+
const dot = filePath.lastIndexOf(".");
|
|
220
|
+
return dot >= 0 ? EXTENSION_TO_LANGUAGE[filePath.slice(dot)] : undefined;
|
|
221
|
+
}
|
|
222
|
+
async function detectFunctionsLanguage(fileSystem, projectPath) {
|
|
223
|
+
const fromManifest = await languageFromUipathJson(fileSystem, projectPath);
|
|
224
|
+
if (fromManifest) {
|
|
225
|
+
return fromManifest;
|
|
226
|
+
}
|
|
227
|
+
if (await fileSystem.exists(fileSystem.path.join(projectPath, "package.json"))) {
|
|
228
|
+
return FunctionsLanguages.JavaScript;
|
|
229
|
+
}
|
|
230
|
+
if (await fileSystem.exists(fileSystem.path.join(projectPath, "pyproject.toml"))) {
|
|
231
|
+
return FunctionsLanguages.Python;
|
|
232
|
+
}
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
async function languageFromUipathJson(fileSystem, projectPath) {
|
|
236
|
+
const uipathJsonPath = fileSystem.path.join(projectPath, "uipath.json");
|
|
237
|
+
if (!await fileSystem.exists(uipathJsonPath)) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const content = await fileSystem.readFile(uipathJsonPath, "utf-8");
|
|
241
|
+
if (!content) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
try {
|
|
245
|
+
const uipathJson = JSON.parse(content);
|
|
246
|
+
return functionsLanguageFromMap(uipathJson.functions);
|
|
247
|
+
} catch {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// src/functions-tool.ts
|
|
253
|
+
import {
|
|
254
|
+
ensureProjectId,
|
|
255
|
+
NugetConstants as NugetConstants3,
|
|
256
|
+
NugetPackager as NugetPackager2,
|
|
257
|
+
Path as Path3,
|
|
7
258
|
ProjectTool,
|
|
8
|
-
TemporaryStorageService,
|
|
259
|
+
TemporaryStorageService as TemporaryStorageService2,
|
|
9
260
|
ToolErrorCodes,
|
|
10
261
|
ToolResult
|
|
11
262
|
} from "@uipath/solutionpackager-tool-core";
|
|
@@ -113,7 +364,7 @@ function parseUipathJson(raw) {
|
|
|
113
364
|
}
|
|
114
365
|
return uipathJson;
|
|
115
366
|
}
|
|
116
|
-
var
|
|
367
|
+
var EXCLUDED_NAMES2 = new Set([
|
|
117
368
|
"node_modules",
|
|
118
369
|
".git",
|
|
119
370
|
".env",
|
|
@@ -123,7 +374,7 @@ var EXCLUDED_NAMES = new Set([
|
|
|
123
374
|
]);
|
|
124
375
|
var EXCLUDED_EXTENSIONS = [".nupkg"];
|
|
125
376
|
var SCOPES_NOT_PACKAGED = ["@uipath"];
|
|
126
|
-
async function
|
|
377
|
+
async function buildFunctionsPackage2(fs, options) {
|
|
127
378
|
const { projectPath, outputPath, projectStorageId } = options;
|
|
128
379
|
const contentPath = fs.path.join(outputPath, "content");
|
|
129
380
|
await fs.mkdir(outputPath);
|
|
@@ -206,7 +457,7 @@ async function copyProjectFiles(fs, sourcePath, destPath, lockFile, packOptions)
|
|
|
206
457
|
await fs.mkdir(dest);
|
|
207
458
|
const entries = await fs.readdir(src);
|
|
208
459
|
for (const name of entries) {
|
|
209
|
-
if (
|
|
460
|
+
if (EXCLUDED_NAMES2.has(name))
|
|
210
461
|
continue;
|
|
211
462
|
if (extraExcludedDirs.has(name))
|
|
212
463
|
continue;
|
|
@@ -238,259 +489,18 @@ async function copyProjectFiles(fs, sourcePath, destPath, lockFile, packOptions)
|
|
|
238
489
|
|
|
239
490
|
// src/js/build-js-functions-package.ts
|
|
240
491
|
async function buildJsFunctionsPackage(fileSystem, options) {
|
|
241
|
-
await
|
|
492
|
+
await buildFunctionsPackage2(fileSystem, {
|
|
242
493
|
projectPath: options.projectPath,
|
|
243
494
|
outputPath: options.outputPath,
|
|
244
495
|
projectStorageId: options.projectStorageId
|
|
245
496
|
});
|
|
246
497
|
}
|
|
247
|
-
// src/types.ts
|
|
248
|
-
var Languages = {
|
|
249
|
-
JavaScript: "javascript",
|
|
250
|
-
Python: "python"
|
|
251
|
-
};
|
|
252
|
-
var LanguageLabels = {
|
|
253
|
-
[Languages.JavaScript]: "JS/TS",
|
|
254
|
-
[Languages.Python]: "Python"
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
// src/language-detection.ts
|
|
258
|
-
var EXTENSION_TO_LANGUAGE = {
|
|
259
|
-
".ts": Languages.JavaScript,
|
|
260
|
-
".js": Languages.JavaScript,
|
|
261
|
-
".mjs": Languages.JavaScript,
|
|
262
|
-
".py": Languages.Python
|
|
263
|
-
};
|
|
264
|
-
function languageFromFunctionsMap(functions) {
|
|
265
|
-
const firstEntry = Object.values(functions ?? {})[0];
|
|
266
|
-
if (!firstEntry) {
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
const filePath = firstEntry.split(":")[0] ?? "";
|
|
270
|
-
const dot = filePath.lastIndexOf(".");
|
|
271
|
-
return dot >= 0 ? EXTENSION_TO_LANGUAGE[filePath.slice(dot)] : undefined;
|
|
272
|
-
}
|
|
273
|
-
async function detectProjectLanguage(fileSystem, projectPath) {
|
|
274
|
-
const fromManifest = await languageFromUipathJson(fileSystem, projectPath);
|
|
275
|
-
if (fromManifest) {
|
|
276
|
-
return fromManifest;
|
|
277
|
-
}
|
|
278
|
-
if (await fileSystem.exists(fileSystem.path.join(projectPath, "package.json"))) {
|
|
279
|
-
return Languages.JavaScript;
|
|
280
|
-
}
|
|
281
|
-
if (await fileSystem.exists(fileSystem.path.join(projectPath, "pyproject.toml"))) {
|
|
282
|
-
return Languages.Python;
|
|
283
|
-
}
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
async function languageFromUipathJson(fileSystem, projectPath) {
|
|
287
|
-
const uipathJsonPath = fileSystem.path.join(projectPath, "uipath.json");
|
|
288
|
-
if (!await fileSystem.exists(uipathJsonPath)) {
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
const content = await fileSystem.readFile(uipathJsonPath, "utf-8");
|
|
292
|
-
if (!content) {
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
try {
|
|
296
|
-
const uipathJson = JSON.parse(content);
|
|
297
|
-
return languageFromFunctionsMap(uipathJson.functions);
|
|
298
|
-
} catch {
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
// src/py/build-py-functions-package.ts
|
|
304
|
-
import { NugetConstants, Path } from "@uipath/solutionpackager-tool-core";
|
|
305
|
-
|
|
306
|
-
// src/py/constants.ts
|
|
307
|
-
var EXCLUDED_NAMES2 = new Set([
|
|
308
|
-
"agent.json",
|
|
309
|
-
"project.uiproj",
|
|
310
|
-
"bindings.json",
|
|
311
|
-
"entry-points.json",
|
|
312
|
-
".DS_Store",
|
|
313
|
-
"Thumbs.db"
|
|
314
|
-
]);
|
|
315
|
-
var EXCLUDED_DIRECTORIES = new Set([
|
|
316
|
-
"evaluations",
|
|
317
|
-
".function-builder",
|
|
318
|
-
"node_modules",
|
|
319
|
-
"__pycache__",
|
|
320
|
-
".pytest_cache",
|
|
321
|
-
".venv",
|
|
322
|
-
"venv",
|
|
323
|
-
"env",
|
|
324
|
-
".git",
|
|
325
|
-
".vscode",
|
|
326
|
-
".idea",
|
|
327
|
-
".local"
|
|
328
|
-
]);
|
|
329
|
-
var CONTENT_TYPE = "function";
|
|
330
|
-
var TARGET_RUNTIME = "python";
|
|
331
|
-
var UIPATH_JSON_FILE_NAME = "uipath.json";
|
|
332
|
-
var BINDINGS_SOURCE_FILE_NAME = "bindings.json";
|
|
333
|
-
var BINDINGS_VERSION = "2.0";
|
|
334
|
-
var ENTRY_POINT_TYPE = "function";
|
|
335
|
-
var SCHEMA_BASE_URL = "https://cloud.uipath.com/draft/2024-12";
|
|
336
|
-
var SCHEMAS = {
|
|
337
|
-
Bindings: `${SCHEMA_BASE_URL}/bindings`,
|
|
338
|
-
EntryPoint: `${SCHEMA_BASE_URL}/entry-point`,
|
|
339
|
-
Operate: `${SCHEMA_BASE_URL}/operate`,
|
|
340
|
-
PackageDescriptor: `${SCHEMA_BASE_URL}/package-descriptor`
|
|
341
|
-
};
|
|
342
|
-
|
|
343
|
-
// src/py/build-py-functions-package.ts
|
|
344
|
-
async function buildPyFunctionsPackage(fileSystem, options) {
|
|
345
|
-
const contentFolder = Path.join(options.outputPath, NugetConstants.ContentFolderName);
|
|
346
|
-
await validateProjectFiles(fileSystem, options.projectPath);
|
|
347
|
-
await copyFiles(fileSystem, options.projectPath, contentFolder);
|
|
348
|
-
await writeEntryPointsFile(fileSystem, options.projectPath, contentFolder);
|
|
349
|
-
await createOperateFile(fileSystem, contentFolder, options.projectStorageId);
|
|
350
|
-
await createBindingsFile(fileSystem, options.projectPath, contentFolder);
|
|
351
|
-
await createPackageDescriptor(fileSystem, options.outputPath);
|
|
352
|
-
}
|
|
353
|
-
async function validateProjectFiles(fileSystem, projectPath) {
|
|
354
|
-
const uipathJsonPath = Path.join(projectPath, UIPATH_JSON_FILE_NAME);
|
|
355
|
-
const entryPointsPath = Path.join(projectPath, NugetConstants.EntryPointsFileName);
|
|
356
|
-
if (!await fileSystem.exists(uipathJsonPath)) {
|
|
357
|
-
throw new Error("uipath.json is missing from the project.");
|
|
358
|
-
}
|
|
359
|
-
if (!await fileSystem.exists(entryPointsPath)) {
|
|
360
|
-
throw new Error("entry-points.json is missing from the project.");
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
async function copyFiles(fileSystem, sourcePath, destinationPath) {
|
|
364
|
-
await fileSystem.mkdir(destinationPath);
|
|
365
|
-
const entries = await fileSystem.readdir(sourcePath);
|
|
366
|
-
for (const entry of entries) {
|
|
367
|
-
const sourceFile = Path.join(sourcePath, entry);
|
|
368
|
-
const destinationFile = Path.join(destinationPath, entry);
|
|
369
|
-
const stat = await fileSystem.stat(sourceFile);
|
|
370
|
-
if (stat?.isFile()) {
|
|
371
|
-
if (EXCLUDED_NAMES2.has(entry)) {
|
|
372
|
-
continue;
|
|
373
|
-
}
|
|
374
|
-
const content = await fileSystem.readFile(sourceFile);
|
|
375
|
-
if (content) {
|
|
376
|
-
await fileSystem.writeFile(destinationFile, content);
|
|
377
|
-
}
|
|
378
|
-
} else if (stat?.isDirectory()) {
|
|
379
|
-
if (EXCLUDED_DIRECTORIES.has(entry)) {
|
|
380
|
-
continue;
|
|
381
|
-
}
|
|
382
|
-
await copyFiles(fileSystem, sourceFile, destinationFile);
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
async function createOperateFile(fileSystem, contentFolder, projectStorageId) {
|
|
387
|
-
const operateJsonFilePath = Path.join(contentFolder, NugetConstants.OperateFileName);
|
|
388
|
-
const exists = await fileSystem.exists(operateJsonFilePath);
|
|
389
|
-
if (exists) {
|
|
390
|
-
return;
|
|
391
|
-
}
|
|
392
|
-
const entryPointsFilePath = Path.join(contentFolder, NugetConstants.EntryPointsFileName);
|
|
393
|
-
let mainPath = "";
|
|
394
|
-
const entryPointsExists = await fileSystem.exists(entryPointsFilePath);
|
|
395
|
-
if (entryPointsExists) {
|
|
396
|
-
const entryPointsContent = await fileSystem.readFile(entryPointsFilePath);
|
|
397
|
-
if (entryPointsContent) {
|
|
398
|
-
try {
|
|
399
|
-
const entryPointsText = new TextDecoder().decode(entryPointsContent);
|
|
400
|
-
const entryPoints = JSON.parse(entryPointsText);
|
|
401
|
-
mainPath = entryPoints.entryPoints?.[0]?.filePath ?? "";
|
|
402
|
-
} catch {}
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
const operateFileModel = {
|
|
406
|
-
$schema: SCHEMAS.Operate,
|
|
407
|
-
contentType: CONTENT_TYPE,
|
|
408
|
-
projectId: projectStorageId,
|
|
409
|
-
main: mainPath,
|
|
410
|
-
targetFramework: "Portable",
|
|
411
|
-
targetRuntime: TARGET_RUNTIME,
|
|
412
|
-
runtimeOptions: {
|
|
413
|
-
isAttended: false,
|
|
414
|
-
requiresUserInteraction: false,
|
|
415
|
-
isConversational: false
|
|
416
|
-
}
|
|
417
|
-
};
|
|
418
|
-
const operateJsonString = JSON.stringify(operateFileModel, null, 2);
|
|
419
|
-
await fileSystem.writeFile(operateJsonFilePath, operateJsonString);
|
|
420
|
-
}
|
|
421
|
-
async function writeEntryPointsFile(fileSystem, projectPath, contentFolder) {
|
|
422
|
-
const sourcePath = Path.join(projectPath, NugetConstants.EntryPointsFileName);
|
|
423
|
-
const destinationPath = Path.join(contentFolder, NugetConstants.EntryPointsFileName);
|
|
424
|
-
const raw = await fileSystem.readFile(sourcePath);
|
|
425
|
-
if (!raw) {
|
|
426
|
-
throw new Error("entry-points.json is missing from the project.");
|
|
427
|
-
}
|
|
428
|
-
let parsed;
|
|
429
|
-
try {
|
|
430
|
-
parsed = JSON.parse(new TextDecoder().decode(raw));
|
|
431
|
-
} catch {
|
|
432
|
-
throw new Error("entry-points.json is not valid JSON.");
|
|
433
|
-
}
|
|
434
|
-
const sourceEntries = Array.isArray(parsed.entryPoints) ? parsed.entryPoints : [];
|
|
435
|
-
const normalizedEntries = sourceEntries.map((entry) => ({
|
|
436
|
-
...entry,
|
|
437
|
-
uniqueId: typeof entry.uniqueId === "string" && entry.uniqueId.length > 0 ? entry.uniqueId : crypto.randomUUID(),
|
|
438
|
-
type: typeof entry.type === "string" && entry.type.length > 0 ? entry.type : ENTRY_POINT_TYPE
|
|
439
|
-
}));
|
|
440
|
-
const normalized = {
|
|
441
|
-
$schema: SCHEMAS.EntryPoint,
|
|
442
|
-
$id: NugetConstants.EntryPointsFileName,
|
|
443
|
-
entryPoints: normalizedEntries
|
|
444
|
-
};
|
|
445
|
-
await fileSystem.writeFile(destinationPath, JSON.stringify(normalized, null, 2));
|
|
446
|
-
}
|
|
447
|
-
async function createBindingsFile(fileSystem, projectPath, contentFolder) {
|
|
448
|
-
const bindingsOutputPath = Path.join(contentFolder, NugetConstants.BindingsV2FileName);
|
|
449
|
-
const sourcePath = Path.join(projectPath, BINDINGS_SOURCE_FILE_NAME);
|
|
450
|
-
let bindings = null;
|
|
451
|
-
if (await fileSystem.exists(sourcePath)) {
|
|
452
|
-
const raw = await fileSystem.readFile(sourcePath);
|
|
453
|
-
if (raw) {
|
|
454
|
-
try {
|
|
455
|
-
bindings = JSON.parse(new TextDecoder().decode(raw));
|
|
456
|
-
} catch {
|
|
457
|
-
bindings = null;
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
if (bindings === null) {
|
|
462
|
-
bindings = {
|
|
463
|
-
$schema: SCHEMAS.Bindings,
|
|
464
|
-
version: BINDINGS_VERSION,
|
|
465
|
-
resources: []
|
|
466
|
-
};
|
|
467
|
-
}
|
|
468
|
-
await fileSystem.writeFile(bindingsOutputPath, JSON.stringify(bindings, null, 2));
|
|
469
|
-
}
|
|
470
|
-
async function createPackageDescriptor(fileSystem, localBuildFolder) {
|
|
471
|
-
const packageDescriptor = {
|
|
472
|
-
files: {}
|
|
473
|
-
};
|
|
474
|
-
addFileToDescriptor(packageDescriptor, NugetConstants.OperateFileName, NugetConstants.OperateFileName);
|
|
475
|
-
addFileToDescriptor(packageDescriptor, NugetConstants.EntryPointsFileName, NugetConstants.EntryPointsFileName);
|
|
476
|
-
addFileToDescriptor(packageDescriptor, NugetConstants.BindingsFileId, NugetConstants.BindingsV2FileName);
|
|
477
|
-
const packageDescriptorPath = Path.join(localBuildFolder, NugetConstants.ContentFolderName, NugetConstants.PackageDescriptorFileName);
|
|
478
|
-
const packageDescriptorJson = JSON.stringify({
|
|
479
|
-
$schema: SCHEMAS.PackageDescriptor,
|
|
480
|
-
...packageDescriptor
|
|
481
|
-
}, null, 2);
|
|
482
|
-
await fileSystem.writeFile(packageDescriptorPath, packageDescriptorJson);
|
|
483
|
-
}
|
|
484
|
-
function addFileToDescriptor(packageDescriptor, key, fileName) {
|
|
485
|
-
const relativePath = Path.join(NugetConstants.ContentFolderName, fileName);
|
|
486
|
-
packageDescriptor.files[key] = relativePath;
|
|
487
|
-
}
|
|
488
498
|
// src/functions-tool.ts
|
|
489
499
|
class FunctionsTool extends ProjectTool {
|
|
490
500
|
_temporaryStorage;
|
|
491
501
|
constructor(fileSystem, logger) {
|
|
492
502
|
super(fileSystem, logger);
|
|
493
|
-
this._temporaryStorage = new
|
|
503
|
+
this._temporaryStorage = new TemporaryStorageService2(fileSystem);
|
|
494
504
|
}
|
|
495
505
|
async restoreAsync(_options, _cancellationToken) {
|
|
496
506
|
this.logger.info("Restore not required for Functions projects.");
|
|
@@ -510,10 +520,10 @@ class FunctionsTool extends ProjectTool {
|
|
|
510
520
|
return prepared;
|
|
511
521
|
}
|
|
512
522
|
const tempFolder = await this._temporaryStorage.getTempFolderPath();
|
|
513
|
-
const localBuildFolder =
|
|
514
|
-
const build = probe.language ===
|
|
523
|
+
const localBuildFolder = Path3.join(tempFolder, NugetConstants3.OutputFolderName);
|
|
524
|
+
const build = probe.language === FunctionsLanguages.Python ? buildFunctionsPackage : buildJsFunctionsPackage;
|
|
515
525
|
try {
|
|
516
|
-
this.logger.progress(`Building ${
|
|
526
|
+
this.logger.progress(`Building ${FunctionsLanguageLabels[probe.language]} Functions package...`);
|
|
517
527
|
const projectStorageId = options.projectStorageId ?? await ensureProjectId(options.projectPath, this.fileSystem);
|
|
518
528
|
await build(this.fileSystem, {
|
|
519
529
|
projectPath: options.projectPath,
|
|
@@ -534,8 +544,8 @@ class FunctionsTool extends ProjectTool {
|
|
|
534
544
|
try {
|
|
535
545
|
this.logger.progress("Creating NuGet package...");
|
|
536
546
|
const nupkgFileName = `${options.package.id}.${options.package.version}.nupkg`;
|
|
537
|
-
const nupkgPath =
|
|
538
|
-
const packager = new
|
|
547
|
+
const nupkgPath = Path3.join(options.outputPath, nupkgFileName);
|
|
548
|
+
const packager = new NugetPackager2(this.fileSystem);
|
|
539
549
|
const result = await packager.packAsync(localBuildFolder, options.package, nupkgPath);
|
|
540
550
|
this.logger.progress("Package created successfully.");
|
|
541
551
|
return new ToolResult(ToolErrorCodes.Success, "Pack completed successfully.", [result.outputPath]);
|
|
@@ -556,18 +566,18 @@ class FunctionsTool extends ProjectTool {
|
|
|
556
566
|
async probeProject(projectPath) {
|
|
557
567
|
const [name, language] = await Promise.all([
|
|
558
568
|
this.resolveProjectName(projectPath),
|
|
559
|
-
|
|
569
|
+
detectFunctionsLanguage(this.fileSystem, projectPath)
|
|
560
570
|
]);
|
|
561
571
|
return { name, language };
|
|
562
572
|
}
|
|
563
573
|
uninitializedProjectResult(probe, projectPath) {
|
|
564
|
-
const message = `${describeProject(probe)} is not initialized: ${projectPath} has
|
|
574
|
+
const message = `${describeProject(probe)} is not initialized: ${projectPath} has ${NO_FUNCTIONS_LANGUAGE_SIGNAL}.`;
|
|
565
575
|
this.logger.error(message);
|
|
566
576
|
return ToolResult.error(ToolErrorCodes.InternalError, message, "Initialize the project, then pack again.");
|
|
567
577
|
}
|
|
568
578
|
failureResult(probe, stage, error) {
|
|
569
579
|
const inner = error instanceof Error ? error.message : String(error);
|
|
570
|
-
const languageLabel = probe.language === undefined ? "" : ` (${
|
|
580
|
+
const languageLabel = probe.language === undefined ? "" : ` (${FunctionsLanguageLabels[probe.language]})`;
|
|
571
581
|
const message = `${stage} failed for ${describeProject(probe)}${languageLabel}: ${inner}`;
|
|
572
582
|
this.logger.error(error instanceof Error ? error.toString() : String(error));
|
|
573
583
|
return ToolResult.error(ToolErrorCodes.InternalError, message);
|
|
@@ -596,10 +606,7 @@ class FunctionsToolFactory {
|
|
|
596
606
|
}
|
|
597
607
|
export {
|
|
598
608
|
FunctionsTool,
|
|
599
|
-
FunctionsToolFactory
|
|
600
|
-
Languages,
|
|
601
|
-
detectProjectLanguage,
|
|
602
|
-
languageFromFunctionsMap
|
|
609
|
+
FunctionsToolFactory
|
|
603
610
|
};
|
|
604
611
|
|
|
605
|
-
//# debugId=
|
|
612
|
+
//# debugId=A28EDB26836FC18364756E2164756E21
|
package/dist/types.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type { IFileSystem } from "@uipath/solutionpackager-tool-core";
|
|
2
|
-
|
|
2
|
+
declare const PROBE_LANGUAGES: {
|
|
3
3
|
readonly JavaScript: "javascript";
|
|
4
4
|
readonly Python: "python";
|
|
5
5
|
};
|
|
6
|
-
export type Language = (typeof Languages)[keyof typeof Languages];
|
|
7
|
-
export declare const LanguageLabels: Record<Language, string>;
|
|
8
6
|
/**
|
|
9
7
|
* What `FunctionsTool.probeProject` learns about a project before building
|
|
10
8
|
* it. `name` is project.uiproj's Name, or "" when it declares none.
|
|
@@ -13,7 +11,7 @@ export declare const LanguageLabels: Record<Language, string>;
|
|
|
13
11
|
*/
|
|
14
12
|
export interface FunctionsProjectProbe {
|
|
15
13
|
name: string;
|
|
16
|
-
language:
|
|
14
|
+
language: (typeof PROBE_LANGUAGES)[keyof typeof PROBE_LANGUAGES] | undefined;
|
|
17
15
|
}
|
|
18
16
|
export interface BuildPackageOptions {
|
|
19
17
|
projectPath: string;
|
|
@@ -21,3 +19,4 @@ export interface BuildPackageOptions {
|
|
|
21
19
|
projectStorageId: string;
|
|
22
20
|
}
|
|
23
21
|
export type BuildPackageFn = (fileSystem: IFileSystem, options: BuildPackageOptions) => Promise<void>;
|
|
22
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/packager-tool-functions",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.207.0-preview.305",
|
|
4
4
|
"description": "UiPath Functions tool implementation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
|
-
".": "./dist/index.js"
|
|
8
|
-
"./language-detection": "./dist/language-detection.js"
|
|
7
|
+
".": "./dist/index.js"
|
|
9
8
|
},
|
|
10
9
|
"repository": {
|
|
11
10
|
"type": "git",
|
|
@@ -22,7 +21,7 @@
|
|
|
22
21
|
"author": "UiPath",
|
|
23
22
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
24
23
|
"peerDependencies": {
|
|
25
|
-
"@uipath/solutionpackager-tool-core": "1.
|
|
24
|
+
"@uipath/solutionpackager-tool-core": "1.207.0"
|
|
26
25
|
},
|
|
27
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "1600aa89255c37c1b8bc68d9882c3395c1d5bff4"
|
|
28
27
|
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { IFileSystem } from "@uipath/solutionpackager-tool-core";
|
|
2
|
-
import { type Language } from "./types.js";
|
|
3
|
-
export type { Language } from "./types.js";
|
|
4
|
-
/**
|
|
5
|
-
* The language a uipath.json functions map declares, read off the first
|
|
6
|
-
* entry's file extension, or `undefined` when the map is missing, empty or
|
|
7
|
-
* points at an extension no runtime owns.
|
|
8
|
-
*/
|
|
9
|
-
export declare function languageFromFunctionsMap(functions?: Record<string, string>): Language | undefined;
|
|
10
|
-
/**
|
|
11
|
-
* The language of the Functions project at `projectPath`, from what its
|
|
12
|
-
* files declare. There is no language in project.uiproj, so this is the one
|
|
13
|
-
* place the CLI dispatcher and the solution packager read it from:
|
|
14
|
-
* 1. uipath.json functions map extension (.ts/.js/.mjs → javascript, .py → python)
|
|
15
|
-
* 2. package.json → javascript; pyproject.toml → python
|
|
16
|
-
* 3. neither → `undefined`: the project has not been initialized
|
|
17
|
-
*/
|
|
18
|
-
export declare function detectProjectLanguage(fileSystem: IFileSystem, projectPath: string): Promise<Language | undefined>;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
// src/types.ts
|
|
2
|
-
var Languages = {
|
|
3
|
-
JavaScript: "javascript",
|
|
4
|
-
Python: "python"
|
|
5
|
-
};
|
|
6
|
-
var LanguageLabels = {
|
|
7
|
-
[Languages.JavaScript]: "JS/TS",
|
|
8
|
-
[Languages.Python]: "Python"
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
// src/language-detection.ts
|
|
12
|
-
var EXTENSION_TO_LANGUAGE = {
|
|
13
|
-
".ts": Languages.JavaScript,
|
|
14
|
-
".js": Languages.JavaScript,
|
|
15
|
-
".mjs": Languages.JavaScript,
|
|
16
|
-
".py": Languages.Python
|
|
17
|
-
};
|
|
18
|
-
function languageFromFunctionsMap(functions) {
|
|
19
|
-
const firstEntry = Object.values(functions ?? {})[0];
|
|
20
|
-
if (!firstEntry) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const filePath = firstEntry.split(":")[0] ?? "";
|
|
24
|
-
const dot = filePath.lastIndexOf(".");
|
|
25
|
-
return dot >= 0 ? EXTENSION_TO_LANGUAGE[filePath.slice(dot)] : undefined;
|
|
26
|
-
}
|
|
27
|
-
async function detectProjectLanguage(fileSystem, projectPath) {
|
|
28
|
-
const fromManifest = await languageFromUipathJson(fileSystem, projectPath);
|
|
29
|
-
if (fromManifest) {
|
|
30
|
-
return fromManifest;
|
|
31
|
-
}
|
|
32
|
-
if (await fileSystem.exists(fileSystem.path.join(projectPath, "package.json"))) {
|
|
33
|
-
return Languages.JavaScript;
|
|
34
|
-
}
|
|
35
|
-
if (await fileSystem.exists(fileSystem.path.join(projectPath, "pyproject.toml"))) {
|
|
36
|
-
return Languages.Python;
|
|
37
|
-
}
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
async function languageFromUipathJson(fileSystem, projectPath) {
|
|
41
|
-
const uipathJsonPath = fileSystem.path.join(projectPath, "uipath.json");
|
|
42
|
-
if (!await fileSystem.exists(uipathJsonPath)) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const content = await fileSystem.readFile(uipathJsonPath, "utf-8");
|
|
46
|
-
if (!content) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
try {
|
|
50
|
-
const uipathJson = JSON.parse(content);
|
|
51
|
-
return languageFromFunctionsMap(uipathJson.functions);
|
|
52
|
-
} catch {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
export {
|
|
57
|
-
detectProjectLanguage,
|
|
58
|
-
languageFromFunctionsMap
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
//# debugId=47785DEAEF1EDBB764756E2164756E21
|
package/dist/py/constants.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare const EXCLUDED_NAMES: Set<string>;
|
|
2
|
-
export declare const EXCLUDED_DIRECTORIES: Set<string>;
|
|
3
|
-
export declare const CONTENT_TYPE = "function";
|
|
4
|
-
export declare const TARGET_RUNTIME = "python";
|
|
5
|
-
export declare const UIPATH_JSON_FILE_NAME = "uipath.json";
|
|
6
|
-
export declare const BINDINGS_SOURCE_FILE_NAME = "bindings.json";
|
|
7
|
-
export declare const BINDINGS_VERSION = "2.0";
|
|
8
|
-
export declare const ENTRY_POINT_TYPE = "function";
|
|
9
|
-
export declare const SCHEMAS: {
|
|
10
|
-
readonly Bindings: "https://cloud.uipath.com/draft/2024-12/bindings";
|
|
11
|
-
readonly EntryPoint: "https://cloud.uipath.com/draft/2024-12/entry-point";
|
|
12
|
-
readonly Operate: "https://cloud.uipath.com/draft/2024-12/operate";
|
|
13
|
-
readonly PackageDescriptor: "https://cloud.uipath.com/draft/2024-12/package-descriptor";
|
|
14
|
-
};
|
package/dist/py/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { buildPyFunctionsPackage } from "./build-py-functions-package.js";
|