@uipath/common 1.199.0 → 1.201.0-preview.115

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.
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Lazy loaders for the two output codecs that only some invocations need.
3
+ *
4
+ * `formatter.ts` is imported by every command in every tool, so anything it
5
+ * imports statically is parsed on every `uip` invocation — including
6
+ * `uip <tool> -h`. `js-yaml` (101 KB) is only reached by `--output yaml` and
7
+ * `@jmespath-community/jmespath` (68 KB) only by `--output-filter`, so both
8
+ * live behind `await import` here instead.
9
+ *
10
+ * The API is split in two on purpose:
11
+ *
12
+ * - `loadOutputCodecsAsync` is awaited from the async paths that already know
13
+ * what the user asked for — the CLI host right after it resolves `--output`
14
+ * and `--output-filter`, and `trackedAction` before it runs a handler.
15
+ * - `getYamlCodec` / `getJmespathCodec` are the synchronous accessors
16
+ * `OutputFormatter` uses, because the formatter API is synchronous.
17
+ *
18
+ * Loaded modules live in cross-bundle singleton slots: each tool bundles its
19
+ * own copy of `@uipath/common`, so a module-level variable would be loaded by
20
+ * the host and then missing in the tool. See `singleton.ts`.
21
+ */
22
+ /** The slice of `js-yaml` the formatter uses. */
23
+ export interface YamlCodec {
24
+ dump: (data: unknown) => string;
25
+ }
26
+ /** The slice of `@jmespath-community/jmespath` the formatter uses. */
27
+ export interface JmespathCodec {
28
+ compile: (expression: string) => unknown;
29
+ search: (data: never, expression: string) => unknown;
30
+ }
31
+ /** Which codecs an invocation needs, derived from the resolved CLI options. */
32
+ export interface OutputCodecsNeeded {
33
+ /** True when the resolved output format is `yaml`. */
34
+ yaml?: boolean;
35
+ /** True when an `--output-filter` expression is present. */
36
+ filter?: boolean;
37
+ }
38
+ /**
39
+ * Load the codecs this invocation needs, if they are not loaded already.
40
+ *
41
+ * Safe to call repeatedly — a codec already in its slot is not re-imported.
42
+ * Call before any `OutputFormatter` output that could use them.
43
+ */
44
+ export declare function loadOutputCodecsAsync(needed: OutputCodecsNeeded): Promise<void>;
45
+ /**
46
+ * The loaded YAML codec, or `undefined` when nothing preloaded it.
47
+ *
48
+ * `undefined` means a code path produced `--output yaml` output without
49
+ * passing through the CLI host or `trackedAction` — a bug in that path, not a
50
+ * user error, so callers should throw rather than silently emit JSON.
51
+ */
52
+ export declare function getYamlCodec(): YamlCodec | undefined;
53
+ /** The loaded JMESPath codec, or `undefined` when nothing preloaded it. */
54
+ export declare function getJmespathCodec(): JmespathCodec | undefined;
55
+ /** Test seam — drops both codecs so a spec can assert the unloaded path. */
56
+ export declare function resetOutputCodecs(): void;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Import a tool's `packager-tool` entry point and run its registration.
3
+ *
4
+ * Its own module so tests can stand in for it. The real entry points are
5
+ * multi-megabyte tool bundles; loading one takes seconds and blocks the event
6
+ * loop while it evaluates, which is far too slow for a unit test.
7
+ */
8
+ /** Named export every in-repo `packager-tool` entry point must provide. */
9
+ export declare const REGISTER_EXPORT = "registerPackagerFactories";
10
+ /** Shape of a `packager-tool` entry point's module namespace. */
11
+ export interface PackagerToolModule {
12
+ [REGISTER_EXPORT]?: () => void;
13
+ }
14
+ /**
15
+ * Import `specifier` and call its `registerPackagerFactories` export. Returns
16
+ * the failure instead of throwing so the caller can decide what to say.
17
+ *
18
+ * Registration is a call, not an import side effect, so a run that reaches
19
+ * the same factories through two tool bundles registers them once — from the
20
+ * one caller that is about to pack.
21
+ *
22
+ * Tools published before that change register at import and ship no export.
23
+ * They still work: the import above already registered them, so treat a
24
+ * missing export as a legacy entry point instead of a failure. Tools that live
25
+ * in this repo must export it — `scripts/lint-packager-tool-exports.ts` fails
26
+ * the build if one doesn't.
27
+ */
28
+ export declare function importPackagerTool(specifier: string): Promise<Error | undefined>;
@@ -20,7 +20,7 @@
20
20
  * isTerminalStatus("FAULTED") // true
