@reopt-ai/opt-workflow 0.0.0-stage → 0.1.1

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.
Files changed (54) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/LICENSE +21 -0
  3. package/README.md +213 -2
  4. package/dist/ai-stream-APc3uCiQ.js +389 -0
  5. package/dist/ai-stream-B_lk9_Rf.cjs +628 -0
  6. package/dist/branch-resolver-BDi6Wu6m.js +589 -0
  7. package/dist/branch-resolver-D_wM183Q.cjs +714 -0
  8. package/dist/core-CtqBb-6v.d.cts +919 -0
  9. package/dist/core-z3nXmUBj.d.ts +919 -0
  10. package/dist/core.cjs +301 -0
  11. package/dist/core.d.cts +5 -0
  12. package/dist/core.d.ts +5 -0
  13. package/dist/core.js +184 -0
  14. package/dist/define-template-Bmn96lF_.cjs +74 -0
  15. package/dist/define-template-BvGNB5Tv.js +69 -0
  16. package/dist/end-node-ids-D6WBaCLm.cjs +109 -0
  17. package/dist/end-node-ids-p85jFEcP.js +86 -0
  18. package/dist/execution-context-DVeybULC.d.cts +258 -0
  19. package/dist/execution-context-YFTRCj0y.d.ts +258 -0
  20. package/dist/grid-workflow-dto-C86EArJP.d.cts +300 -0
  21. package/dist/grid-workflow-dto-C86EArJP.d.ts +300 -0
  22. package/dist/index.cjs +11899 -0
  23. package/dist/index.d.cts +803 -0
  24. package/dist/index.d.ts +803 -0
  25. package/dist/index.js +11852 -0
  26. package/dist/mock.cjs +7295 -0
  27. package/dist/mock.d.cts +88 -0
  28. package/dist/mock.d.ts +88 -0
  29. package/dist/mock.js +7287 -0
  30. package/dist/node-definitions-C-GMfjMm.js +797 -0
  31. package/dist/node-definitions-pS1Zp1dK.cjs +940 -0
  32. package/dist/nodes-D_a8ZkRp.d.cts +50 -0
  33. package/dist/nodes-myp8R2zo.d.ts +50 -0
  34. package/dist/nodes.cjs +36 -0
  35. package/dist/nodes.d.cts +3 -0
  36. package/dist/nodes.d.ts +3 -0
  37. package/dist/nodes.js +4 -0
  38. package/dist/shadcn-bridge.css +72 -0
  39. package/dist/simulate.cjs +6 -0
  40. package/dist/simulate.d.cts +111 -0
  41. package/dist/simulate.d.ts +111 -0
  42. package/dist/simulate.js +1 -0
  43. package/dist/step-type-for-node-Blf5DKrp.js +228 -0
  44. package/dist/step-type-for-node-D9sdHfWA.cjs +281 -0
  45. package/dist/styles.css +4 -0
  46. package/dist/test-executor-C2AvI73G.cjs +342 -0
  47. package/dist/test-executor-DpT3qXIT.js +313 -0
  48. package/dist/types-Bj0VWFny.d.cts +126 -0
  49. package/dist/types-C5744w6f.d.cts +184 -0
  50. package/dist/types-DQcmIuAl.d.ts +126 -0
  51. package/dist/types-dVHX2CyI.d.ts +184 -0
  52. package/dist/workflow-preview-B0kul6f-.js +1742 -0
  53. package/dist/workflow-preview-CZzXKXqK.cjs +2065 -0
  54. package/package.json +119 -4
