@uipath/maestro-builder-sdk 6.117.3 → 6.118.0

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.
@@ -41,6 +41,9 @@ import { flagValue, runWhenInvokedDirectly } from './cli-run.js';
41
41
  import { connectionResources, inlineAgentResources, mergeBindingsV2, projectBindingRows, refreshInlineAgentRows } from './bindings-v2.js';
42
42
  import { readBindingsV2, readInlineAgentFiles } from './bindings-v2-files.js';
43
43
  import { readSolutionProjects } from './solution-projects-files.js';
44
+ import { provisionIdpProcessors } from './idp-processor-files.js';
45
+ import { idpProcessorBindingRows, withIdpProcessorRows } from './nodes/document/flow/family.js';
46
+ import { isRecord } from './core/node-envelope.js';
44
47
  import { ensureTypeScriptRuntime } from './node-runtime.js';
45
48
  import { defaultBindingsFile, defaultResourcesFile } from './workdir.js';
46
49
  import { readCliResources } from './registry/prepare/resources.js';
@@ -49,7 +52,7 @@ import { flowSources, projectMainFlow, resourceSourcesOfOtherFlows } from './pro
49
52
  import { fnv1aX4Uuid } from './core/stable-id.js';
50
53
  import { cliSpelling } from './core/cli-spelling.js';
51
54
  import { readNodeCatalog } from './node-catalog-files.js';
52
- import { secondFlowWarning } from './project-flows.js';
55
+ import { flowProjectOf, secondFlowWarning } from './project-flows.js';
53
56
  /** An agent folder name: a uuid, any case. */
54
57
  const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
