suppa-mcp-2 1.43.4 → 1.44.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.
- package/README.md +45 -0
- package/dist/server.js +9 -7
- package/dist/tools/automation.js +29 -1
- package/dist/tools/formV2.js +107 -9
- package/dist/tools/forms.js +29 -5
- package/package.json +1 -1
- package/skills/building-suppa-automations/SKILL.md +185 -0
- package/skills/building-suppa-automations/references/node-reference.md +76 -0
- package/skills/building-suppa-automations/references/publishing.md +41 -0
- package/skills/building-suppa-automations/references/tenant-time.md +43 -0
- package/skills/building-suppa-automations/scripts/auto-layout.mjs +201 -0
- package/skills/building-suppa-automations/scripts/edges.mjs +55 -0
- package/skills/building-suppa-automations/scripts/geometry.mjs +30 -0
- package/skills/building-suppa-automations/scripts/graph-hash.mjs +22 -0
- package/skills/building-suppa-automations/scripts/graph.mjs +21 -0
- package/skills/building-suppa-automations/scripts/layout-check.mjs +9 -0
- package/skills/building-suppa-automations/scripts/layout.mjs +45 -0
- package/skills/building-suppa-automations/scripts/lint-graph.mjs +207 -0
- package/skills/building-suppa-automations/scripts/render-graph.mjs +77 -0
- package/skills/suppa-form-v2/scripts/validate-form-schema.mjs +9 -4
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Node reference (verified on published, running automations)
|
|
2
|
+
|
|
3
|
+
Every shape below comes from a published, running automation; the ids in the examples are sample values.
|
|
4
|
+
For a type not listed, call `suppa_get_automation_node_schema`.
|
|
5
|
+
|
|
6
|
+
## Graph
|
|
7
|
+
|
|
8
|
+
```json
|
|
9
|
+
{ "id": "create-task", "type": "suppa", "name": "A4. Create task", "parameters": { … }, "position": { "x": 7900, "y": 292 } }
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Connections: `{ "<from id>": { "<output handle>": [{ "node": "<to id>", "index": 0 }] } }`.
|
|
13
|
+
|
|
14
|
+
| Node type | Output handles |
|
|
15
|
+
|---|---|
|
|
16
|
+
| ordinary nodes, triggers | `main` |
|
|
17
|
+
| `if` | `true` / `false` |
|
|
18
|
+
| `approval` | `approved` / `rejected` |
|
|
19
|
+
| `switch` | the rule's `output` **name** (not an index) |
|
|
20
|
+
|
|
21
|
+
`index` is the target input. Only `merge` uses `1`.
|
|
22
|
+
|
|
23
|
+
## Triggers
|
|
24
|
+
|
|
25
|
+
| Trigger | Parameters | Notes |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| Form submission / request | `formSubmission` `{ "formId": 1260 }` | Routes on `formId` alone, fires after insert. The output is the FormSubmissions row: `id`, `number`, `state`, `requestType {id,title}`, `form`, `createdBy {id,fullName}`, `formData` (relations as `{id}` only). Read values from it — see SKILL.md «Requests and form submissions». |
|
|
28
|
+
| Entity change | `triggerEntity` `{ "entityName": "Tasks", "events": ["after-update"], "watchFields": ["stage"], "conditions": { "operator": "and", "filters": [ {"operator": "or", "filters": [{"field": "project", "comparator": "=", "value": {"id": 3683}}]}, {"field": "stage.id", "comparator": "in", "value": [947, 968]} ] } }` | `events` take `after-insert` / `after-update` / `after-remove` (and `before-*`). Conditions nest `{operator, filters}`. Relation fields take `{id}` values or dotted paths (`stage.id`). Comparators include `=`, `!=`, `in`, `not in`, `contains`, `is null`, `is not null` (the null checks take no `value`). |
|
|
29
|
+
|
|
30
|
+
Several triggers in one automation are allowed. The run starts at the trigger that fired.
|
|
31
|
+
|
|
32
|
+
## Core nodes
|
|
33
|
+
|
|
34
|
+
| Node | Parameters |
|
|
35
|
+
|---|---|
|
|
36
|
+
| `suppa` getById | `{ "action": "getById", "entityName": "AutomationWorkflow", "id": "={{ $workflow.id }}", "fields": {"id": true, "activeSettings": true} }` — the automation's own settings. |
|
|
37
|
+
| `suppa` select | `{ "action": "select", "entityName": "OrgEmployees", "limit": 50, "fields": {"id": true, "user": {"id": true}}, "conditions": {"operator": "and", "filters": [{"field": "id", "comparator": "in", "value": "={{ … }}"}]} }` — **0 rows ends the branch.** |
|
|
38
|
+
| `suppa` insert / updateById | `{ "action": "updateById", "entityName": "Tasks", "id": "={{ … }}", "fields": {"stage": "={{ x != null ? { id: x } : null }}"}, "merge": ["watchers"] }` — relations are `{id}`. List fields are replaced unless named in `merge`. |
|
|
39
|
+
| `set` | `{ "keepOnlySet": true, "assignments": [{"name": "request", "value": "={{ $('A1. Start: …').first().json }}"}] }` |
|
|
40
|
+
| `code` | `{ "code": "…return [{ … }];" }` — sees only `$json` / `$input`, with no `$()` / `$workflow` / `$now`. Feed it through a `set`. One run covers all input items. |
|
|
41
|
+
| `if` | `{ "expression": "={{ … === true }}" }` |
|
|
42
|
+
| `switch` | `{ "mode": "first", "fallbackEnabled": false, "rules": [{"output": "approvalIt", "condition": "={{ $json.action === 'approvalIt' }}"}] }` |
|
|
43
|
+
| `responseEntity` | Only after a `before-insert` / `before-update` trigger: `{ "action": "apply", "values": [{"name": "status", "value": "={{ … }}"}] }` — the values are applied to the record before it is saved (defaults, normalisation) at the cost of no write. Every listed field takes the value returned, so when a field needs no change, return what came in (`… ?? $('A1. Start…').first().json.<field>`). |
|
|
44
|
+
| `merge` | `{ "mode": "append" }`, node field `"inputCount": 2`. Waits for both inputs and still runs when one select produced nothing (fan out: source → select → input 0, source → merge input 1). |
|
|
45
|
+
| `approval` | `{ "flow": "sequential", "entityName": "Tasks", "instanceId": "={{ … }}", "approvers": "={{ … }}", "description": "Text ={{ expr }}: ={{ expr }}" }` — `approvers` = `[{ "user": { "id": 75 } }]`. |
|
|
46
|
+
| `notification` | `{ "type": "insert", "channels": [{"channel": "inApp"}], "entityName": "Tasks", "recordId": "={{ … }}", "userIds": "={{ [ … ] }}", "subjectTemplate": {"uk": "…", "en": "…"}, "bodyTemplate": {"uk": "… ={{ expr }} …"}, "navigateTo": {"entityId": 45, "instanceId": "={{ … }}"} }` |
|
|
47
|
+
|
|
48
|
+
## Linking a request to its task
|
|
49
|
+
|
|
50
|
+
Do not invent a field on the task. Use `EntityLinks`.
|
|
51
|
+
|
|
52
|
+
To create the link:
|
|
53
|
+
```json
|
|
54
|
+
{ "action": "insert", "entityName": "EntityLinks", "fields": {
|
|
55
|
+
"type": "={{ { id: <link type id from settings> } }}",
|
|
56
|
+
"instanceA": { "type": "many-to-one", "relationTarget": "FormSubmissions", "value": { "id": "={{ … }}" } },
|
|
57
|
+
"instanceB": { "type": "many-to-one", "relationTarget": "Tasks", "value": { "id": "={{ … }}" } } } }
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
To find the request from the task: select `EntityLinks` with the filters
|
|
61
|
+
- `type.id = <type>`,
|
|
62
|
+
- `instanceB.$entityId = 45` (the Tasks entity id),
|
|
63
|
+
- `instanceB.$instanceId = <task id>`,
|
|
64
|
+
|
|
65
|
+
then read `instanceA.value.id ?? instanceA.id`.
|
|
66
|
+
|
|
67
|
+
## Expressions and settings
|
|
68
|
+
|
|
69
|
+
- `={{ js }}` evaluates. Text and several `={{ }}` mix inside one string.
|
|
70
|
+
- Reference a node as `$('Node name').first().json`. `$json` is the incoming item.
|
|
71
|
+
- A trigger or `suppa` item lazily loads `$json.<field>` that was not selected (the item carries `meta.entity`).
|
|
72
|
+
- Settings are stored as jsonb:
|
|
73
|
+
- object keys get re-sorted, so keep an explicit order array;
|
|
74
|
+
- a key named `constructor` is stripped;
|
|
75
|
+
- an update merges top-level keys only, so resend the whole `settings.<key>`;
|
|
76
|
+
- flows read `activeSettings`, so republish after any change.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Publishing and verifying an automation
|
|
2
|
+
|
|
3
|
+
## Draft and published
|
|
4
|
+
|
|
5
|
+
`AutomationWorkflow` has two sides:
|
|
6
|
+
- the **draft** — `nodes` / `connections` / `settings`;
|
|
7
|
+
- the **published** version — `activeNodes` / `activeConnections` / `activeSettings`.
|
|
8
|
+
|
|
9
|
+
Production runs only the published side. `hasUnpublishedChanges` tells you the draft differs.
|
|
10
|
+
|
|
11
|
+
## Order of work
|
|
12
|
+
|
|
13
|
+
1. **Tenant.** Run `suppa_use_tenant("<full https URL>")`, then confirm with `suppa_list_tenants`. Aliases collide, and the MCP may start on (or drift back to) prod. Check again before every write.
|
|
14
|
+
2. **Close the builder.** Any `workflow-builder/<id>` tab must be navigated away before you write through the API. An open builder autosaves its stale graph over yours. It also turns expression `approvers` into `[]`, adds duplicate `condition` keys and re-lays-out the nodes. After writing, compare `nodes` with `activeNodes`. If the draft was overwritten, copy `activeNodes` / `activeConnections` back into it and republish.
|
|
15
|
+
3. **Write.**
|
|
16
|
+
- Small graphs: `suppa_update_automation` (`nodes_json`, `connections_json`, `settings_json`; settings merge top-level).
|
|
17
|
+
- Big graphs (> ~40 KB): build the graph **inside the tenant page** from the stored `activeNodes` plus small inline maps (names, positions, new nodes). Then `POST /api/core/data/AutomationWorkflow/update/<id>` with `{ fields: { … } }` using the page's own session.
|
|
18
|
+
- A page **cannot** fetch `http://127.0.0.1` (Chrome Local Network Access): the call hangs and nothing arrives.
|
|
19
|
+
4. **Verify by hash, not by reading.** `suppa_get_automation` returns 150 KB+. Run `node scripts/graph-hash.mjs graph.json` locally, and compute the same thing in the page:
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
const canon = (v) => Array.isArray(v) ? '[' + v.map(canon).join(',') + ']' : v && typeof v === 'object' ? '{' + Object.keys(v).sort().map(k => JSON.stringify(k) + ':' + canon(v[k])).join(',') + '}' : JSON.stringify(v);
|
|
23
|
+
const sha = async (s) => [...new Uint8Array(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(s)))].map(b => b.toString(16).padStart(2, '0')).join('');
|
|
24
|
+
const key = (nodes) => nodes.map(n => ({ id: n.id, name: n.name, parameters: n.parameters, position: n.position })).sort((a, b) => a.id < b.id ? -1 : 1);
|
|
25
|
+
// compare (await sha(canon(key(row.nodes)))) with the local hash; return booleans, not hashes —
|
|
26
|
+
// the browser tool redacts long hex strings from results
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Settings hashes must drop `constructor` keys, because the platform strips them.
|
|
30
|
+
5. **Publish** with `suppa_publish_automation`. This copies the draft to the published side and runs pre-flight checks.
|
|
31
|
+
- The builder may keep showing «Unpublished changes» for a graph written through the API. It compares its own normalized copy, not the server state.
|
|
32
|
+
- Trust `hasUnpublishedChanges` and `nodes == activeNodes` instead.
|
|
33
|
+
- Never press «Publish changes» in the UI to clear the badge: it publishes the builder's version, with expression approvers wiped.
|
|
34
|
+
6. **Test every flow live.**
|
|
35
|
+
- Submit the form, or move a test task to the stage.
|
|
36
|
+
- Read the run with `suppa_get_automation_run`. The output is large and lands in a file, so summarize it with `node -e` (`steps[].nodeId / status / error / output`).
|
|
37
|
+
- Also confirm that a move which should start nothing starts no run (`suppa_list_automation_runs`).
|
|
38
|
+
- Approvals auto-approve when the approver started the run, so route test approvals to a second account. A real rejection needs a click from that account.
|
|
39
|
+
- Read the approval step of the run: `responses[0].comment` «Automatically approved…» means it did not wait. On modern-expo.test (2026-10-23 – 26) that happened in 20 of 20 runs the tester started, even with a second account (a plus-address of the tester's mailbox), cause not established — so the rejection path counts as tested only after an approval has waited and been rejected by a click.
|
|
40
|
+
7. **Retire what a merge replaced.** Run `suppa_unpublish_automation`, then `suppa_delete_automation`. The delete is soft; `suppa_restore_record('AutomationWorkflow', id)` undoes it.
|
|
41
|
+
8. **Update the description.** Start it with the step guide by flow letter and number, then list the real people per BP or role (test ids stay in settings).
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Tenant time in a `code` node
|
|
2
|
+
|
|
3
|
+
A datetime written without an offset is read as **UTC**, and Kyiv is +02:00 in winter and +03:00 in summer. The switch happens on the last Sunday of March and of October, at 01:00 UTC. So never append a fixed offset. Paste these helpers at the top of the `code` node that computes dates. They use `Intl` time zones when the sandbox has them and fall back to the EU rule Ukraine follows.
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
const kyivOffsetMin = (d) => {
|
|
7
|
+
try {
|
|
8
|
+
const name = new Intl.DateTimeFormat('en-US', { timeZone: 'Europe/Kyiv', timeZoneName: 'longOffset' }).formatToParts(d).find((p) => p.type === 'timeZoneName').value;
|
|
9
|
+
const m = /GMT([+-])(\d{2}):(\d{2})/.exec(name);
|
|
10
|
+
if (m) return (m[1] === '-' ? -1 : 1) * (Number(m[2]) * 60 + Number(m[3]));
|
|
11
|
+
} catch (e) { /* no Intl time zones in the sandbox */ }
|
|
12
|
+
const y = d.getUTCFullYear();
|
|
13
|
+
const lastSunday = (month) => { const t = new Date(Date.UTC(y, month + 1, 0, 1)); t.setUTCDate(t.getUTCDate() - t.getUTCDay()); return t; };
|
|
14
|
+
return d >= lastSunday(2) && d < lastSunday(9) ? 180 : 120;
|
|
15
|
+
};
|
|
16
|
+
const pad2 = (n) => String(n).padStart(2, '0');
|
|
17
|
+
// The calendar day an instant falls on in Kyiv, as a UTC-midnight Date.
|
|
18
|
+
const kyivDay = (d) => { const k = new Date(d.getTime() + kyivOffsetMin(d) * 60000); return new Date(Date.UTC(k.getUTCFullYear(), k.getUTCMonth(), k.getUTCDate())); };
|
|
19
|
+
// A form date: 'YYYY-MM-DD' is already the picked day; an ISO instant is the Kyiv day it falls on
|
|
20
|
+
// (a picker may send local midnight, which is the previous day in UTC).
|
|
21
|
+
const toKyivDay = (v) => {
|
|
22
|
+
if (v == null || v === '') return null;
|
|
23
|
+
const s = String(v);
|
|
24
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(s)) return new Date(s + 'T00:00:00Z');
|
|
25
|
+
const d = new Date(s);
|
|
26
|
+
return Number.isNaN(d.getTime()) ? null : kyivDay(d);
|
|
27
|
+
};
|
|
28
|
+
// ISO-8601 with the right offset for HH:MM Kyiv on that day.
|
|
29
|
+
const atKyiv = (day, hhmm) => {
|
|
30
|
+
const [h, m] = String(hhmm || '16:00').split(':').map(Number);
|
|
31
|
+
const off = kyivOffsetMin(new Date(Date.UTC(day.getUTCFullYear(), day.getUTCMonth(), day.getUTCDate(), h, m) - 120 * 60000));
|
|
32
|
+
const a = Math.abs(off);
|
|
33
|
+
return `${day.toISOString().slice(0, 10)}T${pad2(h)}:${pad2(m)}:00${off < 0 ? '-' : '+'}${pad2(Math.floor(a / 60))}:${pad2(a % 60)}`;
|
|
34
|
+
};
|
|
35
|
+
// N working days after a Kyiv day; weekends and the days in `off` ('YYYY-MM-DD') are skipped.
|
|
36
|
+
const addBusinessDays = (day, n, off = new Set()) => { const d = new Date(day); while (n > 0) { d.setUTCDate(d.getUTCDate() + 1); if (d.getUTCDay() % 6 !== 0 && !off.has(d.toISOString().slice(0, 10))) n--; } return d; };
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Usage:
|
|
40
|
+
- «due at 16:00 on the picked day»: `atKyiv(toKyivDay(fd.desired_date), '16:00')`;
|
|
41
|
+
- «+2 working days from now»: `atKyiv(addBusinessDays(kyivDay(new Date($json.now)), 2, holidays), '16:00')`. The `code` node has no `$now`, so feed `now: "={{ $now }}"` through the `set` before it, and read holidays from their entity.
|
|
42
|
+
|
|
43
|
+
For a tenant in another zone, replace `'Europe/Kyiv'` and the fallback rule. The trigger payload's `options.timezone` names the tenant's zone.
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// Lays out a whole automation with no hand-written spec, then repairs what the edge model flags.
|
|
2
|
+
// usage: node auto-layout.mjs <graph.json> > placed.json (stderr: straight-edge count and leftovers)
|
|
3
|
+
// graph.json: the stored shape or a suppa_get_automation answer; placed.json is always the stored shape.
|
|
4
|
+
//
|
|
5
|
+
// Rules, in the order they apply:
|
|
6
|
+
// - column = longest path from the flow's trigger, so every edge runs left to right;
|
|
7
|
+
// - each node hangs on one feeding edge (its anchor): the one from the earliest column, i.e. the edge that
|
|
8
|
+
// skips a detour; a node fed from 3+ different branches is a collector and goes below the flow;
|
|
9
|
+
// - at a fork, the edge to a node that another branch rejoins stays straight and that other branch goes
|
|
10
|
+
// above (a skippable lookup, an approval with a bypass); otherwise the first output stays straight and the
|
|
11
|
+
// rest stack below, each clear of what is already in its columns;
|
|
12
|
+
// - after an approval / if whose lower line runs far right, the node on the upper line steps up so the
|
|
13
|
+
// lower line does not run along its border;
|
|
14
|
+
// - flows stack in bands, each trigger 300 below the previous flow's lowest node;
|
|
15
|
+
// - then: whatever the edge model still flags is nudged away (node moved off a line, a target pushed one
|
|
16
|
+
// column right when a vertical segment crosses a node, overlaps pushed apart), up to 80 rounds.
|
|
17
|
+
import fs from 'node:fs';
|
|
18
|
+
import { fileURLToPath } from 'node:url';
|
|
19
|
+
import { height, inOffset, outOffset } from './geometry.mjs';
|
|
20
|
+
import { analyse, rect } from './edges.mjs';
|
|
21
|
+
import { readGraph } from './graph.mjs';
|
|
22
|
+
|
|
23
|
+
const TRIGGERS = new Set(['formSubmission', 'triggerEntity', 'triggerWebhook', 'triggerSchedule', 'triggerManual']);
|
|
24
|
+
const handleRank = (n, h) => {
|
|
25
|
+
if (n.type === 'if') return h === 'true' ? 0 : 1;
|
|
26
|
+
if (n.type === 'approval') return h === 'approved' ? 0 : 1;
|
|
27
|
+
if (n.type === 'switch') return (n.parameters?.rules || []).findIndex((r) => r.output === h);
|
|
28
|
+
return h === 'error' ? 9 : 0;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const autoLayout = (graph, { pitch = 340, x0 = 80, lift = 150, gap = 50, band = 300, clear = 24, rounds = 80 } = {}) => {
|
|
32
|
+
const { nodes, connections } = graph;
|
|
33
|
+
const by = Object.fromEntries(nodes.map((n) => [n.id, n]));
|
|
34
|
+
const order = Object.fromEntries(nodes.map((n, i) => [n.id, i]));
|
|
35
|
+
const succ = Object.fromEntries(nodes.map((n) => [n.id, []]));
|
|
36
|
+
const pred = Object.fromEntries(nodes.map((n) => [n.id, []]));
|
|
37
|
+
let seq = 0;
|
|
38
|
+
for (const [from, hs] of Object.entries(connections)) for (const [h, ts] of Object.entries(hs)) for (const t of ts) {
|
|
39
|
+
if (!by[from] || !by[t.node]) continue;
|
|
40
|
+
const e = { from, to: t.node, handle: h, seq: seq++ };
|
|
41
|
+
succ[from].push(e);
|
|
42
|
+
pred[t.node].push(e);
|
|
43
|
+
}
|
|
44
|
+
for (const id of Object.keys(succ)) succ[id].sort((a, b) => handleRank(by[id], a.handle) - handleRank(by[id], b.handle) || a.seq - b.seq);
|
|
45
|
+
|
|
46
|
+
// flows: a node belongs to the first trigger that reaches it
|
|
47
|
+
const triggers = nodes.filter((n) => TRIGGERS.has(n.type));
|
|
48
|
+
const flow = {};
|
|
49
|
+
for (const t of triggers) {
|
|
50
|
+
const stack = [t.id];
|
|
51
|
+
while (stack.length) { const id = stack.pop(); if (flow[id]) continue; flow[id] = t.id; for (const e of succ[id]) stack.push(e.to); }
|
|
52
|
+
}
|
|
53
|
+
const reach = {};
|
|
54
|
+
const reaches = (a, b) => {
|
|
55
|
+
if (!reach[a]) { const s = new Set(); const st = [a]; while (st.length) for (const e of succ[st.pop()]) if (!s.has(e.to)) { s.add(e.to); st.push(e.to); } reach[a] = s; }
|
|
56
|
+
return reach[a].has(b);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// topological order (Kahn), columns = longest path, with right-shifts from the repair loop
|
|
60
|
+
const indeg = Object.fromEntries(nodes.map((n) => [n.id, pred[n.id].length]));
|
|
61
|
+
const topo = [];
|
|
62
|
+
const queue = nodes.filter((n) => !indeg[n.id]).map((n) => n.id);
|
|
63
|
+
while (queue.length) { const id = queue.shift(); topo.push(id); for (const e of succ[id]) if (!--indeg[e.to]) queue.push(e.to); }
|
|
64
|
+
if (topo.length !== nodes.length) throw new Error('the graph has a cycle');
|
|
65
|
+
const colMin = {};
|
|
66
|
+
const cols = () => {
|
|
67
|
+
const col = {};
|
|
68
|
+
for (const id of topo) col[id] = Math.max(colMin[id] ?? 0, ...pred[id].map((e) => col[e.from] + 1), 0);
|
|
69
|
+
return col;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// anchors
|
|
73
|
+
const collector = (id) => new Set(pred[id].map((e) => e.from)).size >= 3;
|
|
74
|
+
const anchorOf = {};
|
|
75
|
+
const pickAnchors = (col) => {
|
|
76
|
+
for (const id of topo) {
|
|
77
|
+
if (!pred[id].length || collector(id)) { anchorOf[id] = null; continue; }
|
|
78
|
+
anchorOf[id] = [...pred[id]].sort((a, b) => col[a.from] - col[b.from] || handleRank(by[a.from], a.handle) - handleRank(by[b.from], b.handle) || a.seq - b.seq)[0];
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const childrenOf = (s) => succ[s].filter((e) => anchorOf[e.to] === e).map((e) => e);
|
|
82
|
+
|
|
83
|
+
// placement
|
|
84
|
+
const extra = {};
|
|
85
|
+
const pos = {};
|
|
86
|
+
const kindOf = {};
|
|
87
|
+
const place = () => {
|
|
88
|
+
const col = cols();
|
|
89
|
+
pickAnchors(col);
|
|
90
|
+
const anchoredSpan = {};
|
|
91
|
+
const span = (id) => {
|
|
92
|
+
if (anchoredSpan[id]) return anchoredSpan[id];
|
|
93
|
+
let lo = col[id], hi = col[id];
|
|
94
|
+
for (const e of childrenOf(id)) { const [a, b] = span(e.to); lo = Math.min(lo, a); hi = Math.max(hi, b); }
|
|
95
|
+
return (anchoredSpan[id] = [lo, hi]);
|
|
96
|
+
};
|
|
97
|
+
const placed = [];
|
|
98
|
+
const setTop = (id, top) => { pos[id] = { x: x0 + col[id] * pitch, y: Math.round(top) }; placed.push(id); };
|
|
99
|
+
const nodeRect = (id) => rect({ ...by[id], position: pos[id] });
|
|
100
|
+
const bottomIn = (lo, hi, belowY, flowId) => {
|
|
101
|
+
let b = -Infinity;
|
|
102
|
+
for (const id of placed) if (flow[id] === flowId && col[id] >= lo && col[id] <= hi) { const r = nodeRect(id); if (r.y2 > belowY) b = Math.max(b, r.y2); }
|
|
103
|
+
return b;
|
|
104
|
+
};
|
|
105
|
+
const raiseFor = (s, child, handleY, childHandle) => {
|
|
106
|
+
const lower = succ[s].filter((e) => handleRank(by[s], e.handle) > handleRank(by[s], childHandle) && (col[e.to] > col[s] + 1 || anchorOf[e.to] === null));
|
|
107
|
+
if (!lower.length) return 0;
|
|
108
|
+
const lowerY = pos[s].y + Math.min(...lower.map((e) => outOffset(by[s], e.handle)));
|
|
109
|
+
const straightBottom = handleY - inOffset(by[child]) + height(by[child]);
|
|
110
|
+
return Math.min(0, lowerY - clear - straightBottom);
|
|
111
|
+
};
|
|
112
|
+
const dfs = (s, flowId) => {
|
|
113
|
+
const kids = childrenOf(s);
|
|
114
|
+
const rejoin = new Set(kids.filter((e) => kids.some((o) => o !== e && reaches(o.to, e.to))).map((e) => e.to));
|
|
115
|
+
const plan = [];
|
|
116
|
+
let straightTaken = false;
|
|
117
|
+
for (const e of kids) if (rejoin.has(e.to) && !straightTaken) { plan.push([e, 'straight']); straightTaken = true; }
|
|
118
|
+
for (const e of kids) if (!plan.some(([p]) => p === e) && [...rejoin].some((r) => reaches(e.to, r))) plan.push([e, 'above']);
|
|
119
|
+
for (const e of kids) if (!plan.some(([p]) => p === e)) { plan.push([e, straightTaken ? 'below' : 'straight']); straightTaken = true; }
|
|
120
|
+
const order2 = { straight: 0, above: 1, below: 2 };
|
|
121
|
+
plan.sort((a, b) => order2[a[1]] - order2[b[1]]);
|
|
122
|
+
for (const [e, kind] of plan) {
|
|
123
|
+
const child = e.to;
|
|
124
|
+
const handleY = pos[s].y + outOffset(by[s], e.handle);
|
|
125
|
+
let inputY;
|
|
126
|
+
if (kind === 'straight') inputY = handleY + raiseFor(s, child, handleY, e.handle);
|
|
127
|
+
else if (kind === 'above') inputY = handleY - lift;
|
|
128
|
+
else {
|
|
129
|
+
const [lo, hi] = span(child);
|
|
130
|
+
const b = bottomIn(lo, hi, handleY - 30, flowId);
|
|
131
|
+
inputY = b === -Infinity ? handleY + lift : b + gap + inOffset(by[child]);
|
|
132
|
+
}
|
|
133
|
+
kindOf[child] = kind;
|
|
134
|
+
setTop(child, inputY + (extra[child] ?? 0) - inOffset(by[child]));
|
|
135
|
+
dfs(child, flowId);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
let bandTop = 200;
|
|
139
|
+
for (const t of triggers) {
|
|
140
|
+
kindOf[t.id] = 'trigger';
|
|
141
|
+
setTop(t.id, bandTop + (extra[t.id] ?? 0) - outOffset(t, 'main'));
|
|
142
|
+
dfs(t.id, t.id);
|
|
143
|
+
const collectors = topo.filter((id) => flow[id] === t.id && anchorOf[id] === null && id !== t.id);
|
|
144
|
+
for (const c of collectors) {
|
|
145
|
+
const flowBottom = Math.max(...placed.filter((id) => flow[id] === t.id).map((id) => nodeRect(id).y2));
|
|
146
|
+
kindOf[c] = 'collector';
|
|
147
|
+
setTop(c, flowBottom + gap * 2 + (extra[c] ?? 0));
|
|
148
|
+
dfs(c, t.id);
|
|
149
|
+
}
|
|
150
|
+
const flowTop = Math.min(...placed.filter((id) => flow[id] === t.id).map((id) => nodeRect(id).y1));
|
|
151
|
+
if (flowTop < bandTop - 2000) throw new Error('layout ran away upwards');
|
|
152
|
+
bandTop = Math.max(...placed.filter((id) => flow[id] === t.id).map((id) => nodeRect(id).y2)) + band;
|
|
153
|
+
}
|
|
154
|
+
for (const n of nodes) n.position = pos[n.id];
|
|
155
|
+
return col;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// A row is a node placed above / below / as a collector, plus everything hanging straight off it.
|
|
159
|
+
const rowRoot = (id) => { while (kindOf[id] === 'straight') id = anchorOf[id].from; return id; };
|
|
160
|
+
// Push the lower of two rows down, or lift an above-detour row higher.
|
|
161
|
+
const separate = (upperId, lowerId, amount) => {
|
|
162
|
+
const u = rowRoot(upperId), l = rowRoot(lowerId);
|
|
163
|
+
if (u === l) { extra[lowerId] = (extra[lowerId] ?? 0) + amount; return; }
|
|
164
|
+
if (kindOf[u] === 'above') extra[u] = (extra[u] ?? 0) - amount;
|
|
165
|
+
else if (kindOf[l] === 'below' || kindOf[l] === 'collector' || kindOf[l] === 'above') extra[l] = (extra[l] ?? 0) + amount;
|
|
166
|
+
else extra[lowerId] = (extra[lowerId] ?? 0) + amount;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
let col = place();
|
|
170
|
+
let report = analyse(graph);
|
|
171
|
+
for (let round = 0; round < rounds && report.problems.length; round++) {
|
|
172
|
+
const p = report.problems[0];
|
|
173
|
+
if (p.kind === 'crossing' && p.seg.dir === 'h') {
|
|
174
|
+
const r = rect(by[p.node]);
|
|
175
|
+
const y = p.seg.y1;
|
|
176
|
+
const nodeAbove = (r.y1 + r.y2) / 2 < y;
|
|
177
|
+
if (rowRoot(p.node) === rowRoot(p.from)) {
|
|
178
|
+
// same row: step the node off the line (an approval's lower line under its own row)
|
|
179
|
+
extra[p.node] = (extra[p.node] ?? 0) + (nodeAbove ? -(r.y2 + clear - y) : y + clear - r.y1);
|
|
180
|
+
} else if (nodeAbove) separate(p.node, p.from, r.y2 + clear - y);
|
|
181
|
+
else separate(p.from, p.node, y + clear - r.y1);
|
|
182
|
+
} else if (p.kind === 'crossing') colMin[p.to] = col[p.to] + 1;
|
|
183
|
+
else if (p.kind === 'overlap') {
|
|
184
|
+
const ra = rect(by[p.a]), rb = rect(by[p.b]);
|
|
185
|
+
const [upper, lower] = ra.y1 + ra.y2 <= rb.y1 + rb.y2 ? [p.a, p.b] : [p.b, p.a];
|
|
186
|
+
const ru = rect(by[upper]), rl = rect(by[lower]);
|
|
187
|
+
separate(upper, lower, ru.y2 + gap - rl.y1);
|
|
188
|
+
} else if (p.kind === 'backward') colMin[p.to] = col[p.from] + 1;
|
|
189
|
+
col = place();
|
|
190
|
+
report = analyse(graph);
|
|
191
|
+
}
|
|
192
|
+
return report;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
if (process.argv[1] && fs.realpathSync(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
196
|
+
const graph = readGraph(process.argv[2]);
|
|
197
|
+
const report = autoLayout(graph);
|
|
198
|
+
console.error(`straight edges ${report.straight}/${report.total}${report.problems.length ? '' : ', no problems'}`);
|
|
199
|
+
for (const p of report.problems) console.error(' ' + p.text);
|
|
200
|
+
process.stdout.write(JSON.stringify(graph, null, 1));
|
|
201
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Edge model shared by layout-check and auto-layout: the builder draws an edge as a step line —
|
|
2
|
+
// horizontal from the source handle to the midpoint x, vertical, horizontal into the target handle.
|
|
3
|
+
import { MAX_WIDTH, OUT_X, height, inOffset, outOffset } from './geometry.mjs';
|
|
4
|
+
|
|
5
|
+
export const MARGIN = 10; // a line closer than this to a node border reads as touching it
|
|
6
|
+
|
|
7
|
+
export const rect = (n) => ({ x1: n.position.x, y1: n.position.y, x2: n.position.x + MAX_WIDTH, y2: n.position.y + height(n) });
|
|
8
|
+
|
|
9
|
+
export const edges = (graph) => {
|
|
10
|
+
const by = Object.fromEntries(graph.nodes.map((n) => [n.id, n]));
|
|
11
|
+
const list = [];
|
|
12
|
+
for (const [from, handles] of Object.entries(graph.connections)) {
|
|
13
|
+
for (const [handle, targets] of Object.entries(handles)) {
|
|
14
|
+
for (const t of targets) {
|
|
15
|
+
const s = by[from], d = by[t.node];
|
|
16
|
+
if (!s || !d) continue;
|
|
17
|
+
const sx = s.position.x + OUT_X, sy = s.position.y + outOffset(s, handle);
|
|
18
|
+
const tx = d.position.x, ty = d.position.y + inOffset(d);
|
|
19
|
+
const mx = (sx + tx) / 2;
|
|
20
|
+
list.push({
|
|
21
|
+
from, to: t.node, handle, sx, sy, tx, ty,
|
|
22
|
+
segments: [
|
|
23
|
+
{ dir: 'h', x1: sx, x2: mx, y1: sy, y2: sy },
|
|
24
|
+
{ dir: 'v', x1: mx, x2: mx, y1: Math.min(sy, ty), y2: Math.max(sy, ty) },
|
|
25
|
+
{ dir: 'h', x1: mx, x2: tx, y1: ty, y2: ty },
|
|
26
|
+
],
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return list;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const hits = (s, r) => s.x1 < r.x2 + MARGIN && s.x2 > r.x1 - MARGIN && s.y1 < r.y2 + MARGIN && s.y2 > r.y1 - MARGIN;
|
|
35
|
+
|
|
36
|
+
// Everything that makes a canvas hard to read, as structured problems.
|
|
37
|
+
export const analyse = (graph) => {
|
|
38
|
+
const problems = [];
|
|
39
|
+
const list = edges(graph);
|
|
40
|
+
for (const e of list) {
|
|
41
|
+
if (e.tx <= e.sx) problems.push({ kind: 'backward', from: e.from, to: e.to, text: `backward edge ${e.from} → ${e.to} (target must be right of the source)` });
|
|
42
|
+
for (const n of graph.nodes) {
|
|
43
|
+
if (n.id === e.from || n.id === e.to) continue;
|
|
44
|
+
const seg = e.segments.find((g) => g.y1 !== g.y2 || g.x1 !== g.x2 ? hits(g, rect(n)) : false);
|
|
45
|
+
if (seg) problems.push({ kind: 'crossing', from: e.from, to: e.to, handle: e.handle, node: n.id, seg, text: `${e.from} → ${e.to} [${e.handle}] runs through or along ${n.id}` });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const ns = graph.nodes;
|
|
49
|
+
for (let i = 0; i < ns.length; i++) for (let j = i + 1; j < ns.length; j++) {
|
|
50
|
+
const r = rect(ns[i]), q = rect(ns[j]);
|
|
51
|
+
if (r.x1 < q.x2 + 20 && r.x2 > q.x1 - 20 && r.y1 < q.y2 + 20 && r.y2 > q.y1 - 20) problems.push({ kind: 'overlap', a: ns[i].id, b: ns[j].id, text: `nodes overlap: ${ns[i].id} / ${ns[j].id}` });
|
|
52
|
+
}
|
|
53
|
+
const straight = list.filter((e) => e.sy === e.ty).length;
|
|
54
|
+
return { problems, straight, total: list.length };
|
|
55
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Node geometry of the Suppa workflow builder (Vue Flow), measured in the canvas (zoom-independent).
|
|
2
|
+
// position = top-left corner. Widths vary 160..280 with the name; 280 is the worst case.
|
|
3
|
+
export const MAX_WIDTH = 280;
|
|
4
|
+
export const OUT_X = 264; // x of an output handle on a 280-wide node (smaller nodes: width - 16)
|
|
5
|
+
|
|
6
|
+
const isTrigger = (n) => n.type === 'formSubmission' || n.type === 'triggerEntity' || n.type === 'triggerWebhook' || n.type === 'triggerSchedule' || n.type === 'triggerManual';
|
|
7
|
+
const rules = (n) => (n.parameters && n.parameters.rules) || [];
|
|
8
|
+
|
|
9
|
+
export const height = (n) => {
|
|
10
|
+
if (n.type === 'if' || n.type === 'approval') return 98;
|
|
11
|
+
if (n.type === 'switch') return 74 + 24 * (rules(n).length - 1);
|
|
12
|
+
if (isTrigger(n)) return 53;
|
|
13
|
+
return 48;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// y of the input handle, from the node top (merge: every input sits at the same point).
|
|
17
|
+
export const inOffset = (n) => (n.type === 'if' || n.type === 'approval' ? 49 : n.type === 'switch' ? height(n) / 2 : 24);
|
|
18
|
+
|
|
19
|
+
// y of an output handle, from the node top.
|
|
20
|
+
export const outOffset = (n, handle) => {
|
|
21
|
+
if (isTrigger(n)) return 26;
|
|
22
|
+
if (n.type === 'if') return handle === 'false' ? 78 : 54;
|
|
23
|
+
if (n.type === 'approval') return handle === 'rejected' ? 78 : 54;
|
|
24
|
+
if (n.type === 'switch') {
|
|
25
|
+
const i = rules(n).findIndex((r) => r.output === handle);
|
|
26
|
+
if (i < 0) throw new Error(`switch ${n.id} has no output ${handle}`);
|
|
27
|
+
return 54 + 24 * i;
|
|
28
|
+
}
|
|
29
|
+
return 24;
|
|
30
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Fingerprints a graph so the stored draft can be compared with the local build without reading it back
|
|
2
|
+
// through a tool (outputs are huge). The same canon()/sha() run inside the tenant page — see references/publishing.md.
|
|
3
|
+
// usage: node graph-hash.mjs <graph.json> → prints nodes / connections / settings hashes
|
|
4
|
+
// graph.json: the stored shape or a suppa_get_automation answer (its draft side) — both hash the same.
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import crypto from 'node:crypto';
|
|
8
|
+
import { readGraph } from './graph.mjs';
|
|
9
|
+
|
|
10
|
+
// The platform strips object keys named `constructor` from stored JSON; drop them so hashes compare.
|
|
11
|
+
const strip = (v) => (Array.isArray(v) ? v.map(strip) : v && typeof v === 'object' ? Object.fromEntries(Object.entries(v).filter(([k]) => k !== 'constructor').map(([k, x]) => [k, strip(x)])) : v);
|
|
12
|
+
// jsonb re-sorts keys, so the fingerprint sorts them too.
|
|
13
|
+
export const canon = (v) => (Array.isArray(v) ? `[${v.map(canon).join(',')}]` : v && typeof v === 'object' ? `{${Object.keys(v).sort().map((k) => `${JSON.stringify(k)}:${canon(v[k])}`).join(',')}}` : JSON.stringify(v));
|
|
14
|
+
const sha = (s) => crypto.createHash('sha256').update(s, 'utf8').digest('hex');
|
|
15
|
+
export const nodesKey = (nodes) => nodes.map((n) => ({ id: n.id, name: n.name, parameters: n.parameters, position: n.position })).sort((a, b) => (a.id < b.id ? -1 : 1));
|
|
16
|
+
|
|
17
|
+
if (process.argv[1] && fs.realpathSync(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
18
|
+
const g = readGraph(process.argv[2]);
|
|
19
|
+
console.log('nodes ', sha(canon(strip(nodesKey(g.nodes)))));
|
|
20
|
+
console.log('connections', sha(canon(g.connections)));
|
|
21
|
+
if (g.settings) console.log('settings ', sha(canon(strip(g.settings))));
|
|
22
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Reads a graph file in either shape the tools hand out and returns the stored shape the scripts work on:
|
|
2
|
+
// - stored (what suppa_update_automation takes): nodes[].parameters + connections { from: { handle: [{ node, index }] } };
|
|
3
|
+
// - normalized (what suppa_get_automation returns): nodes[].config + edges [{ from, fromHandle, to, toIndex }], the
|
|
4
|
+
// published snapshot under `published`.
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
|
|
7
|
+
export const toStored = (g) => {
|
|
8
|
+
if (!g || !Array.isArray(g.nodes)) throw new Error('not a graph: expected { nodes, connections } or the suppa_get_automation answer { nodes, edges }');
|
|
9
|
+
const normalized = Array.isArray(g.edges) || g.nodes.some((n) => n && 'config' in n && !('parameters' in n));
|
|
10
|
+
if (!normalized) return g.connections ? g : { ...g, connections: {} };
|
|
11
|
+
const nodes = g.nodes.map(({ config, ...n }) => ('parameters' in n ? n : { ...n, parameters: config ?? {} }));
|
|
12
|
+
const connections = {};
|
|
13
|
+
for (const e of g.edges ?? []) ((connections[e.from] ??= {})[e.fromHandle] ??= []).push({ node: e.to, index: e.toIndex ?? 0 });
|
|
14
|
+
return { nodes, connections, ...(g.settings ? { settings: g.settings } : {}) };
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// side 'published': the snapshot that runs now, when the file is a suppa_get_automation answer (a stored file is itself).
|
|
18
|
+
export const readGraph = (file, { side = 'draft' } = {}) => {
|
|
19
|
+
const raw = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
20
|
+
return toStored(side === 'published' && raw && raw.published ? raw.published : raw);
|
|
21
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Reports what makes a canvas hard to read: lines through or along nodes, overlapping nodes, backward edges.
|
|
2
|
+
// usage: node layout-check.mjs <graph.json> → exit 1 when anything is reported (stored shape or a suppa_get_automation answer)
|
|
3
|
+
import { analyse } from './edges.mjs';
|
|
4
|
+
import { readGraph } from './graph.mjs';
|
|
5
|
+
|
|
6
|
+
const { problems, straight, total } = analyse(readGraph(process.argv[2]));
|
|
7
|
+
console.log(`straight edges ${straight}/${total}`);
|
|
8
|
+
for (const p of problems) console.log(' ' + p.text);
|
|
9
|
+
process.exit(problems.length ? 1 : 0);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Places nodes so each input sits level with the output that feeds it: the builder then draws that edge straight.
|
|
2
|
+
// usage: node layout.mjs <graph.json> <spec.json> [--pitch 340] [--x0 80] > placed.json
|
|
3
|
+
// graph.json: { nodes, connections, settings? } or a suppa_get_automation answer; placed.json is the stored shape.
|
|
4
|
+
// spec.json: { "<id>": [column, "<source id>" | null, "<source handle>" | null, dy] }
|
|
5
|
+
// input y = source handle y + dy (dy = 0 → straight); a trigger takes [column, null, null, <y of its output>].
|
|
6
|
+
// Several flows in one automation: give each flow its own trigger row (e.g. flow B's trigger 400+ below flow A's lowest node).
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
import { inOffset, outOffset } from './geometry.mjs';
|
|
10
|
+
import { readGraph } from './graph.mjs';
|
|
11
|
+
|
|
12
|
+
export const place = (nodes, spec, { pitch = 340, x0 = 80 } = {}) => {
|
|
13
|
+
const by = Object.fromEntries(nodes.map((n) => [n.id, n]));
|
|
14
|
+
const missing = nodes.filter((n) => !spec[n.id]).map((n) => n.id);
|
|
15
|
+
if (missing.length) throw new Error(`no place for: ${missing.join(', ')}`);
|
|
16
|
+
const done = new Set();
|
|
17
|
+
const visiting = new Set();
|
|
18
|
+
const put = (id) => {
|
|
19
|
+
if (done.has(id)) return;
|
|
20
|
+
if (visiting.has(id)) throw new Error(`placement cycle at ${id}`);
|
|
21
|
+
visiting.add(id);
|
|
22
|
+
const [col, from, handle, dy] = spec[id];
|
|
23
|
+
const n = by[id];
|
|
24
|
+
let top;
|
|
25
|
+
if (from == null) top = dy - outOffset(n, 'main');
|
|
26
|
+
else {
|
|
27
|
+
if (!by[from]) throw new Error(`${id}: unknown source ${from}`);
|
|
28
|
+
put(from);
|
|
29
|
+
top = by[from].position.y + outOffset(by[from], handle) + dy - inOffset(n);
|
|
30
|
+
}
|
|
31
|
+
n.position = { x: x0 + col * pitch, y: Math.round(top) };
|
|
32
|
+
done.add(id);
|
|
33
|
+
};
|
|
34
|
+
for (const n of nodes) put(n.id);
|
|
35
|
+
return nodes;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
if (process.argv[1] && fs.realpathSync(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
39
|
+
const [graphFile, specFile, ...rest] = process.argv.slice(2);
|
|
40
|
+
if (!graphFile || !specFile) { console.error('usage: node layout.mjs <graph.json> <spec.json> [--pitch N] [--x0 N]'); process.exit(2); }
|
|
41
|
+
const opt = (k, d) => { const i = rest.indexOf(`--${k}`); return i >= 0 ? Number(rest[i + 1]) : d; };
|
|
42
|
+
const graph = readGraph(graphFile);
|
|
43
|
+
place(graph.nodes, JSON.parse(fs.readFileSync(specFile, 'utf8')), { pitch: opt('pitch', 340), x0: opt('x0', 80) });
|
|
44
|
+
process.stdout.write(JSON.stringify(graph, null, 1));
|
|
45
|
+
}
|