@uipath/solutionpackager-tool-core 1.206.0-preview.306 → 1.207.0-preview.307

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/dist/index.js CHANGED
@@ -1144,6 +1144,8 @@ var ToolErrorCodes;
1144
1144
  ((ToolErrorCodes) => {
1145
1145
  ToolErrorCodes["Success"] = "SUCCESS";
1146
1146
  ToolErrorCodes["InternalError"] = "INTERNAL_ERROR";
1147
+ ToolErrorCodes["InvalidProject"] = "INVALID_PROJECT";
1148
+ ToolErrorCodes["DependencyInstallFailed"] = "DEPENDENCY_INSTALL_FAILED";
1147
1149
  ToolErrorCodes["Canceled"] = "CANCELED";
1148
1150
  })(ToolErrorCodes ||= {});
1149
1151
  // src/models/tool-result.ts
@@ -1197,12 +1199,15 @@ function createDefaultBindingsVersion() {
1197
1199
  return { major: 2, minor: 0 };
1198
1200
  }
1199
1201
  // src/services/json-object.ts
1202
+ function isJsonObject(value) {
1203
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1204
+ }
1200
1205
  function parseJsonObject(text) {
1201
1206
  if (!text)
1202
1207
  return;
1203
1208
  try {
1204
1209
  const value = JSON.parse(text);
1205
- return typeof value === "object" && value !== null && !Array.isArray(value) ? value : undefined;
1210
+ return isJsonObject(value) ? value : undefined;
1206
1211
  } catch {
1207
1212
  return;
1208
1213
  }
@@ -1547,23 +1552,28 @@ class NugetPackager {
1547
1552
  }
1548
1553
  }
1549
1554
  // src/services/project-identity.ts
1555
+ function declaredProjectType(project) {
1556
+ const design = project.designOptions;
1557
+ return (isJsonObject(design) ? design.outputType : undefined) ?? project.ProjectType ?? project.type;
1558
+ }
1559
+ var MAX_IDENTITY_FILE_BYTES = 1024 * 1024;
1550
1560
  async function readIdentityJson(fs, path) {
1551
1561
  const stat = await fs.stat(path);
1552
1562
  if (!stat)
1553
1563
  return;
1554
- if (!stat.isFile() || stat.size > 1024 * 1024)
1564
+ if (!stat.isFile() || stat.size > MAX_IDENTITY_FILE_BYTES)
1555
1565
  throw new Error("Invalid identity metadata");
1556
1566
  const text = await fs.readFile(path, "utf-8");
1557
1567
  if (text === null)
1558
1568
  return;
1559
- const value = JSON.parse(text);
1569
+ const value = JSON.parse(text.replace(/^/, ""));
1560
1570
  if (!value || typeof value !== "object" || Array.isArray(value)) {
1561
1571
  throw new Error("Invalid identity metadata");
1562
1572
  }
1563
1573
  return value;
1564
1574
  }
