@uipath/api-workflow-tool
Advanced tools
| import { | ||
| BrowserContextStorage, | ||
| ConsoleTelemetryProvider, | ||
| GovernancePolicyService, | ||
| PackService, | ||
| PackagerParameters, | ||
| PackagerParametersValidator, | ||
| ProjectBuildOptionsValidator, | ||
| ProjectLoader, | ||
| ProjectPackager, | ||
| ProjectToolExecutor, | ||
| ProjectValidateOptionsValidator, | ||
| RulesConfigFileType, | ||
| TelemetryNames, | ||
| TelemetryService, | ||
| ToolLogger, | ||
| ToolsFactory, | ||
| resolveProducedNupkgsAsync, | ||
| setGlobalLogHandler, | ||
| signNupkgsAsync | ||
| } from "./packager-tool-9yfnj0t1.js"; | ||
| import { | ||
| ToolErrorCodes, | ||
| ToolResult, | ||
| translate | ||
| } from "./packager-tool-h1tyrbff.js"; | ||
| import"./packager-tool-wckvcay0.js"; | ||
| // ../packager/project-packager/src/models/project-restore-options.ts | ||
| class ProjectRestoreOptions extends PackagerParameters { | ||
| } | ||
| // ../packager/project-packager/src/models/project-validate-options.ts | ||
| class ProjectValidateOptions extends ProjectRestoreOptions { | ||
| validateOptions = { | ||
| skipAnalyze: false, | ||
| skipValidate: false, | ||
| governanceFileType: "Default" /* Default */ | ||
| }; | ||
| } | ||
| // ../packager/project-packager/src/models/project-build-options.ts | ||
| class ProjectBuildOptions extends ProjectValidateOptions { | ||
| outputType; | ||
| } | ||
| // ../packager/project-packager/src/models/project-cleanup-options.ts | ||
| class ProjectCleanupOptions extends PackagerParameters { | ||
| dryRun = false; | ||
| skipImports = false; | ||
| lockKey; | ||
| } | ||
| // ../packager/project-packager/src/models/project-pack-options.ts | ||
| class ProjectPackOptions extends ProjectBuildOptions { | ||
| destinationPath; | ||
| package; | ||
| signingInfo; | ||
| packOptions; | ||
| } | ||
| // ../packager/project-packager/src/publish/models/publish-options.ts | ||
| var PublishDestinationKind; | ||
| ((PublishDestinationKind2) => { | ||
| PublishDestinationKind2["LocalFolder"] = "LocalFolder"; | ||
| PublishDestinationKind2["NugetFeed"] = "NugetFeed"; | ||
| PublishDestinationKind2["OrchestratorPersonalWorkspace"] = "OrchestratorPersonalWorkspace"; | ||
| PublishDestinationKind2["OrchestratorTenantProcesses"] = "OrchestratorTenantProcesses"; | ||
| PublishDestinationKind2["OrchestratorSharedLibraries"] = "OrchestratorSharedLibraries"; | ||
| PublishDestinationKind2["OrchestratorCustom"] = "OrchestratorCustom"; | ||
| })(PublishDestinationKind ||= {}); | ||
| class ProjectPublishOptions { | ||
| packagePaths; | ||
| destination; | ||
| constructor(packagePaths, destination) { | ||
| this.packagePaths = packagePaths; | ||
| this.destination = destination; | ||
| } | ||
| } | ||
| // ../packager/project-packager/src/publish/services/local-folder-publisher.ts | ||
| class LocalFolderPublisher { | ||
| fileSystem; | ||
| logger; | ||
| constructor(fileSystem) { | ||
| this.fileSystem = fileSystem; | ||
| this.logger = new ToolLogger("ProjectPublisher", "LocalFolder"); | ||
| } | ||
| async publishAsync(packagePaths, destination) { | ||
| const overwrite = destination.overwrite ?? true; | ||
| if (!destination.folderPath) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.localFolderRequired")); | ||
| } | ||
| if (!await this.fileSystem.exists(destination.folderPath)) { | ||
| await this.fileSystem.mkdir(destination.folderPath); | ||
| } | ||
| const written = []; | ||
| for (const sourcePath of packagePaths) { | ||
| const fileName = this.fileSystem.path.basename(sourcePath); | ||
| const destPath = this.fileSystem.path.join(destination.folderPath, fileName); | ||
| if (!overwrite && await this.fileSystem.exists(destPath)) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.localFolderFileExists", { path: destPath })); | ||
| } | ||
| const data = await this.fileSystem.readFile(sourcePath); | ||
| if (!data) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.failedToReadPackage", { path: sourcePath })); | ||
| } | ||
| await this.fileSystem.writeFile(destPath, data); | ||
| written.push(destPath); | ||
| this.logger.info(`Copied package to ${destPath}`); | ||
| } | ||
| return new ToolResult(ToolErrorCodes.Success, undefined, written); | ||
| } | ||
| } | ||
| // ../packager/project-packager/src/publish/services/nuget-feed-publisher.ts | ||
| var NUGET_V3_PACKAGE_PUBLISH_TYPE = "PackagePublish/2.0.0"; | ||
| class NugetFeedPublisher { | ||
| fileSystem; | ||
| logger; | ||
| constructor(fileSystem) { | ||
| this.fileSystem = fileSystem; | ||
| this.logger = new ToolLogger("ProjectPublisher", "NugetFeed"); | ||
| } | ||
| async publishAsync(packagePaths, destination) { | ||
| if (!destination.feedUrl) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.nugetFeedUrlRequired")); | ||
| } | ||
| let pushUrl; | ||
| try { | ||
| pushUrl = await this.resolvePushUrl(destination.feedUrl, destination.apiKey); | ||
| } catch (error) { | ||
| const message = error instanceof Error ? error.message : String(error); | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.nugetPushUrlResolutionFailed", { feedUrl: destination.feedUrl, message })); | ||
| } | ||
| const published = []; | ||
| for (const packagePath of packagePaths) { | ||
| const data = await this.fileSystem.readFile(packagePath); | ||
| if (!data) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.failedToReadPackage", { path: packagePath })); | ||
| } | ||
| const fileName = this.fileSystem.path.basename(packagePath); | ||
| const form = new FormData; | ||
| form.append("package", new Blob([data], { | ||
| type: "application/octet-stream" | ||
| }), fileName); | ||
| const headers = {}; | ||
| if (destination.apiKey) { | ||
| headers["X-NuGet-ApiKey"] = destination.apiKey; | ||
| } | ||
| this.logger.info(`Pushing ${fileName} to ${pushUrl}`); | ||
| const response = await fetch(pushUrl, { | ||
| method: "PUT", | ||
| headers, | ||
| body: form | ||
| }); | ||
| if (!response.ok) { | ||
| const body = await this.safeReadBody(response); | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.nugetPushFailed", { | ||
| fileName, | ||
| status: response.status, | ||
| statusText: response.statusText, | ||
| body: body ? ` - ${body}` : "" | ||
| })); | ||
| } | ||
| published.push(packagePath); | ||
| this.logger.info(`Pushed ${fileName} successfully.`); | ||
| } | ||
| return new ToolResult(ToolErrorCodes.Success, undefined, published); | ||
| } | ||
| async resolvePushUrl(feedUrl, apiKey) { | ||
| let end = feedUrl.length; | ||
| while (end > 0 && feedUrl.charCodeAt(end - 1) === 47) | ||
| end--; | ||
| const trimmed = feedUrl.slice(0, end); | ||
| if (/\/api\/v2\/package\/?$/i.test(trimmed)) { | ||
| return trimmed; | ||
| } | ||
| if (/\.json$/i.test(trimmed)) { | ||
| return this.resolveFromServiceIndex(trimmed, apiKey); | ||
| } | ||
| return `${trimmed}/api/v2/package`; | ||
| } | ||
| async resolveFromServiceIndex(serviceIndexUrl, apiKey) { | ||
| const headers = { Accept: "application/json" }; | ||
| if (apiKey) { | ||
| headers["X-NuGet-ApiKey"] = apiKey; | ||
| } | ||
| const response = await fetch(serviceIndexUrl, { headers }); | ||
| if (!response.ok) { | ||
| throw new Error(`service index returned ${response.status} ${response.statusText}`); | ||
| } | ||
| const index = await response.json(); | ||
| const resource = index.resources?.find((r) => r["@type"] === NUGET_V3_PACKAGE_PUBLISH_TYPE); | ||
| if (!resource?.["@id"]) { | ||
| throw new Error(`service index has no ${NUGET_V3_PACKAGE_PUBLISH_TYPE} resource`); | ||
| } | ||
| return resource["@id"]; | ||
| } | ||
| async safeReadBody(response) { | ||
| try { | ||
| const text = await response.text(); | ||
| return text.slice(0, 500); | ||
| } catch { | ||
| return ""; | ||
| } | ||
| } | ||
| } | ||
| // ../packager/project-packager/src/publish/services/orchestrator-feed-types.ts | ||
| var PackageFeedDtoPurposeEnum = { | ||
| Undefined: "Undefined", | ||
| Processes: "Processes", | ||
| Libraries: "Libraries", | ||
| PersonalWorkspace: "PersonalWorkspace", | ||
| FolderHierarchy: "FolderHierarchy" | ||
| }; | ||
| var PackageFeedDtoAuthenticationTypeEnum = { | ||
| Secure: "Secure", | ||
| ApiKey: "ApiKey", | ||
| Basic: "Basic" | ||
| }; | ||
| var ExtendedFolderDtoFeedTypeEnum = { | ||
| Undefined: "Undefined", | ||
| Processes: "Processes", | ||
| Libraries: "Libraries", | ||
| PersonalWorkspace: "PersonalWorkspace", | ||
| FolderHierarchy: "FolderHierarchy" | ||
| }; | ||
| // ../common/dist/sdk-user-agent.js | ||
| var PREFIX = "@uipath/common/"; | ||
| var _g = globalThis; | ||
| function singleton(ctorOrName) { | ||
| const name = typeof ctorOrName === "string" ? ctorOrName : ctorOrName.name; | ||
| const key = Symbol.for(PREFIX + name); | ||
| return { | ||
| get(fallback) { | ||
| return _g[key] ?? fallback; | ||
| }, | ||
| set(value) { | ||
| _g[key] = value; | ||
| }, | ||
| clear() { | ||
| delete _g[key]; | ||
| }, | ||
| getOrInit(factory, guard) { | ||
| const existing = _g[key]; | ||
| if (existing != null && typeof existing === "object") { | ||
| if (!guard || guard(existing)) { | ||
| return existing; | ||
| } | ||
| } | ||
| const instance = factory(); | ||
| _g[key] = instance; | ||
| return instance; | ||
| } | ||
| }; | ||
| } | ||
| var telemetryPropsSlot = singleton("TelemetryDefaultProps"); | ||
| var USER_AGENT_HEADER = "User-Agent"; | ||
| var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken"); | ||
| function splitUserAgentTokens(value) { | ||
| return value?.trim().split(/\s+/).filter(Boolean) ?? []; | ||
| } | ||
| function appendUserAgentToken(value, userAgent) { | ||
| const tokens = splitUserAgentTokens(value); | ||
| const seen = new Set(tokens); | ||
| for (const token of splitUserAgentTokens(userAgent)) { | ||
| if (!seen.has(token)) { | ||
| tokens.push(token); | ||
| seen.add(token); | ||
| } | ||
| } | ||
| return tokens.join(" "); | ||
| } | ||
| function getEffectiveUserAgent(userAgent) { | ||
| return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent); | ||
| } | ||
| function getHeaderName(headers, headerName) { | ||
| return Object.keys(headers).find((key) => key.toLowerCase() === headerName.toLowerCase()); | ||
| } | ||
| function addSdkUserAgentHeader(headers, userAgent) { | ||
| const result = { ...headers ?? {} }; | ||
| const headerName = getHeaderName(result, USER_AGENT_HEADER); | ||
| result[headerName ?? USER_AGENT_HEADER] = appendUserAgentToken(headerName ? result[headerName] : undefined, getEffectiveUserAgent(userAgent)); | ||
| return result; | ||
| } | ||
| // ../packager/project-packager/package.json | ||
| var package_default = { | ||
| name: "@uipath/project-packager", | ||
| license: "MIT", | ||
| version: "1.200.0-preview.120", | ||
| description: "UiPath Project Packager - core library for packing individual UiPath projects", | ||
| type: "module", | ||
| main: "./dist/index.js", | ||
| exports: { | ||
| ".": { | ||
| types: "./dist/src/index.d.ts", | ||
| default: "./dist/index.js" | ||
| }, | ||
| "./node": { | ||
| types: "./dist/src/node.d.ts", | ||
| default: "./dist/node.js" | ||
| }, | ||
| "./browser": { | ||
| types: "./dist/src/browser.d.ts", | ||
| default: "./dist/browser.js" | ||
| } | ||
| }, | ||
| types: "./dist/src/index.d.ts", | ||
| repository: { | ||
| type: "git", | ||
| url: "https://github.com/UiPath/cli.git", | ||
| directory: "packages/packager/project-packager" | ||
| }, | ||
| publishConfig: { | ||
| registry: "https://npm.pkg.github.com/" | ||
| }, | ||
| files: [ | ||
| "dist" | ||
| ], | ||
| scripts: { | ||
| build: "bun build ./src/index.ts --outdir dist --format esm --target browser --external @uipath/solutionpackager-tool-core --external '@uipath/filesystem/*' --external @uipath/filesystem --sourcemap=linked && bun build ./src/browser.ts --outdir dist --format esm --target browser --external @uipath/solutionpackager-tool-core --external '@uipath/filesystem/*' --external @uipath/filesystem --sourcemap=linked && bun build ./src/node.ts --outdir dist --format esm --target node --external @uipath/solutionpackager-tool-core --external '@uipath/filesystem/*' --external @uipath/filesystem --sourcemap=linked && tsc --emitDeclarationOnly --outDir dist", | ||
| clean: "rimraf dist", | ||
| test: "vitest run", | ||
| e2e: "vitest run --config vitest.e2e.config.ts", | ||
| "test:coverage": "vitest run --coverage", | ||
| prepack: "bun run build", | ||
| "publish:dry": "bun publish --dry-run", | ||
| "publish:gh": "bun publish", | ||
| "version:patch": "bun version patch --no-git-tag-version", | ||
| "version:minor": "bun version minor --no-git-tag-version", | ||
| "version:major": "bun version major --no-git-tag-version", | ||
| lint: "biome check ." | ||
| }, | ||
| dependencies: { | ||
| "@uipath/filesystem": "workspace:*", | ||
| "@uipath/solutionpackager-tool-core": "workspace:*", | ||
| "@uipath/common": "workspace:*" | ||
| }, | ||
| peerDependencies: { | ||
| fflate: "^0.8.2" | ||
| }, | ||
| devDependencies: { | ||
| "@types/node": "^25.5.2", | ||
| "@uipath/resource-builder-tool": "2025.11.0-alpha4535-3530", | ||
| "@uipath/tool-agent": "^2.0.0", | ||
| "@uipath/packager-tool-apiworkflow": "workspace:*", | ||
| "@uipath/packager-tool-connector": "workspace:*", | ||
| "@uipath/packager-tool-flow": "workspace:*", | ||
| "@uipath/packager-tool-functions": "workspace:*", | ||
| "@uipath/packager-tool-webapp": "workspace:*", | ||
| "@uipath/packager-tool-workflowcompiler": "workspace:*", | ||
| "@vitest/coverage-v8": "^4.1.6", | ||
| jsdom: "^30.0.1", | ||
| typescript: "^7.0.2", | ||
| "vite-tsconfig-paths": "^6.1.1", | ||
| vitest: "^4.1.6" | ||
| } | ||
| }; | ||
| // ../packager/project-packager/src/publish/services/orchestrator-feeds-service.ts | ||
| var HEADER_TENANT_ID = "X-UIPATH-TenantId"; | ||
| var FEEDS_PATH = "/api/PackageFeeds/GetFeeds"; | ||
| var FOLDERS_PATH = "/api/FoldersNavigation/GetAllFoldersForCurrentUser"; | ||
| var SDK_USER_AGENT = `${package_default.name.replace(/^@uipath\//, "")}/${package_default.version}`; | ||
| class OrchestratorFeedsService { | ||
| logger; | ||
| constructor() { | ||
| this.logger = new ToolLogger("OrchestratorFeedsService", "Feeds"); | ||
| } | ||
| async getAccessibleFeedsAsync(connection) { | ||
| this.ensureOrchestratorUrl(connection); | ||
| this.logger.info(`Fetching accessible feeds from ${connection.orchestratorUrl}`); | ||
| try { | ||
| const json = await orchestratorGet(connection, FEEDS_PATH); | ||
| return Array.isArray(json) ? json : []; | ||
| } catch (error) { | ||
| const { status, statusText, body } = await describeResponseError(error); | ||
| throw new Error(translate.t("solutionpackager.publish.errors.getAccessibleFeedsFailed", { status, statusText, body })); | ||
| } | ||
| } | ||
| async getFoldersForCurrentUserAsync(connection) { | ||
| this.ensureOrchestratorUrl(connection); | ||
| this.logger.info(`Fetching folders from ${connection.orchestratorUrl}`); | ||
| try { | ||
| const json = await orchestratorGet(connection, FOLDERS_PATH); | ||
| return Array.isArray(json) ? json.map(mapExtendedFolder) : []; | ||
| } catch (error) { | ||
| const { status, statusText, body } = await describeResponseError(error); | ||
| throw new Error(translate.t("solutionpackager.publish.errors.getFoldersForCurrentUserFailed", { status, statusText, body })); | ||
| } | ||
| } | ||
| ensureOrchestratorUrl(connection) { | ||
| if (!connection.orchestratorUrl) { | ||
| throw new Error(translate.t("solutionpackager.publish.errors.orchestratorUrlRequired")); | ||
| } | ||
| } | ||
| } | ||
| function mapExtendedFolder(json) { | ||
| return { | ||
| isSelectable: json.IsSelectable, | ||
| hasChildren: json.HasChildren, | ||
| level: json.Level, | ||
| key: json.Key, | ||
| displayName: json.DisplayName, | ||
| fullyQualifiedName: json.FullyQualifiedName, | ||
| description: json.Description, | ||
| folderType: json.FolderType, | ||
| isPersonal: json.IsPersonal, | ||
| provisionType: json.ProvisionType, | ||
| permissionModel: json.PermissionModel, | ||
| parentId: json.ParentId, | ||
| parentKey: json.ParentKey, | ||
| feedType: json.FeedType, | ||
| id: json.Id | ||
| }; | ||
| } | ||
| class OrchestratorResponseError extends Error { | ||
| response; | ||
| constructor(response) { | ||
| super(`Orchestrator request failed with status ${response.status}.`); | ||
| this.response = response; | ||
| this.name = "OrchestratorResponseError"; | ||
| } | ||
| } | ||
| async function orchestratorGet(connection, relativePath) { | ||
| const url = `${normalizeOrchestratorBasePath(connection.orchestratorUrl)}${relativePath}`; | ||
| const response = await fetch(url, { | ||
| method: "GET", | ||
| headers: buildHeaders(connection) | ||
| }); | ||
| if (!response.ok) { | ||
| throw new OrchestratorResponseError(response); | ||
| } | ||
| const text = await response.text(); | ||
| if (text === "" || text === "null") { | ||
| return null; | ||
| } | ||
| return JSON.parse(text); | ||
| } | ||
| function buildHeaders(connection) { | ||
| const headers = {}; | ||
| if (connection.accessToken) { | ||
| headers.Authorization = `Bearer ${connection.accessToken}`; | ||
| } | ||
| if (connection.tenantId) { | ||
| headers[HEADER_TENANT_ID] = connection.tenantId; | ||
| } | ||
| return addSdkUserAgentHeader(headers, SDK_USER_AGENT); | ||
| } | ||
| function normalizeOrchestratorBasePath(orchestratorUrl) { | ||
| let end = orchestratorUrl.length; | ||
| while (end > 0 && orchestratorUrl.charCodeAt(end - 1) === 47) | ||
| end--; | ||
| const trimmed = orchestratorUrl.slice(0, end); | ||
| return /\/orchestrator_$/i.test(trimmed) ? trimmed : `${trimmed}/orchestrator_`; | ||
| } | ||
| async function describeResponseError(error) { | ||
| const response = error?.response; | ||
| if (response) { | ||
| let body = ""; | ||
| try { | ||
| body = (await response.text()).slice(0, 500); | ||
| } catch { | ||
| body = ""; | ||
| } | ||
| return { | ||
| status: response.status, | ||
| statusText: response.statusText, | ||
| body: body ? ` - ${body}` : "" | ||
| }; | ||
| } | ||
| const cause = error?.cause; | ||
| const message = cause instanceof Error ? cause.message : error instanceof Error ? error.message : String(error); | ||
| return { status: "?", statusText: message, body: "" }; | ||
| } | ||
| // ../packager/project-packager/src/publish/services/orchestrator-publisher.ts | ||
| var HEADER_FOLDER_ID = "X-UIPATH-OrganizationUnitId"; | ||
| var HEADER_TENANT_ID2 = "X-UIPATH-TenantId"; | ||
| var HEADER_NUGET_API_KEY = "X-NuGet-ApiKey"; | ||
| var ORCHESTRATOR_RELATIVE_URL = "/orchestrator_"; | ||
| var PROCESSES_UPLOAD_PATH = "/odata/Processes/UiPath.Server.Configuration.OData.UploadPackage"; | ||
| var LIBRARIES_UPLOAD_PATH = "/odata/Libraries/UiPath.Server.Configuration.OData.UploadPackage"; | ||
| class OrchestratorPublisher { | ||
| fileSystem; | ||
| logger; | ||
| feedsService; | ||
| constructor(fileSystem, feedsService) { | ||
| this.fileSystem = fileSystem; | ||
| this.logger = new ToolLogger("ProjectPublisher", "Orchestrator"); | ||
| this.feedsService = feedsService ?? new OrchestratorFeedsService; | ||
| } | ||
| async publishAsync(packagePaths, destination) { | ||
| if (packagePaths.length === 0) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.orchestratorNoPackages")); | ||
| } | ||
| if (destination.kind === "OrchestratorCustom" /* OrchestratorCustom */) { | ||
| if (!destination.publishUrl) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.orchestratorCustomPublishUrlRequired")); | ||
| } | ||
| this.logger.info(`Publishing ${packagePaths.length} package(s) to ${destination.publishUrl} (custom)`); | ||
| return this.postPackages(packagePaths, destination.publishUrl, this.buildCustomHeaders(destination)); | ||
| } | ||
| if (!destination.connectionInfo?.cloudUrl) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.orchestratorCloudUrlRequired")); | ||
| } | ||
| const orchestratorUrl = this.deriveOrchestratorUrl(destination.connectionInfo); | ||
| let feed; | ||
| try { | ||
| feed = await this.resolveFeed(destination, orchestratorUrl); | ||
| } catch (error) { | ||
| const message = error instanceof Error ? error.message : String(error); | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.orchestratorFeedResolutionFailed", { message })); | ||
| } | ||
| const targetUrl = this.buildPublishUrl(orchestratorUrl, feed); | ||
| const headers = this.buildHeaders(destination, feed); | ||
| this.logger.info(`Publishing ${packagePaths.length} package(s) to ${targetUrl} (feed ${feed.name}, ${feed.purpose})`); | ||
| return this.postPackages(packagePaths, targetUrl, headers); | ||
| } | ||
| async postPackages(packagePaths, targetUrl, headers) { | ||
| const form = new FormData; | ||
| for (const packagePath of packagePaths) { | ||
| const data = await this.fileSystem.readFile(packagePath); | ||
| if (!data) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.failedToReadPackage", { path: packagePath })); | ||
| } | ||
| const fileName = this.fileSystem.path.basename(packagePath); | ||
| form.append("file", new Blob([data], { | ||
| type: "application/octet-stream" | ||
| }), fileName); | ||
| } | ||
| const response = await fetch(targetUrl, { | ||
| method: "POST", | ||
| headers, | ||
| body: form | ||
| }); | ||
| if (!response.ok) { | ||
| const body = await this.safeReadBody(response); | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.orchestratorPublishFailed", { | ||
| status: response.status, | ||
| statusText: response.statusText, | ||
| body: body ? ` - ${body}` : "" | ||
| })); | ||
| } | ||
| this.logger.info("Orchestrator publish completed."); | ||
| return new ToolResult(ToolErrorCodes.Success, undefined, packagePaths); | ||
| } | ||
| async resolveFeed(destination, orchestratorUrl) { | ||
| const connection = { | ||
| orchestratorUrl, | ||
| accessToken: destination.connectionInfo.accessToken, | ||
| tenantId: destination.connectionInfo.tenantId | ||
| }; | ||
| const feeds = await this.feedsService.getAccessibleFeedsAsync(connection); | ||
| if (destination.kind === "OrchestratorPersonalWorkspace" /* OrchestratorPersonalWorkspace */) { | ||
| const folders = await this.feedsService.getFoldersForCurrentUserAsync(connection); | ||
| const personalFolder = folders.find((f) => f.feedType === ExtendedFolderDtoFeedTypeEnum.PersonalWorkspace); | ||
| if (!personalFolder) { | ||
| const foldersDebug = folders.length === 0 ? "<none>" : folders.map((f) => `${f.displayName} (id=${f.id}, feedType=${f.feedType})`).join(", "); | ||
| throw new Error(translate.t("solutionpackager.publish.errors.orchestratorPersonalWorkspaceFolderNotFound", { folders: foldersDebug })); | ||
| } | ||
| if (personalFolder.id == null) { | ||
| throw new Error(`Personal-workspace folder "${personalFolder.displayName}" has no id; cannot resolve its feed.`); | ||
| } | ||
| const match2 = feeds.find((f) => f.folderId === personalFolder.id); | ||
| if (!match2) { | ||
| this.throwFeedNotFound(destination, feeds); | ||
| } | ||
| return match2; | ||
| } | ||
| const expectedPurpose = destination.kind === "OrchestratorSharedLibraries" /* OrchestratorSharedLibraries */ ? PackageFeedDtoPurposeEnum.Libraries : PackageFeedDtoPurposeEnum.Processes; | ||
| const match = feeds.find((f) => f.purpose === expectedPurpose && f.folderId == null); | ||
| if (!match) { | ||
| this.throwFeedNotFound(destination, feeds); | ||
| } | ||
| return match; | ||
| } | ||
| throwFeedNotFound(destination, feeds) { | ||
| const available = feeds.length === 0 ? "<none>" : feeds.map((f) => `${f.name} (purpose=${f.purpose}, folderId=${f.folderId ?? "null"})`).join(", "); | ||
| throw new Error(translate.t("solutionpackager.publish.errors.orchestratorFeedNotFound", { | ||
| kind: destination.kind, | ||
| available | ||
| })); | ||
| } | ||
| buildPublishUrl(orchestratorUrl, feed) { | ||
| const baseUrl = feed.publishUrl ? feed.publishUrl : `${orchestratorUrl}${feed.purpose === PackageFeedDtoPurposeEnum.Libraries ? LIBRARIES_UPLOAD_PATH : PROCESSES_UPLOAD_PATH}`; | ||
| const parsed = new URL(baseUrl); | ||
| if (feed.id) { | ||
| parsed.searchParams.set("feedId", feed.id); | ||
| } | ||
| return parsed.toString(); | ||
| } | ||
| deriveOrchestratorUrl(connectionInfo) { | ||
| const raw = connectionInfo.cloudUrl ?? ""; | ||
| let end = raw.length; | ||
| while (end > 0 && raw.charCodeAt(end - 1) === 47) | ||
| end--; | ||
| return `${raw.slice(0, end)}${ORCHESTRATOR_RELATIVE_URL}`; | ||
| } | ||
| buildHeaders(destination, feed) { | ||
| const headers = this.buildAuthHeaders(destination.connectionInfo); | ||
| const folderHeader = destination.kind === "OrchestratorSharedLibraries" /* OrchestratorSharedLibraries */ ? destination.folderId : feed.folderId; | ||
| if (folderHeader != null) { | ||
| headers[HEADER_FOLDER_ID] = String(folderHeader); | ||
| } | ||
| if (feed.authenticationType === PackageFeedDtoAuthenticationTypeEnum.ApiKey && feed.apiKey) { | ||
| headers[HEADER_NUGET_API_KEY] = feed.apiKey; | ||
| } | ||
| return headers; | ||
| } | ||
| buildCustomHeaders(destination) { | ||
| const headers = this.buildAuthHeaders(destination.connectionInfo); | ||
| if (destination.folderId != null) { | ||
| headers[HEADER_FOLDER_ID] = String(destination.folderId); | ||
| } | ||
| if (destination.apiKey) { | ||
| headers[HEADER_NUGET_API_KEY] = destination.apiKey; | ||
| } | ||
| return headers; | ||
| } | ||
| buildAuthHeaders(connectionInfo) { | ||
| const headers = {}; | ||
| if (connectionInfo.accessToken) { | ||
| headers.Authorization = `Bearer ${connectionInfo.accessToken}`; | ||
| } | ||
| if (connectionInfo.tenantId) { | ||
| headers[HEADER_TENANT_ID2] = connectionInfo.tenantId; | ||
| } | ||
| return headers; | ||
| } | ||
| async safeReadBody(response) { | ||
| try { | ||
| const text = await response.text(); | ||
| return text.slice(0, 500); | ||
| } catch { | ||
| return ""; | ||
| } | ||
| } | ||
| } | ||
| // ../packager/project-packager/src/publish/services/project-publisher.ts | ||
| class ProjectPublisher { | ||
| fileSystem; | ||
| logger; | ||
| localFolderPublisher; | ||
| nugetFeedPublisher; | ||
| orchestratorPublisher; | ||
| constructor(fileSystem, publishers) { | ||
| this.fileSystem = fileSystem; | ||
| this.logger = new ToolLogger("ProjectPublisher", "Publish"); | ||
| this.localFolderPublisher = publishers?.localFolder ?? new LocalFolderPublisher(fileSystem); | ||
| this.nugetFeedPublisher = publishers?.nugetFeed ?? new NugetFeedPublisher(fileSystem); | ||
| this.orchestratorPublisher = publishers?.orchestrator ?? new OrchestratorPublisher(fileSystem); | ||
| } | ||
| async publishAsync(options) { | ||
| if (!options.packagePaths || options.packagePaths.length === 0) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.atLeastOnePackage")); | ||
| } | ||
| for (const path of options.packagePaths) { | ||
| if (!await this.fileSystem.exists(path)) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.packageNotFound", { path })); | ||
| } | ||
| } | ||
| try { | ||
| const destination = options.destination; | ||
| switch (destination.kind) { | ||
| case "LocalFolder" /* LocalFolder */: | ||
| return await this.localFolderPublisher.publishAsync(options.packagePaths, destination); | ||
| case "NugetFeed" /* NugetFeed */: | ||
| return await this.nugetFeedPublisher.publishAsync(options.packagePaths, destination); | ||
| case "OrchestratorPersonalWorkspace" /* OrchestratorPersonalWorkspace */: | ||
| case "OrchestratorTenantProcesses" /* OrchestratorTenantProcesses */: | ||
| case "OrchestratorSharedLibraries" /* OrchestratorSharedLibraries */: | ||
| case "OrchestratorCustom" /* OrchestratorCustom */: | ||
| return await this.orchestratorPublisher.publishAsync(options.packagePaths, destination); | ||
| default: { | ||
| const exhaustive = destination; | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.unknownDestination", { destination: JSON.stringify(exhaustive) })); | ||
| } | ||
| } | ||
| } catch (error) { | ||
| const message = error instanceof Error ? error.message : String(error); | ||
| const localized = translate.t("solutionpackager.publish.errors.publishFailed", { message }); | ||
| this.logger.error(localized); | ||
| return ToolResult.error(ToolErrorCodes.InternalError, localized); | ||
| } | ||
| } | ||
| } | ||
| export { | ||
| signNupkgsAsync, | ||
| setGlobalLogHandler, | ||
| resolveProducedNupkgsAsync, | ||
| ToolsFactory, | ||
| ToolLogger, | ||
| TelemetryService, | ||
| TelemetryNames, | ||
| RulesConfigFileType, | ||
| PublishDestinationKind, | ||
| ProjectValidateOptionsValidator, | ||
| ProjectValidateOptions, | ||
| ProjectToolExecutor, | ||
| ProjectRestoreOptions, | ||
| ProjectPublisher, | ||
| ProjectPublishOptions, | ||
| ProjectPackager, | ||
| ProjectPackOptions, | ||
| ProjectLoader, | ||
| ProjectCleanupOptions, | ||
| ProjectBuildOptionsValidator, | ||
| ProjectBuildOptions, | ||
| PackagerParametersValidator, | ||
| PackagerParameters, | ||
| PackService, | ||
| GovernancePolicyService, | ||
| ConsoleTelemetryProvider, | ||
| BrowserContextStorage | ||
| }; | ||
| //# debugId=EC190DCB47AC5F3964756E2164756E21 |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
+1
-1
@@ -6,3 +6,3 @@ #!/usr/bin/env node | ||
| registerCommands | ||
| } from "./packager-tool-ppq822pp.js"; | ||
| } from "./packager-tool-9cz2z4tn.js"; | ||
| import"./packager-tool-1v8fmky0.js"; | ||
@@ -9,0 +9,0 @@ import"./packager-tool-9qecd4wb.js"; |
+1
-1
| import { | ||
| metadata, | ||
| registerCommands | ||
| } from "./packager-tool-ppq822pp.js"; | ||
| } from "./packager-tool-9cz2z4tn.js"; | ||
| import"./packager-tool-1v8fmky0.js"; | ||
@@ -6,0 +6,0 @@ import"./packager-tool-9qecd4wb.js"; |
+2
-2
| { | ||
| "name": "@uipath/api-workflow-tool", | ||
| "license": "MIT", | ||
| "version": "1.200.0-preview.118", | ||
| "version": "1.200.0-preview.120", | ||
| "description": "Run UiPath API Workflows locally.", | ||
@@ -27,3 +27,3 @@ "private": false, | ||
| ], | ||
| "gitHead": "bc87399d98869787498783b3b9383df4426fd896" | ||
| "gitHead": "173ad4b4930bd3e17a493b32e9f1c3c616ea1c10" | ||
| } |
| import { | ||
| BrowserContextStorage, | ||
| ConsoleTelemetryProvider, | ||
| GovernancePolicyService, | ||
| PackService, | ||
| PackagerParameters, | ||
| PackagerParametersValidator, | ||
| ProjectBuildOptionsValidator, | ||
| ProjectLoader, | ||
| ProjectPackager, | ||
| ProjectToolExecutor, | ||
| ProjectValidateOptionsValidator, | ||
| RulesConfigFileType, | ||
| TelemetryNames, | ||
| TelemetryService, | ||
| ToolLogger, | ||
| ToolsFactory, | ||
| resolveProducedNupkgsAsync, | ||
| setGlobalLogHandler, | ||
| signNupkgsAsync | ||
| } from "./packager-tool-9yfnj0t1.js"; | ||
| import { | ||
| ToolErrorCodes, | ||
| ToolResult, | ||
| translate | ||
| } from "./packager-tool-h1tyrbff.js"; | ||
| import"./packager-tool-wckvcay0.js"; | ||
| // ../packager/project-packager/src/models/project-restore-options.ts | ||
| class ProjectRestoreOptions extends PackagerParameters { | ||
| } | ||
| // ../packager/project-packager/src/models/project-validate-options.ts | ||
| class ProjectValidateOptions extends ProjectRestoreOptions { | ||
| validateOptions = { | ||
| skipAnalyze: false, | ||
| skipValidate: false, | ||
| governanceFileType: "Default" /* Default */ | ||
| }; | ||
| } | ||
| // ../packager/project-packager/src/models/project-build-options.ts | ||
| class ProjectBuildOptions extends ProjectValidateOptions { | ||
| outputType; | ||
| } | ||
| // ../packager/project-packager/src/models/project-cleanup-options.ts | ||
| class ProjectCleanupOptions extends PackagerParameters { | ||
| dryRun = false; | ||
| skipImports = false; | ||
| lockKey; | ||
| } | ||
| // ../packager/project-packager/src/models/project-pack-options.ts | ||
| class ProjectPackOptions extends ProjectBuildOptions { | ||
| destinationPath; | ||
| package; | ||
| signingInfo; | ||
| packOptions; | ||
| } | ||
| // ../packager/project-packager/src/publish/models/publish-options.ts | ||
| var PublishDestinationKind; | ||
| ((PublishDestinationKind2) => { | ||
| PublishDestinationKind2["LocalFolder"] = "LocalFolder"; | ||
| PublishDestinationKind2["NugetFeed"] = "NugetFeed"; | ||
| PublishDestinationKind2["OrchestratorPersonalWorkspace"] = "OrchestratorPersonalWorkspace"; | ||
| PublishDestinationKind2["OrchestratorTenantProcesses"] = "OrchestratorTenantProcesses"; | ||
| PublishDestinationKind2["OrchestratorSharedLibraries"] = "OrchestratorSharedLibraries"; | ||
| PublishDestinationKind2["OrchestratorCustom"] = "OrchestratorCustom"; | ||
| })(PublishDestinationKind ||= {}); | ||
| class ProjectPublishOptions { | ||
| packagePaths; | ||
| destination; | ||
| constructor(packagePaths, destination) { | ||
| this.packagePaths = packagePaths; | ||
| this.destination = destination; | ||
| } | ||
| } | ||
| // ../packager/project-packager/src/publish/services/local-folder-publisher.ts | ||
| class LocalFolderPublisher { | ||
| fileSystem; | ||
| logger; | ||
| constructor(fileSystem) { | ||
| this.fileSystem = fileSystem; | ||
| this.logger = new ToolLogger("ProjectPublisher", "LocalFolder"); | ||
| } | ||
| async publishAsync(packagePaths, destination) { | ||
| const overwrite = destination.overwrite ?? true; | ||
| if (!destination.folderPath) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.localFolderRequired")); | ||
| } | ||
| if (!await this.fileSystem.exists(destination.folderPath)) { | ||
| await this.fileSystem.mkdir(destination.folderPath); | ||
| } | ||
| const written = []; | ||
| for (const sourcePath of packagePaths) { | ||
| const fileName = this.fileSystem.path.basename(sourcePath); | ||
| const destPath = this.fileSystem.path.join(destination.folderPath, fileName); | ||
| if (!overwrite && await this.fileSystem.exists(destPath)) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.localFolderFileExists", { path: destPath })); | ||
| } | ||
| const data = await this.fileSystem.readFile(sourcePath); | ||
| if (!data) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.failedToReadPackage", { path: sourcePath })); | ||
| } | ||
| await this.fileSystem.writeFile(destPath, data); | ||
| written.push(destPath); | ||
| this.logger.info(`Copied package to ${destPath}`); | ||
| } | ||
| return new ToolResult(ToolErrorCodes.Success, undefined, written); | ||
| } | ||
| } | ||
| // ../packager/project-packager/src/publish/services/nuget-feed-publisher.ts | ||
| var NUGET_V3_PACKAGE_PUBLISH_TYPE = "PackagePublish/2.0.0"; | ||
| class NugetFeedPublisher { | ||
| fileSystem; | ||
| logger; | ||
| constructor(fileSystem) { | ||
| this.fileSystem = fileSystem; | ||
| this.logger = new ToolLogger("ProjectPublisher", "NugetFeed"); | ||
| } | ||
| async publishAsync(packagePaths, destination) { | ||
| if (!destination.feedUrl) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.nugetFeedUrlRequired")); | ||
| } | ||
| let pushUrl; | ||
| try { | ||
| pushUrl = await this.resolvePushUrl(destination.feedUrl, destination.apiKey); | ||
| } catch (error) { | ||
| const message = error instanceof Error ? error.message : String(error); | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.nugetPushUrlResolutionFailed", { feedUrl: destination.feedUrl, message })); | ||
| } | ||
| const published = []; | ||
| for (const packagePath of packagePaths) { | ||
| const data = await this.fileSystem.readFile(packagePath); | ||
| if (!data) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.failedToReadPackage", { path: packagePath })); | ||
| } | ||
| const fileName = this.fileSystem.path.basename(packagePath); | ||
| const form = new FormData; | ||
| form.append("package", new Blob([data], { | ||
| type: "application/octet-stream" | ||
| }), fileName); | ||
| const headers = {}; | ||
| if (destination.apiKey) { | ||
| headers["X-NuGet-ApiKey"] = destination.apiKey; | ||
| } | ||
| this.logger.info(`Pushing ${fileName} to ${pushUrl}`); | ||
| const response = await fetch(pushUrl, { | ||
| method: "PUT", | ||
| headers, | ||
| body: form | ||
| }); | ||
| if (!response.ok) { | ||
| const body = await this.safeReadBody(response); | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.nugetPushFailed", { | ||
| fileName, | ||
| status: response.status, | ||
| statusText: response.statusText, | ||
| body: body ? ` - ${body}` : "" | ||
| })); | ||
| } | ||
| published.push(packagePath); | ||
| this.logger.info(`Pushed ${fileName} successfully.`); | ||
| } | ||
| return new ToolResult(ToolErrorCodes.Success, undefined, published); | ||
| } | ||
| async resolvePushUrl(feedUrl, apiKey) { | ||
| let end = feedUrl.length; | ||
| while (end > 0 && feedUrl.charCodeAt(end - 1) === 47) | ||
| end--; | ||
| const trimmed = feedUrl.slice(0, end); | ||
| if (/\/api\/v2\/package\/?$/i.test(trimmed)) { | ||
| return trimmed; | ||
| } | ||
| if (/\.json$/i.test(trimmed)) { | ||
| return this.resolveFromServiceIndex(trimmed, apiKey); | ||
| } | ||
| return `${trimmed}/api/v2/package`; | ||
| } | ||
| async resolveFromServiceIndex(serviceIndexUrl, apiKey) { | ||
| const headers = { Accept: "application/json" }; | ||
| if (apiKey) { | ||
| headers["X-NuGet-ApiKey"] = apiKey; | ||
| } | ||
| const response = await fetch(serviceIndexUrl, { headers }); | ||
| if (!response.ok) { | ||
| throw new Error(`service index returned ${response.status} ${response.statusText}`); | ||
| } | ||
| const index = await response.json(); | ||
| const resource = index.resources?.find((r) => r["@type"] === NUGET_V3_PACKAGE_PUBLISH_TYPE); | ||
| if (!resource?.["@id"]) { | ||
| throw new Error(`service index has no ${NUGET_V3_PACKAGE_PUBLISH_TYPE} resource`); | ||
| } | ||
| return resource["@id"]; | ||
| } | ||
| async safeReadBody(response) { | ||
| try { | ||
| const text = await response.text(); | ||
| return text.slice(0, 500); | ||
| } catch { | ||
| return ""; | ||
| } | ||
| } | ||
| } | ||
| // ../packager/project-packager/src/publish/services/orchestrator-feed-types.ts | ||
| var PackageFeedDtoPurposeEnum = { | ||
| Undefined: "Undefined", | ||
| Processes: "Processes", | ||
| Libraries: "Libraries", | ||
| PersonalWorkspace: "PersonalWorkspace", | ||
| FolderHierarchy: "FolderHierarchy" | ||
| }; | ||
| var PackageFeedDtoAuthenticationTypeEnum = { | ||
| Secure: "Secure", | ||
| ApiKey: "ApiKey", | ||
| Basic: "Basic" | ||
| }; | ||
| var ExtendedFolderDtoFeedTypeEnum = { | ||
| Undefined: "Undefined", | ||
| Processes: "Processes", | ||
| Libraries: "Libraries", | ||
| PersonalWorkspace: "PersonalWorkspace", | ||
| FolderHierarchy: "FolderHierarchy" | ||
| }; | ||
| // ../common/dist/sdk-user-agent.js | ||
| var PREFIX = "@uipath/common/"; | ||
| var _g = globalThis; | ||
| function singleton(ctorOrName) { | ||
| const name = typeof ctorOrName === "string" ? ctorOrName : ctorOrName.name; | ||
| const key = Symbol.for(PREFIX + name); | ||
| return { | ||
| get(fallback) { | ||
| return _g[key] ?? fallback; | ||
| }, | ||
| set(value) { | ||
| _g[key] = value; | ||
| }, | ||
| clear() { | ||
| delete _g[key]; | ||
| }, | ||
| getOrInit(factory, guard) { | ||
| const existing = _g[key]; | ||
| if (existing != null && typeof existing === "object") { | ||
| if (!guard || guard(existing)) { | ||
| return existing; | ||
| } | ||
| } | ||
| const instance = factory(); | ||
| _g[key] = instance; | ||
| return instance; | ||
| } | ||
| }; | ||
| } | ||
| var telemetryPropsSlot = singleton("TelemetryDefaultProps"); | ||
| var USER_AGENT_HEADER = "User-Agent"; | ||
| var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken"); | ||
| function splitUserAgentTokens(value) { | ||
| return value?.trim().split(/\s+/).filter(Boolean) ?? []; | ||
| } | ||
| function appendUserAgentToken(value, userAgent) { | ||
| const tokens = splitUserAgentTokens(value); | ||
| const seen = new Set(tokens); | ||
| for (const token of splitUserAgentTokens(userAgent)) { | ||
| if (!seen.has(token)) { | ||
| tokens.push(token); | ||
| seen.add(token); | ||
| } | ||
| } | ||
| return tokens.join(" "); | ||
| } | ||
| function getEffectiveUserAgent(userAgent) { | ||
| return appendUserAgentToken(sdkUserAgentHostToken.get(), userAgent); | ||
| } | ||
| function getHeaderName(headers, headerName) { | ||
| return Object.keys(headers).find((key) => key.toLowerCase() === headerName.toLowerCase()); | ||
| } | ||
| function addSdkUserAgentHeader(headers, userAgent) { | ||
| const result = { ...headers ?? {} }; | ||
| const headerName = getHeaderName(result, USER_AGENT_HEADER); | ||
| result[headerName ?? USER_AGENT_HEADER] = appendUserAgentToken(headerName ? result[headerName] : undefined, getEffectiveUserAgent(userAgent)); | ||
| return result; | ||
| } | ||
| // ../packager/project-packager/package.json | ||
| var package_default = { | ||
| name: "@uipath/project-packager", | ||
| license: "MIT", | ||
| version: "1.200.0-preview.118", | ||
| description: "UiPath Project Packager - core library for packing individual UiPath projects", | ||
| type: "module", | ||
| main: "./dist/index.js", | ||
| exports: { | ||
| ".": { | ||
| types: "./dist/src/index.d.ts", | ||
| default: "./dist/index.js" | ||
| }, | ||
| "./node": { | ||
| types: "./dist/src/node.d.ts", | ||
| default: "./dist/node.js" | ||
| }, | ||
| "./browser": { | ||
| types: "./dist/src/browser.d.ts", | ||
| default: "./dist/browser.js" | ||
| } | ||
| }, | ||
| types: "./dist/src/index.d.ts", | ||
| repository: { | ||
| type: "git", | ||
| url: "https://github.com/UiPath/cli.git", | ||
| directory: "packages/packager/project-packager" | ||
| }, | ||
| publishConfig: { | ||
| registry: "https://npm.pkg.github.com/" | ||
| }, | ||
| files: [ | ||
| "dist" | ||
| ], | ||
| scripts: { | ||
| build: "bun build ./src/index.ts --outdir dist --format esm --target browser --external @uipath/solutionpackager-tool-core --external '@uipath/filesystem/*' --external @uipath/filesystem --sourcemap=linked && bun build ./src/browser.ts --outdir dist --format esm --target browser --external @uipath/solutionpackager-tool-core --external '@uipath/filesystem/*' --external @uipath/filesystem --sourcemap=linked && bun build ./src/node.ts --outdir dist --format esm --target node --external @uipath/solutionpackager-tool-core --external '@uipath/filesystem/*' --external @uipath/filesystem --sourcemap=linked && tsc --emitDeclarationOnly --outDir dist", | ||
| clean: "rimraf dist", | ||
| test: "vitest run", | ||
| e2e: "vitest run --config vitest.e2e.config.ts", | ||
| "test:coverage": "vitest run --coverage", | ||
| prepack: "bun run build", | ||
| "publish:dry": "bun publish --dry-run", | ||
| "publish:gh": "bun publish", | ||
| "version:patch": "bun version patch --no-git-tag-version", | ||
| "version:minor": "bun version minor --no-git-tag-version", | ||
| "version:major": "bun version major --no-git-tag-version", | ||
| lint: "biome check ." | ||
| }, | ||
| dependencies: { | ||
| "@uipath/filesystem": "workspace:*", | ||
| "@uipath/solutionpackager-tool-core": "workspace:*", | ||
| "@uipath/common": "workspace:*" | ||
| }, | ||
| peerDependencies: { | ||
| fflate: "^0.8.2" | ||
| }, | ||
| devDependencies: { | ||
| "@types/node": "^25.5.2", | ||
| "@uipath/resource-builder-tool": "2025.11.0-alpha4535-3530", | ||
| "@uipath/tool-agent": "^2.0.0", | ||
| "@uipath/packager-tool-apiworkflow": "workspace:*", | ||
| "@uipath/packager-tool-connector": "workspace:*", | ||
| "@uipath/packager-tool-flow": "workspace:*", | ||
| "@uipath/packager-tool-functions": "workspace:*", | ||
| "@uipath/packager-tool-webapp": "workspace:*", | ||
| "@uipath/packager-tool-workflowcompiler": "workspace:*", | ||
| "@vitest/coverage-v8": "^4.1.6", | ||
| jsdom: "^30.0.1", | ||
| typescript: "^7.0.2", | ||
| "vite-tsconfig-paths": "^6.1.1", | ||
| vitest: "^4.1.6" | ||
| } | ||
| }; | ||
| // ../packager/project-packager/src/publish/services/orchestrator-feeds-service.ts | ||
| var HEADER_TENANT_ID = "X-UIPATH-TenantId"; | ||
| var FEEDS_PATH = "/api/PackageFeeds/GetFeeds"; | ||
| var FOLDERS_PATH = "/api/FoldersNavigation/GetAllFoldersForCurrentUser"; | ||
| var SDK_USER_AGENT = `${package_default.name.replace(/^@uipath\//, "")}/${package_default.version}`; | ||
| class OrchestratorFeedsService { | ||
| logger; | ||
| constructor() { | ||
| this.logger = new ToolLogger("OrchestratorFeedsService", "Feeds"); | ||
| } | ||
| async getAccessibleFeedsAsync(connection) { | ||
| this.ensureOrchestratorUrl(connection); | ||
| this.logger.info(`Fetching accessible feeds from ${connection.orchestratorUrl}`); | ||
| try { | ||
| const json = await orchestratorGet(connection, FEEDS_PATH); | ||
| return Array.isArray(json) ? json : []; | ||
| } catch (error) { | ||
| const { status, statusText, body } = await describeResponseError(error); | ||
| throw new Error(translate.t("solutionpackager.publish.errors.getAccessibleFeedsFailed", { status, statusText, body })); | ||
| } | ||
| } | ||
| async getFoldersForCurrentUserAsync(connection) { | ||
| this.ensureOrchestratorUrl(connection); | ||
| this.logger.info(`Fetching folders from ${connection.orchestratorUrl}`); | ||
| try { | ||
| const json = await orchestratorGet(connection, FOLDERS_PATH); | ||
| return Array.isArray(json) ? json.map(mapExtendedFolder) : []; | ||
| } catch (error) { | ||
| const { status, statusText, body } = await describeResponseError(error); | ||
| throw new Error(translate.t("solutionpackager.publish.errors.getFoldersForCurrentUserFailed", { status, statusText, body })); | ||
| } | ||
| } | ||
| ensureOrchestratorUrl(connection) { | ||
| if (!connection.orchestratorUrl) { | ||
| throw new Error(translate.t("solutionpackager.publish.errors.orchestratorUrlRequired")); | ||
| } | ||
| } | ||
| } | ||
| function mapExtendedFolder(json) { | ||
| return { | ||
| isSelectable: json.IsSelectable, | ||
| hasChildren: json.HasChildren, | ||
| level: json.Level, | ||
| key: json.Key, | ||
| displayName: json.DisplayName, | ||
| fullyQualifiedName: json.FullyQualifiedName, | ||
| description: json.Description, | ||
| folderType: json.FolderType, | ||
| isPersonal: json.IsPersonal, | ||
| provisionType: json.ProvisionType, | ||
| permissionModel: json.PermissionModel, | ||
| parentId: json.ParentId, | ||
| parentKey: json.ParentKey, | ||
| feedType: json.FeedType, | ||
| id: json.Id | ||
| }; | ||
| } | ||
| class OrchestratorResponseError extends Error { | ||
| response; | ||
| constructor(response) { | ||
| super(`Orchestrator request failed with status ${response.status}.`); | ||
| this.response = response; | ||
| this.name = "OrchestratorResponseError"; | ||
| } | ||
| } | ||
| async function orchestratorGet(connection, relativePath) { | ||
| const url = `${normalizeOrchestratorBasePath(connection.orchestratorUrl)}${relativePath}`; | ||
| const response = await fetch(url, { | ||
| method: "GET", | ||
| headers: buildHeaders(connection) | ||
| }); | ||
| if (!response.ok) { | ||
| throw new OrchestratorResponseError(response); | ||
| } | ||
| const text = await response.text(); | ||
| if (text === "" || text === "null") { | ||
| return null; | ||
| } | ||
| return JSON.parse(text); | ||
| } | ||
| function buildHeaders(connection) { | ||
| const headers = {}; | ||
| if (connection.accessToken) { | ||
| headers.Authorization = `Bearer ${connection.accessToken}`; | ||
| } | ||
| if (connection.tenantId) { | ||
| headers[HEADER_TENANT_ID] = connection.tenantId; | ||
| } | ||
| return addSdkUserAgentHeader(headers, SDK_USER_AGENT); | ||
| } | ||
| function normalizeOrchestratorBasePath(orchestratorUrl) { | ||
| let end = orchestratorUrl.length; | ||
| while (end > 0 && orchestratorUrl.charCodeAt(end - 1) === 47) | ||
| end--; | ||
| const trimmed = orchestratorUrl.slice(0, end); | ||
| return /\/orchestrator_$/i.test(trimmed) ? trimmed : `${trimmed}/orchestrator_`; | ||
| } | ||
| async function describeResponseError(error) { | ||
| const response = error?.response; | ||
| if (response) { | ||
| let body = ""; | ||
| try { | ||
| body = (await response.text()).slice(0, 500); | ||
| } catch { | ||
| body = ""; | ||
| } | ||
| return { | ||
| status: response.status, | ||
| statusText: response.statusText, | ||
| body: body ? ` - ${body}` : "" | ||
| }; | ||
| } | ||
| const cause = error?.cause; | ||
| const message = cause instanceof Error ? cause.message : error instanceof Error ? error.message : String(error); | ||
| return { status: "?", statusText: message, body: "" }; | ||
| } | ||
| // ../packager/project-packager/src/publish/services/orchestrator-publisher.ts | ||
| var HEADER_FOLDER_ID = "X-UIPATH-OrganizationUnitId"; | ||
| var HEADER_TENANT_ID2 = "X-UIPATH-TenantId"; | ||
| var HEADER_NUGET_API_KEY = "X-NuGet-ApiKey"; | ||
| var ORCHESTRATOR_RELATIVE_URL = "/orchestrator_"; | ||
| var PROCESSES_UPLOAD_PATH = "/odata/Processes/UiPath.Server.Configuration.OData.UploadPackage"; | ||
| var LIBRARIES_UPLOAD_PATH = "/odata/Libraries/UiPath.Server.Configuration.OData.UploadPackage"; | ||
| class OrchestratorPublisher { | ||
| fileSystem; | ||
| logger; | ||
| feedsService; | ||
| constructor(fileSystem, feedsService) { | ||
| this.fileSystem = fileSystem; | ||
| this.logger = new ToolLogger("ProjectPublisher", "Orchestrator"); | ||
| this.feedsService = feedsService ?? new OrchestratorFeedsService; | ||
| } | ||
| async publishAsync(packagePaths, destination) { | ||
| if (packagePaths.length === 0) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.orchestratorNoPackages")); | ||
| } | ||
| if (destination.kind === "OrchestratorCustom" /* OrchestratorCustom */) { | ||
| if (!destination.publishUrl) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.orchestratorCustomPublishUrlRequired")); | ||
| } | ||
| this.logger.info(`Publishing ${packagePaths.length} package(s) to ${destination.publishUrl} (custom)`); | ||
| return this.postPackages(packagePaths, destination.publishUrl, this.buildCustomHeaders(destination)); | ||
| } | ||
| if (!destination.connectionInfo?.cloudUrl) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.orchestratorCloudUrlRequired")); | ||
| } | ||
| const orchestratorUrl = this.deriveOrchestratorUrl(destination.connectionInfo); | ||
| let feed; | ||
| try { | ||
| feed = await this.resolveFeed(destination, orchestratorUrl); | ||
| } catch (error) { | ||
| const message = error instanceof Error ? error.message : String(error); | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.orchestratorFeedResolutionFailed", { message })); | ||
| } | ||
| const targetUrl = this.buildPublishUrl(orchestratorUrl, feed); | ||
| const headers = this.buildHeaders(destination, feed); | ||
| this.logger.info(`Publishing ${packagePaths.length} package(s) to ${targetUrl} (feed ${feed.name}, ${feed.purpose})`); | ||
| return this.postPackages(packagePaths, targetUrl, headers); | ||
| } | ||
| async postPackages(packagePaths, targetUrl, headers) { | ||
| const form = new FormData; | ||
| for (const packagePath of packagePaths) { | ||
| const data = await this.fileSystem.readFile(packagePath); | ||
| if (!data) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.failedToReadPackage", { path: packagePath })); | ||
| } | ||
| const fileName = this.fileSystem.path.basename(packagePath); | ||
| form.append("file", new Blob([data], { | ||
| type: "application/octet-stream" | ||
| }), fileName); | ||
| } | ||
| const response = await fetch(targetUrl, { | ||
| method: "POST", | ||
| headers, | ||
| body: form | ||
| }); | ||
| if (!response.ok) { | ||
| const body = await this.safeReadBody(response); | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.orchestratorPublishFailed", { | ||
| status: response.status, | ||
| statusText: response.statusText, | ||
| body: body ? ` - ${body}` : "" | ||
| })); | ||
| } | ||
| this.logger.info("Orchestrator publish completed."); | ||
| return new ToolResult(ToolErrorCodes.Success, undefined, packagePaths); | ||
| } | ||
| async resolveFeed(destination, orchestratorUrl) { | ||
| const connection = { | ||
| orchestratorUrl, | ||
| accessToken: destination.connectionInfo.accessToken, | ||
| tenantId: destination.connectionInfo.tenantId | ||
| }; | ||
| const feeds = await this.feedsService.getAccessibleFeedsAsync(connection); | ||
| if (destination.kind === "OrchestratorPersonalWorkspace" /* OrchestratorPersonalWorkspace */) { | ||
| const folders = await this.feedsService.getFoldersForCurrentUserAsync(connection); | ||
| const personalFolder = folders.find((f) => f.feedType === ExtendedFolderDtoFeedTypeEnum.PersonalWorkspace); | ||
| if (!personalFolder) { | ||
| const foldersDebug = folders.length === 0 ? "<none>" : folders.map((f) => `${f.displayName} (id=${f.id}, feedType=${f.feedType})`).join(", "); | ||
| throw new Error(translate.t("solutionpackager.publish.errors.orchestratorPersonalWorkspaceFolderNotFound", { folders: foldersDebug })); | ||
| } | ||
| if (personalFolder.id == null) { | ||
| throw new Error(`Personal-workspace folder "${personalFolder.displayName}" has no id; cannot resolve its feed.`); | ||
| } | ||
| const match2 = feeds.find((f) => f.folderId === personalFolder.id); | ||
| if (!match2) { | ||
| this.throwFeedNotFound(destination, feeds); | ||
| } | ||
| return match2; | ||
| } | ||
| const expectedPurpose = destination.kind === "OrchestratorSharedLibraries" /* OrchestratorSharedLibraries */ ? PackageFeedDtoPurposeEnum.Libraries : PackageFeedDtoPurposeEnum.Processes; | ||
| const match = feeds.find((f) => f.purpose === expectedPurpose && f.folderId == null); | ||
| if (!match) { | ||
| this.throwFeedNotFound(destination, feeds); | ||
| } | ||
| return match; | ||
| } | ||
| throwFeedNotFound(destination, feeds) { | ||
| const available = feeds.length === 0 ? "<none>" : feeds.map((f) => `${f.name} (purpose=${f.purpose}, folderId=${f.folderId ?? "null"})`).join(", "); | ||
| throw new Error(translate.t("solutionpackager.publish.errors.orchestratorFeedNotFound", { | ||
| kind: destination.kind, | ||
| available | ||
| })); | ||
| } | ||
| buildPublishUrl(orchestratorUrl, feed) { | ||
| const baseUrl = feed.publishUrl ? feed.publishUrl : `${orchestratorUrl}${feed.purpose === PackageFeedDtoPurposeEnum.Libraries ? LIBRARIES_UPLOAD_PATH : PROCESSES_UPLOAD_PATH}`; | ||
| const parsed = new URL(baseUrl); | ||
| if (feed.id) { | ||
| parsed.searchParams.set("feedId", feed.id); | ||
| } | ||
| return parsed.toString(); | ||
| } | ||
| deriveOrchestratorUrl(connectionInfo) { | ||
| const raw = connectionInfo.cloudUrl ?? ""; | ||
| let end = raw.length; | ||
| while (end > 0 && raw.charCodeAt(end - 1) === 47) | ||
| end--; | ||
| return `${raw.slice(0, end)}${ORCHESTRATOR_RELATIVE_URL}`; | ||
| } | ||
| buildHeaders(destination, feed) { | ||
| const headers = this.buildAuthHeaders(destination.connectionInfo); | ||
| const folderHeader = destination.kind === "OrchestratorSharedLibraries" /* OrchestratorSharedLibraries */ ? destination.folderId : feed.folderId; | ||
| if (folderHeader != null) { | ||
| headers[HEADER_FOLDER_ID] = String(folderHeader); | ||
| } | ||
| if (feed.authenticationType === PackageFeedDtoAuthenticationTypeEnum.ApiKey && feed.apiKey) { | ||
| headers[HEADER_NUGET_API_KEY] = feed.apiKey; | ||
| } | ||
| return headers; | ||
| } | ||
| buildCustomHeaders(destination) { | ||
| const headers = this.buildAuthHeaders(destination.connectionInfo); | ||
| if (destination.folderId != null) { | ||
| headers[HEADER_FOLDER_ID] = String(destination.folderId); | ||
| } | ||
| if (destination.apiKey) { | ||
| headers[HEADER_NUGET_API_KEY] = destination.apiKey; | ||
| } | ||
| return headers; | ||
| } | ||
| buildAuthHeaders(connectionInfo) { | ||
| const headers = {}; | ||
| if (connectionInfo.accessToken) { | ||
| headers.Authorization = `Bearer ${connectionInfo.accessToken}`; | ||
| } | ||
| if (connectionInfo.tenantId) { | ||
| headers[HEADER_TENANT_ID2] = connectionInfo.tenantId; | ||
| } | ||
| return headers; | ||
| } | ||
| async safeReadBody(response) { | ||
| try { | ||
| const text = await response.text(); | ||
| return text.slice(0, 500); | ||
| } catch { | ||
| return ""; | ||
| } | ||
| } | ||
| } | ||
| // ../packager/project-packager/src/publish/services/project-publisher.ts | ||
| class ProjectPublisher { | ||
| fileSystem; | ||
| logger; | ||
| localFolderPublisher; | ||
| nugetFeedPublisher; | ||
| orchestratorPublisher; | ||
| constructor(fileSystem, publishers) { | ||
| this.fileSystem = fileSystem; | ||
| this.logger = new ToolLogger("ProjectPublisher", "Publish"); | ||
| this.localFolderPublisher = publishers?.localFolder ?? new LocalFolderPublisher(fileSystem); | ||
| this.nugetFeedPublisher = publishers?.nugetFeed ?? new NugetFeedPublisher(fileSystem); | ||
| this.orchestratorPublisher = publishers?.orchestrator ?? new OrchestratorPublisher(fileSystem); | ||
| } | ||
| async publishAsync(options) { | ||
| if (!options.packagePaths || options.packagePaths.length === 0) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.atLeastOnePackage")); | ||
| } | ||
| for (const path of options.packagePaths) { | ||
| if (!await this.fileSystem.exists(path)) { | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.packageNotFound", { path })); | ||
| } | ||
| } | ||
| try { | ||
| const destination = options.destination; | ||
| switch (destination.kind) { | ||
| case "LocalFolder" /* LocalFolder */: | ||
| return await this.localFolderPublisher.publishAsync(options.packagePaths, destination); | ||
| case "NugetFeed" /* NugetFeed */: | ||
| return await this.nugetFeedPublisher.publishAsync(options.packagePaths, destination); | ||
| case "OrchestratorPersonalWorkspace" /* OrchestratorPersonalWorkspace */: | ||
| case "OrchestratorTenantProcesses" /* OrchestratorTenantProcesses */: | ||
| case "OrchestratorSharedLibraries" /* OrchestratorSharedLibraries */: | ||
| case "OrchestratorCustom" /* OrchestratorCustom */: | ||
| return await this.orchestratorPublisher.publishAsync(options.packagePaths, destination); | ||
| default: { | ||
| const exhaustive = destination; | ||
| return ToolResult.error(ToolErrorCodes.InternalError, translate.t("solutionpackager.publish.errors.unknownDestination", { destination: JSON.stringify(exhaustive) })); | ||
| } | ||
| } | ||
| } catch (error) { | ||
| const message = error instanceof Error ? error.message : String(error); | ||
| const localized = translate.t("solutionpackager.publish.errors.publishFailed", { message }); | ||
| this.logger.error(localized); | ||
| return ToolResult.error(ToolErrorCodes.InternalError, localized); | ||
| } | ||
| } | ||
| } | ||
| export { | ||
| signNupkgsAsync, | ||
| setGlobalLogHandler, | ||
| resolveProducedNupkgsAsync, | ||
| ToolsFactory, | ||
| ToolLogger, | ||
| TelemetryService, | ||
| TelemetryNames, | ||
| RulesConfigFileType, | ||
| PublishDestinationKind, | ||
| ProjectValidateOptionsValidator, | ||
| ProjectValidateOptions, | ||
| ProjectToolExecutor, | ||
| ProjectRestoreOptions, | ||
| ProjectPublisher, | ||
| ProjectPublishOptions, | ||
| ProjectPackager, | ||
| ProjectPackOptions, | ||
| ProjectLoader, | ||
| ProjectCleanupOptions, | ||
| ProjectBuildOptionsValidator, | ||
| ProjectBuildOptions, | ||
| PackagerParametersValidator, | ||
| PackagerParameters, | ||
| PackService, | ||
| GovernancePolicyService, | ||
| ConsoleTelemetryProvider, | ||
| BrowserContextStorage | ||
| }; | ||
| //# debugId=D696059BF0D8962764756E2164756E21 |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
48
-2.04%