@uipath/packager-tool-datafabric 1.201.0-preview.141 → 1.201.0-preview.142

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/init.js CHANGED
@@ -20651,7 +20651,7 @@ function querystringSingleKey(key, value, keyPrefix = "") {
20651
20651
  var package_default = {
20652
20652
  name: "@uipath/solution-sdk",
20653
20653
  license: "MIT",
20654
- version: "1.202.0-preview.141",
20654
+ version: "1.202.0-preview.142",
20655
20655
  repository: {
20656
20656
  type: "git",
20657
20657
  url: "https://github.com/UiPath/cli.git",
@@ -24488,4 +24488,4 @@ export {
24488
24488
  entityInitAsync
24489
24489
  };
24490
24490
 
24491
- //# debugId=166BFA8B6D51570364756E2164756E21
24491
+ //# debugId=C23089524159D74064756E2164756E21
package/package.json CHANGED
@@ -1,17 +1,11 @@
1
1
  {
2
2
  "name": "@uipath/packager-tool-datafabric",
3
- "version": "1.201.0-preview.141",
3
+ "version": "1.201.0-preview.142",
4
4
  "description": "UiPath Data Fabric entity schema, validation and packaging library",
5
5
  "type": "module",
6
6
  "exports": {
7
- ".": {
8
- "source": "./src/index.ts",
9
- "default": "./dist/index.js"
10
- },
11
- "./init": {
12
- "source": "./src/init.ts",
13
- "default": "./dist/init.js"
14
- }
7
+ ".": "./dist/index.js",
8
+ "./init": "./dist/init.js"
15
9
  },
16
10
  "repository": {
17
11
  "type": "git",
@@ -23,13 +17,12 @@
23
17
  },
24
18
  "types": "./dist/index.d.ts",
25
19
  "files": [
26
- "dist",
27
- "src"
20
+ "dist"
28
21
  ],
29
22
  "author": "",
30
23
  "license": "ISC",
31
24
  "peerDependencies": {
32
25
  "@uipath/solutionpackager-tool-core": "1.202.0"
33
26
  },
34
- "gitHead": "2c2b4b3b218f18c26db78eb8cd9ab8002d2b5290"
27
+ "gitHead": "2f7204440851d62ecc9f2d2e202c863293821d90"
35
28
  }
package/src/index.ts DELETED
@@ -1,53 +0,0 @@
1
- // Data Fabric entity library for the solution packager and its hosts: the CLI
2
- // via @uipath/data-fabric-tool, the Maestro VS Code extension directly.
3
- // Side-effect-free: importing this package registers nothing and touches
4
- // neither disk nor network.
5
-
6
- export type { EntityPackDiagnostic } from "./pack/entity-project-tool.js";
7
- export {
8
- ENTITY_VALIDATION_FAILED,
9
- EntityProjectTool,
10
- } from "./pack/entity-project-tool.js";
11
- export { EntityToolFactory } from "./pack/entity-tool-factory.js";
12
- export type {
13
- PairFailure,
14
- PairFailureCode,
15
- PairResult,
16
- } from "./pack/verify-pair.js";
17
- export { findSolutionRoot, verifyPair } from "./pack/verify-pair.js";
18
- export type { ResourceParseFailure } from "./resource/resource-io.js";
19
- export {
20
- EntityResourceError,
21
- serialize,
22
- serializeEntityJson,
23
- unwrapResource,
24
- updateResourceSchema,
25
- wrapEntityJson,
26
- } from "./resource/resource-io.js";
27
- export type {
28
- ResourceFolderRef,
29
- ResourceSpec,
30
- SolutionResource,
31
- UnifiedResourceFile,
32
- } from "./resource/unified-resource-file.js";
33
- export {
34
- ENTITY_RESOURCE_API_VERSION,
35
- ENTITY_RESOURCE_DOC_VERSION,
36
- ENTITY_RESOURCE_KIND,
37
- ENTITY_RESOURCE_TYPE,
38
- entityResourcePath,
39
- SOLUTION_FOLDER,
40
- } from "./resource/unified-resource-file.js";
41
- export {
42
- createEntitySkeleton,
43
- SYSTEM_FIELD_TEMPLATES,
44
- } from "./schema/create-entity-skeleton.js";
45
- export type {
46
- DiagnosticCode,
47
- EntityDiagnostic,
48
- ValidateEntityContext,
49
- } from "./schema/validate-entity.js";
50
- export { DIAGNOSTIC_CODES, validateEntity } from "./schema/validate-entity.js";
51
- // `entityInitAsync` is deliberately NOT exported here: it needs the filesystem
52
- // and solution-sdk, so it lives on the node-only `./init` entry and this module
53
- // stays browser-safe.
@@ -1,354 +0,0 @@
1
- import { catchError, logger } from "@uipath/common";
2
- import { NAME_PATTERN } from "@uipath/entity-modeler/schema";
3
- import { getFileSystem } from "@uipath/filesystem";
4
- import {
5
- type AutoCreatedSolution,
6
- prepareProjectLocation,
7
- readSolutionManifest,
8
- tryRegisterProjectInParentSolution,
9
- type UipxProject,
10
- } from "@uipath/solution-sdk";
11
- import { ENTITY_EXTENSION_CONST as ENTITY_EXTENSION } from "../pack/constants.js";
12
- import { serialize, wrapEntityJson } from "../resource/resource-io.js";
13
- import { entityResourcePath } from "../resource/unified-resource-file.js";
14
- import { createEntitySkeleton } from "../schema/create-entity-skeleton.js";
15
-
16
- export type { AutoCreatedSolution };
17
-
18
- /** Same rule `maestro-sdk` applies to project names, inlined so the root
19
- * module stays free of the SDK. */
20
- const VALID_PROJECT_NAME_REGEX = /^[a-zA-Z0-9_-]+$/;
21
-
22
- export interface EntityInitOptions {
23
- /** Initialize even if the target directory exists and is not empty. */
24
- force?: boolean;
25
- /**
26
- * Base dir the bare project `name` resolves against, and what a relative
27
- * `uipxPath` resolves against. Required unless `uipxPath` is absolute.
28
- */
29
- cwd?: string;
30
- /**
31
- * Path to the parent solution's `.uipx` FILE. Give this when the caller
32
- * already knows the manifest — an editor host does — so placement and
33
- * registration stop depending on where the process happens to be.
34
- *
35
- * The project is created at `<dirname(uipxPath)>/<name>`, which is also the
36
- * directory registration searches first — so the named manifest is the one
37
- * that gets the `Projects[]` entry. Passing it suppresses the auto-scaffold:
38
- * a named manifest that does not exist is an error, not a cue to create a
39
- * solution.
40
- *
41
- * Not yet honored when that directory holds more than one `.uipx` — the
42
- * SDK's discovery refuses the ambiguity, and the run fails with that reason.
43
- *
44
- * Omit it to keep the previous behavior: place under `cwd` and take
45
- * whichever `.uipx` the upward search finds.
46
- */
47
- uipxPath?: string;
48
- /** The first entity's own Name. */
49
- firstEntityName: string;
50
- }
51
-
52
- /**
53
- * Outcome of registering the project in the parent `.uipx`. Structural mirror of
54
- * solution-sdk's envelope, so the published `.d.ts` stays free of the private
55
- * SDK type.
56
- *
57
- * Only `Status` is guaranteed: the SDK always returns a status — "Registered",
58
- * "AlreadyRegistered", "NotInSolution", "OptedOut", "Skipped" or "Failed" — but
59
- * the rest describe a registration that actually happened, so they are absent
60
- * when it did not. `Solution` and `ProjectId` are present for the two statuses
61
- * this service accepts; every other status makes it throw.
62
- */
63
- export interface EntityProjectRegistration {
64
- Status: string;
65
- Message?: string;
66
- Instructions?: string;
67
- /** Absolute path to the parent `.uipx`. */
68
- Solution?: string;
69
- /** Solution-relative path to the project file. */
70
- Project?: string;
71
- /** GUID written into the `.uipx` `Projects[]` entry. */
72
- ProjectId?: string;
73
- }
74
-
75
- export interface EntityInitResult {
76
- projectName: string;
77
- /** Absolute path to the created project directory. */
78
- projectDir: string;
79
- /** Absolute path to the written `<EntityName>.entity` stub. */
80
- entityFile: string;
81
- /** Absolute path to the written entity definition resource. */
82
- resourceFile: string;
83
- registration: EntityProjectRegistration;
84
- /** Present when the SDK auto-created the parent solution. */
85
- autoCreatedSolution?: AutoCreatedSolution;
86
- }
87
-
88
- /**
89
- * Scaffolds an Entity project: `project.uiproj`, the `.entity` pointer stub, a
90
- * `{ Type: "Entity" }` entry in the parent `.uipx` (auto-creating the solution
91
- * when outside one, like `flowInitAsync`), and the entity definition resource
92
- * under the solution root.
93
- *
94
- * Throws on failure and rolls back what it created. The resource lives outside
95
- * the project dir, so an Entity project cannot exist without a solution.
96
- */
97
- export async function entityInitAsync(
98
- name: string,
99
- options: EntityInitOptions,
100
- ): Promise<EntityInitResult> {
101
- if (!VALID_PROJECT_NAME_REGEX.test(name)) {
102
- throw new Error(
103
- `Invalid project name "${name}". Name can only contain letters, numbers, underscores (_), and hyphens (-).`,
104
- );
105
- }
106
- const entityName = options.firstEntityName;
107
- if (!NAME_PATTERN.test(entityName)) {
108
- throw new Error(
109
- `Invalid entity name "${entityName}". Entity names start with a letter and contain 3-100 letters or digits.`,
110
- );
111
- }
112
-
113
- const fs = getFileSystem();
114
- const solutionFile = await resolveSolutionFileAsync(options);
115
-
116
- // With a named manifest the location is already decided, so skip
117
- // `prepareProjectLocation` entirely — its job is discovery plus the
118
- // auto-scaffold fallback, and both are wrong once the caller has told us
119
- // which solution to join.
120
- const { projectDir, autoCreatedSolution } = solutionFile
121
- ? { projectDir: fs.path.join(fs.path.dirname(solutionFile), name) }
122
- : await prepareProjectLocation(
123
- fs,
124
- fs.path.resolve(requireCwd(options), name),
125
- name,
126
- {},
127
- );
128
-
129
- // `stat` resolves to null for a missing path, so the null check — not the
130
- // error — is what marks the dir as new. An error here is real I/O failure.
131
- const [statError, stat] = await catchError(fs.stat(projectDir));
132
- if (statError && !isMissingPathError(statError)) {
133
- throw statError;
134
- }
135
- const projectDirExisted = !statError && stat !== null;
136
-
137
- if (projectDirExisted && !options.force) {
138
- const existingEntries = await fs.readdir(projectDir);
139
- if (existingEntries.length > 0) {
140
- throw new Error(
141
- `Directory "${name}" already exists and is not empty. Use --force to overwrite.`,
142
- );
143
- }
144
- }
145
-
146
- /** Undo only what THIS run created: never a pre-existing dir, and never a
147
- * `.uipx` entry that was already there. */
148
- let registered: { solutionFile: string; projectId: string } | undefined;
149
- const rollback = async (): Promise<void> => {
150
- if (registered) {
151
- await unregisterProject(registered);
152
- }
153
- if (!projectDirExisted) {
154
- await catchError(fs.rm(projectDir));
155
- }
156
- };
157
-
158
- try {
159
- await fs.mkdir(projectDir);
160
-
161
- await fs.writeFile(
162
- fs.path.join(projectDir, "project.uiproj"),
163
- serialize({ Name: name, ProjectType: "Entity" }),
164
- );
165
-
166
- const relativeResourcePath = entityResourcePath(entityName);
167
- const entityFile = fs.path.join(
168
- projectDir,
169
- `${entityName}${ENTITY_EXTENSION}`,
170
- );
171
- await fs.writeFile(
172
- entityFile,
173
- serialize({ name: entityName, resourcePath: relativeResourcePath }),
174
- );
175
-
176
- const registration = (await tryRegisterProjectInParentSolution(
177
- fs,
178
- projectDir,
179
- {},
180
- )) as EntityProjectRegistration;
181
-
182
- if (
183
- registration.Status === "Registered" &&
184
- registration.Solution &&
185
- registration.ProjectId
186
- ) {
187
- registered = {
188
- solutionFile: registration.Solution,
189
- projectId: registration.ProjectId,
190
- };
191
- }
192
-
193
- if (
194
- (registration.Status !== "Registered" &&
195
- registration.Status !== "AlreadyRegistered") ||
196
- !registration.Solution
197
- ) {
198
- // No solution → the stub's pointer can never resolve. Fail instead
199
- // of scaffolding a broken pair; the catch below rolls back.
200
- if (solutionFile && registration.Status === "Skipped") {
201
- // Known limit: registration discovers the manifest by walking up,
202
- // and it refuses a directory holding more than one `.uipx` — so a
203
- // named manifest cannot be honored there yet. Say that plainly
204
- // instead of reporting a missing parent solution.
205
- throw new Error(
206
- `Entity project "${name}" could not be registered in '${solutionFile}': ` +
207
- `${registration.Instructions ?? registration.Message ?? "registration was skipped"}. ` +
208
- "A solution folder containing more than one .uipx is not supported yet — " +
209
- "register the project with 'uip solution projects add' instead.",
210
- );
211
- }
212
- throw new Error(
213
- `Entity project "${name}" requires a parent solution (registration status: ${registration.Status}). ` +
214
- "Run inside a solution directory, or create one first with 'uip solution init'.",
215
- );
216
- }
217
-
218
- const solutionDir = fs.path.dirname(registration.Solution);
219
- const resourceFile = fs.path.join(
220
- solutionDir,
221
- ...relativeResourcePath.split("/"),
222
- );
223
- await fs.mkdir(fs.path.dirname(resourceFile));
224
- await fs.writeFile(
225
- resourceFile,
226
- serialize(wrapEntityJson(createEntitySkeleton(entityName))),
227
- );
228
-
229
- // No `uip solution project add`-equivalent artifact step here, unlike the
230
- // other init paths. The resource engine has no mapping for `Entity`, so
231
- // it falls back to its default and writes a `package/` plus a
232
- // `process/process/` resource — a process package that will never exist,
233
- // since an Entity project emits none: its definition resource above IS
234
- // the deployable payload. Pack only needs the `.uipx` Projects[] entry
235
- // that registration just wrote.
236
-
237
- return {
238
- projectName: name,
239
- projectDir,
240
- entityFile,
241
- resourceFile,
242
- registration,
243
- autoCreatedSolution,
244
- };
245
- } catch (error) {
246
- await rollback();
247
- throw error;
248
- }
249
- }
250
-
251
- /**
252
- * The caller's `cwd`, or a clear error. Only reached on the discovery path —
253
- * `uipxPath` supplies the base dir itself.
254
- */
255
- function requireCwd(options: EntityInitOptions): string {
256
- if (!options.cwd) {
257
- throw new Error(
258
- "Either 'cwd' or 'uipxPath' is required: without one there is no base " +
259
- "directory to create the project in.",
260
- );
261
- }
262
- return options.cwd;
263
- }
264
-
265
- /**
266
- * Resolve `uipxPath` to an absolute, existing `.uipx` file, or `undefined` when
267
- * the caller did not name one (keep discovering as before).
268
- *
269
- * Validated before anything is written, so a bad path fails with a useful
270
- * message instead of scaffolding a project that cannot be registered.
271
- */
272
- async function resolveSolutionFileAsync(
273
- options: EntityInitOptions,
274
- ): Promise<string | undefined> {
275
- if (!options.uipxPath) {
276
- return undefined;
277
- }
278
-
279
- const fs = getFileSystem();
280
- let resolved: string;
281
- if (fs.path.isAbsolute(options.uipxPath)) {
282
- resolved = options.uipxPath;
283
- } else if (options.cwd) {
284
- resolved = fs.path.resolve(options.cwd, options.uipxPath);
285
- } else {
286
- // Not the same failure as "neither was given": uipxPath IS set, it just
287
- // has nothing to resolve against.
288
- throw new Error(
289
- `uipxPath '${options.uipxPath}' is relative and no 'cwd' was given to resolve it against. ` +
290
- "Pass an absolute path, or set 'cwd'.",
291
- );
292
- }
293
-
294
- if (!resolved.endsWith(".uipx")) {
295
- throw new Error(
296
- `uipxPath must point at a .uipx file, got '${resolved}'. Pass the manifest itself, not its directory.`,
297
- );
298
- }
299
-
300
- const [statError, stat] = await catchError(fs.stat(resolved));
301
- if (statError || stat === null) {
302
- throw new Error(
303
- `Solution manifest not found: '${resolved}'. Create the solution first, or omit uipxPath to search for one.`,
304
- );
305
- }
306
- if (stat.isDirectory()) {
307
- throw new Error(
308
- `uipxPath must point at a .uipx file, but '${resolved}' is a directory.`,
309
- );
310
- }
311
-
312
- return resolved;
313
- }
314
-
315
- function isMissingPathError(error: Error): boolean {
316
- return (
317
- "code" in error &&
318
- (error.code === "ENOENT" || error.code === "PathNotFound")
319
- );
320
- }
321
-
322
- /**
323
- * Drop the `Projects[]` entry this run added to the parent `.uipx`. Best-effort:
324
- * rollback runs while another error is already heading to the caller, so a
325
- * failure here is logged rather than thrown.
326
- */
327
- async function unregisterProject(registered: {
328
- solutionFile: string;
329
- projectId: string;
330
- }): Promise<void> {
331
- const { solutionFile, projectId } = registered;
332
- const fs = getFileSystem();
333
- const [readError, solution] = await readSolutionManifest(fs, solutionFile);
334
- if (readError) {
335
- logger.warn(
336
- `Could not undo the solution registration for project id ${projectId} in '${solutionFile}': ${readError.message}. ` +
337
- "Remove the stale entry with 'uip solution project remove'.",
338
- );
339
- return;
340
- }
341
-
342
- solution.content.Projects = solution.projects.filter(
343
- (project: UipxProject) => project.Id !== projectId,
344
- );
345
- const [writeError] = await catchError(
346
- fs.writeFile(solutionFile, serialize(solution.content)),
347
- );
348
- if (writeError) {
349
- logger.warn(
350
- `Could not undo the solution registration for project id ${projectId} in '${solutionFile}': ${writeError.message}. ` +
351
- "Remove the stale entry with 'uip solution project remove'.",
352
- );
353
- }
354
- }
package/src/init.ts DELETED
@@ -1,13 +0,0 @@
1
- /**
2
- * Entity project scaffolding. A separate entry (like `@uipath/flow-tool/init`)
3
- * because it needs the filesystem and solution-sdk — node-only machinery the
4
- * root module must not pull into browser bundles.
5
- */
6
-
7
- export type {
8
- AutoCreatedSolution,
9
- EntityInitOptions,
10
- EntityInitResult,
11
- EntityProjectRegistration,
12
- } from "./init/entity-init-service.js";
13
- export { entityInitAsync } from "./init/entity-init-service.js";
@@ -1,20 +0,0 @@
1
- /** The entity stub extension. Its own module so every caller shares one
2
- * literal. */
3
- export const ENTITY_EXTENSION_CONST = ".entity";
4
-
5
- /** Error code on the `ToolResult` when entity validation fails. */
6
- export const ENTITY_VALIDATION_FAILED = "ENTITY_VALIDATION_FAILED";
7
-
8
- /**
9
- * Diagnostic codes pack raises about the PROJECT rather than a single entity.
10
- * The per-entity codes live with the checks that raise them: pair failures in
11
- * `verify-pair.ts` (`PairFailureCode`) and schema failures in
12
- * `validate-entity.ts` (`DIAGNOSTIC_CODES`).
13
- */
14
- export const PACK_DIAGNOSTIC_CODES = {
15
- /** A main file belonging to another project type sits in an Entity project. */
16
- misplacedMainFile: "MISPLACED_MAIN_FILE",
17
- /** The project has entities but no parent solution, so their
18
- * solution-relative resource pointers cannot resolve. */
19
- noParentSolution: "NO_PARENT_SOLUTION",
20
- } as const;