@nodaro/shared 3.31.0 → 3.33.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 +17 -0
- package/dist/chunk-23FJQTEA.js +1604 -0
- package/dist/chunk-23FJQTEA.js.map +1 -0
- package/dist/chunk-2NIQO2J3.cjs +54 -0
- package/dist/chunk-2NIQO2J3.cjs.map +1 -0
- package/dist/chunk-2NQLSLSN.cjs +19 -0
- package/dist/chunk-2NQLSLSN.cjs.map +1 -0
- package/dist/chunk-2OJIVO7R.cjs +32 -0
- package/dist/chunk-2OJIVO7R.cjs.map +1 -0
- package/dist/chunk-2RF4Z7KG.cjs +803 -0
- package/dist/chunk-2RF4Z7KG.cjs.map +1 -0
- package/dist/chunk-3RYKIUAE.js +86 -0
- package/dist/chunk-3RYKIUAE.js.map +1 -0
- package/dist/chunk-44I73CQS.cjs +194 -0
- package/dist/chunk-44I73CQS.cjs.map +1 -0
- package/dist/chunk-5PC6JBGJ.cjs +1419 -0
- package/dist/chunk-5PC6JBGJ.cjs.map +1 -0
- package/dist/chunk-5RU2HCW2.js +30 -0
- package/dist/chunk-5RU2HCW2.js.map +1 -0
- package/dist/chunk-5RYLK3MQ.js +267 -0
- package/dist/chunk-5RYLK3MQ.js.map +1 -0
- package/dist/chunk-5THUHJ3E.js +46 -0
- package/dist/chunk-5THUHJ3E.js.map +1 -0
- package/dist/chunk-6DAWSVX2.cjs +103 -0
- package/dist/chunk-6DAWSVX2.cjs.map +1 -0
- package/dist/chunk-6WZ2VN7V.js +920 -0
- package/dist/chunk-6WZ2VN7V.js.map +1 -0
- package/dist/chunk-7G7G42KS.js +86 -0
- package/dist/chunk-7G7G42KS.js.map +1 -0
- package/dist/chunk-7Z5LUTGU.js +1567 -0
- package/dist/chunk-7Z5LUTGU.js.map +1 -0
- package/dist/chunk-AINCI23X.js +2171 -0
- package/dist/chunk-AINCI23X.js.map +1 -0
- package/dist/chunk-BG5D5CZ6.js +1922 -0
- package/dist/chunk-BG5D5CZ6.js.map +1 -0
- package/dist/chunk-CK3GK34R.js +1381 -0
- package/dist/chunk-CK3GK34R.js.map +1 -0
- package/dist/chunk-CUH22J4D.js +17 -0
- package/dist/chunk-CUH22J4D.js.map +1 -0
- package/dist/chunk-D26ENTN2.cjs +1770 -0
- package/dist/chunk-D26ENTN2.cjs.map +1 -0
- package/dist/chunk-D6GNRSCV.cjs +2017 -0
- package/dist/chunk-D6GNRSCV.cjs.map +1 -0
- package/dist/chunk-FBV5DF6D.js +95 -0
- package/dist/chunk-FBV5DF6D.js.map +1 -0
- package/dist/chunk-FG4E7MTG.cjs +4 -0
- package/dist/chunk-FG4E7MTG.cjs.map +1 -0
- package/dist/chunk-FT5CF6IA.js +42 -0
- package/dist/chunk-FT5CF6IA.js.map +1 -0
- package/dist/chunk-G6IIVKMO.js +26 -0
- package/dist/chunk-G6IIVKMO.js.map +1 -0
- package/dist/chunk-HC7VKIV5.cjs +430 -0
- package/dist/chunk-HC7VKIV5.cjs.map +1 -0
- package/dist/chunk-HGC5JNVA.cjs +1503 -0
- package/dist/chunk-HGC5JNVA.cjs.map +1 -0
- package/dist/chunk-HKFMXNVQ.cjs +1273 -0
- package/dist/chunk-HKFMXNVQ.cjs.map +1 -0
- package/dist/chunk-HRXEZ3SX.cjs +526 -0
- package/dist/chunk-HRXEZ3SX.cjs.map +1 -0
- package/dist/chunk-HSHCCBIV.js +255 -0
- package/dist/chunk-HSHCCBIV.js.map +1 -0
- package/dist/chunk-HUR6ZJ7S.cjs +159 -0
- package/dist/chunk-HUR6ZJ7S.cjs.map +1 -0
- package/dist/chunk-J7BMO73N.cjs +114 -0
- package/dist/chunk-J7BMO73N.cjs.map +1 -0
- package/dist/chunk-JFS3NWZ5.cjs +1714 -0
- package/dist/chunk-JFS3NWZ5.cjs.map +1 -0
- package/dist/chunk-JL4C5VJ7.cjs +488 -0
- package/dist/chunk-JL4C5VJ7.cjs.map +1 -0
- package/dist/chunk-JSGIEF6Z.cjs +1087 -0
- package/dist/chunk-JSGIEF6Z.cjs.map +1 -0
- package/dist/chunk-JWA5SGCS.js +203 -0
- package/dist/chunk-JWA5SGCS.js.map +1 -0
- package/dist/chunk-K3LLGRK7.cjs +3545 -0
- package/dist/chunk-K3LLGRK7.cjs.map +1 -0
- package/dist/chunk-KU6S7IYV.cjs +210 -0
- package/dist/chunk-KU6S7IYV.cjs.map +1 -0
- package/dist/chunk-M36G6SRP.js +447 -0
- package/dist/chunk-M36G6SRP.js.map +1 -0
- package/dist/chunk-M7GQBRZU.cjs +1963 -0
- package/dist/chunk-M7GQBRZU.cjs.map +1 -0
- package/dist/chunk-MRXGWL42.cjs +4 -0
- package/dist/chunk-MRXGWL42.cjs.map +1 -0
- package/dist/chunk-NEJ2PV4C.cjs +211 -0
- package/dist/chunk-NEJ2PV4C.cjs.map +1 -0
- package/dist/chunk-OTATNBMD.js +141 -0
- package/dist/chunk-OTATNBMD.js.map +1 -0
- package/dist/chunk-OZSACQ2V.js +471 -0
- package/dist/chunk-OZSACQ2V.js.map +1 -0
- package/dist/chunk-PHZ23DP3.js +1782 -0
- package/dist/chunk-PHZ23DP3.js.map +1 -0
- package/dist/chunk-PQHS255G.js +1369 -0
- package/dist/chunk-PQHS255G.js.map +1 -0
- package/dist/chunk-PRYE7AZQ.cjs +1227 -0
- package/dist/chunk-PRYE7AZQ.cjs.map +1 -0
- package/dist/chunk-PVJBAPYJ.js +404 -0
- package/dist/chunk-PVJBAPYJ.js.map +1 -0
- package/dist/chunk-PXFQVLBX.js +776 -0
- package/dist/chunk-PXFQVLBX.js.map +1 -0
- package/dist/chunk-QA3MVQ32.js +21 -0
- package/dist/chunk-QA3MVQ32.js.map +1 -0
- package/dist/chunk-QJRP44ZO.js +769 -0
- package/dist/chunk-QJRP44ZO.js.map +1 -0
- package/dist/chunk-SAW5OK36.cjs +54 -0
- package/dist/chunk-SAW5OK36.cjs.map +1 -0
- package/dist/chunk-SES6GDBQ.cjs +624 -0
- package/dist/chunk-SES6GDBQ.cjs.map +1 -0
- package/dist/chunk-SFW3UB2P.js +31 -0
- package/dist/chunk-SFW3UB2P.js.map +1 -0
- package/dist/chunk-TNPDV7I4.cjs +2346 -0
- package/dist/chunk-TNPDV7I4.cjs.map +1 -0
- package/dist/chunk-TU33KYKW.cjs +25 -0
- package/dist/chunk-TU33KYKW.cjs.map +1 -0
- package/dist/chunk-TZBIY5C3.js +187 -0
- package/dist/chunk-TZBIY5C3.js.map +1 -0
- package/dist/chunk-TZE673G6.js +3 -0
- package/dist/chunk-TZE673G6.js.map +1 -0
- package/dist/chunk-UCFWI6D4.js +29 -0
- package/dist/chunk-UCFWI6D4.js.map +1 -0
- package/dist/chunk-UTQSSKSG.js +1164 -0
- package/dist/chunk-UTQSSKSG.js.map +1 -0
- package/dist/chunk-VA42637J.cjs +287 -0
- package/dist/chunk-VA42637J.cjs.map +1 -0
- package/dist/chunk-VNQRI2RO.cjs +1047 -0
- package/dist/chunk-VNQRI2RO.cjs.map +1 -0
- package/dist/chunk-VXPLKQWY.cjs +821 -0
- package/dist/chunk-VXPLKQWY.cjs.map +1 -0
- package/dist/chunk-WD6HJRBG.cjs +197 -0
- package/dist/chunk-WD6HJRBG.cjs.map +1 -0
- package/dist/chunk-WDIBOWAA.js +1054 -0
- package/dist/chunk-WDIBOWAA.js.map +1 -0
- package/dist/chunk-WKOIGLQX.cjs +38 -0
- package/dist/chunk-WKOIGLQX.cjs.map +1 -0
- package/dist/chunk-WNVQ3SMB.cjs +96 -0
- package/dist/chunk-WNVQ3SMB.cjs.map +1 -0
- package/dist/chunk-WRSWH7US.cjs +285 -0
- package/dist/chunk-WRSWH7US.cjs.map +1 -0
- package/dist/chunk-XGFTL5XY.js +181 -0
- package/dist/chunk-XGFTL5XY.js.map +1 -0
- package/dist/chunk-XNISPHTZ.js +1039 -0
- package/dist/chunk-XNISPHTZ.js.map +1 -0
- package/dist/chunk-Y2PM3FFL.js +3 -0
- package/dist/chunk-Y2PM3FFL.js.map +1 -0
- package/dist/chunk-YBPBK5KI.js +1030 -0
- package/dist/chunk-YBPBK5KI.js.map +1 -0
- package/dist/chunk-YWNYGYI7.cjs +31 -0
- package/dist/chunk-YWNYGYI7.cjs.map +1 -0
- package/dist/chunk-YYV35XOS.js +122 -0
- package/dist/chunk-YYV35XOS.js.map +1 -0
- package/dist/chunk-Z2OL5AJD.cjs +133 -0
- package/dist/chunk-Z2OL5AJD.cjs.map +1 -0
- package/dist/chunk-ZDFHA2EC.js +572 -0
- package/dist/chunk-ZDFHA2EC.js.map +1 -0
- package/dist/chunk-ZL7UM6PU.cjs +34 -0
- package/dist/chunk-ZL7UM6PU.cjs.map +1 -0
- package/dist/chunk-ZNZDQAXN.js +175 -0
- package/dist/chunk-ZNZDQAXN.js.map +1 -0
- package/dist/chunk-ZO5PBBFX.js +3497 -0
- package/dist/chunk-ZO5PBBFX.js.map +1 -0
- package/dist/chunk-ZRL2UFTH.cjs +1073 -0
- package/dist/chunk-ZRL2UFTH.cjs.map +1 -0
- package/dist/entries/apps.cjs +155 -0
- package/dist/entries/apps.cjs.map +1 -0
- package/dist/entries/apps.d.cts +292 -0
- package/dist/entries/apps.d.ts +292 -0
- package/dist/entries/apps.js +10 -0
- package/dist/entries/apps.js.map +1 -0
- package/dist/entries/captions.cjs +124 -0
- package/dist/entries/captions.cjs.map +1 -0
- package/dist/entries/captions.d.cts +354 -0
- package/dist/entries/captions.d.ts +354 -0
- package/dist/entries/captions.js +3 -0
- package/dist/entries/captions.js.map +1 -0
- package/dist/entries/catalogs.cjs +165 -0
- package/dist/entries/catalogs.cjs.map +1 -0
- package/dist/entries/catalogs.d.cts +385 -0
- package/dist/entries/catalogs.d.ts +385 -0
- package/dist/entries/catalogs.js +4 -0
- package/dist/entries/catalogs.js.map +1 -0
- package/dist/entries/credits.cjs +596 -0
- package/dist/entries/credits.cjs.map +1 -0
- package/dist/entries/credits.d.cts +1460 -0
- package/dist/entries/credits.d.ts +1460 -0
- package/dist/entries/credits.js +11 -0
- package/dist/entries/credits.js.map +1 -0
- package/dist/entries/edl.cjs +409 -0
- package/dist/entries/edl.cjs.map +1 -0
- package/dist/entries/edl.d.cts +1199 -0
- package/dist/entries/edl.d.ts +1199 -0
- package/dist/entries/edl.js +4 -0
- package/dist/entries/edl.js.map +1 -0
- package/dist/entries/entities.cjs +530 -0
- package/dist/entries/entities.cjs.map +1 -0
- package/dist/entries/entities.d.cts +1371 -0
- package/dist/entries/entities.d.ts +1371 -0
- package/dist/entries/entities.js +5 -0
- package/dist/entries/entities.js.map +1 -0
- package/dist/entries/i18n.cjs +48 -0
- package/dist/entries/i18n.cjs.map +1 -0
- package/dist/entries/i18n.d.cts +69 -0
- package/dist/entries/i18n.d.ts +69 -0
- package/dist/entries/i18n.js +3 -0
- package/dist/entries/i18n.js.map +1 -0
- package/dist/entries/llm-models.cjs +177 -0
- package/dist/entries/llm-models.cjs.map +1 -0
- package/dist/entries/llm-models.d.cts +435 -0
- package/dist/entries/llm-models.d.ts +435 -0
- package/dist/entries/llm-models.js +4 -0
- package/dist/entries/llm-models.js.map +1 -0
- package/dist/entries/media.cjs +335 -0
- package/dist/entries/media.cjs.map +1 -0
- package/dist/entries/media.d.cts +518 -0
- package/dist/entries/media.d.ts +518 -0
- package/dist/entries/media.js +6 -0
- package/dist/entries/media.js.map +1 -0
- package/dist/entries/model-catalog.cjs +259 -0
- package/dist/entries/model-catalog.cjs.map +1 -0
- package/dist/entries/model-catalog.d.cts +202 -0
- package/dist/entries/model-catalog.d.ts +202 -0
- package/dist/entries/model-catalog.js +6 -0
- package/dist/entries/model-catalog.js.map +1 -0
- package/dist/entries/models.cjs +833 -0
- package/dist/entries/models.cjs.map +1 -0
- package/dist/entries/models.d.cts +287 -0
- package/dist/entries/models.d.ts +287 -0
- package/dist/entries/models.js +8 -0
- package/dist/entries/models.js.map +1 -0
- package/dist/entries/nodes.cjs +789 -0
- package/dist/entries/nodes.cjs.map +1 -0
- package/dist/entries/nodes.d.cts +1600 -0
- package/dist/entries/nodes.d.ts +1600 -0
- package/dist/entries/nodes.js +16 -0
- package/dist/entries/nodes.js.map +1 -0
- package/dist/entries/organizations.cjs +80 -0
- package/dist/entries/organizations.cjs.map +1 -0
- package/dist/entries/organizations.d.cts +466 -0
- package/dist/entries/organizations.d.ts +466 -0
- package/dist/entries/organizations.js +3 -0
- package/dist/entries/organizations.js.map +1 -0
- package/dist/entries/pipeline.cjs +594 -0
- package/dist/entries/pipeline.cjs.map +1 -0
- package/dist/entries/pipeline.d.cts +2617 -0
- package/dist/entries/pipeline.d.ts +2617 -0
- package/dist/entries/pipeline.js +5 -0
- package/dist/entries/pipeline.js.map +1 -0
- package/dist/entries/scene3d.cjs +704 -0
- package/dist/entries/scene3d.cjs.map +1 -0
- package/dist/entries/scene3d.d.cts +4284 -0
- package/dist/entries/scene3d.d.ts +4284 -0
- package/dist/entries/scene3d.js +3 -0
- package/dist/entries/scene3d.js.map +1 -0
- package/dist/entries/social.cjs +714 -0
- package/dist/entries/social.cjs.map +1 -0
- package/dist/entries/social.d.cts +1366 -0
- package/dist/entries/social.d.ts +1366 -0
- package/dist/entries/social.js +5 -0
- package/dist/entries/social.js.map +1 -0
- package/dist/entries/types.cjs +13 -0
- package/dist/entries/types.cjs.map +1 -0
- package/dist/entries/types.d.cts +162 -0
- package/dist/entries/types.d.ts +162 -0
- package/dist/entries/types.js +4 -0
- package/dist/entries/types.js.map +1 -0
- package/dist/entries/ugc.cjs +279 -0
- package/dist/entries/ugc.cjs.map +1 -0
- package/dist/entries/ugc.d.cts +575 -0
- package/dist/entries/ugc.d.ts +575 -0
- package/dist/entries/ugc.js +6 -0
- package/dist/entries/ugc.js.map +1 -0
- package/dist/entries/video.cjs +549 -0
- package/dist/entries/video.cjs.map +1 -0
- package/dist/entries/video.d.cts +1791 -0
- package/dist/entries/video.d.ts +1791 -0
- package/dist/entries/video.js +8 -0
- package/dist/entries/video.js.map +1 -0
- package/dist/entries/workflow.cjs +574 -0
- package/dist/entries/workflow.cjs.map +1 -0
- package/dist/entries/workflow.d.cts +1743 -0
- package/dist/entries/workflow.d.ts +1743 -0
- package/dist/entries/workflow.js +5 -0
- package/dist/entries/workflow.js.map +1 -0
- package/dist/fan-out-meta-Bu6VyXcZ.d.cts +19 -0
- package/dist/fan-out-meta-Bu6VyXcZ.d.ts +19 -0
- package/dist/gemini-omni-voices-zeRXxSbZ.d.cts +174 -0
- package/dist/gemini-omni-voices-zeRXxSbZ.d.ts +174 -0
- package/dist/image-overlay-layers-CyBfRhxJ.d.cts +208 -0
- package/dist/image-overlay-layers-CyBfRhxJ.d.ts +208 -0
- package/dist/index.cjs +7747 -27084
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -24198
- package/dist/index.d.ts +32 -24198
- package/dist/index.js +40 -25220
- package/dist/index.js.map +1 -1
- package/dist/model-catalog-V-ZNzRSd.d.cts +651 -0
- package/dist/model-catalog-V-ZNzRSd.d.ts +651 -0
- package/dist/presentation-types-0ENOCjoj.d.cts +61 -0
- package/dist/presentation-types-0ENOCjoj.d.ts +61 -0
- package/dist/presentation-utils-D0kxsWf9.d.cts +92 -0
- package/dist/presentation-utils-pZwlEAzo.d.ts +92 -0
- package/dist/scene-node-types-C3kl_zyK.d.cts +1949 -0
- package/dist/scene-node-types-C3kl_zyK.d.ts +1949 -0
- package/dist/supported-fonts-CRoF1gOy.d.cts +16 -0
- package/dist/supported-fonts-CRoF1gOy.d.ts +16 -0
- package/dist/types-BRlFPEru.d.cts +511 -0
- package/dist/types-BRlFPEru.d.ts +511 -0
- package/dist/types-DffyGSy5.d.cts +67 -0
- package/dist/types-DffyGSy5.d.ts +67 -0
- package/package.json +102 -1
- package/src/__tests__/add-captions-plan.test.ts +6 -2
- package/src/__tests__/caption-edge-dash.test.ts +23 -0
- package/src/__tests__/fixtures/root-exports.baseline.json +4625 -0
- package/src/__tests__/input-field-extra-keys.test.ts +1 -0
- package/src/__tests__/model-makers.test.ts +76 -0
- package/src/__tests__/no-internal-imports.test.ts +1 -1
- package/src/__tests__/node-aspect-ratio.test.ts +25 -0
- package/src/__tests__/node-runtime-keys.test.ts +9 -0
- package/src/__tests__/package-entries.test.ts +50 -0
- package/src/__tests__/pitch-tempo-pricing.test.ts +21 -0
- package/src/__tests__/presentation-utils.test.ts +15 -0
- package/src/__tests__/preview-gate-use-case.test.ts +151 -0
- package/src/__tests__/private-host.test.ts +53 -0
- package/src/__tests__/run-continuation.test.ts +7 -1
- package/src/__tests__/site-capture-node.test.ts +58 -0
- package/src/__tests__/ugc-lane-wires.test.ts +228 -0
- package/src/__tests__/ugc-node-wires.test.ts +9 -3
- package/src/__tests__/ugc-run-state.test.ts +5 -4
- package/src/__tests__/video-analysis-catalog-sync.test.ts +1 -1
- package/src/__tests__/video-analysis-pricing.test.ts +6 -6
- package/src/__tests__/voice-changer-pro-quote.test.ts +79 -0
- package/src/add-captions-plan.ts +9 -3
- package/src/caption-edge-dash.ts +33 -0
- package/src/component-types.ts +9 -0
- package/src/credit-estimators/index.ts +22 -1
- package/src/credit-estimators/pitch-tempo.ts +15 -1
- package/src/credit-estimators/speech.ts +72 -4
- package/src/credit-estimators/unit-quote.ts +52 -0
- package/src/credit-estimators/video-sfx.ts +15 -0
- package/src/credit-estimators/voice-changer-pro-quote.ts +138 -0
- package/src/credit-identifiers.ts +62 -17
- package/src/entity-image-handle.ts +2 -0
- package/src/entries/apps.ts +63 -0
- package/src/entries/captions.ts +34 -0
- package/src/entries/catalogs.ts +65 -0
- package/src/entries/credits.ts +105 -0
- package/src/entries/edl.ts +42 -0
- package/src/entries/entities.ts +144 -0
- package/src/entries/i18n.ts +31 -0
- package/src/entries/llm-models.ts +63 -0
- package/src/entries/media.ts +36 -0
- package/src/entries/model-catalog.ts +95 -0
- package/src/entries/models.ts +266 -0
- package/src/entries/nodes.ts +245 -0
- package/src/entries/organizations.ts +9 -0
- package/src/entries/pipeline.ts +43 -0
- package/src/entries/scene3d.ts +27 -0
- package/src/entries/social.ts +297 -0
- package/src/entries/types.ts +26 -0
- package/src/entries/ugc.ts +14 -0
- package/src/entries/video.ts +59 -0
- package/src/entries/workflow.ts +172 -0
- package/src/fan-out-rows.ts +2 -0
- package/src/index.ts +25 -1845
- package/src/json-kinds.ts +4 -0
- package/src/model-catalog.ts +243 -34
- package/src/node-mappable-fields.ts +1 -0
- package/src/node-run-routes.ts +2 -0
- package/src/node-runtime-keys.ts +8 -0
- package/src/normalize-node-params.ts +30 -0
- package/src/presentation-utils.ts +12 -0
- package/src/preview-gate.ts +92 -14
- package/src/private-host.ts +89 -59
- package/src/producer-types.ts +16 -2
- package/src/run-continuation.ts +21 -0
- package/src/site-capture-node.ts +82 -0
- package/src/ugc-lane-wires.ts +246 -0
- package/src/ugc-node-wires.ts +37 -7
- package/src/ugc-run-state.ts +5 -3
- package/src/video-analysis-pricing.ts +31 -29
|
@@ -0,0 +1,1087 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/node-refs.ts
|
|
4
|
+
var NODE_REF_PATTERN = /\{([^}]+)\}/g;
|
|
5
|
+
var RESERVED_TEMPLATE_VARS = /* @__PURE__ */ new Set([
|
|
6
|
+
"name",
|
|
7
|
+
"description",
|
|
8
|
+
"userPrompt",
|
|
9
|
+
"assetDescriptions",
|
|
10
|
+
"outputCount"
|
|
11
|
+
]);
|
|
12
|
+
function parseNodeRef(raw) {
|
|
13
|
+
const i = raw.indexOf("||");
|
|
14
|
+
if (i === -1) return { name: raw.trim(), fallback: null };
|
|
15
|
+
return { name: raw.slice(0, i).trim(), fallback: raw.slice(i + 2).trim() };
|
|
16
|
+
}
|
|
17
|
+
function canonicalVarName(label) {
|
|
18
|
+
return label.trim().toLowerCase();
|
|
19
|
+
}
|
|
20
|
+
function extractReferencedLabels(...texts) {
|
|
21
|
+
const refs = /* @__PURE__ */ new Set();
|
|
22
|
+
for (const text of texts) {
|
|
23
|
+
if (typeof text !== "string" || text.length === 0) continue;
|
|
24
|
+
for (const m of text.matchAll(NODE_REF_PATTERN)) {
|
|
25
|
+
const { name } = parseNodeRef(m[1] ?? "");
|
|
26
|
+
if (name === "" || name.startsWith("image:") || RESERVED_TEMPLATE_VARS.has(name)) continue;
|
|
27
|
+
refs.add(canonicalVarName(name));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return refs;
|
|
31
|
+
}
|
|
32
|
+
var REF_HANDLE_CATEGORY = {
|
|
33
|
+
prompt: 0,
|
|
34
|
+
elements: 1,
|
|
35
|
+
look: 2,
|
|
36
|
+
cinematography: 2,
|
|
37
|
+
style: 2
|
|
38
|
+
};
|
|
39
|
+
function refHandleCategory(targetHandle) {
|
|
40
|
+
if (targetHandle != null && Object.prototype.hasOwnProperty.call(REF_HANDLE_CATEGORY, targetHandle)) {
|
|
41
|
+
return REF_HANDLE_CATEGORY[targetHandle];
|
|
42
|
+
}
|
|
43
|
+
return -1;
|
|
44
|
+
}
|
|
45
|
+
var REFERENCE_HANDLE_MAP = {
|
|
46
|
+
// Legacy / i2v single-name handle ids (kept for un-migrated workflows)
|
|
47
|
+
"references": "referenceImageUrls",
|
|
48
|
+
"reference-videos": "referenceVideoUrls",
|
|
49
|
+
"reference-audio": "referenceAudioUrls",
|
|
50
|
+
// New canonical typed-handle ids (Generate Video) — share the resolved-input
|
|
51
|
+
// keys with the legacy ids so payload-builder code doesn't fork.
|
|
52
|
+
"imageReferences": "referenceImageUrls",
|
|
53
|
+
"videoReferences": "referenceVideoUrls",
|
|
54
|
+
"audioReferences": "referenceAudioUrls"
|
|
55
|
+
};
|
|
56
|
+
function referenceModalityForHandle(targetHandle) {
|
|
57
|
+
if (targetHandle == null) return null;
|
|
58
|
+
const key = REFERENCE_HANDLE_MAP[targetHandle];
|
|
59
|
+
return key === "referenceImageUrls" ? "image" : key === "referenceVideoUrls" ? "video" : key === "referenceAudioUrls" ? "audio" : null;
|
|
60
|
+
}
|
|
61
|
+
var FRAME_TARGET_HANDLES = /* @__PURE__ */ new Set(["startFrame", "endFrame"]);
|
|
62
|
+
function countRefModalityEdges(edges, nodeId, modality) {
|
|
63
|
+
let n = 0;
|
|
64
|
+
for (const e of edges) {
|
|
65
|
+
if (e.target === nodeId && referenceModalityForHandle(e.targetHandle) === modality) n += 1;
|
|
66
|
+
}
|
|
67
|
+
return n;
|
|
68
|
+
}
|
|
69
|
+
function combineSameLabelRefs(candidates) {
|
|
70
|
+
const byLabel = /* @__PURE__ */ new Map();
|
|
71
|
+
for (const c of candidates) {
|
|
72
|
+
if (c.category < 0) continue;
|
|
73
|
+
const key = canonicalVarName(c.label);
|
|
74
|
+
const arr = byLabel.get(key);
|
|
75
|
+
if (arr) arr.push(c);
|
|
76
|
+
else byLabel.set(key, [c]);
|
|
77
|
+
}
|
|
78
|
+
const combined = /* @__PURE__ */ new Map();
|
|
79
|
+
for (const [label, group] of byLabel) {
|
|
80
|
+
if (group.length < 2) continue;
|
|
81
|
+
const ordered = group.map((c, i) => ({ c, i })).sort((a, b) => a.c.category - b.c.category || a.i - b.i).map((x) => x.c.output);
|
|
82
|
+
combined.set(label, ordered.join(", "));
|
|
83
|
+
}
|
|
84
|
+
return combined;
|
|
85
|
+
}
|
|
86
|
+
function resolveNodeRefs(text, labelToOutput) {
|
|
87
|
+
const MAX_PASSES = 10;
|
|
88
|
+
let result = text;
|
|
89
|
+
for (let i = 0; i < MAX_PASSES; i++) {
|
|
90
|
+
const next = result.replace(NODE_REF_PATTERN, (match, raw) => {
|
|
91
|
+
const { name, fallback } = parseNodeRef(raw);
|
|
92
|
+
if (RESERVED_TEMPLATE_VARS.has(name)) return match;
|
|
93
|
+
const output = labelToOutput.get(name) ?? labelToOutput.get(canonicalVarName(name));
|
|
94
|
+
if (output !== void 0) return output;
|
|
95
|
+
if (fallback !== null) return fallback;
|
|
96
|
+
return match;
|
|
97
|
+
});
|
|
98
|
+
if (next === result) break;
|
|
99
|
+
result = next;
|
|
100
|
+
}
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
var REF_TOKEN_NAMESPACE_PREFIXES = [
|
|
104
|
+
"image:",
|
|
105
|
+
"video:",
|
|
106
|
+
"audio:",
|
|
107
|
+
"slot:",
|
|
108
|
+
"ref:"
|
|
109
|
+
];
|
|
110
|
+
function classifyRefToken(name, resolvable) {
|
|
111
|
+
const lower = name.toLowerCase();
|
|
112
|
+
if (name === "" || REF_TOKEN_NAMESPACE_PREFIXES.some((p) => lower.startsWith(p))) return "skip";
|
|
113
|
+
if (RESERVED_TEMPLATE_VARS.has(name)) return "reserved";
|
|
114
|
+
if (resolvable === null) return "unknown";
|
|
115
|
+
return resolvable.has(canonicalVarName(name)) ? "wired" : "missing";
|
|
116
|
+
}
|
|
117
|
+
function unresolvedRefTokens(text, opts) {
|
|
118
|
+
if (typeof text !== "string" || text.length === 0) return [];
|
|
119
|
+
const seen = /* @__PURE__ */ new Set();
|
|
120
|
+
const out = [];
|
|
121
|
+
for (const m of text.matchAll(NODE_REF_PATTERN)) {
|
|
122
|
+
const { name, fallback } = parseNodeRef(m[1] ?? "");
|
|
123
|
+
if (fallback !== null) continue;
|
|
124
|
+
if (classifyRefToken(name, opts.resolvable) !== "missing") continue;
|
|
125
|
+
const canon = canonicalVarName(name);
|
|
126
|
+
if (opts.known.has(canon) || seen.has(canon)) continue;
|
|
127
|
+
seen.add(canon);
|
|
128
|
+
out.push(name);
|
|
129
|
+
}
|
|
130
|
+
return out;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// src/trigger-feeds.ts
|
|
134
|
+
function buildFeedMaps(nodes, edges) {
|
|
135
|
+
const live = new Set(nodes.map((n) => n.id));
|
|
136
|
+
const children = /* @__PURE__ */ new Map();
|
|
137
|
+
const parents = /* @__PURE__ */ new Map();
|
|
138
|
+
const feeds = (source, target) => {
|
|
139
|
+
if (!live.has(source) || !live.has(target) || source === target) return;
|
|
140
|
+
children.set(source, [...children.get(source) ?? [], target]);
|
|
141
|
+
parents.set(target, [...parents.get(target) ?? [], source]);
|
|
142
|
+
};
|
|
143
|
+
for (const edge of edges) feeds(edge.source, edge.target);
|
|
144
|
+
for (const n of nodes) {
|
|
145
|
+
if (typeof n.parentId === "string" && n.parentId) feeds(n.id, n.parentId);
|
|
146
|
+
const mappings = n.data?.fieldMappings;
|
|
147
|
+
if (mappings && typeof mappings === "object") {
|
|
148
|
+
for (const mapping of Object.values(mappings)) {
|
|
149
|
+
const sourceNodeId = mapping?.sourceNodeId;
|
|
150
|
+
if (typeof sourceNodeId === "string" && sourceNodeId) feeds(sourceNodeId, n.id);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return { children, parents };
|
|
155
|
+
}
|
|
156
|
+
function nodeFeedsAnything(nodes, edges, nodeId) {
|
|
157
|
+
return (buildFeedMaps(nodes, edges).children.get(nodeId) ?? []).length > 0;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// src/node-runtime-keys.ts
|
|
161
|
+
var EXECUTION_DATA_KEYS = /* @__PURE__ */ new Set([
|
|
162
|
+
"executionStatus",
|
|
163
|
+
"currentJobId",
|
|
164
|
+
"currentJobProgress",
|
|
165
|
+
"errorMessage",
|
|
166
|
+
// Structured detail alongside errorMessage for a safety-filter block
|
|
167
|
+
// (see `JobErrorHint` in the app's frontend/src/types/nodes.ts). Same
|
|
168
|
+
// lifecycle as errorMessage: a RESULT the user expects to survive reload,
|
|
169
|
+
// never user-edited config.
|
|
170
|
+
"errorHint",
|
|
171
|
+
// A job policy registered by the deployment held this node's result for a
|
|
172
|
+
// human reviewer (`jobs.status = "pending_review"`). Pure run state, like
|
|
173
|
+
// executionStatus: the node is still "running" and the flag disappears the
|
|
174
|
+
// moment the review resolves — so it is ALSO in TRANSIENT_RUNTIME_KEYS
|
|
175
|
+
// below. Without the transient half, a flip into review marks a passive tab
|
|
176
|
+
// dirty and a preset captures "awaiting review".
|
|
177
|
+
"jobAwaitingReview",
|
|
178
|
+
// The editor cannot reach the server to read this node's job. The job keeps
|
|
179
|
+
// running and the watch keeps polling. Pure run state, cleared by the next
|
|
180
|
+
// check that gets through, so it is ALSO in TRANSIENT_RUNTIME_KEYS below.
|
|
181
|
+
"jobConnectionLost",
|
|
182
|
+
"isStreaming",
|
|
183
|
+
"generatedImageUrl",
|
|
184
|
+
"generatedVideoUrl",
|
|
185
|
+
"generatedAudioUrl",
|
|
186
|
+
"generatedText",
|
|
187
|
+
"generatedScript",
|
|
188
|
+
"generatedItems",
|
|
189
|
+
"generatedResults",
|
|
190
|
+
"activeResultIndex",
|
|
191
|
+
"sourceImageUrl",
|
|
192
|
+
"__listTotal",
|
|
193
|
+
"__listCompleted",
|
|
194
|
+
"__listResults",
|
|
195
|
+
// Row-aligned twin of __listResults (Extract Field, List output) — read only
|
|
196
|
+
// by the fan-out so two lists cut from one array pair by row.
|
|
197
|
+
"__alignedListResults",
|
|
198
|
+
// A render's fan-out row stamps, row-aligned with __listResults: each row's
|
|
199
|
+
// take identity, and the clip every row was sent for (a failed row too).
|
|
200
|
+
"__listResultStamps",
|
|
201
|
+
// List fan-out window flag (abandon-guard exemption). Set/cleared by
|
|
202
|
+
// executeNodeForList — purely execution-related, never user-edited.
|
|
203
|
+
"__listRunning",
|
|
204
|
+
// Why the last server run skipped this node (`empty_input`): a chip on the
|
|
205
|
+
// card for the run that just ended, never a saved result — also in
|
|
206
|
+
// TRANSIENT_RUNTIME_KEYS below.
|
|
207
|
+
"__runSkipReason",
|
|
208
|
+
// One token per paid run still out on this node that no executor mark
|
|
209
|
+
// covers (the editor's `withRunInFlight`, around each paid call outside the
|
|
210
|
+
// executors). Purely execution-related, never user-edited; also in
|
|
211
|
+
// TRANSIENT_RUNTIME_KEYS.
|
|
212
|
+
"__runsInFlight",
|
|
213
|
+
// Selector node dual-channel outputs (picked + rest). Server-side execution
|
|
214
|
+
// output, not user-edited config.
|
|
215
|
+
"pickedResults",
|
|
216
|
+
"restResults",
|
|
217
|
+
"__pickedResults",
|
|
218
|
+
"__restResults",
|
|
219
|
+
"__pickedTotal",
|
|
220
|
+
"__restTotal",
|
|
221
|
+
"generatedJson",
|
|
222
|
+
// A render's remapped transcript on its own pip (Speaker View's
|
|
223
|
+
// `transcript`, RENDER_NODE_TYPES transcriptOutput) — run-result data.
|
|
224
|
+
"generatedTranscript",
|
|
225
|
+
// Edit Plan: a person's review of the plan (`EditedEdl`, edit-plan-review.ts),
|
|
226
|
+
// kept beside `generatedJson` and fingerprinted against it. Run-result data
|
|
227
|
+
// (TA14, decided 2026-10-04): out of undo, presets, templates and exports,
|
|
228
|
+
// and Clear results wipes it. Persisted — never transient.
|
|
229
|
+
"editedEdl",
|
|
230
|
+
"subWorkflowProgress",
|
|
231
|
+
"outputResults",
|
|
232
|
+
"shots",
|
|
233
|
+
"result",
|
|
234
|
+
"processedResult",
|
|
235
|
+
"activeRoutes",
|
|
236
|
+
"routeOutputs",
|
|
237
|
+
"_upstreamRefresh",
|
|
238
|
+
"zoom",
|
|
239
|
+
// Character LoRA training status fields — written every 8s while training.
|
|
240
|
+
"loraReplicateVersion",
|
|
241
|
+
"loraTriggerWord",
|
|
242
|
+
"loraTrainingStatus",
|
|
243
|
+
// Collect (fan-in) execution snapshot.
|
|
244
|
+
"lastInputs",
|
|
245
|
+
"lastMeta",
|
|
246
|
+
"__upstreamCount",
|
|
247
|
+
// Video URL node — the download's live percent/phase, written on every
|
|
248
|
+
// progress tick (~2/s). Pure run-state; also in TRANSIENT_RUNTIME_KEYS below.
|
|
249
|
+
"downloadPercent",
|
|
250
|
+
"downloadPhase",
|
|
251
|
+
// Webhook Output's delivery receipt. A webhook target may reflect the
|
|
252
|
+
// request back (httpbin, RequestBin, an API that 400s with "headers
|
|
253
|
+
// received: …"), so `webhookResponseBody` can carry whatever the request
|
|
254
|
+
// carried — with an attached credential, the secret itself. Listing the three
|
|
255
|
+
// here is what keeps the receipt out of template exports (GENERATED_FIELDS
|
|
256
|
+
// derives from this set), out of node presets, and out of undo history.
|
|
257
|
+
"webhookSuccess",
|
|
258
|
+
"webhookStatusCode",
|
|
259
|
+
"webhookResponseBody",
|
|
260
|
+
// Content Ideas: one creative brief per idea (the node's list output — kept
|
|
261
|
+
// out of __listResults, which would clone the node). And the non-fatal notes
|
|
262
|
+
// a Content Recipe / Content Ideas run returns ("read the first of 3 posts").
|
|
263
|
+
// Both are RESULTS: they persist, and a preset, a template or a run-only
|
|
264
|
+
// patch must never treat them as config.
|
|
265
|
+
"ideaBriefs",
|
|
266
|
+
"runWarnings",
|
|
267
|
+
// Content Ideas: the own brand whose results the last run leaned on — a
|
|
268
|
+
// RESULT naming the runner's brand, so a template or a preset never carries it.
|
|
269
|
+
"brandLessons",
|
|
270
|
+
// Social Search: every post the last search found (the picker's grid), the
|
|
271
|
+
// ids a person picked from them, and the run's non-fatal notes ("only part
|
|
272
|
+
// of the results loaded"). All RESULTS: a template, a preset or a run-only
|
|
273
|
+
// patch must never carry yesterday's posts or picks as configuration.
|
|
274
|
+
"searchResults",
|
|
275
|
+
"pickedIds",
|
|
276
|
+
"searchWarnings",
|
|
277
|
+
// Save to Collection: how the last run ended for this node (inserted /
|
|
278
|
+
// duplicate / replayed) and how many old records the cap evicted. RESULTS of
|
|
279
|
+
// a run — Clear results wipes them, and a template, a preset or a run-only
|
|
280
|
+
// patch never carries them as configuration.
|
|
281
|
+
"lastOutcome",
|
|
282
|
+
"lastEvicted",
|
|
283
|
+
// When the editor's "Clear results" last emptied this node (ISO time). Not a
|
|
284
|
+
// result and not config: bookkeeping that tells the load-time recovery lanes
|
|
285
|
+
// "this node is empty ON PURPOSE" — without it, every reload reads an empty
|
|
286
|
+
// node as "ran while the editor was closed" and paints the last run back.
|
|
287
|
+
// Persisted (never transient): the reload is exactly when it is read.
|
|
288
|
+
"resultsClearedAt",
|
|
289
|
+
// The id of the trigger-started run whose results this node shows (the
|
|
290
|
+
// editor paints a Telegram run onto the canvas). Bookkeeping, not a result
|
|
291
|
+
// and not config: it stops a reload from painting the same run again over
|
|
292
|
+
// edits made since. Persisted for the same reason as resultsClearedAt.
|
|
293
|
+
"resultsRunId",
|
|
294
|
+
// When that run ended the node (beside resultsRunId): the editor's reopen
|
|
295
|
+
// keeps a result a NEWER run left even when its own run listing cannot see
|
|
296
|
+
// that run. Bookkeeping, persisted for the same reason.
|
|
297
|
+
"resultsRunEndedAt",
|
|
298
|
+
// A trigger's last run values (also in TRANSIENT_RUNTIME_KEYS: never saved).
|
|
299
|
+
"__triggerData",
|
|
300
|
+
// A fan-out's notes rows, every fan-out's (row-aligned with __listResults):
|
|
301
|
+
// a row's warnings and length. A RESULT: persisted.
|
|
302
|
+
"__listResultMeta",
|
|
303
|
+
// A use-case node's continuation of one of its runs (Tighten Episode): set
|
|
304
|
+
// for ONE run only, as that run's input override (an app's or the editor's
|
|
305
|
+
// Render final, the canvas Continue's run option). Never saved — also in
|
|
306
|
+
// TRANSIENT_RUNTIME_KEYS — so a saved one can never turn a later plain run
|
|
307
|
+
// into a continuation of an old run.
|
|
308
|
+
"useCaseContinue"
|
|
309
|
+
]);
|
|
310
|
+
var NODE_TYPE_EXECUTION_DATA_KEYS = {
|
|
311
|
+
"ugc-creator": ["ugcOutputs", "candidates", "optionFailed"],
|
|
312
|
+
"ugc-script": ["ugcOutputs"],
|
|
313
|
+
"ugc-clips": ["ugcOutputs", "quote"],
|
|
314
|
+
"ugc-clip": ["ugcOutputs", "clipWarnings", "durationSec", "rerenderPending"],
|
|
315
|
+
"ugc-cards": ["ugcOutputs"]
|
|
316
|
+
};
|
|
317
|
+
function isExecutionDataKey(key, type) {
|
|
318
|
+
if (EXECUTION_DATA_KEYS.has(key)) return true;
|
|
319
|
+
return typeof type === "string" && Object.hasOwn(NODE_TYPE_EXECUTION_DATA_KEYS, type) && NODE_TYPE_EXECUTION_DATA_KEYS[type].includes(key);
|
|
320
|
+
}
|
|
321
|
+
var EXECUTION_DATA_KEYS_BY_TYPE = new Map(
|
|
322
|
+
Object.entries(NODE_TYPE_EXECUTION_DATA_KEYS).map(([type, keys]) => [type, /* @__PURE__ */ new Set([...EXECUTION_DATA_KEYS, ...keys])])
|
|
323
|
+
);
|
|
324
|
+
function executionDataKeysOf(type) {
|
|
325
|
+
return (typeof type === "string" ? EXECUTION_DATA_KEYS_BY_TYPE.get(type) : void 0) ?? EXECUTION_DATA_KEYS;
|
|
326
|
+
}
|
|
327
|
+
var TRANSIENT_RUNTIME_KEYS = /* @__PURE__ */ new Set([
|
|
328
|
+
"executionStatus",
|
|
329
|
+
"currentJobId",
|
|
330
|
+
"currentJobProgress",
|
|
331
|
+
"jobAwaitingReview",
|
|
332
|
+
"jobConnectionLost",
|
|
333
|
+
"isStreaming",
|
|
334
|
+
"subWorkflowProgress",
|
|
335
|
+
"__listTotal",
|
|
336
|
+
"__listCompleted",
|
|
337
|
+
"__listRunning",
|
|
338
|
+
"__runSkipReason",
|
|
339
|
+
// A paid run still out, held by the editor tab that started it. Never
|
|
340
|
+
// saved, so a reload, which has no such run, starts without one.
|
|
341
|
+
"__runsInFlight",
|
|
342
|
+
"_upstreamRefresh",
|
|
343
|
+
"__upstreamCount",
|
|
344
|
+
// Video URL node download ticks. They used to dirty the workflow twice a
|
|
345
|
+
// second for the length of the download — the same phantom-save chain the
|
|
346
|
+
// job-progress keys above were moved here to stop. What SURVIVES a reload is
|
|
347
|
+
// `downloadStatus` + `downloadId`; the percent is re-read from the server.
|
|
348
|
+
"downloadPercent",
|
|
349
|
+
"downloadPhase",
|
|
350
|
+
// A trigger's last run values, shown in the editor after a run (a webhook's
|
|
351
|
+
// body, a Telegram message and its post). Never saved: the workflow is not
|
|
352
|
+
// where a message's content is kept — runs are, under their retention.
|
|
353
|
+
"__triggerData",
|
|
354
|
+
// A use-case node's continuation: one run's override, never config (above).
|
|
355
|
+
"useCaseContinue"
|
|
356
|
+
]);
|
|
357
|
+
function stripTransientRuntimeData(nodes) {
|
|
358
|
+
return nodes.map((node) => {
|
|
359
|
+
const data = node.data;
|
|
360
|
+
if (!data) return node;
|
|
361
|
+
let hasTransient = false;
|
|
362
|
+
for (const key of TRANSIENT_RUNTIME_KEYS) {
|
|
363
|
+
if (key in data) {
|
|
364
|
+
hasTransient = true;
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
if (!hasTransient) return node;
|
|
369
|
+
const cleaned = {};
|
|
370
|
+
for (const [key, value] of Object.entries(data)) {
|
|
371
|
+
if (!TRANSIENT_RUNTIME_KEYS.has(key)) cleaned[key] = value;
|
|
372
|
+
}
|
|
373
|
+
return { ...node, data: cleaned };
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// src/json-path.ts
|
|
378
|
+
function evaluateJsonPath(value, path) {
|
|
379
|
+
const segments = path.length === 0 ? [] : path.split(".");
|
|
380
|
+
return walk(value, segments, 0);
|
|
381
|
+
}
|
|
382
|
+
function stringifyPathResults(raw) {
|
|
383
|
+
const out = [];
|
|
384
|
+
for (const v of raw) {
|
|
385
|
+
if (v === null || v === void 0) continue;
|
|
386
|
+
if (typeof v === "string") out.push(v);
|
|
387
|
+
else if (typeof v === "number" || typeof v === "boolean") out.push(String(v));
|
|
388
|
+
else out.push(JSON.stringify(v));
|
|
389
|
+
}
|
|
390
|
+
return out;
|
|
391
|
+
}
|
|
392
|
+
function walk(value, segments, offset) {
|
|
393
|
+
if (Array.isArray(value)) {
|
|
394
|
+
const results = [];
|
|
395
|
+
for (const item of value) {
|
|
396
|
+
for (const v of walk(item, segments, offset)) results.push(v);
|
|
397
|
+
}
|
|
398
|
+
return results;
|
|
399
|
+
}
|
|
400
|
+
if (offset >= segments.length) return [value];
|
|
401
|
+
if (value !== null && typeof value === "object") {
|
|
402
|
+
const head = segments[offset];
|
|
403
|
+
if (!Object.hasOwn(value, head)) return [];
|
|
404
|
+
return walk(value[head], segments, offset + 1);
|
|
405
|
+
}
|
|
406
|
+
return [];
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// src/filter-condition.ts
|
|
410
|
+
function tryParseJson(item) {
|
|
411
|
+
if (typeof item !== "string") return item;
|
|
412
|
+
const trimmed = item.trim();
|
|
413
|
+
if (!trimmed) return item;
|
|
414
|
+
const first = trimmed[0];
|
|
415
|
+
if (first !== "{" && first !== "[" && first !== '"' && !/^-?\d/.test(trimmed) && trimmed !== "true" && trimmed !== "false" && trimmed !== "null") {
|
|
416
|
+
return item;
|
|
417
|
+
}
|
|
418
|
+
try {
|
|
419
|
+
return JSON.parse(trimmed);
|
|
420
|
+
} catch {
|
|
421
|
+
return item;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
var HOUR_MS = 60 * 60 * 1e3;
|
|
425
|
+
var DAY_MS = 24 * HOUR_MS;
|
|
426
|
+
var WEEK_MS = 7 * DAY_MS;
|
|
427
|
+
function resolveRelativeWindowToken(key) {
|
|
428
|
+
const m = /^last_N_(hours|days|weeks):(-?\d+)$/.exec(key);
|
|
429
|
+
if (!m) return void 0;
|
|
430
|
+
const n = parseInt(m[2], 10);
|
|
431
|
+
if (!Number.isFinite(n)) return void 0;
|
|
432
|
+
const unitMs = m[1] === "hours" ? HOUR_MS : m[1] === "days" ? DAY_MS : WEEK_MS;
|
|
433
|
+
return new Date(Date.now() - n * unitMs).toISOString();
|
|
434
|
+
}
|
|
435
|
+
function substituteTriggerTokens(raw, triggerData) {
|
|
436
|
+
if (!/\{\{/.test(raw)) return raw;
|
|
437
|
+
return raw.replace(/\{\{\s*([^}]+?)\s*\}\}/g, (_m, expr) => {
|
|
438
|
+
const key = String(expr).trim();
|
|
439
|
+
if (key === "now") return (/* @__PURE__ */ new Date()).toISOString();
|
|
440
|
+
if (key === "trigger.last_triggered_at") {
|
|
441
|
+
const v = triggerData?.last_triggered_at;
|
|
442
|
+
return v == null ? "" : String(v);
|
|
443
|
+
}
|
|
444
|
+
if (key.startsWith("trigger.")) {
|
|
445
|
+
const path = key.slice("trigger.".length);
|
|
446
|
+
const v = triggerData?.[path];
|
|
447
|
+
return v == null ? "" : String(v);
|
|
448
|
+
}
|
|
449
|
+
const relative = resolveRelativeWindowToken(key);
|
|
450
|
+
if (relative !== void 0) return relative;
|
|
451
|
+
return "";
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
function resolveConditionValue(raw, valueType, triggerData, variables) {
|
|
455
|
+
let value = raw;
|
|
456
|
+
if (variables && variables.size > 0) {
|
|
457
|
+
value = resolveNodeRefs(value, variables);
|
|
458
|
+
}
|
|
459
|
+
const hasTemplate = /\{\{/.test(value);
|
|
460
|
+
if (valueType !== "variable" && !hasTemplate) return value;
|
|
461
|
+
return substituteTriggerTokens(value, triggerData);
|
|
462
|
+
}
|
|
463
|
+
function asComparableNumber(v) {
|
|
464
|
+
if (typeof v === "number") return v;
|
|
465
|
+
if (typeof v === "boolean") return v ? 1 : 0;
|
|
466
|
+
if (typeof v === "string") {
|
|
467
|
+
const trimmed = v.trim();
|
|
468
|
+
if (trimmed === "") return NaN;
|
|
469
|
+
const n = Number(trimmed);
|
|
470
|
+
if (!isNaN(n)) return n;
|
|
471
|
+
const d = Date.parse(trimmed);
|
|
472
|
+
if (!isNaN(d)) return d;
|
|
473
|
+
}
|
|
474
|
+
return NaN;
|
|
475
|
+
}
|
|
476
|
+
function compareValues(a, b) {
|
|
477
|
+
const na = asComparableNumber(a);
|
|
478
|
+
const nb = asComparableNumber(b);
|
|
479
|
+
if (!isNaN(na) && !isNaN(nb)) return na - nb;
|
|
480
|
+
return String(a ?? "").localeCompare(String(b ?? ""));
|
|
481
|
+
}
|
|
482
|
+
function valuesEqual(a, b) {
|
|
483
|
+
const na = asComparableNumber(a);
|
|
484
|
+
const nb = asComparableNumber(b);
|
|
485
|
+
if (!isNaN(na) && !isNaN(nb)) return na === nb;
|
|
486
|
+
return String(a ?? "") === String(b ?? "");
|
|
487
|
+
}
|
|
488
|
+
function applyCase(s, caseSensitive) {
|
|
489
|
+
return caseSensitive ? s : s.toLowerCase();
|
|
490
|
+
}
|
|
491
|
+
function evaluateCondition(parsedItem, rawItem, condition, triggerData, options) {
|
|
492
|
+
const path = (condition.field ?? "").trim();
|
|
493
|
+
let fieldValue;
|
|
494
|
+
if (path === "") {
|
|
495
|
+
fieldValue = parsedItem ?? rawItem;
|
|
496
|
+
} else {
|
|
497
|
+
const matches = evaluateJsonPath(parsedItem ?? rawItem, path);
|
|
498
|
+
fieldValue = matches.length > 0 ? matches[0] : void 0;
|
|
499
|
+
}
|
|
500
|
+
const targetStr = resolveConditionValue(condition.value ?? "", condition.valueType, triggerData, options?.variables);
|
|
501
|
+
const cs = options?.caseSensitive ?? true;
|
|
502
|
+
const fieldStr = String(fieldValue ?? "");
|
|
503
|
+
switch (condition.operator) {
|
|
504
|
+
case "exists":
|
|
505
|
+
return fieldValue !== void 0 && fieldValue !== null;
|
|
506
|
+
case "not_exists":
|
|
507
|
+
return fieldValue === void 0 || fieldValue === null;
|
|
508
|
+
case "contains":
|
|
509
|
+
return applyCase(fieldStr, cs).includes(applyCase(targetStr, cs));
|
|
510
|
+
case "not_contains":
|
|
511
|
+
return !applyCase(fieldStr, cs).includes(applyCase(targetStr, cs));
|
|
512
|
+
case "starts_with":
|
|
513
|
+
return applyCase(fieldStr, cs).startsWith(applyCase(targetStr, cs));
|
|
514
|
+
case "ends_with":
|
|
515
|
+
return applyCase(fieldStr, cs).endsWith(applyCase(targetStr, cs));
|
|
516
|
+
case "regex": {
|
|
517
|
+
if (!targetStr) return false;
|
|
518
|
+
try {
|
|
519
|
+
return new RegExp(targetStr).test(fieldStr);
|
|
520
|
+
} catch {
|
|
521
|
+
return false;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
case "=":
|
|
525
|
+
return cs ? valuesEqual(fieldValue, targetStr) : applyCase(fieldStr, false) === applyCase(targetStr, false);
|
|
526
|
+
case "!=":
|
|
527
|
+
return cs ? !valuesEqual(fieldValue, targetStr) : applyCase(fieldStr, false) !== applyCase(targetStr, false);
|
|
528
|
+
case ">":
|
|
529
|
+
return compareValues(fieldValue, targetStr) > 0;
|
|
530
|
+
case "<":
|
|
531
|
+
return compareValues(fieldValue, targetStr) < 0;
|
|
532
|
+
case ">=":
|
|
533
|
+
return compareValues(fieldValue, targetStr) >= 0;
|
|
534
|
+
case "<=":
|
|
535
|
+
return compareValues(fieldValue, targetStr) <= 0;
|
|
536
|
+
default:
|
|
537
|
+
return false;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
function evaluateConditionGroup(parsedItem, rawItem, conditions, logic, triggerData, options) {
|
|
541
|
+
const effective = conditions.filter((c) => c && c.operator);
|
|
542
|
+
if (effective.length === 0) return true;
|
|
543
|
+
const results = effective.map((c) => evaluateCondition(parsedItem, rawItem, c, triggerData, options));
|
|
544
|
+
return logic === "OR" ? results.some(Boolean) : results.every(Boolean);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// src/selector.ts
|
|
548
|
+
function resolveIndex(expr, listLength, defaultExpr = "1") {
|
|
549
|
+
if (listLength <= 0) return 0;
|
|
550
|
+
const trimmed = expr.trim();
|
|
551
|
+
let index;
|
|
552
|
+
if (trimmed === "last") {
|
|
553
|
+
index = listLength - 1;
|
|
554
|
+
} else if (trimmed.startsWith("last-")) {
|
|
555
|
+
const offset = parseInt(trimmed.slice(5), 10);
|
|
556
|
+
if (isNaN(offset) || offset < 0) return resolveIndex(defaultExpr === expr ? "1" : defaultExpr, listLength);
|
|
557
|
+
index = listLength - 1 - offset;
|
|
558
|
+
} else {
|
|
559
|
+
const n = parseInt(trimmed, 10);
|
|
560
|
+
if (isNaN(n)) return resolveIndex(defaultExpr === expr ? "1" : defaultExpr, listLength);
|
|
561
|
+
index = n - 1;
|
|
562
|
+
}
|
|
563
|
+
return Math.max(0, Math.min(index, listLength - 1));
|
|
564
|
+
}
|
|
565
|
+
function applyRange(list, from, to, step) {
|
|
566
|
+
if (list.length === 0) return [];
|
|
567
|
+
const fromIdx = resolveIndex(from ?? "1", list.length, "1");
|
|
568
|
+
const toIdx = resolveIndex(to ?? "last", list.length, "last");
|
|
569
|
+
const effectiveStep = step === 0 || step === void 0 ? 1 : step;
|
|
570
|
+
if (effectiveStep > 0 && fromIdx > toIdx) return [];
|
|
571
|
+
if (effectiveStep < 0 && fromIdx < toIdx) return [];
|
|
572
|
+
const result = [];
|
|
573
|
+
if (effectiveStep > 0) {
|
|
574
|
+
for (let i = fromIdx; i <= toIdx; i += effectiveStep) result.push(list[i]);
|
|
575
|
+
} else {
|
|
576
|
+
for (let i = fromIdx; i >= toIdx; i += effectiveStep) result.push(list[i]);
|
|
577
|
+
}
|
|
578
|
+
return result;
|
|
579
|
+
}
|
|
580
|
+
function migrateEdgeOutputMode(data) {
|
|
581
|
+
if (!data) return data;
|
|
582
|
+
const mode = data.outputMode;
|
|
583
|
+
if (!mode || !mode.startsWith("item:")) return data;
|
|
584
|
+
const idx = parseInt(mode.split(":")[1], 10);
|
|
585
|
+
return {
|
|
586
|
+
...data,
|
|
587
|
+
outputMode: "item",
|
|
588
|
+
itemIndex: String(isNaN(idx) ? 1 : idx + 1)
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
function buildRangeLabel(mode, rangeFrom, rangeTo, rangeStep, itemIndex, selectorMode, listExpression) {
|
|
592
|
+
return buildItemLabel(mode, rangeFrom, rangeTo, rangeStep, itemIndex, selectorMode, listExpression);
|
|
593
|
+
}
|
|
594
|
+
function buildItemLabel(mode, rangeFrom, rangeTo, rangeStep, itemIndex, selectorMode, listExpression) {
|
|
595
|
+
if (mode === "last") return void 0;
|
|
596
|
+
if ((mode === "each" || mode === "all") && selectorMode === "list") {
|
|
597
|
+
const trimmed = (listExpression ?? "").trim();
|
|
598
|
+
if (trimmed === "") return void 0;
|
|
599
|
+
return truncateLabel(trimmed, 18);
|
|
600
|
+
}
|
|
601
|
+
if (mode === "item") return itemIndex || void 0;
|
|
602
|
+
const from = rangeFrom ?? "1";
|
|
603
|
+
const to = rangeTo ?? "last";
|
|
604
|
+
const step = rangeStep ?? 1;
|
|
605
|
+
const isDefaultRange = from === "1" && to === "last";
|
|
606
|
+
const isDefaultStep = step === 1;
|
|
607
|
+
if (isDefaultRange && isDefaultStep) return void 0;
|
|
608
|
+
let label = `${from}..${to}`;
|
|
609
|
+
if ((mode === "each" || mode === "all") && !isDefaultStep) {
|
|
610
|
+
label += step > 0 ? ` +${step}` : ` ${step}`;
|
|
611
|
+
}
|
|
612
|
+
return label;
|
|
613
|
+
}
|
|
614
|
+
function truncateLabel(s, maxLen) {
|
|
615
|
+
if (s.length <= maxLen) return s;
|
|
616
|
+
return s.slice(0, maxLen) + "\u2026";
|
|
617
|
+
}
|
|
618
|
+
function parseListExpression(expr) {
|
|
619
|
+
const result = parseListTerms(expr.trim());
|
|
620
|
+
return result.ok ? { ok: true } : { ok: false, error: result.error };
|
|
621
|
+
}
|
|
622
|
+
function isValidIndexToken(token) {
|
|
623
|
+
if (token === "last") return true;
|
|
624
|
+
if (/^[1-9]\d*$/.test(token)) return true;
|
|
625
|
+
const m = /^last-(\d+)$/.exec(token);
|
|
626
|
+
if (m) return !isNaN(parseInt(m[1], 10));
|
|
627
|
+
return false;
|
|
628
|
+
}
|
|
629
|
+
function resolveListExpression(expr, listLength) {
|
|
630
|
+
if (listLength <= 0) return [];
|
|
631
|
+
const result = parseListTerms(expr.trim());
|
|
632
|
+
if (!result.ok) {
|
|
633
|
+
console.warn("[edge-range] invalid list expression:", expr, "\u2014", result.error);
|
|
634
|
+
return indexRange(0, listLength - 1, 1);
|
|
635
|
+
}
|
|
636
|
+
if (result.terms.length === 0) return indexRange(0, listLength - 1, 1);
|
|
637
|
+
const out = [];
|
|
638
|
+
for (const term of result.terms) {
|
|
639
|
+
if (term.kind === "index") {
|
|
640
|
+
out.push(resolveIndex(term.token, listLength));
|
|
641
|
+
} else {
|
|
642
|
+
const from = resolveIndex(term.from, listLength);
|
|
643
|
+
const to = resolveIndex(term.to, listLength);
|
|
644
|
+
for (const idx of indexRange(from, to, term.step)) out.push(idx);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
return out;
|
|
648
|
+
}
|
|
649
|
+
function indexRange(from, to, step) {
|
|
650
|
+
const out = [];
|
|
651
|
+
if (step > 0) {
|
|
652
|
+
if (from > to) return [];
|
|
653
|
+
for (let i = from; i <= to; i += step) out.push(i);
|
|
654
|
+
} else {
|
|
655
|
+
if (from < to) return [];
|
|
656
|
+
for (let i = from; i >= to; i += step) out.push(i);
|
|
657
|
+
}
|
|
658
|
+
return out;
|
|
659
|
+
}
|
|
660
|
+
function selectListItems(items, edgeData) {
|
|
661
|
+
if (items.length === 0) return [];
|
|
662
|
+
if (isDefaultSelectorConfig(edgeData)) return items;
|
|
663
|
+
if (edgeData?.selectorMode === "list") {
|
|
664
|
+
const indices = resolveListExpression(edgeData.listExpression ?? "", items.length);
|
|
665
|
+
return indices.map((i) => items[i]);
|
|
666
|
+
}
|
|
667
|
+
return applyRange(items, edgeData?.rangeFrom, edgeData?.rangeTo, edgeData?.rangeStep);
|
|
668
|
+
}
|
|
669
|
+
function isDefaultSelectorConfig(edgeData) {
|
|
670
|
+
if (!edgeData) return true;
|
|
671
|
+
if (edgeData.selectorMode === "list") {
|
|
672
|
+
return (edgeData.listExpression ?? "").trim() === "";
|
|
673
|
+
}
|
|
674
|
+
const { from, to, step } = canonicalRange(edgeData);
|
|
675
|
+
return from === "1" && to === "last" && step === 1;
|
|
676
|
+
}
|
|
677
|
+
function describeEdgeBehavior(edgeData) {
|
|
678
|
+
const mode = edgeData?.outputMode;
|
|
679
|
+
return buildBaseSentence(edgeData, mode);
|
|
680
|
+
}
|
|
681
|
+
function buildBaseSentence(edgeData, mode) {
|
|
682
|
+
if (mode === "last") return "Passes the selected result.";
|
|
683
|
+
if (mode === "item") return buildItemSentence(edgeData);
|
|
684
|
+
if (mode === "each") return buildEachSentence(edgeData);
|
|
685
|
+
if (mode === "all") return buildAllSentence(edgeData);
|
|
686
|
+
return "Passes all items at once.";
|
|
687
|
+
}
|
|
688
|
+
function buildItemSentence(edgeData) {
|
|
689
|
+
const canonical = canonicalItemIndex(edgeData?.itemIndex);
|
|
690
|
+
return `Passes only ${itemModeForm(canonical)}.`;
|
|
691
|
+
}
|
|
692
|
+
function buildEachSentence(edgeData) {
|
|
693
|
+
if (isDefaultSelectorConfig(edgeData)) return "Runs the next node one by one, per item.";
|
|
694
|
+
if (edgeData?.selectorMode === "list") {
|
|
695
|
+
const result = parseListTerms((edgeData.listExpression ?? "").trim());
|
|
696
|
+
if (!result.ok) return "Runs the next node one by one, per item.";
|
|
697
|
+
}
|
|
698
|
+
const phrase = buildSelectionPhrase(edgeData);
|
|
699
|
+
if (phrase.kind === "empty-result") {
|
|
700
|
+
return "Nothing selected \u2014 the next node won't run.";
|
|
701
|
+
}
|
|
702
|
+
if (phrase.kind === "single-index") {
|
|
703
|
+
return `Runs the next node only on ${phrase.itemModeForm}.`;
|
|
704
|
+
}
|
|
705
|
+
return `Runs the next node once for ${phrase.text}.`;
|
|
706
|
+
}
|
|
707
|
+
function buildAllSentence(edgeData) {
|
|
708
|
+
if (isDefaultSelectorConfig(edgeData)) return "Passes all items at once.";
|
|
709
|
+
if (edgeData?.selectorMode === "list") {
|
|
710
|
+
const result = parseListTerms((edgeData.listExpression ?? "").trim());
|
|
711
|
+
if (!result.ok) return "Passes all items at once.";
|
|
712
|
+
}
|
|
713
|
+
const phrase = buildSelectionPhrase(edgeData);
|
|
714
|
+
if (phrase.kind === "empty-result") {
|
|
715
|
+
return "Nothing selected \u2014 the next node will get an empty bundle.";
|
|
716
|
+
}
|
|
717
|
+
if (phrase.kind === "single-index") {
|
|
718
|
+
return `Passes only ${phrase.itemModeForm}.`;
|
|
719
|
+
}
|
|
720
|
+
return `Passes ${phrase.text} at once.`;
|
|
721
|
+
}
|
|
722
|
+
function canonicalItemIndex(raw) {
|
|
723
|
+
const trimmed = (raw ?? "").trim();
|
|
724
|
+
if (trimmed === "") return "1";
|
|
725
|
+
if (!isValidIndexToken(trimmed)) return "1";
|
|
726
|
+
return trimmed;
|
|
727
|
+
}
|
|
728
|
+
function canonicalRange(edgeData) {
|
|
729
|
+
const from = (edgeData?.rangeFrom ?? "").trim() || "1";
|
|
730
|
+
const to = (edgeData?.rangeTo ?? "").trim() || "last";
|
|
731
|
+
const rawStep = edgeData?.rangeStep;
|
|
732
|
+
const step = rawStep === void 0 || rawStep === 0 ? 1 : rawStep;
|
|
733
|
+
return { from, to, step };
|
|
734
|
+
}
|
|
735
|
+
function itemModeForm(canonical) {
|
|
736
|
+
if (canonical === "1") return "the first item";
|
|
737
|
+
if (/^\d+$/.test(canonical)) return `item ${canonical}`;
|
|
738
|
+
if (canonical === "last" || canonical === "last-0") return "the last item";
|
|
739
|
+
const m = /^last-(\d+)$/.exec(canonical);
|
|
740
|
+
if (m) {
|
|
741
|
+
const n = parseInt(m[1], 10);
|
|
742
|
+
if (n === 1) return "the second-to-last item";
|
|
743
|
+
if (n === 2) return "the third-to-last item";
|
|
744
|
+
if (n === 3) return "the fourth-to-last item";
|
|
745
|
+
return `the ${ordinal(n + 1)}-from-last item`;
|
|
746
|
+
}
|
|
747
|
+
return "the first item";
|
|
748
|
+
}
|
|
749
|
+
function compactForm(canonical) {
|
|
750
|
+
if (/^\d+$/.test(canonical)) return canonical;
|
|
751
|
+
if (canonical === "last" || canonical === "last-0") return "the last one";
|
|
752
|
+
const m = /^last-(\d+)$/.exec(canonical);
|
|
753
|
+
if (m) {
|
|
754
|
+
const n = parseInt(m[1], 10);
|
|
755
|
+
if (n === 1) return "the second-to-last";
|
|
756
|
+
if (n === 2) return "the third-to-last";
|
|
757
|
+
if (n === 3) return "the fourth-to-last";
|
|
758
|
+
return `the ${ordinal(n + 1)}-from-last`;
|
|
759
|
+
}
|
|
760
|
+
return canonical;
|
|
761
|
+
}
|
|
762
|
+
function ordinal(n) {
|
|
763
|
+
const absN = Math.abs(n);
|
|
764
|
+
const lastTwo = absN % 100;
|
|
765
|
+
if (lastTwo >= 11 && lastTwo <= 13) return `${n}th`;
|
|
766
|
+
switch (absN % 10) {
|
|
767
|
+
case 1:
|
|
768
|
+
return `${n}st`;
|
|
769
|
+
case 2:
|
|
770
|
+
return `${n}nd`;
|
|
771
|
+
case 3:
|
|
772
|
+
return `${n}rd`;
|
|
773
|
+
default:
|
|
774
|
+
return `${n}th`;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
function buildSelectionPhrase(edgeData) {
|
|
778
|
+
if (edgeData?.selectorMode === "list") {
|
|
779
|
+
return buildListSelectionPhrase((edgeData.listExpression ?? "").trim());
|
|
780
|
+
}
|
|
781
|
+
return buildRangeSelectionPhrase(canonicalRange(edgeData));
|
|
782
|
+
}
|
|
783
|
+
function indexKind(token) {
|
|
784
|
+
if (/^[1-9]\d*$/.test(token)) return "concrete";
|
|
785
|
+
if (token === "last" || /^last-\d+$/.test(token)) return "relative";
|
|
786
|
+
return "invalid";
|
|
787
|
+
}
|
|
788
|
+
function relativeOffset(token) {
|
|
789
|
+
if (token === "last") return 0;
|
|
790
|
+
const m = /^last-(\d+)$/.exec(token);
|
|
791
|
+
return m ? parseInt(m[1], 10) : 0;
|
|
792
|
+
}
|
|
793
|
+
function compareTokens(a, b) {
|
|
794
|
+
const ka = indexKind(a);
|
|
795
|
+
const kb = indexKind(b);
|
|
796
|
+
if (ka !== kb) return "indeterminate";
|
|
797
|
+
if (ka === "concrete") {
|
|
798
|
+
const na = parseInt(a, 10);
|
|
799
|
+
const nb = parseInt(b, 10);
|
|
800
|
+
return na < nb ? -1 : na > nb ? 1 : 0;
|
|
801
|
+
}
|
|
802
|
+
if (ka === "relative") {
|
|
803
|
+
const oa = relativeOffset(a);
|
|
804
|
+
const ob = relativeOffset(b);
|
|
805
|
+
return oa < ob ? 1 : oa > ob ? -1 : 0;
|
|
806
|
+
}
|
|
807
|
+
return "indeterminate";
|
|
808
|
+
}
|
|
809
|
+
function buildRangeSelectionPhrase(r) {
|
|
810
|
+
const { from, to, step } = r;
|
|
811
|
+
const cmp = compareTokens(from, to);
|
|
812
|
+
if (cmp !== "indeterminate") {
|
|
813
|
+
if (step > 0 && cmp === 1) return { kind: "empty-result" };
|
|
814
|
+
if (step < 0 && cmp === -1) return { kind: "empty-result" };
|
|
815
|
+
}
|
|
816
|
+
if (cmp === 0) {
|
|
817
|
+
return { kind: "single-index", itemModeForm: itemModeForm(from) };
|
|
818
|
+
}
|
|
819
|
+
const absStep = Math.abs(step);
|
|
820
|
+
if (step === -1 && from === "last" && to === "1") {
|
|
821
|
+
return { kind: "items", text: "all items in reverse order" };
|
|
822
|
+
}
|
|
823
|
+
let text = `items ${compactForm(from)} through ${compactForm(to)}`;
|
|
824
|
+
if (absStep === 1 && step < 0) {
|
|
825
|
+
text += " in reverse order";
|
|
826
|
+
} else if (absStep > 1 && step > 0) {
|
|
827
|
+
text += ` (every ${ordinal(absStep)} item)`;
|
|
828
|
+
} else if (absStep > 1 && step < 0) {
|
|
829
|
+
text += ` (every ${ordinal(absStep)} item, in reverse)`;
|
|
830
|
+
}
|
|
831
|
+
return { kind: "items", text };
|
|
832
|
+
}
|
|
833
|
+
function parseListTerms(expr) {
|
|
834
|
+
if (expr === "") return { ok: true, terms: [] };
|
|
835
|
+
const terms = [];
|
|
836
|
+
const raw = expr.split(",");
|
|
837
|
+
for (const rawTerm of raw) {
|
|
838
|
+
const term = rawTerm.trim();
|
|
839
|
+
if (term === "") return { ok: false, error: "Empty item between commas" };
|
|
840
|
+
const rangeIdx = term.indexOf("..");
|
|
841
|
+
if (rangeIdx === -1) {
|
|
842
|
+
if (!isValidIndexToken(term)) return { ok: false, error: `Invalid index: ${term}` };
|
|
843
|
+
terms.push({ kind: "index", token: term });
|
|
844
|
+
continue;
|
|
845
|
+
}
|
|
846
|
+
const left = term.slice(0, rangeIdx).trim();
|
|
847
|
+
const rightWithStep = term.slice(rangeIdx + 2).trim();
|
|
848
|
+
if (left === "" || rightWithStep === "") {
|
|
849
|
+
return { ok: false, error: `Range missing endpoint: ${term}` };
|
|
850
|
+
}
|
|
851
|
+
const colonIdx = rightWithStep.indexOf(":");
|
|
852
|
+
const right = colonIdx === -1 ? rightWithStep : rightWithStep.slice(0, colonIdx).trim();
|
|
853
|
+
const stepStr = colonIdx === -1 ? null : rightWithStep.slice(colonIdx + 1).trim();
|
|
854
|
+
if (right === "") return { ok: false, error: `Range missing endpoint: ${term}` };
|
|
855
|
+
if (!isValidIndexToken(left)) return { ok: false, error: `Invalid index: ${left}` };
|
|
856
|
+
if (!isValidIndexToken(right)) return { ok: false, error: `Invalid index: ${right}` };
|
|
857
|
+
let step = 1;
|
|
858
|
+
if (stepStr !== null) {
|
|
859
|
+
if (!/^-?\d+$/.test(stepStr)) return { ok: false, error: "Step must be an integer" };
|
|
860
|
+
const parsed = parseInt(stepStr, 10);
|
|
861
|
+
step = parsed === 0 ? 1 : parsed;
|
|
862
|
+
}
|
|
863
|
+
terms.push({ kind: "range", from: left, to: right, step });
|
|
864
|
+
}
|
|
865
|
+
return { ok: true, terms };
|
|
866
|
+
}
|
|
867
|
+
function buildListSelectionPhrase(expr) {
|
|
868
|
+
const result = parseListTerms(expr);
|
|
869
|
+
if (!result.ok) return { kind: "empty-result" };
|
|
870
|
+
if (result.terms.length === 0) return { kind: "items", text: "items" };
|
|
871
|
+
const normalized = result.terms.map((t) => {
|
|
872
|
+
if (t.kind === "range") {
|
|
873
|
+
const cmp = compareTokens(t.from, t.to);
|
|
874
|
+
if (cmp === 0) return { kind: "index", token: t.from };
|
|
875
|
+
}
|
|
876
|
+
return t;
|
|
877
|
+
});
|
|
878
|
+
if (normalized.length === 1 && normalized[0].kind === "index") {
|
|
879
|
+
return { kind: "single-index", itemModeForm: itemModeForm(normalized[0].token) };
|
|
880
|
+
}
|
|
881
|
+
const rendered = normalized.map((t) => {
|
|
882
|
+
if (t.kind === "index") return compactForm(t.token);
|
|
883
|
+
let text = `${compactForm(t.from)} through ${compactForm(t.to)}`;
|
|
884
|
+
const absStep = Math.abs(t.step);
|
|
885
|
+
if (absStep === 1 && t.step < 0) {
|
|
886
|
+
if (t.from === "last" && t.to === "1") return "all items in reverse";
|
|
887
|
+
text += " in reverse";
|
|
888
|
+
} else if (absStep > 1 && t.step > 0) {
|
|
889
|
+
text += ` (every ${ordinal(absStep)})`;
|
|
890
|
+
} else if (absStep > 1 && t.step < 0) {
|
|
891
|
+
text += ` (every ${ordinal(absStep)}, in reverse)`;
|
|
892
|
+
}
|
|
893
|
+
return text;
|
|
894
|
+
});
|
|
895
|
+
let joined;
|
|
896
|
+
if (rendered.length === 1) {
|
|
897
|
+
joined = rendered[0];
|
|
898
|
+
} else if (rendered.length === 2) {
|
|
899
|
+
joined = `${rendered[0]} and ${rendered[1]}`;
|
|
900
|
+
} else {
|
|
901
|
+
const head = rendered.slice(0, -1).join(", ");
|
|
902
|
+
joined = `${head}, and ${rendered[rendered.length - 1]}`;
|
|
903
|
+
}
|
|
904
|
+
return { kind: "items", text: `items ${joined}` };
|
|
905
|
+
}
|
|
906
|
+
function runSelector(items, config) {
|
|
907
|
+
if (items.length === 0) return { picked: [], rest: [] };
|
|
908
|
+
switch (config.mode) {
|
|
909
|
+
case "item": {
|
|
910
|
+
const idx = resolveIndex(config.itemIndex ?? "1", items.length, "1");
|
|
911
|
+
return splitByIndices(items, [idx]);
|
|
912
|
+
}
|
|
913
|
+
case "range": {
|
|
914
|
+
const indices = applyRangeIndices(items.length, config.rangeFrom, config.rangeTo, config.rangeStep);
|
|
915
|
+
return splitByIndices(items, indices);
|
|
916
|
+
}
|
|
917
|
+
case "list": {
|
|
918
|
+
const indices = resolveListExpression(config.listExpression ?? "", items.length);
|
|
919
|
+
return splitByIndices(items, indices);
|
|
920
|
+
}
|
|
921
|
+
case "random":
|
|
922
|
+
return selectRandom(items, config.randomCount ?? 1, config.seed);
|
|
923
|
+
case "modulo":
|
|
924
|
+
return selectByModulo(items, config.moduloDivisor);
|
|
925
|
+
case "predicate":
|
|
926
|
+
return selectByPredicate(items, config);
|
|
927
|
+
case "named-key":
|
|
928
|
+
return selectByNamedKey(items, config.namedKeyField, config.namedKeyValue);
|
|
929
|
+
default:
|
|
930
|
+
return { picked: [], rest: items.slice() };
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
function splitByIndices(items, pickedIndices) {
|
|
934
|
+
const pickedSet = new Set(pickedIndices.filter((i) => i >= 0 && i < items.length));
|
|
935
|
+
const picked = [];
|
|
936
|
+
const rest = [];
|
|
937
|
+
for (let i = 0; i < items.length; i++) {
|
|
938
|
+
if (pickedSet.has(i)) picked.push(items[i]);
|
|
939
|
+
else rest.push(items[i]);
|
|
940
|
+
}
|
|
941
|
+
return { picked, rest };
|
|
942
|
+
}
|
|
943
|
+
function applyRangeIndices(length, from, to, step) {
|
|
944
|
+
if (length === 0) return [];
|
|
945
|
+
const fromIdx = resolveIndex(from ?? "1", length, "1");
|
|
946
|
+
const toIdx = resolveIndex(to ?? "last", length, "last");
|
|
947
|
+
const effectiveStep = step === 0 || step === void 0 ? 1 : step;
|
|
948
|
+
if (effectiveStep > 0 && fromIdx > toIdx) return [];
|
|
949
|
+
if (effectiveStep < 0 && fromIdx < toIdx) return [];
|
|
950
|
+
const result = [];
|
|
951
|
+
if (effectiveStep > 0) {
|
|
952
|
+
for (let i = fromIdx; i <= toIdx; i += effectiveStep) result.push(i);
|
|
953
|
+
} else {
|
|
954
|
+
for (let i = fromIdx; i >= toIdx; i += effectiveStep) result.push(i);
|
|
955
|
+
}
|
|
956
|
+
return result;
|
|
957
|
+
}
|
|
958
|
+
function mulberry32(seed) {
|
|
959
|
+
let a = seed | 0;
|
|
960
|
+
return () => {
|
|
961
|
+
a = a + 1831565813 | 0;
|
|
962
|
+
let t = a;
|
|
963
|
+
t = Math.imul(t ^ t >>> 15, t | 1);
|
|
964
|
+
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
|
|
965
|
+
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
966
|
+
};
|
|
967
|
+
}
|
|
968
|
+
function hashSeed(s) {
|
|
969
|
+
let h = 2166136261 | 0;
|
|
970
|
+
for (let i = 0; i < s.length; i++) {
|
|
971
|
+
h ^= s.charCodeAt(i);
|
|
972
|
+
h = Math.imul(h, 16777619);
|
|
973
|
+
}
|
|
974
|
+
return h;
|
|
975
|
+
}
|
|
976
|
+
function selectRandom(items, count, seed) {
|
|
977
|
+
if (items.length === 0) return { picked: [], rest: [] };
|
|
978
|
+
const k = Math.max(0, Math.min(count, items.length));
|
|
979
|
+
const rand = seed && seed.length > 0 ? mulberry32(hashSeed(seed)) : Math.random;
|
|
980
|
+
const indices = items.map((_, i) => i);
|
|
981
|
+
for (let i = 0; i < k; i++) {
|
|
982
|
+
const j = i + Math.floor(rand() * (indices.length - i));
|
|
983
|
+
[indices[i], indices[j]] = [indices[j], indices[i]];
|
|
984
|
+
}
|
|
985
|
+
return splitByIndices(items, indices.slice(0, k));
|
|
986
|
+
}
|
|
987
|
+
function selectByModulo(items, divisor) {
|
|
988
|
+
if (items.length === 0) return { picked: [], rest: [] };
|
|
989
|
+
const n = divisor ? Number.parseInt(divisor.trim(), 10) : NaN;
|
|
990
|
+
const safeN = Number.isFinite(n) ? n : 0;
|
|
991
|
+
const idx = (safeN % items.length + items.length) % items.length;
|
|
992
|
+
return splitByIndices(items, [idx]);
|
|
993
|
+
}
|
|
994
|
+
function selectByPredicate(items, config) {
|
|
995
|
+
if (items.length === 0) return { picked: [], rest: [] };
|
|
996
|
+
const op = config.predicateOp ?? "=";
|
|
997
|
+
const opts = { caseSensitive: config.predicateCaseSensitive ?? false };
|
|
998
|
+
const matchAll = config.predicateMatch === "all";
|
|
999
|
+
const cond = {
|
|
1000
|
+
field: config.predicateField ?? "",
|
|
1001
|
+
operator: op,
|
|
1002
|
+
value: config.predicateValue ?? "",
|
|
1003
|
+
valueType: "static"
|
|
1004
|
+
};
|
|
1005
|
+
const matchedIndices = [];
|
|
1006
|
+
for (let i = 0; i < items.length; i++) {
|
|
1007
|
+
const parsed = tryParseJson(items[i]);
|
|
1008
|
+
const hit = evaluateCondition(parsed, items[i], cond, void 0, opts);
|
|
1009
|
+
if (hit) {
|
|
1010
|
+
matchedIndices.push(i);
|
|
1011
|
+
if (!matchAll) break;
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
return splitByIndices(items, matchedIndices);
|
|
1015
|
+
}
|
|
1016
|
+
function selectByNamedKey(items, field, value) {
|
|
1017
|
+
return selectByPredicate(items, {
|
|
1018
|
+
predicateField: field,
|
|
1019
|
+
predicateOp: "=",
|
|
1020
|
+
predicateValue: value,
|
|
1021
|
+
predicateMatch: "first"
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
function resolveSelectorRefs(config, triggerData, variables) {
|
|
1025
|
+
const resolve = (v) => {
|
|
1026
|
+
if (v == null) return v;
|
|
1027
|
+
const refsResolved = resolveNodeRefs(v, variables);
|
|
1028
|
+
return substituteTriggerTokens(refsResolved, triggerData);
|
|
1029
|
+
};
|
|
1030
|
+
return {
|
|
1031
|
+
...config,
|
|
1032
|
+
moduloDivisor: resolve(config.moduloDivisor),
|
|
1033
|
+
predicateValue: resolve(config.predicateValue),
|
|
1034
|
+
namedKeyValue: resolve(config.namedKeyValue),
|
|
1035
|
+
seed: resolve(config.seed)
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
exports.EXECUTION_DATA_KEYS = EXECUTION_DATA_KEYS;
|
|
1040
|
+
exports.FRAME_TARGET_HANDLES = FRAME_TARGET_HANDLES;
|
|
1041
|
+
exports.NODE_REF_PATTERN = NODE_REF_PATTERN;
|
|
1042
|
+
exports.NODE_TYPE_EXECUTION_DATA_KEYS = NODE_TYPE_EXECUTION_DATA_KEYS;
|
|
1043
|
+
exports.REFERENCE_HANDLE_MAP = REFERENCE_HANDLE_MAP;
|
|
1044
|
+
exports.REF_HANDLE_CATEGORY = REF_HANDLE_CATEGORY;
|
|
1045
|
+
exports.REF_TOKEN_NAMESPACE_PREFIXES = REF_TOKEN_NAMESPACE_PREFIXES;
|
|
1046
|
+
exports.RESERVED_TEMPLATE_VARS = RESERVED_TEMPLATE_VARS;
|
|
1047
|
+
exports.TRANSIENT_RUNTIME_KEYS = TRANSIENT_RUNTIME_KEYS;
|
|
1048
|
+
exports.applyRange = applyRange;
|
|
1049
|
+
exports.applyRangeIndices = applyRangeIndices;
|
|
1050
|
+
exports.buildFeedMaps = buildFeedMaps;
|
|
1051
|
+
exports.buildRangeLabel = buildRangeLabel;
|
|
1052
|
+
exports.canonicalVarName = canonicalVarName;
|
|
1053
|
+
exports.classifyRefToken = classifyRefToken;
|
|
1054
|
+
exports.combineSameLabelRefs = combineSameLabelRefs;
|
|
1055
|
+
exports.countRefModalityEdges = countRefModalityEdges;
|
|
1056
|
+
exports.describeEdgeBehavior = describeEdgeBehavior;
|
|
1057
|
+
exports.evaluateCondition = evaluateCondition;
|
|
1058
|
+
exports.evaluateConditionGroup = evaluateConditionGroup;
|
|
1059
|
+
exports.evaluateJsonPath = evaluateJsonPath;
|
|
1060
|
+
exports.executionDataKeysOf = executionDataKeysOf;
|
|
1061
|
+
exports.extractReferencedLabels = extractReferencedLabels;
|
|
1062
|
+
exports.isDefaultSelectorConfig = isDefaultSelectorConfig;
|
|
1063
|
+
exports.isExecutionDataKey = isExecutionDataKey;
|
|
1064
|
+
exports.migrateEdgeOutputMode = migrateEdgeOutputMode;
|
|
1065
|
+
exports.nodeFeedsAnything = nodeFeedsAnything;
|
|
1066
|
+
exports.parseListExpression = parseListExpression;
|
|
1067
|
+
exports.parseNodeRef = parseNodeRef;
|
|
1068
|
+
exports.refHandleCategory = refHandleCategory;
|
|
1069
|
+
exports.referenceModalityForHandle = referenceModalityForHandle;
|
|
1070
|
+
exports.resolveConditionValue = resolveConditionValue;
|
|
1071
|
+
exports.resolveIndex = resolveIndex;
|
|
1072
|
+
exports.resolveListExpression = resolveListExpression;
|
|
1073
|
+
exports.resolveNodeRefs = resolveNodeRefs;
|
|
1074
|
+
exports.resolveRelativeWindowToken = resolveRelativeWindowToken;
|
|
1075
|
+
exports.resolveSelectorRefs = resolveSelectorRefs;
|
|
1076
|
+
exports.runSelector = runSelector;
|
|
1077
|
+
exports.selectByModulo = selectByModulo;
|
|
1078
|
+
exports.selectByNamedKey = selectByNamedKey;
|
|
1079
|
+
exports.selectByPredicate = selectByPredicate;
|
|
1080
|
+
exports.selectListItems = selectListItems;
|
|
1081
|
+
exports.selectRandom = selectRandom;
|
|
1082
|
+
exports.stringifyPathResults = stringifyPathResults;
|
|
1083
|
+
exports.stripTransientRuntimeData = stripTransientRuntimeData;
|
|
1084
|
+
exports.tryParseJson = tryParseJson;
|
|
1085
|
+
exports.unresolvedRefTokens = unresolvedRefTokens;
|
|
1086
|
+
//# sourceMappingURL=chunk-JSGIEF6Z.cjs.map
|
|
1087
|
+
//# sourceMappingURL=chunk-JSGIEF6Z.cjs.map
|