@uipath/data-fabric-tool 1.201.0 → 1.202.0-preview.136

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.
Files changed (28) hide show
  1. package/dist/{getMachineId-bsd-wfkxpxjv.js → getMachineId-bsd-67w37xtj.js} +5 -5
  2. package/dist/{getMachineId-darwin-9asn4zy6.js → getMachineId-darwin-4g3xfpfp.js} +5 -5
  3. package/dist/{getMachineId-linux-62t6m027.js → getMachineId-linux-a4p6fb9w.js} +4 -4
  4. package/dist/{getMachineId-unsupported-dfrzeqc3.js → getMachineId-unsupported-77w362eh.js} +4 -4
  5. package/dist/{getMachineId-win-zgvrp5q3.js → getMachineId-win-9cfxg9c8.js} +5 -5
  6. package/dist/{index-2fj08e7n.js → index-gpd94m28.js} +27 -27
  7. package/dist/{index-w03qc9m8.js → index-sby22td6.js} +4 -4
  8. package/dist/index.js +4 -7
  9. package/dist/{js-yaml-4ypbq2tt.js → js-yaml-88tdqrtd.js} +27 -19
  10. package/dist/{tool-0v6na3yp.js → packager-tool-1de529jm.js} +9 -7
  11. package/dist/{tool-h1k9mjs9.js → packager-tool-2czkpqb0.js} +3 -3
  12. package/dist/{tool-r6rhp5ep.js → packager-tool-bndhpxxj.js} +46 -46
  13. package/dist/{tool-91jjmaaz.js → packager-tool-r3p26srq.js} +2124 -1228
  14. package/dist/packager-tool.js +2568 -0
  15. package/dist/tool.js +6 -9
  16. package/package.json +4 -3
  17. package/src/packager-tool.spec.ts +29 -0
  18. package/src/packager-tool.ts +10 -0
  19. package/src/utils/validate.ts +11 -273
  20. package/tests/choice-sets-lifecycle.e2e.test.ts +2 -1
  21. package/tests/entities-lifecycle.e2e.test.ts +2 -1
  22. package/tests/entity-project-packaging.e2e.test.ts +549 -0
  23. package/tests/files-management.e2e.test.ts +2 -1
  24. package/dist/browser-strategy-yccf8mtd.js +0 -99
  25. package/dist/node-strategy-12qfy0nv.js +0 -348
  26. package/dist/tool-5arsyj36.js +0 -11
  27. package/dist/tool-7eva0peq.js +0 -265
  28. package/dist/tool-9qecd4wb.js +0 -14
