@uipath/maestro-builder-sdk 6.96.2 → 6.96.4
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/case/decompile-cli.js +28 -9
- package/dist/case/plan-connectors.d.ts +105 -0
- package/dist/case/plan-connectors.js +545 -0
- package/dist/registry/generator-identity.d.ts +16 -0
- package/dist/registry/generator-identity.js +92 -0
- package/dist/registry/prepare/event.js +3 -2
- package/dist/registry/prepare/messages.d.ts +9 -0
- package/dist/registry/prepare/messages.js +15 -0
- package/dist/registry/prepare/overlay.d.ts +22 -2
- package/dist/registry/prepare/overlay.js +80 -2
- package/dist/registry/prepare/pipeline.js +3 -2
- package/dist/registry/pull-cli.js +13 -5
- package/package.json +2 -2
|
@@ -20,16 +20,20 @@
|
|
|
20
20
|
* prepare` writes (`--connectors-local`, else `.flow-sdk/connectors-local`). A
|
|
21
21
|
* plan whose connector is one only a tenant has (a Data Service entity, a custom
|
|
22
22
|
* connector) is decompiled after `registry prepare` has described it, as it is
|
|
23
|
-
* compiled.
|
|
23
|
+
* compiled. When neither layer names a connector element the plan describes,
|
|
24
|
+
* decompile writes the plan's own description of it into that overlay
|
|
25
|
+
* (`plan-connectors.ts`), so check and compile accept it too; `registry
|
|
26
|
+
* prepare` later replaces it with the tenant's.
|
|
24
27
|
*/
|
|
25
28
|
import { reportResult } from '../cli-result.js';
|
|
26
29
|
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
27
30
|
import { openCliLibrary } from '../core/cli-library.js';
|
|
28
31
|
import { resolveLibraryDir } from '../core/library-cache.js';
|
|
29
32
|
import { basename, join, resolve } from 'node:path';
|
|
30
|
-
import { defaultOverlayDir, defaultSourceOut, workDirBeside, writeSource } from '../workdir.js';
|
|
33
|
+
import { defaultOverlayDir, defaultSourceOut, workDirBeside, workPath, writeSource } from '../workdir.js';
|
|
31
34
|
import { flagValue, runWhenInvokedDirectly } from '../cli-run.js';
|
|
32
35
|
import { decompileWithDiagnostics } from './decompile.js';
|
|
36
|
+
import { decompileWithPlanConnectors } from './plan-connectors.js';
|
|
33
37
|
import { CASE_IMPORT } from '../package-name.js';
|
|
34
38
|
import { commentText } from '../core/comment-text.js';
|
|
35
39
|
import { pipelineFrontDoor } from '../registry/uip/pipeline-front-door.js';
|
|
@@ -63,15 +67,30 @@ export function run(argv) {
|
|
|
63
67
|
const plan = JSON.parse(readFileSync(pos, 'utf8'));
|
|
64
68
|
const libraryDir = resolveLibraryDir(flagValue(argv, '--library'));
|
|
65
69
|
// The overlay the library opened, flag or auto-detected, so the helper reads it from any directory.
|
|
66
|
-
|
|
67
|
-
const library = openCliLibrary(argv);
|
|
70
|
+
let overlayDir = flagValue(argv, '--connectors-local') ?? defaultOverlayDir();
|
|
68
71
|
const importSpecifier = flagValue(argv, '--import') ?? CASE_IMPORT;
|
|
69
72
|
const bestEffort = argv.includes('--best-effort');
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
const run = (library) => decompileWithDiagnostics(plan, { importSpecifier, library, bestEffort });
|
|
74
|
+
const library = openCliLibrary(argv);
|
|
75
|
+
let result;
|
|
76
|
+
if (!library)
|
|
77
|
+
result = run(undefined);
|
|
78
|
+
else {
|
|
79
|
+
// A connector the library and the overlay lack, that the plan describes:
|
|
80
|
+
// decompile writes the plan's description into the overlay check and
|
|
81
|
+
// compile read, and goes on (`plan-connectors.ts`). Only what decompile
|
|
82
|
+
// asks the library for and it cannot answer; nothing it names is touched.
|
|
83
|
+
const carried = decompileWithPlanConnectors(plan, (dir) => (dir === undefined ? library : openCliLibrary([...argv, '--connectors-local', dir])), overlayDir, () => workPath('connectors-local'), run);
|
|
84
|
+
result = carried.result;
|
|
85
|
+
overlayDir = carried.overlayDir;
|
|
86
|
+
for (const { entry } of carried.written) {
|
|
87
|
+
const object = entry.operation?.objectName ? ` (object ${entry.operation.objectName})` : '';
|
|
88
|
+
console.error(`decompile: ${entry.nodeType}${object} is in no connector library; wrote the plan's own description of it into ${overlayDir}. `
|
|
89
|
+
+ 'It knows only the fields the plan uses; `registry prepare` describes the connector from the tenant and replaces it.');
|
|
90
|
+
}
|
|
91
|
+
if (carried.written.length)
|
|
92
|
+
reportResult({ connectorsFromPlan: { overlay: resolve(overlayDir), nodeTypes: carried.written.map((c) => c.entry.nodeType) } });
|
|
93
|
+
}
|
|
75
94
|
const out = flagValue(argv, '-o') ?? defaultSourceOut(`${baseName(plan)}.case.ts`);
|
|
76
95
|
writeSource(out, result.source);
|
|
77
96
|
console.log(`decompile: wrote ${basename(out)}`);
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { LibraryEntry } from '../registry/model/library.js';
|
|
2
|
+
import { type LibraryFiles } from '../registry/prepare/overlay.js';
|
|
3
|
+
import type { Library } from '../core/library.js';
|
|
4
|
+
/** `provenance.source` of every entry this module writes. A `registry prepare` of the same operation replaces such an entry. */
|
|
5
|
+
export declare const PLAN_CONNECTOR_SOURCE = "case-plan";
|
|
6
|
+
type Dict = Record<string, any>;
|
|
7
|
+
/** One connector bag of a plan: the object whose `context` names a `connectorKey`, and the element that owns it. */
|
|
8
|
+
export interface PlanConnectorBag {
|
|
9
|
+
/** The id of the task, trigger node or rule that holds the bag; none for a bag directly under a stage. */
|
|
10
|
+
owner?: string;
|
|
11
|
+
/** The names that element goes by in a decompile or compile message: its display name or label. */
|
|
12
|
+
names: string[];
|
|
13
|
+
bag: Dict;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Every connector bag in `plan`, with the element that owns it.
|
|
17
|
+
*
|
|
18
|
+
* The owner is the nearest object with an `id` above the bag, but never a stage
|
|
19
|
+
* or the case itself: a bag in an id-less wrapper directly under a stage has no
|
|
20
|
+
* owner.
|
|
21
|
+
*/
|
|
22
|
+
export declare function planConnectorBags(plan: unknown): PlanConnectorBag[];
|
|
23
|
+
/** One library field, as {@link responseSchemaFields} reads it back. */
|
|
24
|
+
export interface SchemaField {
|
|
25
|
+
name: string;
|
|
26
|
+
type: string;
|
|
27
|
+
displayName?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The response JSON schema a plan saved, read back as library fields: the
|
|
31
|
+
* inverse of `responseJsonSchema` (`core/connector-response-schema.ts`). A
|
|
32
|
+
* nested object is `parent.child`, an array of objects `items[*].child`.
|
|
33
|
+
*
|
|
34
|
+
* For instance `{ properties: { CreatedBy: { $ref: '#/definitions/U' } }, definitions: { U: { properties: { Email: { type: 'string' } } } } }`
|
|
35
|
+
* reads as `[{ name: 'CreatedBy.Email', type: 'string' }]`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function responseSchemaFields(schema: unknown): SchemaField[];
|
|
38
|
+
/** One connector operation a plan describes and the library lacks, as {@link planConnectors} derives it. */
|
|
39
|
+
export interface PlanConnector {
|
|
40
|
+
/** The library entry, marked with {@link PLAN_CONNECTOR_SOURCE}. */
|
|
41
|
+
entry: LibraryEntry;
|
|
42
|
+
/** The overlay library `registry prepare` writes for one operation: `index.json` and the entry's files. */
|
|
43
|
+
files: LibraryFiles;
|
|
44
|
+
/** The ids of the tasks, triggers and rules that use it. */
|
|
45
|
+
owners: string[];
|
|
46
|
+
/** The names those elements go by in a decompile or compile message. */
|
|
47
|
+
names: string[];
|
|
48
|
+
/** The library questions it answers, as {@link libraryQuestion} spells them. */
|
|
49
|
+
questions: string[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* One library question decompile asks, as a string: the `identifyAction` or
|
|
53
|
+
* `identifyEvent` wire it passes, minus the version and activity type (the
|
|
54
|
+
* entry is written at the version asked). For instance
|
|
55
|
+
* `["action","custom-acme","POST","/tickets","ticket"]`.
|
|
56
|
+
*/
|
|
57
|
+
export declare function libraryQuestion(kind: 'action' | 'trigger' | 'event', wire: {
|
|
58
|
+
connectorKey: string;
|
|
59
|
+
httpMethod?: string;
|
|
60
|
+
endpoint?: string;
|
|
61
|
+
objectName?: string;
|
|
62
|
+
eventOperation?: string;
|
|
63
|
+
}): string;
|
|
64
|
+
/**
|
|
65
|
+
* The connector operations `plan` describes and `library` cannot name (see the
|
|
66
|
+
* module comment), one per operation and object. Pure: reads `library`,
|
|
67
|
+
* writes nothing. It reads every connector element of the plan, also one
|
|
68
|
+
* decompile never asks the library about (a placeholder is skipped); decompile
|
|
69
|
+
* writes only the ones it asks for ({@link decompileWithPlanConnectors}).
|
|
70
|
+
*
|
|
71
|
+
* @param plan - The Case plan, as saved (`caseplan.json`).
|
|
72
|
+
* @param library - The library decompile opens: the shipped one plus the `connectors-local` overlay.
|
|
73
|
+
* @returns An empty list when the library names every connector element the plan describes.
|
|
74
|
+
*/
|
|
75
|
+
export declare function planConnectors(plan: unknown, library: Library): PlanConnector[];
|
|
76
|
+
/**
|
|
77
|
+
* Merge `connectors` into the overlay at `overlayDir`, as `registry prepare`
|
|
78
|
+
* merges an operation.
|
|
79
|
+
*/
|
|
80
|
+
export declare function writePlanConnectors(connectors: readonly PlanConnector[], overlayDir: string): void;
|
|
81
|
+
/** What {@link decompileWithPlanConnectors} returns: decompile's result, and the connectors it wrote. */
|
|
82
|
+
export interface PlanConnectorsDecompile<R> {
|
|
83
|
+
result: R;
|
|
84
|
+
/** The connectors written into the overlay, in the order decompile asked for them; empty when none was needed. */
|
|
85
|
+
written: PlanConnector[];
|
|
86
|
+
/** The library the result was decompiled with: the last one opened. */
|
|
87
|
+
library: Library;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Run `decompile` and, each time it fails on a connector question the library
|
|
91
|
+
* cannot answer and the plan describes, write that connector into the overlay
|
|
92
|
+
* and run it again. Only the connectors decompile asks for are written: a
|
|
93
|
+
* connector element it never names through the library (a placeholder, a
|
|
94
|
+
* global event kept verbatim) is not.
|
|
95
|
+
*
|
|
96
|
+
* @param plan - The plan being decompiled.
|
|
97
|
+
* @param open - Opens the library with the overlay at the given directory (`undefined`: none).
|
|
98
|
+
* @param overlayDir - The overlay the library reads, or `undefined` for none yet.
|
|
99
|
+
* @param newOverlayDir - Where the overlay goes when there is none yet, e.g. `.flow-sdk/connectors-local`.
|
|
100
|
+
* @param decompile - The decompile to run, with the library to use.
|
|
101
|
+
*/
|
|
102
|
+
export declare function decompileWithPlanConnectors<R>(plan: unknown, open: (overlayDir: string | undefined) => Library, overlayDir: string | undefined, newOverlayDir: () => string, decompile: (library: Library) => R): PlanConnectorsDecompile<R> & {
|
|
103
|
+
overlayDir: string | undefined;
|
|
104
|
+
};
|
|
105
|
+
export {};
|
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Connector descriptions a Case plan CARRIES: the library entries for the
|
|
3
|
+
* connector elements the library and the `connectors-local` overlay lack, read
|
|
4
|
+
* from what the plan itself saved.
|
|
5
|
+
*
|
|
6
|
+
* Case decompile names every connector task, event trigger and
|
|
7
|
+
* wait-for-connector through the connector library (`identifyAction`,
|
|
8
|
+
* `identifyEvent`). A connector only one tenant has (a Data Service entity
|
|
9
|
+
* such as `uipath-uipath-dataservice CREATED Invoice`, a custom connector, an
|
|
10
|
+
* operation newer than the library) is in no shipped library, so decompile
|
|
11
|
+
* refused the whole plan: `connector trigger event not found in library`. The
|
|
12
|
+
* way past that was `uip maestro registry prepare` against the tenant, which
|
|
13
|
+
* writes the connector into the overlay. Without a tenant, the plan could not
|
|
14
|
+
* be edited at all, though it describes the connector itself.
|
|
15
|
+
*
|
|
16
|
+
* A saved plan carries most of what `prepare` reads from the tenant: the
|
|
17
|
+
* connector key, object, method and path, the activity's instance parameters,
|
|
18
|
+
* its display text, the fields it fills and the response schema. So this
|
|
19
|
+
* module writes the two tenant answers `prepare` reads (the registry node and
|
|
20
|
+
* the Integration Service describe, or for an event the trigger definition)
|
|
21
|
+
* from the plan's own wire, and hands them to the writers `prepare` runs:
|
|
22
|
+
* `extractCanonical`, `applyDescribe`, `assembleEventDefinition`,
|
|
23
|
+
* `planLibrary`, `mergeFilesInto`. Decompile writes the result into the overlay
|
|
24
|
+
* that `check` and `compile` already read. This is the same idea as Flow's
|
|
25
|
+
* carried node definitions (`core/carried-definitions.ts`) and Case's carried
|
|
26
|
+
* fields (`core/carried-connector-fields.ts`): the file's own description is
|
|
27
|
+
* the third source, after the SDK and the library.
|
|
28
|
+
*
|
|
29
|
+
* The rules are the carried fields' rules:
|
|
30
|
+
*
|
|
31
|
+
* - It only fills a gap. Decompile writes an entry only when it asks the
|
|
32
|
+
* library about an element and neither the library nor the overlay can
|
|
33
|
+
* answer ({@link decompileWithPlanConnectors}). An entry whose node type and
|
|
34
|
+
* version a library layer already holds is not written, so a plan's entry
|
|
35
|
+
* never shadows a library one. A later `registry prepare` of the same
|
|
36
|
+
* operation replaces it: the overlay merge drops a plan-described row whose
|
|
37
|
+
* operation (connector, verb, path and object; or connector, object and
|
|
38
|
+
* event) the tenant's entry describes, whatever node type each was written
|
|
39
|
+
* under (`describedOperation` in `registry/prepare/overlay.ts`). The plan's
|
|
40
|
+
* action id is its own making (`curated-create-issue-post` where prepare
|
|
41
|
+
* writes `create-issue`), so a source decompiled before the prepare names an
|
|
42
|
+
* id that is gone; prepare says so, and a fresh decompile names the tenant's.
|
|
43
|
+
* - It describes only what the plan saved. A connector element the plan does
|
|
44
|
+
* not describe (no connector key, object, method and path for an action; no
|
|
45
|
+
* object and event operation for an event) gets nothing, and decompile still
|
|
46
|
+
* refuses it by name.
|
|
47
|
+
* - Every field it declares is optional, and the plan cannot know a field it
|
|
48
|
+
* never used, nor a field's real type and `required`. The tenant's describe
|
|
49
|
+
* can; `registry prepare` stays the way to get it.
|
|
50
|
+
*
|
|
51
|
+
* Each entry is marked `provenance: { source: "case-plan" }`.
|
|
52
|
+
*
|
|
53
|
+
* For instance, a plan whose stage waits for `uipath-uipath-dataservice CREATED
|
|
54
|
+
* Invoice` gets one overlay entry, `uipath.connector.event.uipath-uipath-dataservice.created`
|
|
55
|
+
* for the object `Invoice`, with the event parameters and response fields the
|
|
56
|
+
* subscription saved; decompile then names it as
|
|
57
|
+
* `{ connector: 'uipath-uipath-dataservice', event: 'created', object: 'Invoice' }`.
|
|
58
|
+
*/
|
|
59
|
+
import { extractCanonical } from '../registry/library-build/canonical.js';
|
|
60
|
+
import { applyDescribe, HTTP_METHOD_TO_OPERATION } from '../registry/library-build/enrich.js';
|
|
61
|
+
import { planLibrary } from '../registry/library-build/plan.js';
|
|
62
|
+
import { assembleEventDefinition } from '../registry/prepare/event.js';
|
|
63
|
+
import { activityActionId } from '../registry/prepare/integration-service.js';
|
|
64
|
+
import { mergeFilesInto, PLAN_DESCRIBED_SOURCE } from '../registry/prepare/overlay.js';
|
|
65
|
+
import { ConnectorResolveError } from '../core/connector-resolve-error.js';
|
|
66
|
+
import { ownEntry } from '../core/own-entry.js';
|
|
67
|
+
/** `provenance.source` of every entry this module writes. A `registry prepare` of the same operation replaces such an entry. */
|
|
68
|
+
export const PLAN_CONNECTOR_SOURCE = PLAN_DESCRIBED_SOURCE;
|
|
69
|
+
const JSON_STRING = '=jsonString:';
|
|
70
|
+
const TRIGGER = 'Intsvc.EventTrigger';
|
|
71
|
+
const WAIT = 'Intsvc.WaitForEvent';
|
|
72
|
+
const ACTIVITY = 'Intsvc.ActivityExecution';
|
|
73
|
+
const STAGE = 'case-management:Stage';
|
|
74
|
+
const isObject = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
75
|
+
const presentString = (v) => (typeof v === 'string' && v ? v : undefined);
|
|
76
|
+
function parseJson(text) {
|
|
77
|
+
try {
|
|
78
|
+
return JSON.parse(text);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/** The names an element goes by in a message. */
|
|
85
|
+
function namesOf(element) {
|
|
86
|
+
return [element.displayName, element.name, element.label, element.data?.label, element.display?.label, element.data?.display?.label]
|
|
87
|
+
.filter((n) => typeof n === 'string' && n.trim().length > 2);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Every connector bag in `plan`, with the element that owns it.
|
|
91
|
+
*
|
|
92
|
+
* The owner is the nearest object with an `id` above the bag, but never a stage
|
|
93
|
+
* or the case itself: a bag in an id-less wrapper directly under a stage has no
|
|
94
|
+
* owner.
|
|
95
|
+
*/
|
|
96
|
+
export function planConnectorBags(plan) {
|
|
97
|
+
const out = [];
|
|
98
|
+
const walk = (value, owner) => {
|
|
99
|
+
if (Array.isArray(value)) {
|
|
100
|
+
for (const v of value)
|
|
101
|
+
walk(v, owner);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (!isObject(value))
|
|
105
|
+
return;
|
|
106
|
+
let here = owner;
|
|
107
|
+
if (typeof value.id === 'string')
|
|
108
|
+
here = value === plan || value.type === STAGE ? undefined : { id: value.id, names: namesOf(value) };
|
|
109
|
+
if (Array.isArray(value.context) && value.context.some((row) => row?.name === 'connectorKey')) {
|
|
110
|
+
out.push({ ...(here ? { owner: here.id } : {}), names: here?.names ?? [], bag: value });
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
for (const v of Object.values(value))
|
|
114
|
+
walk(v, here);
|
|
115
|
+
};
|
|
116
|
+
walk(plan, undefined);
|
|
117
|
+
return out;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* The wire facts of one bag, or `undefined` for a bag the plan does not
|
|
121
|
+
* describe well enough to name: a placeholder, an external task, an action
|
|
122
|
+
* without its object, method and path, an event without its object and
|
|
123
|
+
* operation. Those stay refused by name.
|
|
124
|
+
*/
|
|
125
|
+
function wireOf(bag) {
|
|
126
|
+
const rows = new Map(bag.context.filter(isObject).map((row) => [row.name, row]));
|
|
127
|
+
const value = (name) => presentString(rows.get(name)?.value);
|
|
128
|
+
const connectorKey = value('connectorKey');
|
|
129
|
+
const kind = bag.serviceType === TRIGGER ? 'trigger' : bag.serviceType === WAIT ? 'event' : bag.serviceType === ACTIVITY ? 'action' : undefined;
|
|
130
|
+
// A placeholder (`connectorKey: "placeholder"`) names no connector: decompile lifts it as the placeholder.
|
|
131
|
+
if (!connectorKey || !kind || connectorKey === 'placeholder')
|
|
132
|
+
return undefined;
|
|
133
|
+
const metadata = isObject(rows.get('metadata')?.body) ? rows.get('metadata').body : {};
|
|
134
|
+
const apc = isObject(metadata.activityPropertyConfiguration) ? metadata.activityPropertyConfiguration : {};
|
|
135
|
+
const encoded = typeof apc.configuration === 'string' && apc.configuration.startsWith(JSON_STRING);
|
|
136
|
+
const parsed = encoded ? parseJson(apc.configuration.slice(JSON_STRING.length)) : undefined;
|
|
137
|
+
const config = isObject(parsed) ? parsed : {};
|
|
138
|
+
const essential = isObject(config.essentialConfiguration) ? config.essentialConfiguration : {};
|
|
139
|
+
const activity = isObject(metadata.activityMetadata?.activity) ? metadata.activityMetadata.activity : {};
|
|
140
|
+
const activityConfig = typeof activity.configuration === 'string' ? parseJson(activity.configuration) : undefined;
|
|
141
|
+
const instance = isObject(essential.instanceParameters) ? essential.instanceParameters : isObject(activityConfig) ? activityConfig : {};
|
|
142
|
+
const optional = isObject(config.optionalConfiguration) ? config.optionalConfiguration : {};
|
|
143
|
+
const telemetry = isObject(metadata.telemetryData) ? metadata.telemetryData : {};
|
|
144
|
+
const objectName = value('objectName');
|
|
145
|
+
const method = value('method');
|
|
146
|
+
const path = value('path');
|
|
147
|
+
const operation = value('operation');
|
|
148
|
+
if (!objectName)
|
|
149
|
+
return undefined;
|
|
150
|
+
if (kind === 'action' && (!method || !path))
|
|
151
|
+
return undefined;
|
|
152
|
+
if (kind !== 'action' && !operation)
|
|
153
|
+
return undefined;
|
|
154
|
+
return {
|
|
155
|
+
kind, connectorKey, bag, apc, essential, instance, optional, activity, telemetry, objectName, method, path, operation,
|
|
156
|
+
// As decompile reads it (`connectorActivityType`): the saved instance parameters, else the activity's.
|
|
157
|
+
activityType: presentString(essential.instanceParameters?.activityType) ?? (isObject(activityConfig) ? presentString(activityConfig.activityType) : undefined),
|
|
158
|
+
version: encoded ? presentString(essential.instanceParameters?.version) ?? presentString(essential.packageVersion)
|
|
159
|
+
: isObject(activityConfig) ? presentString(activityConfig.version) : undefined,
|
|
160
|
+
connectorName: String(telemetry.connectorName ?? optional.connectorName ?? connectorKey),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/** Whether `library` already names the wire, asked the way decompile asks it. */
|
|
164
|
+
function known(library, w) {
|
|
165
|
+
try {
|
|
166
|
+
if (w.kind === 'action') {
|
|
167
|
+
library.identifyAction({
|
|
168
|
+
connectorKey: w.connectorKey, httpMethod: w.method, endpoint: w.path, objectName: w.objectName,
|
|
169
|
+
version: w.version, activityType: w.activityType,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
library.identifyEvent(w.kind, {
|
|
174
|
+
connectorKey: w.connectorKey, objectName: w.objectName, eventOperation: w.operation,
|
|
175
|
+
eventMode: w.apc.eventMode, version: w.essential.packageVersion,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/** Whether a library layer already holds `nodeType` at `version`, for any object. */
|
|
185
|
+
function nodeTypeTaken(library, nodeType, version) {
|
|
186
|
+
try {
|
|
187
|
+
library.pageSource(nodeType, version);
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
catch (e) {
|
|
191
|
+
return !(e instanceof ConnectorResolveError && e.code === 'CONNECTOR_NOT_IN_LIBRARY');
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* The response JSON schema a plan saved, read back as library fields: the
|
|
196
|
+
* inverse of `responseJsonSchema` (`core/connector-response-schema.ts`). A
|
|
197
|
+
* nested object is `parent.child`, an array of objects `items[*].child`.
|
|
198
|
+
*
|
|
199
|
+
* For instance `{ properties: { CreatedBy: { $ref: '#/definitions/U' } }, definitions: { U: { properties: { Email: { type: 'string' } } } } }`
|
|
200
|
+
* reads as `[{ name: 'CreatedBy.Email', type: 'string' }]`.
|
|
201
|
+
*/
|
|
202
|
+
export function responseSchemaFields(schema) {
|
|
203
|
+
if (!isObject(schema))
|
|
204
|
+
return [];
|
|
205
|
+
const definitions = isObject(schema.definitions) ? schema.definitions : {};
|
|
206
|
+
const out = [];
|
|
207
|
+
const seen = new Set();
|
|
208
|
+
const ref = (p) => (typeof p?.$ref === 'string' && p.$ref.startsWith('#/definitions/') ? definitions[p.$ref.slice(14)] : undefined);
|
|
209
|
+
const titled = (prop) => (typeof prop.title === 'string' && prop.title ? { displayName: prop.title } : {});
|
|
210
|
+
const visit = (properties, prefix, depth) => {
|
|
211
|
+
if (!isObject(properties) || depth > 8)
|
|
212
|
+
return;
|
|
213
|
+
for (const [name, prop] of Object.entries(properties)) {
|
|
214
|
+
if (!isObject(prop))
|
|
215
|
+
continue;
|
|
216
|
+
const path = `${prefix}${name}`;
|
|
217
|
+
const target = ref(prop) ?? (prop.type === 'object' && isObject(prop.properties) ? prop : undefined);
|
|
218
|
+
if (target && !seen.has(target)) {
|
|
219
|
+
seen.add(target);
|
|
220
|
+
visit(target.properties, `${path}.`, depth + 1);
|
|
221
|
+
seen.delete(target);
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
if (prop.type === 'array') {
|
|
225
|
+
const items = ref(prop.items) ?? (isObject(prop.items?.properties) ? prop.items : undefined);
|
|
226
|
+
if (items) {
|
|
227
|
+
visit(items.properties, `${path}[*].`, depth + 1);
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
out.push({ name: `${path}[*]`, type: typeof prop.items?.type === 'string' ? prop.items.type : 'string', ...titled(prop) });
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
out.push({ name: path, type: typeof prop.type === 'string' ? prop.type : 'string', ...titled(prop) });
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
visit(schema.properties, '', 0);
|
|
237
|
+
return out;
|
|
238
|
+
}
|
|
239
|
+
const responseSchemaOf = (bag) => (Array.isArray(bag.outputs) ? bag.outputs : []).find((o) => o?.name === 'response' && isObject(o.body))?.body;
|
|
240
|
+
/** The registry form block `extractCanonical` reads the activity's configuration from. */
|
|
241
|
+
function connectorForm(configuration) {
|
|
242
|
+
return {
|
|
243
|
+
sections: [{
|
|
244
|
+
fields: [{
|
|
245
|
+
componentProps: {
|
|
246
|
+
connectorDetail: { isEnabled: true, targetPlatform: 'CrossPlatform', isExperimental: false, configuration: JSON.stringify(configuration) },
|
|
247
|
+
},
|
|
248
|
+
}],
|
|
249
|
+
}],
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
const LOCATIONS = { body: 'body', query: 'query', path: 'path' };
|
|
253
|
+
/** A field's type as the value the task sends says it; none for a string or an expression, which fit any. */
|
|
254
|
+
function wireType(value) {
|
|
255
|
+
if (Array.isArray(value))
|
|
256
|
+
return 'array';
|
|
257
|
+
if (isObject(value))
|
|
258
|
+
return 'object';
|
|
259
|
+
if (typeof value === 'number')
|
|
260
|
+
return 'number';
|
|
261
|
+
if (typeof value === 'boolean')
|
|
262
|
+
return 'boolean';
|
|
263
|
+
return undefined;
|
|
264
|
+
}
|
|
265
|
+
/** The connector ACTION's two tenant answers: the registry node and the `is resources describe` reply, from what the task saved. */
|
|
266
|
+
function actionAnswers(w, nodeType) {
|
|
267
|
+
const fields = new Map();
|
|
268
|
+
const add = (name, location, type, displayName) => {
|
|
269
|
+
if (typeof name !== 'string' || !name || fields.has(name))
|
|
270
|
+
return;
|
|
271
|
+
fields.set(name, { name, location, ...(type ? { type } : {}), ...(typeof displayName === 'string' && displayName ? { displayName } : {}) });
|
|
272
|
+
};
|
|
273
|
+
// The live connector's field list the Designer saved, then every value the task sends.
|
|
274
|
+
const saved = w.optional.fieldsContainer?.inputFields;
|
|
275
|
+
for (const f of Array.isArray(saved) ? saved : []) {
|
|
276
|
+
if (!isObject(f) || f.request === false)
|
|
277
|
+
continue;
|
|
278
|
+
const location = typeof f.fieldLocation === 'string' ? ownEntry(LOCATIONS, f.fieldLocation) : undefined;
|
|
279
|
+
if (location)
|
|
280
|
+
add(f.name, location, typeof f.type === 'string' ? f.type : undefined, f.displayName);
|
|
281
|
+
}
|
|
282
|
+
for (const m of String(w.path ?? '').matchAll(/\{([^}]+)\}/g))
|
|
283
|
+
add(m[1], 'path', 'string');
|
|
284
|
+
const slot = { pathParameters: 'path', queryParameters: 'query', body: 'body' };
|
|
285
|
+
for (const row of Array.isArray(w.bag.inputs) ? w.bag.inputs : []) {
|
|
286
|
+
const location = typeof row?.name === 'string' ? ownEntry(slot, row.name) : undefined;
|
|
287
|
+
if (!location || !isObject(row.body))
|
|
288
|
+
continue;
|
|
289
|
+
for (const [name, value] of Object.entries(row.body))
|
|
290
|
+
add(name, location, wireType(value));
|
|
291
|
+
}
|
|
292
|
+
const parameters = [...fields.values()].filter((f) => f.location !== 'body')
|
|
293
|
+
.map((f) => ({ name: f.name, type: f.location, dataType: f.type ?? 'string', required: false, ...(f.displayName ? { displayName: f.displayName } : {}) }));
|
|
294
|
+
const multipart = Array.isArray(w.apc.multipartParameters) ? w.apc.multipartParameters : [];
|
|
295
|
+
for (const part of multipart)
|
|
296
|
+
if (isObject(part) && typeof part.name === 'string')
|
|
297
|
+
parameters.push({ name: part.name, type: 'multipart', dataType: part.dataType ?? 'string', required: false });
|
|
298
|
+
const requestFields = [...fields.values()].filter((f) => f.location === 'body')
|
|
299
|
+
.map((f) => ({ name: f.name, required: false, ...(f.type ? { type: f.type } : {}), ...(f.displayName ? { displayName: f.displayName } : {}) }));
|
|
300
|
+
const httpMethod = String(w.instance.httpMethod ?? w.method ?? '').toUpperCase();
|
|
301
|
+
const operation = String(w.essential.operation ?? HTTP_METHOD_TO_OPERATION.get(httpMethod) ?? '');
|
|
302
|
+
const label = String(w.activity.displayName ?? w.objectName);
|
|
303
|
+
const node = {
|
|
304
|
+
nodeType,
|
|
305
|
+
version: w.version ?? '1.0.0',
|
|
306
|
+
category: 'connector',
|
|
307
|
+
tags: ['connector', 'activity'],
|
|
308
|
+
display: { label, description: String(w.activity.description ?? '') },
|
|
309
|
+
model: {
|
|
310
|
+
type: 'bpmn:SendTask',
|
|
311
|
+
serviceType: ACTIVITY,
|
|
312
|
+
context: [{ name: 'connectorKey', value: w.connectorKey }, { name: 'connection' }, { name: 'folderKey' }, { name: 'operation', value: operation }],
|
|
313
|
+
},
|
|
314
|
+
form: connectorForm({ ...w.instance, connectorKey: w.connectorKey, objectName: w.objectName, httpMethod }),
|
|
315
|
+
connectorMethodInfo: { operation, path: w.path, curated: { displayName: String(w.telemetry.objectDisplayName ?? '') } },
|
|
316
|
+
uiPathActivityTypeId: String(w.apc.uiPathActivityTypeId ?? ''),
|
|
317
|
+
};
|
|
318
|
+
const describe = {
|
|
319
|
+
Operation: { Name: operation, Path: w.path, Curated: label },
|
|
320
|
+
DisplayName: String(w.telemetry.objectDisplayName ?? w.objectName),
|
|
321
|
+
Parameters: parameters,
|
|
322
|
+
RequestFields: requestFields,
|
|
323
|
+
ResponseFields: responseSchemaFields(responseSchemaOf(w.bag)),
|
|
324
|
+
};
|
|
325
|
+
return { node, describe };
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* The connector EVENT's `uip is triggers objects` row: the object and its
|
|
329
|
+
* parameters, each in the bucket the subscription saved it in (`queryParams`
|
|
330
|
+
* holds the event bucket, `parameters` the query bucket).
|
|
331
|
+
*/
|
|
332
|
+
function eventObjectRow(w) {
|
|
333
|
+
const body = (Array.isArray(w.bag.inputs) ? w.bag.inputs : []).find((row) => row?.name === 'body')?.body;
|
|
334
|
+
return {
|
|
335
|
+
Name: w.objectName,
|
|
336
|
+
DisplayName: String(w.telemetry.objectDisplayName ?? w.objectName),
|
|
337
|
+
Parameters: [
|
|
338
|
+
...Object.keys(isObject(body?.queryParams) ? body.queryParams : {}).map((name) => ({ Name: name, Type: 'event', DataType: 'string' })),
|
|
339
|
+
...Object.keys(isObject(body?.parameters) ? body.parameters : {}).map((name) => ({ Name: name, Type: 'query', DataType: 'string' })),
|
|
340
|
+
],
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* The activity type of an event's WAIT form, the one the entry is stored as
|
|
345
|
+
* (`uipath.connector.event.*`, as the registry ships it), from what a wire saved.
|
|
346
|
+
* A start's `CuratedTrigger` is its wait form's `CuratedWaitFor`: the library
|
|
347
|
+
* derives the start from the wait (`deriveTriggerForm` in `core/library.ts`),
|
|
348
|
+
* and compile writes a trigger's own kind itself. A generic one keeps its type.
|
|
349
|
+
* Built from a start's wire as saved, a wait-for-connector on the same event
|
|
350
|
+
* would compile to `CuratedTrigger`.
|
|
351
|
+
*/
|
|
352
|
+
function waitActivityType(saved) {
|
|
353
|
+
const type = presentString(saved) ?? 'CuratedWaitFor';
|
|
354
|
+
return type === 'CuratedTrigger' ? 'CuratedWaitFor' : type;
|
|
355
|
+
}
|
|
356
|
+
/** The connector EVENT's registry node (its wait form), from what the subscription saved. */
|
|
357
|
+
function eventNode(w, nodeType) {
|
|
358
|
+
const eventMode = String(w.apc.eventMode ?? w.instance.eventMode ?? '');
|
|
359
|
+
const eventOperation = String(w.operation ?? w.instance.eventOperation ?? '');
|
|
360
|
+
const activityType = waitActivityType(w.instance.activityType);
|
|
361
|
+
return {
|
|
362
|
+
nodeType,
|
|
363
|
+
version: String(w.essential.packageVersion ?? w.instance.version ?? '1.0.0'),
|
|
364
|
+
category: 'connector',
|
|
365
|
+
tags: ['connector', 'trigger'],
|
|
366
|
+
display: { label: String(w.activity.displayName ?? eventOperation), description: String(w.activity.description ?? '') },
|
|
367
|
+
model: {
|
|
368
|
+
type: 'bpmn:ReceiveTask',
|
|
369
|
+
serviceType: WAIT,
|
|
370
|
+
context: [{ name: 'connectorKey', value: w.connectorKey }, { name: 'connection' }, { name: 'folderKey' }, { name: 'operation', value: eventOperation }],
|
|
371
|
+
},
|
|
372
|
+
form: connectorForm({
|
|
373
|
+
connectorKey: w.connectorKey, objectName: w.objectName, activityType, version: String(w.essential.packageVersion ?? '1.0.0'),
|
|
374
|
+
eventOperation, eventMode, supportsStreaming: w.instance.supportsStreaming ?? false,
|
|
375
|
+
}),
|
|
376
|
+
connectorMethodInfo: { operation: eventOperation, curated: { displayName: String(w.telemetry.objectDisplayName ?? '') } },
|
|
377
|
+
eventMode,
|
|
378
|
+
outputResponseDefinition: { fields: responseSchemaFields(responseSchemaOf(w.bag)) },
|
|
379
|
+
uiPathActivityTypeId: String(w.apc.uiPathActivityTypeId ?? ''),
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
const slug = (s) => activityActionId(String(s ?? '')).replace(/[^a-z0-9-]+/g, '-').replace(/^-+|-+$/g, '') || 'op';
|
|
383
|
+
/**
|
|
384
|
+
* One library question decompile asks, as a string: the `identifyAction` or
|
|
385
|
+
* `identifyEvent` wire it passes, minus the version and activity type (the
|
|
386
|
+
* entry is written at the version asked). For instance
|
|
387
|
+
* `["action","custom-acme","POST","/tickets","ticket"]`.
|
|
388
|
+
*/
|
|
389
|
+
export function libraryQuestion(kind, wire) {
|
|
390
|
+
return JSON.stringify(kind === 'action'
|
|
391
|
+
? [kind, wire.connectorKey, String(wire.httpMethod ?? '').toUpperCase(), wire.endpoint ?? '', wire.objectName ?? '']
|
|
392
|
+
: [kind, wire.connectorKey, wire.objectName ?? '', wire.eventOperation ?? '']);
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* The connector operations `plan` describes and `library` cannot name (see the
|
|
396
|
+
* module comment), one per operation and object. Pure: reads `library`,
|
|
397
|
+
* writes nothing. It reads every connector element of the plan, also one
|
|
398
|
+
* decompile never asks the library about (a placeholder is skipped); decompile
|
|
399
|
+
* writes only the ones it asks for ({@link decompileWithPlanConnectors}).
|
|
400
|
+
*
|
|
401
|
+
* @param plan - The Case plan, as saved (`caseplan.json`).
|
|
402
|
+
* @param library - The library decompile opens: the shipped one plus the `connectors-local` overlay.
|
|
403
|
+
* @returns An empty list when the library names every connector element the plan describes.
|
|
404
|
+
*/
|
|
405
|
+
export function planConnectors(plan, library) {
|
|
406
|
+
const out = [];
|
|
407
|
+
const byKey = new Map();
|
|
408
|
+
const actionIds = new Map();
|
|
409
|
+
// A wait-for-connector's wire first: an event entry is stored as its wait form,
|
|
410
|
+
// and the first wire on an operation is the one its entry is built from.
|
|
411
|
+
const bags = planConnectorBags(plan);
|
|
412
|
+
const ordered = [...bags.filter((b) => b.bag.serviceType === WAIT), ...bags.filter((b) => b.bag.serviceType !== WAIT)];
|
|
413
|
+
for (const { owner, names, bag } of ordered) {
|
|
414
|
+
const w = wireOf(bag);
|
|
415
|
+
if (!w || known(library, w))
|
|
416
|
+
continue;
|
|
417
|
+
let entry;
|
|
418
|
+
let node;
|
|
419
|
+
if (w.kind === 'action') {
|
|
420
|
+
// One action id per operation: object and verb, with a counter when two
|
|
421
|
+
// paths share them or a library layer already holds the node type.
|
|
422
|
+
const base = `${slug(w.objectName)}-${slug(w.method)}`;
|
|
423
|
+
const operationKey = JSON.stringify([w.connectorKey, w.method, w.path, w.objectName, w.version]);
|
|
424
|
+
let id = actionIds.get(operationKey);
|
|
425
|
+
if (id === undefined) {
|
|
426
|
+
id = base;
|
|
427
|
+
const taken = (candidate) => [...actionIds.values()].includes(candidate)
|
|
428
|
+
|| nodeTypeTaken(library, `uipath.connector.${w.connectorKey}.${candidate}`, w.version ?? '1.0.0');
|
|
429
|
+
for (let n = 2; taken(id); n++)
|
|
430
|
+
id = `${base}-${n}`;
|
|
431
|
+
actionIds.set(operationKey, id);
|
|
432
|
+
}
|
|
433
|
+
const answers = actionAnswers(w, `uipath.connector.${w.connectorKey}.${id}`);
|
|
434
|
+
node = answers.node;
|
|
435
|
+
const canonical = extractCanonical(node);
|
|
436
|
+
if (!canonical)
|
|
437
|
+
continue;
|
|
438
|
+
canonical.connector.name = w.connectorName;
|
|
439
|
+
entry = applyDescribe(canonical, answers.describe);
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
const nodeType = `uipath.connector.event.${w.connectorKey}.${slug(w.operation)}`;
|
|
443
|
+
const eventDef = eventNode(w, nodeType);
|
|
444
|
+
// An event's node type is the event's name, so one a library layer holds is left to the library.
|
|
445
|
+
if (nodeTypeTaken(library, nodeType, String(eventDef.version)))
|
|
446
|
+
continue;
|
|
447
|
+
const canonical = extractCanonical(eventDef);
|
|
448
|
+
if (!canonical)
|
|
449
|
+
continue;
|
|
450
|
+
canonical.connector.name = w.connectorName;
|
|
451
|
+
// The stored shape `prepare` writes for an event: generic per object, curated as is.
|
|
452
|
+
const definition = assembleEventDefinition(eventDef, { ...canonical, operation: { ...canonical.operation, objectName: w.objectName } }, undefined, eventObjectRow(w), nodeType);
|
|
453
|
+
entry = definition.entry;
|
|
454
|
+
node = definition.node;
|
|
455
|
+
}
|
|
456
|
+
entry.provenance = { source: PLAN_CONNECTOR_SOURCE };
|
|
457
|
+
const question = libraryQuestion(w.kind, { connectorKey: w.connectorKey, httpMethod: w.method, endpoint: w.path, objectName: w.objectName, eventOperation: w.operation });
|
|
458
|
+
// Two wires on one operation give one entry: the first one's.
|
|
459
|
+
const key = JSON.stringify([entry.nodeType, entry.operation?.objectName ?? '', entry.version]);
|
|
460
|
+
let connector = byKey.get(key);
|
|
461
|
+
if (!connector) {
|
|
462
|
+
// One library per entry, so each sidecar is built from its own node (two objects share a node type).
|
|
463
|
+
connector = { entry, files: planLibrary([entry], () => node).files, owners: [], names: [], questions: [] };
|
|
464
|
+
byKey.set(key, connector);
|
|
465
|
+
out.push(connector);
|
|
466
|
+
}
|
|
467
|
+
if (owner && !connector.owners.includes(owner))
|
|
468
|
+
connector.owners.push(owner);
|
|
469
|
+
for (const n of names)
|
|
470
|
+
if (!connector.names.includes(n))
|
|
471
|
+
connector.names.push(n);
|
|
472
|
+
if (!connector.questions.includes(question))
|
|
473
|
+
connector.questions.push(question);
|
|
474
|
+
}
|
|
475
|
+
return out;
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Merge `connectors` into the overlay at `overlayDir`, as `registry prepare`
|
|
479
|
+
* merges an operation.
|
|
480
|
+
*/
|
|
481
|
+
export function writePlanConnectors(connectors, overlayDir) {
|
|
482
|
+
for (const c of connectors)
|
|
483
|
+
mergeFilesInto(c.files, overlayDir);
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* `library`, with every question its `identifyAction` and `identifyEvent`
|
|
487
|
+
* cannot answer recorded in `misses` (as {@link libraryQuestion} spells it).
|
|
488
|
+
* The answers and the errors are the library's own.
|
|
489
|
+
*/
|
|
490
|
+
function recordingMisses(library, misses) {
|
|
491
|
+
const identifyAction = library.identifyAction.bind(library);
|
|
492
|
+
const identifyEvent = library.identifyEvent.bind(library);
|
|
493
|
+
library.identifyAction = (wire) => {
|
|
494
|
+
try {
|
|
495
|
+
return identifyAction(wire);
|
|
496
|
+
}
|
|
497
|
+
catch (e) {
|
|
498
|
+
misses.add(libraryQuestion('action', wire));
|
|
499
|
+
throw e;
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
library.identifyEvent = (kind, wire) => {
|
|
503
|
+
try {
|
|
504
|
+
return identifyEvent(kind, wire);
|
|
505
|
+
}
|
|
506
|
+
catch (e) {
|
|
507
|
+
misses.add(libraryQuestion(kind, wire));
|
|
508
|
+
throw e;
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
return library;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Run `decompile` and, each time it fails on a connector question the library
|
|
515
|
+
* cannot answer and the plan describes, write that connector into the overlay
|
|
516
|
+
* and run it again. Only the connectors decompile asks for are written: a
|
|
517
|
+
* connector element it never names through the library (a placeholder, a
|
|
518
|
+
* global event kept verbatim) is not.
|
|
519
|
+
*
|
|
520
|
+
* @param plan - The plan being decompiled.
|
|
521
|
+
* @param open - Opens the library with the overlay at the given directory (`undefined`: none).
|
|
522
|
+
* @param overlayDir - The overlay the library reads, or `undefined` for none yet.
|
|
523
|
+
* @param newOverlayDir - Where the overlay goes when there is none yet, e.g. `.flow-sdk/connectors-local`.
|
|
524
|
+
* @param decompile - The decompile to run, with the library to use.
|
|
525
|
+
*/
|
|
526
|
+
export function decompileWithPlanConnectors(plan, open, overlayDir, newOverlayDir, decompile) {
|
|
527
|
+
let library = open(overlayDir);
|
|
528
|
+
const candidates = planConnectors(plan, library);
|
|
529
|
+
const written = [];
|
|
530
|
+
for (;;) {
|
|
531
|
+
const misses = new Set();
|
|
532
|
+
try {
|
|
533
|
+
return { result: decompile(recordingMisses(library, misses)), written, library, overlayDir };
|
|
534
|
+
}
|
|
535
|
+
catch (e) {
|
|
536
|
+
const needed = candidates.filter((c) => !written.includes(c) && c.questions.some((q) => misses.has(q)));
|
|
537
|
+
if (!needed.length)
|
|
538
|
+
throw e;
|
|
539
|
+
overlayDir ??= newOverlayDir();
|
|
540
|
+
writePlanConnectors(needed, overlayDir);
|
|
541
|
+
written.push(...needed);
|
|
542
|
+
library = open(overlayDir);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every module the extractor and the generators load, as absolute paths,
|
|
3
|
+
* sorted: what {@link generatorIdentity} hashes. Exported so a test can check
|
|
4
|
+
* the walk reaches every generator module; a module it missed would drop out of
|
|
5
|
+
* the hash without any error.
|
|
6
|
+
*
|
|
7
|
+
* @param here - The URL to resolve the entry modules against.
|
|
8
|
+
*/
|
|
9
|
+
export declare function generatorModules(here?: string): Promise<string[]>;
|
|
10
|
+
/**
|
|
11
|
+
* The sha256 of every module the extractor and the generators load.
|
|
12
|
+
*
|
|
13
|
+
* @param here - The URL to resolve the entry modules against; a parameter so
|
|
14
|
+
* tests can point it at a tree of their own.
|
|
15
|
+
*/
|
|
16
|
+
export declare function generatorIdentity(here?: string): Promise<string>;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity of the code that turns a connector archive into the cached library.
|
|
3
|
+
*
|
|
4
|
+
* `registry pull` keys its cache on the archive and the curated overlay, and
|
|
5
|
+
* reuses an entry whose key matches. The extracted JSON and the generated
|
|
6
|
+
* Markdown are also a function of the extractor and the generators, so an SDK
|
|
7
|
+
* release that changes either would keep serving the old output under the same
|
|
8
|
+
* key, and `--force` was the only way out. This hashes that code, as it runs, so
|
|
9
|
+
* a changed generator gets a new cache entry.
|
|
10
|
+
*
|
|
11
|
+
* The code is found by following the relative imports of the two entry modules
|
|
12
|
+
* (`extractor`, `materializer`), file by file, and hashing each file reached
|
|
13
|
+
* with its path. Running from source, a `.js` specifier is read as the `.ts`
|
|
14
|
+
* beside it. Inside a bundle the entry modules are not separate files, so the
|
|
15
|
+
* bundle itself is hashed: any change to it then counts, which costs an
|
|
16
|
+
* unneeded regeneration but never serves stale output.
|
|
17
|
+
*/
|
|
18
|
+
import { createHash } from "node:crypto";
|
|
19
|
+
import { readFile, stat } from "node:fs/promises";
|
|
20
|
+
import { dirname, relative, resolve } from "node:path";
|
|
21
|
+
import { fileURLToPath } from "node:url";
|
|
22
|
+
/** The modules whose output the cache holds: extraction and generation. */
|
|
23
|
+
const ENTRY_MODULES = ["./extractor.js", "./materializer.js"];
|
|
24
|
+
/** A static or dynamic import, or a re-export, of a relative specifier. */
|
|
25
|
+
const RELATIVE_IMPORT_RE = /(?:\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)["'](\.{1,2}\/[^"']+)["']/g;
|
|
26
|
+
async function isFileAsync(path) {
|
|
27
|
+
try {
|
|
28
|
+
return (await stat(path)).isFile();
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** The file a specifier names, or its `.ts` source when running from source. */
|
|
35
|
+
async function moduleFile(path) {
|
|
36
|
+
if (await isFileAsync(path))
|
|
37
|
+
return path;
|
|
38
|
+
const source = path.replace(/\.js$/, ".ts");
|
|
39
|
+
return source !== path && (await isFileAsync(source)) ? source : undefined;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Every module the extractor and the generators load, as absolute paths,
|
|
43
|
+
* sorted: what {@link generatorIdentity} hashes. Exported so a test can check
|
|
44
|
+
* the walk reaches every generator module; a module it missed would drop out of
|
|
45
|
+
* the hash without any error.
|
|
46
|
+
*
|
|
47
|
+
* @param here - The URL to resolve the entry modules against.
|
|
48
|
+
*/
|
|
49
|
+
export async function generatorModules(here = import.meta.url) {
|
|
50
|
+
const self = fileURLToPath(here);
|
|
51
|
+
const root = dirname(self);
|
|
52
|
+
const pending = [];
|
|
53
|
+
for (const specifier of ENTRY_MODULES) {
|
|
54
|
+
const file = await moduleFile(resolve(root, specifier));
|
|
55
|
+
if (file !== undefined)
|
|
56
|
+
pending.push(file);
|
|
57
|
+
}
|
|
58
|
+
// Bundled: the entry modules are inside this file, so it is the code.
|
|
59
|
+
if (pending.length === 0)
|
|
60
|
+
pending.push(self);
|
|
61
|
+
const seen = new Set();
|
|
62
|
+
while (pending.length > 0) {
|
|
63
|
+
const file = pending.pop();
|
|
64
|
+
if (seen.has(file))
|
|
65
|
+
continue;
|
|
66
|
+
seen.add(file);
|
|
67
|
+
const text = await readFile(file, "utf8");
|
|
68
|
+
for (const match of text.matchAll(RELATIVE_IMPORT_RE)) {
|
|
69
|
+
const next = await moduleFile(resolve(dirname(file), match[1]));
|
|
70
|
+
if (next !== undefined && !seen.has(next))
|
|
71
|
+
pending.push(next);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return [...seen].sort();
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The sha256 of every module the extractor and the generators load.
|
|
78
|
+
*
|
|
79
|
+
* @param here - The URL to resolve the entry modules against; a parameter so
|
|
80
|
+
* tests can point it at a tree of their own.
|
|
81
|
+
*/
|
|
82
|
+
export async function generatorIdentity(here = import.meta.url) {
|
|
83
|
+
const root = dirname(fileURLToPath(here));
|
|
84
|
+
const hash = createHash("sha256");
|
|
85
|
+
for (const file of await generatorModules(here)) {
|
|
86
|
+
hash.update(relative(root, file));
|
|
87
|
+
hash.update("\0");
|
|
88
|
+
hash.update(await readFile(file));
|
|
89
|
+
hash.update("\0");
|
|
90
|
+
}
|
|
91
|
+
return hash.digest("hex");
|
|
92
|
+
}
|
|
@@ -27,7 +27,7 @@ import { planLibrary } from "../library-build/plan.js";
|
|
|
27
27
|
import { recordByoaVerification } from "./byoa-ledger.js";
|
|
28
28
|
import { ConnectionRefusal, byoaConnections, byoaListing, restoreBindings } from "./connections.js";
|
|
29
29
|
import { writeResolutions } from "./ledger.js";
|
|
30
|
-
import { PREPARE_COMMAND, PrepareRefusal, byoaListingFailedMessage, byoaRecordedLine, byoaRequiredMessage, describeFallbackWarning, generatedModulesLine, eventAllObjectsMessage, eventNextLine, eventParentFieldsMessage, eventSubscription, eventSummaryLine, filterableFieldsLine, genericEventNeedsObjectMessage, lookupVocabularyLines, objectNoteLine, objectOnCuratedEventMessage, objectRecordedLine, warnLine, webhookNoteLines, } from "./messages.js";
|
|
30
|
+
import { PREPARE_COMMAND, PrepareRefusal, byoaListingFailedMessage, byoaRecordedLine, byoaRequiredMessage, describeFallbackWarning, generatedModulesLine, eventAllObjectsMessage, eventNextLine, eventParentFieldsMessage, eventSubscription, eventSummaryLine, filterableFieldsLine, genericEventNeedsObjectMessage, lookupVocabularyLines, objectNoteLine, objectOnCuratedEventMessage, objectRecordedLine, warnLine, webhookNoteLines, planRowReplacedLine, } from "./messages.js";
|
|
31
31
|
import { RESOLUTIONS_FILENAME, matchObject, recordObjectResolution } from "./objects.js";
|
|
32
32
|
import { lookupSpecsFromOverlay, mergeFilesInto } from "./overlay.js";
|
|
33
33
|
import { regenerateDescriptors } from "./regenerate.js";
|
|
@@ -227,7 +227,8 @@ export async function prepareEvent(ctx, options) {
|
|
|
227
227
|
const plan = planLibrary([definition.entry], () => definition.node);
|
|
228
228
|
for (const line of plan.warnings)
|
|
229
229
|
warn(line);
|
|
230
|
-
mergeFilesInto(plan.files, out)
|
|
230
|
+
for (const nodeType of mergeFilesInto(plan.files, out).replacedPlanRows)
|
|
231
|
+
info(planRowReplacedLine(nodeType, eventNodeType));
|
|
231
232
|
if (byoaRow !== undefined) {
|
|
232
233
|
// What `check` and `compile` look for before they accept this event on this
|
|
233
234
|
// connection: the proof that the live check above ran and passed.
|
|
@@ -322,4 +322,13 @@ export declare function descriptorUsageFallbackLines(sourcePosix: string): strin
|
|
|
322
322
|
export declare function descriptorUsageUnparsedLines(sourcePosix: string, descriptorName: string): string[];
|
|
323
323
|
/** The ready-to-paste handoff for a module with exactly one descriptor. */
|
|
324
324
|
export declare function descriptorUsageLines(descriptorName: string, importPath: string, requiredFields: ReadonlyArray<readonly [name: string, type: string]>, boundConnection: string, boundFolder: string): string[];
|
|
325
|
+
/**
|
|
326
|
+
* A plan-described entry (written by `case decompile` from the plan's own saved
|
|
327
|
+
* configuration) that this prepare's tenant description of the same operation
|
|
328
|
+
* replaced. A source decompiled against it still names the plan's operation id,
|
|
329
|
+
* which no layer has now; renaming it to the tenant's is all it needs, and
|
|
330
|
+
* keeps the edits made to that source. For instance
|
|
331
|
+
* `rename "curated-create-issue-post" to "create-issue" in a source decompiled earlier, or decompile the plan again`.
|
|
332
|
+
*/
|
|
333
|
+
export declare function planRowReplacedLine(replaced: string, preparedNodeType: string): string;
|
|
325
334
|
export {};
|
|
@@ -772,3 +772,18 @@ export function descriptorUsageLines(descriptorName, importPath, requiredFields,
|
|
|
772
772
|
"operation and object identity even when the baked action id differs",
|
|
773
773
|
];
|
|
774
774
|
}
|
|
775
|
+
/**
|
|
776
|
+
* A plan-described entry (written by `case decompile` from the plan's own saved
|
|
777
|
+
* configuration) that this prepare's tenant description of the same operation
|
|
778
|
+
* replaced. A source decompiled against it still names the plan's operation id,
|
|
779
|
+
* which no layer has now; renaming it to the tenant's is all it needs, and
|
|
780
|
+
* keeps the edits made to that source. For instance
|
|
781
|
+
* `rename "curated-create-issue-post" to "create-issue" in a source decompiled earlier, or decompile the plan again`.
|
|
782
|
+
*/
|
|
783
|
+
export function planRowReplacedLine(replaced, preparedNodeType) {
|
|
784
|
+
if (replaced === preparedNodeType)
|
|
785
|
+
return ` replaced the plan's own description of ${replaced} with the tenant's`;
|
|
786
|
+
const op = (nodeType) => nodeType.split('.').at(-1) ?? nodeType;
|
|
787
|
+
return ` replaced the plan's own description of this operation (${replaced}) with the tenant's ${preparedNodeType}: `
|
|
788
|
+
+ `rename "${op(replaced)}" to "${op(preparedNodeType)}" in a source decompiled earlier, or decompile the plan again`;
|
|
789
|
+
}
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import { type LookupStrategy } from "../lookup-specs.js";
|
|
2
2
|
export declare const INDEX_FILENAME = "index.json";
|
|
3
3
|
export declare const DESCRIPTORS_ROOT = "descriptors";
|
|
4
|
+
/**
|
|
5
|
+
* `provenance.source` of an overlay entry described from a saved plan, not from
|
|
6
|
+
* the tenant (`case/plan-connectors.ts`). A tenant-described entry for the same
|
|
7
|
+
* operation replaces it on merge ({@link mergeFilesInto}).
|
|
8
|
+
*/
|
|
9
|
+
export declare const PLAN_DESCRIBED_SOURCE = "case-plan";
|
|
10
|
+
/**
|
|
11
|
+
* The operation an entry describes, whatever node type it was written under:
|
|
12
|
+
* an action by connector, verb, path and object, an event by connector, object
|
|
13
|
+
* and event operation. A plan-described entry gets an id of its own making
|
|
14
|
+
* (`curated-create-issue-post`) where `prepare` writes the tenant's
|
|
15
|
+
* (`create-issue`), so the node type cannot tell that the two describe one
|
|
16
|
+
* operation; this can. `undefined` for an entry that names no operation.
|
|
17
|
+
*/
|
|
18
|
+
export declare function describedOperation(entry: unknown, row?: Record<string, unknown>): string | undefined;
|
|
4
19
|
/**
|
|
5
20
|
* `_variant_key`: identity for one resolvable activity schema variant. Keying
|
|
6
21
|
* only by nodeType made the last prepared object overwrite every earlier one.
|
|
@@ -46,9 +61,14 @@ export type LibraryFiles = ReadonlyMap<string, string | Uint8Array>;
|
|
|
46
61
|
* `files` must carry `index.json`; every other file is copied under
|
|
47
62
|
* `descriptors/` (a nested `index.json` is skipped, as the Python's walk did).
|
|
48
63
|
*/
|
|
49
|
-
export declare function mergeFilesInto(files: LibraryFiles, dst: string):
|
|
64
|
+
export declare function mergeFilesInto(files: LibraryFiles, dst: string): MergeResult;
|
|
65
|
+
/** What {@link mergeFilesInto} did beyond adding the new rows. */
|
|
66
|
+
export interface MergeResult {
|
|
67
|
+
/** Node types of plan-described rows a tenant description of the same operation replaced. */
|
|
68
|
+
replacedPlanRows: string[];
|
|
69
|
+
}
|
|
50
70
|
/** `merge_into(src, dst)`: merge a freshly written single-op library directory into the overlay. */
|
|
51
|
-
export declare function mergeInto(src: string, dst: string):
|
|
71
|
+
export declare function mergeInto(src: string, dst: string): MergeResult;
|
|
52
72
|
/** `_overlay_has_generic_expanded`: does the overlay hold ANY `GenericExpanded` entry, from any prepare? */
|
|
53
73
|
export declare function overlayHasGenericExpanded(out: string): boolean;
|
|
54
74
|
/**
|
|
@@ -35,6 +35,52 @@ import { afterWrites, existsSync, mkdirSync, readFileSync, stagedReadText, write
|
|
|
35
35
|
import { isPlainObject, pyGet, pyOr, pyStrAny, pyTruthy, pyTypeName } from "./support.js";
|
|
36
36
|
export const INDEX_FILENAME = "index.json";
|
|
37
37
|
export const DESCRIPTORS_ROOT = "descriptors";
|
|
38
|
+
/**
|
|
39
|
+
* `provenance.source` of an overlay entry described from a saved plan, not from
|
|
40
|
+
* the tenant (`case/plan-connectors.ts`). A tenant-described entry for the same
|
|
41
|
+
* operation replaces it on merge ({@link mergeFilesInto}).
|
|
42
|
+
*/
|
|
43
|
+
export const PLAN_DESCRIBED_SOURCE = "case-plan";
|
|
44
|
+
/**
|
|
45
|
+
* The operation an entry describes, whatever node type it was written under:
|
|
46
|
+
* an action by connector, verb, path and object, an event by connector, object
|
|
47
|
+
* and event operation. A plan-described entry gets an id of its own making
|
|
48
|
+
* (`curated-create-issue-post`) where `prepare` writes the tenant's
|
|
49
|
+
* (`create-issue`), so the node type cannot tell that the two describe one
|
|
50
|
+
* operation; this can. `undefined` for an entry that names no operation.
|
|
51
|
+
*/
|
|
52
|
+
export function describedOperation(entry, row = {}) {
|
|
53
|
+
if (!isPlainObject(entry))
|
|
54
|
+
return undefined;
|
|
55
|
+
const operation = isPlainObject(entry.operation) ? entry.operation : {};
|
|
56
|
+
const connector = isPlainObject(entry.connector) ? entry.connector : {};
|
|
57
|
+
const key = pyStrAny(pyOr(pyGet(connector, "key", null), pyGet(row, "connectorKey", "")));
|
|
58
|
+
const nodeType = pyStrAny(pyOr(pyGet(entry, "nodeType", null), pyGet(row, "nodeType", "")));
|
|
59
|
+
const objectName = pyStrAny(pyOr(pyGet(operation, "objectName", null), pyGet(row, "objectName", "")));
|
|
60
|
+
if (!key)
|
|
61
|
+
return undefined;
|
|
62
|
+
const upper = (v) => pyStrAny(v ?? "").toUpperCase();
|
|
63
|
+
if (isEventNodeType(nodeType)) {
|
|
64
|
+
const event = upper(pyOr(pyGet(operation, "eventOperation", null), pyOr(pyGet(operation, "name", null), pyGet(row, "operationName", ""))));
|
|
65
|
+
return event ? JSON.stringify([key, "event", objectName, event]) : undefined;
|
|
66
|
+
}
|
|
67
|
+
// A prepared entry may carry the route as `pathTemplate` alone (`path: ""`).
|
|
68
|
+
const path = pyStrAny(pyOr(pyGet(operation, "path", null), pyGet(operation, "pathTemplate", "")));
|
|
69
|
+
return path ? JSON.stringify([key, "action", upper(pyGet(operation, "httpMethod", "")), path, objectName]) : undefined;
|
|
70
|
+
}
|
|
71
|
+
/** The entry file a row names, parsed, or `undefined` when it cannot be read. */
|
|
72
|
+
function rowEntry(dst, row) {
|
|
73
|
+
if (!isPlainObject(row) || typeof row.path !== "string")
|
|
74
|
+
return undefined;
|
|
75
|
+
try {
|
|
76
|
+
const parsed = JSON.parse(readFileSync(join(dst, ...descriptorOverlayPath(row.path).split("/")), "utf8"));
|
|
77
|
+
return isPlainObject(parsed) ? parsed : undefined;
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const planDescribed = (entry) => isPlainObject(entry?.provenance) && entry.provenance.source === PLAN_DESCRIBED_SOURCE;
|
|
38
84
|
/**
|
|
39
85
|
* `_variant_key`: identity for one resolvable activity schema variant. Keying
|
|
40
86
|
* only by nodeType made the last prepared object overwrite every earlier one.
|
|
@@ -221,7 +267,38 @@ export function mergeFilesInto(files, dst) {
|
|
|
221
267
|
throw new TypeError("index.json: \"entries\" is not a list");
|
|
222
268
|
migrateLegacyDescriptorRoots(dst, dstEntries);
|
|
223
269
|
const srcEntries = isPlainObject(srcIdx) ? pyGet(srcIdx, "entries", []) : [];
|
|
224
|
-
|
|
270
|
+
const srcRows = Array.isArray(srcEntries) ? srcEntries : [];
|
|
271
|
+
// A tenant description replaces the plan's description of the same operation,
|
|
272
|
+
// whatever node type each was written under: one operation, one row.
|
|
273
|
+
const text = (rel) => {
|
|
274
|
+
const content = typeof rel === "string" ? files.get(rel) : undefined;
|
|
275
|
+
return content === undefined ? undefined : typeof content === "string" ? content : Buffer.from(content).toString("utf8");
|
|
276
|
+
};
|
|
277
|
+
const described = new Set(srcRows.flatMap((row) => {
|
|
278
|
+
let entry;
|
|
279
|
+
try {
|
|
280
|
+
entry = JSON.parse(text(isPlainObject(row) ? row.path : undefined) ?? "null");
|
|
281
|
+
}
|
|
282
|
+
catch {
|
|
283
|
+
return [];
|
|
284
|
+
}
|
|
285
|
+
if (!isPlainObject(entry) || planDescribed(entry))
|
|
286
|
+
return [];
|
|
287
|
+
const op = describedOperation(entry, row);
|
|
288
|
+
return op === undefined ? [] : [op];
|
|
289
|
+
}));
|
|
290
|
+
const replaced = [];
|
|
291
|
+
const kept = described.size === 0 ? dstEntries : dstEntries.filter((row) => {
|
|
292
|
+
const entry = rowEntry(dst, row);
|
|
293
|
+
if (!planDescribed(entry))
|
|
294
|
+
return true;
|
|
295
|
+
const op = describedOperation(entry, row);
|
|
296
|
+
if (op === undefined || !described.has(op))
|
|
297
|
+
return true;
|
|
298
|
+
replaced.push(pyStrAny(pyGet(row, "nodeType", "")));
|
|
299
|
+
return false;
|
|
300
|
+
});
|
|
301
|
+
dstIdx.entries = mergeIndexEntries(kept, srcRows);
|
|
225
302
|
writeInsideSync(dst, join(dst, INDEX_FILENAME), formatOverlayIndex(dstIdx));
|
|
226
303
|
for (const [rel, content] of files) {
|
|
227
304
|
if (basename(rel) === INDEX_FILENAME)
|
|
@@ -230,6 +307,7 @@ export function mergeFilesInto(files, dst) {
|
|
|
230
307
|
mkdirSync(dirname(out), { recursive: true });
|
|
231
308
|
writeInsideSync(dst, out, content);
|
|
232
309
|
}
|
|
310
|
+
return { replacedPlanRows: replaced };
|
|
233
311
|
}
|
|
234
312
|
/** Every file under `root`, as `POSIX-relative path → bytes`. */
|
|
235
313
|
function readTree(root) {
|
|
@@ -248,7 +326,7 @@ function readTree(root) {
|
|
|
248
326
|
}
|
|
249
327
|
/** `merge_into(src, dst)`: merge a freshly written single-op library directory into the overlay. */
|
|
250
328
|
export function mergeInto(src, dst) {
|
|
251
|
-
mergeFilesInto(readTree(src), dst);
|
|
329
|
+
return mergeFilesInto(readTree(src), dst);
|
|
252
330
|
}
|
|
253
331
|
/** `_overlay_has_generic_expanded`: does the overlay hold ANY `GenericExpanded` entry, from any prepare? */
|
|
254
332
|
export function overlayHasGenericExpanded(out) {
|
|
@@ -43,7 +43,7 @@ import { prepareEvent } from "./event.js";
|
|
|
43
43
|
import { integrationServiceEntry } from "./integration-service.js";
|
|
44
44
|
import { descriptorUsage } from "./handoff.js";
|
|
45
45
|
import { ResolutionsExhausted, allParentsResolved, resolvedParentValues, writeResolutions } from "./ledger.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";
|
|
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, planRowReplacedLine, } from "./messages.js";
|
|
47
47
|
import { ObjectMatchRefusal, RESOLUTIONS_FILENAME, matchObject, recordObjectResolution } from "./objects.js";
|
|
48
48
|
import { countInputFields, keepPreparedSchema, lookupSpecsFromOverlay, mergeFilesInto, parentFields as overlayParentFields, schemaActionParents, } from "./overlay.js";
|
|
49
49
|
import { declaredParents, objectActionRequest, objectActionSpecs, parseFields } from "./parents.js";
|
|
@@ -530,7 +530,8 @@ async function prepareOnConnection(options, ports, connected, registryRefresh) {
|
|
|
530
530
|
warn(line);
|
|
531
531
|
const kept = keepPreparedSchema(out, entryNodeType, plan.files, parentFields, objectName);
|
|
532
532
|
if (kept === undefined)
|
|
533
|
-
mergeFilesInto(plan.files, out)
|
|
533
|
+
for (const replaced of mergeFilesInto(plan.files, out).replacedPlanRows)
|
|
534
|
+
info(planRowReplacedLine(replaced, entryNodeType));
|
|
534
535
|
// The object decision is the FIRST resolution — recorded before any lookup
|
|
535
536
|
// rows, because it is their prerequisite.
|
|
536
537
|
if (objectDecision !== undefined) {
|
|
@@ -7,6 +7,7 @@ import { CURRENT_LINK, LIBRARY_JSON_DIR, LIBRARY_MARKDOWN_DIR, cacheEntry, libra
|
|
|
7
7
|
import { extractLibrary } from "./extractor.js";
|
|
8
8
|
import { materializeRegistry } from "./materializer.js";
|
|
9
9
|
import { curatedOverlayIdentity } from "./curated-overlay.js";
|
|
10
|
+
import { generatorIdentity } from "./generator-identity.js";
|
|
10
11
|
import { WORK_DIR, workPath } from "../workdir.js";
|
|
11
12
|
/**
|
|
12
13
|
* Fetch the published connector library into the shared cache, and generate the
|
|
@@ -191,12 +192,17 @@ async function archiveIdentity(archive) {
|
|
|
191
192
|
return archive.checksum;
|
|
192
193
|
return createHash("sha256").update(await readFile(archive.path)).digest("hex");
|
|
193
194
|
}
|
|
194
|
-
/**
|
|
195
|
-
function
|
|
195
|
+
/**
|
|
196
|
+
* The extracted library and its Markdown are a function of the dump, the SDK's
|
|
197
|
+
* corrections, and the SDK code that extracts and generates them.
|
|
198
|
+
*/
|
|
199
|
+
function libraryIdentity(archiveSha256, overlaySha256, generatorSha256) {
|
|
196
200
|
return createHash("sha256")
|
|
197
201
|
.update(archiveSha256)
|
|
198
202
|
.update("\0")
|
|
199
203
|
.update(overlaySha256)
|
|
204
|
+
.update("\0")
|
|
205
|
+
.update(generatorSha256)
|
|
200
206
|
.digest("hex");
|
|
201
207
|
}
|
|
202
208
|
async function isCurrentLibrary(libraryPath, sha256) {
|
|
@@ -210,11 +216,12 @@ async function isCurrentLibrary(libraryPath, sha256) {
|
|
|
210
216
|
return false;
|
|
211
217
|
}
|
|
212
218
|
}
|
|
213
|
-
async function writeSource(libraryPath, archive, sha256, archiveSha256, overlaySha256) {
|
|
219
|
+
async function writeSource(libraryPath, archive, sha256, archiveSha256, overlaySha256, generatorSha256) {
|
|
214
220
|
writeJsonFile(join(libraryPath, SOURCE_FILE), {
|
|
215
221
|
sha256,
|
|
216
222
|
archiveSha256,
|
|
217
223
|
overlaySha256,
|
|
224
|
+
generatorSha256,
|
|
218
225
|
url: archive.url ?? null,
|
|
219
226
|
archive: archive.checksum ? undefined : archive.path,
|
|
220
227
|
pulledAt: new Date().toISOString(),
|
|
@@ -317,7 +324,8 @@ export async function run(argv) {
|
|
|
317
324
|
const archive = await resolveArchive(argv, cacheDir, force);
|
|
318
325
|
const archiveSha256 = await archiveIdentity(archive);
|
|
319
326
|
const overlaySha256 = await curatedOverlayIdentity();
|
|
320
|
-
const
|
|
327
|
+
const generatorSha256 = await generatorIdentity();
|
|
328
|
+
const sha256 = libraryIdentity(archiveSha256, overlaySha256, generatorSha256);
|
|
321
329
|
const entry = cacheEntry(sha256, cacheDir);
|
|
322
330
|
// Destination overrides: a caller can still put the trees somewhere of their
|
|
323
331
|
// own choosing instead of in the cache.
|
|
@@ -340,7 +348,7 @@ export async function run(argv) {
|
|
|
340
348
|
await rm(libraryPath, { recursive: true, force: true });
|
|
341
349
|
await mkdir(join(libraryPath, ".."), { recursive: true });
|
|
342
350
|
await rename(staging, libraryPath);
|
|
343
|
-
await writeSource(libraryPath, archive, sha256, archiveSha256, overlaySha256);
|
|
351
|
+
await writeSource(libraryPath, archive, sha256, archiveSha256, overlaySha256, generatorSha256);
|
|
344
352
|
}
|
|
345
353
|
// Which descriptors this project will actually import. Generating all 30
|
|
346
354
|
// costs 1.1 MB in someone's repository for operations they never call.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/maestro-builder-sdk",
|
|
3
|
-
"version": "6.96.
|
|
3
|
+
"version": "6.96.4",
|
|
4
4
|
"description": "Build UiPath Flow, Case, and BPMN artifacts by writing TypeScript.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://docs.uipath.com/maestro",
|
|
@@ -113,5 +113,5 @@
|
|
|
113
113
|
"@types/node": "^22.7.0",
|
|
114
114
|
"esbuild": "^0.28.1"
|
|
115
115
|
},
|
|
116
|
-
"gitref": "
|
|
116
|
+
"gitref": "0439ae5d0fdb447fb350759a56d3ffd7f8c859dd"
|
|
117
117
|
}
|