@uipath/maestro-builder-sdk 6.86.25 → 6.86.27

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.
@@ -141,6 +141,7 @@ export interface ReadEventFilter {
141
141
  * const filter = { field: 'Id', equals: { expression: '=vars.request.Id' } };
142
142
  */
143
143
  export interface EventFilterExpression {
144
+ /** The Case expression the field is compared against: `=vars.<path>` or `=js:<expression>`. */
144
145
  expression: string;
145
146
  }
146
147
  /** The operators an expression-valued filter takes: the ones that compare a string. */
@@ -216,6 +216,7 @@ export declare const REFUSALS: {
216
216
  readonly CEQL_UNPARSEABLE: "lowering";
217
217
  readonly CHECK_INCOMPLETE: "lowering";
218
218
  readonly COMPILE_FAILED: "lowering";
219
+ readonly CONNECTION_BINDING_NOT_GUID: "lint";
219
220
  readonly CONNECTION_CONNECTOR_CONFLICT: "draft";
220
221
  readonly CONNECTION_STUB: "lint";
221
222
  readonly CONNECTOR_IMPORT_NOT_A_FILE: "lowering";
@@ -493,8 +494,13 @@ export declare const REFUSALS: {
493
494
  readonly INTSVC_BINDING_MISMATCH: "lint";
494
495
  readonly INTSVC_BINDING_UNDECLARED: "lint";
495
496
  readonly INTSVC_CATALOG_PLACEHOLDER: "lint";
497
+ readonly INTSVC_CONNECTION_BINDING_MISSING: "lint";
498
+ readonly INTSVC_CONNECTION_FOLDER_MISMATCH: "lint";
496
499
  readonly INTSVC_CONNECTION_MISSING: "lint";
497
500
  readonly INTSVC_CONNECTION_NOT_BINDING: "lint";
501
+ readonly INTSVC_CONNECTION_RESOURCE_CONFLICT: "lint";
502
+ readonly INTSVC_CONNECTOR_KEY_MISSING: "lint";
503
+ readonly INTSVC_EVENT_NO_CONNECTION: "lint";
498
504
  readonly INTSVC_METHOD_UNKNOWN: "lint";
499
505
  readonly INTSVC_OBJECT_NAME_SLUG: "lint";
500
506
  readonly INTSVC_OPERATION_NOT_IDENTIFIER: "lint";
@@ -289,6 +289,7 @@ export const REFUSALS = {
289
289
  CHECK_INCOMPLETE: 'lowering',
290
290
  // A throw that is no refusal, which `compile` cannot get past: check reports it on its step.
291
291
  COMPILE_FAILED: 'lowering',
292
+ CONNECTION_BINDING_NOT_GUID: 'lint',
292
293
  CONNECTION_CONNECTOR_CONFLICT: 'draft',
293
294
  CONNECTION_STUB: 'lint',
294
295
  CONNECTOR_IMPORT_NOT_A_FILE: 'lowering',
@@ -566,8 +567,13 @@ export const REFUSALS = {
566
567
  INTSVC_BINDING_MISMATCH: 'lint',
567
568
  INTSVC_BINDING_UNDECLARED: 'lint',
568
569
  INTSVC_CATALOG_PLACEHOLDER: 'lint',
570
+ INTSVC_CONNECTION_BINDING_MISSING: 'lint',
571
+ INTSVC_CONNECTION_FOLDER_MISMATCH: 'lint',
569
572
  INTSVC_CONNECTION_MISSING: 'lint',
570
573
  INTSVC_CONNECTION_NOT_BINDING: 'lint',
574
+ INTSVC_CONNECTION_RESOURCE_CONFLICT: 'lint',
575
+ INTSVC_CONNECTOR_KEY_MISSING: 'lint',
576
+ INTSVC_EVENT_NO_CONNECTION: 'lint',
571
577
  INTSVC_METHOD_UNKNOWN: 'lint',
572
578
  INTSVC_OBJECT_NAME_SLUG: 'lint',
573
579
  INTSVC_OPERATION_NOT_IDENTIFIER: 'lint',
@@ -56,13 +56,26 @@ export interface RegistryCatalog {
56
56
  */
57
57
  failure?: string;
58
58
  }
59
- /** Whether `registry pull --force` refreshed the local catalog copy, or why not. */
59
+ /**
60
+ * Whether the search ANSWERED and listed no action and no event: the catalog
61
+ * copy serves no node for the connector. A failed search is not this.
62
+ */
63
+ export declare function catalogServesNothing(catalog: RegistryCatalog): boolean;
64
+ /**
65
+ * Whether `registry pull --force` refreshed the local catalog copy, or why not.
66
+ * `partial` is set when the pull exited 0 but did not write a whole catalog
67
+ * (`CacheWritten` not true, or `MissingSources` listed): its answers are used,
68
+ * but an absence read from them must not be remembered.
69
+ */
60
70
  export type RegistryRefresh = {
61
71
  ok: true;
72
+ partial?: string;
62
73
  } | {
63
74
  ok: false;
64
75
  reason: string;
65
76
  };
77
+ /** Why a successful pull's reply does not show a whole catalog written, or `undefined` when it does. */
78
+ export declare function partialPullReason(stdout: string): string | undefined;
66
79
  /**
67
80
  * `uip maestro flow registry pull --force`: refresh the local catalog copy the
68
81
  * probes and the search answer from. It never refreshes itself, so before
@@ -19,7 +19,7 @@
19
19
  import { compareCodePoints, sortedStrings } from "../compat/compare.js";
20
20
  import { editDistance } from "../../core/edit-distance.js";
21
21
  import { registryPull, registrySearch } from "../uip/commands.js";
22
- import { failureReason, findJsonDocument, tail } from "../uip/envelope.js";
22
+ import { failureReason, findJsonDocument, getCI, parseEnvelope, tail } from "../uip/envelope.js";
23
23
  import { isPlainObject, pyOr } from "./support.js";
24
24
  /**
25
25
  * The action ids in a `registry search <key>` reply, sorted.
@@ -141,6 +141,27 @@ export function registryEventIds(payload, connectorKey) {
141
141
  forms: ["trigger", "event"].filter((form) => forms.get(id).has(form)),
142
142
  }));
143
143
  }
144
+ /**
145
+ * Whether the search ANSWERED and listed no action and no event: the catalog
146
+ * copy serves no node for the connector. A failed search is not this.
147
+ */
148
+ export function catalogServesNothing(catalog) {
149
+ return catalog.failure === undefined && catalog.actions.length === 0 && catalog.events.length === 0;
150
+ }
151
+ /** Why a successful pull's reply does not show a whole catalog written, or `undefined` when it does. */
152
+ export function partialPullReason(stdout) {
153
+ const data = getCI(parseEnvelope(stdout), "Data");
154
+ if (data === undefined)
155
+ return "its reply did not say what it wrote";
156
+ const missing = getCI(data, "MissingSources");
157
+ if (Array.isArray(missing) && missing.length > 0) {
158
+ const sources = missing.map((entry) => getCI(entry, "Source")).filter((source) => typeof source === "string");
159
+ return `missing node sources: ${sources.length > 0 ? sources.join(", ") : `${missing.length} source(s)`}`;
160
+ }
161
+ if (getCI(data, "CacheWritten") !== true)
162
+ return "the CLI did not write its catalog cache";
163
+ return undefined;
164
+ }
144
165
  /**
145
166
  * `uip maestro flow registry pull --force`: refresh the local catalog copy the
146
167
  * probes and the search answer from. It never refreshes itself, so before
@@ -150,7 +171,10 @@ export function registryEventIds(payload, connectorKey) {
150
171
  */
151
172
  export async function refreshRegistryCatalog(client, timeoutMs) {
152
173
  const result = await client.run(registryPull(), timeoutMs === undefined ? undefined : { timeoutMs });
153
- return result.code === 0 ? { ok: true } : { ok: false, reason: failureReason(result) };
174
+ if (result.code !== 0)
175
+ return { ok: false, reason: failureReason(result) };
176
+ const partial = partialPullReason(result.stdout);
177
+ return partial === undefined ? { ok: true } : { ok: true, partial };
154
178
  }
155
179
  /**
156
180
  * `registry search <key>`, read for both catalogs. This runs only on the
@@ -0,0 +1,50 @@
1
+ /** One hour: a session's worth of `prepare` calls, short enough that a newly published node is not hidden for long. */
2
+ export declare const DEFAULT_ABSENCE_TTL_MS: number;
3
+ /** What a remembered verdict says. */
4
+ export interface RememberedAbsence {
5
+ /** Epoch ms when the verdict was recorded, right after the pull that reached it. */
6
+ recordedAt: number;
7
+ /** How long ago that was, by the store's clock. */
8
+ ageMs: number;
9
+ /**
10
+ * The tenant the catalog copy was fetched for (`baseUrl|orgId|tenantId`,
11
+ * lower case). Accept the verdict only when the ACTIVE login is that tenant:
12
+ * after a login switch the copy's metadata still names the old one until the
13
+ * CLI refetches.
14
+ */
15
+ scope: string;
16
+ }
17
+ /** The port `prepare` reads and writes the verdicts through. Without one, nothing is remembered. */
18
+ export interface CatalogAbsence {
19
+ /** The verdict for `connectorKey` against the CURRENT catalog copy, if one is remembered and fresh. */
20
+ lookup(connectorKey: string): RememberedAbsence | undefined;
21
+ /** The current catalog copy's epoch. Read it BEFORE the search whose answer you then {@link record}. */
22
+ epoch(): string | undefined;
23
+ /**
24
+ * Remember that the catalog copy at `epoch` serves no node for `connectorKey`.
25
+ * Records nothing when the copy is no longer at `epoch`: the answer was about
26
+ * a copy another process has since replaced.
27
+ */
28
+ record(connectorKey: string, epoch: string): void;
29
+ }
30
+ /**
31
+ * The tenant scope of a `uip login status --output json` `Data` block, spelled
32
+ * as the CLI's `nodeCacheScope` spells a catalog's scope (each part trimmed,
33
+ * trailing slashes dropped from the base URL, lower case), or `undefined` when
34
+ * any part is missing.
35
+ */
36
+ export declare function loginScope(data: unknown): string | undefined;
37
+ export interface FsCatalogAbsenceOptions {
38
+ /** The CLI's index metadata. Defaults to `~/.uipath/nodes/index.meta.json`. */
39
+ metaPath?: string;
40
+ /** Where the verdicts live. Defaults to `~/.uipath/cache/flow-sdk/catalog-absent.json`. */
41
+ file?: string;
42
+ /**
43
+ * How long a verdict is trusted; 0 or less disables the memory. Defaults to
44
+ * `UIP_FLOW_SDK_CATALOG_ABSENCE_TTL_MS`, else {@link DEFAULT_ABSENCE_TTL_MS}.
45
+ */
46
+ ttlMs?: number;
47
+ now?: () => number;
48
+ }
49
+ /** The on-disk memory, beside the CLI's own catalog copy under `~/.uipath`. */
50
+ export declare function fsCatalogAbsence(options?: FsCatalogAbsenceOptions): CatalogAbsence;
@@ -0,0 +1,135 @@
1
+ /**
2
+ * The remembered answer "the Flow node catalog serves no node for connector K",
3
+ * so `prepare` does not force a catalog pull for it on every call.
4
+ *
5
+ * Keyed on the catalog copy's epoch: `scope|cacheVersion|hash` from the CLI's
6
+ * `~/.uipath/nodes/index.meta.json`. A pull that changes the catalog changes
7
+ * the hash and so drops every entry; entries also expire after a TTL, so a
8
+ * newly published node is found even when nothing pulls. No readable metadata
9
+ * means nothing is remembered. File errors are swallowed: losing the memory
10
+ * costs one pull, never a wrong answer.
11
+ */
12
+ import { mkdirSync, readFileSync, renameSync, rmSync } from "node:fs";
13
+ import { homedir } from "node:os";
14
+ import { dirname, join } from "node:path";
15
+ import { writeJsonFile } from "../../core/json-file.js";
16
+ import { getCI } from "../uip/envelope.js";
17
+ /** One hour: a session's worth of `prepare` calls, short enough that a newly published node is not hidden for long. */
18
+ export const DEFAULT_ABSENCE_TTL_MS = 60 * 60 * 1000;
19
+ /** The catalog copy's epoch and tenant scope, or `undefined` when the metadata names no hash or scope. */
20
+ function catalogIdentity(metaPath) {
21
+ try {
22
+ const meta = JSON.parse(readFileSync(metaPath, "utf8"));
23
+ const { hash, scope, cacheVersion } = meta;
24
+ if (typeof hash !== "string" || hash === "" || typeof scope !== "string" || scope === "")
25
+ return undefined;
26
+ const tenant = scope.toLowerCase();
27
+ return { epoch: `${tenant}|${typeof cacheVersion === "number" ? cacheVersion : ""}|${hash}`, scope: tenant };
28
+ }
29
+ catch {
30
+ return undefined;
31
+ }
32
+ }
33
+ function catalogEpoch(metaPath) {
34
+ return catalogIdentity(metaPath)?.epoch;
35
+ }
36
+ /**
37
+ * The tenant scope of a `uip login status --output json` `Data` block, spelled
38
+ * as the CLI's `nodeCacheScope` spells a catalog's scope (each part trimmed,
39
+ * trailing slashes dropped from the base URL, lower case), or `undefined` when
40
+ * any part is missing.
41
+ */
42
+ export function loginScope(data) {
43
+ const pick = (name) => {
44
+ const value = getCI(data, name);
45
+ const trimmed = typeof value === "string" ? value.trim() : "";
46
+ return trimmed === "" ? undefined : trimmed;
47
+ };
48
+ const baseUrl = pick("BaseUrl")?.replace(/\/+$/, "");
49
+ const parts = [baseUrl, pick("OrganizationId"), pick("TenantId")];
50
+ return parts.every((part) => part !== undefined && part !== "") ? parts.join("|").toLowerCase() : undefined;
51
+ }
52
+ function readAbsenceFile(path) {
53
+ try {
54
+ const parsed = JSON.parse(readFileSync(path, "utf8"));
55
+ if (parsed === null || typeof parsed !== "object")
56
+ return undefined;
57
+ const { epoch, absent } = parsed;
58
+ if (typeof epoch !== "string" || typeof absent !== "object" || absent === null || Array.isArray(absent))
59
+ return undefined;
60
+ return { epoch, absent };
61
+ }
62
+ catch {
63
+ return undefined;
64
+ }
65
+ }
66
+ function absenceTtlFromEnv() {
67
+ const raw = process.env.UIP_FLOW_SDK_CATALOG_ABSENCE_TTL_MS;
68
+ if (raw === undefined || raw.trim() === "")
69
+ return DEFAULT_ABSENCE_TTL_MS;
70
+ const value = Number(raw);
71
+ return Number.isFinite(value) ? value : DEFAULT_ABSENCE_TTL_MS;
72
+ }
73
+ /** The on-disk memory, beside the CLI's own catalog copy under `~/.uipath`. */
74
+ export function fsCatalogAbsence(options = {}) {
75
+ const metaPath = options.metaPath ?? join(homedir(), ".uipath", "nodes", "index.meta.json");
76
+ const file = options.file ?? join(homedir(), ".uipath", "cache", "flow-sdk", "catalog-absent.json");
77
+ const ttlMs = options.ttlMs ?? absenceTtlFromEnv();
78
+ const now = options.now ?? Date.now;
79
+ return {
80
+ lookup(connectorKey) {
81
+ if (ttlMs <= 0)
82
+ return undefined;
83
+ const identity = catalogIdentity(metaPath);
84
+ if (identity === undefined)
85
+ return undefined;
86
+ const stored = readAbsenceFile(file);
87
+ if (stored === undefined || stored.epoch !== identity.epoch)
88
+ return undefined;
89
+ const recordedAt = Object.hasOwn(stored.absent, connectorKey) ? stored.absent[connectorKey] : undefined;
90
+ if (typeof recordedAt !== "number")
91
+ return undefined;
92
+ const age = now() - recordedAt;
93
+ // A clock that went backwards is not evidence of freshness.
94
+ if (age < 0 || age >= ttlMs)
95
+ return undefined;
96
+ return { recordedAt, ageMs: age, scope: identity.scope };
97
+ },
98
+ epoch() {
99
+ return ttlMs <= 0 ? undefined : catalogEpoch(metaPath);
100
+ },
101
+ record(connectorKey, epoch) {
102
+ if (ttlMs <= 0)
103
+ return;
104
+ const current = catalogEpoch(metaPath);
105
+ if (current === undefined || current !== epoch)
106
+ return;
107
+ const stored = readAbsenceFile(file);
108
+ const absent = stored !== undefined && stored.epoch === epoch ? { ...stored.absent } : {};
109
+ absent[connectorKey] = now();
110
+ // Written under `epoch`, never a re-read one: a pull landing after the
111
+ // check above leaves the entry unreadable rather than misfiled.
112
+ const value = {
113
+ $comment: "Connectors this Flow node catalog copy (epoch) served no node for after a forced pull. Written by `registry prepare`; safe to delete.",
114
+ epoch,
115
+ absent,
116
+ };
117
+ const temp = `${file}.${process.pid}.${now()}.tmp`;
118
+ try {
119
+ mkdirSync(dirname(file), { recursive: true });
120
+ // Write, then rename, so a concurrent `prepare` never reads half a file.
121
+ writeJsonFile(temp, value);
122
+ renameSync(temp, file);
123
+ }
124
+ catch {
125
+ // A memory that cannot be written costs the next call one pull; leave no temp file behind.
126
+ try {
127
+ rmSync(temp, { force: true });
128
+ }
129
+ catch {
130
+ // Nothing more to do.
131
+ }
132
+ }
133
+ },
134
+ };
135
+ }
@@ -1,6 +1,6 @@
1
1
  import { Refusal } from "../errors.js";
2
- import { loginStatus } from "../uip/commands.js";
3
- import { failureReason, getCI, parseEnvelope } from "../uip/envelope.js";
2
+ import { failureReason, getCI } from "../uip/envelope.js";
3
+ import { loginStatusData } from "../uip/login-status.js";
4
4
  /**
5
5
  * Set by `uip` for the processes it starts: the login profile the run is for.
6
6
  * Empty or unset means the default login.
@@ -14,8 +14,7 @@ export const INHERITED_PROFILE_ENV = "UIPATH_CLI_INHERITED_PROFILE";
14
14
  * notices (UiPath/cli#5485).
15
15
  */
16
16
  export async function assertInheritedProfile(client, profile) {
17
- const result = await client.run(loginStatus());
18
- const data = result.code === 0 ? getCI(parseEnvelope(result.stdout), "Data") : undefined;
17
+ const { data, result } = await loginStatusData(client);
19
18
  if (data === undefined) {
20
19
  throw new Refusal(`could not confirm login profile "${profile}": ${failureReason(result)}`, "PROFILE_UNCONFIRMED");
21
20
  }
@@ -158,6 +158,15 @@ export declare function preparedSummaryLine(nodeType: string, out: string, ts: s
158
158
  export declare function catalogServesNothingPhrase(key: string, refresh: RegistryRefresh | undefined): string;
159
159
  /** The progress line before the one `registry pull --force` the fallback runs. */
160
160
  export declare function refreshingCatalogLine(key: string): string;
161
+ /**
162
+ * The progress line when the verdict was remembered from an earlier call
163
+ * (catalog-absence.ts), so no lookup and no pull runs this time.
164
+ */
165
+ export declare function rememberedAbsenceLine(key: string, ageMs: number): string;
166
+ /** Why a `registry get` probe was not run: the search already said the connector has no node at all. */
167
+ export declare function probeSkippedReason(key: string): string;
168
+ /** The warning when that pull exited 0 without a whole catalog; its answer is used but not remembered. */
169
+ export declare function catalogRefreshPartialLine(reason: string): string;
161
170
  /** The warning when that pull failed; the fallback continues against the local copy. */
162
171
  export declare function catalogRefreshFailedLine(reason: string): string;
163
172
  /** The note when the author's `--action` spelling was not the entry's id. */
@@ -344,6 +344,9 @@ export function preparedSummaryLine(nodeType, out, ts, variants, fieldNote) {
344
344
  * refreshes itself).
345
345
  */
346
346
  export function catalogServesNothingPhrase(key, refresh) {
347
+ if (refresh?.ok === true && refresh.partial !== undefined) {
348
+ return `the Flow node catalog, partly refreshed with \`uip maestro flow registry pull --force\` (${refresh.partial}), serves no node for ${key}`;
349
+ }
347
350
  if (refresh?.ok === true)
348
351
  return `the Flow node catalog, refreshed with \`uip maestro flow registry pull --force\`, serves no node for ${key}`;
349
352
  const why = refresh === undefined ? "it was not refreshed" : `refreshing it failed: ${refresh.reason}`;
@@ -353,6 +356,23 @@ export function catalogServesNothingPhrase(key, refresh) {
353
356
  export function refreshingCatalogLine(key) {
354
357
  return ` the local catalog copy serves no node for ${key}; refreshing it (uip maestro flow registry pull --force) and looking again.`;
355
358
  }
359
+ /**
360
+ * The progress line when the verdict was remembered from an earlier call
361
+ * (catalog-absence.ts), so no lookup and no pull runs this time.
362
+ */
363
+ export function rememberedAbsenceLine(key, ageMs) {
364
+ const minutes = Math.max(0, Math.round(ageMs / 60_000));
365
+ return (` the Flow node catalog served no node for ${key} when it was refreshed ${minutes} min ago, and this copy of it has not changed since; `
366
+ + "skipping the registry lookups. A `uip maestro flow registry pull --force` that brings a changed catalog makes the next call look again.");
367
+ }
368
+ /** Why a `registry get` probe was not run: the search already said the connector has no node at all. */
369
+ export function probeSkippedReason(key) {
370
+ return `not looked up: the catalog serves no node for ${key}`;
371
+ }
372
+ /** The warning when that pull exited 0 without a whole catalog; its answer is used but not remembered. */
373
+ export function catalogRefreshPartialLine(reason) {
374
+ return `${PREFIX}registry pull --force was partial (${reason}); continuing with what it wrote, and not remembering the answer.`;
375
+ }
356
376
  /** The warning when that pull failed; the fallback continues against the local copy. */
357
377
  export function catalogRefreshFailedLine(reason) {
358
378
  return `${PREFIX}registry pull --force failed (${reason}); continuing with the local catalog copy, which may be stale.`;
@@ -1,6 +1,7 @@
1
1
  import { type BuildCaches, type BuildContext } from "../library-build/context.js";
2
2
  import type { Reporter } from "../reporter.js";
3
3
  import type { UipClient } from "../uip/client.js";
4
+ import { type CatalogAbsence } from "./catalog-absence.js";
4
5
  import { type CatalogueRow } from "./objects.js";
5
6
  /** The command line, as `argparse` parsed it. Defaults are the Python's. */
6
7
  export interface PrepareOptions {
@@ -55,6 +56,12 @@ export interface PreparePorts {
55
56
  timeoutMs?: number;
56
57
  /** How the CLI is spelled in the pasteable commands; defaults to {@link cliSpelling}. */
57
58
  cli?: string;
59
+ /**
60
+ * The remembered "the catalog serves no node for this connector" verdicts
61
+ * (catalog-absence.ts). The CLI passes the on-disk one; without it nothing is
62
+ * remembered and every call pulls before concluding.
63
+ */
64
+ catalogAbsence?: CatalogAbsence;
58
65
  }
59
66
  /**
60
67
  * Where prepare writes its overlay when `--out` is not given, as shown to the
@@ -35,13 +35,15 @@ import { enrichEntry } from "../library-build/enrich.js";
35
35
  import { expandGenericForConnector, genericTemplatesByOp } from "../library-build/generic-expand.js";
36
36
  import { planLibrary } from "../library-build/plan.js";
37
37
  import { MemoryResponseCache } from "../uip/response-cache.js";
38
- import { refreshRegistryCatalog, registryCatalog } from "./actions.js";
38
+ import { catalogServesNothing, refreshRegistryCatalog, registryCatalog } from "./actions.js";
39
+ import { loginScope } from "./catalog-absence.js";
40
+ import { loginStatusData } from "../uip/login-status.js";
39
41
  import { chooseConnection, listConnections, lookupConnection, mergeBindings, restoreBindings, snapshotBindings, solutionConnectionIds, } from "./connections.js";
40
42
  import { prepareEvent } from "./event.js";
41
43
  import { integrationServiceEntry } from "./integration-service.js";
42
44
  import { descriptorUsage } from "./handoff.js";
43
45
  import { ResolutionsExhausted, allParentsResolved, resolvedParentValues, writeResolutions } from "./ledger.js";
44
- import { PrepareRefusal, ambiguousLabelsMessage, connectionChoiceLine, bindingsLine, bpmnConnectorUsageLines, candidateLabel, connectionLine, describeNextLine, generatedModulesLine, genericActionNeedsObjectMessage, inputFieldNote, flagDiffersFromSourceLine, keptSchemaMessage, labelTakenMessage, lookupVocabularyLines, missingGenericSchemaMessage, missingParentsNote, nextLine, noCanonicalEntryMessage, objectFlagsOnlyForGenericMessage, objectNoteLine, objectRecordedLine, parentFieldNamesMismatchMessage, parentOnlyMessage, prefixed, preparedFromIntegrationServiceLine, actionCanonicalizedLine, catalogRefreshFailedLine, refreshingCatalogLine, preparedSummaryLine, rejectedParentFieldsMessage, rerunAgainstLine, resolvedParentsNote, registryGetFailedMessage, sharedLabelMessage, sourceLabelSuffix, tsNote, partlyUnreadableLabelLine, unreadableLabelLine, unresolvedOperationMessage, } from "./messages.js";
46
+ import { PrepareRefusal, ambiguousLabelsMessage, connectionChoiceLine, bindingsLine, bpmnConnectorUsageLines, candidateLabel, connectionLine, describeNextLine, generatedModulesLine, genericActionNeedsObjectMessage, inputFieldNote, flagDiffersFromSourceLine, keptSchemaMessage, labelTakenMessage, lookupVocabularyLines, missingGenericSchemaMessage, missingParentsNote, nextLine, noCanonicalEntryMessage, objectFlagsOnlyForGenericMessage, objectNoteLine, objectRecordedLine, parentFieldNamesMismatchMessage, parentOnlyMessage, prefixed, preparedFromIntegrationServiceLine, actionCanonicalizedLine, catalogRefreshFailedLine, catalogRefreshPartialLine, probeSkippedReason, refreshingCatalogLine, rememberedAbsenceLine, preparedSummaryLine, rejectedParentFieldsMessage, rerunAgainstLine, resolvedParentsNote, registryGetFailedMessage, sharedLabelMessage, sourceLabelSuffix, tsNote, partlyUnreadableLabelLine, unreadableLabelLine, unresolvedOperationMessage, } from "./messages.js";
45
47
  import { ObjectMatchRefusal, RESOLUTIONS_FILENAME, matchObject, recordObjectResolution } from "./objects.js";
46
48
  import { countInputFields, keepPreparedSchema, lookupSpecsFromOverlay, mergeFilesInto, parentFields as overlayParentFields, schemaActionParents, } from "./overlay.js";
47
49
  import { declaredParents, objectActionRequest, objectActionSpecs, parseFields } from "./parents.js";
@@ -361,8 +363,54 @@ async function prepareOnConnection(options, ports, connected, registryRefresh) {
361
363
  const ctx = createBuildContext({ client: ports.client, caches: ports.caches ?? memoryCaches(), reporter: ports.reporter, concurrency: 1, timeoutMs: ports.timeoutMs }, { connectionId, parentFields });
362
364
  let nodeType = `uipath.connector.${connectorKey}.${action}`;
363
365
  let fromIntegrationService;
364
- const actionProbe = await registryProbe(ctx, nodeType);
365
- if ("miss" in actionProbe) {
366
+ /** The operation from Integration Service, once the Flow catalog is known to serve nothing for the connector. */
367
+ const integrationServiceFallback = async (probes, catalog, refresh) => {
368
+ const prepared = await integrationServiceEntry(ctx, { connectorKey, action });
369
+ if ("miss" in prepared) {
370
+ throw new PrepareRefusal(unresolvedOperationMessage({ connectorKey, name: action, probes, catalog, integrationService: prepared.miss, registryRefresh: refresh }), "OPERATION_UNKNOWN");
371
+ }
372
+ info(preparedFromIntegrationServiceLine(connectorKey, prepared.activity, refresh));
373
+ if (prepared.action !== action)
374
+ info(actionCanonicalizedLine(action, prepared.action));
375
+ return prepared;
376
+ };
377
+ // When the catalog is known to serve nothing for the connector, no
378
+ // `registry get` can find a node: skip the probes. Known means a verdict
379
+ // remembered for this catalog copy, or, after the pull, an empty search.
380
+ let knownAbsent;
381
+ let searched;
382
+ if (registryRefresh === undefined) {
383
+ const remembered = ports.catalogAbsence?.lookup(connectorKey);
384
+ // Only for the tenant the copy was fetched for: after a login switch the
385
+ // CLI refetches on its next lookup, while the copy still names the old
386
+ // tenant. An unconfirmed login is a miss, never a match.
387
+ if (remembered !== undefined && loginScope((await loginStatusData(ports.client)).data) === remembered.scope) {
388
+ info(rememberedAbsenceLine(connectorKey, remembered.ageMs));
389
+ knownAbsent = { catalog: { actions: [], events: [] }, refresh: { ok: true } };
390
+ }
391
+ }
392
+ else {
393
+ // Read before the search, so an answer about a copy another process
394
+ // replaced meanwhile is not recorded under the new one.
395
+ const epoch = ports.catalogAbsence?.epoch();
396
+ searched = await registryCatalog(ports.client, connectorKey, ports.timeoutMs);
397
+ if (catalogServesNothing(searched)) {
398
+ // Remember only what a successful pull confirmed; a stale copy's answer is no verdict.
399
+ // A partial pull (missing sources, no cache written) is not a whole catalog either.
400
+ if (registryRefresh.ok && registryRefresh.partial === undefined && epoch !== undefined)
401
+ ports.catalogAbsence?.record(connectorKey, epoch);
402
+ knownAbsent = { catalog: searched, refresh: registryRefresh };
403
+ }
404
+ }
405
+ const actionProbe = knownAbsent === undefined ? await registryProbe(ctx, nodeType) : undefined;
406
+ if (knownAbsent !== undefined) {
407
+ // The two lookups the refusal would otherwise quote, named as not run and why.
408
+ const skipped = [nodeType, `uipath.connector.trigger.${connectorKey}.${action}`].map((probed) => ({ nodeType: probed, reason: probeSkippedReason(connectorKey) }));
409
+ fromIntegrationService = await integrationServiceFallback(skipped, knownAbsent.catalog, knownAbsent.refresh);
410
+ action = fromIntegrationService.action;
411
+ nodeType = fromIntegrationService.entry.nodeType;
412
+ }
413
+ else if (actionProbe !== undefined && "miss" in actionProbe) {
366
414
  // Not an activity. Connector EVENTS live one namespace over, and their
367
415
  // registry definition only answers with a connection, which this command
368
416
  // has by now. Same loop, different twin pair.
@@ -394,12 +442,13 @@ async function prepareOnConnection(options, ports, connected, registryRefresh) {
394
442
  if (probes.some((probe) => !probe.notFound)) {
395
443
  throw new PrepareRefusal(registryGetFailedMessage(connectorKey, action, probes), "REGISTRY_GET_FAILED");
396
444
  }
397
- const catalog = await registryCatalog(ports.client, connectorKey, ports.timeoutMs);
445
+ // On the re-entry the search already ran, first, and answered something.
446
+ const catalog = searched ?? (await registryCatalog(ports.client, connectorKey, ports.timeoutMs));
398
447
  // A catalog that serves NOTHING for the connector — no action, no event, and
399
448
  // the search itself answered — is a connector the Flow registry does not
400
449
  // carry, not a misspelt action on one it does. Integration Service still
401
450
  // serves it, and a BPMN connector task needs nothing more.
402
- if (catalog.failure === undefined && catalog.actions.length === 0 && catalog.events.length === 0) {
451
+ if (catalogServesNothing(catalog)) {
403
452
  // The probes and the search answer from the CLI's local catalog copy,
404
453
  // which never refreshes itself. Pull once and look again before
405
454
  // concluding anything: a stale copy would send a connector the catalog
@@ -409,18 +458,13 @@ async function prepareOnConnection(options, ports, connected, registryRefresh) {
409
458
  const refreshed = await refreshRegistryCatalog(ports.client, ports.timeoutMs);
410
459
  if (!refreshed.ok)
411
460
  warn(catalogRefreshFailedLine(refreshed.reason));
461
+ else if (refreshed.partial !== undefined)
462
+ warn(catalogRefreshPartialLine(refreshed.partial));
412
463
  return prepareOnConnection(options, ports, connected, refreshed);
413
464
  }
414
- const prepared = await integrationServiceEntry(ctx, { connectorKey, action });
415
- if ("miss" in prepared) {
416
- throw new PrepareRefusal(unresolvedOperationMessage({ connectorKey, name: action, probes, catalog, integrationService: prepared.miss, registryRefresh }), "OPERATION_UNKNOWN");
417
- }
418
- info(preparedFromIntegrationServiceLine(connectorKey, prepared.activity, registryRefresh));
419
- if (prepared.action !== action)
420
- info(actionCanonicalizedLine(action, prepared.action));
421
- action = prepared.action;
422
- nodeType = prepared.entry.nodeType;
423
- fromIntegrationService = prepared;
465
+ fromIntegrationService = await integrationServiceFallback(probes, catalog, registryRefresh);
466
+ action = fromIntegrationService.action;
467
+ nodeType = fromIntegrationService.entry.nodeType;
424
468
  }
425
469
  else {
426
470
  throw new PrepareRefusal(unresolvedOperationMessage({ connectorKey, name: action, probes, catalog }), "OPERATION_UNKNOWN");
@@ -429,7 +473,7 @@ async function prepareOnConnection(options, ports, connected, registryRefresh) {
429
473
  // The registry reply this entry came from, or none when Integration Service
430
474
  // supplied it — then there is no node to read parents from and the sidecar
431
475
  // is built from the synthesized node instead.
432
- const payload = fromIntegrationService === undefined && "name" in actionProbe ? ctx.caches.registry.read(actionProbe.name) : undefined;
476
+ const payload = fromIntegrationService === undefined && actionProbe !== undefined && "name" in actionProbe ? ctx.caches.registry.read(actionProbe.name) : undefined;
433
477
  // The registry's own declaration of parent inputs, read from the same reply.
434
478
  const declared = payload === undefined ? [] : declaredParents(payload);
435
479
  let entry = fromIntegrationService?.entry ?? extractCanonical(nodeOf(payload));
@@ -3,6 +3,7 @@ import { reportResult } from '../cli-result.js';
3
3
  import { PACKAGE_NAME } from "../package-name.js";
4
4
  import { exitCodeOf } from "./errors.js";
5
5
  import { assertInheritedProfile, INHERITED_PROFILE_ENV } from "./prepare/inherited-profile.js";
6
+ import { fsCatalogAbsence } from "./prepare/catalog-absence.js";
6
7
  import { exitText } from "./prepare/messages.js";
7
8
  import { defaultOverlayOut, prepareConnector as runPipeline } from "./prepare/pipeline.js";
8
9
  import { consoleReporter } from "./reporter.js";
@@ -70,7 +71,15 @@ export function pipelineOptions(options) {
70
71
  * `uip` client and reporter injected so tests replay recordings.
71
72
  */
72
73
  export async function prepareConnector(options) {
73
- return withPrepareClient((client) => runPipeline(pipelineOptions(options), { client, reporter: consoleReporter }));
74
+ return withPrepareClient((client) => runPipeline(pipelineOptions(options), { client, reporter: consoleReporter, catalogAbsence: cliCatalogAbsence() }));
75
+ }
76
+ /**
77
+ * The on-disk "catalog serves no node for K" memory,
78
+ * except under `UIP_REPLAY_DIR`: replayed answers are a recording, not this
79
+ * machine's catalog copy, so neither may be read as evidence about the other.
80
+ */
81
+ function cliCatalogAbsence() {
82
+ return process.env.UIP_REPLAY_DIR ? undefined : fsCatalogAbsence();
74
83
  }
75
84
  /**
76
85
  * Run `work` with the one `uip` client a prepare uses, after checking it talks
@@ -260,7 +269,7 @@ export async function run(argv) {
260
269
  return 0;
261
270
  }
262
271
  }
263
- const report = await runPipeline(pipelineOptions(options), { client, reporter: consoleReporter });
272
+ const report = await runPipeline(pipelineOptions(options), { client, reporter: consoleReporter, catalogAbsence: cliCatalogAbsence() });
264
273
  reportResult({ connector: options.connectorKey, action: options.action, overlay: resolve(options.outPath ?? defaultOverlayOut(process.cwd())), ...report });
265
274
  return 0;
266
275
  });
@@ -0,0 +1,8 @@
1
+ import type { UipClient, UipResult } from "./client.js";
2
+ /** `uip login status`: its `Data` block when the call succeeded, and the raw result for a failure message. */
3
+ export interface LoginStatus {
4
+ data: unknown;
5
+ result: UipResult;
6
+ }
7
+ /** `uip login status --output json` through `client`, run at most once per client. */
8
+ export declare function loginStatusData(client: UipClient): Promise<LoginStatus>;
@@ -0,0 +1,17 @@
1
+ import { loginStatus } from "./commands.js";
2
+ import { getCI, parseEnvelope } from "./envelope.js";
3
+ // One call per client: a client lives for one command, and the inherited-profile
4
+ // check and the catalog-absence scope check both ask during the same command.
5
+ const answered = new WeakMap();
6
+ /** `uip login status --output json` through `client`, run at most once per client. */
7
+ export function loginStatusData(client) {
8
+ let pending = answered.get(client);
9
+ if (pending === undefined) {
10
+ pending = client.run(loginStatus()).then((result) => ({
11
+ data: result.code === 0 ? getCI(parseEnvelope(result.stdout), "Data") : undefined,
12
+ result,
13
+ }));
14
+ answered.set(client, pending);
15
+ }
16
+ return pending;
17
+ }