@@ -0,0 +1,549 @@
1
+ import {
2
+ cpSync,
3
+ readdirSync,
4
+ readFileSync,
5
+ rmSync,
6
+ writeFileSync,
7
+ } from "node:fs";
8
+ import { join, resolve } from "node:path";
9
+ import { unzipSync } from "fflate";
10
+ import { describe, expect, it } from "vitest";
11
+ import {
12
+ type E2EManifest,
13
+ MANIFEST_PATH,
14
+ } from "../../../tests/e2e-shared/global-setup";
15
+ import {
16
+ createDir,
17
+ extractLastJson,
18
+ localCliRawWithArgs,
19
+ localCliWithArgs,
20
+ readManifest,
21
+ } from "../../../tests/e2e-shared/helpers";
22
+
23
+ // Owner of the df-entity-project-packaging thread: how an `Entity` project
24
+ // behaves inside a solution for `uip solution validate` / `uip solution pack`.
25
+ // Scenario: scenarios/data-fabric-tool/entity-project-packaging.md
26
+ //
27
+ // Pack of an Entity project is a local operation — no tenant, no login — so
28
+ // these build their own solution on disk and read the produced .zip.
29
+
30
+ const manifest = readManifest<E2EManifest>(MANIFEST_PATH);
31
+ const { tempDir: installDir } = manifest.sharedInstall;
32
+ const PACK_TIMEOUT = 5 * 60_000;
33
+
34
+ /** The api-workflow JSON fixture: a project that really does emit a .nupkg, so
35
+ * a mixed solution can be packed without a tenant. */
36
+ const API_FIXTURE = resolve(
37
+ import.meta.dirname,
38
+ "../../api-workflow-tool/tests/test-data/ApiWorkflowJsonProject",
39
+ );
40
+
41
+ /** Entry names inside the produced solution .zip. */
42
+ function zipEntries(outputDir: string): string[] {
43
+ const zip = readdirSync(outputDir).find((name) => name.endsWith(".zip"));
44
+ expect(zip).toBeDefined();
45
+ return Object.keys(
46
+ unzipSync(new Uint8Array(readFileSync(join(outputDir, zip as string)))),
47
+ );
48
+ }
49
+
50
+ interface PackEnvelope {
51
+ Result: string;
52
+ Code?: string;
53
+ ErrorCode?: string;
54
+ Message?: string;
55
+ Data?: { Packages?: string[] };
56
+ }
57
+
58
+ /**
59
+ * Scaffold a solution with one Entity project: `project.uiproj`, the `.entity`
60
+ * pointer, the definition resource under the solution root, and the `.uipx`
61
+ * entry — the shape `entityInitAsync` produces.
62
+ */
63
+ function seedEntitySolution(
64
+ root: string,
65
+ options: { entityName?: string; withApiProject?: boolean } = {},
66
+ ): string {
67
+ const entityName = options.entityName ?? "PurchaseOrder";
68
+ const solutionDir = join(root, "EntitySolution");
69
+ const projectDir = join(solutionDir, "MasterData");
70
+ createDir(projectDir);
71
+
72
+ const projects: Array<Record<string, string>> = [
73
+ {
74
+ Id: "11111111-1111-1111-1111-111111111111",
75
+ Type: "Entity",
76
+ ProjectRelativePath: "MasterData/project.uiproj",
77
+ },
78
+ ];
79
+
80
+ writeFileSync(
81
+ join(projectDir, "project.uiproj"),
82
+ `${JSON.stringify({ Name: "MasterData", ProjectType: "Entity" }, null, 2)}\n`,
83
+ );
84
+ const resourcePath = `resources/solution_folder/entity/native/${entityName}.json`;
85
+ writeFileSync(
86
+ join(projectDir, `${entityName}.entity`),
87
+ `${JSON.stringify({ name: entityName, resourcePath }, null, 2)}\n`,
88
+ );
89
+
90
+ const resourceDir = join(
91
+ solutionDir,
92
+ "resources",
93
+ "solution_folder",
94
+ "entity",
95
+ "native",
96
+ );
97
+ createDir(resourceDir);
98
+ writeFileSync(
99
+ join(resourceDir, `${entityName}.json`),
100
+ `${JSON.stringify(entityResource(entityName), null, 2)}\n`,
101
+ );
102
+
103
+ if (options.withApiProject) {
104
+ const apiDir = join(solutionDir, "ApiProj");
105
+ cpSync(API_FIXTURE, apiDir, { recursive: true });
106
+ projects.push({
107
+ Id: "22222222-2222-2222-2222-222222222222",
108
+ Type: "Api",
109
+ ProjectRelativePath: "ApiProj/project.json",
110
+ });
111
+ }
112
+
113
+ writeFileSync(
114
+ join(solutionDir, "EntitySolution.uipx"),
115
+ `${JSON.stringify(
116
+ {
117
+ DocVersion: "1.0.0",
118
+ StudioMinVersion: "2025.10.0",
119
+ SolutionId: "00000000-0000-0000-0000-0000000000aa",
120
+ Projects: projects,
121
+ },
122
+ null,
123
+ 2,
124
+ )}\n`,
125
+ );
126
+ return solutionDir;
127
+ }
128
+
129
+ /** A minimal valid entity definition resource: the 5 system fields only. */
130
+ function entityResource(name: string): unknown {
131
+ const systemField = (
132
+ fieldName: string,
133
+ sqlType: string,
134
+ over: Record<string, unknown> = {},
135
+ ) => ({
136
+ IsPrimaryKey: false,
137
+ IsForeignKey: false,
138
+ IsExternalField: false,
139
+ IsHiddenField: true,
140
+ FieldCategoryId: 0,
141
+ IsUnique: false,
142
+ ReferenceType: "ManyToOne",
143
+ Transformation: null,
144
+ IsRequired: false,
145
+ IsEncrypted: false,
146
+ Description: "",
147
+ IsSystemField: true,
148
+ FieldDisplayType: "Basic",
149
+ IsAttachment: false,
150
+ IsRbacEnabled: false,
151
+ IsModelReserved: false,
152
+ Name: fieldName,
153
+ DisplayName: fieldName,
154
+ SqlType: { Name: sqlType },
155
+ ...over,
156
+ });
157
+ const entity = {
158
+ Id: "8673235c-6cb4-4536-9ff7-f19e4337147f",
159
+ Name: name,
160
+ DisplayName: name,
161
+ EntityTypeId: 0,
162
+ EntityType: "Entity",
163
+ Description: "",
164
+ FolderId: "99999999-9999-9999-9999-999999999999",
165
+ Fields: [
166
+ systemField("Id", "UNIQUEIDENTIFIER", { IsPrimaryKey: true }),
167
+ systemField("CreateTime", "DATETIMEOFFSET"),
168
+ systemField("CreatedBy", "UNIQUEIDENTIFIER", {
169
+ FieldDisplayType: "Relationship",
170
+ }),
171
+ systemField("UpdateTime", "DATETIMEOFFSET"),
172
+ systemField("UpdatedBy", "UNIQUEIDENTIFIER", {
173
+ FieldDisplayType: "Relationship",
174
+ }),
175
+ ],
176
+ Data: null,
177
+ ExternalFields: null,
178
+ SourceJoinCriterias: null,
179
+ RecordCount: 0,
180
+ StorageSizeInMB: null,
181
+ UsedStorageSizeInMB: null,
182
+ AttachmentSizeInByte: null,
183
+ IsRbacEnabled: false,
184
+ InvalidIdentifiers: [],
185
+ IsModelReserved: false,
186
+ CategoryId: null,
187
+ };
188
+ return {
189
+ docVersion: "1.0.0",
190
+ resource: {
191
+ name,
192
+ kind: "entity",
193
+ type: "native",
194
+ apiVersion: "dataservice.uipath.com/v2",
195
+ isOverridable: true,
196
+ dependencies: [],
197
+ runtimeDependencies: [],
198
+ folders: [{ fullyQualifiedName: "solution_folder" }],
199
+ spec: {
200
+ resourceJson: JSON.stringify(entity),
201
+ name,
202
+ displayName: name,
203
+ description: "",
204
+ },
205
+ locks: [],
206
+ key: entity.Id,
207
+ files: [],
208
+ },
209
+ };
210
+ }
211
+
212
+ /** Pack a seeded solution and return the parsed envelope plus exit code. */
213
+ function packSolution(
214
+ root: string,
215
+ solutionDir: string,
216
+ ): { exitCode: number; envelope: PackEnvelope; output: string } {
217
+ const output = join(root, "out");
218
+ const { exitCode, stdout } = localCliRawWithArgs(
219
+ installDir,
220
+ ["solution", "pack", solutionDir, output],
221
+ undefined,
222
+ { timeout: PACK_TIMEOUT },
223
+ );
224
+ return {
225
+ exitCode,
226
+ envelope: extractLastJson(stdout) as PackEnvelope,
227
+ output,
228
+ };
229
+ }
230
+
231
+ /** Every failure case asserts the same envelope shape; only the message differs.
232
+ * The tool's own ENTITY_VALIDATION_FAILED code does not reach the CLI — pack
233
+ * reports INTERNAL_ERROR and carries the diagnostic in Message. */
234
+ function expectPackFailure(
235
+ result: { exitCode: number; envelope: PackEnvelope },
236
+ ...messageFragments: string[]
237
+ ): void {
238
+ expect(result.exitCode).not.toBe(0);
239
+ expect(result.envelope.Result).toBe("Failure");
240
+ expect(result.envelope.Message).toContain("Entity validation failed");
241
+ for (const fragment of messageFragments) {
242
+ expect(result.envelope.Message).toContain(fragment);
243
+ }
244
+ }
245
+
246
+ describe("entity project packaging e2e", () => {
247
+ it(
248
+ "S1: pack a solution whose only project is an Entity project",
249
+ async () => {
250
+ const root = join(installDir, "entity-pack-only");
251
+ createDir(root);
252
+ const solutionDir = seedEntitySolution(root);
253
+ const output = join(root, "out");
254
+
255
+ const out = localCliWithArgs(
256
+ installDir,
257
+ ["solution", "pack", solutionDir, output],
258
+ undefined,
259
+ { timeout: PACK_TIMEOUT },
260
+ );
261
+ const result = extractLastJson(out) as PackEnvelope;
262
+ expect(result.Result).toBe("Success");
263
+ expect(result.Code).toBe("SolutionPack");
264
+
265
+ // The entity definition IS the deliverable: it ships in the zip, and
266
+ // because nothing was compiled there is no .nupkg and no folder for
267
+ // the Entity project.
268
+ const entries = zipEntries(output);
269
+ expect(entries).toContain(
270
+ "resources/solution_folder/entity/native/PurchaseOrder.json",
271
+ );
272
+ expect(entries.filter((e) => e.endsWith(".nupkg"))).toEqual([]);
273
+ expect(entries.some((e) => e.startsWith("MasterData/"))).toBe(
274
+ false,
275
+ );
276
+ },
277
+ PACK_TIMEOUT,
278
+ );
279
+
280
+ it(
281
+ "S2: check the same solution without producing a package",
282
+ async () => {
283
+ const root = join(installDir, "entity-validate");
284
+ createDir(root);
285
+ const solutionDir = seedEntitySolution(root);
286
+
287
+ // There is no `solution validate` command: `pack --dry-run` runs the
288
+ // same checks and produces nothing.
289
+ const out = localCliWithArgs(
290
+ installDir,
291
+ ["solution", "pack", solutionDir, "--dry-run"],
292
+ undefined,
293
+ { timeout: PACK_TIMEOUT },
294
+ );
295
+
296
+ expect((extractLastJson(out) as PackEnvelope).Result).toBe(
297
+ "Success",
298
+ );
299
+ },
300
+ PACK_TIMEOUT,
301
+ );
302
+
303
+ it(
304
+ "S3: pack a mixed solution (Entity alongside a package-producing project)",
305
+ async () => {
306
+ const root = join(installDir, "entity-pack-mixed");
307
+ createDir(root);
308
+ const solutionDir = seedEntitySolution(root, {
309
+ withApiProject: true,
310
+ });
311
+ const output = join(root, "out");
312
+
313
+ const out = localCliWithArgs(
314
+ installDir,
315
+ ["solution", "pack", solutionDir, output],
316
+ undefined,
317
+ { timeout: PACK_TIMEOUT },
318
+ );
319
+ const result = extractLastJson(out) as PackEnvelope;
320
+
321
+ // Two projects, one package. The Api project contributes a .nupkg
322
+ // under files/<projectId>/; the Entity project contributes its
323
+ // definition resource instead, and that asymmetry is not an error.
324
+ expect(result.Result).toBe("Success");
325
+ expect(result.Code).toBe("SolutionPack");
326
+ const entries = zipEntries(output);
327
+ expect(entries.filter((e) => e.endsWith(".nupkg"))).toHaveLength(1);
328
+ expect(entries).toContain(
329
+ "resources/solution_folder/entity/native/PurchaseOrder.json",
330
+ );
331
+ },
332
+ PACK_TIMEOUT,
333
+ );
334
+
335
+ it(
336
+ "S4: a `.entity` whose resource file is missing fails the pack",
337
+ async () => {
338
+ const root = join(installDir, "entity-pack-missing");
339
+ createDir(root);
340
+ const solutionDir = seedEntitySolution(root);
341
+ rmSync(
342
+ join(
343
+ solutionDir,
344
+ "resources/solution_folder/entity/native/PurchaseOrder.json",
345
+ ),
346
+ );
347
+
348
+ const { exitCode, stdout } = localCliRawWithArgs(
349
+ installDir,
350
+ ["solution", "pack", solutionDir, join(root, "out")],
351
+ undefined,
352
+ { timeout: PACK_TIMEOUT },
353
+ );
354
+
355
+ // The tool's own ENTITY_VALIDATION_FAILED code does not reach the
356
+ // CLI envelope — pack reports INTERNAL_ERROR and carries the
357
+ // diagnostic in Message, so assert on what the user actually sees.
358
+ expect(exitCode).not.toBe(0);
359
+ const failure = extractLastJson(stdout) as PackEnvelope;
360
+ expect(failure.Result).toBe("Failure");
361
+ expect(failure.Message).toContain("Entity validation failed");
362
+ expect(failure.Message).toContain(
363
+ "resources/solution_folder/entity/native/PurchaseOrder.json",
364
+ );
365
+ },
366
+ PACK_TIMEOUT,
367
+ );
368
+
369
+ it(
370
+ "S5: a `.entity` whose filename does not match the entity name fails the pack",
371
+ async () => {
372
+ const root = join(installDir, "entity-name-mismatch");
373
+ createDir(root);
374
+ const solutionDir = seedEntitySolution(root);
375
+ // Rename the stub only: its `name` still says Order.
376
+ cpSync(
377
+ join(solutionDir, "MasterData", "PurchaseOrder.entity"),
378
+ join(solutionDir, "MasterData", "Renamed.entity"),
379
+ );
380
+ rmSync(join(solutionDir, "MasterData", "PurchaseOrder.entity"));
381
+
382
+ expectPackFailure(packSolution(root, solutionDir), "Renamed");
383
+ },
384
+ PACK_TIMEOUT,
385
+ );
386
+
387
+ it(
388
+ "S6: a `resourcePath` pointing outside the solution fails the pack",
389
+ async () => {
390
+ const root = join(installDir, "entity-escapes");
391
+ createDir(root);
392
+ const solutionDir = seedEntitySolution(root);
393
+ writeFileSync(
394
+ join(solutionDir, "MasterData", "PurchaseOrder.entity"),
395
+ `${JSON.stringify({ name: "PurchaseOrder", resourcePath: "../../outside/PurchaseOrder.json" }, null, 2)}\n`,
396
+ );
397
+
398
+ expectPackFailure(
399
+ packSolution(root, solutionDir),
400
+ "outside the solution",
401
+ );
402
+ },
403
+ PACK_TIMEOUT,
404
+ );
405
+
406
+ it(
407
+ "S7: an invalid schema is reported against the resource file, not the stub",
408
+ async () => {
409
+ const root = join(installDir, "entity-bad-schema");
410
+ createDir(root);
411
+ const solutionDir = seedEntitySolution(root);
412
+ const resource = join(
413
+ solutionDir,
414
+ "resources/solution_folder/entity/native/PurchaseOrder.json",
415
+ );
416
+ const parsed = JSON.parse(readFileSync(resource, "utf8"));
417
+ const entity = JSON.parse(parsed.resource.spec.resourceJson);
418
+ // A custom field with a type combination the modeller cannot author.
419
+ entity.Fields.push({
420
+ Name: "Bad",
421
+ DisplayName: "Bad",
422
+ SqlType: { Name: "UNKNOWN" },
423
+ FieldDisplayType: "Basic",
424
+ IsRequired: false,
425
+ IsUnique: false,
426
+ IsPrimaryKey: false,
427
+ IsForeignKey: false,
428
+ IsSystemField: false,
429
+ IsExternalField: false,
430
+ IsHiddenField: false,
431
+ FieldCategoryId: 0,
432
+ ReferenceType: "ManyToOne",
433
+ IsEncrypted: false,
434
+ Description: "",
435
+ IsAttachment: false,
436
+ IsRbacEnabled: false,
437
+ IsModelReserved: false,
438
+ });
439
+ parsed.resource.spec.resourceJson = JSON.stringify(entity);
440
+ writeFileSync(resource, `${JSON.stringify(parsed, null, 2)}\n`);
441
+
442
+ expectPackFailure(packSolution(root, solutionDir), "Bad");
443
+ },
444
+ PACK_TIMEOUT,
445
+ );
446
+
447
+ it(
448
+ "S8: the same entity name in two Entity projects fails the pack",
449
+ async () => {
450
+ const root = join(installDir, "entity-dup-name");
451
+ createDir(root);
452
+ const solutionDir = seedEntitySolution(root);
453
+ // A second Entity project declaring the same entity name.
454
+ const second = join(solutionDir, "MoreData");
455
+ createDir(second);
456
+ writeFileSync(
457
+ join(second, "project.uiproj"),
458
+ `${JSON.stringify({ Name: "MoreData", ProjectType: "Entity" }, null, 2)}\n`,
459
+ );
460
+ cpSync(
461
+ join(solutionDir, "MasterData", "PurchaseOrder.entity"),
462
+ join(second, "PurchaseOrder.entity"),
463
+ );
464
+ const uipx = join(solutionDir, "EntitySolution.uipx");
465
+ const manifest = JSON.parse(readFileSync(uipx, "utf8"));
466
+ manifest.Projects.push({
467
+ Id: "33333333-3333-3333-3333-333333333333",
468
+ Type: "Entity",
469
+ ProjectRelativePath: "MoreData/project.uiproj",
470
+ });
471
+ writeFileSync(uipx, `${JSON.stringify(manifest, null, 2)}\n`);
472
+
473
+ expectPackFailure(packSolution(root, solutionDir), "PurchaseOrder");
474
+ },
475
+ PACK_TIMEOUT,
476
+ );
477
+
478
+ it(
479
+ "S9: a misplaced `.flow` inside an Entity project fails with move guidance",
480
+ async () => {
481
+ const root = join(installDir, "entity-misplaced-flow");
482
+ createDir(root);
483
+ const solutionDir = seedEntitySolution(root);
484
+ writeFileSync(
485
+ join(solutionDir, "MasterData", "Stray.flow"),
486
+ "{}\n",
487
+ );
488
+
489
+ expectPackFailure(
490
+ packSolution(root, solutionDir),
491
+ "Stray.flow",
492
+ "Flow project",
493
+ );
494
+ },
495
+ PACK_TIMEOUT,
496
+ );
497
+
498
+ it(
499
+ "S10: an Entity project with no entities packs successfully",
500
+ async () => {
501
+ const root = join(installDir, "entity-empty");
502
+ createDir(root);
503
+ // Keep the Api project: a solution whose every resource is removed
504
+ // fails earlier, on an empty solution definition, which is not what
505
+ // this scenario is about.
506
+ const solutionDir = seedEntitySolution(root, {
507
+ withApiProject: true,
508
+ });
509
+ // Remove the only entity: the project itself stays registered.
510
+ rmSync(join(solutionDir, "MasterData", "PurchaseOrder.entity"));
511
+ rmSync(
512
+ join(
513
+ solutionDir,
514
+ "resources/solution_folder/entity/native/PurchaseOrder.json",
515
+ ),
516
+ );
517
+
518
+ const result = packSolution(root, solutionDir);
519
+ expect(result.exitCode).toBe(0);
520
+ expect(result.envelope.Result).toBe("Success");
521
+ },
522
+ PACK_TIMEOUT,
523
+ );
524
+
525
+ it(
526
+ "S11: every pack diagnostic is reported, not just the first",
527
+ async () => {
528
+ const root = join(installDir, "entity-two-issues");
529
+ createDir(root);
530
+ const solutionDir = seedEntitySolution(root);
531
+ // Two independent entity problems: a stub whose filename no longer
532
+ // matches its entity name, and a stray Flow main file.
533
+ cpSync(
534
+ join(solutionDir, "MasterData", "PurchaseOrder.entity"),
535
+ join(solutionDir, "MasterData", "Renamed.entity"),
536
+ );
537
+ rmSync(join(solutionDir, "MasterData", "PurchaseOrder.entity"));
538
+ writeFileSync(
539
+ join(solutionDir, "MasterData", "Stray.flow"),
540
+ "{}\n",
541
+ );
542
+
543
+ const result = packSolution(root, solutionDir);
544
+ expectPackFailure(result);
545
+ expect(result.envelope.Message).toContain("2 issue(s)");
546
+ },
547
+ PACK_TIMEOUT,
548
+ );
549
+ });
@@ -18,6 +18,7 @@ import {
18
18
  readManifest,
19
19
  SETUP_TIMEOUT,
20
20
  } from "../../../tests/e2e-shared/helpers";
