@milaboratories/pl-middle-layer 1.46.20 → 1.46.22
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/block_registry/index.d.ts +3 -3
- package/dist/block_registry/registry-v2-provider.cjs.map +1 -1
- package/dist/block_registry/registry-v2-provider.d.ts +2 -2
- package/dist/block_registry/registry-v2-provider.js.map +1 -1
- package/dist/block_registry/registry.cjs +54 -53
- package/dist/block_registry/registry.cjs.map +1 -1
- package/dist/block_registry/registry.d.ts +4 -4
- package/dist/block_registry/registry.d.ts.map +1 -1
- package/dist/block_registry/registry.js +54 -53
- package/dist/block_registry/registry.js.map +1 -1
- package/dist/block_registry/watcher.cjs +12 -12
- package/dist/block_registry/watcher.cjs.map +1 -1
- package/dist/block_registry/watcher.d.ts +6 -6
- package/dist/block_registry/watcher.d.ts.map +1 -1
- package/dist/block_registry/watcher.js +12 -12
- package/dist/block_registry/watcher.js.map +1 -1
- package/dist/block_registry/well_known_registries.cjs +6 -6
- package/dist/block_registry/well_known_registries.cjs.map +1 -1
- package/dist/block_registry/well_known_registries.d.ts +1 -1
- package/dist/block_registry/well_known_registries.js +6 -6
- package/dist/block_registry/well_known_registries.js.map +1 -1
- package/dist/cfg_render/executor.cjs +11 -11
- package/dist/cfg_render/executor.cjs.map +1 -1
- package/dist/cfg_render/executor.d.ts +5 -5
- package/dist/cfg_render/executor.js +11 -11
- package/dist/cfg_render/executor.js.map +1 -1
- package/dist/cfg_render/operation.d.ts +5 -5
- package/dist/cfg_render/renderer.cjs +74 -75
- package/dist/cfg_render/renderer.cjs.map +1 -1
- package/dist/cfg_render/renderer.d.ts +2 -2
- package/dist/cfg_render/renderer.d.ts.map +1 -1
- package/dist/cfg_render/renderer.js +74 -75
- package/dist/cfg_render/renderer.js.map +1 -1
- package/dist/cfg_render/traverse.cjs +27 -27
- package/dist/cfg_render/traverse.cjs.map +1 -1
- package/dist/cfg_render/traverse.d.ts +1 -1
- package/dist/cfg_render/traverse.js +27 -27
- package/dist/cfg_render/traverse.js.map +1 -1
- package/dist/cfg_render/util.cjs +1 -1
- package/dist/cfg_render/util.cjs.map +1 -1
- package/dist/cfg_render/util.d.ts +1 -1
- package/dist/cfg_render/util.js +1 -1
- package/dist/cfg_render/util.js.map +1 -1
- package/dist/debug/index.cjs +4 -2
- package/dist/debug/index.cjs.map +1 -1
- package/dist/debug/index.d.ts +2 -2
- package/dist/debug/index.d.ts.map +1 -1
- package/dist/debug/index.js +4 -2
- package/dist/debug/index.js.map +1 -1
- package/dist/dev_env/index.cjs +8 -8
- package/dist/dev_env/index.cjs.map +1 -1
- package/dist/dev_env/index.js +8 -8
- package/dist/dev_env/index.js.map +1 -1
- package/dist/dev_env/util.cjs +1 -1
- package/dist/dev_env/util.cjs.map +1 -1
- package/dist/dev_env/util.d.ts +1 -1
- package/dist/dev_env/util.js +1 -1
- package/dist/dev_env/util.js.map +1 -1
- package/dist/index.d.ts +16 -16
- package/dist/js_render/computable_context.cjs +78 -78
- package/dist/js_render/computable_context.cjs.map +1 -1
- package/dist/js_render/computable_context.d.ts +9 -9
- package/dist/js_render/computable_context.d.ts.map +1 -1
- package/dist/js_render/computable_context.js +78 -78
- package/dist/js_render/computable_context.js.map +1 -1
- package/dist/js_render/context.cjs +33 -27
- package/dist/js_render/context.cjs.map +1 -1
- package/dist/js_render/context.d.ts +7 -7
- package/dist/js_render/context.d.ts.map +1 -1
- package/dist/js_render/context.js +33 -27
- package/dist/js_render/context.js.map +1 -1
- package/dist/js_render/index.cjs +10 -6
- package/dist/js_render/index.cjs.map +1 -1
- package/dist/js_render/index.d.ts +6 -6
- package/dist/js_render/index.d.ts.map +1 -1
- package/dist/js_render/index.js +10 -6
- package/dist/js_render/index.js.map +1 -1
- package/dist/middle_layer/active_cfg.cjs.map +1 -1
- package/dist/middle_layer/active_cfg.d.ts +3 -3
- package/dist/middle_layer/active_cfg.d.ts.map +1 -1
- package/dist/middle_layer/active_cfg.js.map +1 -1
- package/dist/middle_layer/block.cjs +1 -1
- package/dist/middle_layer/block.cjs.map +1 -1
- package/dist/middle_layer/block.d.ts +6 -6
- package/dist/middle_layer/block.d.ts.map +1 -1
- package/dist/middle_layer/block.js +1 -1
- package/dist/middle_layer/block.js.map +1 -1
- package/dist/middle_layer/block_ctx.cjs +9 -9
- package/dist/middle_layer/block_ctx.cjs.map +1 -1
- package/dist/middle_layer/block_ctx.d.ts +6 -6
- package/dist/middle_layer/block_ctx.d.ts.map +1 -1
- package/dist/middle_layer/block_ctx.js +9 -9
- package/dist/middle_layer/block_ctx.js.map +1 -1
- package/dist/middle_layer/block_ctx_unsafe.cjs +1 -1
- package/dist/middle_layer/block_ctx_unsafe.cjs.map +1 -1
- package/dist/middle_layer/block_ctx_unsafe.d.ts +5 -5
- package/dist/middle_layer/block_ctx_unsafe.js +1 -1
- package/dist/middle_layer/block_ctx_unsafe.js.map +1 -1
- package/dist/middle_layer/driver_kit.cjs +1 -2
- package/dist/middle_layer/driver_kit.cjs.map +1 -1
- package/dist/middle_layer/driver_kit.d.ts +7 -7
- package/dist/middle_layer/driver_kit.d.ts.map +1 -1
- package/dist/middle_layer/driver_kit.js +1 -2
- package/dist/middle_layer/driver_kit.js.map +1 -1
- package/dist/middle_layer/frontend_path.cjs +5 -5
- package/dist/middle_layer/frontend_path.cjs.map +1 -1
- package/dist/middle_layer/frontend_path.d.ts +4 -4
- package/dist/middle_layer/frontend_path.d.ts.map +1 -1
- package/dist/middle_layer/frontend_path.js +5 -5
- package/dist/middle_layer/frontend_path.js.map +1 -1
- package/dist/middle_layer/index.d.ts +4 -4
- package/dist/middle_layer/middle_layer.cjs +11 -11
- package/dist/middle_layer/middle_layer.cjs.map +1 -1
- package/dist/middle_layer/middle_layer.d.ts +18 -18
- package/dist/middle_layer/middle_layer.d.ts.map +1 -1
- package/dist/middle_layer/middle_layer.js +11 -11
- package/dist/middle_layer/middle_layer.js.map +1 -1
- package/dist/middle_layer/navigation_states.cjs +2 -2
- package/dist/middle_layer/navigation_states.cjs.map +1 -1
- package/dist/middle_layer/navigation_states.d.ts +2 -2
- package/dist/middle_layer/navigation_states.js +2 -2
- package/dist/middle_layer/navigation_states.js.map +1 -1
- package/dist/middle_layer/ops.cjs +5 -5
- package/dist/middle_layer/ops.cjs.map +1 -1
- package/dist/middle_layer/ops.d.ts +11 -11
- package/dist/middle_layer/ops.d.ts.map +1 -1
- package/dist/middle_layer/ops.js +5 -5
- package/dist/middle_layer/ops.js.map +1 -1
- package/dist/middle_layer/project.cjs +71 -63
- package/dist/middle_layer/project.cjs.map +1 -1
- package/dist/middle_layer/project.d.ts +10 -10
- package/dist/middle_layer/project.d.ts.map +1 -1
- package/dist/middle_layer/project.js +71 -63
- package/dist/middle_layer/project.js.map +1 -1
- package/dist/middle_layer/project_list.cjs +2 -2
- package/dist/middle_layer/project_list.cjs.map +1 -1
- package/dist/middle_layer/project_list.d.ts +6 -6
- package/dist/middle_layer/project_list.d.ts.map +1 -1
- package/dist/middle_layer/project_list.js +2 -2
- package/dist/middle_layer/project_list.js.map +1 -1
- package/dist/middle_layer/project_overview.cjs +40 -40
- package/dist/middle_layer/project_overview.cjs.map +1 -1
- package/dist/middle_layer/project_overview.d.ts +5 -5
- package/dist/middle_layer/project_overview.d.ts.map +1 -1
- package/dist/middle_layer/project_overview.js +40 -40
- package/dist/middle_layer/project_overview.js.map +1 -1
- package/dist/middle_layer/project_overview_light.cjs.map +1 -1
- package/dist/middle_layer/project_overview_light.d.ts +2 -2
- package/dist/middle_layer/project_overview_light.d.ts.map +1 -1
- package/dist/middle_layer/project_overview_light.js.map +1 -1
- package/dist/middle_layer/render.cjs +1 -1
- package/dist/middle_layer/render.cjs.map +1 -1
- package/dist/middle_layer/render.d.ts +4 -4
- package/dist/middle_layer/render.js +1 -1
- package/dist/middle_layer/render.js.map +1 -1
- package/dist/middle_layer/render.test.d.ts +2 -2
- package/dist/middle_layer/types.d.ts +3 -3
- package/dist/middle_layer/util.cjs +9 -4
- package/dist/middle_layer/util.cjs.map +1 -1
- package/dist/middle_layer/util.d.ts +4 -4
- package/dist/middle_layer/util.d.ts.map +1 -1
- package/dist/middle_layer/util.js +9 -4
- package/dist/middle_layer/util.js.map +1 -1
- package/dist/model/args.cjs +19 -15
- package/dist/model/args.cjs.map +1 -1
- package/dist/model/args.d.ts +1 -1
- package/dist/model/args.d.ts.map +1 -1
- package/dist/model/args.js +19 -15
- package/dist/model/args.js.map +1 -1
- package/dist/model/block_pack.d.ts +2 -2
- package/dist/model/block_pack_spec.cjs +3 -3
- package/dist/model/block_pack_spec.cjs.map +1 -1
- package/dist/model/block_pack_spec.d.ts +8 -8
- package/dist/model/block_pack_spec.js +3 -3
- package/dist/model/block_pack_spec.js.map +1 -1
- package/dist/model/block_storage_helper.cjs +4 -4
- package/dist/model/block_storage_helper.cjs.map +1 -1
- package/dist/model/block_storage_helper.d.ts +2 -2
- package/dist/model/block_storage_helper.d.ts.map +1 -1
- package/dist/model/block_storage_helper.js +4 -4
- package/dist/model/block_storage_helper.js.map +1 -1
- package/dist/model/index.d.ts +3 -3
- package/dist/model/project_helper.cjs +30 -13
- package/dist/model/project_helper.cjs.map +1 -1
- package/dist/model/project_helper.d.ts +4 -4
- package/dist/model/project_helper.d.ts.map +1 -1
- package/dist/model/project_helper.js +30 -13
- package/dist/model/project_helper.js.map +1 -1
- package/dist/model/project_model.cjs +23 -23
- package/dist/model/project_model.cjs.map +1 -1
- package/dist/model/project_model.d.ts +6 -6
- package/dist/model/project_model.d.ts.map +1 -1
- package/dist/model/project_model.js +23 -23
- package/dist/model/project_model.js.map +1 -1
- package/dist/model/project_model_util.cjs +2 -2
- package/dist/model/project_model_util.cjs.map +1 -1
- package/dist/model/project_model_util.d.ts +3 -3
- package/dist/model/project_model_util.d.ts.map +1 -1
- package/dist/model/project_model_util.js +2 -2
- package/dist/model/project_model_util.js.map +1 -1
- package/dist/model/project_model_v1.cjs +2 -2
- package/dist/model/project_model_v1.cjs.map +1 -1
- package/dist/model/project_model_v1.js +2 -2
- package/dist/model/project_model_v1.js.map +1 -1
- package/dist/model/template_spec.d.ts +5 -5
- package/dist/mutator/block-pack/block_pack.cjs +43 -43
- package/dist/mutator/block-pack/block_pack.cjs.map +1 -1
- package/dist/mutator/block-pack/block_pack.d.ts +6 -6
- package/dist/mutator/block-pack/block_pack.d.ts.map +1 -1
- package/dist/mutator/block-pack/block_pack.js +43 -43
- package/dist/mutator/block-pack/block_pack.js.map +1 -1
- package/dist/mutator/block-pack/frontend.cjs +2 -2
- package/dist/mutator/block-pack/frontend.cjs.map +1 -1
- package/dist/mutator/block-pack/frontend.d.ts +2 -2
- package/dist/mutator/block-pack/frontend.d.ts.map +1 -1
- package/dist/mutator/block-pack/frontend.js +2 -2
- package/dist/mutator/block-pack/frontend.js.map +1 -1
- package/dist/mutator/context_export.cjs +5 -5
- package/dist/mutator/context_export.cjs.map +1 -1
- package/dist/mutator/context_export.d.ts +2 -2
- package/dist/mutator/context_export.d.ts.map +1 -1
- package/dist/mutator/context_export.js +5 -5
- package/dist/mutator/context_export.js.map +1 -1
- package/dist/mutator/migration.cjs +7 -7
- package/dist/mutator/migration.cjs.map +1 -1
- package/dist/mutator/migration.d.ts +1 -1
- package/dist/mutator/migration.d.ts.map +1 -1
- package/dist/mutator/migration.js +7 -7
- package/dist/mutator/migration.js.map +1 -1
- package/dist/mutator/project.cjs +147 -148
- package/dist/mutator/project.cjs.map +1 -1
- package/dist/mutator/project.d.ts +13 -13
- package/dist/mutator/project.d.ts.map +1 -1
- package/dist/mutator/project.js +147 -148
- package/dist/mutator/project.js.map +1 -1
- package/dist/mutator/template/direct_template_loader.cjs +16 -16
- package/dist/mutator/template/direct_template_loader.cjs.map +1 -1
- package/dist/mutator/template/direct_template_loader.d.ts +2 -2
- package/dist/mutator/template/direct_template_loader.d.ts.map +1 -1
- package/dist/mutator/template/direct_template_loader.js +16 -16
- package/dist/mutator/template/direct_template_loader.js.map +1 -1
- package/dist/mutator/template/direct_template_loader_v3.cjs +13 -13
- package/dist/mutator/template/direct_template_loader_v3.cjs.map +1 -1
- package/dist/mutator/template/direct_template_loader_v3.d.ts +3 -3
- package/dist/mutator/template/direct_template_loader_v3.d.ts.map +1 -1
- package/dist/mutator/template/direct_template_loader_v3.js +13 -13
- package/dist/mutator/template/direct_template_loader_v3.js.map +1 -1
- package/dist/mutator/template/render_block.cjs +7 -7
- package/dist/mutator/template/render_block.cjs.map +1 -1
- package/dist/mutator/template/render_block.d.ts +1 -1
- package/dist/mutator/template/render_block.d.ts.map +1 -1
- package/dist/mutator/template/render_block.js +7 -7
- package/dist/mutator/template/render_block.js.map +1 -1
- package/dist/mutator/template/render_template.cjs +10 -10
- package/dist/mutator/template/render_template.cjs.map +1 -1
- package/dist/mutator/template/render_template.d.ts +2 -2
- package/dist/mutator/template/render_template.js +10 -10
- package/dist/mutator/template/render_template.js.map +1 -1
- package/dist/mutator/template/template_loading.cjs +17 -17
- package/dist/mutator/template/template_loading.cjs.map +1 -1
- package/dist/mutator/template/template_loading.d.ts +2 -2
- package/dist/mutator/template/template_loading.js +17 -17
- package/dist/mutator/template/template_loading.js.map +1 -1
- package/dist/network_check/network_check.cjs +33 -32
- package/dist/network_check/network_check.cjs.map +1 -1
- package/dist/network_check/network_check.d.ts +6 -6
- package/dist/network_check/network_check.d.ts.map +1 -1
- package/dist/network_check/network_check.js +33 -32
- package/dist/network_check/network_check.js.map +1 -1
- package/dist/network_check/pings.cjs +3 -3
- package/dist/network_check/pings.cjs.map +1 -1
- package/dist/network_check/pings.d.ts +4 -4
- package/dist/network_check/pings.d.ts.map +1 -1
- package/dist/network_check/pings.js +3 -3
- package/dist/network_check/pings.js.map +1 -1
- package/dist/network_check/template.cjs +57 -44
- package/dist/network_check/template.cjs.map +1 -1
- package/dist/network_check/template.d.ts +8 -8
- package/dist/network_check/template.d.ts.map +1 -1
- package/dist/network_check/template.js +57 -44
- package/dist/network_check/template.js.map +1 -1
- package/dist/pool/data.cjs +45 -33
- package/dist/pool/data.cjs.map +1 -1
- package/dist/pool/data.d.ts +3 -3
- package/dist/pool/data.d.ts.map +1 -1
- package/dist/pool/data.js +45 -33
- package/dist/pool/data.js.map +1 -1
- package/dist/pool/driver.cjs +18 -16
- package/dist/pool/driver.cjs.map +1 -1
- package/dist/pool/driver.d.ts +5 -5
- package/dist/pool/driver.d.ts.map +1 -1
- package/dist/pool/driver.js +18 -16
- package/dist/pool/driver.js.map +1 -1
- package/dist/pool/index.d.ts +2 -2
- package/dist/pool/p_object_collection.cjs +5 -5
- package/dist/pool/p_object_collection.cjs.map +1 -1
- package/dist/pool/p_object_collection.d.ts +2 -2
- package/dist/pool/p_object_collection.d.ts.map +1 -1
- package/dist/pool/p_object_collection.js +5 -5
- package/dist/pool/p_object_collection.js.map +1 -1
- package/dist/pool/result_pool.cjs +6 -6
- package/dist/pool/result_pool.cjs.map +1 -1
- package/dist/pool/result_pool.d.ts +6 -6
- package/dist/pool/result_pool.d.ts.map +1 -1
- package/dist/pool/result_pool.js +6 -6
- package/dist/pool/result_pool.js.map +1 -1
- package/dist/test/block_packs.d.ts +2 -2
- package/dist/test/known_templates.d.ts +1 -1
- package/dist/worker/WorkerManager.cjs +7 -8
- package/dist/worker/WorkerManager.cjs.map +1 -1
- package/dist/worker/WorkerManager.d.ts +2 -2
- package/dist/worker/WorkerManager.d.ts.map +1 -1
- package/dist/worker/WorkerManager.js +7 -8
- package/dist/worker/WorkerManager.js.map +1 -1
- package/dist/worker/worker.cjs +6 -4
- package/dist/worker/worker.cjs.map +1 -1
- package/dist/worker/worker.js +6 -4
- package/dist/worker/worker.js.map +1 -1
- package/dist/worker/workerApi.cjs.map +1 -1
- package/dist/worker/workerApi.js.map +1 -1
- package/package.json +41 -41
- package/src/block_registry/index.ts +3 -3
- package/src/block_registry/registry-v2-provider.ts +2 -2
- package/src/block_registry/registry.test.ts +17 -17
- package/src/block_registry/registry.ts +55 -60
- package/src/block_registry/watcher.ts +24 -23
- package/src/block_registry/well_known_registries.ts +7 -7
- package/src/cfg_render/executor.test.ts +36 -36
- package/src/cfg_render/executor.ts +24 -24
- package/src/cfg_render/operation.ts +5 -5
- package/src/cfg_render/renderer.ts +96 -93
- package/src/cfg_render/traverse.ts +50 -50
- package/src/cfg_render/util.ts +3 -3
- package/src/debug/index.ts +6 -4
- package/src/dev_env/index.ts +16 -16
- package/src/dev_env/util.ts +3 -3
- package/src/index.ts +16 -16
- package/src/js_render/computable_context.ts +143 -126
- package/src/js_render/context.ts +72 -44
- package/src/js_render/index.ts +51 -24
- package/src/middle_layer/active_cfg.ts +14 -12
- package/src/middle_layer/block.ts +30 -23
- package/src/middle_layer/block_ctx.ts +27 -31
- package/src/middle_layer/block_ctx_unsafe.ts +9 -9
- package/src/middle_layer/driver_kit.ts +13 -19
- package/src/middle_layer/frontend_path.ts +18 -23
- package/src/middle_layer/index.ts +4 -4
- package/src/middle_layer/middle_layer.ts +57 -55
- package/src/middle_layer/navigation_states.ts +6 -6
- package/src/middle_layer/ops.ts +43 -42
- package/src/middle_layer/project.ts +274 -173
- package/src/middle_layer/project_list.ts +14 -15
- package/src/middle_layer/project_overview.ts +104 -113
- package/src/middle_layer/project_overview_light.ts +7 -9
- package/src/middle_layer/render.test.ts +49 -48
- package/src/middle_layer/render.ts +9 -9
- package/src/middle_layer/types.ts +3 -3
- package/src/middle_layer/util.ts +17 -12
- package/src/model/args.ts +22 -19
- package/src/model/block_pack.ts +2 -2
- package/src/model/block_pack_spec.ts +11 -11
- package/src/model/block_storage_helper.ts +11 -11
- package/src/model/index.ts +3 -3
- package/src/model/project_helper.ts +78 -32
- package/src/model/project_model.test.ts +5 -9
- package/src/model/project_model.ts +48 -49
- package/src/model/project_model_util.test.ts +86 -53
- package/src/model/project_model_util.ts +18 -14
- package/src/model/project_model_v1.ts +3 -3
- package/src/model/template_spec.ts +5 -5
- package/src/mutator/block-pack/block_pack.test.ts +25 -25
- package/src/mutator/block-pack/block_pack.ts +70 -68
- package/src/mutator/block-pack/frontend.ts +6 -13
- package/src/mutator/context_export.ts +12 -10
- package/src/mutator/migration.ts +20 -14
- package/src/mutator/project-v3.test.ts +123 -118
- package/src/mutator/project.test.ts +105 -94
- package/src/mutator/project.ts +357 -274
- package/src/mutator/template/direct_template_loader.ts +26 -32
- package/src/mutator/template/direct_template_loader_v3.ts +51 -25
- package/src/mutator/template/render_block.ts +14 -21
- package/src/mutator/template/render_template.ts +13 -13
- package/src/mutator/template/template_loading.ts +23 -23
- package/src/mutator/template/template_render.test.ts +87 -86
- package/src/network_check/network_check.test.ts +4 -4
- package/src/network_check/network_check.ts +102 -79
- package/src/network_check/pings.ts +35 -16
- package/src/network_check/template.test.ts +47 -44
- package/src/network_check/template.ts +151 -95
- package/src/network_check/test_utils.ts +1 -1
- package/src/pool/data.ts +81 -69
- package/src/pool/driver.ts +56 -51
- package/src/pool/index.ts +2 -2
- package/src/pool/p_object_collection.ts +16 -15
- package/src/pool/result_pool.ts +23 -34
- package/src/test/block_packs.ts +15 -15
- package/src/test/explicit_templates.ts +4 -4
- package/src/test/known_templates.ts +10 -10
- package/src/test_env.ts +1 -1
- package/src/worker/WorkerManager.ts +22 -18
- package/src/worker/worker.ts +11 -9
- package/src/worker/workerApi.ts +1 -1
package/src/mutator/project.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
ResourceData,
|
|
7
7
|
ResourceId,
|
|
8
8
|
TxOps,
|
|
9
|
-
} from
|
|
9
|
+
} from "@milaboratories/pl-client";
|
|
10
10
|
import {
|
|
11
11
|
ensureResourceIdNotNull,
|
|
12
12
|
field,
|
|
@@ -17,13 +17,14 @@ import {
|
|
|
17
17
|
isResourceRef,
|
|
18
18
|
Pl,
|
|
19
19
|
PlClient,
|
|
20
|
-
} from
|
|
21
|
-
import { createRenderHeavyBlock, createBContextFromUpstreams } from
|
|
20
|
+
} from "@milaboratories/pl-client";
|
|
21
|
+
import { createRenderHeavyBlock, createBContextFromUpstreams } from "./template/render_block";
|
|
22
22
|
import type {
|
|
23
23
|
Block,
|
|
24
24
|
ProjectStructure,
|
|
25
25
|
ProjectField,
|
|
26
|
-
ProjectRenderingState
|
|
26
|
+
ProjectRenderingState,
|
|
27
|
+
} from "../model/project_model";
|
|
27
28
|
import {
|
|
28
29
|
BlockRenderingStateKey,
|
|
29
30
|
ProjectStructureKey,
|
|
@@ -42,37 +43,33 @@ import {
|
|
|
42
43
|
ProjectStructureAuthorKey,
|
|
43
44
|
getServiceTemplateField,
|
|
44
45
|
FieldsToDuplicate,
|
|
45
|
-
} from
|
|
46
|
-
import { BlockPackTemplateField, createBlockPack } from
|
|
47
|
-
import type {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
import {
|
|
51
|
-
allBlocks,
|
|
52
|
-
graphDiff,
|
|
53
|
-
productionGraph,
|
|
54
|
-
stagingGraph,
|
|
55
|
-
} from '../model/project_model_util';
|
|
56
|
-
import type { BlockPackSpecPrepared } from '../model';
|
|
46
|
+
} from "../model/project_model";
|
|
47
|
+
import { BlockPackTemplateField, createBlockPack } from "./block-pack/block_pack";
|
|
48
|
+
import type { BlockGraph, ProductionGraphBlockInfo } from "../model/project_model_util";
|
|
49
|
+
import { allBlocks, graphDiff, productionGraph, stagingGraph } from "../model/project_model_util";
|
|
50
|
+
import type { BlockPackSpecPrepared } from "../model";
|
|
57
51
|
import type {
|
|
58
52
|
AuthorMarker,
|
|
59
53
|
BlockPackSpec,
|
|
60
54
|
BlockSettings,
|
|
61
55
|
ProjectMeta,
|
|
62
|
-
} from
|
|
56
|
+
} from "@milaboratories/pl-model-middle-layer";
|
|
57
|
+
import { InitialBlockSettings } from "@milaboratories/pl-model-middle-layer";
|
|
58
|
+
import Denque from "denque";
|
|
59
|
+
import { exportContext, getPreparedExportTemplateEnvelope } from "./context_export";
|
|
60
|
+
import { loadTemplate } from "./template/template_loading";
|
|
63
61
|
import {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
import {
|
|
70
|
-
import type
|
|
71
|
-
import {
|
|
72
|
-
import {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
type FieldStatus = 'NotReady' | 'Ready' | 'Error';
|
|
62
|
+
cachedDeserialize,
|
|
63
|
+
notEmpty,
|
|
64
|
+
canonicalJsonBytes,
|
|
65
|
+
cachedDecode,
|
|
66
|
+
} from "@milaboratories/ts-helpers";
|
|
67
|
+
import type { ProjectHelper } from "../model/project_helper";
|
|
68
|
+
import { extractConfig, UiError, type BlockConfig } from "@platforma-sdk/model";
|
|
69
|
+
import { getDebugFlags } from "../debug";
|
|
70
|
+
import type { BlockPackInfo } from "../model/block_pack";
|
|
71
|
+
|
|
72
|
+
type FieldStatus = "NotReady" | "Ready" | "Error";
|
|
76
73
|
|
|
77
74
|
interface BlockFieldState {
|
|
78
75
|
modCount: number;
|
|
@@ -81,8 +78,8 @@ interface BlockFieldState {
|
|
|
81
78
|
value?: Uint8Array;
|
|
82
79
|
}
|
|
83
80
|
|
|
84
|
-
type BlockFieldStates = Partial<Record<ProjectField[
|
|
85
|
-
type BlockFieldStateValue = Omit<BlockFieldState,
|
|
81
|
+
type BlockFieldStates = Partial<Record<ProjectField["fieldName"], BlockFieldState>>;
|
|
82
|
+
type BlockFieldStateValue = Omit<BlockFieldState, "modCount">;
|
|
86
83
|
|
|
87
84
|
interface BlockInfoState {
|
|
88
85
|
readonly id: string;
|
|
@@ -123,26 +120,26 @@ class BlockInfo {
|
|
|
123
120
|
// state assertions
|
|
124
121
|
|
|
125
122
|
if ((this.fields.prodOutput === undefined) !== (this.fields.prodCtx === undefined))
|
|
126
|
-
throw new Error(
|
|
123
|
+
throw new Error("inconsistent prod fields");
|
|
127
124
|
|
|
128
125
|
if ((this.fields.stagingOutput === undefined) !== (this.fields.stagingCtx === undefined))
|
|
129
|
-
throw new Error(
|
|
126
|
+
throw new Error("inconsistent stage fields");
|
|
130
127
|
|
|
131
128
|
if (
|
|
132
|
-
(this.fields.prodOutputPrevious === undefined)
|
|
133
|
-
|
|
129
|
+
(this.fields.prodOutputPrevious === undefined) !==
|
|
130
|
+
(this.fields.prodCtxPrevious === undefined)
|
|
134
131
|
)
|
|
135
|
-
throw new Error(
|
|
132
|
+
throw new Error("inconsistent prod cache fields");
|
|
136
133
|
|
|
137
134
|
if (
|
|
138
|
-
(this.fields.stagingOutputPrevious === undefined)
|
|
139
|
-
|
|
135
|
+
(this.fields.stagingOutputPrevious === undefined) !==
|
|
136
|
+
(this.fields.stagingCtxPrevious === undefined)
|
|
140
137
|
)
|
|
141
|
-
throw new Error(
|
|
138
|
+
throw new Error("inconsistent stage cache fields");
|
|
142
139
|
|
|
143
|
-
if (this.fields.blockPack === undefined) throw new Error(
|
|
140
|
+
if (this.fields.blockPack === undefined) throw new Error("no block pack field");
|
|
144
141
|
|
|
145
|
-
if (this.fields.blockStorage === undefined) throw new Error(
|
|
142
|
+
if (this.fields.blockStorage === undefined) throw new Error("no block storage field");
|
|
146
143
|
}
|
|
147
144
|
|
|
148
145
|
private readonly currentArgsC = cached(
|
|
@@ -198,7 +195,7 @@ class BlockInfo {
|
|
|
198
195
|
try {
|
|
199
196
|
return this.blockStorageC();
|
|
200
197
|
} catch (e) {
|
|
201
|
-
console.error(
|
|
198
|
+
console.error("Error getting blockStorage:", e);
|
|
202
199
|
return undefined;
|
|
203
200
|
}
|
|
204
201
|
}
|
|
@@ -220,14 +217,14 @@ class BlockInfo {
|
|
|
220
217
|
}
|
|
221
218
|
|
|
222
219
|
get productionHasErrors(): boolean {
|
|
223
|
-
return this.fields.prodUiCtx?.status ===
|
|
220
|
+
return this.fields.prodUiCtx?.status === "Error";
|
|
224
221
|
}
|
|
225
222
|
|
|
226
223
|
private readonly productionStaleC: () => boolean = cached(
|
|
227
224
|
() => `${this.fields.currentArgs!.modCount}_${this.fields.prodArgs?.modCount}`,
|
|
228
225
|
() =>
|
|
229
|
-
this.fields.prodArgs === undefined
|
|
230
|
-
|
|
226
|
+
this.fields.prodArgs === undefined ||
|
|
227
|
+
Buffer.compare(this.fields.currentArgs!.value!, this.fields.prodArgs.value!) !== 0,
|
|
231
228
|
);
|
|
232
229
|
|
|
233
230
|
get requireProductionRendering(): boolean {
|
|
@@ -249,7 +246,7 @@ class BlockInfo {
|
|
|
249
246
|
return tx.getFutureFieldValue(
|
|
250
247
|
Pl.unwrapHolder(tx, this.fields.blockPack!.ref!),
|
|
251
248
|
BlockPackTemplateField,
|
|
252
|
-
|
|
249
|
+
"Input",
|
|
253
250
|
);
|
|
254
251
|
}
|
|
255
252
|
}
|
|
@@ -260,8 +257,8 @@ class BlockInfo {
|
|
|
260
257
|
*/
|
|
261
258
|
/** Specification for creating a new block. Discriminated union based on `storageMode`. */
|
|
262
259
|
export type NewBlockSpec =
|
|
263
|
-
| { storageMode:
|
|
264
|
-
| { storageMode:
|
|
260
|
+
| { storageMode: "fromModel"; blockPack: BlockPackSpecPrepared }
|
|
261
|
+
| { storageMode: "legacy"; blockPack: BlockPackSpecPrepared; legacyState: string };
|
|
265
262
|
|
|
266
263
|
const NoNewBlocks = (blockId: string) => {
|
|
267
264
|
throw new Error(`No new block info for ${blockId}`);
|
|
@@ -272,17 +269,19 @@ const NoNewBlocks = (blockId: string) => {
|
|
|
272
269
|
* For v3 blocks: state is the block's state
|
|
273
270
|
* For v1/v2 blocks: state should be { args, uiState } format
|
|
274
271
|
*/
|
|
275
|
-
export type SetStatesRequest =
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
};
|
|
272
|
+
export type SetStatesRequest =
|
|
273
|
+
| {
|
|
274
|
+
blockId: string;
|
|
275
|
+
/** The unified state to set */
|
|
276
|
+
state: unknown;
|
|
277
|
+
modelAPIVersion: 1;
|
|
278
|
+
}
|
|
279
|
+
| {
|
|
280
|
+
blockId: string;
|
|
281
|
+
/** Storage operation payload - middle layer is agnostic to specific operations */
|
|
282
|
+
payload: { operation: string; value: unknown };
|
|
283
|
+
modelAPIVersion: 2;
|
|
284
|
+
};
|
|
286
285
|
|
|
287
286
|
export type ClearState = {
|
|
288
287
|
state: unknown;
|
|
@@ -312,7 +311,7 @@ export class ProjectMutator {
|
|
|
312
311
|
private lastModified: number,
|
|
313
312
|
private meta: ProjectMeta,
|
|
314
313
|
private struct: ProjectStructure,
|
|
315
|
-
private readonly renderingState: Omit<ProjectRenderingState,
|
|
314
|
+
private readonly renderingState: Omit<ProjectRenderingState, "blocksInLimbo">,
|
|
316
315
|
private readonly blocksInLimbo: Set<string>,
|
|
317
316
|
private readonly blockInfos: Map<string, BlockInfo>,
|
|
318
317
|
private readonly ctxExportTplHolder: AnyResourceRef,
|
|
@@ -323,31 +322,31 @@ export class ProjectMutator {
|
|
|
323
322
|
// Fixing problems introduced by old code
|
|
324
323
|
this.blockInfos.forEach((blockInfo) => {
|
|
325
324
|
if (
|
|
326
|
-
blockInfo.fields.prodArgs === undefined
|
|
327
|
-
|
|
328
|
-
|
|
325
|
+
blockInfo.fields.prodArgs === undefined ||
|
|
326
|
+
blockInfo.fields.prodOutput === undefined ||
|
|
327
|
+
blockInfo.fields.prodCtx === undefined
|
|
329
328
|
)
|
|
330
|
-
this.deleteBlockFields(blockInfo.id,
|
|
329
|
+
this.deleteBlockFields(blockInfo.id, "prodArgs", "prodOutput", "prodCtx");
|
|
331
330
|
});
|
|
332
331
|
|
|
333
332
|
// Migration for addition of block settings field
|
|
334
|
-
let initialBlockSettings: Omit<BlockFieldState,
|
|
333
|
+
let initialBlockSettings: Omit<BlockFieldState, "modCount"> | undefined;
|
|
335
334
|
this.blockInfos.forEach((blockInfo) => {
|
|
336
335
|
if (blockInfo.fields.blockSettings === undefined) {
|
|
337
336
|
if (initialBlockSettings === undefined)
|
|
338
337
|
initialBlockSettings = this.createJsonFieldValue(InitialBlockSettings);
|
|
339
|
-
this.setBlockFieldObj(blockInfo.id,
|
|
338
|
+
this.setBlockFieldObj(blockInfo.id, "blockSettings", initialBlockSettings);
|
|
340
339
|
}
|
|
341
340
|
});
|
|
342
341
|
}
|
|
343
342
|
|
|
344
343
|
get wasModified(): boolean {
|
|
345
344
|
return (
|
|
346
|
-
this.lastModifiedChanged
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
345
|
+
this.lastModifiedChanged ||
|
|
346
|
+
this.structureChanged ||
|
|
347
|
+
this.fieldsChanged ||
|
|
348
|
+
this.metaChanged ||
|
|
349
|
+
this.renderingStateChanged
|
|
351
350
|
);
|
|
352
351
|
}
|
|
353
352
|
|
|
@@ -368,7 +367,10 @@ export class ProjectMutator {
|
|
|
368
367
|
return this.stagingGraph;
|
|
369
368
|
}
|
|
370
369
|
|
|
371
|
-
private getProductionGraphBlockInfo(
|
|
370
|
+
private getProductionGraphBlockInfo(
|
|
371
|
+
blockId: string,
|
|
372
|
+
prod: boolean,
|
|
373
|
+
): ProductionGraphBlockInfo | undefined {
|
|
372
374
|
const bInfo = this.getBlockInfo(blockId);
|
|
373
375
|
|
|
374
376
|
let argsField: BlockFieldState | undefined;
|
|
@@ -393,30 +395,34 @@ export class ProjectMutator {
|
|
|
393
395
|
if (isResourceId(argsField.ref!) && isResourceId(blockPackField.ref!))
|
|
394
396
|
return {
|
|
395
397
|
args,
|
|
396
|
-
enrichmentTargets: this.projectHelper.getEnrichmentTargets(
|
|
397
|
-
|
|
398
|
+
enrichmentTargets: this.projectHelper.getEnrichmentTargets(
|
|
399
|
+
() => bInfo.config,
|
|
400
|
+
() => args,
|
|
401
|
+
{ argsRid: argsField.ref, blockPackRid: blockPackField.ref },
|
|
402
|
+
),
|
|
398
403
|
};
|
|
399
404
|
else
|
|
400
405
|
return {
|
|
401
406
|
args,
|
|
402
|
-
enrichmentTargets: this.projectHelper.getEnrichmentTargets(
|
|
407
|
+
enrichmentTargets: this.projectHelper.getEnrichmentTargets(
|
|
408
|
+
() => bInfo.config,
|
|
409
|
+
() => args,
|
|
410
|
+
),
|
|
403
411
|
};
|
|
404
412
|
}
|
|
405
413
|
|
|
406
414
|
private getPendingProductionGraph(): BlockGraph {
|
|
407
415
|
if (this.pendingProductionGraph === undefined)
|
|
408
|
-
this.pendingProductionGraph = productionGraph(
|
|
409
|
-
this.
|
|
410
|
-
(blockId) => this.getProductionGraphBlockInfo(blockId, false),
|
|
416
|
+
this.pendingProductionGraph = productionGraph(this.struct, (blockId) =>
|
|
417
|
+
this.getProductionGraphBlockInfo(blockId, false),
|
|
411
418
|
);
|
|
412
419
|
return this.pendingProductionGraph;
|
|
413
420
|
}
|
|
414
421
|
|
|
415
422
|
private getActualProductionGraph(): BlockGraph {
|
|
416
423
|
if (this.actualProductionGraph === undefined)
|
|
417
|
-
this.actualProductionGraph = productionGraph(
|
|
418
|
-
this.
|
|
419
|
-
(blockId) => this.getProductionGraphBlockInfo(blockId, true),
|
|
424
|
+
this.actualProductionGraph = productionGraph(this.struct, (blockId) =>
|
|
425
|
+
this.getProductionGraphBlockInfo(blockId, true),
|
|
420
426
|
);
|
|
421
427
|
return this.actualProductionGraph;
|
|
422
428
|
}
|
|
@@ -432,10 +438,10 @@ export class ProjectMutator {
|
|
|
432
438
|
}
|
|
433
439
|
|
|
434
440
|
private createJsonFieldValueByContent(content: string): BlockFieldStateValue {
|
|
435
|
-
if (content === undefined) throw new Error(
|
|
441
|
+
if (content === undefined) throw new Error("content is undefined");
|
|
436
442
|
const value = Buffer.from(content);
|
|
437
443
|
const ref = this.tx.createValue(Pl.JsonObject, value);
|
|
438
|
-
return { ref, value, status:
|
|
444
|
+
return { ref, value, status: "Ready" };
|
|
439
445
|
}
|
|
440
446
|
|
|
441
447
|
private createJsonFieldValue(obj: unknown): BlockFieldStateValue {
|
|
@@ -444,7 +450,7 @@ export class ProjectMutator {
|
|
|
444
450
|
|
|
445
451
|
private getBlock(blockId: string): Block {
|
|
446
452
|
for (const block of allBlocks(this.struct)) if (block.id === blockId) return block;
|
|
447
|
-
throw new Error(
|
|
453
|
+
throw new Error("block not found");
|
|
448
454
|
}
|
|
449
455
|
|
|
450
456
|
private setBlockFieldObj(
|
|
@@ -454,10 +460,10 @@ export class ProjectMutator {
|
|
|
454
460
|
) {
|
|
455
461
|
const fid = field(this.rid, projectFieldName(blockId, fieldName));
|
|
456
462
|
|
|
457
|
-
if (state.ref === undefined) throw new Error(
|
|
463
|
+
if (state.ref === undefined) throw new Error("Can't set value with empty ref");
|
|
458
464
|
|
|
459
465
|
if (this.getBlockInfo(blockId).fields[fieldName] === undefined)
|
|
460
|
-
this.tx.createField(fid,
|
|
466
|
+
this.tx.createField(fid, "Dynamic", state.ref);
|
|
461
467
|
else this.tx.setField(fid, state.ref);
|
|
462
468
|
|
|
463
469
|
this.getBlockInfo(blockId).fields[fieldName] = {
|
|
@@ -509,30 +515,30 @@ export class ProjectMutator {
|
|
|
509
515
|
private resetStaging(blockId: string): void {
|
|
510
516
|
const fields = this.getBlockInfo(blockId).fields;
|
|
511
517
|
if (
|
|
512
|
-
fields.stagingOutput?.status ===
|
|
513
|
-
|
|
514
|
-
|
|
518
|
+
fields.stagingOutput?.status === "Ready" &&
|
|
519
|
+
fields.stagingCtx?.status === "Ready" &&
|
|
520
|
+
fields.stagingUiCtx?.status === "Ready"
|
|
515
521
|
) {
|
|
516
|
-
this.setBlockFieldObj(blockId,
|
|
517
|
-
this.setBlockFieldObj(blockId,
|
|
518
|
-
this.setBlockFieldObj(blockId,
|
|
522
|
+
this.setBlockFieldObj(blockId, "stagingOutputPrevious", fields.stagingOutput);
|
|
523
|
+
this.setBlockFieldObj(blockId, "stagingCtxPrevious", fields.stagingCtx);
|
|
524
|
+
this.setBlockFieldObj(blockId, "stagingUiCtxPrevious", fields.stagingUiCtx);
|
|
519
525
|
}
|
|
520
|
-
if (this.deleteBlockFields(blockId,
|
|
526
|
+
if (this.deleteBlockFields(blockId, "stagingOutput", "stagingCtx", "stagingUiCtx"))
|
|
521
527
|
this.resetStagingRefreshTimestamp();
|
|
522
528
|
}
|
|
523
529
|
|
|
524
530
|
private resetProduction(blockId: string): void {
|
|
525
531
|
const fields = this.getBlockInfo(blockId).fields;
|
|
526
532
|
if (
|
|
527
|
-
fields.prodOutput?.status ===
|
|
528
|
-
|
|
529
|
-
|
|
533
|
+
fields.prodOutput?.status === "Ready" &&
|
|
534
|
+
fields.prodCtx?.status === "Ready" &&
|
|
535
|
+
fields.prodUiCtx?.status === "Ready"
|
|
530
536
|
) {
|
|
531
|
-
this.setBlockFieldObj(blockId,
|
|
532
|
-
this.setBlockFieldObj(blockId,
|
|
533
|
-
this.setBlockFieldObj(blockId,
|
|
537
|
+
this.setBlockFieldObj(blockId, "prodOutputPrevious", fields.prodOutput);
|
|
538
|
+
this.setBlockFieldObj(blockId, "prodCtxPrevious", fields.prodCtx);
|
|
539
|
+
this.setBlockFieldObj(blockId, "prodUiCtxPrevious", fields.prodUiCtx);
|
|
534
540
|
}
|
|
535
|
-
this.deleteBlockFields(blockId,
|
|
541
|
+
this.deleteBlockFields(blockId, "prodOutput", "prodCtx", "prodUiCtx", "prodArgs");
|
|
536
542
|
}
|
|
537
543
|
|
|
538
544
|
/** Running blocks are reset, already computed moved to limbo. Returns if
|
|
@@ -542,7 +548,7 @@ export class ProjectMutator {
|
|
|
542
548
|
const fields = this.getBlockInfo(blockId).fields;
|
|
543
549
|
|
|
544
550
|
// Check if we can safely move to limbo (both core production fields are ready)
|
|
545
|
-
if (fields.prodOutput?.status ===
|
|
551
|
+
if (fields.prodOutput?.status === "Ready" && fields.prodCtx?.status === "Ready") {
|
|
546
552
|
if (this.blocksInLimbo.has(blockId))
|
|
547
553
|
// we are already in limbo
|
|
548
554
|
return false;
|
|
@@ -552,20 +558,20 @@ export class ProjectMutator {
|
|
|
552
558
|
this.renderingStateChanged = true;
|
|
553
559
|
|
|
554
560
|
// doing some gc - clean up previous cache fields
|
|
555
|
-
this.deleteBlockFields(blockId,
|
|
561
|
+
this.deleteBlockFields(blockId, "prodOutputPrevious", "prodCtxPrevious", "prodUiCtxPrevious");
|
|
556
562
|
|
|
557
563
|
return true;
|
|
558
564
|
} else {
|
|
559
565
|
// reset - clean up any partial/inconsistent production stat
|
|
560
566
|
return this.deleteBlockFields(
|
|
561
567
|
blockId,
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
568
|
+
"prodOutput",
|
|
569
|
+
"prodCtx",
|
|
570
|
+
"prodUiCtx",
|
|
571
|
+
"prodArgs",
|
|
572
|
+
"prodOutputPrevious",
|
|
573
|
+
"prodCtxPrevious",
|
|
574
|
+
"prodUiCtxPrevious",
|
|
569
575
|
);
|
|
570
576
|
}
|
|
571
577
|
}
|
|
@@ -595,7 +601,11 @@ export class ProjectMutator {
|
|
|
595
601
|
* @param rawStorageJson Raw storage as JSON string
|
|
596
602
|
*/
|
|
597
603
|
public setBlockStorageRaw(blockId: string, rawStorageJson: string): void {
|
|
598
|
-
this.setBlockFieldObj(
|
|
604
|
+
this.setBlockFieldObj(
|
|
605
|
+
blockId,
|
|
606
|
+
"blockStorage",
|
|
607
|
+
this.createJsonFieldValueByContent(rawStorageJson),
|
|
608
|
+
);
|
|
599
609
|
this.blocksWithChangedInputs.add(blockId);
|
|
600
610
|
this.updateLastModified();
|
|
601
611
|
}
|
|
@@ -613,7 +623,7 @@ export class ProjectMutator {
|
|
|
613
623
|
const blockConfig = info.config;
|
|
614
624
|
|
|
615
625
|
if (blockConfig.modelAPIVersion !== 2) {
|
|
616
|
-
throw new Error(
|
|
626
|
+
throw new Error("resetToInitialStorage is only supported for model API version 2");
|
|
617
627
|
}
|
|
618
628
|
|
|
619
629
|
// Get initial storage from VM
|
|
@@ -621,16 +631,26 @@ export class ProjectMutator {
|
|
|
621
631
|
this.setBlockStorageRaw(blockId, initialStorageJson);
|
|
622
632
|
|
|
623
633
|
// Derive args from storage - set or clear currentArgs based on derivation result
|
|
624
|
-
const deriveArgsResult = this.projectHelper.deriveArgsFromStorage(
|
|
634
|
+
const deriveArgsResult = this.projectHelper.deriveArgsFromStorage(
|
|
635
|
+
blockConfig,
|
|
636
|
+
initialStorageJson,
|
|
637
|
+
);
|
|
625
638
|
if (!deriveArgsResult.error) {
|
|
626
|
-
this.setBlockFieldObj(
|
|
639
|
+
this.setBlockFieldObj(
|
|
640
|
+
blockId,
|
|
641
|
+
"currentArgs",
|
|
642
|
+
this.createJsonFieldValue(deriveArgsResult.value),
|
|
643
|
+
);
|
|
627
644
|
// Derive prerunArgs from storage
|
|
628
|
-
const prerunArgs = this.projectHelper.derivePrerunArgsFromStorage(
|
|
645
|
+
const prerunArgs = this.projectHelper.derivePrerunArgsFromStorage(
|
|
646
|
+
blockConfig,
|
|
647
|
+
initialStorageJson,
|
|
648
|
+
);
|
|
629
649
|
if (prerunArgs !== undefined) {
|
|
630
|
-
this.setBlockFieldObj(blockId,
|
|
650
|
+
this.setBlockFieldObj(blockId, "currentPrerunArgs", this.createJsonFieldValue(prerunArgs));
|
|
631
651
|
}
|
|
632
652
|
} else {
|
|
633
|
-
this.deleteBlockFields(blockId,
|
|
653
|
+
this.deleteBlockFields(blockId, "currentArgs");
|
|
634
654
|
}
|
|
635
655
|
}
|
|
636
656
|
|
|
@@ -646,7 +666,9 @@ export class ProjectMutator {
|
|
|
646
666
|
// modelAPIVersion === 2 means BlockModelV3 with .args() lambda for deriving args
|
|
647
667
|
|
|
648
668
|
if (req.modelAPIVersion !== blockConfig.modelAPIVersion) {
|
|
649
|
-
throw new Error(
|
|
669
|
+
throw new Error(
|
|
670
|
+
`Model API version mismatch for block ${req.blockId}: ${req.modelAPIVersion} !== ${blockConfig.modelAPIVersion}`,
|
|
671
|
+
);
|
|
650
672
|
}
|
|
651
673
|
|
|
652
674
|
// Derive args from storage using the block's config.args() callback
|
|
@@ -666,21 +688,31 @@ export class ProjectMutator {
|
|
|
666
688
|
req.payload,
|
|
667
689
|
);
|
|
668
690
|
|
|
669
|
-
this.setBlockFieldObj(
|
|
691
|
+
this.setBlockFieldObj(
|
|
692
|
+
req.blockId,
|
|
693
|
+
"blockStorage",
|
|
694
|
+
this.createJsonFieldValueByContent(updatedStorageJson),
|
|
695
|
+
);
|
|
670
696
|
|
|
671
697
|
// Derive args directly from storage (VM extracts data internally)
|
|
672
|
-
const derivedArgsResult = this.projectHelper.deriveArgsFromStorage(
|
|
698
|
+
const derivedArgsResult = this.projectHelper.deriveArgsFromStorage(
|
|
699
|
+
blockConfig,
|
|
700
|
+
updatedStorageJson,
|
|
701
|
+
);
|
|
673
702
|
if (derivedArgsResult.error) {
|
|
674
703
|
args = undefined;
|
|
675
704
|
prerunArgs = undefined;
|
|
676
705
|
} else {
|
|
677
706
|
args = derivedArgsResult.value;
|
|
678
707
|
// Derive prerunArgs from storage, or fall back to args
|
|
679
|
-
prerunArgs = this.projectHelper.derivePrerunArgsFromStorage(
|
|
708
|
+
prerunArgs = this.projectHelper.derivePrerunArgsFromStorage(
|
|
709
|
+
blockConfig,
|
|
710
|
+
updatedStorageJson,
|
|
711
|
+
);
|
|
680
712
|
}
|
|
681
713
|
} else {
|
|
682
|
-
this.setBlockFieldObj(req.blockId,
|
|
683
|
-
if (req.state !== null && typeof req.state ===
|
|
714
|
+
this.setBlockFieldObj(req.blockId, "blockStorage", this.createJsonFieldValue(req.state));
|
|
715
|
+
if (req.state !== null && typeof req.state === "object" && "args" in req.state) {
|
|
684
716
|
args = (req.state as { args: unknown }).args;
|
|
685
717
|
} else {
|
|
686
718
|
args = req.state;
|
|
@@ -693,9 +725,9 @@ export class ProjectMutator {
|
|
|
693
725
|
if (args !== undefined) {
|
|
694
726
|
const currentArgsData = canonicalJsonBytes(args);
|
|
695
727
|
const argsPartRef = this.tx.createValue(Pl.JsonObject, currentArgsData);
|
|
696
|
-
this.setBlockField(req.blockId,
|
|
728
|
+
this.setBlockField(req.blockId, "currentArgs", argsPartRef, "Ready", currentArgsData);
|
|
697
729
|
} else {
|
|
698
|
-
this.deleteBlockFields(req.blockId,
|
|
730
|
+
this.deleteBlockFields(req.blockId, "currentArgs");
|
|
699
731
|
}
|
|
700
732
|
|
|
701
733
|
// Set currentPrerunArgs field and check if it actually changed
|
|
@@ -704,11 +736,20 @@ export class ProjectMutator {
|
|
|
704
736
|
const prerunArgsData = canonicalJsonBytes(prerunArgs);
|
|
705
737
|
const oldPrerunArgsData = info.fields.currentPrerunArgs?.value;
|
|
706
738
|
// Check if prerunArgs actually changed
|
|
707
|
-
if (
|
|
739
|
+
if (
|
|
740
|
+
oldPrerunArgsData === undefined ||
|
|
741
|
+
Buffer.compare(oldPrerunArgsData, prerunArgsData) !== 0
|
|
742
|
+
) {
|
|
708
743
|
prerunArgsChanged = true;
|
|
709
744
|
}
|
|
710
745
|
const prerunArgsRef = this.tx.createValue(Pl.JsonObject, prerunArgsData);
|
|
711
|
-
this.setBlockField(
|
|
746
|
+
this.setBlockField(
|
|
747
|
+
req.blockId,
|
|
748
|
+
"currentPrerunArgs",
|
|
749
|
+
prerunArgsRef,
|
|
750
|
+
"Ready",
|
|
751
|
+
prerunArgsData,
|
|
752
|
+
);
|
|
712
753
|
} else {
|
|
713
754
|
// prerunArgs is undefined - check if we previously had one
|
|
714
755
|
if (info.fields.currentPrerunArgs !== undefined) {
|
|
@@ -730,13 +771,13 @@ export class ProjectMutator {
|
|
|
730
771
|
}
|
|
731
772
|
|
|
732
773
|
// resetting staging outputs for all downstream blocks
|
|
733
|
-
this.getStagingGraph().traverse(
|
|
774
|
+
this.getStagingGraph().traverse("downstream", changedArgs, ({ id }) => this.resetStaging(id));
|
|
734
775
|
|
|
735
776
|
if (somethingChanged) this.updateLastModified();
|
|
736
777
|
}
|
|
737
778
|
|
|
738
779
|
public setBlockSettings(blockId: string, newValue: BlockSettings): void {
|
|
739
|
-
this.setBlockFieldObj(blockId,
|
|
780
|
+
this.setBlockFieldObj(blockId, "blockSettings", this.createJsonFieldValue(newValue));
|
|
740
781
|
this.updateLastModified();
|
|
741
782
|
}
|
|
742
783
|
|
|
@@ -744,9 +785,9 @@ export class ProjectMutator {
|
|
|
744
785
|
const upstreamContexts: AnyRef[] = [];
|
|
745
786
|
upstream.forEach((id) => {
|
|
746
787
|
const info = this.getBlockInfo(id);
|
|
747
|
-
if (info.fields[
|
|
748
|
-
throw new Error(
|
|
749
|
-
upstreamContexts.push(Pl.unwrapHolder(this.tx, info.fields[
|
|
788
|
+
if (info.fields["prodCtx"]?.ref === undefined)
|
|
789
|
+
throw new Error("One of the upstreams staging is not rendered.");
|
|
790
|
+
upstreamContexts.push(Pl.unwrapHolder(this.tx, info.fields["prodCtx"].ref));
|
|
750
791
|
});
|
|
751
792
|
return createBContextFromUpstreams(this.tx, upstreamContexts);
|
|
752
793
|
}
|
|
@@ -755,11 +796,11 @@ export class ProjectMutator {
|
|
|
755
796
|
const upstreamContexts: AnyRef[] = [];
|
|
756
797
|
upstream.forEach((id) => {
|
|
757
798
|
const info = this.getBlockInfo(id);
|
|
758
|
-
if (info.fields[
|
|
759
|
-
throw new Error(
|
|
760
|
-
upstreamContexts.push(Pl.unwrapHolder(this.tx, info.fields[
|
|
761
|
-
if (info.fields[
|
|
762
|
-
upstreamContexts.push(Pl.unwrapHolder(this.tx, info.fields[
|
|
799
|
+
if (info.fields["stagingCtx"]?.ref === undefined)
|
|
800
|
+
throw new Error("One of the upstreams staging is not rendered.");
|
|
801
|
+
upstreamContexts.push(Pl.unwrapHolder(this.tx, info.fields["stagingCtx"].ref));
|
|
802
|
+
if (info.fields["prodCtx"]?.ref !== undefined)
|
|
803
|
+
upstreamContexts.push(Pl.unwrapHolder(this.tx, info.fields["prodCtx"].ref));
|
|
763
804
|
});
|
|
764
805
|
return createBContextFromUpstreams(this.tx, upstreamContexts);
|
|
765
806
|
}
|
|
@@ -785,7 +826,7 @@ export class ProjectMutator {
|
|
|
785
826
|
|
|
786
827
|
const ctx = this.createStagingCtx(this.getStagingGraph().nodes.get(blockId)!.upstream);
|
|
787
828
|
|
|
788
|
-
if (this.getBlock(blockId).renderingMode !==
|
|
829
|
+
if (this.getBlock(blockId).renderingMode !== "Heavy") throw new Error("not supported yet");
|
|
789
830
|
|
|
790
831
|
const tpl = info.getTemplate(this.tx);
|
|
791
832
|
|
|
@@ -800,17 +841,12 @@ export class ProjectMutator {
|
|
|
800
841
|
// Here we set the staging ctx to the input context of the staging workflow, not the output because exports
|
|
801
842
|
// of one staging context should stay within the same block, and not travel downstream.
|
|
802
843
|
// We may change this decision in the future if wanted to support traveling staging exports downstream.
|
|
803
|
-
this.setBlockField(
|
|
804
|
-
blockId,
|
|
805
|
-
'stagingCtx',
|
|
806
|
-
Pl.wrapInEphHolder(this.tx, ctx),
|
|
807
|
-
'NotReady',
|
|
808
|
-
);
|
|
844
|
+
this.setBlockField(blockId, "stagingCtx", Pl.wrapInEphHolder(this.tx, ctx), "NotReady");
|
|
809
845
|
|
|
810
846
|
// Yet the staging UI Ctx is the output context of the staging workflow, because it is used to form the result pool
|
|
811
847
|
// thus creating a certain discrepancy between staging workflow context behavior and desktop's result pool.
|
|
812
|
-
this.setBlockField(blockId,
|
|
813
|
-
this.setBlockField(blockId,
|
|
848
|
+
this.setBlockField(blockId, "stagingUiCtx", this.exportCtx(results.context), "NotReady");
|
|
849
|
+
this.setBlockField(blockId, "stagingOutput", results.result, "NotReady");
|
|
814
850
|
}
|
|
815
851
|
|
|
816
852
|
private renderProductionFor(blockId: string) {
|
|
@@ -825,8 +861,8 @@ export class ProjectMutator {
|
|
|
825
861
|
|
|
826
862
|
const ctx = this.createProdCtx(this.getPendingProductionGraph().nodes.get(blockId)!.upstream);
|
|
827
863
|
|
|
828
|
-
if (this.getBlock(blockId).renderingMode ===
|
|
829
|
-
throw new Error(
|
|
864
|
+
if (this.getBlock(blockId).renderingMode === "Light")
|
|
865
|
+
throw new Error("Can't render production for light block.");
|
|
830
866
|
|
|
831
867
|
const tpl = info.getTemplate(this.tx);
|
|
832
868
|
|
|
@@ -838,15 +874,15 @@ export class ProjectMutator {
|
|
|
838
874
|
});
|
|
839
875
|
this.setBlockField(
|
|
840
876
|
blockId,
|
|
841
|
-
|
|
877
|
+
"prodCtx",
|
|
842
878
|
Pl.wrapInEphHolder(this.tx, results.context),
|
|
843
|
-
|
|
879
|
+
"NotReady",
|
|
844
880
|
);
|
|
845
|
-
this.setBlockField(blockId,
|
|
846
|
-
this.setBlockField(blockId,
|
|
881
|
+
this.setBlockField(blockId, "prodUiCtx", this.exportCtx(results.context), "NotReady");
|
|
882
|
+
this.setBlockField(blockId, "prodOutput", results.result, "NotReady");
|
|
847
883
|
|
|
848
884
|
// saving inputs for which we rendered the production
|
|
849
|
-
this.setBlockFieldObj(blockId,
|
|
885
|
+
this.setBlockFieldObj(blockId, "prodArgs", info.fields.currentArgs);
|
|
850
886
|
|
|
851
887
|
// removing block from limbo as we juts rendered fresh production for it
|
|
852
888
|
if (this.blocksInLimbo.delete(blockId)) this.renderingStateChanged = true;
|
|
@@ -857,17 +893,22 @@ export class ProjectMutator {
|
|
|
857
893
|
//
|
|
858
894
|
|
|
859
895
|
private initializeNewBlock(blockId: string, spec: NewBlockSpec): void {
|
|
860
|
-
const info = new BlockInfo(
|
|
896
|
+
const info = new BlockInfo(
|
|
897
|
+
blockId,
|
|
898
|
+
{},
|
|
899
|
+
extractConfig(spec.blockPack.config),
|
|
900
|
+
spec.blockPack.source,
|
|
901
|
+
);
|
|
861
902
|
this.blockInfos.set(blockId, info);
|
|
862
903
|
|
|
863
904
|
// block pack
|
|
864
905
|
const bp = createBlockPack(this.tx, spec.blockPack);
|
|
865
|
-
this.setBlockField(blockId,
|
|
906
|
+
this.setBlockField(blockId, "blockPack", Pl.wrapInHolder(this.tx, bp), "NotReady");
|
|
866
907
|
|
|
867
908
|
// settings
|
|
868
909
|
this.setBlockFieldObj(
|
|
869
910
|
blockId,
|
|
870
|
-
|
|
911
|
+
"blockSettings",
|
|
871
912
|
this.createJsonFieldValue(InitialBlockSettings),
|
|
872
913
|
);
|
|
873
914
|
|
|
@@ -877,12 +918,15 @@ export class ProjectMutator {
|
|
|
877
918
|
let prerunArgs: unknown;
|
|
878
919
|
let storageToWrite: string;
|
|
879
920
|
|
|
880
|
-
if (spec.storageMode ===
|
|
921
|
+
if (spec.storageMode === "fromModel") {
|
|
881
922
|
// Model API v2+: get initial storage and derive args from it
|
|
882
923
|
storageToWrite = this.projectHelper.getInitialStorageInVM(blockConfig);
|
|
883
924
|
|
|
884
925
|
// Derive args directly from storage (VM extracts data internally)
|
|
885
|
-
const deriveArgsResult = this.projectHelper.deriveArgsFromStorage(
|
|
926
|
+
const deriveArgsResult = this.projectHelper.deriveArgsFromStorage(
|
|
927
|
+
blockConfig,
|
|
928
|
+
storageToWrite,
|
|
929
|
+
);
|
|
886
930
|
if (deriveArgsResult.error) {
|
|
887
931
|
args = undefined;
|
|
888
932
|
prerunArgs = undefined;
|
|
@@ -890,12 +934,12 @@ export class ProjectMutator {
|
|
|
890
934
|
args = deriveArgsResult.value;
|
|
891
935
|
prerunArgs = this.projectHelper.derivePrerunArgsFromStorage(blockConfig, storageToWrite);
|
|
892
936
|
}
|
|
893
|
-
} else if (spec.storageMode ===
|
|
937
|
+
} else if (spec.storageMode === "legacy") {
|
|
894
938
|
// Model API v1: use legacyState from spec
|
|
895
939
|
const parsedState = JSON.parse(spec.legacyState);
|
|
896
940
|
args = parsedState.args;
|
|
897
941
|
if (args === undefined) {
|
|
898
|
-
throw new Error(
|
|
942
|
+
throw new Error("args is undefined in legacyState");
|
|
899
943
|
}
|
|
900
944
|
prerunArgs = args;
|
|
901
945
|
storageToWrite = spec.legacyState;
|
|
@@ -905,57 +949,59 @@ export class ProjectMutator {
|
|
|
905
949
|
|
|
906
950
|
// currentArgs
|
|
907
951
|
if (args !== undefined) {
|
|
908
|
-
this.setBlockFieldObj(blockId,
|
|
952
|
+
this.setBlockFieldObj(blockId, "currentArgs", this.createJsonFieldValue(args));
|
|
909
953
|
}
|
|
910
954
|
|
|
911
955
|
// currentPrerunArgs
|
|
912
956
|
if (prerunArgs !== undefined) {
|
|
913
|
-
this.setBlockFieldObj(blockId,
|
|
957
|
+
this.setBlockFieldObj(blockId, "currentPrerunArgs", this.createJsonFieldValue(prerunArgs));
|
|
914
958
|
}
|
|
915
959
|
|
|
916
960
|
// blockStorage
|
|
917
|
-
this.setBlockFieldObj(
|
|
961
|
+
this.setBlockFieldObj(
|
|
962
|
+
blockId,
|
|
963
|
+
"blockStorage",
|
|
964
|
+
this.createJsonFieldValueByContent(storageToWrite),
|
|
965
|
+
);
|
|
918
966
|
|
|
919
967
|
// checking structure
|
|
920
968
|
info.check();
|
|
921
969
|
}
|
|
922
970
|
|
|
923
|
-
private getFieldNamesToDuplicate(blockId: string): Set<ProjectField[
|
|
971
|
+
private getFieldNamesToDuplicate(blockId: string): Set<ProjectField["fieldName"]> {
|
|
924
972
|
const fields = this.getBlockInfo(blockId).fields;
|
|
925
973
|
|
|
926
|
-
const diff = <T>(setA: Set<T>, setB: Set<T>): Set<T> =>
|
|
974
|
+
const diff = <T>(setA: Set<T>, setB: Set<T>): Set<T> =>
|
|
975
|
+
new Set([...setA].filter((x) => !setB.has(x)));
|
|
927
976
|
|
|
928
977
|
// Check if we can safely move to limbo (both core production fields are ready)
|
|
929
|
-
if (fields.prodOutput?.status ===
|
|
978
|
+
if (fields.prodOutput?.status === "Ready" && fields.prodCtx?.status === "Ready") {
|
|
930
979
|
if (this.blocksInLimbo.has(blockId))
|
|
931
980
|
// we are already in limbo
|
|
932
981
|
return FieldsToDuplicate;
|
|
933
982
|
|
|
934
|
-
return diff(
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
]));
|
|
983
|
+
return diff(
|
|
984
|
+
FieldsToDuplicate,
|
|
985
|
+
new Set(["prodOutputPrevious", "prodCtxPrevious", "prodUiCtxPrevious"]),
|
|
986
|
+
);
|
|
939
987
|
} else {
|
|
940
|
-
return diff(
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
988
|
+
return diff(
|
|
989
|
+
FieldsToDuplicate,
|
|
990
|
+
new Set([
|
|
991
|
+
"prodOutput",
|
|
992
|
+
"prodCtx",
|
|
993
|
+
"prodUiCtx",
|
|
994
|
+
"prodArgs",
|
|
995
|
+
"prodOutputPrevious",
|
|
996
|
+
"prodCtxPrevious",
|
|
997
|
+
"prodUiCtxPrevious",
|
|
998
|
+
]),
|
|
999
|
+
);
|
|
949
1000
|
}
|
|
950
1001
|
}
|
|
951
1002
|
|
|
952
1003
|
private initializeBlockDuplicate(blockId: string, originalBlockInfo: BlockInfo) {
|
|
953
|
-
const info = new BlockInfo(
|
|
954
|
-
blockId,
|
|
955
|
-
{},
|
|
956
|
-
originalBlockInfo.config,
|
|
957
|
-
originalBlockInfo.source,
|
|
958
|
-
);
|
|
1004
|
+
const info = new BlockInfo(blockId, {}, originalBlockInfo.config, originalBlockInfo.source);
|
|
959
1005
|
|
|
960
1006
|
this.blockInfos.set(blockId, info);
|
|
961
1007
|
|
|
@@ -963,7 +1009,11 @@ export class ProjectMutator {
|
|
|
963
1009
|
|
|
964
1010
|
// Copy all fields from original block to new block by sharing references
|
|
965
1011
|
for (const [fieldName, fieldState] of Object.entries(originalBlockInfo.fields)) {
|
|
966
|
-
if (
|
|
1012
|
+
if (
|
|
1013
|
+
fieldNamesToDuplicate.has(fieldName as ProjectField["fieldName"]) &&
|
|
1014
|
+
fieldState &&
|
|
1015
|
+
fieldState.ref
|
|
1016
|
+
) {
|
|
967
1017
|
this.setBlockFieldObj(blockId, fieldName as keyof BlockFieldStates, {
|
|
968
1018
|
ref: fieldState.ref,
|
|
969
1019
|
status: fieldState.status,
|
|
@@ -992,7 +1042,7 @@ export class ProjectMutator {
|
|
|
992
1042
|
// removing blocks
|
|
993
1043
|
for (const blockId of stagingDiff.onlyInA) {
|
|
994
1044
|
const { fields } = this.getBlockInfo(blockId);
|
|
995
|
-
this.deleteBlockFields(blockId, ...(Object.keys(fields) as ProjectField[
|
|
1045
|
+
this.deleteBlockFields(blockId, ...(Object.keys(fields) as ProjectField["fieldName"][]));
|
|
996
1046
|
this.blockInfos.delete(blockId);
|
|
997
1047
|
if (this.blocksInLimbo.delete(blockId)) this.renderingStateChanged = true;
|
|
998
1048
|
}
|
|
@@ -1006,23 +1056,22 @@ export class ProjectMutator {
|
|
|
1006
1056
|
for (const blockId of stagingDiff.different) this.resetStaging(blockId);
|
|
1007
1057
|
|
|
1008
1058
|
// new actual production graph without new blocks
|
|
1009
|
-
const newActualProductionGraph = productionGraph(
|
|
1010
|
-
|
|
1011
|
-
(blockId) => this.getProductionGraphBlockInfo(blockId, true),
|
|
1059
|
+
const newActualProductionGraph = productionGraph(newStructure, (blockId) =>
|
|
1060
|
+
this.getProductionGraphBlockInfo(blockId, true),
|
|
1012
1061
|
);
|
|
1013
1062
|
|
|
1014
1063
|
const prodDiff = graphDiff(currentActualProductionGraph, newActualProductionGraph);
|
|
1015
1064
|
|
|
1016
1065
|
// applying changes due to topology change in production to affected nodes and
|
|
1017
1066
|
// all their downstreams
|
|
1018
|
-
currentActualProductionGraph.traverse(
|
|
1067
|
+
currentActualProductionGraph.traverse("downstream", [...prodDiff.different], (node) => {
|
|
1019
1068
|
this.resetOrLimboProduction(node.id);
|
|
1020
1069
|
});
|
|
1021
1070
|
|
|
1022
1071
|
if (
|
|
1023
|
-
stagingDiff.onlyInB.size > 0
|
|
1024
|
-
|
|
1025
|
-
|
|
1072
|
+
stagingDiff.onlyInB.size > 0 ||
|
|
1073
|
+
stagingDiff.onlyInA.size > 0 ||
|
|
1074
|
+
stagingDiff.different.size > 0
|
|
1026
1075
|
)
|
|
1027
1076
|
this.resetStagingRefreshTimestamp();
|
|
1028
1077
|
|
|
@@ -1056,7 +1105,7 @@ export class ProjectMutator {
|
|
|
1056
1105
|
if (!done) throw new Error(`Can't find element with id: ${before}`);
|
|
1057
1106
|
}
|
|
1058
1107
|
this.updateStructure(newStruct, (blockId) => {
|
|
1059
|
-
if (blockId !== block.id) throw new Error(
|
|
1108
|
+
if (blockId !== block.id) throw new Error("Unexpected");
|
|
1060
1109
|
this.initializeNewBlock(blockId, spec);
|
|
1061
1110
|
});
|
|
1062
1111
|
}
|
|
@@ -1099,7 +1148,7 @@ export class ProjectMutator {
|
|
|
1099
1148
|
}
|
|
1100
1149
|
|
|
1101
1150
|
this.updateStructure(newStruct, (blockId) => {
|
|
1102
|
-
if (blockId !== newBlockId) throw new Error(
|
|
1151
|
+
if (blockId !== newBlockId) throw new Error("Unexpected");
|
|
1103
1152
|
this.initializeBlockDuplicate(blockId, originalBlockInfo);
|
|
1104
1153
|
});
|
|
1105
1154
|
}
|
|
@@ -1122,15 +1171,19 @@ export class ProjectMutator {
|
|
|
1122
1171
|
// Block-pack migration
|
|
1123
1172
|
//
|
|
1124
1173
|
|
|
1125
|
-
public migrateBlockPack(
|
|
1174
|
+
public migrateBlockPack(
|
|
1175
|
+
blockId: string,
|
|
1176
|
+
spec: BlockPackSpecPrepared,
|
|
1177
|
+
newClearState?: ClearState,
|
|
1178
|
+
): void {
|
|
1126
1179
|
const info = this.getBlockInfo(blockId);
|
|
1127
1180
|
const newConfig = extractConfig(spec.config);
|
|
1128
1181
|
|
|
1129
1182
|
this.setBlockField(
|
|
1130
1183
|
blockId,
|
|
1131
|
-
|
|
1184
|
+
"blockPack",
|
|
1132
1185
|
Pl.wrapInHolder(this.tx, createBlockPack(this.tx, spec)),
|
|
1133
|
-
|
|
1186
|
+
"NotReady",
|
|
1134
1187
|
);
|
|
1135
1188
|
|
|
1136
1189
|
if (newClearState !== undefined) {
|
|
@@ -1143,13 +1196,27 @@ export class ProjectMutator {
|
|
|
1143
1196
|
this.setBlockStorageRaw(blockId, initialStorageJson);
|
|
1144
1197
|
|
|
1145
1198
|
// Derive args from storage - only set currentArgs if derivation succeeds
|
|
1146
|
-
const deriveArgsResult = this.projectHelper.deriveArgsFromStorage(
|
|
1199
|
+
const deriveArgsResult = this.projectHelper.deriveArgsFromStorage(
|
|
1200
|
+
newConfig,
|
|
1201
|
+
initialStorageJson,
|
|
1202
|
+
);
|
|
1147
1203
|
if (!deriveArgsResult.error) {
|
|
1148
|
-
this.setBlockFieldObj(
|
|
1204
|
+
this.setBlockFieldObj(
|
|
1205
|
+
blockId,
|
|
1206
|
+
"currentArgs",
|
|
1207
|
+
this.createJsonFieldValue(deriveArgsResult.value),
|
|
1208
|
+
);
|
|
1149
1209
|
// Derive prerunArgs from storage
|
|
1150
|
-
const prerunArgs = this.projectHelper.derivePrerunArgsFromStorage(
|
|
1210
|
+
const prerunArgs = this.projectHelper.derivePrerunArgsFromStorage(
|
|
1211
|
+
newConfig,
|
|
1212
|
+
initialStorageJson,
|
|
1213
|
+
);
|
|
1151
1214
|
if (prerunArgs !== undefined) {
|
|
1152
|
-
this.setBlockFieldObj(
|
|
1215
|
+
this.setBlockFieldObj(
|
|
1216
|
+
blockId,
|
|
1217
|
+
"currentPrerunArgs",
|
|
1218
|
+
this.createJsonFieldValue(prerunArgs),
|
|
1219
|
+
);
|
|
1153
1220
|
}
|
|
1154
1221
|
}
|
|
1155
1222
|
this.blocksWithChangedInputs.add(blockId);
|
|
@@ -1166,26 +1233,33 @@ export class ProjectMutator {
|
|
|
1166
1233
|
if (supportsStateMigrations) {
|
|
1167
1234
|
const currentStorageJson = info.blockStorageJson;
|
|
1168
1235
|
|
|
1169
|
-
const migrationResult = this.projectHelper.migrateStorageInVM(
|
|
1236
|
+
const migrationResult = this.projectHelper.migrateStorageInVM(
|
|
1237
|
+
newConfig,
|
|
1238
|
+
currentStorageJson,
|
|
1239
|
+
);
|
|
1170
1240
|
|
|
1171
1241
|
if (migrationResult.error !== undefined) {
|
|
1172
|
-
console.error(
|
|
1242
|
+
console.error(
|
|
1243
|
+
`[migrateBlockPack] Block ${blockId} migration error: ${migrationResult.error}`,
|
|
1244
|
+
);
|
|
1173
1245
|
} else {
|
|
1174
1246
|
console.log(`[migrateBlockPack] Block ${blockId}: ${migrationResult.info}`);
|
|
1175
1247
|
if (migrationResult.warn) {
|
|
1176
|
-
console.warn(
|
|
1248
|
+
console.warn(
|
|
1249
|
+
`[migrateBlockPack] Block ${blockId} migration warning: ${migrationResult.warn}`,
|
|
1250
|
+
);
|
|
1177
1251
|
}
|
|
1178
1252
|
this.setBlockStorageRaw(blockId, migrationResult.newStorageJson);
|
|
1179
1253
|
}
|
|
1180
1254
|
}
|
|
1181
1255
|
|
|
1182
1256
|
// resetting staging outputs for all downstream blocks
|
|
1183
|
-
this.getStagingGraph().traverse(
|
|
1257
|
+
this.getStagingGraph().traverse("downstream", [blockId], ({ id }) => this.resetStaging(id));
|
|
1184
1258
|
}
|
|
1185
1259
|
|
|
1186
1260
|
// also reset or limbo all downstream productions
|
|
1187
1261
|
if (info.productionRendered)
|
|
1188
|
-
this.getActualProductionGraph().traverse(
|
|
1262
|
+
this.getActualProductionGraph().traverse("downstream", [blockId], ({ id }) =>
|
|
1189
1263
|
this.resetOrLimboProduction(id),
|
|
1190
1264
|
);
|
|
1191
1265
|
|
|
@@ -1202,16 +1276,17 @@ export class ProjectMutator {
|
|
|
1202
1276
|
const prodGraph = this.getPendingProductionGraph();
|
|
1203
1277
|
if (addUpstreams)
|
|
1204
1278
|
// adding all upstreams automatically
|
|
1205
|
-
prodGraph.traverse(
|
|
1279
|
+
prodGraph.traverse("upstream", blockIds, (node) => {
|
|
1206
1280
|
blockIdsSet.add(node.id);
|
|
1207
1281
|
});
|
|
1208
|
-
else
|
|
1282
|
+
else
|
|
1283
|
+
// checking that targets contain all upstreams
|
|
1209
1284
|
for (const blockId of blockIdsSet) {
|
|
1210
1285
|
const node = prodGraph.nodes.get(blockId);
|
|
1211
1286
|
if (node === undefined) throw new Error(`Can't find block with id: ${blockId}`);
|
|
1212
1287
|
for (const upstream of node.upstream)
|
|
1213
1288
|
if (!blockIdsSet.has(upstream))
|
|
1214
|
-
throw new Error(
|
|
1289
|
+
throw new Error("Can't render blocks not including all upstreams.");
|
|
1215
1290
|
}
|
|
1216
1291
|
|
|
1217
1292
|
// traversing in topological order and rendering target blocks
|
|
@@ -1219,8 +1294,8 @@ export class ProjectMutator {
|
|
|
1219
1294
|
for (const block of allBlocks(this.structure)) {
|
|
1220
1295
|
if (!blockIdsSet.has(block.id)) continue;
|
|
1221
1296
|
|
|
1222
|
-
let render
|
|
1223
|
-
|
|
1297
|
+
let render =
|
|
1298
|
+
this.getBlockInfo(block.id).requireProductionRendering || this.blocksInLimbo.has(block.id);
|
|
1224
1299
|
|
|
1225
1300
|
if (!render)
|
|
1226
1301
|
for (const upstream of prodGraph.nodes.get(block.id)!.upstream)
|
|
@@ -1238,7 +1313,7 @@ export class ProjectMutator {
|
|
|
1238
1313
|
const renderedArray = [...rendered];
|
|
1239
1314
|
|
|
1240
1315
|
// sending to limbo all downstream blocks
|
|
1241
|
-
prodGraph.traverse(
|
|
1316
|
+
prodGraph.traverse("downstream", renderedArray, (node) => {
|
|
1242
1317
|
if (rendered.has(node.id))
|
|
1243
1318
|
// don't send to limbo blocks that were just rendered
|
|
1244
1319
|
return;
|
|
@@ -1246,7 +1321,7 @@ export class ProjectMutator {
|
|
|
1246
1321
|
});
|
|
1247
1322
|
|
|
1248
1323
|
// resetting staging outputs for all downstream blocks
|
|
1249
|
-
this.getStagingGraph().traverse(
|
|
1324
|
+
this.getStagingGraph().traverse("downstream", renderedArray, ({ id }) => {
|
|
1250
1325
|
// don't reset staging of the first rendered block
|
|
1251
1326
|
if (renderedArray[0] !== id) this.resetStaging(id);
|
|
1252
1327
|
});
|
|
@@ -1270,16 +1345,16 @@ export class ProjectMutator {
|
|
|
1270
1345
|
const blockId = queue.shift()!;
|
|
1271
1346
|
const fields = this.getBlockInfo(blockId).fields;
|
|
1272
1347
|
|
|
1273
|
-
if (fields.prodOutput?.status ===
|
|
1348
|
+
if (fields.prodOutput?.status === "Ready" && fields.prodCtx?.status === "Ready")
|
|
1274
1349
|
// skipping finished blocks
|
|
1275
1350
|
continue;
|
|
1276
1351
|
|
|
1277
|
-
if (this.deleteBlockFields(blockId,
|
|
1352
|
+
if (this.deleteBlockFields(blockId, "prodOutput", "prodCtx", "prodUiCtx", "prodArgs")) {
|
|
1278
1353
|
// was actually stopped
|
|
1279
1354
|
stopped.push(blockId);
|
|
1280
1355
|
|
|
1281
1356
|
// will try to stop all its downstreams
|
|
1282
|
-
for (const downstream of activeProdGraph.traverseIdsExcludingRoots(
|
|
1357
|
+
for (const downstream of activeProdGraph.traverseIdsExcludingRoots("downstream", blockId)) {
|
|
1283
1358
|
if (queued.has(downstream)) continue;
|
|
1284
1359
|
queue.push(downstream);
|
|
1285
1360
|
queued.add(downstream);
|
|
@@ -1288,11 +1363,11 @@ export class ProjectMutator {
|
|
|
1288
1363
|
}
|
|
1289
1364
|
|
|
1290
1365
|
// blocks under stopped blocks, but having finished production results, goes to limbo
|
|
1291
|
-
for (const blockId of activeProdGraph.traverseIdsExcludingRoots(
|
|
1366
|
+
for (const blockId of activeProdGraph.traverseIdsExcludingRoots("downstream", ...stopped))
|
|
1292
1367
|
this.resetOrLimboProduction(blockId);
|
|
1293
1368
|
|
|
1294
1369
|
// reset staging outputs for all downstream blocks
|
|
1295
|
-
this.getStagingGraph().traverse(
|
|
1370
|
+
this.getStagingGraph().traverse("downstream", stopped, ({ id }) => this.resetStaging(id));
|
|
1296
1371
|
}
|
|
1297
1372
|
|
|
1298
1373
|
private traverseWithStagingLag(cb: (blockId: string, lag: number) => void) {
|
|
@@ -1319,8 +1394,8 @@ export class ProjectMutator {
|
|
|
1319
1394
|
/** @param stagingRenderingRate rate in blocks per second */
|
|
1320
1395
|
private refreshStagings(stagingRenderingRate?: number) {
|
|
1321
1396
|
const elapsed = Date.now() - this.renderingState.stagingRefreshTimestamp;
|
|
1322
|
-
const lagThreshold
|
|
1323
|
-
|
|
1397
|
+
const lagThreshold =
|
|
1398
|
+
stagingRenderingRate === undefined
|
|
1324
1399
|
? undefined
|
|
1325
1400
|
: 1 + Math.max(0, (elapsed * stagingRenderingRate) / 1000);
|
|
1326
1401
|
let rendered = 0;
|
|
@@ -1357,24 +1432,24 @@ export class ProjectMutator {
|
|
|
1357
1432
|
this.refreshStagings(stagingRenderingRate);
|
|
1358
1433
|
this.blockInfos.forEach((blockInfo) => {
|
|
1359
1434
|
if (
|
|
1360
|
-
blockInfo.fields.prodCtx?.status ===
|
|
1361
|
-
|
|
1435
|
+
blockInfo.fields.prodCtx?.status === "Ready" &&
|
|
1436
|
+
blockInfo.fields.prodOutput?.status === "Ready"
|
|
1362
1437
|
)
|
|
1363
1438
|
this.deleteBlockFields(
|
|
1364
1439
|
blockInfo.id,
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1440
|
+
"prodOutputPrevious",
|
|
1441
|
+
"prodCtxPrevious",
|
|
1442
|
+
"prodUiCtxPrevious",
|
|
1368
1443
|
);
|
|
1369
1444
|
if (
|
|
1370
|
-
blockInfo.fields.stagingCtx?.status ===
|
|
1371
|
-
|
|
1445
|
+
blockInfo.fields.stagingCtx?.status === "Ready" &&
|
|
1446
|
+
blockInfo.fields.stagingOutput?.status === "Ready"
|
|
1372
1447
|
)
|
|
1373
1448
|
this.deleteBlockFields(
|
|
1374
1449
|
blockInfo.id,
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1450
|
+
"stagingOutputPrevious",
|
|
1451
|
+
"stagingCtxPrevious",
|
|
1452
|
+
"stagingUiCtxPrevious",
|
|
1378
1453
|
);
|
|
1379
1454
|
});
|
|
1380
1455
|
}
|
|
@@ -1463,41 +1538,42 @@ export class ProjectMutator {
|
|
|
1463
1538
|
// (start of round-trip #2)
|
|
1464
1539
|
//
|
|
1465
1540
|
|
|
1466
|
-
const blockFieldRequests: [
|
|
1541
|
+
const blockFieldRequests: [
|
|
1542
|
+
BlockInfoState,
|
|
1543
|
+
ProjectField["fieldName"],
|
|
1544
|
+
BlockFieldState,
|
|
1545
|
+
Promise<BasicResourceData | ResourceData>,
|
|
1546
|
+
][] = [];
|
|
1467
1547
|
blockInfoStates.forEach((info) => {
|
|
1468
1548
|
const fields = info.fields;
|
|
1469
1549
|
for (const [fName, state] of Object.entries(fields)) {
|
|
1470
1550
|
if (state.ref === undefined) continue;
|
|
1471
1551
|
if (!isResource(state.ref) || isResourceRef(state.ref))
|
|
1472
|
-
throw new Error(
|
|
1473
|
-
const fieldName = fName as ProjectField[
|
|
1552
|
+
throw new Error("unexpected behaviour");
|
|
1553
|
+
const fieldName = fName as ProjectField["fieldName"];
|
|
1474
1554
|
blockFieldRequests.push([
|
|
1475
|
-
info,
|
|
1476
|
-
|
|
1555
|
+
info,
|
|
1556
|
+
fieldName,
|
|
1557
|
+
state,
|
|
1558
|
+
tx.getResourceData(state.ref, fieldName == "blockPack"),
|
|
1559
|
+
]);
|
|
1477
1560
|
}
|
|
1478
1561
|
});
|
|
1479
1562
|
|
|
1480
1563
|
// loading jsons
|
|
1481
|
-
const [
|
|
1482
|
-
|
|
1483
|
-
lastModified,
|
|
1484
|
-
meta,
|
|
1485
|
-
structure,
|
|
1486
|
-
{ stagingRefreshTimestamp, blocksInLimbo },
|
|
1487
|
-
] = await Promise.all([
|
|
1488
|
-
schemaP,
|
|
1489
|
-
lastModifiedP,
|
|
1490
|
-
metaP,
|
|
1491
|
-
structureP,
|
|
1492
|
-
renderingStateP,
|
|
1493
|
-
]);
|
|
1564
|
+
const [schema, lastModified, meta, structure, { stagingRefreshTimestamp, blocksInLimbo }] =
|
|
1565
|
+
await Promise.all([schemaP, lastModifiedP, metaP, structureP, renderingStateP]);
|
|
1494
1566
|
|
|
1495
1567
|
// Checking schema version of the project
|
|
1496
1568
|
if (schema !== SchemaVersionCurrent) {
|
|
1497
1569
|
if (Number(schema) < Number(SchemaVersionCurrent))
|
|
1498
|
-
throw new UiError(
|
|
1570
|
+
throw new UiError(
|
|
1571
|
+
`Can't perform this action on this project because it has older schema. Try (re)loading the project to update it.`,
|
|
1572
|
+
);
|
|
1499
1573
|
else
|
|
1500
|
-
throw new UiError(
|
|
1574
|
+
throw new UiError(
|
|
1575
|
+
`Can't perform this action on this project because it has newer schema. Upgrade your desktop app to the latest version.`,
|
|
1576
|
+
);
|
|
1501
1577
|
}
|
|
1502
1578
|
|
|
1503
1579
|
//
|
|
@@ -1513,17 +1589,19 @@ export class ProjectMutator {
|
|
|
1513
1589
|
for (const [info, fieldName, state, response] of blockFieldRequests) {
|
|
1514
1590
|
const result = await response;
|
|
1515
1591
|
state.value = result.data;
|
|
1516
|
-
if (isNotNullResourceId(result.error)) state.status =
|
|
1592
|
+
if (isNotNullResourceId(result.error)) state.status = "Error";
|
|
1517
1593
|
else if (result.resourceReady || isNotNullResourceId(result.originalResourceId))
|
|
1518
|
-
state.status =
|
|
1519
|
-
else state.status =
|
|
1594
|
+
state.status = "Ready";
|
|
1595
|
+
else state.status = "NotReady";
|
|
1520
1596
|
|
|
1521
1597
|
// For block pack we need to traverse the ref field from the resource data
|
|
1522
|
-
if (fieldName ===
|
|
1598
|
+
if (fieldName === "blockPack") {
|
|
1523
1599
|
const refField = (result as ResourceData).fields.find((f) => f.name === Pl.HolderRefField);
|
|
1524
|
-
if (refField === undefined)
|
|
1525
|
-
|
|
1526
|
-
|
|
1600
|
+
if (refField === undefined) throw new Error("Block pack ref field is missing");
|
|
1601
|
+
blockPackRequests.push([
|
|
1602
|
+
info,
|
|
1603
|
+
tx.getResourceData(ensureResourceIdNotNull(refField.value), false),
|
|
1604
|
+
]);
|
|
1527
1605
|
}
|
|
1528
1606
|
}
|
|
1529
1607
|
|
|
@@ -1557,7 +1635,7 @@ export class ProjectMutator {
|
|
|
1557
1635
|
ctxExportTplHolder = Pl.wrapInHolder(tx, loadTemplate(tx, ctxExportTplEnvelope.spec));
|
|
1558
1636
|
tx.createField(
|
|
1559
1637
|
field(rid, getServiceTemplateField(ctxExportTplEnvelope.hash)),
|
|
1560
|
-
|
|
1638
|
+
"Dynamic",
|
|
1561
1639
|
ctxExportTplHolder,
|
|
1562
1640
|
);
|
|
1563
1641
|
}
|
|
@@ -1566,8 +1644,9 @@ export class ProjectMutator {
|
|
|
1566
1644
|
const blocksInLimboSet = new Set(blocksInLimbo);
|
|
1567
1645
|
|
|
1568
1646
|
const blockInfos = new Map<string, BlockInfo>();
|
|
1569
|
-
blockInfoStates.forEach(({ id, fields, blockConfig, blockPack }) =>
|
|
1570
|
-
new BlockInfo(id, fields, notEmpty(blockConfig), notEmpty(blockPack)))
|
|
1647
|
+
blockInfoStates.forEach(({ id, fields, blockConfig, blockPack }) =>
|
|
1648
|
+
blockInfos.set(id, new BlockInfo(id, fields, notEmpty(blockConfig), notEmpty(blockPack))),
|
|
1649
|
+
);
|
|
1571
1650
|
|
|
1572
1651
|
// check consistency of project state
|
|
1573
1652
|
const blockInStruct = new Set<string>();
|
|
@@ -1607,7 +1686,7 @@ export class ProjectMutator {
|
|
|
1607
1686
|
export interface ProjectState {
|
|
1608
1687
|
schema: string;
|
|
1609
1688
|
structure: ProjectStructure;
|
|
1610
|
-
renderingState: Omit<ProjectRenderingState,
|
|
1689
|
+
renderingState: Omit<ProjectRenderingState, "blocksInLimbo">;
|
|
1611
1690
|
blocksInLimbo: Set<string>;
|
|
1612
1691
|
blockInfos: Map<string, BlockInfo>;
|
|
1613
1692
|
}
|
|
@@ -1628,7 +1707,7 @@ export async function createProject(
|
|
|
1628
1707
|
const ctxExportTplEnvelope = await getPreparedExportTemplateEnvelope();
|
|
1629
1708
|
tx.createField(
|
|
1630
1709
|
field(prj, getServiceTemplateField(ctxExportTplEnvelope.hash)),
|
|
1631
|
-
|
|
1710
|
+
"Dynamic",
|
|
1632
1711
|
Pl.wrapInHolder(tx, loadTemplate(tx, ctxExportTplEnvelope.spec)),
|
|
1633
1712
|
);
|
|
1634
1713
|
return prj;
|
|
@@ -1653,17 +1732,21 @@ export async function withProjectAuthored<T>(
|
|
|
1653
1732
|
ops: Partial<TxOps> = {},
|
|
1654
1733
|
): Promise<T> {
|
|
1655
1734
|
if (txOrPl instanceof PlClient) {
|
|
1656
|
-
return await txOrPl.withWriteTx(
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1735
|
+
return await txOrPl.withWriteTx(
|
|
1736
|
+
"ProjectAction" + (ops.name ? `: ${ops.name}` : ""),
|
|
1737
|
+
async (tx) => {
|
|
1738
|
+
const mut = await ProjectMutator.load(projectHelper, tx, rid, author);
|
|
1739
|
+
const result = await cb(mut);
|
|
1740
|
+
if (!mut.wasModified)
|
|
1741
|
+
// skipping save and commit altogether if no modifications were actually made
|
|
1742
|
+
return result;
|
|
1743
|
+
mut.save();
|
|
1744
|
+
await tx.commit();
|
|
1745
|
+
if (getDebugFlags().logProjectMutationStat) console.log(JSON.stringify(tx.stat));
|
|
1661
1746
|
return result;
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
return result;
|
|
1666
|
-
}, ops);
|
|
1747
|
+
},
|
|
1748
|
+
ops,
|
|
1749
|
+
);
|
|
1667
1750
|
} else {
|
|
1668
1751
|
const mut = await ProjectMutator.load(projectHelper, txOrPl, rid, author);
|
|
1669
1752
|
const result = await cb(mut);
|