21
21
  * ```
22
22
  */
23
- export declare function isTerminalStatus(status: string): boolean;
23
+ export declare function isTerminalStatus(status: string | null | undefined): boolean;
24
24
  /**
25
25
  * Check if a status string represents a failure state (case-insensitive).
26
26
  *
@@ -34,7 +34,7 @@ export declare function isTerminalStatus(status: string): boolean;
34
34
  * isFailureStatus("Cancelled") // true
35
35
  * ```
36
36
  */
37
- export declare function isFailureStatus(status: string): boolean;
37
+ export declare function isFailureStatus(status: string | null | undefined): boolean;
38
38
  /**
39
39
  * Check if a status string represents a successful terminal state (case-insensitive).
40
40
  *
@@ -47,4 +47,4 @@ export declare function isFailureStatus(status: string): boolean;
47
47
  * isSuccessStatus("Running") // false
48
48
  * ```
49
49
  */
50
- export declare function isSuccessStatus(status: string): boolean;
50
+ export declare function isSuccessStatus(status: string | null | undefined): boolean;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Shared `ensureProjectArtifacts` used by every `*-tool init` path (agent,
3
+ * case, codedapp, flow, maestro). Lives here so the five tools don't each
4
+ * carry a copy; each tool re-exports it from its own
5
+ * `src/services/project-artifacts.ts` shim (the browser-build
6
+ * `excludedImports` stub mechanism resolves only relative paths under each
7
+ * tool's own src tree).
8
+ */
9
+ /** Options forwarded to solution-tool's `addProjectArtifactsToSolutionAsync`. */
10
+ export interface EnsureProjectArtifactsArgs {
11
+ /** Absolute path to the solution directory (containing the `.uipx`). */
12
+ solutionDir: string;
13
+ /** Stable project key — must match the `Id` in `.uipx` `Projects[]`. */
14
+ projectId: string;
15
+ /** Display name for the project; typically the project folder name. */
16
+ projectName: string;
17
+ /** Project type as written to `project.uiproj` (e.g. `Flow`, `Agent`). */
18
+ projectType: string;
19
+ /** Optional SDK subType (AppV2: `"Coded"` / `"CodedAction"`). */
20
+ projectSubType?: string;
21
+ }
22
+ /**
23
+ * Result envelope. Structurally identical to `ProjectArtifactsResult` in
24
+ * `@uipath/solution-sdk/resources` — declared here too because this
25
+ * package sits below `solution-sdk` in the dependency graph and cannot import
26
+ * from it.
27
+ */
28
+ export interface ProjectArtifactsResult {
29
+ /** True when artifact resources were generated. */
30
+ Created: boolean;
31
+ /** Error message when `Created` is `false`. */
32
+ Error?: string;
33
+ }
34
+ /**
35
+ * Generate the `resources/solution_folder/...` artifact-resource entries for
36
+ * a project that has just been registered in its parent solution's `.uipx`.
37
+ *
38
+ * The implementation is resolved at runtime from the installed
39
+ * `@uipath/solution-tool` (through the CLI host's tool-module provider, which
40
+ * installs it on demand), so the multi-megabyte resource-builder chain is
41
+ * never bundled into the calling tool.
42
+ */
43
+ export declare function ensureProjectArtifacts(args: EnsureProjectArtifactsArgs): Promise<ProjectArtifactsResult>;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Guidance for a project type a solution cannot contain, or `null` when allowed.
3
+ * Lives in `@uipath/common` so `solution-tool`'s packager resolver can ask
4
+ * without importing the `@uipath/solution-sdk` barrel (which drags
5
+ * `@uipath/studioweb-sdk` in).
6
+ *
7
+ * A library registered as a project does not fail late, it deploys *wrong*: the
8
+ * resource builder has no library template, falls through to the default, and
9
+ * mints `kind: process`. Deploy then creates an Orchestrator process backed by a
10
+ * library package, which has no entry point. The SDK metadata agrees a library
11
+ * is not project-shaped: `kind: library` is `scope: Tenant`,
12
+ * `supportsInLineCreation: false`.
13
+ *
14
+ * Case-insensitive — `.uipx` writes PascalCase `Type`, `project.json` uses
15
+ * `designOptions.outputType`.
16
+ *
17
+ * Takes `unknown` because one caller (`ensurePackagerTools`) reads `Type`
18
+ * straight out of `.uipx` JSON, where it can be absent or not a string. Only a
19
+ * type positively known to be unsupported is rejected, so anything else is
20
+ * allowed through to the resolvers, which warn on their own.
21
+ */
22
+ export declare function unsupportedSolutionProjectType(projectType: unknown): string | null;
@@ -86,7 +86,7 @@ var COMMAND_ATTRIBUTION = commandAttribution([
86
86
  ["agents", "build", ["uip.codedagent", "uip.agent"]],
87
87
  ["agenthub", "build", ["uip.agenthub"]],
88
88
  ["coded-apps", "build", ["uip.codedapp"]],
89
- ["functions", "build", ["uip.functions"]],
89
+ ["functions", "build", ["uip.function", "uip.functions"]],
90
90
  ["solution", "build", ["uip.solution"]],
91
91
  ["maestro", "build", ["uip.maestro", "uip.case", "uip.flow"]],
92
92
  ["llm-observability", "troubleshoot", ["uip.traces"]],
@@ -762,14 +762,11 @@ class TelemetryService {
762
762
  }
763
763
  async trackDependencyOperation(name, type, fn, properties) {
764
764
  const parentContext = this.getCurrentContext();
765
- if (!parentContext) {
766
- throw new Error("trackDependencyOperation must be called within a trackRequest block.");
767
- }
768
- const childContext = {
765
+ const childContext = parentContext !== undefined ? {
769
766
  operationId: parentContext.operationId,
770
767
  parentId: parentContext.id,
771
768
  id: this.generateId()
772
- };
769
+ } : this.createRequestContext();
773
770
  const startTime = performance.now();
774
771
  try {
775
772
  const result = await this.contextStorage.run(childContext, fn);
@@ -845,4 +842,4 @@ export {
845
842
  BrowserContextStorage
846
843
  };
847
844
 
848
- //# debugId=F57500BAC82BA8E664756E2164756E21
845
+ //# debugId=E05A0A007C0249BF64756E2164756E21
@@ -1,6 +1,17 @@
1
1
  import type { ITelemetryProvider } from "./telemetry-provider.js";
2
2
  import { type TelemetryProperties } from "./telemetry-service.js";
3
3
  export { getGlobalTelemetryProperties, setGlobalTelemetryProperties, } from "./global-telemetry-properties.js";
4
+ /**
5
+ * Envelopes still buffered in the SDK channel at exit, plus the ingestion
6
+ * endpoint they were headed to. The envelopes are fully formed (tags, ikey,
7
+ * time already baked in) — POSTing them newline-joined and gzipped to
8
+ * `endpointUrl` with `Content-Type: application/x-json-stream` is exactly
9
+ * what the SDK's own sender would have done.
10
+ */
11
+ export interface PendingTelemetryEnvelopes {
12
+ endpointUrl: string;
13
+ envelopes: unknown[];
14
+ }
4
15
  /**
5
16
  * Node.js Application Insights telemetry provider.
6
17
  * Uses the `applicationinsights` Node SDK (not the browser SDK).
@@ -67,6 +78,15 @@ export declare class NodeAppInsightsTelemetryProvider implements ITelemetryProvi
67
78
  trackRequest(name: string, duration: number, success: boolean, properties?: TelemetryProperties): Promise<void>;
68
79
  trackDependency(name: string, type: string, duration: number, success: boolean, properties?: TelemetryProperties, resultCode?: string): Promise<void>;
69
80
  flush(): Promise<void>;
81
+ /**
82
+ * Take the envelopes still buffered in the SDK channel (nothing has sent
83
+ * them yet), clearing the batch timer and the buffer so a later
84
+ * {@link shutdown} has nothing left to send or hold the event loop open
85
+ * with. Returns `undefined` when draining isn't possible (no client, no
86
+ * endpoint, or an unexpected SDK shape) — callers must then fall back to
87
+ * a normal in-process {@link flush}.
88
+ */
89
+ drainPendingEnvelopes(): PendingTelemetryEnvelopes | undefined;
70
90
  /**
71
91
  * Dispose the Application Insights SDK so its internal channels,
72
92
  * keep-alive sockets, and timers are closed — allowing the Node.js
@@ -0,0 +1,2 @@
1
+ export declare function setProxyAuthHttpsAgent(agent: unknown): void;
2
+ export declare function getProxyAuthHttpsAgent(): unknown;
@@ -1,4 +1,14 @@
1
+ /**
2
+ * Canonical CLI event names.
3
+ *
4
+ * Every name lives under the `uip.*` namespace so a single
5
+ * `name startswith "uip."` filter selects all CLI telemetry — a snake_case
6
+ * name outside it is invisible to every downstream pipeline (STUD-80942).
7
+ */
1
8
  export declare const CommonTelemetryEvents: {
2
9
  readonly Error: "uip.error";
3
- readonly ShipSucceeded: "ship_succeeded";
10
+ /** A ship (publish/deploy/upload) completed. The command that shipped is
11
+ * carried by the `command_name` dimension; `ship_kind`/`target` describe
12
+ * what was shipped where. */
13
+ readonly ShipSucceeded: "uip.ship.succeeded";
4
14
  };
@@ -41,8 +41,23 @@ export interface TelemetryInitOptions {
41
41
  */
42
42
  export declare function telemetryInit(options?: TelemetryInitOptions): Promise<void>;
43
43
  /**
44
- * Flush all buffered telemetry to the cloud.
45
- * Must be awaited before the process exits to ensure delivery.
46
- * Capped at FLUSH_SHUTDOWN_TIMEOUT_MS to avoid hanging on slow/unreachable endpoints.
44
+ * Deliver all buffered telemetry before the process exits.
45
+ * Must be awaited on every exit path.
46
+ *
47
+ * Normally hands the buffered envelopes to a detached sidecar process (see
48
+ * {@link trySidecarHandoff}) so the exit is instant. Falls back to the
49
+ * in-process flush — one ingestion round-trip, capped at
50
+ * FLUSH_SHUTDOWN_TIMEOUT_MS — when the sidecar handoff isn't available or
51
+ * UIPATH_TELEMETRY_SYNC_FLUSH=1 forces it.
47
52
  */
48
53
  export declare function telemetryFlushAndShutdown(): Promise<void>;
54
+ /**
55
+ * Dispose the telemetry SDK without sending — buffered events are dropped
56
+ * on purpose. For exits where delivery is not worth a network round-trip
57
+ * (help/version display).
58
+ *
59
+ * Shares the memo slot with {@link telemetryFlushAndShutdown}: whichever
60
+ * runs first wins, so a later flush call on the same exit path awaits the
61
+ * already-finished shutdown instead of opening a network connection.
62
+ */
63
+ export declare function telemetryShutdownWithoutFlush(): Promise<void>;
@@ -193,6 +193,11 @@ export interface ITelemetryService {
193
193
  * @remarks
194
194
  * Tracks this operation as a dependency in Application Insights, automatically correlated
195
195
  * to the parent request using the context from IContextStorage.
196
+ *
197
+ * With no enclosing request the dependency is emitted as a trace root (no
198
+ * `operation_ParentId`) rather than being dropped or throwing — a reusable
199
+ * unit of work stays a dependency even when the host that called it never
200
+ * opened a request of ours.
196
201
  */
197
202
  trackDependencyOperation<T>(name: string, type: string, fn: () => Promise<T>, properties?: TelemetryProperties): Promise<T>;
198
203
  }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Hidden argv verb that makes the CLI entry point run the spool sender
3
+ * instead of the normal Commander pipeline. Never registered as a command —
4
+ * the entry point matches it on raw argv before the program is built.
5
+ */
6
+ export declare const TELEMETRY_DRAIN_ARGV = "__uip-drain-telemetry";
7
+ /**
8
+ * Register the script path that handles {@link TELEMETRY_DRAIN_ARGV}.
9
+ * Called once by the CLI entry point at startup; until it is called, the
10
+ * exit path keeps the in-process flush (no sidecar is ever spawned).
11
+ */
12
+ export declare function setTelemetrySidecarEntry(entryPath: string): void;
13
+ export declare function getTelemetrySidecarEntry(): string | undefined;
14
+ /** Contents of one spool file. */
15
+ export interface TelemetrySpoolPayload {
16
+ /** Full ingestion URL (`<IngestionEndpoint>/v2.1/track`). */
17
+ endpointUrl: string;
18
+ /** Fully-formed App Insights envelopes, exactly as the SDK buffered them. */
19
+ envelopes: unknown[];
20
+ }
21
+ /** A pending spool file claimed for sending (renamed to `.sending`). */
22
+ export interface ClaimedSpoolFile {
23
+ /** The claimed (`.sending`) path — delete it after a successful send. */
24
+ claimedPath: string;
25
+ payload: TelemetrySpoolPayload;
26
+ }
27
+ /** Spool files older than this are deleted unsent — stale telemetry has no value. */
28
+ export declare const MAX_SPOOL_AGE_MS: number;
29
+ /** Hard cap on spool files; oldest beyond this are deleted (offline machines). */
30
+ export declare const MAX_SPOOL_FILES = 50;
31
+ export declare function getTelemetrySpoolDir(): string;
32
+ /**
33
+ * Persist pending envelopes for the sidecar. Writes to a `.tmp` name first
34
+ * and renames into place so a concurrently-running sender never claims a
35
+ * half-written file. Returns the spool file path.
36
+ */
37
+ export declare function writeTelemetrySpoolFile(payload: TelemetrySpoolPayload): Promise<string>;
38
+ /**
39
+ * Claim every pending spool file for sending. Claiming renames the file to
40
+ * `.sending` — an atomic operation, so when two senders sweep concurrently
41
+ * only one wins each file and nothing is delivered twice. Files that fail
42
+ * the rename are skipped (another sender owns them).
43
+ *
44
+ * Bad content is split two ways on purpose: a file that cannot be READ is
45
+ * released for a later attempt (on Windows a concurrent handle shows up as a
46
+ * transient EBUSY, and deleting there would throw telemetry away for a problem
47
+ * that resolves itself), while a file that reads fine but does not parse or
48
+ * does not match the payload shape is deleted — no future sweep can make it
49
+ * valid, so keeping it would just burn a claim on every run until the age cap.
50
+ */
51
+ export declare function claimPendingSpoolFiles(): Promise<ClaimedSpoolFile[]>;
52
+ /**
53
+ * Return a claimed file to the pending pool so a future sender retries it.
54
+ * Best-effort: if the rename fails the file stays `.sending` and the age
55
+ * cap eventually removes it.
56
+ */
57
+ export declare function releaseClaimedSpoolFile(claimedPath: string): Promise<void>;
58
+ /** Delete a claimed file after its envelopes were delivered. Best-effort. */
59
+ export declare function discardClaimedSpoolFile(claimedPath: string): Promise<void>;
60
+ /**
61
+ * Enforce the spool bounds: delete any file older than
62
+ * {@link MAX_SPOOL_AGE_MS} — including `.sending` files orphaned by a
63
+ * crashed sender and `.tmp` files orphaned by a crashed writer — and keep at
64
+ * most {@link MAX_SPOOL_FILES} pending files, deleting the oldest beyond
65
+ * that. Run by the sender before claiming, so an unreachable endpoint can't
66
+ * grow the spool without bound.
67
+ */
68
+ export declare function sweepTelemetrySpool(): Promise<void>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Dynamic import of another tool's library entry point (e.g.
3
+ * `@uipath/solution-tool/init`).
4
+ *
5
+ * Its own module so tests can stand in for it, and so the specifier stays a
6
+ * plain variable — bundlers then leave the `import()` to run at runtime
7
+ * instead of inlining the multi-megabyte target bundle into the caller.
8
+ */
9
+ export declare function importToolModule(specifier: string): Promise<unknown>;
@@ -1,6 +1,38 @@
1
1
  /**
2
- * Cross-module bridge for packager factory resolution.
2
+ * Cross-module bridge for packager factory and tool-module resolution.
3
3
  */
4
4
  export type PackagerFactoryProvider = (verb: string) => Promise<void>;
5
5
  export declare function setPackagerFactoryProvider(provider: PackagerFactoryProvider): void;
6
- export declare function ensurePackagerFactory(verb: string): Promise<void>;
6
+ export type ToolModuleProvider = (verb: string, moduleName: string) => Promise<unknown>;
7
+ export declare function setToolModuleProvider(provider: ToolModuleProvider): void;
8
+ /**
9
+ * Resolve another tool's library entry point (its `dist/<module>.js` subpath
10
+ * export) at runtime and return the module namespace.
11
+ *
12
+ * Prefers the registered provider (installed by the CLI — it can install the
13
+ * tool on demand and imports the entry by absolute path). With no provider —
14
+ * a library caller — falls back to importing `<packageName>/<moduleName>`,
15
+ * which resolves when the tool package is installed next to the caller.
16
+ *
17
+ * This is how one tool uses another tool's code without bundling it: the
18
+ * multi-megabyte implementation ships once, in the tool that owns it.
19
+ *
20
+ * @param verb - CLI tool verb that owns the module (e.g. `"solution"`).
21
+ * @param packageName - npm package behind that verb, used for the fallback
22
+ * import (e.g. `"@uipath/solution-tool"`).
23
+ * @param moduleName - subpath entry to load (e.g. `"init"`, `"resource"`).
24
+ */
25
+ export declare function ensureToolModule(verb: string, packageName: string, moduleName: string): Promise<unknown>;
26
+ /**
27
+ * Resolve the packager factory for a tool verb.
28
+ *
29
+ * Prefers the registered provider (installed by the CLI). With no provider —
30
+ * a library caller — falls back to the tool package's own `packager-tool`
31
+ * entry point: imports it and calls its `registerPackagerFactories` export.
32
+ *
33
+ * @param verb - CLI tool verb that owns the factory (e.g. `"maestro"`).
34
+ * @param packageName - npm package behind that verb. Drives the fallback
35
+ * import and is the one thing the error asks for. Omit when unknown; there is
36
+ * then no fallback and no package to name.
37
+ */
38
+ export declare function ensurePackagerFactory(verb: string, packageName?: string): Promise<void>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uipath/common",
3
3
  "license": "MIT",
4
- "version": "1.199.0",
4
+ "version": "1.201.0-preview.115",
5
5
  "description": "Common infrastructure needed by uip tools.",
6
6
  "repository": {
7
7
  "type": "git",
@@ -28,6 +28,10 @@
28
28
  "types": "./dist/catch-error.d.ts",
29
29
  "default": "./dist/catch-error.js"
30
30
  },
31
+ "./guid": {
32
+ "types": "./dist/guid.d.ts",
33
+ "default": "./dist/guid.js"
34
+ },
31
35
  "./sdk-user-agent": {
32
36
  "browser": {
33
37
  "types": "./dist/sdk-user-agent.d.ts",
@@ -67,5 +71,5 @@
67
71
  "mihaigirleanu",
68
72
  "vlad-uipath"
69
73
  ],
70
- "gitHead": "723e6801b77b5926ba75e75b6a756cc38b1b7adc"
74
+ "gitHead": "f1086b73654d7728cb71f280588b3e0c77d535fc"
71
75
  }