@@ -0,0 +1,940 @@
1
+ const require_end_node_ids = require("./end-node-ids-D6WBaCLm.cjs");
2
+ let lucide_react = require("lucide-react");
3
+ // src/lib/node-contracts/actions/delay.ts
4
+ const delayContract = {
5
+ id: "delay",
6
+ name: "대기",
7
+ description: "지정된 시간만큼 대기합니다",
8
+ icon: lucide_react.CalendarIcon,
9
+ color: "bg-gray-500",
10
+ category: "utility",
11
+ editorCategory: "액션",
12
+ fields: [{
13
+ key: "duration",
14
+ label: "대기 시간",
15
+ type: "number",
16
+ required: true,
17
+ placeholder: "10",
18
+ validation: { min: 1 }
19
+ }, {
20
+ key: "unit",
21
+ label: "시간 단위",
22
+ type: "select",
23
+ required: false,
24
+ options: [
25
+ {
26
+ label: "초",
27
+ value: "seconds"
28
+ },
29
+ {
30
+ label: "분",
31
+ value: "minutes"
32
+ },
33
+ {
34
+ label: "시간",
35
+ value: "hours"
36
+ },
37
+ {
38
+ label: "일",
39
+ value: "days"
40
+ }
41
+ ],
42
+ defaultValue: "seconds"
43
+ }]
44
+ };
45
+ // src/lib/node-contracts/actions/http-request.ts
46
+ const httpRequestContract = {
47
+ id: "httpRequest",
48
+ name: "HTTP 요청",
49
+ description: "외부 API를 호출합니다",
50
+ icon: lucide_react.GlobeIcon,
51
+ color: "bg-cyan-500",
52
+ category: "integration",
53
+ editorCategory: "통합",
54
+ fields: [
55
+ {
56
+ key: "url",
57
+ label: "URL",
58
+ type: "text",
59
+ required: true,
60
+ placeholder: "https://api.example.com/endpoint"
61
+ },
62
+ {
63
+ key: "method",
64
+ label: "HTTP 메서드",
65
+ type: "select",
66
+ required: true,
67
+ options: [
68
+ {
69
+ label: "GET",
70
+ value: "GET"
71
+ },
72
+ {
73
+ label: "POST",
74
+ value: "POST"
75
+ },
76
+ {
77
+ label: "PUT",
78
+ value: "PUT"
79
+ },
80
+ {
81
+ label: "DELETE",
82
+ value: "DELETE"
83
+ },
84
+ {
85
+ label: "PATCH",
86
+ value: "PATCH"
87
+ }
88
+ ]
89
+ },
90
+ {
91
+ key: "headers",
92
+ label: "헤더 (JSON)",
93
+ type: "json",
94
+ editorType: "textarea",
95
+ required: false,
96
+ placeholder: "{\"Authorization\": \"Bearer xxx\"}"
97
+ },
98
+ {
99
+ key: "body",
100
+ label: "요청 본문 (JSON)",
101
+ type: "json",
102
+ editorType: "textarea",
103
+ required: false,
104
+ placeholder: "{\"key\": \"value\"}"
105
+ },
106
+ {
107
+ key: "responseVariable",
108
+ label: "응답 변수",
109
+ type: "text",
110
+ required: false,
111
+ placeholder: "httpResponse"
112
+ }
113
+ ]
114
+ };
115
+ // src/lib/node-contracts/actions/transform-data.ts
116
+ const transformDataContract = {
117
+ id: "transformData",
118
+ name: "데이터 변환",
119
+ description: "데이터를 변환하고 가공합니다",
120
+ icon: lucide_react.ShuffleIcon,
121
+ color: "bg-amber-500",
122
+ category: "utility",
123
+ editorCategory: "데이터",
124
+ fields: [
125
+ {
126
+ key: "input",
127
+ label: "입력 변수",
128
+ type: "text",
129
+ required: true,
130
+ placeholder: "items"
131
+ },
132
+ {
133
+ key: "transform",
134
+ label: "변환 유형",
135
+ type: "select",
136
+ required: true,
137
+ options: [
138
+ {
139
+ label: "map",
140
+ value: "map"
141
+ },
142
+ {
143
+ label: "filter",
144
+ value: "filter"
145
+ },
146
+ {
147
+ label: "reduce",
148
+ value: "reduce"
149
+ },
150
+ {
151
+ label: "pick",
152
+ value: "pick"
153
+ },
154
+ {
155
+ label: "omit",
156
+ value: "omit"
157
+ },
158
+ {
159
+ label: "flatten",
160
+ value: "flatten"
161
+ },
162
+ {
163
+ label: "groupBy",
164
+ value: "groupBy"
165
+ },
166
+ {
167
+ label: "sortBy",
168
+ value: "sortBy"
169
+ },
170
+ {
171
+ label: "jmespath",
172
+ value: "jmespath"
173
+ },
174
+ {
175
+ label: "jsonpath",
176
+ value: "jsonpath"
177
+ }
178
+ ]
179
+ },
180
+ {
181
+ key: "expression",
182
+ label: "표현식",
183
+ type: "text",
184
+ required: false,
185
+ placeholder: "item.name"
186
+ },
187
+ {
188
+ key: "outputVariable",
189
+ label: "결과 변수",
190
+ type: "text",
191
+ required: true,
192
+ placeholder: "transformedData"
193
+ }
194
+ ]
195
+ };
196
+ // src/lib/loop-defaults.ts
197
+ /** Shared by node schemas, editor metadata, and the deterministic loop runners. */
198
+ const DEFAULT_MAX_ITERATIONS = 1e3;
199
+ // src/lib/node-contracts/control/loop.ts
200
+ const forEachContract = {
201
+ id: "forEach",
202
+ name: "반복 (forEach)",
203
+ description: "배열의 각 항목에 대해 body(→ loopEnd까지)를 반복 실행합니다",
204
+ icon: lucide_react.RepeatIcon,
205
+ color: "bg-indigo-500",
206
+ category: "control",
207
+ editorCategory: "제어",
208
+ fields: [
209
+ {
210
+ key: "collection",
211
+ label: "배열 변수",
212
+ type: "variable",
213
+ editorType: "text",
214
+ required: true,
215
+ placeholder: "items"
216
+ },
217
+ {
218
+ key: "itemVariable",
219
+ label: "항목 변수명",
220
+ type: "text",
221
+ required: true,
222
+ placeholder: "item"
223
+ },
224
+ {
225
+ key: "indexVariable",
226
+ label: "인덱스 변수명",
227
+ type: "text",
228
+ required: false
229
+ },
230
+ {
231
+ key: "maxIterations",
232
+ label: "최대 반복 횟수",
233
+ type: "number",
234
+ required: false,
235
+ defaultValue: DEFAULT_MAX_ITERATIONS
236
+ }
237
+ ]
238
+ };
239
+ const whileContract = {
240
+ id: "while",
241
+ name: "반복 (while)",
242
+ description: "조건이 참인 동안 body(→ loopEnd까지)를 반복 실행합니다",
243
+ icon: lucide_react.RepeatIcon,
244
+ color: "bg-indigo-600",
245
+ category: "control",
246
+ editorCategory: "제어",
247
+ fields: [
248
+ {
249
+ key: "condition",
250
+ label: "조건 표현식",
251
+ type: "textarea",
252
+ required: true,
253
+ placeholder: "{{count}} < 10",
254
+ helpText: "참인 동안 반복합니다. {{변수}} === '값' · {{변수}} < 10 · {{변수}} 형식만 됩니다."
255
+ },
256
+ {
257
+ key: "maxIterations",
258
+ label: "최대 반복 횟수",
259
+ type: "number",
260
+ required: false,
261
+ placeholder: "100",
262
+ defaultValue: DEFAULT_MAX_ITERATIONS
263
+ },
264
+ {
265
+ key: "iterationVariable",
266
+ label: "반복 횟수 변수명",
267
+ type: "text",
268
+ required: false
269
+ }
270
+ ]
271
+ };
272
+ const repeatContract = {
273
+ id: "repeat",
274
+ name: "반복 (repeat)",
275
+ description: "지정된 횟수만큼 body(→ loopEnd까지)를 반복 실행합니다",
276
+ icon: lucide_react.RepeatIcon,
277
+ color: "bg-indigo-400",
278
+ category: "control",
279
+ editorCategory: "제어",
280
+ fields: [{
281
+ key: "count",
282
+ label: "반복 횟수",
283
+ type: "number",
284
+ required: true,
285
+ placeholder: "5"
286
+ }, {
287
+ key: "indexVariable",
288
+ label: "인덱스 변수명",
289
+ type: "text",
290
+ required: false,
291
+ placeholder: "i"
292
+ }]
293
+ };
294
+ // src/lib/node-contracts/control/loop-end.ts
295
+ const loopEndContract = {
296
+ id: "loopEnd",
297
+ name: "반복 끝 (loopEnd)",
298
+ description: "반복(forEach/while/repeat) body의 끝을 표시합니다",
299
+ icon: lucide_react.GitBranchIcon,
300
+ color: "bg-indigo-300",
301
+ category: "control",
302
+ editorCategory: "제어",
303
+ fields: []
304
+ };
305
+ // src/lib/node-contracts/control/parallel.ts
306
+ const parallelContract = {
307
+ id: "parallel",
308
+ name: "병렬 실행",
309
+ description: "여러 작업을 동시에 실행합니다",
310
+ icon: lucide_react.GitBranchIcon,
311
+ color: "bg-teal-500",
312
+ category: "control",
313
+ editorCategory: "제어",
314
+ fields: [
315
+ {
316
+ key: "mode",
317
+ label: "완료 조건",
318
+ type: "select",
319
+ required: false,
320
+ options: [
321
+ {
322
+ label: "모두 완료 (all)",
323
+ value: "all"
324
+ },
325
+ {
326
+ label: "하나 성공 (any)",
327
+ value: "any"
328
+ },
329
+ {
330
+ label: "가장 빠른 것 (race)",
331
+ value: "race"
332
+ },
333
+ {
334
+ label: "모두 settle (allSettled)",
335
+ value: "allSettled"
336
+ }
337
+ ],
338
+ helpText: "⚠️ any/race로 승부가 갈리면 나머지 갈래는 **다음 스텝을 실행하지 않습니다**. 다만 그 순간 이미 시작된 스텝은 끝까지 진행되므로, 그 스텝의 부수효과(메일 발송 등)는 일어납니다.",
339
+ defaultValue: "all"
340
+ },
341
+ {
342
+ key: "maxConcurrency",
343
+ label: "최대 동시 실행 수",
344
+ type: "number",
345
+ required: false,
346
+ placeholder: "5",
347
+ helpText: "묶음 단위로 나눠 실행합니다. 한 묶음이 모두 끝나야 다음 묶음이 시작됩니다.",
348
+ defaultValue: 0
349
+ },
350
+ {
351
+ key: "branchTimeout",
352
+ label: "브랜치 타임아웃(ms)",
353
+ type: "number",
354
+ required: false,
355
+ placeholder: "300000",
356
+ defaultValue: 3e5
357
+ },
358
+ {
359
+ key: "resultVariable",
360
+ label: "결과 변수명",
361
+ type: "text",
362
+ required: false
363
+ },
364
+ {
365
+ key: "branches",
366
+ label: "브랜치 ID 목록",
367
+ type: "multiselect",
368
+ required: true,
369
+ hiddenInEditor: true
370
+ }
371
+ ]
372
+ };
373
+ const joinContract = {
374
+ id: "join",
375
+ name: "병렬 합류",
376
+ description: "병렬 브랜치의 결과를 합칩니다",
377
+ icon: lucide_react.GitBranchIcon,
378
+ color: "bg-teal-600",
379
+ category: "control",
380
+ editorCategory: "제어",
381
+ fields: [
382
+ {
383
+ key: "mode",
384
+ label: "합류 모드",
385
+ type: "select",
386
+ required: false,
387
+ options: [
388
+ {
389
+ label: "모두 완료 (all)",
390
+ value: "all"
391
+ },
392
+ {
393
+ label: "하나라도 완료 (any)",
394
+ value: "any"
395
+ },
396
+ {
397
+ label: "가장 빠른 것 (race)",
398
+ value: "race"
399
+ },
400
+ {
401
+ label: "모두 settle (allSettled)",
402
+ value: "allSettled"
403
+ }
404
+ ],
405
+ defaultValue: "all"
406
+ },
407
+ {
408
+ key: "mergeStrategy",
409
+ label: "병합 전략",
410
+ type: "select",
411
+ required: false,
412
+ options: [
413
+ {
414
+ label: "배열로 수집",
415
+ value: "array"
416
+ },
417
+ {
418
+ label: "객체 병합",
419
+ value: "merge"
420
+ },
421
+ {
422
+ label: "첫 번째",
423
+ value: "first"
424
+ },
425
+ {
426
+ label: "마지막",
427
+ value: "last"
428
+ },
429
+ {
430
+ label: "커스텀",
431
+ value: "custom"
432
+ }
433
+ ],
434
+ defaultValue: "array"
435
+ },
436
+ {
437
+ key: "timeout",
438
+ label: "타임아웃(ms)",
439
+ type: "number",
440
+ required: false,
441
+ defaultValue: 6e5
442
+ },
443
+ {
444
+ key: "resultVariable",
445
+ label: "결과 변수명",
446
+ type: "text",
447
+ required: false
448
+ },
449
+ {
450
+ key: "awaitBranches",
451
+ label: "대기할 브랜치 ID",
452
+ type: "multiselect",
453
+ required: true,
454
+ hiddenInEditor: true
455
+ }
456
+ ]
457
+ };
458
+ // src/lib/node-contracts/triggers/manual.ts
459
+ const manualTriggerContract = {
460
+ id: "manual",
461
+ name: "수동 실행",
462
+ description: "워크플로우를 수동으로 실행합니다",
463
+ icon: lucide_react.PlayIcon,
464
+ color: "bg-blue-500",
465
+ category: "trigger",
466
+ editorCategory: "트리거",
467
+ fields: []
468
+ };
469
+ // src/lib/node-contracts/triggers/schedule.ts
470
+ const scheduleTriggerContract = {
471
+ id: "schedule",
472
+ name: "일정 트리거",
473
+ description: "지정된 일정에 따라 자동 실행합니다",
474
+ icon: lucide_react.CalendarIcon,
475
+ color: "bg-purple-500",
476
+ category: "trigger",
477
+ editorCategory: "트리거",
478
+ fields: [
479
+ {
480
+ key: "schedule",
481
+ label: "실행 일정",
482
+ type: "select",
483
+ required: true,
484
+ options: [
485
+ {
486
+ label: "매일",
487
+ value: "daily"
488
+ },
489
+ {
490
+ label: "매주",
491
+ value: "weekly"
492
+ },
493
+ {
494
+ label: "매월",
495
+ value: "monthly"
496
+ }
497
+ ]
498
+ },
499
+ {
500
+ key: "time",
501
+ label: "실행 시각",
502
+ type: "text",
503
+ required: true,
504
+ placeholder: "09:00",
505
+ helpText: "HH:mm 형식. 비워 두면 실행되지 않습니다."
506
+ },
507
+ {
508
+ key: "dayOfWeek",
509
+ label: "요일",
510
+ type: "select",
511
+ showWhen: {
512
+ field: "schedule",
513
+ value: "weekly"
514
+ },
515
+ options: [
516
+ {
517
+ label: "일요일",
518
+ value: "0"
519
+ },
520
+ {
521
+ label: "월요일",
522
+ value: "1"
523
+ },
524
+ {
525
+ label: "화요일",
526
+ value: "2"
527
+ },
528
+ {
529
+ label: "수요일",
530
+ value: "3"
531
+ },
532
+ {
533
+ label: "목요일",
534
+ value: "4"
535
+ },
536
+ {
537
+ label: "금요일",
538
+ value: "5"
539
+ },
540
+ {
541
+ label: "토요일",
542
+ value: "6"
543
+ }
544
+ ],
545
+ helpText: "'매주'일 때만 사용합니다. 비우면 매일로 취급합니다."
546
+ },
547
+ {
548
+ key: "dayOfMonth",
549
+ label: "날짜",
550
+ type: "number",
551
+ showWhen: {
552
+ field: "schedule",
553
+ value: "monthly"
554
+ },
555
+ placeholder: "1",
556
+ helpText: "'매월'일 때만 사용합니다(1~31). 비우면 매일로 취급합니다.",
557
+ validation: {
558
+ min: 1,
559
+ max: 31
560
+ }
561
+ },
562
+ {
563
+ key: "timezone",
564
+ label: "타임존",
565
+ type: "text",
566
+ placeholder: "Asia/Seoul",
567
+ helpText: "비우면 한국 시간(Asia/Seoul) 기준입니다.",
568
+ defaultValue: "Asia/Seoul"
569
+ },
570
+ {
571
+ key: "cronExpression",
572
+ hiddenInEditor: true,
573
+ label: "Cron 표현식",
574
+ type: "text",
575
+ required: false,
576
+ placeholder: "0 9 * * *",
577
+ helpText: "분 시 일 월 요일",
578
+ showWhen: {
579
+ field: "schedule",
580
+ value: "custom"
581
+ }
582
+ }
583
+ ]
584
+ };
585
+ // src/lib/node-contracts/triggers/webhook.ts
586
+ const webhookTriggerContract = {
587
+ id: "webhook",
588
+ name: "Webhook",
589
+ description: "Webhook으로 워크플로우를 시작합니다",
590
+ icon: lucide_react.WebhookIcon,
591
+ color: "bg-orange-500",
592
+ category: "trigger",
593
+ editorCategory: "트리거",
594
+ fields: [
595
+ {
596
+ key: "secret",
597
+ label: "검증 비밀키",
598
+ type: "text",
599
+ required: false,
600
+ placeholder: "webhook_secret_key",
601
+ helpText: "요청 검증을 위한 비밀키"
602
+ },
603
+ {
604
+ key: "allowedIps",
605
+ label: "허용 IP",
606
+ type: "text",
607
+ required: false,
608
+ placeholder: "192.168.1.1, 10.0.0.0/8",
609
+ helpText: "쉼표로 구분된 IP 또는 CIDR"
610
+ },
611
+ {
612
+ key: "payloadVariable",
613
+ label: "페이로드 변수명",
614
+ type: "text",
615
+ required: false,
616
+ placeholder: "webhookData",
617
+ helpText: "요청 데이터를 저장할 변수명"
618
+ }
619
+ ]
620
+ };
621
+ // src/lib/node-contracts/to-node-definition.ts
622
+ const _excluded = [
623
+ "hiddenInEditor",
624
+ "defaultValue",
625
+ "validation",
626
+ "editorType"
627
+ ];
628
+ function toEditorField(field) {
629
+ const { hiddenInEditor: _hidden, defaultValue: _default, validation: _validation, editorType } = field, visible = require_end_node_ids._objectWithoutProperties(field, _excluded);
630
+ const type = editorType !== null && editorType !== void 0 ? editorType : field.type;
631
+ if (type === "json" || type === "code" || type === "variable" || type === "multiselect") throw new Error(`Missing editorType for ${field.key} (${type})`);
632
+ return require_end_node_ids._objectSpread2(require_end_node_ids._objectSpread2({}, visible), {}, { type });
633
+ }
634
+ /** No executor or schema imports: this projection is safe in client bundles. */
635
+ function toNodeDefinition(contract, type) {
636
+ const fields = contract.fields.filter((field) => !field.hiddenInEditor).map(toEditorField);
637
+ return require_end_node_ids._objectSpread2(require_end_node_ids._objectSpread2(require_end_node_ids._objectSpread2({
638
+ id: contract.id,
639
+ type,
640
+ name: contract.name,
641
+ description: contract.description,
642
+ icon: contract.icon,
643
+ color: contract.color,
644
+ category: contract.editorCategory
645
+ }, contract.comingSoon === void 0 ? {} : { comingSoon: contract.comingSoon }), contract.initialConfig ? { initialConfig: contract.initialConfig } : {}), fields.length ? { config: { fields } } : {});
646
+ }
647
+ // src/lib/node-definitions/registry.ts
648
+ /**
649
+ * 노드 카탈로그 — 에디터의 피커·설정 패널·점검·AI 제안이 전부 여기서 읽는다.
650
+ *
651
+ * 내장 범용 노드(반복·병렬·대기·HTTP 등)는 모듈이 넣고, 제품 고유 노드는 호스트가
652
+ * `registerNodeContracts`로 더한다. 등록은 **덧붙이기**이고 같은 `종류:id`를 다시 넣으면
653
+ * 그 자리를 갈아 끼운다(HMR·재마운트에서 중복이 쌓이지 않는다). 배열 객체는 바뀌지 않는다 —
654
+ * 이미 import한 쪽이 등록 뒤의 내용을 본다.
655
+ */
656
+ /** 내장 트리거 — 수동·일정·웹훅. 제품 이벤트 트리거는 호스트가 더한다. */
657
+ const builtInTriggerContracts = [
658
+ manualTriggerContract,
659
+ scheduleTriggerContract,
660
+ webhookTriggerContract
661
+ ];
662
+ /**
663
+ * 내장 액션·제어 노드. 반복·병렬은 캔버스가 구조로 아는 종류라(마커 짝짓기·브랜치 채우기)
664
+ * 모듈이 갖고, 대기·HTTP·데이터 변환은 어떤 제품에서도 뜻이 같은 범용 액션이다.
665
+ */
666
+ const builtInActionContracts = [
667
+ delayContract,
668
+ httpRequestContract,
669
+ transformDataContract,
670
+ forEachContract,
671
+ whileContract,
672
+ repeatContract,
673
+ parallelContract,
674
+ joinContract,
675
+ loopEndContract
676
+ ];
677
+ const triggerDefinitions = builtInTriggerContracts.map((contract) => toNodeDefinition(contract, "trigger"));
678
+ const actionDefinitions = builtInActionContracts.map((contract) => toNodeDefinition(contract, "action"));
679
+ let version = 0;
680
+ const listeners = /* @__PURE__ */ new Set();
681
+ function upsert(list, definition) {
682
+ const index = list.findIndex((item) => item.id === definition.id);
683
+ if (index >= 0) list[index] = definition;
684
+ else list.push(definition);
685
+ }
686
+ const scopedOwners = /* @__PURE__ */ new Map();
687
+ const scopes = /* @__PURE__ */ new Map();
688
+ const keyOf = (kind, id) => `${kind}:${id}`;
689
+ const listOf = (kind) => kind === "trigger" ? triggerDefinitions : actionDefinitions;
690
+ function notify() {
691
+ version += 1;
692
+ for (const listener of listeners) listener();
693
+ }
694
+ function registerScoped(scope, kind, contracts, replace) {
695
+ var _scopes$get;
696
+ const entry = (_scopes$get = scopes.get(scope)) !== null && _scopes$get !== void 0 ? _scopes$get : {
697
+ trigger: {
698
+ ids: [],
699
+ replace: false
700
+ },
701
+ action: {
702
+ ids: [],
703
+ replace: false
704
+ }
705
+ };
706
+ scopes.set(scope, entry);
707
+ if (!contracts) return;
708
+ const list = listOf(kind);
709
+ entry[kind] = {
710
+ ids: contracts.map((contract) => contract.id),
711
+ replace
712
+ };
713
+ for (const contract of contracts) {
714
+ const key = keyOf(kind, contract.id);
715
+ const exists = list.some((item) => item.id === contract.id);
716
+ const owners = scopedOwners.get(key);
717
+ if (!exists) scopedOwners.set(key, /* @__PURE__ */ new Set([scope]));
718
+ else if (owners) owners.add(scope);
719
+ if (!exists || owners) upsert(list, toNodeDefinition(contract, kind));
720
+ }
721
+ }
722
+ /**
723
+ * 이 범위(에디터)에게 보이는 노드 — 전역 노드와 그 범위가 등록한 노드. 범위가 `replace`로
724
+ * 등록한 종류는 그 범위가 준 목록 그대로(순서 포함)다. 범위를 안 주면 전역 노드만이다.
725
+ */
726
+ function listVisibleNodeDefinitions(kind, scope) {
727
+ var _scopes$get2;
728
+ const list = listOf(kind);
729
+ const entry = scope ? (_scopes$get2 = scopes.get(scope)) === null || _scopes$get2 === void 0 ? void 0 : _scopes$get2[kind] : void 0;
730
+ if (entry === null || entry === void 0 ? void 0 : entry.replace) return entry.ids.flatMap((id) => {
731
+ var _list$find;
732
+ return (_list$find = list.find((definition) => definition.id === id)) !== null && _list$find !== void 0 ? _list$find : [];
733
+ });
734
+ return list.filter((definition) => {
735
+ const owners = scopedOwners.get(keyOf(kind, definition.id));
736
+ return !owners || scope !== void 0 && owners.has(scope);
737
+ });
738
+ }
739
+ /** 범위를 거둔다(에디터가 사라질 때). 다른 주인이 없는 노드는 카탈로그에서 빠진다. */
740
+ function releaseNodeScope(scope) {
741
+ const entry = scopes.get(scope);
742
+ if (!entry) return;
743
+ scopes.delete(scope);
744
+ for (const kind of ["trigger", "action"]) {
745
+ const list = listOf(kind);
746
+ for (const id of entry[kind].ids) {
747
+ const key = keyOf(kind, id);
748
+ const owners = scopedOwners.get(key);
749
+ if (!owners) continue;
750
+ owners.delete(scope);
751
+ if (owners.size > 0) continue;
752
+ scopedOwners.delete(key);
753
+ const index = list.findIndex((item) => item.id === id);
754
+ if (index >= 0) list.splice(index, 1);
755
+ }
756
+ }
757
+ notify();
758
+ }
759
+ function registerNodeContracts({ triggers, actions, mode = "append", scope }) {
760
+ if (scope) {
761
+ registerScoped(scope, "trigger", triggers, mode === "replace");
762
+ registerScoped(scope, "action", actions, mode === "replace");
763
+ notify();
764
+ return;
765
+ }
766
+ for (const [kind, contracts] of [["trigger", triggers], ["action", actions]]) {
767
+ if (!contracts) continue;
768
+ const list = listOf(kind);
769
+ if (mode === "replace") {
770
+ for (const item of list) scopedOwners.delete(keyOf(kind, item.id));
771
+ list.length = 0;
772
+ }
773
+ for (const contract of contracts) {
774
+ scopedOwners.delete(keyOf(kind, contract.id));
775
+ upsert(list, toNodeDefinition(contract, kind));
776
+ }
777
+ }
778
+ notify();
779
+ }
780
+ /** 카탈로그가 바뀔 때마다 오르는 숫자 — `useSyncExternalStore`의 스냅샷으로 쓴다. */
781
+ function getNodeCatalogVersion() {
782
+ return version;
783
+ }
784
+ function subscribeNodeCatalog(listener) {
785
+ listeners.add(listener);
786
+ return () => listeners.delete(listener);
787
+ }
788
+ // src/lib/node-definitions/index.ts
789
+ /** 트리거 + 액션. 호출할 때마다 지금의 카탈로그를 읽는다. */
790
+ function listNodeDefinitions() {
791
+ return [...triggerDefinitions, ...actionDefinitions];
792
+ }
793
+ function getNodeDefinition(id) {
794
+ var _triggerDefinitions$f;
795
+ return (_triggerDefinitions$f = triggerDefinitions.find((def) => def.id === id)) !== null && _triggerDefinitions$f !== void 0 ? _triggerDefinitions$f : actionDefinitions.find((def) => def.id === id);
796
+ }
797
+ Object.defineProperty(exports, "actionDefinitions", {
798
+ enumerable: true,
799
+ get: function() {
800
+ return actionDefinitions;
801
+ }
802
+ });
803
+ Object.defineProperty(exports, "builtInActionContracts", {
804
+ enumerable: true,
805
+ get: function() {
806
+ return builtInActionContracts;
807
+ }
808
+ });
809
+ Object.defineProperty(exports, "builtInTriggerContracts", {
810
+ enumerable: true,
811
+ get: function() {
812
+ return builtInTriggerContracts;
813
+ }
814
+ });
815
+ Object.defineProperty(exports, "delayContract", {
816
+ enumerable: true,
817
+ get: function() {
818
+ return delayContract;
819
+ }
820
+ });
821
+ Object.defineProperty(exports, "forEachContract", {
822
+ enumerable: true,
823
+ get: function() {
824
+ return forEachContract;
825
+ }
826
+ });
827
+ Object.defineProperty(exports, "getNodeCatalogVersion", {
828
+ enumerable: true,
829
+ get: function() {
830
+ return getNodeCatalogVersion;
831
+ }
832
+ });
833
+ Object.defineProperty(exports, "getNodeDefinition", {
834
+ enumerable: true,
835
+ get: function() {
836
+ return getNodeDefinition;
837
+ }
838
+ });
839
+ Object.defineProperty(exports, "httpRequestContract", {
840
+ enumerable: true,
841
+ get: function() {
842
+ return httpRequestContract;
843
+ }
844
+ });
845
+ Object.defineProperty(exports, "joinContract", {
846
+ enumerable: true,
847
+ get: function() {
848
+ return joinContract;
849
+ }
850
+ });
851
+ Object.defineProperty(exports, "listNodeDefinitions", {
852
+ enumerable: true,
853
+ get: function() {
854
+ return listNodeDefinitions;
855
+ }
856
+ });
857
+ Object.defineProperty(exports, "listVisibleNodeDefinitions", {
858
+ enumerable: true,
859
+ get: function() {
860
+ return listVisibleNodeDefinitions;
861
+ }
862
+ });
863
+ Object.defineProperty(exports, "loopEndContract", {
864
+ enumerable: true,
865
+ get: function() {
866
+ return loopEndContract;
867
+ }
868
+ });
869
+ Object.defineProperty(exports, "manualTriggerContract", {
870
+ enumerable: true,
871
+ get: function() {
872
+ return manualTriggerContract;
873
+ }
874
+ });
875
+ Object.defineProperty(exports, "parallelContract", {
876
+ enumerable: true,
877
+ get: function() {
878
+ return parallelContract;
879
+ }
880
+ });
881
+ Object.defineProperty(exports, "registerNodeContracts", {
882
+ enumerable: true,
883
+ get: function() {
884
+ return registerNodeContracts;
885
+ }
886
+ });
887
+ Object.defineProperty(exports, "releaseNodeScope", {
888
+ enumerable: true,
889
+ get: function() {
890
+ return releaseNodeScope;
891
+ }
892
+ });
893
+ Object.defineProperty(exports, "repeatContract", {
894
+ enumerable: true,
895
+ get: function() {
896
+ return repeatContract;
897
+ }
898
+ });
899
+ Object.defineProperty(exports, "scheduleTriggerContract", {
900
+ enumerable: true,
901
+ get: function() {
902
+ return scheduleTriggerContract;
903
+ }
904
+ });
905
+ Object.defineProperty(exports, "subscribeNodeCatalog", {
906
+ enumerable: true,
907
+ get: function() {
908
+ return subscribeNodeCatalog;
909
+ }
910
+ });
911
+ Object.defineProperty(exports, "toNodeDefinition", {
912
+ enumerable: true,
913
+ get: function() {
914
+ return toNodeDefinition;
915
+ }
916
+ });
917
+ Object.defineProperty(exports, "transformDataContract", {
918
+ enumerable: true,
919
+ get: function() {
920
+ return transformDataContract;
921
+ }
922
+ });
923
+ Object.defineProperty(exports, "triggerDefinitions", {
924
+ enumerable: true,
925
+ get: function() {
926
+ return triggerDefinitions;
927
+ }
928
+ });
929
+ Object.defineProperty(exports, "webhookTriggerContract", {
930
+ enumerable: true,
931
+ get: function() {
932
+ return webhookTriggerContract;
933
+ }
934
+ });
935
+ Object.defineProperty(exports, "whileContract", {
936
+ enumerable: true,
937
+ get: function() {
938
+ return whileContract;
939
+ }
940
+ });