@bpmnkit/core 1.2.0 → 1.3.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 +26 -0
- package/dist/bpmn/bpmn-builder.d.ts +8 -0
- package/dist/bpmn/bpmn-builder.js +6 -2
- package/dist/bpmn/compact.d.ts +33 -5
- package/dist/bpmn/compact.js +138 -30
- package/dist/bpmn/connector-line.d.ts +46 -0
- package/dist/bpmn/connector-line.js +135 -0
- package/dist/bpmn/optimize/patterns.js +1 -3
- package/dist/bpmn/process-delta.d.ts +3 -0
- package/dist/bpmn/process-delta.js +23 -0
- package/dist/bpmn/process-text-writer.d.ts +12 -2
- package/dist/bpmn/process-text-writer.js +10 -1
- package/dist/bpmn/process-text.d.ts +26 -1
- package/dist/bpmn/process-text.js +329 -16
- package/dist/bpmn/rest-connector.d.ts +6 -0
- package/dist/bpmn/rest-connector.js +6 -0
- package/dist/bpmn/secrets.d.ts +15 -0
- package/dist/bpmn/secrets.js +59 -0
- package/dist/bpmn/utils.js +4 -0
- package/dist/bpmn/zeebe-extensions.d.ts +10 -0
- package/dist/bpmn/zeebe-extensions.js +7 -0
- package/dist/connectors/aliases.d.ts +21 -0
- package/dist/connectors/aliases.js +272 -0
- package/dist/connectors/api.d.ts +118 -0
- package/dist/connectors/api.js +280 -0
- package/dist/connectors/apply-element.d.ts +59 -0
- package/dist/connectors/apply-element.js +385 -0
- package/dist/connectors/apply.d.ts +136 -0
- package/dist/connectors/apply.js +352 -0
- package/dist/connectors/cards.d.ts +96 -0
- package/dist/connectors/cards.js +306 -0
- package/dist/connectors/catalog.d.ts +79 -0
- package/dist/connectors/catalog.js +209 -0
- package/dist/connectors/index.d.ts +33 -0
- package/dist/connectors/index.js +24 -0
- package/dist/connectors/lines.d.ts +108 -0
- package/dist/connectors/lines.js +568 -0
- package/dist/connectors/select.d.ts +85 -0
- package/dist/connectors/select.js +419 -0
- package/dist/connectors/template-types.d.ts +188 -0
- package/dist/connectors/template-types.js +6 -0
- package/dist/connectors/templates/bpmnkit.d.ts +12 -0
- package/dist/connectors/templates/bpmnkit.js +186 -0
- package/dist/connectors/templates/generated.d.ts +3 -0
- package/dist/connectors/templates/generated.js +95885 -0
- package/dist/connectors/validate.d.ts +66 -0
- package/dist/connectors/validate.js +271 -0
- package/dist/index.d.ts +7 -3
- package/dist/index.js +2 -0
- package/package.json +5 -1
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*
|
|
16
16
|
* @packageDocumentation
|
|
17
17
|
*/
|
|
18
|
+
import { CONNECTOR_LINE, parseConnectorLine } from "./connector-line.js";
|
|
18
19
|
import { ALIASES, KINDS, TRIGGERS, edgeLabel, tokenizePath, } from "./process-text.js";
|
|
19
20
|
/**
|
|
20
21
|
* Kind words the writer uses for element types the line format cannot create.
|
|
@@ -111,6 +112,7 @@ export function parseProcessDelta(text) {
|
|
|
111
112
|
removedNodes: [],
|
|
112
113
|
removedFlows: [],
|
|
113
114
|
addressed: [],
|
|
115
|
+
connectors: [],
|
|
114
116
|
problems: [],
|
|
115
117
|
};
|
|
116
118
|
const declared = new Map();
|
|
@@ -124,6 +126,21 @@ export function parseProcessDelta(text) {
|
|
|
124
126
|
if (tokens.note !== undefined) {
|
|
125
127
|
delta.problems.push({ line: n, message: `ignored the note "${tokens.note}"` });
|
|
126
128
|
}
|
|
129
|
+
for (const id of tokens.bracketless ?? []) {
|
|
130
|
+
delta.problems.push({
|
|
131
|
+
line: n,
|
|
132
|
+
message: `"${id} …" has no brackets; read it as declaring "${id}"`,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
for (const id of tokens.unclosed ?? []) {
|
|
136
|
+
delta.problems.push({
|
|
137
|
+
line: n,
|
|
138
|
+
message: `"${id}[" is not closed; closed it where its name ends`,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
for (const { written, id } of tokens.joined ?? []) {
|
|
142
|
+
delta.problems.push({ line: n, message: `"${written}" is not an id; read as "${id}"` });
|
|
143
|
+
}
|
|
127
144
|
for (const ref of tokens.refs) {
|
|
128
145
|
if (ref.spec === undefined)
|
|
129
146
|
continue;
|
|
@@ -211,6 +228,12 @@ export function parseProcessDelta(text) {
|
|
|
211
228
|
delta.addressed.push({ item, ids, line: n });
|
|
212
229
|
return;
|
|
213
230
|
}
|
|
231
|
+
if (CONNECTOR_LINE.test(line)) {
|
|
232
|
+
const connector = parseConnectorLine(line, n, delta.problems);
|
|
233
|
+
if (connector)
|
|
234
|
+
delta.connectors.push(connector);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
214
237
|
// `- x` removes; `-> x` is an arrow a model wrote at the start of a line.
|
|
215
238
|
const removed = /^-(?![->])\s*(.*)$/.exec(line);
|
|
216
239
|
if (removed) {
|
|
@@ -15,7 +15,17 @@
|
|
|
15
15
|
*
|
|
16
16
|
* @packageDocumentation
|
|
17
17
|
*/
|
|
18
|
-
import type { BpmnDefinitions } from "./bpmn-model.js";
|
|
18
|
+
import type { BpmnDefinitions, BpmnFlowElement } from "./bpmn-model.js";
|
|
19
|
+
/** Options for {@link writeProcessText}. */
|
|
20
|
+
export interface WriteProcessTextOptions {
|
|
21
|
+
/**
|
|
22
|
+
* Writes an element's connector as a `with` line, after `with <id>: `, or
|
|
23
|
+
* answers `undefined` for an element without one. Pass `connectorLineFor`
|
|
24
|
+
* from `@bpmnkit/core/connectors`, so a model that changes the diagram keeps
|
|
25
|
+
* its connectors; without it no `with` lines are written.
|
|
26
|
+
*/
|
|
27
|
+
connectorLine?: (element: BpmnFlowElement, definitions: BpmnDefinitions) => string | undefined;
|
|
28
|
+
}
|
|
19
29
|
/** What {@link writeProcessText} wrote. */
|
|
20
30
|
export interface WrittenProcessText {
|
|
21
31
|
/** The diagram in the line format. */
|
|
@@ -49,5 +59,5 @@ export declare function writableCondition(condition: string): string;
|
|
|
49
59
|
* // aliases: { start: "StartEvent_1", check_order: "Activity_0x9k2lm", … }
|
|
50
60
|
* ```
|
|
51
61
|
*/
|
|
52
|
-
export declare function writeProcessText(definitions: BpmnDefinitions): WrittenProcessText;
|
|
62
|
+
export declare function writeProcessText(definitions: BpmnDefinitions, options?: WriteProcessTextOptions): WrittenProcessText;
|
|
53
63
|
//# sourceMappingURL=process-text-writer.d.ts.map
|
|
@@ -102,7 +102,7 @@ function label(flow) {
|
|
|
102
102
|
* // aliases: { start: "StartEvent_1", check_order: "Activity_0x9k2lm", … }
|
|
103
103
|
* ```
|
|
104
104
|
*/
|
|
105
|
-
export function writeProcessText(definitions) {
|
|
105
|
+
export function writeProcessText(definitions, options = {}) {
|
|
106
106
|
assertBpmnDefinitions(definitions, "writeProcessText");
|
|
107
107
|
const process = compactify(definitions).processes[0];
|
|
108
108
|
if (!process)
|
|
@@ -185,6 +185,15 @@ export function writeProcessText(definitions) {
|
|
|
185
185
|
if (!declared.has(el.id))
|
|
186
186
|
lines.push(ref(el.id));
|
|
187
187
|
}
|
|
188
|
+
if (options.connectorLine) {
|
|
189
|
+
const real = new Map((definitions.processes[0]?.flowElements ?? []).map((el) => [el.id, el]));
|
|
190
|
+
for (const el of elements) {
|
|
191
|
+
const element = real.get(el.id);
|
|
192
|
+
const line = element && options.connectorLine(element, definitions);
|
|
193
|
+
if (line)
|
|
194
|
+
lines.push(`with ${alias.get(el.id) ?? el.id}: ${line}`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
188
197
|
const aliases = {};
|
|
189
198
|
for (const [id, written] of alias)
|
|
190
199
|
aliases[written] = id;
|
|
@@ -22,13 +22,14 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import type { BpmnDefinitions, BpmnElementType } from "./bpmn-model.js";
|
|
24
24
|
import type { CompactDiagram, CompactFlow } from "./compact.js";
|
|
25
|
+
import { type ConnectorLine } from "./connector-line.js";
|
|
25
26
|
/**
|
|
26
27
|
* How to write the format — the part of a system prompt that teaches it.
|
|
27
28
|
*
|
|
28
29
|
* It lives beside the parser so the two cannot drift: a test parses its example
|
|
29
30
|
* and expects no problems.
|
|
30
31
|
*/
|
|
31
|
-
export declare const PROCESS_TEXT_GUIDE = "Format \u2014 one path per line, nothing else:\n# Process name (first line)\na > b > c sequence flow\nid[kind Name] declare a node the first time it appears; afterwards write only id\ngw >(Label: condition) x conditional branch, condition in FEEL (amount > 1000, status = \"ok\")\ngw >(Label: default) y branch taken when no condition holds\nKinds: start end task user service rule (DMN decision) send receive script manual call xor and or eventgw catch (wait for message or timer) throw boundary\nEvents take a trigger: start:message end:error catch:timer boundary:error (timer message signal error escalation terminate conditional compensate cancel)\nAttributes after |: on=<task id> (required on boundary), nonint (non-interrupting), job=<job type
|
|
32
|
+
export declare const PROCESS_TEXT_GUIDE = "Format \u2014 one path per line, nothing else:\n# Process name (first line)\na > b > c sequence flow\nid[kind Name] declare a node the first time it appears; afterwards write only id\ngw >(Label: condition) x conditional branch, condition in FEEL (amount > 1000, status = \"ok\")\ngw >(Label: default) y branch taken when no condition holds\nKinds: start end task user service rule (DMN decision) send receive script manual call xor and or eventgw catch (wait for message or timer) throw boundary\nEvents take a trigger: start:message end:error catch:timer boundary:error (timer message signal error escalation terminate conditional compensate cancel)\nAttributes after |: on=<task id> (required on boundary), nonint (non-interrupting), job=<job type>, each=<list variable> (once per item), after=<ISO duration> (timer)\nRules:\n- One start event. Every node is on a path from it to an end event: never a node nothing leads to.\n- An xor has two or more branches: exactly one is (Label: default), each other has a FEEL condition.\n- A boundary starts its own line, on a task you declared, and leads to a task that handles it; never draw an arrow into a boundary.\n- Branches that meet again are joined automatically; join parallel branches with an and node.\n- Steps done at the same time start from an and node and meet at another. A deadline is a boundary:timer with after= on the task that may run late. A step done for every item of a list takes each=<list>; use it only when the description says every or each.\n\nExample:\n# Expense approval\nstart[start Expense submitted] > check[xor Amount over 1000?]\ncheck >(Yes: amount > 1000) review[user Review expense] > pay[service Pay expense] > done[end Expense paid]\ncheck >(No: default) auto[service Approve automatically] > pay\nfailed[boundary:error Payment failed | on=pay] > notify[send Notify submitter] > notice[end Payment failed]";
|
|
32
33
|
/** A line, or part of one, that {@link parseProcessText} could not use. */
|
|
33
34
|
export interface ProcessTextProblem {
|
|
34
35
|
/** 1-based line number in the text. */
|
|
@@ -62,6 +63,16 @@ export interface ProcessTextResult {
|
|
|
62
63
|
fixes: string[];
|
|
63
64
|
/** The guesses behind the fixes that only the reader can confirm, in the order of the text. */
|
|
64
65
|
questions: ProcessTextQuestion[];
|
|
66
|
+
/**
|
|
67
|
+
* The `with` lines, each with the id of the element it configures. Not
|
|
68
|
+
* applied: `applyConnectorLines` from `@bpmnkit/core/connectors` writes them
|
|
69
|
+
* onto the expanded diagram.
|
|
70
|
+
*/
|
|
71
|
+
connectors: ConnectorRef[];
|
|
72
|
+
}
|
|
73
|
+
/** A `with` line, and the element it names in the diagram. */
|
|
74
|
+
export interface ConnectorRef extends ConnectorLine {
|
|
75
|
+
elementId: string;
|
|
65
76
|
}
|
|
66
77
|
export declare const KINDS: Record<string, BpmnElementType>;
|
|
67
78
|
/**
|
|
@@ -83,6 +94,15 @@ export interface PathTokens {
|
|
|
83
94
|
labels: (string | undefined)[];
|
|
84
95
|
/** A parenthesised note after the last node, which carries no meaning. */
|
|
85
96
|
note?: string;
|
|
97
|
+
/** Ids written with spaces (`call back[…]`), and the id each was read as. */
|
|
98
|
+
joined?: {
|
|
99
|
+
written: string;
|
|
100
|
+
id: string;
|
|
101
|
+
}[];
|
|
102
|
+
/** Ids whose bracket was never closed, read as closed where the name ends. */
|
|
103
|
+
unclosed?: string[];
|
|
104
|
+
/** Kinds written with a name but no brackets after an arrow (`> end Done`), read as declared. */
|
|
105
|
+
bracketless?: string[];
|
|
86
106
|
}
|
|
87
107
|
/**
|
|
88
108
|
* Splits one complete path line (`a[kind Name] >(Label: cond) b > c`) into its
|
|
@@ -106,6 +126,11 @@ export declare function conditionOrLabel(edge: Pick<CompactFlow, "name" | "condi
|
|
|
106
126
|
edge: Pick<CompactFlow, "name" | "condition" | "isDefault">;
|
|
107
127
|
problem?: string;
|
|
108
128
|
};
|
|
129
|
+
/**
|
|
130
|
+
* An ISO 8601 duration from what models write: `PT5M` as it is, `5m`, `5 min`,
|
|
131
|
+
* `5 minutes`, `2 hours` or `1 day`, also inside a name ("Wait 5 minutes").
|
|
132
|
+
*/
|
|
133
|
+
export declare function duration(text: string): string | undefined;
|
|
109
134
|
export declare function edgeLabel(label: string | undefined): Pick<CompactFlow, "name" | "condition" | "isDefault">;
|
|
110
135
|
/**
|
|
111
136
|
* Reads a process written in the line format ({@link PROCESS_TEXT_GUIDE}).
|