55
58
  export async function run(argv) {
@@ -222,6 +225,19 @@ export async function run(argv) {
222
225
  }
223
226
  // Reported before the first write, so a write that throws still carries it.
224
227
  reportDiagnostics(diagnostics);
228
+ // Each Extract document step's IDP processor (#1984): its resource file in the
229
+ // solution, and the processor's name on the node — what `nodes create` leaves.
230
+ // Only for the flow the project packs: a candidate compiled beside the project
231
+ // (the brownfield loop's baseline/edited files) or a second `.flow` is not
232
+ // deployed, and must not rewrite the solution's processors.
233
+ // The project is the nearest folder holding `project.uiproj`, so a main flow
234
+ // under `content/` counts; a flow the project does not name as its main one
235
+ // only counts when it sits at the project's root and the project names none.
236
+ const projectDir = flowProjectOf(resolve(out));
237
+ const mainFlow = projectDir !== undefined ? projectMainFlow(projectDir).file : undefined;
238
+ const packsThisFlow = projectDir !== undefined
239
+ && (mainFlow !== undefined ? resolve(mainFlow) === resolve(out) : projectDir === outDir);
240
+ const processors = packsThisFlow ? provisionIdpProcessors(flowJson, projectDir) : undefined;
225
241
  writeJsonFile(out, flowJson);
226
242
  console.log(`compile: wrote ${out} (${flowJson.nodes.length} nodes, ${flowJson.edges.length} edges)`);
227
243
  const written = [];
@@ -231,6 +247,12 @@ export async function run(argv) {
231
247
  console.log(`compile: wrote ${sidecar.path}`);
232
248
  written.push(target);
233
249
  }
250
+ for (const path of processors?.written ?? [])
251
+ console.log(`compile: wrote ${path} (IDP processor)`);
252
+ for (const why of processors?.skipped ?? [])
253
+ console.error(`compile: did not write the IDP processor ${why}`);
254
+ if (processors?.pending !== undefined)
255
+ console.log(`compile: ${processors.pending}`);
234
256
  // A re-homed agent's folder starts as a copy of the folder it came from, minus
235
257
  // what this compile just wrote (its `agent.json`, the resources it derives)
236
258
  // and minus every `resources/<id>/` this flow's nodes do not name — copying
@@ -323,7 +345,10 @@ export async function run(argv) {
323
345
  // `project.uiproj` is what makes the output directory a project rather than
324
346
  // somewhere a `.flow` was merely dropped, and littering a scratch directory
325
347
  // with a resource declaration nothing reads would be worse than not writing it.
326
- if (existsSync(join(outDir, 'project.uiproj'))) {
348
+ // Also for a project's main flow below its root (`MainFile: "content/Intake.flow"`),
349
+ // whose sidecar sits beside it, as the CLI's `regenerateBindingsFile` writes it.
350
+ const nestedMain = packsThisFlow && !inProject;
351
+ if (inProject || nestedMain) {
327
352
  const sidecarPath = join(outDir, 'bindings_v2.json');
328
353
  // A connection two of this flow's nodes type differently is refused here,
329
354
  // whichever flow the sidecar declares.
@@ -337,7 +362,8 @@ export async function run(argv) {
337
362
  // pack would take whichever the file system lists first.
338
363
  const self = resolve(out);
339
364
  const ownFile = basename(self);
340
- const main = projectMainFlow(outDir);
365
+ // A nested main flow is the one flow declared: it is its project's main one.
366
+ const main = nestedMain ? { file: resolve(out), ambiguous: [] } : projectMainFlow(outDir);
341
367
  const flowAt = (path) => ({
342
368
  file: relative(outDir, path),
343
369
  flow: resolve(path) === self ? flowJson : readJsonOrUndefined(path),
@@ -362,6 +388,9 @@ export async function run(argv) {
362
388
  console.error(`compile: could not read the connections of ${file}; keeping the bindings_v2.json rows this compile does not derive, `
363
389
  + 'since some may be its. Fix or recompile that flow to re-derive them.');
364
390
  }
391
+ // The `idpProcessor` row of each processor the declared flows' Extract
392
+ // document steps name, as pack derives it (#1984).
393
+ const processorRows = rowFlows.flatMap((f) => idpProcessorBindingRows(isRecord(f.flow) ? f.flow : {}, processors?.namesByKey));
365
394
  const existing = readBindingsV2(sidecarPath);
366
395
  // Each inline agent's own rows (process, index, app, … — #962), derived from
367
396
  // the agent directory as it now stands on disk, the way `uip agent refresh
@@ -388,15 +417,16 @@ export async function run(argv) {
388
417
  const agentRows = agentFiles.map((files) => inlineAgentResources(files));
389
418
  // Nothing to declare and nothing already declared — do not create an empty
390
419
  // file for a flow that has no resources at all.
391
- if (connections.length > 0 || entityRows.length > 0 || existing !== undefined || agentRows.some((rows) => rows.length > 0)) {
420
+ if (connections.length > 0 || entityRows.length > 0 || processorRows.length > 0 || existing !== undefined || agentRows.some((rows) => rows.length > 0)) {
392
421
  const merged = mergeBindingsV2(existing, connections, entityRows, { keepUnderived: unreadable.length > 0 });
393
- merged.resources = refreshInlineAgentRows(merged.resources, agentFiles, removedResources);
422
+ merged.resources = withIdpProcessorRows(refreshInlineAgentRows(merged.resources, agentFiles, removedResources), processorRows, { keepUnderived: unreadable.length > 0 });
394
423
  writeJsonFile(sidecarPath, merged);
395
- const derived = new Set([...connections, ...entityRows, ...agentRows.flat()].map((r) => `${r.resource}\u0000${r.key}`));
396
- const agentCount = merged.resources.filter((r) => r.resource !== 'connection' && r.resource !== 'Entity' && derived.has(`${r.resource}\u0000${r.key}`)).length;
424
+ const derived = new Set([...connections, ...entityRows, ...processorRows, ...agentRows.flat()].map((r) => `${r.resource}\u0000${r.key}`));
425
+ const agentCount = merged.resources.filter((r) => r.resource !== 'connection' && r.resource !== 'Entity' && r.resource !== 'idpProcessor' && derived.has(`${r.resource}\u0000${r.key}`)).length;
397
426
  const kept = merged.resources.filter((r) => !derived.has(`${r.resource}\u0000${r.key}`)).length;
398
427
  console.log(`compile: wrote bindings_v2.json (${connections.length} connection resource(s)`
399
428
  + `${entityRows.length > 0 ? `, ${entityRows.length} entity resource(s)` : ''}`
429
+ + `${processorRows.length > 0 ? `, ${processorRows.length} IDP processor resource(s)` : ''}`
400
430
  + `${agentCount > 0 ? `, ${agentCount} inline-agent resource(s)` : ''}`
401
431
  + `${kept > 0 ? `, ${kept} other resource(s) preserved` : ''})`);
402
432
  }
@@ -1 +1,3 @@
1
- export declare function writeJsonFile(path: string, value: unknown): void;
1
+ export declare function writeJsonFile(path: string, value: unknown, options?: {
2
+ exclusive?: boolean;
3
+ }): void;
@@ -7,6 +7,8 @@
7
7
  * JSON writes to this function. Creating the parent directory stays the caller's job.
8
8
  */
9
9
  import { writeFileSync } from 'node:fs';
10
- export function writeJsonFile(path, value) {
11
- writeFileSync(path, JSON.stringify(value, null, 2) + '\n');
10
+ export function writeJsonFile(path, value, options = {}) {
11
+ // `exclusive` creates the file and fails when anything is at `path`, a link
12
+ // included (O_CREAT | O_EXCL never follows one).
13
+ writeFileSync(path, JSON.stringify(value, null, 2) + '\n', options.exclusive === true ? { flag: 'wx' } : undefined);
12
14
  }
@@ -226,6 +226,7 @@ export declare const REFUSALS: {
226
226
  readonly CONNECTION_BINDING_NOT_GUID: "lint";
227
227
  readonly CONNECTION_CONNECTOR_CONFLICT: "draft";
228
228
  readonly CONNECTION_STUB: "lint";
229
+ readonly CONNECTOR_CONFIG_V2_DEFAULT: "lint";
229
230
  readonly CONNECTOR_IMPORT_NOT_A_FILE: "lowering";
230
231
  readonly CONNECTOR_INPUT: "lowering";
231
232
  readonly CONNECTOR_INPUTS_SHADOWED: "lowering";
@@ -300,6 +300,7 @@ export const REFUSALS = {
300
300
  CONNECTION_BINDING_NOT_GUID: 'lint',
301
301
  CONNECTION_CONNECTOR_CONFLICT: 'draft',
302
302
  CONNECTION_STUB: 'lint',
303
+ CONNECTOR_CONFIG_V2_DEFAULT: 'lint',
303
304
  CONNECTOR_IMPORT_NOT_A_FILE: 'lowering',
304
305
  CONNECTOR_INPUT: 'lowering',
305
306
  CONNECTOR_INPUTS_SHADOWED: 'lowering',
@@ -7364,6 +7364,12 @@
7364
7364
  "uipath.ixp.extract-document-builder@1.0.0": {
7365
7365
  "nodeType": "uipath.ixp.extract-document-builder",
7366
7366
  "version": "1.0.0",
7367
+ "takeoverTabs": [
7368
+ "definition",
7369
+ "datasets",
7370
+ "evaluators",
7371
+ "evalRuns"
7372
+ ],
7367
7373
  "category": "document-extraction",
7368
7374
  "tags": [
7369
7375
  "ixp",
@@ -7371,10 +7377,11 @@
7371
7377
  "extraction"
7372
7378
  ],
7373
7379
  "description": "Create and configure a document extraction from scratch",
7374
- "sortOrder": 46,
7380
+ "sortOrder": 45,
7375
7381
  "display": {
7376
- "canvasLabel": "Extract v2",
7377
- "label": "Extract v2",
7382
+ "canvasLabel": "Extract document",
7383
+ "isPreview": true,
7384
+ "label": "Extract document",
7378
7385
  "description": "Create and configure a document extraction from scratch",
7379
7386
  "icon": "file-text"
7380
7387
  },
@@ -7404,7 +7411,7 @@
7404
7411
  "model": {
7405
7412
  "source": true,
7406
7413
  "type": "bpmn:ServiceTask",
7407
- "serviceType": "IXP.DynamicExtraction",
7414
+ "serviceType": "IDP.Extraction",
7408
7415
  "skipBindingsReference": true,
7409
7416
  "evaluationTarget": {
7410
7417
  "kind": "documentExtraction",
@@ -7435,25 +7442,6 @@
7435
7442
  ".tiff"
7436
7443
  ]
7437
7444
  }
7438
- },
7439
- "bindings": {
7440
- "resource": "ixpDeployment",
7441
- "entityType": "ixpDeployment",
7442
- "resourceSubType": null,
7443
- "resourceKey": "",
7444
- "name": "",
7445
- "values": [
7446
- {
7447
- "name": "name",
7448
- "propertyAttribute": "name",
7449
- "default": ""
7450
- },
7451
- {
7452
- "name": "folderPath",
7453
- "propertyAttribute": "folderPath",
7454
- "default": ""
7455
- }
7456
- ]
7457
7445
  }
7458
7446
  },
7459
7447
  "form": {
@@ -7483,28 +7471,33 @@
7483
7471
  {
7484
7472
  "name": "inputs.fileRef",
7485
7473
  "type": "file",
7474
+ "placeholder": "File to extract data from",
7486
7475
  "label": "File",
7487
- "description": "File to extract data from",
7488
7476
  "validation": {
7489
- "required": true,
7490
- "messages": {
7491
- "required": "A file is required for extraction"
7492
- }
7477
+ "required": true
7493
7478
  }
7494
7479
  },
7495
7480
  {
7496
7481
  "name": "inputs.pageRange",
7497
- "type": "text",
7482
+ "type": "custom",
7483
+ "component": "code-editor",
7484
+ "componentProps": {
7485
+ "singleLine": true,
7486
+ "showVariableButton": true,
7487
+ "showAiButton": false,
7488
+ "lineNumbers": false,
7489
+ "placeholder": "e.g. 1-5",
7490
+ "expectedType": "text",
7491
+ "defaultToLiteralMode": true
7492
+ },
7498
7493
  "label": "Page range",
7499
- "placeholder": "e.g. 1-5",
7500
7494
  "description": "Optional page range to process."
7501
7495
  }
7502
7496
  ]
7503
7497
  },
7504
7498
  {
7505
7499
  "id": "schema-definition",
7506
- "title": "Schema definition",
7507
- "collapsible": false,
7500
+ "title": "",
7508
7501
  "fields": [
7509
7502
  {
7510
7503
  "name": "inputs.schemaDocument",
@@ -7556,10 +7549,8 @@
7556
7549
  },
7557
7550
  "fileRef": {
7558
7551
  "type": "string",
7559
- "minLength": 1
7560
- },
7561
- "pageRange": {
7562
- "type": "string"
7552
+ "minLength": 1,
7553
+ "errorMessage": "File is required"
7563
7554
  },
7564
7555
  "attachmentConfig": {
7565
7556
  "type": "object"
@@ -7592,6 +7583,9 @@
7592
7583
  "ID"
7593
7584
  ]
7594
7585
  },
7586
+ "pageRange": {
7587
+ "type": "string"
7588
+ },
7595
7589
  "modelConfig": {
7596
7590
  "type": "object"
7597
7591
  },
@@ -7618,7 +7612,11 @@
7618
7612
  "model_version": "gemini_2_5_flash",
7619
7613
  "execution_mode": "standard",
7620
7614
  "attribution_method": "word_ids",
7615
+ "attribution_model_version": "gemini-2.5-flash",
7621
7616
  "input_config": "none",
7617
+ "language_support": "latin",
7618
+ "layout_parsing": "none",
7619
+ "layout_model_version": null,
7622
7620
  "system_prompt_override": null,
7623
7621
  "frequency_penalty": null,
7624
7622
  "temperature": null,
@@ -0,0 +1,21 @@
1
+ /** What {@link provisionIdpProcessors} did, for compile to report. */
2
+ export interface IdpProcessorProvisioning {
3
+ /** Solution-relative paths of the resource files created or updated. */
4
+ written: string[];
5
+ /** Why no file was written although a node authors a processor (the project is not in a solution). */
6
+ pending?: string;
7
+ /** Processors whose file was not written, and why (a resource folder that resolves outside the solution). */
8
+ skipped: string[];
9
+ /** The processor display names by key, as the solution's files hold them, for `bindings_v2.json`. */
10
+ namesByKey: Map<string, string>;
11
+ }
12
+ /**
13
+ * Give each processor the flow's Extract document nodes author its resource
14
+ * file, and each such node the processor's name (`inputs.processorName`) —
15
+ * MUTATES `flow`, so call it before the `.flow` is written. `projectDir` is the
16
+ * Flow project (the folder holding `project.uiproj`) the flow is the main flow of.
17
+ */
18
+ export declare function provisionIdpProcessors(flow: {
19
+ nodes?: unknown;
20
+ subflows?: unknown;
21
+ }, projectDir: string): IdpProcessorProvisioning;
@@ -0,0 +1,251 @@
1
+ /**
2
+ * Writing each Extract document node's IDP processor resource file, for
3
+ * `compile-cli` (builder-sdk#1984). The rules are the document family's
4
+ * (`nodes/document/flow/idp-processor.ts`, pure, so the flow core loads no
5
+ * `node:fs` — FB015); this module only reads and writes the files.
6
+ *
7
+ * What it does, as `uip maestro flow nodes create` / `nodes provision` and
8
+ * `uip solution pack` do it: find the solution whose `.uipx` lists the
9
+ * project; read its `idpProcessor` resources, matched by `kind` and `key`
10
+ * (never by path); merge each authored processor's spec into its file, or
11
+ * create the file under a de-duplicated name.
12
+ *
13
+ * Confinement: every path read or written resolves inside the solution. The
14
+ * walk follows only canonical paths, a new file's folder is checked through
15
+ * its nearest existing ancestor, and a new file is created exclusively (it
16
+ * fails on anything already at the path, a dangling link included). A link at
17
+ * a candidate path is never read through or reused.
18
+ *
19
+ * A file is only written when its content changes, and never deleted: a
20
+ * resource outlives its node, as pack leaves it.
21
+ */
22
+ import { existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, realpathSync, statSync } from 'node:fs';
23
+ import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
24
+ import { writeJsonFile } from './core/json-file.js';
25
+ import { buildIdpProcessorSpec, collectWorkflowNodes, DEFAULT_IDP_PROCESSOR_NAME, deriveIdpProcessorName, idpProcessorResourcePath, isIdpProcessorResource, isPublishedIdpProcessorLink, readAuthoringProcessorKey, readIdpProcessorName, readNodeLabel, updateIdpProcessorResource, wrapIdpProcessorSpec, } from './nodes/document/flow/family.js';
26
+ function readJson(path) {
27
+ try {
28
+ return JSON.parse(readFileSync(path, 'utf8'));
29
+ }
30
+ catch {
31
+ return undefined;
32
+ }
33
+ }
34
+ function canonical(path) {
35
+ try {
36
+ return realpathSync(path);
37
+ }
38
+ catch {
39
+ return undefined;
40
+ }
41
+ }
42
+ function contains(root, target) {
43
+ const rel = relative(root, target);
44
+ return rel === '' || (!rel.startsWith('..') && !isAbsolute(rel));
45
+ }
46
+ /** The Flow project folders a solution's `.uipx` lists (the CLI's `readFlowProjectDirs`). */
47
+ function flowProjectDirs(solutionDir) {
48
+ let entries;
49
+ try {
50
+ entries = readdirSync(solutionDir);
51
+ }
52
+ catch {
53
+ return [];
54
+ }
55
+ const uipx = entries.find((e) => e.endsWith('.uipx'));
56
+ if (uipx === undefined)
57
+ return [];
58
+ const manifest = readJson(join(solutionDir, uipx));
59
+ const root = resolve(solutionDir);
60
+ const dirs = [];
61
+ for (const project of Array.isArray(manifest?.Projects) ? manifest.Projects : []) {
62
+ if (project?.Type !== 'Flow' || typeof project.ProjectRelativePath !== 'string')
63
+ continue;
64
+ const target = resolve(root, ...project.ProjectRelativePath.replace(/\\/g, '/').split('/'));
65
+ const dir = target.endsWith('.uiproj') ? dirname(target) : target;
66
+ if (contains(root, dir))
67
+ dirs.push(dir);
68
+ }
69
+ return dirs;
70
+ }
71
+ /** The nearest folder at or above `projectDir` whose `.uipx` lists it (the CLI's `findEnclosingSolutionDir`). */
72
+ function enclosingSolution(projectDir) {
73
+ const project = resolve(projectDir);
74
+ let dir = project;
75
+ for (;;) {
76
+ let entries = [];
77
+ try {
78
+ entries = readdirSync(dir);
79
+ }
80
+ catch {
81
+ // An unreadable folder is not a solution; keep walking up.
82
+ }
83
+ if (entries.some((e) => e.endsWith('.uipx')) && flowProjectDirs(dir).includes(project))
84
+ return dir;
85
+ const parent = dirname(dir);
86
+ if (parent === dir)
87
+ return undefined;
88
+ dir = parent;
89
+ }
90
+ }
91
+ /**
92
+ * Every processor resource under `<solution>/resources/`, walked through
93
+ * canonical paths so a link cannot carry a write out of the solution, each
94
+ * folder visited once.
95
+ */
96
+ function readResources(solutionDir) {
97
+ const root = canonical(solutionDir);
98
+ const entries = [];
99
+ if (root === undefined)
100
+ return entries;
101
+ const visited = new Set();
102
+ const walk = (dir) => {
103
+ const at = canonical(dir);
104
+ if (at === undefined || !contains(root, at) || visited.has(at))
105
+ return;
106
+ visited.add(at);
107
+ let names;
108
+ try {
109
+ names = readdirSync(at).sort();
110
+ }
111
+ catch {
112
+ return;
113
+ }
114
+ for (const name of names) {
115
+ const child = canonical(join(at, name));
116
+ if (child === undefined || !contains(root, child))
117
+ continue;
118
+ const stat = statSync(child);
119
+ if (stat.isDirectory())
120
+ walk(child);
121
+ else if (stat.isFile() && name.endsWith('.json')) {
122
+ const parsed = readJson(child);
123
+ if (!isIdpProcessorResource(parsed))
124
+ continue;
125
+ const resource = parsed.resource;
126
+ entries.push({
127
+ filePath: child,
128
+ key: typeof resource.key === 'string' ? resource.key : '',
129
+ name: typeof resource.name === 'string' ? resource.name : '',
130
+ file: parsed,
131
+ });
132
+ }
133
+ }
134
+ };
135
+ walk(join(root, 'resources'));
136
+ return entries;
137
+ }
138
+ /** What is at a candidate path, without following a link there. */
139
+ function occupant(path) {
140
+ try {
141
+ return lstatSync(path).isSymbolicLink() ? 'link' : 'file';
142
+ }
143
+ catch {
144
+ return 'free';
145
+ }
146
+ }
147
+ /**
148
+ * `path`, or the first `<name>_<N>.json` that is free or already holds this
149
+ * processor's own file. A link is never followed, read or reused: its path is skipped.
150
+ */
151
+ function freeResourcePath(path, key) {
152
+ const base = path.slice(0, -'.json'.length);
153
+ for (let suffix = 1, candidate = path;; candidate = `${base}_${suffix++}.json`) {
154
+ const at = occupant(candidate);
155
+ if (at === 'free')
156
+ return { path: candidate, own: false };
157
+ if (at === 'link')
158
+ continue;
159
+ const parsed = readJson(candidate);
160
+ if (parsed?.resource?.key === key)
161
+ return { path: candidate, own: true };
162
+ }
163
+ }
164
+ /** The deterministic bytes the CLI writes a resource file with. */
165
+ function serialized(value) {
166
+ return `${JSON.stringify(value, null, 2)}\n`;
167
+ }
168
+ /**
169
+ * Give each processor the flow's Extract document nodes author its resource
170
+ * file, and each such node the processor's name (`inputs.processorName`) —
171
+ * MUTATES `flow`, so call it before the `.flow` is written. `projectDir` is the
172
+ * Flow project (the folder holding `project.uiproj`) the flow is the main flow of.
173
+ */
174
+ export function provisionIdpProcessors(flow, projectDir) {
175
+ const authors = collectWorkflowNodes(flow).filter((node) => {
176
+ const key = readAuthoringProcessorKey(node);
177
+ return key !== undefined && !isPublishedIdpProcessorLink(node.inputs);
178
+ });
179
+ const namesByKey = new Map();
180
+ if (authors.length === 0)
181
+ return { written: [], namesByKey, skipped: [] };
182
+ const solutionDir = enclosingSolution(projectDir);
183
+ if (solutionDir === undefined) {
184
+ return {
185
+ written: [],
186
+ namesByKey,
187
+ skipped: [],
188
+ pending: 'the flow project is not inside a solution, so each Extract document step\'s idpProcessor resource file '
189
+ + 'is created when the project is packed inside one (uip solution pack)',
190
+ };
191
+ }
192
+ const resources = readResources(solutionDir);
193
+ for (const entry of resources)
194
+ if (entry.key !== '' && entry.name !== '')
195
+ namesByKey.set(entry.key, entry.name);
196
+ const taken = new Set(resources.map((r) => r.name.toLowerCase()).filter((n) => n.length > 0));
197
+ const written = [];
198
+ const skipped = [];
199
+ const done = new Map();
200
+ for (const node of authors) {
201
+ const key = readAuthoringProcessorKey(node);
202
+ const inputs = node.inputs;
203
+ // Nodes sharing a key share its processor: the first one writes it.
204
+ const named = done.get(key);
205
+ if (named !== undefined) {
206
+ inputs.processorName = named;
207
+ continue;
208
+ }
209
+ const spec = buildIdpProcessorSpec(node);
210
+ const existing = resources.find((r) => r.key === key);
211
+ if (existing !== undefined) {
212
+ // The resource owns the name once created.
213
+ if (existing.name.length > 0)
214
+ inputs.processorName = existing.name;
215
+ const merged = updateIdpProcessorResource(existing.file, spec);
216
+ if (serialized(merged) !== serialized(existing.file)) {
217
+ writeJsonFile(existing.filePath, merged);
218
+ written.push(relative(solutionDir, existing.filePath));
219
+ }
220
+ done.set(key, existing.name.length > 0 ? existing.name : String(inputs.processorName ?? ''));
221
+ continue;
222
+ }
223
+ const base = readIdpProcessorName(inputs) ?? readNodeLabel(node) ?? DEFAULT_IDP_PROCESSOR_NAME;
224
+ const name = deriveIdpProcessorName(base, taken) ?? DEFAULT_IDP_PROCESSOR_NAME;
225
+ taken.add(name.toLowerCase());
226
+ inputs.processorName = name;
227
+ namesByKey.set(key, name);
228
+ const found = freeResourcePath(join(solutionDir, ...idpProcessorResourcePath(name).split('/')), key);
229
+ const target = found.path;
230
+ // Nearest existing ancestor first: mkdir would follow a link anywhere above
231
+ // the leaf and carry the new folders out of the solution.
232
+ let probe = dirname(target);
233
+ while (!existsSync(probe) && dirname(probe) !== probe)
234
+ probe = dirname(probe);
235
+ const realProbe = canonical(probe);
236
+ const realRoot = canonical(solutionDir);
237
+ if (realProbe === undefined || realRoot === undefined || !contains(realRoot, realProbe)) {
238
+ skipped.push(`${name} (${key}): ${relative(solutionDir, dirname(target))} resolves outside the solution`);
239
+ done.set(key, name);
240
+ continue;
241
+ }
242
+ mkdirSync(dirname(target), { recursive: true });
243
+ // Its own file (a regular file, checked above) is rewritten in place; a
244
+ // new one is created exclusively, so nothing that appears at the path in
245
+ // between, a link included, is written through.
246
+ writeJsonFile(target, wrapIdpProcessorSpec({ key, name, spec }), { exclusive: !found.own });
247
+ written.push(relative(solutionDir, target));
248
+ done.set(key, name);
249
+ }
250
+ return { written, namesByKey, skipped };
251
+ }
@@ -1,3 +1,8 @@
1
1
  /** The document node family, as flow-node-registry.ts lists it: Document Classify, Dynamic Extract and an IxP project's extractor. */
2
2
  import type { FlowNodeFamily } from '../../../flow-node-type.js';
3
3
  export declare const documentFlowFamily: FlowNodeFamily;
4
+ /**
5
+ * The IDP processor rules, for `compile` (`idp-processor-files.ts`) and
6
+ * `bindings_v2.json`: pure, and not part of the public surface.
7
+ */
8
+ export { buildIdpProcessorSpec, collectWorkflowNodes, DEFAULT_IDP_PROCESSOR_NAME, deriveIdpProcessorName, idpProcessorBindingRows, idpProcessorResourcePath, isIdpProcessorResource, isPublishedIdpProcessorLink, readAuthoringProcessorKey, readIdpProcessorName, readNodeLabel, updateIdpProcessorResource, withIdpProcessorRows, wrapIdpProcessorSpec, type IdpProcessorBindingRow, type WorkflowNodeLike, } from './idp-processor.js';
@@ -6,3 +6,8 @@ export const documentFlowFamily = {
6
6
  types: [documentClassifyNodeType, dynamicExtractNodeType, ixpExtractNodeType],
7
7
  diagnostics: { ...DOCUMENT_DIAGNOSTICS, ...IXP_DIAGNOSTICS },
8
8
  };
9
+ /**
10
+ * The IDP processor rules, for `compile` (`idp-processor-files.ts`) and
11
+ * `bindings_v2.json`: pure, and not part of the public surface.
12
+ */
13
+ export { buildIdpProcessorSpec, collectWorkflowNodes, DEFAULT_IDP_PROCESSOR_NAME, deriveIdpProcessorName, idpProcessorBindingRows, idpProcessorResourcePath, isIdpProcessorResource, isPublishedIdpProcessorLink, readAuthoringProcessorKey, readIdpProcessorName, readNodeLabel, updateIdpProcessorResource, withIdpProcessorRows, wrapIdpProcessorSpec, } from './idp-processor.js';