1565
- async function readIdentityField(fs, file, fields) {
1566
- let value = await readIdentityJson(fs, file);
1575
+ function identityFieldValue(source, fields) {
1576
+ let value = source;
1567
1577
  for (const field of fields) {
1568
1578
  if (!value || typeof value !== "object")
1569
1579
  return;
@@ -1575,6 +1585,9 @@ async function readIdentityField(fs, file, fields) {
1575
1585
  throw new Error("Invalid project identity");
1576
1586
  return value;
1577
1587
  }
1588
+ async function readIdentityField(fs, file, fields) {
1589
+ return identityFieldValue(await readIdentityJson(fs, file), fields);
1590
+ }
1578
1591
  // src/services/project-tool.ts
1579
1592
  class ProjectTool {
1580
1593
  fileSystem;
@@ -1695,8 +1708,10 @@ export {
1695
1708
  I18nManager,
1696
1709
  LogLevel,
1697
1710
  LogMessage,
1711
+ MAX_IDENTITY_FILE_BYTES,
1698
1712
  NugetConstants,
1699
1713
  NugetPackager,
1714
+ PROJECT_FILE,
1700
1715
  PackJobTargetKind,
1701
1716
  Path,
1702
1717
  ProjectTool,
@@ -1711,10 +1726,13 @@ export {
1711
1726
  ZipService,
1712
1727
  applyDefaultEntryPoint,
1713
1728
  createDefaultBindingsVersion,
1729
+ declaredProjectType,
1714
1730
  ensureContentOperateFile,
1715
1731
  ensureProjectId,
1716
1732
  ensureProjectIdInOperateFile,
1733
+ identityFieldValue,
1717
1734
  isDefaultFlag,
1735
+ isJsonObject,
1718
1736
  normalizeIgnoredRules,
1719
1737
  orderDefaultEntryPointFirst,
1720
1738
  parseJsonObject,
@@ -1736,4 +1754,4 @@ export {
1736
1754
  writeOrBackfillOperateProjectId
1737
1755
  };
1738
1756
 
1739
- //# debugId=54ADCCF818CF1DF264756E2164756E21
1757
+ //# debugId=D615D32E3BFC992564756E2164756E21
@@ -159,4 +159,10 @@ export interface IProjectPackOptions extends IProjectBuildOptions {
159
159
  * Whether to split packages
160
160
  */
161
161
  splitPackages: boolean;
162
+ /**
163
+ * Pack the project's existing build output instead of running its own
164
+ * build first. Only a tool that builds at pack time reads it (a coded
165
+ * app's `npm run build`). Absent means build.
166
+ */
167
+ skipBuild?: boolean;
162
168
  }
@@ -4,6 +4,19 @@
4
4
  export declare enum ToolErrorCodes {
5
5
  Success = "SUCCESS",
6
6
  InternalError = "INTERNAL_ERROR",
7
+ /**
8
+ * The project cannot be packed as it is on disk, and only its author can
9
+ * change that (a build that fails, a tool the build needs that is not
10
+ * installed). A retry gives the same answer.
11
+ */
12
+ InvalidProject = "INVALID_PROJECT",
13
+ /**
14
+ * Installing the project's dependencies failed. The cause may be outside
15
+ * the project (the package registry, the network) or in it (a lockfile out
16
+ * of step with its manifest), and the packager cannot tell which, so a
17
+ * retry may help.
18
+ */
19
+ DependencyInstallFailed = "DEPENDENCY_INSTALL_FAILED",
7
20
  /** @public Used by packager-tool-workflowcompiler */
8
21
  Canceled = "CANCELED"
9
22
  }
@@ -1,12 +1,12 @@
1
1
  export type { BuildContentOperateFileParams, ContentOperateFileParams, DefaultEntryPointParams, OperateEntryPoint, } from "./content-operate-file.js";
2
2
  export { applyDefaultEntryPoint, ensureContentOperateFile, isDefaultFlag, orderDefaultEntryPointFirst, readOperateMain, readProjectMainFile, resolveOperateMain, resolveOperateMainEntry, resolvePackagedMain, resolvePackagedMainEntry, writeContentOperateFile, } from "./content-operate-file.js";
3
- export { type JsonObject, parseJsonObject, readJsonObjectFile, } from "./json-object.js";
3
+ export { isJsonObject, type JsonObject, parseJsonObject, readJsonObjectFile, } from "./json-object.js";
4
4
  export type { INugetPackager, NugetPackagerResult } from "./nuget-packager.js";
5
5
  export { NugetPackager } from "./nuget-packager.js";
6
- export { ensureProjectId, ensureProjectIdInOperateFile, writeOrBackfillOperateProjectId, } from "./project-id.js";
6
+ export { ensureProjectId, ensureProjectIdInOperateFile, PROJECT_FILE, writeOrBackfillOperateProjectId, } from "./project-id.js";
7
7
  export * from "./project-identity.js";
8
8
  export type { ProjectActivityObserver, ProjectOperationContext, } from "./project-operation-context.js";
9
- export type { ProjectBindingResource, ProjectContributionError, ProjectResourceContribution, ProjectSpecPatch, } from "./project-resource-contribution.js";
9
+ export type { ProjectBindingResource, ProjectContributionError, ProjectResourceContribution, ProjectResourcePreparation, ProjectSpecPatch, } from "./project-resource-contribution.js";
10
10
  export { ProjectTool } from "./project-tool.js";
11
11
  export type { IProjectToolFactory } from "./project-tool-factory.js";
12
12
  export { SolutionTool } from "./solution-tool.js";
@@ -1,5 +1,7 @@
1
1
  import type { IFileSystem } from "@uipath/filesystem";
2
2
  export type JsonObject = Record<string, unknown>;
3
+ /** A parsed JSON value that is an object: not `null`, not an array. */
4
+ export declare function isJsonObject(value: unknown): value is JsonObject;
3
5
  /** `text` as a JSON object, or `undefined` when it is empty, not JSON, or not an object. */
4
6
  export declare function parseJsonObject(text: string | null | undefined): JsonObject | undefined;
5
7
  /**
@@ -1,4 +1,6 @@
1
1
  import type { IFileSystem } from "@uipath/filesystem";
2
+ /** The manifest Studio writes for an RPA project; the one file its id lives in. */
3
+ export declare const PROJECT_FILE = "project.json";
2
4
  /**
3
5
  * Resolve a stable projectId for a project source directory, patching it
4
6
  * into operate.json (or legacy project.json) if missing. Returns a fresh
@@ -8,7 +8,25 @@ export interface ProjectIdentityDescription {
8
8
  status: "resolved" | "missing" | "invalid" | "unsupported";
9
9
  }
10
10
  export type ProjectIdentityReader = (target: string, fs: IFileSystem) => Promise<ProjectIdentityDescription>;
11
+ /**
12
+ * The type a Studio-style `project.json` declares, as declared: the effective
13
+ * `designOptions.outputType` (the field the project loader and the solution
14
+ * reader take it from), then the manifest-level `ProjectType` and `type`
15
+ * spellings. `undefined` when the manifest declares none. Each reader applies
16
+ * its own coercion to the value.
17
+ */
18
+ export declare function declaredProjectType(project: Record<string, unknown>): unknown;
19
+ /** Bound of an identity file read; past it, the file is not read. */
20
+ export declare const MAX_IDENTITY_FILE_BYTES: number;
11
21
  /** Bounded reads; malformed files are not silently treated as absent. */
12
22
  export declare function readIdentityJson(fs: IFileSystem, path: string): Promise<Record<string, unknown> | undefined>;
23
+ /**
24
+ * The identity field at `fields` inside an already parsed source: absent,
25
+ * `null` or empty is `undefined`; anything else that is not a non-blank
26
+ * string is invalid. For a reader that takes its type from the same file and
27
+ * so already holds the parsed object; {@link readIdentityField} reads and
28
+ * applies it in one go.
29
+ */
30
+ export declare function identityFieldValue(source: unknown, fields: readonly string[]): string | undefined;
13
31
  /** Read a source field chosen by its owner, without changing the source. */
14
32
  export declare function readIdentityField(fs: IFileSystem, file: string, fields: readonly string[]): Promise<string | undefined>;
@@ -51,6 +51,15 @@ export interface ProjectBindingResource {
51
51
  key?: string;
52
52
  [field: string]: unknown;
53
53
  }
54
+ /**
55
+ * What a project's preparation pass did (see
56
+ * `IProjectToolFactory.prepareProjectResourcesAsync`). Plain data, like a
57
+ * contribution: the tool writes only files it owns and reports here.
58
+ */
59
+ export interface ProjectResourcePreparation {
60
+ /** Blocking problems. Any entry fails `solution pack` before the sync runs. */
61
+ errors?: ProjectContributionError[];
62
+ }
54
63
  export interface ProjectResourceContribution {
55
64
  /** Blocking problems. Any entry fails `solution pack`. */
56
65
  errors?: ProjectContributionError[];
@@ -2,7 +2,7 @@ import type { IFileSystem } from "../filesystem/file-system.js";
2
2
  import type { ProjectType } from "../models/project-type.js";
3
3
  import type { ProjectIdentityReader } from "./project-identity.js";
4
4
  import type { ProjectOperationContext } from "./project-operation-context.js";
5
- import type { ProjectResourceContribution } from "./project-resource-contribution.js";
5
+ import type { ProjectResourceContribution, ProjectResourcePreparation } from "./project-resource-contribution.js";
6
6
  import type { ProjectTool } from "./project-tool.js";
7
7
  import type { IToolLogger } from "./tool-logger.js";
8
8
  /**
@@ -32,8 +32,28 @@ export interface IProjectToolFactory {
32
32
  * tool is older than this host — but it may equally mean this type has
33
33
  * nothing to contribute, and a caller cannot tell the two apart. How a
34
34
  * caller reports the absence is its own policy.
35
+ *
36
+ * `forDebug` marks a pack for a debug run, which may relax a
37
+ * release-only gate (unbound case roles). The build is the same.
35
38
  */
36
39
  describeResourcesAsync?(projectDir: string, fileSystem: IFileSystem, context?: {
37
40
  sharesSolutionDirectory: boolean;
41
+ forDebug?: boolean;
38
42
  }): Promise<ProjectResourceContribution>;
43
+ /**
44
+ * Bring the files this project type owns — its own project files and the
45
+ * solution resource files of kinds its tool owns — up to date before the
46
+ * solution's resources are read. The one write hook in the pipeline:
47
+ * `describeResourcesAsync` and the sync then observe the prepared state,
48
+ * so a resource regenerated here is seen by everything after it.
49
+ *
50
+ * Implementations write only files they own, never the `.uipx` or another
51
+ * kind's resources, and must be idempotent — a second run with nothing to
52
+ * do writes nothing. Optional for the same reasons as
53
+ * `describeResourcesAsync`.
54
+ */
55
+ prepareProjectResourcesAsync?(projectDir: string, fileSystem: IFileSystem, context: {
56
+ solutionRoot: string;
57
+ sharesSolutionDirectory: boolean;
58
+ }): Promise<ProjectResourcePreparation>;
39
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/solutionpackager-tool-core",
3
- "version": "1.206.0-preview.306",
3
+ "version": "1.207.0-preview.307",
4
4
  "description": "UiPath contracts for solution packager tools",
5
5
  "type": "module",
6
6
  "exports": {
@@ -24,8 +24,8 @@
24
24
  "registry": "https://registry.npmjs.org/"
25
25
  },
26
26
  "dependencies": {
27
- "@uipath/filesystem": "1.206.0",
27
+ "@uipath/filesystem": "1.207.0",
28
28
  "fflate": "^0.8.2"
29
29
  },
30
- "gitHead": "0b8843ae9b6d2f69a0203f96ab91e5d55e416383"
30
+ "gitHead": "a625ed8ac421089170db3cb8b95c497f3c7b0d62"
31
31
  }