21
+ import { e2eResourceName } from "../../../tests/e2e-shared/tenant-cleanup";
21
22
 
22
23
  const manifest = readManifest<E2EManifest>(MANIFEST_PATH);
23
24
  const { tempDir } = manifest.sharedInstall;
@@ -124,7 +125,7 @@ let folderScopedRecordId: string | undefined;
124
125
  const RUN_ID = `${process.pid}_${Date.now()}`;
125
126
  const scratchEntityName = `E2eDfFiles${RUN_ID}`;
126
127
  const folderScopedEntityName = `E2eDfFilesFolder${RUN_ID}`;
127
- const scratchFolderName = `e2e-df-files-folder-${RUN_ID}`;
128
+ const scratchFolderName = e2eResourceName("e2e-df-files-folder");
128
129
  const uploadPath = join(SCRATCH_DIR, "sample.bin");
129
130
  const UPLOAD_BYTES = Buffer.from("data-fabric e2e sample", "utf-8");
130
131
 
@@ -1,99 +0,0 @@
1
- import {
2
- getGlobalThis
3
- } from "./tool-9qecd4wb.js";
4
- import {
5
- AUTH_CANCELLED_ERROR_CODE
6
- } from "./tool-5arsyj36.js";
7
- import"./tool-0v6na3yp.js";
8
-
9
- // ../auth/src/strategies/browser-strategy.ts
10
- class BrowserAuthStrategy {
11
- async execute(url, _redirectUri, expectedState, opts) {
12
- const global = getGlobalThis();
13
- if (!global?.window) {
14
- throw new Error("Browser environment required for authentication");
15
- }
16
- const screenWidth = global.window.screen?.width ?? 1024;
17
- const screenHeight = global.window.screen?.height ?? 768;
18
- const width = 600;
19
- const height = 700;
20
- const left = screenWidth / 2 - width / 2;
21
- const top = screenHeight / 2 - height / 2;
22
- if (!global.window.open) {
23
- throw new Error("window.open is not available");
24
- }
25
- const popupResult = global.window.open(url, "uip_auth", `width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes,status=yes`);
26
- const popup = popupResult;
27
- if (!popup) {
28
- throw new Error(`Authentication popup was blocked by your browser.
29
-
30
- ` + `To continue:
31
- ` + `1. Look for a popup blocker icon in your address bar
32
- ` + `2. Allow popups for this site
33
- ` + `3. Try logging in again
34
-
35
- ` + "If using an ad blocker, you may need to temporarily disable it.");
36
- }
37
- return new Promise((resolve, reject) => {
38
- let timer;
39
- const messageHandler = (event) => {
40
- if (event.data?.type === "UIP_AUTH_CODE" && event.data.code) {
41
- if (event.data.state !== expectedState) {
42
- cleanup();
43
- reject(new Error("OAuth state mismatch — the callback state does not match the expected value. " + "This may indicate a CSRF attack. Please try signing in again."));
44
- popup.close();
45
- return;
46
- }
47
- cleanup();
48
- resolve(event.data.code);
49
- popup.close();
50
- } else if (event.data?.type === "UIP_AUTH_ERROR") {
51
- cleanup();
52
- const errorMsg = event.data.error || "Authentication failed";
53
- reject(new Error(`Authentication failed: ${errorMsg}
54
-
55
- ` + "Please check your credentials and try again. " + "If the problem persists, verify your UiPath account is active."));
56
- popup.close();
57
- }
58
- };
59
- const cleanup = () => {
60
- global.window?.removeEventListener?.("message", messageHandler);
61
- opts?.signal?.removeEventListener("abort", onAbort);
62
- if (timer)
63
- clearInterval(timer);
64
- };
65
- const onAbort = () => {
66
- cleanup();
67
- const err = new Error(`Authentication was cancelled.
68
-
69
- ` + "The sign-in was cancelled before completing the login process. " + "Please try again and complete the authentication flow.");
70
- err.code = AUTH_CANCELLED_ERROR_CODE;
71
- reject(err);
72
- popup.close();
73
- };
74
- if (opts?.signal) {
75
- if (opts.signal.aborted) {
76
- onAbort();
77
- return;
78
- }
79
- opts.signal.addEventListener("abort", onAbort, { once: true });
80
- }
81
- if (global.window?.addEventListener) {
82
- global.window.addEventListener("message", messageHandler);
83
- }
84
- timer = setInterval(() => {
85
- if (popup.closed) {
86
- cleanup();
87
- reject(new Error(`Authentication was cancelled.
88
-
89
- ` + "The authentication popup was closed before completing the login process. " + "Please try again and complete the authentication flow."));
90
- }
91
- }, 1000);
92
- });
93
- }
94
- }
95
- export {
96
- BrowserAuthStrategy
97
- };
98
-
99
- //# debugId=B13A3005E9EE6C6564756E2164756E21