deepline 0.3.545 → 0.3.547
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/dist/bundling-sources/sdk/src/client-core.ts +13 -0
- package/dist/bundling-sources/sdk/src/errors.ts +1 -1
- package/dist/bundling-sources/sdk/src/http-core.ts +41 -12
- package/dist/bundling-sources/sdk/src/index.ts +7 -1
- package/dist/bundling-sources/sdk/src/integrations.ts +17 -7
- package/dist/bundling-sources/sdk/src/play.ts +71 -0
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +13 -4
- package/dist/bundling-sources/sdk/src/types.ts +33 -0
- package/dist/bundling-sources/shared_libs/integration-contracts/calendar-delegation.ts +7 -0
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-batch-operation.ts +2 -0
- package/dist/bundling-sources/shared_libs/monitors/tracking-provider-guidance.ts +1 -0
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +21 -3
- package/dist/bundling-sources/shared_libs/play-data-plane/contracts.ts +5 -0
- package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +17 -2
- package/dist/bundling-sources/shared_libs/play-data-plane/sheet-contract.ts +27 -0
- package/dist/bundling-sources/shared_libs/play-runtime/async-operation.ts +57 -5
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +299 -52
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +18 -1
- package/dist/bundling-sources/shared_libs/play-runtime/docflow-decision-tracker.ts +135 -0
- package/dist/bundling-sources/shared_libs/play-runtime/docflow-fail-open.ts +177 -0
- package/dist/bundling-sources/shared_libs/play-runtime/docflow-node-io.ts +99 -2
- package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +16 -10
- package/dist/bundling-sources/shared_libs/play-runtime/fenced-call-diagnostics.ts +211 -0
- package/dist/bundling-sources/shared_libs/play-runtime/fleet-sandbox-sweep.ts +40 -3
- package/dist/bundling-sources/shared_libs/play-runtime/modal-runtime-config.ts +19 -3
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +18 -4
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +441 -103
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox-egress.ts +322 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox.ts +200 -64
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-capacity-policy.ts +52 -14
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-speed-profile.ts +65 -2
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +5 -3
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +53 -2
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-lane.ts +206 -12
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +18 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +68 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +11 -3
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +30 -2
- package/dist/bundling-sources/shared_libs/play-runtime/tool-cache-policy.ts +9 -1
- package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +48 -0
- package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +36 -2
- package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +716 -51
- package/dist/bundling-sources/shared_libs/plays/docflow-decision-arms.ts +146 -0
- package/dist/bundling-sources/shared_libs/plays/docflow-flow-order.ts +94 -0
- package/dist/bundling-sources/shared_libs/plays/docflow-unreached-reason.ts +10 -1
- package/dist/bundling-sources/shared_libs/plays/docflow.ts +787 -117
- package/dist/bundling-sources/shared_libs/plays/share/static-pipeline-summary.ts +8 -2
- package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +41 -2
- package/dist/bundling-sources/shared_libs/plays/trigger-config-contract.ts +13 -0
- package/dist/bundling-sources/shared_libs/product-notifications/billing-sales.ts +25 -0
- package/dist/bundling-sources/shared_libs/security/email-blacklist.ts +35 -1
- package/dist/bundling-sources/shared_libs/security/email-domain.ts +19 -0
- package/dist/bundling-sources/shared_libs/security/secret-redaction.ts +58 -0
- package/dist/cli/auth-AC5277PI.js +43 -0
- package/dist/cli/{auth-VZAMAMFW.mjs → auth-WJEY4IDX.mjs} +6 -6
- package/dist/cli/{billing-ASZJDFH2.js → billing-IJITDDRQ.js} +99 -99
- package/dist/cli/{billing-DADQUQEZ.mjs → billing-PHJUDYF3.mjs} +11 -11
- package/dist/cli/{chunk-FB7UPZ6M.js → chunk-2AHY47SI.js} +3 -3
- package/dist/cli/{chunk-CJ7DBYEQ.js → chunk-2HPTLBNB.js} +8 -8
- package/dist/cli/{chunk-TI6DTURF.js → chunk-4WAM6TLD.js} +7 -1
- package/dist/cli/{chunk-LTCEZWPZ.mjs → chunk-56MEAGWA.mjs} +2 -2
- package/dist/cli/{chunk-YWTRCKGD.mjs → chunk-5SFHPMBY.mjs} +11 -11
- package/dist/cli/{chunk-D3SXB2NX.js → chunk-ABLTVG3J.js} +41 -41
- package/dist/cli/{chunk-KRW727W6.mjs → chunk-AEQ5VWZ5.mjs} +4 -4
- package/dist/cli/{chunk-Z7QM244Q.mjs → chunk-CKIRKYW7.mjs} +3 -3
- package/dist/cli/{chunk-2JHYYB3F.js → chunk-CSPHSNBW.js} +3 -3
- package/dist/cli/{chunk-OGQYAJSO.js → chunk-D6OIEH47.js} +5 -5
- package/dist/cli/{chunk-2HFSYH7V.mjs → chunk-DIUNDLSX.mjs} +2 -2
- package/dist/cli/{chunk-3M2QH3KA.mjs → chunk-DJI5CLLW.mjs} +22 -12
- package/dist/cli/{chunk-N4LADLCO.js → chunk-DZC7LMYM.js} +6 -6
- package/dist/cli/{chunk-CXETRZ3G.js → chunk-E2OIYPB4.js} +10 -10
- package/dist/cli/{chunk-Z4Y4BLW7.mjs → chunk-ECUD4QPD.mjs} +3 -3
- package/dist/cli/{chunk-2GJZLIKW.js → chunk-EITMD3A5.js} +1 -1
- package/dist/cli/{chunk-NAN3A4IF.mjs → chunk-ESCVHDNY.mjs} +5 -5
- package/dist/cli/{chunk-C6XYSTBW.js → chunk-FFBXLFKV.js} +1 -1
- package/dist/cli/{chunk-HLUNTJBO.mjs → chunk-FMQXAOVE.mjs} +4 -4
- package/dist/cli/{chunk-HXIR3VQL.mjs → chunk-FZHMNK6F.mjs} +7 -1
- package/dist/cli/{chunk-4NZ3OZNO.mjs → chunk-G6KW764N.mjs} +1 -1
- package/dist/cli/{chunk-LWPFMYSO.mjs → chunk-G6XTCG3J.mjs} +2 -2
- package/dist/cli/{chunk-NCX2JH2F.js → chunk-GIGAYLY6.js} +12 -12
- package/dist/cli/{chunk-BLYW6FFB.js → chunk-GJA2PRHJ.js} +2 -2
- package/dist/cli/{chunk-G5TV6WLV.js → chunk-GJOGFWX3.js} +20 -20
- package/dist/cli/{chunk-7MFATEUC.mjs → chunk-GPAWLXW3.mjs} +2 -2
- package/dist/cli/{chunk-DZTVDL2X.js → chunk-GZFZZQL4.js} +289 -268
- package/dist/cli/{chunk-XBYQZEUE.mjs → chunk-HARZ4AAX.mjs} +1 -1
- package/dist/cli/{chunk-QI57XUGA.js → chunk-HFIFKP3A.js} +5 -5
- package/dist/cli/{chunk-WP36UBRY.mjs → chunk-IGAK22XO.mjs} +1 -1
- package/dist/cli/{chunk-XMUPZINS.mjs → chunk-IKYN6PLO.mjs} +5 -5
- package/dist/cli/{chunk-HPX7LLAM.mjs → chunk-ITLZBDSR.mjs} +3 -3
- package/dist/cli/{chunk-QM7PHHYZ.js → chunk-IVFFCAV2.js} +44 -44
- package/dist/cli/{chunk-IYJO3RWR.js → chunk-K3GMDSUX.js} +5 -5
- package/dist/cli/{chunk-EK5C2R7S.js → chunk-L5J6UJ2X.js} +15 -15
- package/dist/cli/{chunk-EWA3M54M.mjs → chunk-L6QE2XVM.mjs} +1 -1
- package/dist/cli/{chunk-3NG43NXB.js → chunk-LMLSOHTU.js} +53 -53
- package/dist/cli/{chunk-7MHBJU73.js → chunk-MBQELFL7.js} +22 -22
- package/dist/cli/{chunk-Z7SXGOIQ.mjs → chunk-MF7PCM6C.mjs} +1 -1
- package/dist/cli/{chunk-DGKDCZGC.js → chunk-MO7TGNXB.js} +13 -13
- package/dist/cli/{chunk-7P72EGLK.mjs → chunk-MOZEAGSR.mjs} +1 -1
- package/dist/cli/{chunk-34UKDHRL.js → chunk-N63U5CRG.js} +26 -26
- package/dist/cli/{chunk-5YYWZ43J.js → chunk-NBYFQZ6O.js} +2 -2
- package/dist/cli/{chunk-CQBIO6HW.mjs → chunk-NURW5XH4.mjs} +1 -1
- package/dist/cli/{chunk-TQKHXMV3.js → chunk-OVYXYTEP.js} +16 -16
- package/dist/cli/{chunk-XGEUPU3L.mjs → chunk-PBMO36BP.mjs} +2 -2
- package/dist/cli/{chunk-4JQEAYN3.js → chunk-PVQCX6KQ.js} +55 -8
- package/dist/cli/{chunk-KYO2FICL.mjs → chunk-QLE3QKJ2.mjs} +5 -5
- package/dist/cli/{chunk-2FF3O2Y2.js → chunk-QU3K3IY6.js} +12 -12
- package/dist/cli/{chunk-HR5BT42R.js → chunk-REAFIEV5.js} +99 -99
- package/dist/cli/{chunk-Y3T5GWYK.mjs → chunk-RMCCB3XY.mjs} +55 -8
- package/dist/cli/{chunk-3TCHX7YK.mjs → chunk-RXRC2COC.mjs} +2 -2
- package/dist/cli/{chunk-YRQKRQDU.js → chunk-SAJWYN4B.js} +36 -26
- package/dist/cli/{chunk-JL5JU3LD.mjs → chunk-TNJG4ZPN.mjs} +3 -3
- package/dist/cli/{chunk-NZDZGK35.js → chunk-VNOQEDVC.js} +7 -7
- package/dist/cli/{chunk-2CBX43LP.mjs → chunk-VPF54TXQ.mjs} +5 -5
- package/dist/cli/{chunk-2HSZCQMT.mjs → chunk-WYT3H6JD.mjs} +1 -1
- package/dist/cli/{chunk-GWDPNOA7.mjs → chunk-XMBVHJPR.mjs} +29 -8
- package/dist/cli/{chunk-52C6W7FG.mjs → chunk-XNTDTAKC.mjs} +1 -1
- package/dist/cli/{chunk-ERLW6RPA.js → chunk-YURGAKI3.js} +2 -2
- package/dist/cli/{chunk-GFRJU2KB.js → chunk-YVKLF7RW.js} +2 -2
- package/dist/cli/{chunk-7JZ27AFH.mjs → chunk-Z2YGQZWV.mjs} +2 -2
- package/dist/cli/command-docs.js +2 -2
- package/dist/cli/command-docs.mjs +1 -1
- package/dist/cli/{concurrent-runs-help-YP7ALTDB.mjs → concurrent-runs-help-ZNGP563R.mjs} +7 -7
- package/dist/cli/concurrent-runs-help-ZYISYOQA.js +21 -0
- package/dist/cli/{csv-D5ITFSYI.mjs → csv-VAHQHYYV.mjs} +5 -5
- package/dist/cli/{csv-67WT5EGR.js → csv-X6D4ZELE.js} +14 -14
- package/dist/cli/{db-SZYBRFYG.mjs → db-4G4S2VOV.mjs} +8 -8
- package/dist/cli/{db-GZS76X7R.js → db-YA5ZGVEX.js} +33 -33
- package/dist/cli/{describe-YJ7ZLLLI.mjs → describe-EVXEM2S6.mjs} +20 -20
- package/dist/cli/describe-GYYSLZLV.js +50 -0
- package/dist/cli/describe-core.d.mts +4 -4
- package/dist/cli/describe-core.d.ts +4 -4
- package/dist/cli/describe-core.js +1 -1
- package/dist/cli/describe-core.mjs +1 -1
- package/dist/cli/{executions-O5USTYGL.js → executions-5YC7ABF6.js} +10 -10
- package/dist/cli/{executions-HMYGR32E.mjs → executions-HR6CTN5M.mjs} +8 -8
- package/dist/cli/{feedback-Z3NXWYUO.mjs → feedback-GEU5SPLR.mjs} +7 -7
- package/dist/cli/{feedback-RHLFDCRS.js → feedback-MJHSYLFF.js} +15 -15
- package/dist/cli/git-FZIQZNI4.js +25 -0
- package/dist/cli/{git-CLFKXELB.mjs → git-NPFF6QUS.mjs} +6 -6
- package/dist/cli/index.js +150 -150
- package/dist/cli/index.mjs +46 -46
- package/dist/cli/{integrations-TZ4QEQGV.js → integrations-YPHFI77G.js} +20 -18
- package/dist/cli/{integrations-FOACOBQB.mjs → integrations-Z7EGVBHF.mjs} +12 -10
- package/dist/cli/{legacy-noops-QRDOS33V.js → legacy-noops-246E3KKG.js} +10 -10
- package/dist/cli/{legacy-noops-6F6Y3BV7.mjs → legacy-noops-5IYCFWWX.mjs} +7 -7
- package/dist/cli/{mcp-UXRCWOZU.mjs → mcp-WUYGZXPI.mjs} +5 -5
- package/dist/cli/{mcp-ETMMDDGB.js → mcp-YTYTW67G.js} +25 -25
- package/dist/cli/{monitors-6XEWR46R.mjs → monitors-73DQKCU7.mjs} +27 -9
- package/dist/cli/{monitors-DITT7QTV.js → monitors-SA6ILD6Z.js} +121 -103
- package/dist/cli/{org-CVSSH73G.mjs → org-WVQRB2KX.mjs} +8 -8
- package/dist/cli/{org-4DE37X3L.js → org-X7ELDV7B.js} +90 -90
- package/dist/cli/{play-Y5NCHOKK.mjs → play-QI6V2EUQ.mjs} +296 -68
- package/dist/cli/{play-RH6P45CI.js → play-QTYOAJPE.js} +898 -670
- package/dist/cli/{providers-VHUHC4IZ.mjs → providers-DPVMVDS4.mjs} +8 -8
- package/dist/cli/{providers-DU42DLOL.js → providers-XXFLVREV.js} +11 -11
- package/dist/cli/{quickstart-XJ43JLEC.js → quickstart-33ISXQJU.js} +7 -7
- package/dist/cli/{quickstart-HJY5YYE5.mjs → quickstart-YWGNHULM.mjs} +5 -5
- package/dist/cli/{run-JXUS7QFI.js → run-BWHZXLTD.js} +46 -46
- package/dist/cli/{run-JAIXHVH7.mjs → run-J6FCAKQC.mjs} +26 -26
- package/dist/cli/search-JCWJX2XD.js +32 -0
- package/dist/cli/{search-RDMNM2AX.mjs → search-Z3UU3WBB.mjs} +9 -9
- package/dist/cli/{search-output-ZKTR3WTJ.mjs → search-output-OJYY4J7E.mjs} +5 -5
- package/dist/cli/{search-output-RKAM2HBH.js → search-output-YIPV74ME.js} +7 -7
- package/dist/cli/{secrets-TKFVMAYX.js → secrets-UXRJCEN4.js} +17 -17
- package/dist/cli/{secrets-WSW3FTF6.mjs → secrets-YZZN2WST.mjs} +8 -8
- package/dist/cli/{sessions-724BK6VP.mjs → sessions-ITCGPD7Z.mjs} +7 -7
- package/dist/cli/sessions-NA4SJH6Q.js +22 -0
- package/dist/cli/{settings-5LJZDAZU.js → settings-LAFYMILP.js} +87 -87
- package/dist/cli/{settings-YRC7J75G.mjs → settings-ZP2LSVNM.mjs} +14 -14
- package/dist/cli/{setup-2F3DBSOS.js → setup-4AL3XYM5.js} +50 -50
- package/dist/cli/{setup-STNPX5MK.mjs → setup-WEQAQSYC.mjs} +10 -10
- package/dist/cli/{skills-D5PK56FO.mjs → skills-NQH4HFW2.mjs} +8 -8
- package/dist/cli/skills-XZ4Y6SZ7.js +36 -0
- package/dist/cli/{tools-WOGWMBA3.mjs → tools-CXK2GSI4.mjs} +19 -19
- package/dist/cli/tools-WJQ6Y7E4.js +57 -0
- package/dist/cli/{update-PC6XSWMI.mjs → update-3ROF3Z75.mjs} +10 -10
- package/dist/cli/update-ZLRLTBRD.js +34 -0
- package/dist/cli/{views-IIHT4RYQ.mjs → views-AOUHVGV2.mjs} +8 -8
- package/dist/cli/{views-HLCLAPWN.js → views-XJFO5CEH.js} +23 -23
- package/dist/cli/{workflow-CCZ2A7DI.js → workflow-GY3DBHXX.js} +19 -19
- package/dist/cli/{workflow-HK4MZ7LK.mjs → workflow-KBS2QJK6.mjs} +9 -9
- package/dist/{client-DfdUc_MY.d.mts → client-D1uWA2Vc.d.mts} +1 -1
- package/dist/{client-BQ6yuSjM.d.ts → client-Hz7SsBXs.d.ts} +1 -1
- package/dist/{client-core-3GQ8WMuk.d.ts → client-core-D3Ad7Flt.d.ts} +554 -504
- package/dist/{client-core-ClsNRytk.d.mts → client-core-Db_e63Hb.d.mts} +554 -504
- package/dist/{compiler-manifest-BWFtsQIC.d.mts → compiler-manifest-BqwVrOri.d.mts} +73 -18
- package/dist/{compiler-manifest-BWFtsQIC.d.ts → compiler-manifest-BqwVrOri.d.ts} +73 -18
- package/dist/{errors-Lm9_vJHZ.d.ts → errors-BU8FB99X.d.mts} +2 -2
- package/dist/{errors-CwKXXtuu.d.mts → errors-DfVN_FUG.d.ts} +2 -2
- package/dist/{index-3vJ-V9yw.d.ts → index-BGnvtYGc.d.ts} +6 -1
- package/dist/{index-DjwsAt82.d.mts → index-DjZgwpGw.d.mts} +6 -1
- package/dist/index.d.mts +28 -8
- package/dist/index.d.ts +28 -8
- package/dist/index.js +65 -40
- package/dist/index.mjs +33 -8
- package/dist/install-integrity.json +137 -130
- package/dist/plays/bundle-play-file.d.mts +3 -3
- package/dist/plays/bundle-play-file.d.ts +3 -3
- package/dist/plays/bundle-play-file.mjs +640 -125
- package/dist/plays/play-description.d.mts +3 -3
- package/dist/plays/play-description.d.ts +3 -3
- package/dist/plays/run-request.d.mts +2 -2
- package/dist/plays/run-request.d.ts +2 -2
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +2 -2
- package/dist/release.mjs +1 -1
- package/dist/server.d.mts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +11 -11
- package/dist/server.mjs +5 -5
- package/package.json +1 -1
- package/dist/cli/auth-455MB4K6.js +0 -43
- package/dist/cli/concurrent-runs-help-GFWXOKF5.js +0 -21
- package/dist/cli/describe-ZRGYAEBT.js +0 -50
- package/dist/cli/git-RC4XDATD.js +0 -25
- package/dist/cli/search-O5VVMXII.js +0 -32
- package/dist/cli/sessions-3PWFWCHO.js +0 -22
- package/dist/cli/skills-RFOMVXIT.js +0 -36
- package/dist/cli/tools-CAO6EVUW.js +0 -57
- package/dist/cli/update-L4DQZY3G.js +0 -34
|
@@ -16,10 +16,10 @@ import {
|
|
|
16
16
|
playRuntimeNames,
|
|
17
17
|
validateScriptPlay,
|
|
18
18
|
wrapScriptPlay
|
|
19
|
-
} from "../cli/chunk-
|
|
19
|
+
} from "../cli/chunk-WYT3H6JD.mjs";
|
|
20
20
|
import {
|
|
21
21
|
resolveExecutionProfile
|
|
22
|
-
} from "../cli/chunk-
|
|
22
|
+
} from "../cli/chunk-MF7PCM6C.mjs";
|
|
23
23
|
import {
|
|
24
24
|
validatePlaySourceFilesHaveNoInlineSecrets
|
|
25
25
|
} from "../cli/chunk-H7HIDGZ7.mjs";
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
UnsupportedToolResponseContractError,
|
|
35
35
|
normalizeToolResponseContract,
|
|
36
36
|
normalizeToolResponseReceiptRevision
|
|
37
|
-
} from "../cli/chunk-
|
|
37
|
+
} from "../cli/chunk-FZHMNK6F.mjs";
|
|
38
38
|
import {
|
|
39
39
|
PLAY_SANDBOX_SIZE_INPUTS,
|
|
40
40
|
SUPPORTED_PLAY_SANDBOX_SIZES
|
|
@@ -1193,6 +1193,25 @@ var PLAY_AUTHORING_FIELD_REGISTRY = {
|
|
|
1193
1193
|
description: "Computed columns deliberately left out of the authored @mermaid diagram.",
|
|
1194
1194
|
errorMessage: "ctx.dataset run undrawnColumns must be a non-empty array of static column-name strings."
|
|
1195
1195
|
},
|
|
1196
|
+
"ctx.dataset.run.columnOrder": {
|
|
1197
|
+
schema: Type.Array(Type.String({ minLength: 1 }), {
|
|
1198
|
+
minItems: 1,
|
|
1199
|
+
uniqueItems: true
|
|
1200
|
+
}),
|
|
1201
|
+
fixtures: {
|
|
1202
|
+
valid: ["full_name", "email"],
|
|
1203
|
+
invalid: [],
|
|
1204
|
+
absent: void 0,
|
|
1205
|
+
unresolved: { expression: "columnOrder" },
|
|
1206
|
+
edition1: ["email"]
|
|
1207
|
+
},
|
|
1208
|
+
referenceType: "readonly string[]",
|
|
1209
|
+
required: false,
|
|
1210
|
+
resolution: "static-when-present",
|
|
1211
|
+
issueCode: "play_authoring_dataset_option_invalid",
|
|
1212
|
+
description: "Columns the run page shows first, in this order; the rest keep their written order.",
|
|
1213
|
+
errorMessage: "ctx.dataset run columnOrder must be a non-empty array of distinct static column-name strings."
|
|
1214
|
+
},
|
|
1196
1215
|
"ctx.step.id": {
|
|
1197
1216
|
schema: Type.String({ minLength: 1 }),
|
|
1198
1217
|
fixtures: {
|
|
@@ -1889,7 +1908,7 @@ var PLAY_AUTHORING_CLOUD_TYPE_DECLARATIONS = [
|
|
|
1889
1908
|
"export type StepProgramOutput<TProgram> = TProgram extends StepProgram<unknown, infer Output, unknown> ? Output : never;",
|
|
1890
1909
|
"export type DatasetRowKey<InputRow extends object> = (keyof InputRow & string) | readonly (keyof InputRow & string)[] | ((row: InputRow, index: number) => string | number | readonly unknown[]);",
|
|
1891
1910
|
"export type DatasetDefinitionOptions<InputRow extends object> = { key?: DatasetRowKey<InputRow> };",
|
|
1892
|
-
`export type DatasetRunOptions<InputRow extends object> = { description?: ${cloudReferenceType("ctx.dataset.run.description")}; key?: DatasetRowKey<InputRow>; rowIdentity?: ${cloudReferenceType("ctx.dataset.run.rowIdentity")}; onRowError?: ${cloudReferenceType("ctx.dataset.run.onRowError")}; mode?: ${cloudReferenceType("ctx.dataset.run.mode")}; undrawnColumns?: ${cloudReferenceType("ctx.dataset.run.undrawnColumns")} };`,
|
|
1911
|
+
`export type DatasetRunOptions<InputRow extends object> = { description?: ${cloudReferenceType("ctx.dataset.run.description")}; key?: DatasetRowKey<InputRow>; rowIdentity?: ${cloudReferenceType("ctx.dataset.run.rowIdentity")}; onRowError?: ${cloudReferenceType("ctx.dataset.run.onRowError")}; mode?: ${cloudReferenceType("ctx.dataset.run.mode")}; undrawnColumns?: ${cloudReferenceType("ctx.dataset.run.undrawnColumns")}; columnOrder?: ${cloudReferenceType("ctx.dataset.run.columnOrder")} };`,
|
|
1893
1912
|
"export type DatasetBuilder<InputRow extends object, OutputRow extends object> = {",
|
|
1894
1913
|
" withColumn<Name extends string, Value>(name: Name, resolver: ColumnResolver<OutputRow, Value>): DatasetBuilder<InputRow, OutputRow & Record<Name, Value>>;",
|
|
1895
1914
|
" withColumn<Name extends string, Value>(name: Name, definition: DatasetColumnDefinition<OutputRow, Value> & { readonly runIf: (row: OutputRow, index: number) => boolean | Promise<boolean> }): DatasetBuilder<InputRow, OutputRow & Record<Name, Value | null>>;",
|
|
@@ -2016,7 +2035,14 @@ var FLOW_START = /^\s*(?:flowchart|graph)\s+(LR|RL|TB|TD|BT)\s*$/i;
|
|
|
2016
2035
|
var MERMAID_NODE = /^\s*\/\/\s*@mermaid-node\s+([A-Za-z][\w-]*)(?:\s+(.*))?$/;
|
|
2017
2036
|
var MERMAID_NODE_HINT = /@mermaid-node/;
|
|
2018
2037
|
var ATTRIBUTE = /([A-Za-z][\w-]*)\s*:\s*"([^"\n]*)"/y;
|
|
2019
|
-
var MERMAID_NODE_ATTRIBUTES = [
|
|
2038
|
+
var MERMAID_NODE_ATTRIBUTES = [
|
|
2039
|
+
"label",
|
|
2040
|
+
"type",
|
|
2041
|
+
"in",
|
|
2042
|
+
"out",
|
|
2043
|
+
"arm",
|
|
2044
|
+
"show"
|
|
2045
|
+
];
|
|
2020
2046
|
var MERMAID_NODE_ID = /^[A-Za-z][\w-]*/;
|
|
2021
2047
|
var SKETCH_CLASS = /^\s*class\s+([A-Za-z][\w-]*(?:\s*,\s*[A-Za-z][\w-]*)*)\s+sketch\s*;?\s*$/;
|
|
2022
2048
|
var MERMAID_NODE_SHAPES = [
|
|
@@ -2260,15 +2286,47 @@ function splitBlockExportHeader(body) {
|
|
|
2260
2286
|
function blockLabel(block) {
|
|
2261
2287
|
return block.authoredExportName ? `@mermaid ${block.authoredExportName}` : "@mermaid";
|
|
2262
2288
|
}
|
|
2263
|
-
function
|
|
2289
|
+
function docflowBlockLineLocator(sourceCode, blockStart, blockText) {
|
|
2290
|
+
const firstLine = sourceCode.slice(0, blockStart).split(/\r?\n/).length;
|
|
2291
|
+
const rawLines = blockText.split(/\r?\n/).map(
|
|
2292
|
+
(line) => line.replace(/^\s*\/\*\*/, "").replace(/\*\/\s*$/, "").replace(/^\s*\* ?/, "").trim()
|
|
2293
|
+
);
|
|
2294
|
+
let cursor = 0;
|
|
2295
|
+
return (diagramLine) => {
|
|
2296
|
+
const wanted = diagramLine.trim();
|
|
2297
|
+
if (!wanted) return null;
|
|
2298
|
+
for (let index = cursor; index < rawLines.length; index += 1) {
|
|
2299
|
+
const raw = rawLines[index].replace(/^@mermaid\b\s*/, "");
|
|
2300
|
+
if (raw === wanted || raw.endsWith(` ${wanted}`)) {
|
|
2301
|
+
cursor = index + 1;
|
|
2302
|
+
return firstLine + index;
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
2305
|
+
return null;
|
|
2306
|
+
};
|
|
2307
|
+
}
|
|
2308
|
+
function locateDocflowErrors(errors, from, line) {
|
|
2309
|
+
if (line === null) return;
|
|
2310
|
+
for (let index = from; index < errors.length; index += 1) {
|
|
2311
|
+
errors[index] = `${errors[index]} (line ${line})`;
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
function parseDocflowBlockGraph(mermaidSource, errors, locate = () => null) {
|
|
2264
2315
|
const docLines = mermaidSource.split(/\r?\n/).filter((line) => line.trim() && !line.trim().startsWith("%%"));
|
|
2265
2316
|
const direction = FLOW_START.exec(docLines[0] ?? "")?.[1]?.toUpperCase();
|
|
2266
2317
|
if (!direction) {
|
|
2318
|
+
const firstErrorAt = errors.length;
|
|
2267
2319
|
errors.push(
|
|
2268
|
-
"Docflow must start with `flowchart` or `graph` and direction `LR`, `RL`, `TB`, `TD`, or `BT`."
|
|
2320
|
+
docLines[0] ? `Docflow must start with \`flowchart\` or \`graph\` and direction \`LR\`, \`RL\`, \`TB\`, \`TD\`, or \`BT\`; found: ${docLines[0].trim()}` : "Docflow must start with `flowchart` or `graph` and direction `LR`, `RL`, `TB`, `TD`, or `BT`."
|
|
2321
|
+
);
|
|
2322
|
+
locateDocflowErrors(
|
|
2323
|
+
errors,
|
|
2324
|
+
firstErrorAt,
|
|
2325
|
+
docLines[0] ? locate(docLines[0]) : null
|
|
2269
2326
|
);
|
|
2270
2327
|
return null;
|
|
2271
2328
|
}
|
|
2329
|
+
locate(docLines[0]);
|
|
2272
2330
|
const nodes = /* @__PURE__ */ new Map();
|
|
2273
2331
|
const edges = [];
|
|
2274
2332
|
const subgraphs = /* @__PURE__ */ new Map();
|
|
@@ -2324,83 +2382,97 @@ function parseDocflowBlockGraph(mermaidSource, errors) {
|
|
|
2324
2382
|
}
|
|
2325
2383
|
return sawDeclaration;
|
|
2326
2384
|
};
|
|
2385
|
+
const openedAt = /* @__PURE__ */ new Map();
|
|
2327
2386
|
for (const line of docLines.slice(1)) {
|
|
2328
|
-
const
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
const
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
"Docflow has an `end` with no open `subgraph` above it. Every `end` closes exactly one `subgraph`."
|
|
2348
|
-
);
|
|
2387
|
+
const lineErrorsFrom = errors.length;
|
|
2388
|
+
const fileLine = locate(line);
|
|
2389
|
+
try {
|
|
2390
|
+
const opened = SUBGRAPH_OPEN.exec(line);
|
|
2391
|
+
if (opened) {
|
|
2392
|
+
const id = opened[1];
|
|
2393
|
+
const rawLabel = opened[2]?.trim() ?? "";
|
|
2394
|
+
const label = rawLabel.length >= 2 && (rawLabel.startsWith('"') && rawLabel.endsWith('"') || rawLabel.startsWith("'") && rawLabel.endsWith("'")) ? rawLabel.slice(1, -1) : rawLabel;
|
|
2395
|
+
const parent = subgraphStack[subgraphStack.length - 1];
|
|
2396
|
+
const subgraph = {
|
|
2397
|
+
id,
|
|
2398
|
+
label: label || id,
|
|
2399
|
+
memberIds: [],
|
|
2400
|
+
...parent ? { parentId: parent.id } : {}
|
|
2401
|
+
};
|
|
2402
|
+
subgraphs.set(id, subgraph);
|
|
2403
|
+
subgraphStack.push(subgraph);
|
|
2404
|
+
openedAt.set(subgraph, fileLine);
|
|
2405
|
+
continue;
|
|
2349
2406
|
}
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
if (isDirective) {
|
|
2356
|
-
const sketch = SKETCH_CLASS.exec(line);
|
|
2357
|
-
if (sketch) {
|
|
2358
|
-
for (const id of sketch[1].split(",")) {
|
|
2359
|
-
const trimmed = id.trim();
|
|
2360
|
-
if (trimmed) sketchIds.add(trimmed);
|
|
2407
|
+
if (SUBGRAPH_END.test(line)) {
|
|
2408
|
+
if (subgraphStack.length === 0) {
|
|
2409
|
+
errors.push(
|
|
2410
|
+
"Docflow has an `end` with no open `subgraph` above it. Every `end` closes exactly one `subgraph`."
|
|
2411
|
+
);
|
|
2361
2412
|
}
|
|
2362
|
-
|
|
2363
|
-
|
|
2413
|
+
subgraphStack.pop();
|
|
2414
|
+
continue;
|
|
2364
2415
|
}
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2416
|
+
let declaredOnThisLine = false;
|
|
2417
|
+
const isDirective = /^\s*(?:direction|classDef|class|style|linkStyle|click)\b/i.test(line);
|
|
2418
|
+
if (isDirective) {
|
|
2419
|
+
const sketch = SKETCH_CLASS.exec(line);
|
|
2420
|
+
if (sketch) {
|
|
2421
|
+
for (const id of sketch[1].split(",")) {
|
|
2422
|
+
const trimmed = id.trim();
|
|
2423
|
+
if (trimmed) sketchIds.add(trimmed);
|
|
2424
|
+
}
|
|
2425
|
+
} else {
|
|
2426
|
+
ignoredDirectives.push(line.trim());
|
|
2427
|
+
}
|
|
2375
2428
|
}
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
addNodes(line, line);
|
|
2379
|
-
for (const node of chain.nodes) {
|
|
2380
|
-
if (subgraphIds.has(node.id)) continue;
|
|
2381
|
-
const existing = nodes.get(node.id);
|
|
2382
|
-
if (!existing) {
|
|
2383
|
-
nodes.set(node.id, node);
|
|
2384
|
-
subgraphStack[subgraphStack.length - 1]?.memberIds.push(node.id);
|
|
2385
|
-
} else if (existing.label === existing.id && node.label !== node.id) {
|
|
2386
|
-
existing.label = node.label;
|
|
2387
|
-
existing.kind = node.kind;
|
|
2429
|
+
if (!isDirective) {
|
|
2430
|
+
declaredOnThisLine = addNodes(line, line);
|
|
2388
2431
|
}
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2432
|
+
const chain = parseEdgeChain(line);
|
|
2433
|
+
if (!chain) {
|
|
2434
|
+
if (!isDirective && !declaredOnThisLine) {
|
|
2435
|
+
errors.push(
|
|
2436
|
+
`Docflow line is not an edge, a node declaration, or a directive this parser understands: ${line.trim()}`
|
|
2437
|
+
);
|
|
2438
|
+
}
|
|
2439
|
+
continue;
|
|
2440
|
+
}
|
|
2441
|
+
addNodes(line, line);
|
|
2442
|
+
for (const node of chain.nodes) {
|
|
2443
|
+
if (subgraphIds.has(node.id)) continue;
|
|
2444
|
+
const existing = nodes.get(node.id);
|
|
2445
|
+
if (!existing) {
|
|
2446
|
+
nodes.set(node.id, node);
|
|
2447
|
+
subgraphStack[subgraphStack.length - 1]?.memberIds.push(node.id);
|
|
2448
|
+
} else if (existing.label === existing.id && node.label !== node.id) {
|
|
2449
|
+
existing.label = node.label;
|
|
2450
|
+
existing.kind = node.kind;
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
for (let index = 0; index < chain.nodes.length - 1; index += 1) {
|
|
2454
|
+
edges.push({
|
|
2455
|
+
from: chain.nodes[index].id,
|
|
2456
|
+
to: chain.nodes[index + 1].id,
|
|
2457
|
+
...chain.labels[index] ? { label: chain.labels[index] } : {}
|
|
2458
|
+
});
|
|
2459
|
+
}
|
|
2460
|
+
} finally {
|
|
2461
|
+
locateDocflowErrors(errors, lineErrorsFrom, fileLine);
|
|
2396
2462
|
}
|
|
2397
2463
|
}
|
|
2398
2464
|
if (subgraphStack.length > 0) {
|
|
2465
|
+
const unclosedFrom = errors.length;
|
|
2399
2466
|
errors.push(
|
|
2400
2467
|
`Docflow subgraph${subgraphStack.length === 1 ? "" : "s"} ${subgraphStack.map((subgraph) => `"${subgraph.id}"`).join(
|
|
2401
2468
|
", "
|
|
2402
2469
|
)} ${subgraphStack.length === 1 ? "is" : "are"} never closed with \`end\`. Everything below an unclosed subgraph is silently drawn inside it.`
|
|
2403
2470
|
);
|
|
2471
|
+
locateDocflowErrors(
|
|
2472
|
+
errors,
|
|
2473
|
+
unclosedFrom,
|
|
2474
|
+
openedAt.get(subgraphStack[0]) ?? null
|
|
2475
|
+
);
|
|
2404
2476
|
}
|
|
2405
2477
|
for (const node of nodes.values()) {
|
|
2406
2478
|
if (declaredIds.has(node.id) || subgraphIds.has(node.id)) continue;
|
|
@@ -2429,9 +2501,29 @@ function materializeDocflow(block) {
|
|
|
2429
2501
|
syntax: block.syntax,
|
|
2430
2502
|
mermaidSource: block.mermaidSource,
|
|
2431
2503
|
...block.subgraphs.size ? { subgraphs: [...block.subgraphs.values()] } : {},
|
|
2432
|
-
...block.ignoredDirectives.length ? { ignoredDirectives: block.ignoredDirectives } : {}
|
|
2504
|
+
...block.ignoredDirectives.length ? { ignoredDirectives: block.ignoredDirectives } : {},
|
|
2505
|
+
...block.inputShow?.length ? { inputShow: block.inputShow } : {}
|
|
2433
2506
|
};
|
|
2434
2507
|
}
|
|
2508
|
+
var MERMAID_INPUT_SHOW = /^\s*%%\s*@input\b(.*)$/;
|
|
2509
|
+
function parseBlockInputShow(diagram, errors) {
|
|
2510
|
+
const declarations = diagram.split(/\r?\n/).map((line) => MERMAID_INPUT_SHOW.exec(line)?.[1]).filter((rest) => rest !== void 0);
|
|
2511
|
+
if (declarations.length === 0) return void 0;
|
|
2512
|
+
if (declarations.length > 1) {
|
|
2513
|
+
errors.push(
|
|
2514
|
+
"Docflow `%% @input` appears more than once in one diagram. Declare the input's fields once."
|
|
2515
|
+
);
|
|
2516
|
+
return void 0;
|
|
2517
|
+
}
|
|
2518
|
+
const match = /^\s+show:"([^"]*)"\s*$/.exec(declarations[0]);
|
|
2519
|
+
if (!match) {
|
|
2520
|
+
errors.push(
|
|
2521
|
+
'Docflow `%% @input` takes one attribute: show:"field,nested.field", the run input fields a reader sees first.'
|
|
2522
|
+
);
|
|
2523
|
+
return void 0;
|
|
2524
|
+
}
|
|
2525
|
+
return parseContractPaths(match[1], "show", "@input", 0, errors);
|
|
2526
|
+
}
|
|
2435
2527
|
function parsePlayDocflowFile(sourceCode, moduleSources) {
|
|
2436
2528
|
const errors = [];
|
|
2437
2529
|
const rawBlocks = [];
|
|
@@ -2440,9 +2532,14 @@ function parsePlayDocflowFile(sourceCode, moduleSources) {
|
|
|
2440
2532
|
const cleanedBody = cleanBlockBody(match[1]);
|
|
2441
2533
|
const mermaid = /^@mermaid(?:[ \t]+|\r?\n|$)([\s\S]*)$/.exec(cleanedBody);
|
|
2442
2534
|
if (!mermaid) continue;
|
|
2443
|
-
rawBlocks.push({
|
|
2535
|
+
rawBlocks.push({
|
|
2536
|
+
syntax: "mermaid",
|
|
2537
|
+
body: mermaid[1].trim(),
|
|
2538
|
+
locate: docflowBlockLineLocator(sourceCode, match.index, match[0])
|
|
2539
|
+
});
|
|
2444
2540
|
}
|
|
2445
|
-
if (rawBlocks.length === 0)
|
|
2541
|
+
if (rawBlocks.length === 0)
|
|
2542
|
+
return { blocks: [], bindings: [], errors, unreadBlocks: [] };
|
|
2446
2543
|
const rejectedNodeIds = /* @__PURE__ */ new Set();
|
|
2447
2544
|
const annotationSources = [{ sourceCode }];
|
|
2448
2545
|
for (const [sourcePath, moduleCode] of moduleSources ?? []) {
|
|
@@ -2455,12 +2552,22 @@ function parsePlayDocflowFile(sourceCode, moduleSources) {
|
|
|
2455
2552
|
rejectedNodeIds
|
|
2456
2553
|
);
|
|
2457
2554
|
const parsedBlocks = [];
|
|
2555
|
+
const unreadBlocks = [];
|
|
2458
2556
|
for (const raw of rawBlocks) {
|
|
2459
2557
|
const { exportName, diagram } = splitBlockExportHeader(raw.body);
|
|
2460
|
-
const
|
|
2461
|
-
|
|
2558
|
+
const blockErrorsFrom = errors.length;
|
|
2559
|
+
const graph = parseDocflowBlockGraph(diagram, errors, raw.locate);
|
|
2560
|
+
const inputShow = graph ? parseBlockInputShow(diagram, errors) : void 0;
|
|
2561
|
+
if (!graph || errors.length > blockErrorsFrom) {
|
|
2562
|
+
unreadBlocks.push({
|
|
2563
|
+
authoredExportName: exportName,
|
|
2564
|
+
reason: errors[blockErrorsFrom] ?? "the diagram did not parse"
|
|
2565
|
+
});
|
|
2566
|
+
continue;
|
|
2567
|
+
}
|
|
2462
2568
|
parsedBlocks.push({
|
|
2463
2569
|
...graph,
|
|
2570
|
+
...inputShow?.length ? { inputShow } : {},
|
|
2464
2571
|
authoredExportName: exportName,
|
|
2465
2572
|
exportName: null,
|
|
2466
2573
|
syntax: raw.syntax,
|
|
@@ -2474,7 +2581,8 @@ function parsePlayDocflowFile(sourceCode, moduleSources) {
|
|
|
2474
2581
|
parsedBlocks,
|
|
2475
2582
|
bindings,
|
|
2476
2583
|
errors,
|
|
2477
|
-
rejectedNodeIds
|
|
2584
|
+
rejectedNodeIds,
|
|
2585
|
+
unreadBlocks.length > 0
|
|
2478
2586
|
);
|
|
2479
2587
|
return {
|
|
2480
2588
|
blocks: parsedBlocks.filter((block) => block.exportName !== null).map((block) => ({
|
|
@@ -2482,7 +2590,8 @@ function parsePlayDocflowFile(sourceCode, moduleSources) {
|
|
|
2482
2590
|
docflow: materializeDocflow(block)
|
|
2483
2591
|
})),
|
|
2484
2592
|
bindings,
|
|
2485
|
-
errors
|
|
2593
|
+
errors,
|
|
2594
|
+
unreadBlocks
|
|
2486
2595
|
};
|
|
2487
2596
|
}
|
|
2488
2597
|
function resolveBlockExports(sourceCode, blocks, errors) {
|
|
@@ -2622,12 +2731,13 @@ function projectRecordedArms(block, errors) {
|
|
|
2622
2731
|
edge.arm = binding.arm;
|
|
2623
2732
|
}
|
|
2624
2733
|
}
|
|
2625
|
-
function attachBindingsToBlocks(sourceCode, blocks, bindings, errors, rejectedNodeIds) {
|
|
2734
|
+
function attachBindingsToBlocks(sourceCode, blocks, bindings, errors, rejectedNodeIds, someBlockUnread = false) {
|
|
2626
2735
|
const lineStarts = sourceLineStartsForDocflow(sourceCode);
|
|
2627
2736
|
const exportRanges = playExportSourceRanges(sourceCode);
|
|
2628
2737
|
for (const binding of bindings) {
|
|
2629
2738
|
let owners = blocks.filter((block) => block.nodes.has(binding.nodeId));
|
|
2630
|
-
if (owners.length === 0 && binding.sourcePath)
|
|
2739
|
+
if (owners.length === 0 && (binding.sourcePath || someBlockUnread))
|
|
2740
|
+
continue;
|
|
2631
2741
|
if (owners.length === 0) {
|
|
2632
2742
|
errors.push(
|
|
2633
2743
|
`Docflow annotation "${binding.nodeId}" does not name a graph node.`
|
|
@@ -2661,15 +2771,16 @@ function attachBindingsToBlocks(sourceCode, blocks, bindings, errors, rejectedNo
|
|
|
2661
2771
|
owner.bindings.push(binding);
|
|
2662
2772
|
}
|
|
2663
2773
|
for (const block of blocks) {
|
|
2664
|
-
for (const binding of block.bindings) {
|
|
2774
|
+
for (const binding of [...block.bindings]) {
|
|
2665
2775
|
const node = block.nodes.get(binding.nodeId);
|
|
2666
|
-
if (binding.label) node.label = binding.label;
|
|
2667
2776
|
if (block.sketchIds.has(binding.nodeId)) {
|
|
2668
2777
|
errors.push(
|
|
2669
2778
|
`Docflow box "${binding.nodeId}" is declared \`class ${binding.nodeId} sketch\` and also bound by \`// @mermaid-node ${binding.nodeId}\` on line ${binding.line}. It is one or the other: drop it from the class line, or drop the annotation.`
|
|
2670
2779
|
);
|
|
2780
|
+
block.bindings.splice(block.bindings.indexOf(binding), 1);
|
|
2671
2781
|
continue;
|
|
2672
2782
|
}
|
|
2783
|
+
if (binding.label) node.label = binding.label;
|
|
2673
2784
|
if (binding.kind) node.kind = binding.kind;
|
|
2674
2785
|
}
|
|
2675
2786
|
projectRecordedArms(block, errors);
|
|
@@ -2678,7 +2789,7 @@ function attachBindingsToBlocks(sourceCode, blocks, bindings, errors, rejectedNo
|
|
|
2678
2789
|
if (node.sketch || node.kind === "conceptual" || bound.has(node.id) || rejectedNodeIds.has(node.id))
|
|
2679
2790
|
continue;
|
|
2680
2791
|
errors.push(
|
|
2681
|
-
`Docflow box "${node.id}" in \`${blockLabel(block)}\` points at nothing, so the canvas can only draw it and say nothing about it.
|
|
2792
|
+
`Docflow box "${node.id}" in \`${blockLabel(block)}\` points at nothing, so the canvas can only draw it and say nothing about it. Put \`// @mermaid-node ${node.id}\` above the statement it runs, in this file or a module it imports. Only a box no statement runs, such as the event that starts the play, belongs on a \`class ${node.id} sketch\` line.`
|
|
2682
2793
|
);
|
|
2683
2794
|
}
|
|
2684
2795
|
}
|
|
@@ -2758,7 +2869,14 @@ function parseDocflowBindingsInSource(source, errors, rejectedNodeIds) {
|
|
|
2758
2869
|
index + 1,
|
|
2759
2870
|
errors
|
|
2760
2871
|
);
|
|
2761
|
-
|
|
2872
|
+
const show = parseContractPaths(
|
|
2873
|
+
attributes.show,
|
|
2874
|
+
"show",
|
|
2875
|
+
id,
|
|
2876
|
+
index + 1,
|
|
2877
|
+
errors
|
|
2878
|
+
);
|
|
2879
|
+
if (attributes.in !== void 0 && !inputs || attributes.out !== void 0 && !outputs || attributes.show !== void 0 && !show) {
|
|
2762
2880
|
continue;
|
|
2763
2881
|
}
|
|
2764
2882
|
const inferred = inputs || outputs ? {
|
|
@@ -2777,6 +2895,7 @@ function parseDocflowBindingsInSource(source, errors, rejectedNodeIds) {
|
|
|
2777
2895
|
// explicit `undefined` key survives `JSON.stringify` round-trips in some
|
|
2778
2896
|
// callers and would reintroduce the hash drift this omission avoids.
|
|
2779
2897
|
...arm ? { arm } : {},
|
|
2898
|
+
...show?.length ? { show } : {},
|
|
2780
2899
|
...inferred
|
|
2781
2900
|
});
|
|
2782
2901
|
}
|
|
@@ -4227,7 +4346,7 @@ function docflowObservationTarget(statement) {
|
|
|
4227
4346
|
function docflowObservedExpression(input) {
|
|
4228
4347
|
const body = input.throws ? `{throw (${input.expression})}` : `(${input.expression})`;
|
|
4229
4348
|
const callback = input.awaitsResult ? `async()=>${body}` : `()=>${body}`;
|
|
4230
|
-
const observation = `((runtimeContext,inputCaptures,execute)=>typeof runtimeContext.__deeplineObserveDocflowNode==="function"
|
|
4349
|
+
const observation = `((runtimeContext,inputCaptures,execute)=>{let state=0,value,error;const once=()=>{if(state===0){state=1;try{value=execute();state=2}catch(thrown){error=thrown;state=3}}if(state===3)throw error;return value};try{if(runtimeContext!=null&&typeof runtimeContext.__deeplineObserveDocflowNode==="function")runtimeContext.__deeplineObserveDocflowNode(${JSON.stringify(input.nodeId)},inputCaptures,${JSON.stringify(input.outputs)},once)}catch(ignored){}return once()})(${input.contextName},${docflowInputCaptureSource(input.inputs)},${callback})`;
|
|
4231
4350
|
return input.awaitsResult ? `(await ${observation})` : observation;
|
|
4232
4351
|
}
|
|
4233
4352
|
function expressionContainsTopLevelAwait(expression) {
|
|
@@ -4245,53 +4364,321 @@ function expressionContainsTopLevelAwait(expression) {
|
|
|
4245
4364
|
}
|
|
4246
4365
|
return false;
|
|
4247
4366
|
}
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4367
|
+
var DOCFLOW_STORE_CONTEXT_READER = "__deeplineDocflowRunContext";
|
|
4368
|
+
var DOCFLOW_STORE_CONTEXT_BINDER = "__deeplineDocflowBindRunContext";
|
|
4369
|
+
var DOCFLOW_SDK_NAMESPACE = "__deeplineDocflowSdk";
|
|
4370
|
+
function docflowRunContextPrelude(ast, sourceCode) {
|
|
4371
|
+
const isModule = astArray(ast.body).some(
|
|
4372
|
+
(statement) => statement.type === "ImportDeclaration" || statement.type === "ExportNamedDeclaration" || statement.type === "ExportDefaultDeclaration" || statement.type === "ExportAllDeclaration"
|
|
4373
|
+
);
|
|
4374
|
+
const sdk = DOCFLOW_SDK_NAMESPACE;
|
|
4375
|
+
const binding = isModule ? `import * as ${sdk} from 'deepline';` : `var ${sdk}=require('deepline');`;
|
|
4376
|
+
const value = `${binding}function ${DOCFLOW_STORE_CONTEXT_READER}(){try{return (typeof ${sdk}.__deeplineCurrentDocflowContext==="function"?${sdk}.__deeplineCurrentDocflowContext():null)??{}}catch(ignored){return {}}}function ${DOCFLOW_STORE_CONTEXT_BINDER}(context,body){let entered=false;const run=()=>{entered=true;return body()};try{if(typeof ${sdk}.__deeplineRunWithDocflowContext==="function")return ${sdk}.__deeplineRunWithDocflowContext(context,run)}catch(failure){if(entered)throw failure}return entered?void 0:body()} `;
|
|
4377
|
+
const at = docflowPreludeOffset(ast, sourceCode);
|
|
4378
|
+
return { start: at, end: at, value };
|
|
4379
|
+
}
|
|
4380
|
+
function docflowPreludeOffset(ast, sourceCode) {
|
|
4381
|
+
let at = sourceCode.startsWith("#!") ? sourceCode.indexOf("\n") + 1 : 0;
|
|
4382
|
+
for (const statement of astArray(ast.body)) {
|
|
4383
|
+
if (statement.type !== "ExpressionStatement" || typeof statement.directive !== "string") {
|
|
4384
|
+
break;
|
|
4385
|
+
}
|
|
4386
|
+
at = astNodeBounds(statement)?.end ?? at;
|
|
4387
|
+
}
|
|
4388
|
+
return at;
|
|
4389
|
+
}
|
|
4390
|
+
function docflowPatternNames(pattern, names) {
|
|
4391
|
+
const pending = [pattern];
|
|
4392
|
+
while (pending.length > 0) {
|
|
4393
|
+
const value = pending.pop();
|
|
4394
|
+
if (Array.isArray(value)) {
|
|
4395
|
+
pending.push(...value);
|
|
4396
|
+
continue;
|
|
4397
|
+
}
|
|
4398
|
+
if (!isAstNode(value)) continue;
|
|
4399
|
+
if (value.type === "Identifier" && typeof value.name === "string") {
|
|
4400
|
+
names.add(value.name);
|
|
4401
|
+
}
|
|
4402
|
+
for (const [key, child] of Object.entries(value)) {
|
|
4403
|
+
if (key === "typeAnnotation") continue;
|
|
4404
|
+
if (Array.isArray(child) || isAstNode(child)) pending.push(child);
|
|
4405
|
+
}
|
|
4406
|
+
}
|
|
4407
|
+
}
|
|
4408
|
+
var DOCFLOW_FUNCTION_NODE_TYPES = /* @__PURE__ */ new Set([
|
|
4409
|
+
"FunctionDeclaration",
|
|
4410
|
+
"FunctionExpression",
|
|
4411
|
+
"ArrowFunctionExpression"
|
|
4412
|
+
]);
|
|
4413
|
+
function docflowRunBodyRedeclaresParameter(run) {
|
|
4414
|
+
const parameters = /* @__PURE__ */ new Set();
|
|
4415
|
+
docflowPatternNames(run.params, parameters);
|
|
4416
|
+
if (parameters.size === 0 || !isAstNode(run.body)) return false;
|
|
4417
|
+
const declared = /* @__PURE__ */ new Set();
|
|
4418
|
+
for (const statement of astArray(run.body.body)) {
|
|
4419
|
+
if (statement.type === "FunctionDeclaration" && isAstNode(statement.id)) {
|
|
4420
|
+
docflowPatternNames(statement.id, declared);
|
|
4421
|
+
}
|
|
4422
|
+
}
|
|
4423
|
+
const pending = [run.body];
|
|
4424
|
+
while (pending.length > 0) {
|
|
4425
|
+
const value = pending.pop();
|
|
4426
|
+
if (Array.isArray(value)) {
|
|
4427
|
+
pending.push(...value);
|
|
4428
|
+
continue;
|
|
4429
|
+
}
|
|
4430
|
+
if (!isAstNode(value)) continue;
|
|
4431
|
+
if (DOCFLOW_FUNCTION_NODE_TYPES.has(value.type)) continue;
|
|
4432
|
+
if (value.type === "VariableDeclaration" && value.kind === "var") {
|
|
4433
|
+
for (const declaration of astArray(value.declarations)) {
|
|
4434
|
+
docflowPatternNames(declaration.id, declared);
|
|
4435
|
+
}
|
|
4436
|
+
}
|
|
4437
|
+
for (const child of Object.values(value)) {
|
|
4438
|
+
if (Array.isArray(child) || isAstNode(child)) pending.push(child);
|
|
4439
|
+
}
|
|
4440
|
+
}
|
|
4441
|
+
return [...declared].some((name) => parameters.has(name));
|
|
4442
|
+
}
|
|
4443
|
+
function docflowRunContextBindings(ast, sourceCode, injectedContextAt, warnings) {
|
|
4444
|
+
const replacements = [];
|
|
4445
|
+
const pending = [ast];
|
|
4446
|
+
while (pending.length > 0) {
|
|
4447
|
+
const value = pending.pop();
|
|
4448
|
+
if (!isAstNode(value)) continue;
|
|
4449
|
+
for (const child of Object.values(value)) {
|
|
4450
|
+
if (Array.isArray(child)) pending.push(...child);
|
|
4451
|
+
else if (isAstNode(child)) pending.push(child);
|
|
4452
|
+
}
|
|
4453
|
+
const context = docflowContextFromCall(value, sourceCode);
|
|
4454
|
+
if (!context || context.kind === "unsupported" || context.kind === "store")
|
|
4455
|
+
continue;
|
|
4456
|
+
const run = definePlayRunFunction(value);
|
|
4457
|
+
if (!run || run.generator === true || !isAstNode(run.body)) continue;
|
|
4458
|
+
if (docflowRunBodyRedeclaresParameter(run)) {
|
|
4459
|
+
warnings.push(
|
|
4460
|
+
"Diagram boxes in imported helper modules are not tracked for this play: its run function redeclares a parameter with `var` or `function`, whose meaning would change if its body were wrapped. The play runs unchanged."
|
|
4461
|
+
);
|
|
4462
|
+
continue;
|
|
4463
|
+
}
|
|
4464
|
+
const body = astNodeBounds(run.body);
|
|
4465
|
+
if (!body) continue;
|
|
4466
|
+
if (context.kind === "inject") injectedContextAt.add(context.at);
|
|
4467
|
+
const contextName = context.kind === "inject" ? DOCFLOW_INJECTED_CONTEXT_NAME : context.name;
|
|
4468
|
+
const arrow = run.async === true ? "async()=>" : "()=>";
|
|
4469
|
+
if (run.body.type === "BlockStatement") {
|
|
4470
|
+
const directives = astArray(run.body.body).filter(
|
|
4471
|
+
(statement) => statement.type === "ExpressionStatement" && typeof statement.directive === "string"
|
|
4472
|
+
);
|
|
4473
|
+
if (directives.length > 0) continue;
|
|
4474
|
+
replacements.push(
|
|
4475
|
+
{
|
|
4476
|
+
start: body.start + 1,
|
|
4477
|
+
end: body.start + 1,
|
|
4478
|
+
value: `return ${DOCFLOW_STORE_CONTEXT_BINDER}(${contextName},${arrow}{`
|
|
4479
|
+
},
|
|
4480
|
+
{ start: body.end - 1, end: body.end - 1, value: "});" }
|
|
4481
|
+
);
|
|
4482
|
+
} else {
|
|
4483
|
+
replacements.push(
|
|
4484
|
+
{
|
|
4485
|
+
start: body.start,
|
|
4486
|
+
end: body.start,
|
|
4487
|
+
value: `${DOCFLOW_STORE_CONTEXT_BINDER}(${contextName},${arrow}(`
|
|
4488
|
+
},
|
|
4489
|
+
{ start: body.end, end: body.end, value: "))" }
|
|
4490
|
+
);
|
|
4491
|
+
}
|
|
4492
|
+
}
|
|
4493
|
+
return replacements;
|
|
4494
|
+
}
|
|
4495
|
+
function instrumentPlayDocflowRuntimeHitsWithReport(sourceCode, options = {}) {
|
|
4496
|
+
const warnings = [];
|
|
4497
|
+
const untouched = (reason) => {
|
|
4498
|
+
if (reason) warnings.push(reason);
|
|
4499
|
+
return { code: sourceCode, instrumented: false, warnings };
|
|
4500
|
+
};
|
|
4501
|
+
let code;
|
|
4502
|
+
try {
|
|
4503
|
+
code = instrumentPlayDocflowRuntimeHitsCore(sourceCode, options, warnings);
|
|
4504
|
+
} catch (error) {
|
|
4505
|
+
return untouched(
|
|
4506
|
+
`Diagram tracking was skipped for this file: instrumentation failed (${boundedInstrumentationReason(error)}). The play runs unchanged.`
|
|
4507
|
+
);
|
|
4508
|
+
}
|
|
4509
|
+
if (code === sourceCode) return untouched();
|
|
4510
|
+
if (!parsePlaySourceAstExact(code)) {
|
|
4511
|
+
return untouched(
|
|
4512
|
+
"Diagram tracking was skipped for this file: the instrumented source did not parse. The play runs unchanged."
|
|
4513
|
+
);
|
|
4514
|
+
}
|
|
4515
|
+
return { code, instrumented: true, warnings };
|
|
4516
|
+
}
|
|
4517
|
+
function boundedInstrumentationReason(error) {
|
|
4518
|
+
let message;
|
|
4519
|
+
try {
|
|
4520
|
+
message = error instanceof Error ? error.message : String(error);
|
|
4521
|
+
} catch {
|
|
4522
|
+
message = "unknown error";
|
|
4523
|
+
}
|
|
4524
|
+
return message.length > 300 ? `${message.slice(0, 300)}\u2026` : message;
|
|
4525
|
+
}
|
|
4526
|
+
function parsePlaySourceAstExact(sourceCode) {
|
|
4527
|
+
try {
|
|
4528
|
+
return TypeScriptParser.parse(sourceCode, {
|
|
4529
|
+
ecmaVersion: "latest",
|
|
4530
|
+
sourceType: "module",
|
|
4531
|
+
allowHashBang: true,
|
|
4532
|
+
// Script plays may end early with a top-level `return`.
|
|
4533
|
+
allowReturnOutsideFunction: true
|
|
4534
|
+
});
|
|
4535
|
+
} catch {
|
|
4536
|
+
return null;
|
|
4537
|
+
}
|
|
4538
|
+
}
|
|
4539
|
+
function docflowStatementListStarts(ast) {
|
|
4540
|
+
const starts = /* @__PURE__ */ new Set();
|
|
4541
|
+
const pending = [ast];
|
|
4542
|
+
while (pending.length > 0) {
|
|
4543
|
+
const value = pending.pop();
|
|
4544
|
+
if (!isAstNode(value)) continue;
|
|
4545
|
+
const list = value.type === "Program" || value.type === "BlockStatement" || value.type === "StaticBlock" ? value.body : value.type === "SwitchCase" ? value.consequent : null;
|
|
4546
|
+
for (const statement of astArray(list)) {
|
|
4547
|
+
if (statement.type === "ExpressionStatement" && typeof statement.directive === "string") {
|
|
4548
|
+
continue;
|
|
4549
|
+
}
|
|
4550
|
+
if (/^(Import|Export)/.test(statement.type)) continue;
|
|
4551
|
+
const bounds = astNodeBounds(statement);
|
|
4552
|
+
if (bounds) starts.add(bounds.start);
|
|
4553
|
+
}
|
|
4554
|
+
for (const child of Object.values(value)) {
|
|
4555
|
+
if (Array.isArray(child)) pending.push(...child);
|
|
4556
|
+
else if (isAstNode(child)) pending.push(child);
|
|
4557
|
+
}
|
|
4558
|
+
}
|
|
4559
|
+
return starts;
|
|
4560
|
+
}
|
|
4561
|
+
function docflowUnwrappableReason(statement, expression) {
|
|
4562
|
+
const pending = [expression];
|
|
4563
|
+
while (pending.length > 0) {
|
|
4564
|
+
const node = pending.pop();
|
|
4565
|
+
if (node.type === "YieldExpression") {
|
|
4566
|
+
return "the statement contains `yield`, which cannot move into an observation callback";
|
|
4567
|
+
}
|
|
4568
|
+
if (node !== expression && (node.type === "FunctionExpression" || node.type === "FunctionDeclaration" || node.type === "ArrowFunctionExpression")) {
|
|
4569
|
+
continue;
|
|
4570
|
+
}
|
|
4571
|
+
for (const child of Object.values(node)) {
|
|
4572
|
+
if (Array.isArray(child)) pending.push(...child.filter(isAstNode));
|
|
4573
|
+
else if (isAstNode(child)) pending.push(child);
|
|
4574
|
+
}
|
|
4575
|
+
}
|
|
4576
|
+
let inner = expression;
|
|
4577
|
+
while ((inner.type === "TSAsExpression" || inner.type === "TSSatisfiesExpression" || inner.type === "TSNonNullExpression" || inner.type === "TSTypeAssertion" || inner.type === "ParenthesizedExpression") && isAstNode(inner.expression)) {
|
|
4578
|
+
inner = inner.expression;
|
|
4579
|
+
}
|
|
4580
|
+
const anonymousCallable = inner.type === "ArrowFunctionExpression" || (inner.type === "FunctionExpression" || inner.type === "ClassExpression") && !isAstNode(inner.id);
|
|
4581
|
+
if (statement?.type === "VariableDeclaration" && anonymousCallable) {
|
|
4582
|
+
return "the declaration initializes an anonymous function or class, whose name comes from the declaration";
|
|
4583
|
+
}
|
|
4584
|
+
return null;
|
|
4585
|
+
}
|
|
4586
|
+
function instrumentPlayDocflowRuntimeHitsCore(sourceCode, options, warnings) {
|
|
4587
|
+
const helperBindings = options.helperBindings;
|
|
4588
|
+
let fileBindings;
|
|
4589
|
+
if (helperBindings !== void 0) {
|
|
4590
|
+
if (helperBindings.length === 0) return sourceCode;
|
|
4591
|
+
fileBindings = helperBindings;
|
|
4592
|
+
} else {
|
|
4593
|
+
const parsed = parsePlayDocflowFile(sourceCode, options.moduleSources);
|
|
4594
|
+
if (parsed.blocks.length === 0) return sourceCode;
|
|
4595
|
+
if (parsed.errors.length > 0) {
|
|
4596
|
+
warnings.push(
|
|
4597
|
+
`Diagram tracking skipped what did not resolve in this file's @mermaid diagram (${boundedInstrumentationReason(parsed.errors[0])}${parsed.errors.length > 1 ? `, and ${parsed.errors.length - 1} more` : ""}). The play runs unchanged.`
|
|
4598
|
+
);
|
|
4599
|
+
fileBindings = parsed.blocks.flatMap((block) => block.docflow.bindings).filter((binding) => !binding.sourcePath);
|
|
4600
|
+
if (fileBindings.length === 0) return sourceCode;
|
|
4601
|
+
} else {
|
|
4602
|
+
fileBindings = parsed.bindings.filter((binding) => !binding.sourcePath);
|
|
4603
|
+
}
|
|
4604
|
+
}
|
|
4605
|
+
const ast = parsePlaySourceAstExact(sourceCode);
|
|
4606
|
+
if (!ast) {
|
|
4607
|
+
warnings.push(
|
|
4608
|
+
"Diagram tracking was skipped for this file: its source could not be parsed exactly for instrumentation. The play runs unchanged."
|
|
4609
|
+
);
|
|
4610
|
+
return sourceCode;
|
|
4611
|
+
}
|
|
4253
4612
|
const lineStarts = sourceLineStarts(sourceCode);
|
|
4254
4613
|
const replacements = [];
|
|
4614
|
+
let statementListStarts = null;
|
|
4255
4615
|
const targets = [];
|
|
4256
4616
|
const injectedContextAt = /* @__PURE__ */ new Set();
|
|
4257
4617
|
const parents = buildDocflowParentIndex(ast);
|
|
4258
4618
|
const scriptContext = parseScriptPlay(sourceCode)?.contextName ?? null;
|
|
4259
|
-
|
|
4619
|
+
let usesRunContextStore = false;
|
|
4620
|
+
for (const binding of fileBindings) {
|
|
4260
4621
|
const resolution = resolveDocflowBinding(ast, binding, lineStarts, parents);
|
|
4261
|
-
const context = findDocflowContext({
|
|
4622
|
+
const context = (helperBindings === void 0 ? findDocflowContext({
|
|
4262
4623
|
ast,
|
|
4263
4624
|
sourceCode,
|
|
4264
4625
|
statement: resolution.statement,
|
|
4265
4626
|
bindingLine: binding.line,
|
|
4266
4627
|
lineStarts,
|
|
4267
4628
|
parents
|
|
4268
|
-
}) ?? (scriptContext ? { kind: "named", name: scriptContext } : null);
|
|
4269
|
-
if (!context) continue;
|
|
4629
|
+
}) ?? (scriptContext ? { kind: "named", name: scriptContext } : null) : null) ?? { kind: "store" };
|
|
4270
4630
|
if (context.kind === "unsupported") {
|
|
4271
|
-
|
|
4272
|
-
`@mermaid-node ${binding.nodeId} (line ${binding.line}) cannot be observed at runtime: ${context.reason}.`
|
|
4631
|
+
warnings.push(
|
|
4632
|
+
`@mermaid-node ${binding.nodeId} (line ${binding.line}) cannot be observed at runtime: ${context.reason}. The box is drawn but not tracked.`
|
|
4273
4633
|
);
|
|
4634
|
+
continue;
|
|
4274
4635
|
}
|
|
4636
|
+
if (context.kind === "store") usesRunContextStore = true;
|
|
4275
4637
|
if (context.kind === "inject") injectedContextAt.add(context.at);
|
|
4276
|
-
const contextName = context.kind === "inject" ? `(${context.name}??{})` : context.name;
|
|
4638
|
+
const contextName = context.kind === "inject" ? `(${context.name}??{})` : context.kind === "store" ? `${DOCFLOW_STORE_CONTEXT_READER}()` : context.name;
|
|
4277
4639
|
const target = docflowObservationTarget(resolution.statement);
|
|
4278
4640
|
const observedRoot = docflowOutputRoot(binding);
|
|
4279
4641
|
if (target && observedRoot && docflowExpressionWrapsStepBuilder(target.expression, observedRoot)) {
|
|
4280
4642
|
continue;
|
|
4281
4643
|
}
|
|
4282
4644
|
if (target) {
|
|
4645
|
+
const unwrappable = docflowUnwrappableReason(
|
|
4646
|
+
resolution.statement,
|
|
4647
|
+
target.expression
|
|
4648
|
+
);
|
|
4649
|
+
if (unwrappable) {
|
|
4650
|
+
warnings.push(
|
|
4651
|
+
`@mermaid-node ${binding.nodeId} (line ${binding.line}) is not tracked: ${unwrappable}.`
|
|
4652
|
+
);
|
|
4653
|
+
continue;
|
|
4654
|
+
}
|
|
4283
4655
|
targets.push({ ...target, contextName, binding });
|
|
4284
4656
|
continue;
|
|
4285
4657
|
}
|
|
4286
4658
|
const lineStart = lineStarts[binding.line - 1];
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4659
|
+
const statementBounds = resolution.statement ? astNodeBounds(resolution.statement) : null;
|
|
4660
|
+
const indentationLength = lineStart === void 0 ? 0 : /^\s*/.exec(sourceCode.slice(lineStart))?.[0].length ?? 0;
|
|
4661
|
+
statementListStarts ??= docflowStatementListStarts(ast);
|
|
4662
|
+
const listStarts = statementListStarts;
|
|
4663
|
+
const at = [
|
|
4664
|
+
statementBounds?.start,
|
|
4665
|
+
lineStart === void 0 ? void 0 : lineStart + indentationLength
|
|
4666
|
+
].find(
|
|
4667
|
+
(candidate) => candidate !== void 0 && listStarts.has(candidate)
|
|
4668
|
+
);
|
|
4669
|
+
if (at === void 0) {
|
|
4670
|
+
warnings.push(
|
|
4671
|
+
`@mermaid-node ${binding.nodeId} (line ${binding.line}) is not tracked: it binds no expression and does not start a statement.`
|
|
4672
|
+
);
|
|
4673
|
+
continue;
|
|
4294
4674
|
}
|
|
4675
|
+
replacements.push({
|
|
4676
|
+
start: at,
|
|
4677
|
+
end: at,
|
|
4678
|
+
// `void` first: a statement opening with `(` would continue a previous
|
|
4679
|
+
// line written without a semicolon (`f()\n(…)` calls f's result).
|
|
4680
|
+
value: `void ((runtimeContext)=>{try{if(runtimeContext!=null&&typeof runtimeContext.__deeplineDocflowHit==="function"){const pending=runtimeContext.__deeplineDocflowHit(${JSON.stringify(binding.nodeId)});if(pending!=null&&typeof pending.then==="function")pending.then(null,()=>{})}}catch(ignored){}})(${contextName}); `
|
|
4681
|
+
});
|
|
4295
4682
|
}
|
|
4296
4683
|
targets.sort(
|
|
4297
4684
|
(left, right) => left.start - right.start || right.end - left.end
|
|
@@ -4327,12 +4714,27 @@ function instrumentPlayDocflowRuntimeHits(sourceCode) {
|
|
|
4327
4714
|
});
|
|
4328
4715
|
innermost = false;
|
|
4329
4716
|
}
|
|
4717
|
+
statementListStarts ??= docflowStatementListStarts(ast);
|
|
4330
4718
|
replacements.push({
|
|
4331
4719
|
start: group.start,
|
|
4332
4720
|
end: group.end,
|
|
4333
|
-
value: expression
|
|
4721
|
+
value: statementListStarts.has(group.start) ? `void ${expression}` : expression
|
|
4334
4722
|
});
|
|
4335
4723
|
}
|
|
4724
|
+
const bindRunContext = helperBindings === void 0 && !scriptContext && (usesRunContextStore || options.bindRunContext === true);
|
|
4725
|
+
if (bindRunContext) {
|
|
4726
|
+
replacements.push(
|
|
4727
|
+
...docflowRunContextBindings(
|
|
4728
|
+
ast,
|
|
4729
|
+
sourceCode,
|
|
4730
|
+
injectedContextAt,
|
|
4731
|
+
warnings
|
|
4732
|
+
)
|
|
4733
|
+
);
|
|
4734
|
+
}
|
|
4735
|
+
if (usesRunContextStore || bindRunContext) {
|
|
4736
|
+
replacements.push(docflowRunContextPrelude(ast, sourceCode));
|
|
4737
|
+
}
|
|
4336
4738
|
for (const at of injectedContextAt) {
|
|
4337
4739
|
replacements.push({
|
|
4338
4740
|
start: at,
|
|
@@ -4340,27 +4742,53 @@ function instrumentPlayDocflowRuntimeHits(sourceCode) {
|
|
|
4340
4742
|
value: DOCFLOW_INJECTED_CONTEXT_NAME
|
|
4341
4743
|
});
|
|
4342
4744
|
}
|
|
4343
|
-
return replacements.sort((left, right) => right.start - left.start).reduce(
|
|
4745
|
+
return replacements.sort((left, right) => right.start - left.start || right.end - left.end).reduce(
|
|
4344
4746
|
(source, replacement) => `${source.slice(0, replacement.start)}${replacement.value}${source.slice(replacement.end)}`,
|
|
4345
4747
|
sourceCode
|
|
4346
4748
|
);
|
|
4347
4749
|
}
|
|
4348
|
-
function docflowRuntimeInstrumentationPlugin(analyzedSources, scriptEntry) {
|
|
4750
|
+
function docflowRuntimeInstrumentationPlugin(analyzedSources, entryFile, scriptEntry) {
|
|
4349
4751
|
const customerSourceFiles = new Map(
|
|
4350
4752
|
Object.entries(analyzedSources).filter(([path]) => extname(path).toLowerCase() !== ".json").map(([path, contents]) => [resolve(path), contents])
|
|
4351
4753
|
);
|
|
4754
|
+
const entryPath = resolve(entryFile);
|
|
4755
|
+
const planWarnings = [];
|
|
4756
|
+
const plan = docflowHelperInstrumentationPlanFailOpen(
|
|
4757
|
+
entryPath,
|
|
4758
|
+
scriptEntry?.source ?? customerSourceFiles.get(entryPath) ?? null,
|
|
4759
|
+
customerSourceFiles,
|
|
4760
|
+
planWarnings
|
|
4761
|
+
);
|
|
4762
|
+
const entryOptions = {
|
|
4763
|
+
moduleSources: plan.moduleSources,
|
|
4764
|
+
bindRunContext: plan.helperBindings.size > 0
|
|
4765
|
+
};
|
|
4766
|
+
const asWarnings = (path, warnings) => warnings.map((text) => ({
|
|
4767
|
+
text: `${DOCFLOW_INSTRUMENTATION_WARNING_PREFIX}${text}`,
|
|
4768
|
+
location: { file: path }
|
|
4769
|
+
}));
|
|
4352
4770
|
return {
|
|
4353
4771
|
name: "deepline-docflow-runtime-instrumentation",
|
|
4354
4772
|
setup(buildContext) {
|
|
4355
4773
|
buildContext.onLoad({ filter: /./ }, (args) => {
|
|
4356
|
-
|
|
4774
|
+
const path = resolve(args.path);
|
|
4775
|
+
if (scriptEntry && path === resolve(scriptEntry.path)) {
|
|
4776
|
+
const script = scriptEntryModule(
|
|
4777
|
+
scriptEntry.source,
|
|
4778
|
+
args.path,
|
|
4779
|
+
entryOptions
|
|
4780
|
+
);
|
|
4357
4781
|
return {
|
|
4358
|
-
contents:
|
|
4782
|
+
contents: script.contents,
|
|
4359
4783
|
loader: sourceLoaderForPath(args.path),
|
|
4360
|
-
resolveDir: dirname(args.path)
|
|
4784
|
+
resolveDir: dirname(args.path),
|
|
4785
|
+
warnings: asWarnings(args.path, [
|
|
4786
|
+
...planWarnings,
|
|
4787
|
+
...script.warnings
|
|
4788
|
+
])
|
|
4361
4789
|
};
|
|
4362
4790
|
}
|
|
4363
|
-
const contents = customerSourceFiles.get(
|
|
4791
|
+
const contents = customerSourceFiles.get(path);
|
|
4364
4792
|
if (contents === void 0) return void 0;
|
|
4365
4793
|
if (isTextImportFile(args.path)) {
|
|
4366
4794
|
return {
|
|
@@ -4369,27 +4797,98 @@ function docflowRuntimeInstrumentationPlugin(analyzedSources, scriptEntry) {
|
|
|
4369
4797
|
resolveDir: dirname(args.path)
|
|
4370
4798
|
};
|
|
4371
4799
|
}
|
|
4800
|
+
const helperBindings = plan.helperBindings.get(path);
|
|
4801
|
+
const report = instrumentPlayDocflowRuntimeHitsWithReport(
|
|
4802
|
+
contents,
|
|
4803
|
+
path === entryPath ? entryOptions : helperBindings ? { helperBindings } : {}
|
|
4804
|
+
);
|
|
4372
4805
|
return {
|
|
4373
|
-
contents:
|
|
4806
|
+
contents: report.code,
|
|
4374
4807
|
loader: sourceLoaderForPath(args.path),
|
|
4375
|
-
resolveDir: dirname(args.path)
|
|
4808
|
+
resolveDir: dirname(args.path),
|
|
4809
|
+
warnings: asWarnings(args.path, [
|
|
4810
|
+
...path === entryPath ? planWarnings : [],
|
|
4811
|
+
...report.warnings
|
|
4812
|
+
])
|
|
4376
4813
|
};
|
|
4377
4814
|
});
|
|
4378
4815
|
}
|
|
4379
4816
|
};
|
|
4380
4817
|
}
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4818
|
+
var DOCFLOW_INSTRUMENTATION_WARNING_PREFIX = "[diagram tracking] ";
|
|
4819
|
+
function docflowHelperInstrumentationPlanFailOpen(entryPath, entrySource, sources, warnings) {
|
|
4820
|
+
try {
|
|
4821
|
+
return docflowHelperInstrumentationPlan(entryPath, entrySource, sources);
|
|
4822
|
+
} catch (error) {
|
|
4823
|
+
warnings.push(
|
|
4824
|
+
`Diagram tracking in imported helper modules was skipped: ${boundedInstrumentationReason(error)}.`
|
|
4387
4825
|
);
|
|
4826
|
+
return {
|
|
4827
|
+
moduleSources: new Map(
|
|
4828
|
+
[...sources].filter(
|
|
4829
|
+
([path]) => path !== entryPath && !isTextImportFile(path)
|
|
4830
|
+
)
|
|
4831
|
+
),
|
|
4832
|
+
helperBindings: /* @__PURE__ */ new Map()
|
|
4833
|
+
};
|
|
4388
4834
|
}
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4835
|
+
}
|
|
4836
|
+
function docflowHelperInstrumentationPlan(entryPath, entrySource, sources) {
|
|
4837
|
+
const moduleSources = new Map(
|
|
4838
|
+
[...sources].filter(
|
|
4839
|
+
([path]) => path !== entryPath && !isTextImportFile(path)
|
|
4840
|
+
)
|
|
4841
|
+
);
|
|
4842
|
+
const helperBindings = /* @__PURE__ */ new Map();
|
|
4843
|
+
if (entrySource === null || moduleSources.size === 0) {
|
|
4844
|
+
return { moduleSources, helperBindings };
|
|
4845
|
+
}
|
|
4846
|
+
const parsed = parsePlayDocflowFile(entrySource, moduleSources);
|
|
4847
|
+
const drawn = new Set(
|
|
4848
|
+
parsed.blocks.flatMap(
|
|
4849
|
+
(block) => block.docflow.nodes.map((node) => node.id)
|
|
4850
|
+
)
|
|
4851
|
+
);
|
|
4852
|
+
const tracked = parsed.errors.length > 0 ? parsed.blocks.flatMap((block) => block.docflow.bindings) : parsed.bindings;
|
|
4853
|
+
for (const binding of tracked) {
|
|
4854
|
+
if (!binding.sourcePath || !drawn.has(binding.nodeId)) continue;
|
|
4855
|
+
const path = resolve(binding.sourcePath);
|
|
4856
|
+
helperBindings.set(path, [...helperBindings.get(path) ?? [], binding]);
|
|
4857
|
+
}
|
|
4858
|
+
return { moduleSources, helperBindings };
|
|
4859
|
+
}
|
|
4860
|
+
function scriptEntryModule(source, path, options = {}) {
|
|
4861
|
+
const typed = /^tsx?$/.test(sourceLoaderForPath(path));
|
|
4862
|
+
const report = instrumentPlayDocflowRuntimeHitsWithReport(source, options);
|
|
4863
|
+
if (report.instrumented) {
|
|
4864
|
+
try {
|
|
4865
|
+
const script2 = parseScriptPlay(report.code);
|
|
4866
|
+
if (script2) {
|
|
4867
|
+
return {
|
|
4868
|
+
contents: wrapScriptPlay(report.code, script2, {
|
|
4869
|
+
typed,
|
|
4870
|
+
authoredSource: source
|
|
4871
|
+
}),
|
|
4872
|
+
warnings: report.warnings
|
|
4873
|
+
};
|
|
4874
|
+
}
|
|
4875
|
+
} catch {
|
|
4876
|
+
}
|
|
4877
|
+
report.warnings.push(
|
|
4878
|
+
"Diagram tracking was skipped for this script play: the instrumented source is no longer a script play. The play runs unchanged."
|
|
4879
|
+
);
|
|
4880
|
+
}
|
|
4881
|
+
const script = parseScriptPlay(source);
|
|
4882
|
+
if (!script) {
|
|
4883
|
+
throw new Error("Script play entry could not be parsed as a script play.");
|
|
4884
|
+
}
|
|
4885
|
+
return {
|
|
4886
|
+
contents: wrapScriptPlay(source, script, {
|
|
4887
|
+
typed,
|
|
4888
|
+
authoredSource: source
|
|
4889
|
+
}),
|
|
4890
|
+
warnings: report.warnings
|
|
4891
|
+
};
|
|
4393
4892
|
}
|
|
4394
4893
|
function buildImportedPlayProxyModule(playName) {
|
|
4395
4894
|
const serializedName = JSON.stringify(playName);
|
|
@@ -4787,6 +5286,7 @@ async function runEsbuildForCjsNode(entryFile, analyzedSources, entryScript, imp
|
|
|
4787
5286
|
const playProxyPlugin = importedPlayProxyPlugin(importedPlayDependencies);
|
|
4788
5287
|
const docflowPlugin = docflowRuntimeInstrumentationPlugin(
|
|
4789
5288
|
analyzedSources,
|
|
5289
|
+
entryFile,
|
|
4790
5290
|
entryScript === null ? null : { path: entryFile, source: entryScript }
|
|
4791
5291
|
);
|
|
4792
5292
|
const namedExportShim = exportName !== "default" ? `export { ${exportName} as default } from ${JSON.stringify(entryFile)};
|
|
@@ -4831,7 +5331,16 @@ async function runEsbuildForCjsNode(entryFile, analyzedSources, entryScript, imp
|
|
|
4831
5331
|
return {
|
|
4832
5332
|
bundledCode: codeFile.text,
|
|
4833
5333
|
sourceMapText: mapFile.text,
|
|
4834
|
-
outputExtension: "cjs"
|
|
5334
|
+
outputExtension: "cjs",
|
|
5335
|
+
docflowInstrumentationWarnings: [
|
|
5336
|
+
...new Set(
|
|
5337
|
+
result.warnings.map((warning) => warning.text).filter(
|
|
5338
|
+
(text) => text.startsWith(DOCFLOW_INSTRUMENTATION_WARNING_PREFIX)
|
|
5339
|
+
).map(
|
|
5340
|
+
(text) => text.slice(DOCFLOW_INSTRUMENTATION_WARNING_PREFIX.length)
|
|
5341
|
+
)
|
|
5342
|
+
)
|
|
5343
|
+
]
|
|
4835
5344
|
};
|
|
4836
5345
|
}
|
|
4837
5346
|
async function bundlePlayFile(filePath, options) {
|
|
@@ -4983,7 +5492,12 @@ preserved-compatibility:${JSON.stringify(preservedCompatibility)}`}` + // A scri
|
|
|
4983
5492
|
errors: buildOutcome
|
|
4984
5493
|
};
|
|
4985
5494
|
}
|
|
4986
|
-
const {
|
|
5495
|
+
const {
|
|
5496
|
+
bundledCode,
|
|
5497
|
+
sourceMapText,
|
|
5498
|
+
outputExtension,
|
|
5499
|
+
docflowInstrumentationWarnings
|
|
5500
|
+
} = buildOutcome;
|
|
4987
5501
|
const normalizedSourceMap = normalizeSourceMapForRuntime(
|
|
4988
5502
|
sourceMapText,
|
|
4989
5503
|
bundleRoot
|
|
@@ -5046,7 +5560,8 @@ preserved-compatibility:${JSON.stringify(preservedCompatibility)}`}` + // A scri
|
|
|
5046
5560
|
sandboxRuntimeDeclaration: analysis.sandboxRuntimeDeclaration,
|
|
5047
5561
|
packagedFiles: discoveredFiles.files,
|
|
5048
5562
|
unresolvedFileReferences: discoveredFiles.unresolved,
|
|
5049
|
-
importedPlayDependencies: analysis.importedPlayDependencies
|
|
5563
|
+
importedPlayDependencies: analysis.importedPlayDependencies,
|
|
5564
|
+
...docflowInstrumentationWarnings.length > 0 ? { docflowInstrumentationWarnings } : {}
|
|
5050
5565
|
};
|
|
5051
5566
|
} catch (error) {
|
|
5052
5567
|
if (error instanceof AggregateError) {
|