@uipath/packager-tool-functions 1.202.0-preview.141 → 1.202.0-preview.143
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/LICENSE.txt +3 -0
- package/dist/THIRD-PARTY-NOTICES.md +8 -0
- package/package.json +5 -9
- package/src/functions-tool-factory.ts +0 -24
- package/src/functions-tool.ts +0 -180
- package/src/index.ts +0 -10
- package/src/js/build-js-functions-package.ts +0 -14
- package/src/js/index.ts +0 -1
- package/src/py/build-py-functions-package.ts +0 -287
- package/src/py/constants.ts +0 -40
- package/src/py/index.ts +0 -1
- package/src/types.ts +0 -24
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
© 2026 UiPath
|
|
2
|
+
Use of this product is subject (a) to the applicable licensing agreement available: https://www.uipath.com/legal/trust-and-security/legal-terms#content-1 and, (b) for paid products listed here https://licensing.uipath.com/: the licensing agreement agreed between you and UiPath.
|
|
3
|
+
(UiPath means UiPath SRL with headquarters at 4 Vasile Alecsandri Str. and 11 Constantin Daniel Str., Building A, floors 5 and 6, District 1, Bucharest 010639, Romania and UiPath Inc. with principal place of business: One Vanderbilt Avenue, 60th Floor, New York, NY 10017)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Third-party notices for @uipath/packager-tool-functions
|
|
2
|
+
|
|
3
|
+
This package is distributed as a bundle: the dependencies below are
|
|
4
|
+
compiled into its `dist/` output rather than installed alongside it.
|
|
5
|
+
Their licences and copyright notices are reproduced here in full, as
|
|
6
|
+
those licences require.
|
|
7
|
+
|
|
8
|
+
No third-party code is bundled into this package.
|
package/package.json
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/packager-tool-functions",
|
|
3
|
-
"version": "1.202.0-preview.
|
|
3
|
+
"version": "1.202.0-preview.143",
|
|
4
4
|
"description": "UiPath Functions tool implementation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
|
-
".":
|
|
8
|
-
"source": "./src/index.ts",
|
|
9
|
-
"default": "./dist/index.js"
|
|
10
|
-
}
|
|
7
|
+
".": "./dist/index.js"
|
|
11
8
|
},
|
|
12
9
|
"repository": {
|
|
13
10
|
"type": "git",
|
|
@@ -19,13 +16,12 @@
|
|
|
19
16
|
},
|
|
20
17
|
"types": "./dist/index.d.ts",
|
|
21
18
|
"files": [
|
|
22
|
-
"dist"
|
|
23
|
-
"src"
|
|
19
|
+
"dist"
|
|
24
20
|
],
|
|
25
21
|
"author": "",
|
|
26
|
-
"license": "
|
|
22
|
+
"license": "SEE LICENSE IN LICENSE.txt",
|
|
27
23
|
"peerDependencies": {
|
|
28
24
|
"@uipath/solutionpackager-tool-core": "1.202.0"
|
|
29
25
|
},
|
|
30
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "23b5a7038ead7264439af18f8b807c7cc99a29d5"
|
|
31
27
|
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type IFileSystem,
|
|
3
|
-
type IProjectToolFactory,
|
|
4
|
-
type IToolLogger,
|
|
5
|
-
type ProjectTool,
|
|
6
|
-
type ProjectType,
|
|
7
|
-
ProjectTypes,
|
|
8
|
-
} from "@uipath/solutionpackager-tool-core";
|
|
9
|
-
import { FunctionsTool } from "./functions-tool.js";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Factory for creating Functions project tools.
|
|
13
|
-
* Handles projects with projectType "Function".
|
|
14
|
-
*/
|
|
15
|
-
export class FunctionsToolFactory implements IProjectToolFactory {
|
|
16
|
-
readonly supportedTypes: readonly ProjectType[] = [ProjectTypes.Function];
|
|
17
|
-
|
|
18
|
-
async createAsync(
|
|
19
|
-
logger: IToolLogger,
|
|
20
|
-
fileSystem: IFileSystem,
|
|
21
|
-
): Promise<ProjectTool> {
|
|
22
|
-
return new FunctionsTool(fileSystem, logger);
|
|
23
|
-
}
|
|
24
|
-
}
|
package/src/functions-tool.ts
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
IProjectBuildOptions,
|
|
3
|
-
IProjectPackOptions,
|
|
4
|
-
IProjectRestoreOptions,
|
|
5
|
-
IProjectValidateOptions,
|
|
6
|
-
} from "@uipath/solutionpackager-tool-core";
|
|
7
|
-
import {
|
|
8
|
-
ensureProjectId,
|
|
9
|
-
type IFileSystem,
|
|
10
|
-
type IToolLogger,
|
|
11
|
-
NugetConstants,
|
|
12
|
-
NugetPackager,
|
|
13
|
-
Path,
|
|
14
|
-
ProjectTool,
|
|
15
|
-
TemporaryStorageService,
|
|
16
|
-
ToolErrorCodes,
|
|
17
|
-
ToolResult,
|
|
18
|
-
} from "@uipath/solutionpackager-tool-core";
|
|
19
|
-
import { buildJsFunctionsPackage } from "./js/index.js";
|
|
20
|
-
import { buildPyFunctionsPackage } from "./py/index.js";
|
|
21
|
-
import {
|
|
22
|
-
type BuildPackageFn,
|
|
23
|
-
type Language,
|
|
24
|
-
LanguageLabels,
|
|
25
|
-
Languages,
|
|
26
|
-
} from "./types.js";
|
|
27
|
-
|
|
28
|
-
export class FunctionsTool extends ProjectTool {
|
|
29
|
-
private readonly _temporaryStorage: TemporaryStorageService;
|
|
30
|
-
|
|
31
|
-
constructor(fileSystem: IFileSystem, logger: IToolLogger) {
|
|
32
|
-
super(fileSystem, logger);
|
|
33
|
-
this._temporaryStorage = new TemporaryStorageService(fileSystem);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
override async restoreAsync(
|
|
37
|
-
_options: IProjectRestoreOptions,
|
|
38
|
-
_cancellationToken?: AbortSignal,
|
|
39
|
-
): Promise<ToolResult> {
|
|
40
|
-
this.logger.info("Restore not required for Functions projects.");
|
|
41
|
-
return ToolResult.success();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
override async validateAsync(
|
|
45
|
-
_options: IProjectValidateOptions,
|
|
46
|
-
_cancellationToken?: AbortSignal,
|
|
47
|
-
): Promise<ToolResult> {
|
|
48
|
-
this.logger.info("Validate not required for Functions projects.");
|
|
49
|
-
return ToolResult.success();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
override async buildAsync(
|
|
53
|
-
options: IProjectBuildOptions,
|
|
54
|
-
_cancellationToken?: AbortSignal,
|
|
55
|
-
): Promise<ToolResult> {
|
|
56
|
-
const language = await this.detectLanguage(options.projectPath);
|
|
57
|
-
const tempFolder = await this._temporaryStorage.getTempFolderPath();
|
|
58
|
-
const localBuildFolder = Path.join(
|
|
59
|
-
tempFolder,
|
|
60
|
-
NugetConstants.OutputFolderName,
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
const build: BuildPackageFn =
|
|
64
|
-
language === Languages.Python
|
|
65
|
-
? buildPyFunctionsPackage
|
|
66
|
-
: buildJsFunctionsPackage;
|
|
67
|
-
const languageLabel = LanguageLabels[language];
|
|
68
|
-
|
|
69
|
-
try {
|
|
70
|
-
this.logger.progress(
|
|
71
|
-
`Building ${languageLabel} Functions package...`,
|
|
72
|
-
);
|
|
73
|
-
const projectStorageId =
|
|
74
|
-
options.projectStorageId ??
|
|
75
|
-
(await ensureProjectId(options.projectPath, this.fileSystem));
|
|
76
|
-
await build(this.fileSystem, {
|
|
77
|
-
projectPath: options.projectPath,
|
|
78
|
-
outputPath: localBuildFolder,
|
|
79
|
-
projectStorageId,
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
return new ToolResult(
|
|
83
|
-
ToolErrorCodes.Success,
|
|
84
|
-
"Build completed successfully.",
|
|
85
|
-
[localBuildFolder],
|
|
86
|
-
);
|
|
87
|
-
} catch (error) {
|
|
88
|
-
const errorMessage =
|
|
89
|
-
error instanceof Error ? error.toString() : String(error);
|
|
90
|
-
this.logger.error(errorMessage);
|
|
91
|
-
return ToolResult.error(
|
|
92
|
-
ToolErrorCodes.InternalError,
|
|
93
|
-
`Build failed for ${languageLabel} Functions project.`,
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
override async packAsync(
|
|
99
|
-
options: IProjectPackOptions,
|
|
100
|
-
cancellationToken?: AbortSignal,
|
|
101
|
-
): Promise<ToolResult> {
|
|
102
|
-
const buildResult = await this.buildAsync(options, cancellationToken);
|
|
103
|
-
if (!buildResult.isSuccess) {
|
|
104
|
-
return buildResult;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const localBuildFolder = buildResult.packages[0];
|
|
108
|
-
|
|
109
|
-
try {
|
|
110
|
-
this.logger.progress("Creating NuGet package...");
|
|
111
|
-
|
|
112
|
-
const nupkgFileName = `${options.package.id}.${options.package.version}.nupkg`;
|
|
113
|
-
const nupkgPath = Path.join(options.outputPath, nupkgFileName);
|
|
114
|
-
|
|
115
|
-
const packager = new NugetPackager(this.fileSystem);
|
|
116
|
-
const result = await packager.packAsync(
|
|
117
|
-
localBuildFolder,
|
|
118
|
-
options.package,
|
|
119
|
-
nupkgPath,
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
this.logger.progress("Package created successfully.");
|
|
123
|
-
return new ToolResult(
|
|
124
|
-
ToolErrorCodes.Success,
|
|
125
|
-
"Pack completed successfully.",
|
|
126
|
-
[result.outputPath],
|
|
127
|
-
);
|
|
128
|
-
} catch (error) {
|
|
129
|
-
const errorMessage =
|
|
130
|
-
error instanceof Error ? error.toString() : String(error);
|
|
131
|
-
this.logger.error(errorMessage);
|
|
132
|
-
return ToolResult.error(
|
|
133
|
-
ToolErrorCodes.InternalError,
|
|
134
|
-
"Pack failed for Functions project.",
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
override async dispose(): Promise<void> {
|
|
140
|
-
this.logger.info("Disposing Functions Tool");
|
|
141
|
-
try {
|
|
142
|
-
await this._temporaryStorage.cleanup();
|
|
143
|
-
} catch {
|
|
144
|
-
// Ignore errors during cleanup
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Detects project language from uipath.json functions map extensions.
|
|
149
|
-
// Mirrors detectProjectKind() in @uipath/tool-agent (Agents repo):
|
|
150
|
-
// primary: uipath.json functions map extension (.ts/.js → javascript, .py → python)
|
|
151
|
-
// fallback: pyproject.toml presence → python (same signal Agents uses)
|
|
152
|
-
protected async detectLanguage(projectPath: string): Promise<Language> {
|
|
153
|
-
const uipathJsonContent = await this.fileSystem.readFile(
|
|
154
|
-
Path.join(projectPath, "uipath.json"),
|
|
155
|
-
"utf-8",
|
|
156
|
-
);
|
|
157
|
-
if (uipathJsonContent) {
|
|
158
|
-
try {
|
|
159
|
-
const uipathJson = JSON.parse(uipathJsonContent as string) as {
|
|
160
|
-
functions?: Record<string, string>;
|
|
161
|
-
};
|
|
162
|
-
const firstEntry = Object.values(uipathJson.functions ?? {})[0];
|
|
163
|
-
if (firstEntry) {
|
|
164
|
-
const filePath = firstEntry.split(":")[0] ?? "";
|
|
165
|
-
const ext = filePath.slice(filePath.lastIndexOf("."));
|
|
166
|
-
if (ext === ".ts" || ext === ".js" || ext === ".mjs")
|
|
167
|
-
return Languages.JavaScript;
|
|
168
|
-
if (ext === ".py") return Languages.Python;
|
|
169
|
-
}
|
|
170
|
-
} catch {
|
|
171
|
-
// fall through to fallback
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
const pyprojectStat = await this.fileSystem.stat(
|
|
175
|
-
Path.join(projectPath, "pyproject.toml"),
|
|
176
|
-
);
|
|
177
|
-
if (pyprojectStat?.isFile()) return Languages.Python;
|
|
178
|
-
return Languages.JavaScript;
|
|
179
|
-
}
|
|
180
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// ============================================================================
|
|
2
|
-
// Functions tool factory. Consumers register it explicitly via
|
|
3
|
-
// `toolsFactoryRepository.registerProjectToolFactory(new FunctionsToolFactory())`.
|
|
4
|
-
// ============================================================================
|
|
5
|
-
|
|
6
|
-
// Base tool + language detection, subclassable by Node-only hosts that add
|
|
7
|
-
// manifest generation before packing (function-tool's packager entry).
|
|
8
|
-
export { FunctionsTool } from "./functions-tool.js";
|
|
9
|
-
export { FunctionsToolFactory } from "./functions-tool-factory.js";
|
|
10
|
-
export { type Language, Languages } from "./types.js";
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { buildFunctionsPackage } from "@uipath/coded-functions-js-packager";
|
|
2
|
-
import type { IFileSystem } from "@uipath/solutionpackager-tool-core";
|
|
3
|
-
import type { BuildPackageOptions } from "../types.js";
|
|
4
|
-
|
|
5
|
-
export async function buildJsFunctionsPackage(
|
|
6
|
-
fileSystem: IFileSystem,
|
|
7
|
-
options: BuildPackageOptions,
|
|
8
|
-
): Promise<void> {
|
|
9
|
-
await buildFunctionsPackage(fileSystem, {
|
|
10
|
-
projectPath: options.projectPath,
|
|
11
|
-
outputPath: options.outputPath,
|
|
12
|
-
projectStorageId: options.projectStorageId,
|
|
13
|
-
});
|
|
14
|
-
}
|
package/src/js/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { buildJsFunctionsPackage } from "./build-js-functions-package.js";
|
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
EntryPointsFileModel,
|
|
3
|
-
IFileSystem,
|
|
4
|
-
PackageDescriptorFileModel,
|
|
5
|
-
} from "@uipath/solutionpackager-tool-core";
|
|
6
|
-
import { NugetConstants, Path } from "@uipath/solutionpackager-tool-core";
|
|
7
|
-
import type { BuildPackageOptions } from "../types.js";
|
|
8
|
-
import {
|
|
9
|
-
BINDINGS_SOURCE_FILE_NAME,
|
|
10
|
-
BINDINGS_VERSION,
|
|
11
|
-
CONTENT_TYPE,
|
|
12
|
-
ENTRY_POINT_TYPE,
|
|
13
|
-
EXCLUDED_DIRECTORIES,
|
|
14
|
-
EXCLUDED_NAMES,
|
|
15
|
-
SCHEMAS,
|
|
16
|
-
TARGET_RUNTIME,
|
|
17
|
-
UIPATH_JSON_FILE_NAME,
|
|
18
|
-
} from "./constants.js";
|
|
19
|
-
|
|
20
|
-
export async function buildPyFunctionsPackage(
|
|
21
|
-
fileSystem: IFileSystem,
|
|
22
|
-
options: BuildPackageOptions,
|
|
23
|
-
): Promise<void> {
|
|
24
|
-
const contentFolder = Path.join(
|
|
25
|
-
options.outputPath,
|
|
26
|
-
NugetConstants.ContentFolderName,
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
await validateProjectFiles(fileSystem, options.projectPath);
|
|
30
|
-
await copyFiles(fileSystem, options.projectPath, contentFolder);
|
|
31
|
-
await writeEntryPointsFile(fileSystem, options.projectPath, contentFolder);
|
|
32
|
-
await createOperateFile(
|
|
33
|
-
fileSystem,
|
|
34
|
-
contentFolder,
|
|
35
|
-
options.projectStorageId,
|
|
36
|
-
);
|
|
37
|
-
await createBindingsFile(fileSystem, options.projectPath, contentFolder);
|
|
38
|
-
await createPackageDescriptor(fileSystem, options.outputPath);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async function validateProjectFiles(
|
|
42
|
-
fileSystem: IFileSystem,
|
|
43
|
-
projectPath: string,
|
|
44
|
-
): Promise<void> {
|
|
45
|
-
const uipathJsonPath = Path.join(projectPath, UIPATH_JSON_FILE_NAME);
|
|
46
|
-
const entryPointsPath = Path.join(
|
|
47
|
-
projectPath,
|
|
48
|
-
NugetConstants.EntryPointsFileName,
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
if (!(await fileSystem.exists(uipathJsonPath))) {
|
|
52
|
-
throw new Error("uipath.json is missing from the project.");
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (!(await fileSystem.exists(entryPointsPath))) {
|
|
56
|
-
throw new Error("entry-points.json is missing from the project.");
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async function copyFiles(
|
|
61
|
-
fileSystem: IFileSystem,
|
|
62
|
-
sourcePath: string,
|
|
63
|
-
destinationPath: string,
|
|
64
|
-
): Promise<void> {
|
|
65
|
-
await fileSystem.mkdir(destinationPath);
|
|
66
|
-
|
|
67
|
-
const entries = await fileSystem.readdir(sourcePath);
|
|
68
|
-
|
|
69
|
-
for (const entry of entries) {
|
|
70
|
-
const sourceFile = Path.join(sourcePath, entry);
|
|
71
|
-
const destinationFile = Path.join(destinationPath, entry);
|
|
72
|
-
|
|
73
|
-
const stat = await fileSystem.stat(sourceFile);
|
|
74
|
-
if (stat?.isFile()) {
|
|
75
|
-
if (EXCLUDED_NAMES.has(entry)) {
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
const content = await fileSystem.readFile(sourceFile);
|
|
79
|
-
if (content) {
|
|
80
|
-
await fileSystem.writeFile(destinationFile, content);
|
|
81
|
-
}
|
|
82
|
-
} else if (stat?.isDirectory()) {
|
|
83
|
-
if (EXCLUDED_DIRECTORIES.has(entry)) {
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
await copyFiles(fileSystem, sourceFile, destinationFile);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
async function createOperateFile(
|
|
92
|
-
fileSystem: IFileSystem,
|
|
93
|
-
contentFolder: string,
|
|
94
|
-
projectStorageId: string,
|
|
95
|
-
): Promise<void> {
|
|
96
|
-
const operateJsonFilePath = Path.join(
|
|
97
|
-
contentFolder,
|
|
98
|
-
NugetConstants.OperateFileName,
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
const exists = await fileSystem.exists(operateJsonFilePath);
|
|
102
|
-
if (exists) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const entryPointsFilePath = Path.join(
|
|
107
|
-
contentFolder,
|
|
108
|
-
NugetConstants.EntryPointsFileName,
|
|
109
|
-
);
|
|
110
|
-
let mainPath = "";
|
|
111
|
-
|
|
112
|
-
const entryPointsExists = await fileSystem.exists(entryPointsFilePath);
|
|
113
|
-
if (entryPointsExists) {
|
|
114
|
-
const entryPointsContent =
|
|
115
|
-
await fileSystem.readFile(entryPointsFilePath);
|
|
116
|
-
if (entryPointsContent) {
|
|
117
|
-
try {
|
|
118
|
-
const entryPointsText = new TextDecoder().decode(
|
|
119
|
-
entryPointsContent,
|
|
120
|
-
);
|
|
121
|
-
const entryPoints: EntryPointsFileModel =
|
|
122
|
-
JSON.parse(entryPointsText);
|
|
123
|
-
mainPath = entryPoints.entryPoints?.[0]?.filePath ?? "";
|
|
124
|
-
} catch {
|
|
125
|
-
// Ignore parse errors, use empty mainPath
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const operateFileModel = {
|
|
131
|
-
$schema: SCHEMAS.Operate,
|
|
132
|
-
contentType: CONTENT_TYPE,
|
|
133
|
-
projectId: projectStorageId,
|
|
134
|
-
main: mainPath,
|
|
135
|
-
targetFramework: "Portable",
|
|
136
|
-
targetRuntime: TARGET_RUNTIME,
|
|
137
|
-
runtimeOptions: {
|
|
138
|
-
isAttended: false,
|
|
139
|
-
requiresUserInteraction: false,
|
|
140
|
-
isConversational: false,
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
const operateJsonString = JSON.stringify(operateFileModel, null, 2);
|
|
145
|
-
await fileSystem.writeFile(operateJsonFilePath, operateJsonString);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
async function writeEntryPointsFile(
|
|
149
|
-
fileSystem: IFileSystem,
|
|
150
|
-
projectPath: string,
|
|
151
|
-
contentFolder: string,
|
|
152
|
-
): Promise<void> {
|
|
153
|
-
const sourcePath = Path.join(
|
|
154
|
-
projectPath,
|
|
155
|
-
NugetConstants.EntryPointsFileName,
|
|
156
|
-
);
|
|
157
|
-
const destinationPath = Path.join(
|
|
158
|
-
contentFolder,
|
|
159
|
-
NugetConstants.EntryPointsFileName,
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
const raw = await fileSystem.readFile(sourcePath);
|
|
163
|
-
if (!raw) {
|
|
164
|
-
throw new Error("entry-points.json is missing from the project.");
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
let parsed: Record<string, unknown>;
|
|
168
|
-
try {
|
|
169
|
-
parsed = JSON.parse(new TextDecoder().decode(raw));
|
|
170
|
-
} catch {
|
|
171
|
-
throw new Error("entry-points.json is not valid JSON.");
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const sourceEntries = Array.isArray(parsed.entryPoints)
|
|
175
|
-
? (parsed.entryPoints as Record<string, unknown>[])
|
|
176
|
-
: [];
|
|
177
|
-
|
|
178
|
-
const normalizedEntries = sourceEntries.map((entry) => ({
|
|
179
|
-
...entry,
|
|
180
|
-
uniqueId:
|
|
181
|
-
typeof entry.uniqueId === "string" && entry.uniqueId.length > 0
|
|
182
|
-
? entry.uniqueId
|
|
183
|
-
: crypto.randomUUID(),
|
|
184
|
-
type:
|
|
185
|
-
typeof entry.type === "string" && entry.type.length > 0
|
|
186
|
-
? entry.type
|
|
187
|
-
: ENTRY_POINT_TYPE,
|
|
188
|
-
}));
|
|
189
|
-
|
|
190
|
-
const normalized = {
|
|
191
|
-
$schema: SCHEMAS.EntryPoint,
|
|
192
|
-
$id: NugetConstants.EntryPointsFileName,
|
|
193
|
-
entryPoints: normalizedEntries,
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
await fileSystem.writeFile(
|
|
197
|
-
destinationPath,
|
|
198
|
-
JSON.stringify(normalized, null, 2),
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
async function createBindingsFile(
|
|
203
|
-
fileSystem: IFileSystem,
|
|
204
|
-
projectPath: string,
|
|
205
|
-
contentFolder: string,
|
|
206
|
-
): Promise<void> {
|
|
207
|
-
const bindingsOutputPath = Path.join(
|
|
208
|
-
contentFolder,
|
|
209
|
-
NugetConstants.BindingsV2FileName,
|
|
210
|
-
);
|
|
211
|
-
|
|
212
|
-
const sourcePath = Path.join(projectPath, BINDINGS_SOURCE_FILE_NAME);
|
|
213
|
-
let bindings: unknown = null;
|
|
214
|
-
|
|
215
|
-
if (await fileSystem.exists(sourcePath)) {
|
|
216
|
-
const raw = await fileSystem.readFile(sourcePath);
|
|
217
|
-
if (raw) {
|
|
218
|
-
try {
|
|
219
|
-
bindings = JSON.parse(new TextDecoder().decode(raw));
|
|
220
|
-
} catch {
|
|
221
|
-
bindings = null;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
if (bindings === null) {
|
|
227
|
-
bindings = {
|
|
228
|
-
$schema: SCHEMAS.Bindings,
|
|
229
|
-
version: BINDINGS_VERSION,
|
|
230
|
-
resources: [],
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
await fileSystem.writeFile(
|
|
235
|
-
bindingsOutputPath,
|
|
236
|
-
JSON.stringify(bindings, null, 2),
|
|
237
|
-
);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
async function createPackageDescriptor(
|
|
241
|
-
fileSystem: IFileSystem,
|
|
242
|
-
localBuildFolder: string,
|
|
243
|
-
): Promise<void> {
|
|
244
|
-
const packageDescriptor: PackageDescriptorFileModel = {
|
|
245
|
-
files: {},
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
addFileToDescriptor(
|
|
249
|
-
packageDescriptor,
|
|
250
|
-
NugetConstants.OperateFileName,
|
|
251
|
-
NugetConstants.OperateFileName,
|
|
252
|
-
);
|
|
253
|
-
addFileToDescriptor(
|
|
254
|
-
packageDescriptor,
|
|
255
|
-
NugetConstants.EntryPointsFileName,
|
|
256
|
-
NugetConstants.EntryPointsFileName,
|
|
257
|
-
);
|
|
258
|
-
addFileToDescriptor(
|
|
259
|
-
packageDescriptor,
|
|
260
|
-
NugetConstants.BindingsFileId,
|
|
261
|
-
NugetConstants.BindingsV2FileName,
|
|
262
|
-
);
|
|
263
|
-
|
|
264
|
-
const packageDescriptorPath = Path.join(
|
|
265
|
-
localBuildFolder,
|
|
266
|
-
NugetConstants.ContentFolderName,
|
|
267
|
-
NugetConstants.PackageDescriptorFileName,
|
|
268
|
-
);
|
|
269
|
-
const packageDescriptorJson = JSON.stringify(
|
|
270
|
-
{
|
|
271
|
-
$schema: SCHEMAS.PackageDescriptor,
|
|
272
|
-
...packageDescriptor,
|
|
273
|
-
},
|
|
274
|
-
null,
|
|
275
|
-
2,
|
|
276
|
-
);
|
|
277
|
-
await fileSystem.writeFile(packageDescriptorPath, packageDescriptorJson);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
function addFileToDescriptor(
|
|
281
|
-
packageDescriptor: PackageDescriptorFileModel,
|
|
282
|
-
key: string,
|
|
283
|
-
fileName: string,
|
|
284
|
-
): void {
|
|
285
|
-
const relativePath = Path.join(NugetConstants.ContentFolderName, fileName);
|
|
286
|
-
packageDescriptor.files[key] = relativePath;
|
|
287
|
-
}
|
package/src/py/constants.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export const EXCLUDED_NAMES = new Set([
|
|
2
|
-
"agent.json",
|
|
3
|
-
"project.uiproj",
|
|
4
|
-
"bindings.json",
|
|
5
|
-
"entry-points.json",
|
|
6
|
-
".DS_Store",
|
|
7
|
-
"Thumbs.db",
|
|
8
|
-
]);
|
|
9
|
-
|
|
10
|
-
export const EXCLUDED_DIRECTORIES = new Set([
|
|
11
|
-
"evaluations",
|
|
12
|
-
"evals",
|
|
13
|
-
".function-builder",
|
|
14
|
-
"node_modules",
|
|
15
|
-
"__pycache__",
|
|
16
|
-
".pytest_cache",
|
|
17
|
-
".venv",
|
|
18
|
-
"venv",
|
|
19
|
-
"env",
|
|
20
|
-
".git",
|
|
21
|
-
".vscode",
|
|
22
|
-
".idea",
|
|
23
|
-
".local",
|
|
24
|
-
]);
|
|
25
|
-
|
|
26
|
-
export const CONTENT_TYPE = "function";
|
|
27
|
-
export const TARGET_RUNTIME = "python";
|
|
28
|
-
export const UIPATH_JSON_FILE_NAME = "uipath.json";
|
|
29
|
-
export const BINDINGS_SOURCE_FILE_NAME = "bindings.json";
|
|
30
|
-
export const BINDINGS_VERSION = "2.0";
|
|
31
|
-
export const ENTRY_POINT_TYPE = "function";
|
|
32
|
-
|
|
33
|
-
const SCHEMA_BASE_URL = "https://cloud.uipath.com/draft/2024-12";
|
|
34
|
-
|
|
35
|
-
export const SCHEMAS = {
|
|
36
|
-
Bindings: `${SCHEMA_BASE_URL}/bindings`,
|
|
37
|
-
EntryPoint: `${SCHEMA_BASE_URL}/entry-point`,
|
|
38
|
-
Operate: `${SCHEMA_BASE_URL}/operate`,
|
|
39
|
-
PackageDescriptor: `${SCHEMA_BASE_URL}/package-descriptor`,
|
|
40
|
-
} as const;
|
package/src/py/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { buildPyFunctionsPackage } from "./build-py-functions-package.js";
|
package/src/types.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { IFileSystem } from "@uipath/solutionpackager-tool-core";
|
|
2
|
-
|
|
3
|
-
export const Languages = {
|
|
4
|
-
JavaScript: "javascript",
|
|
5
|
-
Python: "python",
|
|
6
|
-
} as const;
|
|
7
|
-
|
|
8
|
-
export type Language = (typeof Languages)[keyof typeof Languages];
|
|
9
|
-
|
|
10
|
-
export const LanguageLabels: Record<Language, string> = {
|
|
11
|
-
[Languages.JavaScript]: "JS/TS",
|
|
12
|
-
[Languages.Python]: "Python",
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export interface BuildPackageOptions {
|
|
16
|
-
projectPath: string;
|
|
17
|
-
outputPath: string;
|
|
18
|
-
projectStorageId: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type BuildPackageFn = (
|
|
22
|
-
fileSystem: IFileSystem,
|
|
23
|
-
options: BuildPackageOptions,
|
|
24
|
-
) => Promise<void>;
|