@g1cloud/bpmn-modeler-next 5.0.0-alpha.3 → 5.0.0-alpha.5

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.
@@ -1,6 +1,7 @@
1
1
  import { BpmnDocumentModelerLike } from '../core/modelerLike';
2
2
  import { SymbolicOp } from './symbolicOp';
3
3
  import { ResolveIssue } from './resolver';
4
+ import { GeometryFinding } from './geometryAudit';
4
5
  /** op 출처 — 감사·정책 분기용. `gui` = 호스트 채팅 패널, `rest` = 외부 브리지. */
5
6
  export type BpmnOpOrigin = 'agent' | 'gui' | 'rest';
6
7
  export interface BpmnOpBatch {
@@ -29,10 +30,17 @@ export declare function buildBpmnOpBatch(documentId: string, baseVersion: number
29
30
  * - `conflict` → 에이전트가 read 부터 다시(재-ground 후 재생성). op 재전송은 무의미
30
31
  * - `rejected` → 어휘·참조 문제라 op 를 고쳐 재전송
31
32
  */
32
- export type ApplyBatchOutcome = {
33
+ export type ApplyBatchOutcome =
34
+ /**
35
+ * `findings` = 이 배치가 **새로 만든** 기하 결함(B-9). 거부가 아니라 품질 소견이라
36
+ * `rejected` 로 가지 않는다 — 문서는 이미 적용됐고 고칠지는 읽는 쪽이 정한다.
37
+ * 선재 결함은 담기지 않는다(하강 전후 diff). 문서 전체 감사는 `auditBpmnGeometry`.
38
+ */
39
+ {
33
40
  status: 'applied';
34
41
  version: number;
35
42
  xml: string;
43
+ findings: GeometryFinding[];
36
44
  } | {
37
45
  status: 'conflict';
38
46
  baseVersion: number;
@@ -0,0 +1,87 @@
1
+ import { default as ElementRegistry } from 'diagram-js/lib/core/ElementRegistry';
2
+ import { ModdleElement, ParseWarning } from '../adapter/xml';
3
+ export interface GeometryPoint {
4
+ x: number;
5
+ y: number;
6
+ }
7
+ export interface GeometryShape {
8
+ id: string;
9
+ /** bpmn 타입(`bpmn:Task` 등) — 판정 제외 규칙과 보고 맥락에 쓴다. */
10
+ type: string;
11
+ x: number;
12
+ y: number;
13
+ width: number;
14
+ height: number;
15
+ /** 다른 요소를 담는 도형(풀·레인·그룹·확장 서브프로세스) — 판정 대상에서 제외된다. */
16
+ container: boolean;
17
+ /** 경계 이벤트처럼 **호스트에 붙는 것이 정상**인 도형 — 겹침 판정에서 제외된다. */
18
+ attached: boolean;
19
+ }
20
+ export interface GeometryEdge {
21
+ id: string;
22
+ type: string;
23
+ waypoints: GeometryPoint[];
24
+ /** 이 간선이 자기 끝점으로 삼는 도형 id 들 — 그 도형과의 교차는 도킹이라 관통이 아니다. */
25
+ endpoints: readonly string[];
26
+ }
27
+ /** 판정기가 대면하는 최소 입력 — 좌표만 담는다(의미론 없음). */
28
+ export interface GeometryScene {
29
+ shapes: GeometryShape[];
30
+ edges: GeometryEdge[];
31
+ }
32
+ export type GeometryFinding =
33
+ /**
34
+ * 간선이 자기 끝점이 아닌 도형을 관통한다. 원인은 대개 **라우팅**이지 힌트가 아니다 —
35
+ * bpmn-js 는 장애물을 회피하지 않으므로 두 노드가 같은 축에 놓이면 그 사이를 지나간다.
36
+ */
37
+ {
38
+ kind: 'edge-crosses-shape';
39
+ edge: string;
40
+ shape: string;
41
+ }
42
+ /**
43
+ * 두 도형이 겹친다. `identical` = bounds 가 완전히 같다 — **사람 눈으로 볼 수 없는**
44
+ * 클래스라 따로 표시한다(하나가 다른 하나를 가린다).
45
+ */
46
+ | {
47
+ kind: 'shape-overlap';
48
+ shapes: [string, string];
49
+ identical: boolean;
50
+ };
51
+ /** 발견을 전후 비교(배치가 새로 만든 것 가려내기)할 수 있게 하는 안정 키. */
52
+ export declare function geometryFindingKey(finding: GeometryFinding): string;
53
+ /**
54
+ * 이 간선이 관통하는 도형들(자기 끝점 제외). 판정과 **우회 보정**(routeRepair)이 같은
55
+ * 술어를 써야 "고쳤다는데 판정은 그대로"가 나지 않는다.
56
+ *
57
+ * `targets` 는 컨테이너를 제외한 도형 목록 — 호출자가 한 번 걸러 넘긴다(반복 호출 비용).
58
+ */
59
+ export declare function crossedShapesOf(edge: GeometryEdge, targets: readonly GeometryShape[]): GeometryShape[];
60
+ /** 컨테이너를 뺀 판정 대상 도형 — 관통·겹침 양쪽의 공통 모집단. */
61
+ export declare const auditTargetsOf: (scene: GeometryScene) => GeometryShape[];
62
+ /**
63
+ * 기하 판정 (순수). 결과는 **결정론적 순서**로 정렬해 반환한다 — 전후 diff·골든 비교·회귀
64
+ * 고정이 전부 순서에 의존한다.
65
+ *
66
+ * 복잡도는 O(간선×구간×도형 + 도형²) 이고 공간 색인을 두지 않았다. 실측 규모(도형 23·간선 25)
67
+ * 에서 무시할 수준이고, 색인은 실제로 큰 문서가 관찰될 때 넣는다(조기 최적화 회피).
68
+ */
69
+ export declare function auditGeometry(scene: GeometryScene): GeometryFinding[];
70
+ /**
71
+ * moddle `definitions` → 장면. 입력은 `describeProcess` 와 같은 트리라 캔버스·헤드리스 양쪽
72
+ * 에서 같은 것을 준다(A-6 입력 계약 동형).
73
+ */
74
+ export declare function sceneFromDefinitions(definitions: ModdleElement): GeometryScene;
75
+ /** 저장 진실 기준 전수 판정 — 그 문서에 있는 **전부**(선재 결함 포함). */
76
+ export declare function auditBpmnGeometry(definitions: ModdleElement): GeometryFinding[];
77
+ export interface AuditBpmnGeometryXmlResult {
78
+ findings: GeometryFinding[];
79
+ warnings: ParseWarning[];
80
+ }
81
+ /** XML 문자열 입력 래퍼 (`describeProcessXml` 대칭) — 호스트가 저장본을 그대로 감사한다. */
82
+ export declare function auditBpmnGeometryXml(xml: string): Promise<AuditBpmnGeometryXmlResult>;
83
+ /**
84
+ * 하강 직후의 실제 상태. DI 는 `BpmnUpdater` 가 커맨드마다 동기화하지만, 하강 경로에서는
85
+ * **registry 가 1차 진실**이므로 그쪽을 읽는다(한 단계 덜 거친다).
86
+ */
87
+ export declare function sceneFromRegistry(registry: ElementRegistry): GeometryScene;
@@ -10,6 +10,15 @@ export interface DocumentIndex {
10
10
  lanesOf(participantId: string): readonly string[];
11
11
  /** 플로우 노드가 속한 참여자 id (풀 없는 단일 프로세스 문서면 undefined) */
12
12
  participantOf(nodeId: string): string | undefined;
13
+ /**
14
+ * 연결의 현재 양 끝점 id — 끝점 재배선(`sequenceFlow.update` 의 source/target)에서
15
+ * **한쪽만 지정한 경우** 나머지 끝을 알아야 풀 정합을 검증할 수 있다.
16
+ * undefined = 그 id 가 문서에 없거나 연결이 아님. 끝점이 없는 연결은 필드가 undefined.
17
+ */
18
+ endpointsOf(connectionId: string): {
19
+ source?: string;
20
+ target?: string;
21
+ } | undefined;
13
22
  }
14
23
  /** elementRegistry 어댑터 — 하강 직전 실문서 상태를 대변한다. */
15
24
  export declare function buildRegistryIndex(registry: ElementRegistry): DocumentIndex;
@@ -1,14 +1,25 @@
1
1
  import { BpmnModelerLike } from '../../core/modelerLike';
2
2
  import { SymbolicOp } from '../symbolicOp';
3
3
  import { ResolveIssue } from './issues';
4
+ import { GeometryFinding } from '../geometryAudit';
4
5
  import { lowerOps } from './lower';
5
6
  export type { ResolveIssue } from './issues';
6
7
  export type { DocumentIndex, ElementCategory } from './documentIndex';
7
8
  export { buildRegistryIndex } from './documentIndex';
8
9
  export { validateOps } from './validate';
9
10
  export { lowerOps, resolverServicesOf, type ResolverServices } from './lower';
11
+ export { planEdgeRepair, planSegmentDetours, repairIntroducedCrossings } from './routeRepair';
10
12
  export interface ApplyBpmnOpsResult {
11
13
  ok: boolean;
12
14
  issues: ResolveIssue[];
15
+ /**
16
+ * 이 배치가 **새로 만든** 기하 결함(B-9). `issues` 와 채널이 다른 이유는 성격이 다르기
17
+ * 때문이다 — issue 는 "하강할 수 없다"(→ `ok: false` → 롤백)이고 finding 은 유효하게
18
+ * 적용된 뒤의 품질 소견이다. 여기 값이 있어도 `ok` 는 참이고 문서는 이미 바뀌었다.
19
+ *
20
+ * **전후 diff 라 선재 결함은 담기지 않는다** — 남의 결함까지 돌려주면 에이전트가 그것을
21
+ * 자기 배치 탓으로 읽고 무한 교정에 빠진다. 문서 전체 감사는 `auditBpmnGeometry`.
22
+ */
23
+ findings: GeometryFinding[];
13
24
  }
14
25
  export declare function applyBpmnOps(modeler: BpmnModelerLike, ops: readonly SymbolicOp[], lower?: typeof lowerOps): ApplyBpmnOpsResult;
@@ -0,0 +1,34 @@
1
+ import { GeometryEdge, GeometryPoint, GeometryShape } from '../geometryAudit';
2
+ import { ResolverServices } from './lower';
3
+ /**
4
+ * 축 정렬 구간이 장애물을 **완전히 가로지를 때** 그것을 우회하는 4점을 만든다(순수).
5
+ *
6
+ * 반환은 `a`·`b` **사이에 끼워 넣을** 점들이다(양 끝점은 포함하지 않는다). 두 방향(위/아래
7
+ * 또는 좌/우)을 모두 돌려주고 어느 쪽이 나은지는 호출자가 판정기로 고른다.
8
+ *
9
+ * `null` = 이 구간은 다루지 않는다:
10
+ * - 사선 구간(축 정렬이 아님) — 우회 형상이 자명하지 않다
11
+ * - 장애물이 구간 끝에 걸쳐 있음 — 끝점 도킹과 얽혀 잘못 건드리면 연결이 떨어져 보인다
12
+ */
13
+ export declare function planSegmentDetours(a: GeometryPoint, b: GeometryPoint, rect: GeometryShape, margin?: number): [GeometryPoint[], GeometryPoint[]] | null;
14
+ /**
15
+ * 한 간선의 관통을 없애는 웨이포인트를 찾는다(순수). 못 찾으면 `null`.
16
+ *
17
+ * 장애물을 하나씩 처리하며 **매번 두 방향을 다 재보고 관통이 더 적은 쪽**을 고른다.
18
+ * 부모 컨테이너 바운즈를 알면 그 밖으로 나가는 우회를 후순위로 민다 — 풀 밖으로 튀어나간
19
+ * 선은 관통이 없어도 사람 눈에 결함이다(판정기가 못 보는 축이라 여기서 챙긴다).
20
+ */
21
+ export declare function planEdgeRepair(edge: GeometryEdge, targets: readonly GeometryShape[], container?: {
22
+ x: number;
23
+ y: number;
24
+ width: number;
25
+ height: number;
26
+ }): GeometryPoint[] | null;
27
+ /**
28
+ * 이 배치가 **새로 만든** 관통을 고친다(하강 직후, undo 에피소드 안에서 호출된다).
29
+ *
30
+ * `beforeKeys` = 하강 전 판정 키 집합. 거기 없던 관통만 대상이다(안전 성질 2).
31
+ * 완전히 해소되는 우회만 채택하고, 아니면 손대지 않는다(안전 성질 1) — 부분 개선을 받으면
32
+ * "고쳤는데 여전히 깨져 있다"가 되어 보고와 실물이 어긋난다.
33
+ */
34
+ export declare function repairIntroducedCrossings(services: Pick<ResolverServices, 'elementRegistry' | 'modeling'>, beforeKeys: ReadonlySet<string>): void;
@@ -62,11 +62,23 @@ export type SymbolicOp =
62
62
  name?: string | null;
63
63
  lane?: string;
64
64
  type?: IrFlowNodeType;
65
- } | {
65
+ }
66
+ /**
67
+ * `source`/`target` = 끝점 재배선(B-6 승격). 한쪽만 줘도 되고(나머지 보존) 새 끝점은
68
+ * **같은 배치에서 추가한 노드여도 된다** — 중간 삽입("A 다음에 X 를 넣어라")이 이것 하나로
69
+ * 표현되어 `element.remove` + 재연결 배치를 강요하지 않는다. resolver 는 `modeling.reconnect`
70
+ * 로 하강하고 경로는 라우터가 재산출한다(기존 벤드포인트는 버린다).
71
+ *
72
+ * ⚠ `messageFlow.update` 에는 아직 없다 — 끝점 이동 수요가 sequenceFlow 로만 관측됐고
73
+ * 어휘는 additive-only(불변식 5)라 나중에 붙이는 비용이 같다.
74
+ */
75
+ | {
66
76
  kind: 'sequenceFlow.update';
67
77
  id: string;
68
78
  name?: string | null;
69
79
  condition?: IrFlowCondition | null;
80
+ source?: string;
81
+ target?: string;
70
82
  } | {
71
83
  kind: 'messageFlow.update';
72
84
  id: string;