@nocobase/flow-engine 2.0.0-alpha.10
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/LICENSE +661 -0
- package/README.md +30 -0
- package/lib/ContextPathProxy.d.ts +17 -0
- package/lib/ContextPathProxy.js +65 -0
- package/lib/ElementProxy.d.ts +17 -0
- package/lib/ElementProxy.js +93 -0
- package/lib/FlowContextProvider.d.ts +24 -0
- package/lib/FlowContextProvider.js +82 -0
- package/lib/FlowDefinition.d.ts +423 -0
- package/lib/FlowDefinition.js +257 -0
- package/lib/JSRunner.d.ts +32 -0
- package/lib/JSRunner.js +95 -0
- package/lib/ReactView.d.ts +20 -0
- package/lib/ReactView.js +120 -0
- package/lib/ViewScopedFlowEngine.d.ts +23 -0
- package/lib/ViewScopedFlowEngine.js +81 -0
- package/lib/acl/Acl.d.ts +31 -0
- package/lib/acl/Acl.js +115 -0
- package/lib/action-registry/BaseActionRegistry.d.ts +23 -0
- package/lib/action-registry/BaseActionRegistry.js +57 -0
- package/lib/action-registry/EngineActionRegistry.d.ts +20 -0
- package/lib/action-registry/EngineActionRegistry.js +47 -0
- package/lib/action-registry/ModelActionRegistry.d.ts +34 -0
- package/lib/action-registry/ModelActionRegistry.js +79 -0
- package/lib/components/DynamicFlowsEditor.d.ts +17 -0
- package/lib/components/DynamicFlowsEditor.js +49 -0
- package/lib/components/FieldModelRenderer.d.ts +10 -0
- package/lib/components/FieldModelRenderer.js +100 -0
- package/lib/components/FlowContextSelector.d.ts +11 -0
- package/lib/components/FlowContextSelector.js +221 -0
- package/lib/components/FlowErrorFallback.d.ts +25 -0
- package/lib/components/FlowErrorFallback.js +264 -0
- package/lib/components/FlowModelRenderer.d.ts +61 -0
- package/lib/components/FlowModelRenderer.js +214 -0
- package/lib/components/FormItem.d.ts +18 -0
- package/lib/components/FormItem.js +151 -0
- package/lib/components/common/FlowSettingsButton.d.ts +11 -0
- package/lib/components/common/FlowSettingsButton.js +66 -0
- package/lib/components/common/index.d.ts +9 -0
- package/lib/components/common/index.js +30 -0
- package/lib/components/common/withFlowDesignMode.d.ts +26 -0
- package/lib/components/common/withFlowDesignMode.js +61 -0
- package/lib/components/dnd/findModelUidPosition.d.ts +13 -0
- package/lib/components/dnd/findModelUidPosition.js +50 -0
- package/lib/components/dnd/gridDragPlanner.d.ts +130 -0
- package/lib/components/dnd/gridDragPlanner.js +497 -0
- package/lib/components/dnd/index.d.ts +24 -0
- package/lib/components/dnd/index.js +164 -0
- package/lib/components/index.d.ts +18 -0
- package/lib/components/index.js +48 -0
- package/lib/components/settings/independents/dropdown/FlowsDropdownButton.d.ts +46 -0
- package/lib/components/settings/independents/dropdown/FlowsDropdownButton.js +225 -0
- package/lib/components/settings/independents/dropdown/index.d.ts +9 -0
- package/lib/components/settings/independents/dropdown/index.js +30 -0
- package/lib/components/settings/independents/index.d.ts +1 -0
- package/lib/components/settings/independents/index.js +30 -0
- package/lib/components/settings/index.d.ts +10 -0
- package/lib/components/settings/index.js +32 -0
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.d.ts +24 -0
- package/lib/components/settings/wrappers/contextual/DefaultSettingsIcon.js +501 -0
- package/lib/components/settings/wrappers/contextual/FlowsContextMenu.d.ts +45 -0
- package/lib/components/settings/wrappers/contextual/FlowsContextMenu.js +231 -0
- package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.d.ts +111 -0
- package/lib/components/settings/wrappers/contextual/FlowsFloatContextMenu.js +484 -0
- package/lib/components/settings/wrappers/contextual/StepRequiredSettingsDialog.d.ts +26 -0
- package/lib/components/settings/wrappers/contextual/StepRequiredSettingsDialog.js +342 -0
- package/lib/components/settings/wrappers/contextual/StepSettings.d.ts +23 -0
- package/lib/components/settings/wrappers/contextual/StepSettings.js +110 -0
- package/lib/components/settings/wrappers/contextual/StepSettingsDialog.d.ts +20 -0
- package/lib/components/settings/wrappers/contextual/StepSettingsDialog.js +212 -0
- package/lib/components/settings/wrappers/contextual/StepSettingsDrawer.d.ts +20 -0
- package/lib/components/settings/wrappers/contextual/StepSettingsDrawer.js +47 -0
- package/lib/components/settings/wrappers/contextual/index.d.ts +14 -0
- package/lib/components/settings/wrappers/contextual/index.js +40 -0
- package/lib/components/settings/wrappers/embedded/FlowSettings.d.ts +33 -0
- package/lib/components/settings/wrappers/embedded/FlowSettings.js +207 -0
- package/lib/components/settings/wrappers/embedded/FlowsSettings.d.ts +41 -0
- package/lib/components/settings/wrappers/embedded/FlowsSettings.js +84 -0
- package/lib/components/settings/wrappers/embedded/FlowsSettingsContent.d.ts +16 -0
- package/lib/components/settings/wrappers/embedded/FlowsSettingsContent.js +88 -0
- package/lib/components/settings/wrappers/embedded/index.d.ts +10 -0
- package/lib/components/settings/wrappers/embedded/index.js +32 -0
- package/lib/components/settings/wrappers/index.d.ts +2 -0
- package/lib/components/settings/wrappers/index.js +32 -0
- package/lib/components/subModel/AddSubModelButton.d.ts +62 -0
- package/lib/components/subModel/AddSubModelButton.js +415 -0
- package/lib/components/subModel/LazyDropdown.d.ts +55 -0
- package/lib/components/subModel/LazyDropdown.js +524 -0
- package/lib/components/subModel/index.d.ts +10 -0
- package/lib/components/subModel/index.js +32 -0
- package/lib/components/subModel/utils.d.ts +34 -0
- package/lib/components/subModel/utils.js +287 -0
- package/lib/components/variables/InlineVariableTag.d.ts +21 -0
- package/lib/components/variables/InlineVariableTag.js +123 -0
- package/lib/components/variables/SlateVariableEditor.d.ts +46 -0
- package/lib/components/variables/SlateVariableEditor.js +302 -0
- package/lib/components/variables/VariableInput.d.ts +11 -0
- package/lib/components/variables/VariableInput.js +334 -0
- package/lib/components/variables/VariableTag.d.ts +11 -0
- package/lib/components/variables/VariableTag.js +189 -0
- package/lib/components/variables/VariableTrigger.d.ts +20 -0
- package/lib/components/variables/VariableTrigger.js +136 -0
- package/lib/components/variables/index.d.ts +15 -0
- package/lib/components/variables/index.js +53 -0
- package/lib/components/variables/types.d.ts +93 -0
- package/lib/components/variables/types.js +24 -0
- package/lib/components/variables/useResolvedMetaTree.d.ts +19 -0
- package/lib/components/variables/useResolvedMetaTree.js +91 -0
- package/lib/components/variables/utils.d.ts +22 -0
- package/lib/components/variables/utils.js +177 -0
- package/lib/data-source/index.d.ts +180 -0
- package/lib/data-source/index.js +737 -0
- package/lib/data-source/jioToJoiSchema.d.ts +19 -0
- package/lib/data-source/jioToJoiSchema.js +114 -0
- package/lib/data-source/sortCollectionsByInherits.d.ts +10 -0
- package/lib/data-source/sortCollectionsByInherits.js +71 -0
- package/lib/decorators/index.d.ts +9 -0
- package/lib/decorators/index.js +36 -0
- package/lib/decorators/largeField.d.ts +9 -0
- package/lib/decorators/largeField.js +42 -0
- package/lib/emitter.d.ts +16 -0
- package/lib/emitter.js +58 -0
- package/lib/event-registry/BaseEventRegistry.d.ts +22 -0
- package/lib/event-registry/BaseEventRegistry.js +57 -0
- package/lib/event-registry/EngineEventRegistry.d.ts +19 -0
- package/lib/event-registry/EngineEventRegistry.js +47 -0
- package/lib/event-registry/ModelEventRegistry.d.ts +33 -0
- package/lib/event-registry/ModelEventRegistry.js +79 -0
- package/lib/executor/FlowExecutor.d.ts +25 -0
- package/lib/executor/FlowExecutor.js +290 -0
- package/lib/flow-registry/BaseFlowRegistry.d.ts +46 -0
- package/lib/flow-registry/BaseFlowRegistry.js +86 -0
- package/lib/flow-registry/GlobalFlowRegistry.d.ts +22 -0
- package/lib/flow-registry/GlobalFlowRegistry.js +95 -0
- package/lib/flow-registry/InstanceFlowRegistry.d.ts +21 -0
- package/lib/flow-registry/InstanceFlowRegistry.js +59 -0
- package/lib/flow-registry/index.d.ts +11 -0
- package/lib/flow-registry/index.js +34 -0
- package/lib/flowContext.d.ts +243 -0
- package/lib/flowContext.js +1337 -0
- package/lib/flowEngine.d.ts +340 -0
- package/lib/flowEngine.js +781 -0
- package/lib/flowI18n.d.ts +46 -0
- package/lib/flowI18n.js +117 -0
- package/lib/flowSettings.d.ts +266 -0
- package/lib/flowSettings.js +850 -0
- package/lib/hooks/index.d.ts +14 -0
- package/lib/hooks/index.js +40 -0
- package/lib/hooks/useApplyAutoFlows.d.ts +21 -0
- package/lib/hooks/useApplyAutoFlows.js +63 -0
- package/lib/hooks/useFlowModel.d.ts +29 -0
- package/lib/hooks/useFlowModel.js +72 -0
- package/lib/hooks/useFlowModelById.d.ts +11 -0
- package/lib/hooks/useFlowModelById.js +61 -0
- package/lib/hooks/useFlowSettingsContext.d.ts +20 -0
- package/lib/hooks/useFlowSettingsContext.js +61 -0
- package/lib/hooks/useFlowStep.d.ts +17 -0
- package/lib/hooks/useFlowStep.js +56 -0
- package/lib/hooks/useNiceDropdownMaxHeight.d.ts +13 -0
- package/lib/hooks/useNiceDropdownMaxHeight.js +52 -0
- package/lib/index.d.ts +30 -0
- package/lib/index.js +93 -0
- package/lib/locale/en-US.json +61 -0
- package/lib/locale/index.d.ts +141 -0
- package/lib/locale/index.js +70 -0
- package/lib/locale/zh-CN.json +61 -0
- package/lib/models/CollectionFieldModel.d.ts +52 -0
- package/lib/models/CollectionFieldModel.js +280 -0
- package/lib/models/DisplayItemModel.d.ts +12 -0
- package/lib/models/DisplayItemModel.js +41 -0
- package/lib/models/EditableItemModel.d.ts +12 -0
- package/lib/models/EditableItemModel.js +41 -0
- package/lib/models/FilterableItemModel.d.ts +12 -0
- package/lib/models/FilterableItemModel.js +41 -0
- package/lib/models/flowModel.d.ts +342 -0
- package/lib/models/flowModel.js +1154 -0
- package/lib/models/forkFlowModel.d.ts +83 -0
- package/lib/models/forkFlowModel.js +280 -0
- package/lib/models/index.d.ts +14 -0
- package/lib/models/index.js +40 -0
- package/lib/provider.d.ts +22 -0
- package/lib/provider.js +115 -0
- package/lib/resources/apiResource.d.ts +34 -0
- package/lib/resources/apiResource.js +153 -0
- package/lib/resources/baseRecordResource.d.ts +61 -0
- package/lib/resources/baseRecordResource.js +264 -0
- package/lib/resources/filterItem.d.ts +33 -0
- package/lib/resources/filterItem.js +93 -0
- package/lib/resources/flowResource.d.ts +45 -0
- package/lib/resources/flowResource.js +146 -0
- package/lib/resources/index.d.ts +15 -0
- package/lib/resources/index.js +42 -0
- package/lib/resources/multiRecordResource.d.ts +53 -0
- package/lib/resources/multiRecordResource.js +230 -0
- package/lib/resources/singleRecordResource.d.ts +23 -0
- package/lib/resources/singleRecordResource.js +111 -0
- package/lib/resources/sqlResource.d.ts +73 -0
- package/lib/resources/sqlResource.js +294 -0
- package/lib/runjs-context/contexts/FormJSFieldItemRunJSContext.d.ts +11 -0
- package/lib/runjs-context/contexts/FormJSFieldItemRunJSContext.js +73 -0
- package/lib/runjs-context/contexts/JSBlockRunJSContext.d.ts +11 -0
- package/lib/runjs-context/contexts/JSBlockRunJSContext.js +91 -0
- package/lib/runjs-context/contexts/JSCollectionActionRunJSContext.d.ts +11 -0
- package/lib/runjs-context/contexts/JSCollectionActionRunJSContext.js +58 -0
- package/lib/runjs-context/contexts/JSColumnRunJSContext.d.ts +15 -0
- package/lib/runjs-context/contexts/JSColumnRunJSContext.js +78 -0
- package/lib/runjs-context/contexts/JSFieldRunJSContext.d.ts +11 -0
- package/lib/runjs-context/contexts/JSFieldRunJSContext.js +74 -0
- package/lib/runjs-context/contexts/JSItemRunJSContext.d.ts +11 -0
- package/lib/runjs-context/contexts/JSItemRunJSContext.js +70 -0
- package/lib/runjs-context/contexts/JSRecordActionRunJSContext.d.ts +11 -0
- package/lib/runjs-context/contexts/JSRecordActionRunJSContext.js +60 -0
- package/lib/runjs-context/contexts/base.d.ts +9 -0
- package/lib/runjs-context/contexts/base.js +169 -0
- package/lib/runjs-context/helpers.d.ts +20 -0
- package/lib/runjs-context/helpers.js +88 -0
- package/lib/runjs-context/registry.d.ts +20 -0
- package/lib/runjs-context/registry.js +61 -0
- package/lib/runjs-context/setup.d.ts +9 -0
- package/lib/runjs-context/setup.js +82 -0
- package/lib/runjs-context/snippets/global/api-request.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/api-request.snippet.js +57 -0
- package/lib/runjs-context/snippets/global/import-esm.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/import-esm.snippet.js +58 -0
- package/lib/runjs-context/snippets/global/message-error.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/message-error.snippet.js +47 -0
- package/lib/runjs-context/snippets/global/message-success.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/message-success.snippet.js +47 -0
- package/lib/runjs-context/snippets/global/notification-open.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/notification-open.snippet.js +50 -0
- package/lib/runjs-context/snippets/global/open-view-dialog.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/open-view-dialog.snippet.js +54 -0
- package/lib/runjs-context/snippets/global/open-view-drawer.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/open-view-drawer.snippet.js +54 -0
- package/lib/runjs-context/snippets/global/query-selector.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/query-selector.snippet.js +53 -0
- package/lib/runjs-context/snippets/global/require-amd.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/require-amd.snippet.js +49 -0
- package/lib/runjs-context/snippets/global/window-open.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/window-open.snippet.js +48 -0
- package/lib/runjs-context/snippets/index.d.ts +22 -0
- package/lib/runjs-context/snippets/index.js +213 -0
- package/lib/runjs-context/snippets/scene/block/add-event-listener.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/add-event-listener.snippet.js +55 -0
- package/lib/runjs-context/snippets/scene/block/api-fetch-render-list.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/api-fetch-render-list.snippet.js +64 -0
- package/lib/runjs-context/snippets/scene/block/chartjs-bar.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/chartjs-bar.snippet.js +99 -0
- package/lib/runjs-context/snippets/scene/block/echarts-init.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/echarts-init.snippet.js +63 -0
- package/lib/runjs-context/snippets/scene/block/render-button-handler.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/render-button-handler.snippet.js +52 -0
- package/lib/runjs-context/snippets/scene/block/render-iframe.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/render-iframe.snippet.js +57 -0
- package/lib/runjs-context/snippets/scene/block/render-info-card.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/render-info-card.snippet.js +72 -0
- package/lib/runjs-context/snippets/scene/block/render-react.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/render-react.snippet.js +57 -0
- package/lib/runjs-context/snippets/scene/block/render-statistics.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/render-statistics.snippet.js +100 -0
- package/lib/runjs-context/snippets/scene/block/render-timeline.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/render-timeline.snippet.js +85 -0
- package/lib/runjs-context/snippets/scene/block/resource-example.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/resource-example.snippet.js +60 -0
- package/lib/runjs-context/snippets/scene/block/three-users-orbit.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/three-users-orbit.snippet.js +283 -0
- package/lib/runjs-context/snippets/scene/block/vue-component.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/block/vue-component.snippet.js +124 -0
- package/lib/runjs-context/snippets/scene/detail/color-by-value.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/detail/color-by-value.snippet.js +52 -0
- package/lib/runjs-context/snippets/scene/detail/copy-to-clipboard.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/detail/copy-to-clipboard.snippet.js +64 -0
- package/lib/runjs-context/snippets/scene/detail/format-number.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/detail/format-number.snippet.js +51 -0
- package/lib/runjs-context/snippets/scene/detail/innerHTML-value.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/detail/innerHTML-value.snippet.js +50 -0
- package/lib/runjs-context/snippets/scene/detail/percentage-bar.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/detail/percentage-bar.snippet.js +82 -0
- package/lib/runjs-context/snippets/scene/detail/relative-time.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/detail/relative-time.snippet.js +80 -0
- package/lib/runjs-context/snippets/scene/detail/status-tag.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/detail/status-tag.snippet.js +74 -0
- package/lib/runjs-context/snippets/scene/form/calculate-total.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/calculate-total.snippet.js +63 -0
- package/lib/runjs-context/snippets/scene/form/cascade-select.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/cascade-select.snippet.js +81 -0
- package/lib/runjs-context/snippets/scene/form/conditional-required.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/conditional-required.snippet.js +64 -0
- package/lib/runjs-context/snippets/scene/form/copy-field-values.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/copy-field-values.snippet.js +74 -0
- package/lib/runjs-context/snippets/scene/form/render-basic.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/render-basic.snippet.js +53 -0
- package/lib/runjs-context/snippets/scene/form/set-disabled.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/set-disabled.snippet.js +69 -0
- package/lib/runjs-context/snippets/scene/form/set-field-value.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/set-field-value.snippet.js +68 -0
- package/lib/runjs-context/snippets/scene/form/set-required.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/set-required.snippet.js +69 -0
- package/lib/runjs-context/snippets/scene/form/toggle-multiple-fields.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/toggle-multiple-fields.snippet.js +67 -0
- package/lib/runjs-context/snippets/scene/form/toggle-visible.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/form/toggle-visible.snippet.js +69 -0
- package/lib/runjs-context/snippets/scene/table/cell-open-dialog.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/table/cell-open-dialog.snippet.js +64 -0
- package/lib/runjs-context/snippets/scene/table/collection-selected-count.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/table/collection-selected-count.snippet.js +53 -0
- package/lib/runjs-context/snippets/scene/table/concat-fields.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/table/concat-fields.snippet.js +79 -0
- package/lib/runjs-context/snippets/scene/table/destroy-selected.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/table/destroy-selected.snippet.js +55 -0
- package/lib/runjs-context/snippets/scene/table/export-selected-json.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/table/export-selected-json.snippet.js +64 -0
- package/lib/runjs-context/snippets/scene/table/iterate-selected-rows.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/table/iterate-selected-rows.snippet.js +52 -0
- package/lib/runjs-context/snippets/types.d.ts +24 -0
- package/lib/runjs-context/snippets/types.js +24 -0
- package/lib/types.d.ts +407 -0
- package/lib/types.js +43 -0
- package/lib/utils/autoFlowError.d.ts +16 -0
- package/lib/utils/autoFlowError.js +53 -0
- package/lib/utils/constants.d.ts +29 -0
- package/lib/utils/constants.js +77 -0
- package/lib/utils/context.d.ts +40 -0
- package/lib/utils/context.js +63 -0
- package/lib/utils/createCollectionContextMeta.d.ts +11 -0
- package/lib/utils/createCollectionContextMeta.js +117 -0
- package/lib/utils/exceptions.d.ts +22 -0
- package/lib/utils/exceptions.js +62 -0
- package/lib/utils/flow-definitions.d.ts +11 -0
- package/lib/utils/flow-definitions.js +40 -0
- package/lib/utils/index.d.ts +22 -0
- package/lib/utils/index.js +115 -0
- package/lib/utils/inheritance.d.ts +16 -0
- package/lib/utils/inheritance.js +53 -0
- package/lib/utils/params-resolvers.d.ts +51 -0
- package/lib/utils/params-resolvers.js +309 -0
- package/lib/utils/parsePathnameToViewParams.d.ts +34 -0
- package/lib/utils/parsePathnameToViewParams.js +84 -0
- package/lib/utils/safeGlobals.d.ts +16 -0
- package/lib/utils/safeGlobals.js +179 -0
- package/lib/utils/schema-utils.d.ts +40 -0
- package/lib/utils/schema-utils.js +161 -0
- package/lib/utils/serverContextParams.d.ts +29 -0
- package/lib/utils/serverContextParams.js +106 -0
- package/lib/utils/setupRuntimeContextSteps.d.ts +19 -0
- package/lib/utils/setupRuntimeContextSteps.js +88 -0
- package/lib/utils/translation.d.ts +18 -0
- package/lib/utils/translation.js +58 -0
- package/lib/utils/variablesParams.d.ts +52 -0
- package/lib/utils/variablesParams.js +161 -0
- package/lib/views/DialogComponent.d.ts +22 -0
- package/lib/views/DialogComponent.js +98 -0
- package/lib/views/DrawerComponent.d.ts +11 -0
- package/lib/views/DrawerComponent.js +101 -0
- package/lib/views/FlowView.d.ts +76 -0
- package/lib/views/FlowView.js +81 -0
- package/lib/views/PageComponent.d.ts +10 -0
- package/lib/views/PageComponent.js +168 -0
- package/lib/views/ViewNavigation.d.ts +45 -0
- package/lib/views/ViewNavigation.js +97 -0
- package/lib/views/createViewMeta.d.ts +44 -0
- package/lib/views/createViewMeta.js +377 -0
- package/lib/views/index.d.ts +14 -0
- package/lib/views/index.js +51 -0
- package/lib/views/useDialog.d.ts +32 -0
- package/lib/views/useDialog.js +200 -0
- package/lib/views/useDrawer.d.ts +33 -0
- package/lib/views/useDrawer.js +220 -0
- package/lib/views/usePage.d.ts +32 -0
- package/lib/views/usePage.js +194 -0
- package/lib/views/usePatchElement.d.ts +10 -0
- package/lib/views/usePatchElement.js +54 -0
- package/lib/views/usePopover.d.ts +17 -0
- package/lib/views/usePopover.js +159 -0
- package/package.json +37 -0
- package/src/ContextPathProxy.ts +45 -0
- package/src/ElementProxy.ts +69 -0
- package/src/FlowContextProvider.tsx +42 -0
- package/src/FlowDefinition.ts +275 -0
- package/src/JSRunner.ts +84 -0
- package/src/ReactView.tsx +104 -0
- package/src/ViewScopedFlowEngine.ts +75 -0
- package/src/__tests__/ElementProxy.test.ts +51 -0
- package/src/__tests__/JSRunner.test.ts +92 -0
- package/src/__tests__/ReactView.test.tsx +63 -0
- package/src/__tests__/context-path-proxy.test.ts +35 -0
- package/src/__tests__/flow-engine.test.ts +189 -0
- package/src/__tests__/flowContext.test.ts +2012 -0
- package/src/__tests__/flowContextCreateJSRunner.test.ts +163 -0
- package/src/__tests__/flowEngine.saveModel.test.ts +171 -0
- package/src/__tests__/flowI18n.test.ts +28 -0
- package/src/__tests__/flowModel.getFlows.test.ts +61 -0
- package/src/__tests__/flowModel.openView.navigation.test.ts +78 -0
- package/src/__tests__/flowRunJSContextDefine.test.ts +508 -0
- package/src/__tests__/flowRuntimeContext.test.ts +187 -0
- package/src/__tests__/flowSettings.open.test.tsx +1920 -0
- package/src/__tests__/flowSettings.test.ts +566 -0
- package/src/__tests__/globalFlowRegistry.test.ts +77 -0
- package/src/__tests__/isFieldInterfaceMatch.test.ts +51 -0
- package/src/__tests__/metaTreeNodeCache.test.ts +234 -0
- package/src/__tests__/path-aggregation.test.ts +85 -0
- package/src/__tests__/provider.test.tsx +28 -0
- package/src/__tests__/renderHiddenInConfig.test.tsx +91 -0
- package/src/__tests__/runjsContext.test.ts +241 -0
- package/src/__tests__/runjsContextImplementations.test.ts +217 -0
- package/src/__tests__/runjsContextRuntime.test.ts +269 -0
- package/src/__tests__/runjsEdgeCases.test.ts +281 -0
- package/src/__tests__/runjsLocales.test.ts +36 -0
- package/src/__tests__/runjsRuntimeFeatures.test.ts +449 -0
- package/src/__tests__/runjsSnippets.test.ts +140 -0
- package/src/__tests__/viewScopedFlowEngine.test.ts +212 -0
- package/src/acl/Acl.tsx +109 -0
- package/src/acl/__tests__/Acl.test.tsx +72 -0
- package/src/action-registry/BaseActionRegistry.ts +46 -0
- package/src/action-registry/EngineActionRegistry.ts +32 -0
- package/src/action-registry/ModelActionRegistry.ts +75 -0
- package/src/action-registry/__tests__/engineActionRegistry.test.ts +43 -0
- package/src/action-registry/__tests__/modelActionRegistry.test.ts +107 -0
- package/src/components/DynamicFlowsEditor.tsx +318 -0
- package/src/components/FieldModelRenderer.tsx +68 -0
- package/src/components/FlowContextSelector.tsx +255 -0
- package/src/components/FlowErrorFallback.tsx +316 -0
- package/src/components/FlowModelRenderer.tsx +362 -0
- package/src/components/FormItem.tsx +136 -0
- package/src/components/__tests__/flow-model-render-error-fallback.test.tsx +226 -0
- package/src/components/__tests__/gridDragPlanner.test.ts +494 -0
- package/src/components/common/FlowSettingsButton.tsx +30 -0
- package/src/components/common/index.ts +10 -0
- package/src/components/common/withFlowDesignMode.tsx +49 -0
- package/src/components/dnd/README.md +149 -0
- package/src/components/dnd/findModelUidPosition.ts +26 -0
- package/src/components/dnd/gridDragPlanner.ts +659 -0
- package/src/components/dnd/index.tsx +128 -0
- package/src/components/index.ts +20 -0
- package/src/components/settings/independents/dropdown/FlowsDropdownButton.tsx +279 -0
- package/src/components/settings/independents/dropdown/index.ts +10 -0
- package/src/components/settings/independents/index.ts +2 -0
- package/src/components/settings/index.ts +11 -0
- package/src/components/settings/wrappers/contextual/DefaultSettingsIcon.tsx +617 -0
- package/src/components/settings/wrappers/contextual/FlowsContextMenu.tsx +292 -0
- package/src/components/settings/wrappers/contextual/FlowsFloatContextMenu.tsx +655 -0
- package/src/components/settings/wrappers/contextual/StepRequiredSettingsDialog.tsx +446 -0
- package/src/components/settings/wrappers/contextual/StepSettings.tsx +109 -0
- package/src/components/settings/wrappers/contextual/StepSettingsDialog.tsx +223 -0
- package/src/components/settings/wrappers/contextual/StepSettingsDrawer.tsx +32 -0
- package/src/components/settings/wrappers/contextual/index.ts +15 -0
- package/src/components/settings/wrappers/embedded/FlowSettings.tsx +258 -0
- package/src/components/settings/wrappers/embedded/FlowsSettings.tsx +111 -0
- package/src/components/settings/wrappers/embedded/FlowsSettingsContent.tsx +96 -0
- package/src/components/settings/wrappers/embedded/index.ts +11 -0
- package/src/components/settings/wrappers/index.ts +5 -0
- package/src/components/subModel/AddSubModelButton.tsx +575 -0
- package/src/components/subModel/LazyDropdown.tsx +714 -0
- package/src/components/subModel/__tests__/AddSubModelButton.test.tsx +1185 -0
- package/src/components/subModel/__tests__/buildWrapperFieldChildren.test.ts +192 -0
- package/src/components/subModel/__tests__/utils.test.ts +425 -0
- package/src/components/subModel/index.ts +12 -0
- package/src/components/subModel/utils.ts +278 -0
- package/src/components/variables/InlineVariableTag.tsx +97 -0
- package/src/components/variables/SlateVariableEditor.tsx +384 -0
- package/src/components/variables/VariableInput.tsx +360 -0
- package/src/components/variables/VariableTag.tsx +175 -0
- package/src/components/variables/VariableTrigger.tsx +116 -0
- package/src/components/variables/__tests__/FlowContextSelector.test.tsx +553 -0
- package/src/components/variables/__tests__/VariableInput.test.tsx +550 -0
- package/src/components/variables/__tests__/VariableTag.test.tsx +347 -0
- package/src/components/variables/__tests__/test-utils.tsx +62 -0
- package/src/components/variables/__tests__/utils.test.ts +310 -0
- package/src/components/variables/index.ts +16 -0
- package/src/components/variables/types.ts +100 -0
- package/src/components/variables/useResolvedMetaTree.ts +76 -0
- package/src/components/variables/utils.ts +192 -0
- package/src/data-source/__tests__/collection.test.ts +58 -0
- package/src/data-source/__tests__/index.test.ts +82 -0
- package/src/data-source/__tests__/jioToJoiSchema.test.ts +56 -0
- package/src/data-source/__tests__/sortCollectionsByInherits.test.ts +125 -0
- package/src/data-source/index.ts +816 -0
- package/src/data-source/jioToJoiSchema.ts +103 -0
- package/src/data-source/sortCollectionsByInherits.ts +61 -0
- package/src/decorators/index.ts +10 -0
- package/src/decorators/largeField.ts +14 -0
- package/src/emitter.ts +33 -0
- package/src/event-registry/BaseEventRegistry.ts +40 -0
- package/src/event-registry/EngineEventRegistry.ts +26 -0
- package/src/event-registry/ModelEventRegistry.ts +69 -0
- package/src/event-registry/__tests__/engineEventRegistry.test.ts +48 -0
- package/src/executor/FlowExecutor.ts +302 -0
- package/src/executor/__tests__/eventStep.test.ts +157 -0
- package/src/executor/__tests__/flowExecutor.test.ts +309 -0
- package/src/flow-registry/BaseFlowRegistry.ts +91 -0
- package/src/flow-registry/GlobalFlowRegistry.ts +82 -0
- package/src/flow-registry/InstanceFlowRegistry.ts +39 -0
- package/src/flow-registry/__tests__/globalFlowRegistry.test.ts +141 -0
- package/src/flow-registry/__tests__/instance-and-global-registry.test.ts +67 -0
- package/src/flow-registry/__tests__/instanceFlowRegistry.test.ts +83 -0
- package/src/flow-registry/index.ts +12 -0
- package/src/flowContext.ts +1742 -0
- package/src/flowEngine.ts +905 -0
- package/src/flowI18n.ts +96 -0
- package/src/flowSettings.ts +1045 -0
- package/src/hooks/index.ts +15 -0
- package/src/hooks/useApplyAutoFlows.ts +53 -0
- package/src/hooks/useFlowModel.tsx +59 -0
- package/src/hooks/useFlowModelById.ts +37 -0
- package/src/hooks/useFlowSettingsContext.tsx +37 -0
- package/src/hooks/useFlowStep.tsx +19 -0
- package/src/hooks/useNiceDropdownMaxHeight.ts +34 -0
- package/src/index.ts +46 -0
- package/src/locale/en-US.json +61 -0
- package/src/locale/index.ts +38 -0
- package/src/locale/zh-CN.json +61 -0
- package/src/models/CollectionFieldModel.tsx +306 -0
- package/src/models/DisplayItemModel.tsx +13 -0
- package/src/models/EditableItemModel.tsx +13 -0
- package/src/models/FilterableItemModel.tsx +13 -0
- package/src/models/__tests__/CollectionFieldModel.test.ts +122 -0
- package/src/models/__tests__/defaultParams-on-create.test.ts +83 -0
- package/src/models/__tests__/flow-model-oninit.test.ts +44 -0
- package/src/models/__tests__/flowModel.actions.integration.test.ts +100 -0
- package/src/models/__tests__/flowModel.getFlows.sort.test.ts +100 -0
- package/src/models/__tests__/flowModel.test.ts +2869 -0
- package/src/models/__tests__/flowRegistry.test.ts +512 -0
- package/src/models/__tests__/forkFlowModel.test.ts +1047 -0
- package/src/models/__tests__/model-actions.test.ts +70 -0
- package/src/models/__tests__/model-events.test.ts +69 -0
- package/src/models/flowModel.tsx +1421 -0
- package/src/models/forkFlowModel.ts +319 -0
- package/src/models/index.ts +17 -0
- package/src/provider.tsx +103 -0
- package/src/resources/__tests__/apiResource.test.ts +201 -0
- package/src/resources/__tests__/baseRecordResource.test.ts +262 -0
- package/src/resources/__tests__/filterItem.test.ts +260 -0
- package/src/resources/__tests__/flowResource.test.ts +127 -0
- package/src/resources/apiResource.ts +148 -0
- package/src/resources/baseRecordResource.ts +279 -0
- package/src/resources/filterItem.ts +74 -0
- package/src/resources/flowResource.ts +143 -0
- package/src/resources/index.ts +17 -0
- package/src/resources/multiRecordResource.ts +219 -0
- package/src/resources/singleRecordResource.ts +83 -0
- package/src/resources/sqlResource.ts +299 -0
- package/src/runjs-context/contexts/FormJSFieldItemRunJSContext.ts +46 -0
- package/src/runjs-context/contexts/JSBlockRunJSContext.ts +64 -0
- package/src/runjs-context/contexts/JSCollectionActionRunJSContext.ts +31 -0
- package/src/runjs-context/contexts/JSColumnRunJSContext.ts +58 -0
- package/src/runjs-context/contexts/JSFieldRunJSContext.ts +48 -0
- package/src/runjs-context/contexts/JSItemRunJSContext.ts +43 -0
- package/src/runjs-context/contexts/JSRecordActionRunJSContext.ts +33 -0
- package/src/runjs-context/contexts/base.ts +155 -0
- package/src/runjs-context/helpers.ts +58 -0
- package/src/runjs-context/registry.ts +34 -0
- package/src/runjs-context/setup.ts +51 -0
- package/src/runjs-context/snippets/global/api-request.snippet.ts +38 -0
- package/src/runjs-context/snippets/global/import-esm.snippet.ts +39 -0
- package/src/runjs-context/snippets/global/message-error.snippet.ts +26 -0
- package/src/runjs-context/snippets/global/message-success.snippet.ts +26 -0
- package/src/runjs-context/snippets/global/notification-open.snippet.ts +31 -0
- package/src/runjs-context/snippets/global/open-view-dialog.snippet.ts +33 -0
- package/src/runjs-context/snippets/global/open-view-drawer.snippet.ts +33 -0
- package/src/runjs-context/snippets/global/query-selector.snippet.ts +34 -0
- package/src/runjs-context/snippets/global/require-amd.snippet.ts +30 -0
- package/src/runjs-context/snippets/global/window-open.snippet.ts +29 -0
- package/src/runjs-context/snippets/index.ts +195 -0
- package/src/runjs-context/snippets/scene/block/add-event-listener.snippet.ts +41 -0
- package/src/runjs-context/snippets/scene/block/api-fetch-render-list.snippet.ts +45 -0
- package/src/runjs-context/snippets/scene/block/chartjs-bar.snippet.ts +80 -0
- package/src/runjs-context/snippets/scene/block/echarts-init.snippet.ts +44 -0
- package/src/runjs-context/snippets/scene/block/render-button-handler.snippet.ts +33 -0
- package/src/runjs-context/snippets/scene/block/render-iframe.snippet.ts +38 -0
- package/src/runjs-context/snippets/scene/block/render-info-card.snippet.ts +53 -0
- package/src/runjs-context/snippets/scene/block/render-react.snippet.ts +38 -0
- package/src/runjs-context/snippets/scene/block/render-statistics.snippet.ts +81 -0
- package/src/runjs-context/snippets/scene/block/render-timeline.snippet.ts +66 -0
- package/src/runjs-context/snippets/scene/block/resource-example.snippet.ts +46 -0
- package/src/runjs-context/snippets/scene/block/three-users-orbit.snippet.ts +264 -0
- package/src/runjs-context/snippets/scene/block/vue-component.snippet.ts +105 -0
- package/src/runjs-context/snippets/scene/detail/color-by-value.snippet.ts +33 -0
- package/src/runjs-context/snippets/scene/detail/copy-to-clipboard.snippet.ts +45 -0
- package/src/runjs-context/snippets/scene/detail/format-number.snippet.ts +32 -0
- package/src/runjs-context/snippets/scene/detail/innerHTML-value.snippet.ts +31 -0
- package/src/runjs-context/snippets/scene/detail/percentage-bar.snippet.ts +63 -0
- package/src/runjs-context/snippets/scene/detail/relative-time.snippet.ts +61 -0
- package/src/runjs-context/snippets/scene/detail/status-tag.snippet.ts +55 -0
- package/src/runjs-context/snippets/scene/form/calculate-total.snippet.ts +44 -0
- package/src/runjs-context/snippets/scene/form/cascade-select.snippet.ts +62 -0
- package/src/runjs-context/snippets/scene/form/conditional-required.snippet.ts +45 -0
- package/src/runjs-context/snippets/scene/form/copy-field-values.snippet.ts +55 -0
- package/src/runjs-context/snippets/scene/form/render-basic.snippet.ts +39 -0
- package/src/runjs-context/snippets/scene/form/set-disabled.snippet.ts +50 -0
- package/src/runjs-context/snippets/scene/form/set-field-value.snippet.ts +49 -0
- package/src/runjs-context/snippets/scene/form/set-required.snippet.ts +50 -0
- package/src/runjs-context/snippets/scene/form/toggle-multiple-fields.snippet.ts +48 -0
- package/src/runjs-context/snippets/scene/form/toggle-visible.snippet.ts +50 -0
- package/src/runjs-context/snippets/scene/table/cell-open-dialog.snippet.ts +45 -0
- package/src/runjs-context/snippets/scene/table/collection-selected-count.snippet.ts +34 -0
- package/src/runjs-context/snippets/scene/table/concat-fields.snippet.ts +60 -0
- package/src/runjs-context/snippets/scene/table/destroy-selected.snippet.ts +36 -0
- package/src/runjs-context/snippets/scene/table/export-selected-json.snippet.ts +45 -0
- package/src/runjs-context/snippets/scene/table/iterate-selected-rows.snippet.ts +33 -0
- package/src/runjs-context/snippets/types.ts +21 -0
- package/src/types.ts +484 -0
- package/src/utils/__tests__/context.test.ts +93 -0
- package/src/utils/__tests__/params-resolvers.test.ts +652 -0
- package/src/utils/__tests__/parsePathnameToViewParams.test.ts +104 -0
- package/src/utils/__tests__/safeGlobals.test.ts +29 -0
- package/src/utils/__tests__/utils.test.ts +1021 -0
- package/src/utils/__tests__/variablesParams.test.ts +52 -0
- package/src/utils/autoFlowError.ts +29 -0
- package/src/utils/constants.ts +60 -0
- package/src/utils/context.ts +70 -0
- package/src/utils/createCollectionContextMeta.ts +122 -0
- package/src/utils/exceptions.ts +36 -0
- package/src/utils/flow-definitions.ts +16 -0
- package/src/utils/index.ts +62 -0
- package/src/utils/inheritance.ts +39 -0
- package/src/utils/params-resolvers.ts +482 -0
- package/src/utils/parsePathnameToViewParams.ts +103 -0
- package/src/utils/safeGlobals.ts +188 -0
- package/src/utils/schema-utils.ts +201 -0
- package/src/utils/serverContextParams.ts +112 -0
- package/src/utils/setupRuntimeContextSteps.ts +89 -0
- package/src/utils/translation.ts +37 -0
- package/src/utils/variablesParams.ts +184 -0
- package/src/views/DialogComponent.tsx +79 -0
- package/src/views/DrawerComponent.tsx +72 -0
- package/src/views/FlowView.tsx +103 -0
- package/src/views/PageComponent.tsx +150 -0
- package/src/views/ViewNavigation.ts +122 -0
- package/src/views/__tests__/FlowView.test.ts +31 -0
- package/src/views/__tests__/ViewNavigation.test.ts +191 -0
- package/src/views/__tests__/usePatchElement.test.tsx +28 -0
- package/src/views/createViewMeta.ts +402 -0
- package/src/views/index.tsx +15 -0
- package/src/views/useDialog.tsx +194 -0
- package/src/views/useDrawer.tsx +229 -0
- package/src/views/usePage.tsx +185 -0
- package/src/views/usePatchElement.tsx +27 -0
- package/src/views/usePopover.tsx +131 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 统一的安全全局对象代理:window/document
|
|
12
|
+
* - 默认仅允许常用的定时器、console、Math、Date、addEventListener(绑定原 window)
|
|
13
|
+
* - document 仅允许 createElement/querySelector/querySelectorAll
|
|
14
|
+
* - 不允许随意访问未声明的属性,最小权限原则
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export function createSafeWindow(extra?: Record<string, any>) {
|
|
18
|
+
// 解析相对 URL 使用脱敏 base(不含 query/hash),避免在解析时泄露敏感信息
|
|
19
|
+
const getSafeBaseHref = () => `${window.location.origin}${window.location.pathname}`;
|
|
20
|
+
|
|
21
|
+
// 安全的 window.open 代理
|
|
22
|
+
const safeOpen = (url: string, target?: string, features?: string): Window | null => {
|
|
23
|
+
// 仅允许 http/https 和 about:blank
|
|
24
|
+
const isSafeUrl = (u: string): boolean => {
|
|
25
|
+
try {
|
|
26
|
+
const parsed = new URL(u, getSafeBaseHref()); // 使用脱敏 base
|
|
27
|
+
const protocol = parsed.protocol.toLowerCase();
|
|
28
|
+
if (protocol === 'about:') return parsed.href === 'about:blank';
|
|
29
|
+
return protocol === 'http:' || protocol === 'https:';
|
|
30
|
+
} catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
if (!isSafeUrl(url)) {
|
|
36
|
+
throw new Error('Unsafe URL: window.open only allows http/https/about:blank.');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 强制在新标签页打开,避免覆盖当前页或父窗口
|
|
40
|
+
const sanitizedTarget = '_blank';
|
|
41
|
+
|
|
42
|
+
// 合并并强制加上安全特性
|
|
43
|
+
const enforceFeatures = (f?: string): string => {
|
|
44
|
+
const set = new Set<string>();
|
|
45
|
+
if (f) {
|
|
46
|
+
f.split(',')
|
|
47
|
+
.map((s) => s.trim())
|
|
48
|
+
.filter(Boolean)
|
|
49
|
+
.forEach((part) => {
|
|
50
|
+
const key = part.split('=')[0].trim().toLowerCase();
|
|
51
|
+
if (key !== 'noopener' && key !== 'noreferrer') set.add(part);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
set.add('noopener');
|
|
55
|
+
set.add('noreferrer');
|
|
56
|
+
return Array.from(set).join(',');
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const sanitizedFeatures = enforceFeatures(features);
|
|
60
|
+
|
|
61
|
+
// 调用原生 window.open
|
|
62
|
+
const newWin = window.open.call(window, url, sanitizedTarget, sanitizedFeatures);
|
|
63
|
+
|
|
64
|
+
// 双重保险:禁用 opener(部分浏览器/场景下 features 可能不生效)
|
|
65
|
+
if (newWin && 'opener' in newWin) {
|
|
66
|
+
try {
|
|
67
|
+
(newWin as any).opener = null;
|
|
68
|
+
} catch {
|
|
69
|
+
// ignore
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return newWin;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
// 同源在当前页导航;跨域强制用新标签页 + noreferrer/noopener
|
|
76
|
+
const guardedNavigate = (rawUrl: string, opts?: { replace?: boolean }) => {
|
|
77
|
+
const parsed = new URL(rawUrl, getSafeBaseHref());
|
|
78
|
+
const protocol = parsed.protocol.toLowerCase();
|
|
79
|
+
|
|
80
|
+
const isAboutBlank = protocol === 'about:' && parsed.href === 'about:blank';
|
|
81
|
+
const isHttp = protocol === 'http:' || protocol === 'https:';
|
|
82
|
+
if (!isHttp && !isAboutBlank) {
|
|
83
|
+
throw new Error('Unsafe URL: only http/https/about:blank are allowed.');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (isAboutBlank) {
|
|
87
|
+
return opts?.replace ? window.location.replace('about:blank') : window.location.assign('about:blank');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const sameOrigin =
|
|
91
|
+
parsed.protocol === window.location.protocol &&
|
|
92
|
+
parsed.hostname === window.location.hostname &&
|
|
93
|
+
parsed.port === window.location.port;
|
|
94
|
+
|
|
95
|
+
if (sameOrigin) {
|
|
96
|
+
return opts?.replace ? window.location.replace(parsed.href) : window.location.assign(parsed.href);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const win = safeOpen(parsed.href);
|
|
100
|
+
if (!win) throw new Error('Popup blocked: cross-origin navigation is opened in a new tab.');
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// 只读/脱敏的 location 代理;支持安全的 href 赋值和 assign/replace
|
|
104
|
+
const safeLocation = new Proxy(
|
|
105
|
+
{},
|
|
106
|
+
{
|
|
107
|
+
get(_t, prop: string) {
|
|
108
|
+
switch (prop) {
|
|
109
|
+
case 'origin':
|
|
110
|
+
return window.location.origin;
|
|
111
|
+
case 'protocol':
|
|
112
|
+
return window.location.protocol;
|
|
113
|
+
case 'host':
|
|
114
|
+
return window.location.host;
|
|
115
|
+
case 'hostname':
|
|
116
|
+
return window.location.hostname;
|
|
117
|
+
case 'port':
|
|
118
|
+
return window.location.port;
|
|
119
|
+
case 'pathname':
|
|
120
|
+
return window.location.pathname;
|
|
121
|
+
case 'assign':
|
|
122
|
+
return (u: string) => guardedNavigate(u, { replace: false });
|
|
123
|
+
case 'replace':
|
|
124
|
+
return (u: string) => guardedNavigate(u, { replace: true });
|
|
125
|
+
case 'reload':
|
|
126
|
+
throw new Error('Access to location.reload is not allowed.');
|
|
127
|
+
case 'href':
|
|
128
|
+
throw new Error('Reading location.href is not allowed.');
|
|
129
|
+
default:
|
|
130
|
+
throw new Error(`Access to location property "${prop}" is not allowed.`);
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
set(_t, prop: string, value: any) {
|
|
134
|
+
if (prop === 'href') {
|
|
135
|
+
guardedNavigate(String(value), { replace: false });
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
throw new Error('Mutation on location is not allowed.');
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
const allowedGlobals: Record<string, any> = {
|
|
144
|
+
// 需绑定到原始 window,避免严格模式下触发 Illegal invocation
|
|
145
|
+
setTimeout: window.setTimeout.bind(window),
|
|
146
|
+
clearTimeout: window.clearTimeout.bind(window),
|
|
147
|
+
setInterval: window.setInterval.bind(window),
|
|
148
|
+
clearInterval: window.clearInterval.bind(window),
|
|
149
|
+
console,
|
|
150
|
+
Math,
|
|
151
|
+
Date,
|
|
152
|
+
// 事件侦听仅绑定到真实 window,便于少量需要的全局监听
|
|
153
|
+
addEventListener: addEventListener.bind(window),
|
|
154
|
+
// 安全的 window.open 代理
|
|
155
|
+
open: safeOpen,
|
|
156
|
+
// 安全的 location 代理
|
|
157
|
+
location: safeLocation,
|
|
158
|
+
...(extra || {}),
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
return new Proxy(
|
|
162
|
+
{},
|
|
163
|
+
{
|
|
164
|
+
get(_target, prop: string) {
|
|
165
|
+
if (prop in allowedGlobals) return allowedGlobals[prop];
|
|
166
|
+
throw new Error(`Access to global property "${prop}" is not allowed.`);
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function createSafeDocument(extra?: Record<string, any>) {
|
|
173
|
+
const allowed: Record<string, any> = {
|
|
174
|
+
createElement: document.createElement.bind(document),
|
|
175
|
+
querySelector: document.querySelector.bind(document),
|
|
176
|
+
querySelectorAll: document.querySelectorAll.bind(document),
|
|
177
|
+
...(extra || {}),
|
|
178
|
+
};
|
|
179
|
+
return new Proxy(
|
|
180
|
+
{},
|
|
181
|
+
{
|
|
182
|
+
get(_target, prop: string) {
|
|
183
|
+
if (prop in allowed) return allowed[prop];
|
|
184
|
+
throw new Error(`Access to document property "${prop}" is not allowed.`);
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
);
|
|
188
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { ISchema } from '@formily/json-schema';
|
|
11
|
+
import { Schema } from '@formily/json-schema';
|
|
12
|
+
import type { FlowModel } from '../models';
|
|
13
|
+
import { FlowRuntimeContext } from '../flowContext';
|
|
14
|
+
import type { StepDefinition, StepUIMode } from '../types';
|
|
15
|
+
import { setupRuntimeContextSteps } from './setupRuntimeContextSteps';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 解析 uiSchema,支持静态值和函数形式
|
|
19
|
+
* 函数可以接收 FlowRuntimeContext(在 settings 中)
|
|
20
|
+
* @param {Record<string, ISchema> | ((ctx: FlowRuntimeContext<TModel>) => Record<string, ISchema> | Promise<Record<string, ISchema>>)} uiSchema UI Schema 定义
|
|
21
|
+
* @param {FlowRuntimeContext<TModel>} ctx 上下文
|
|
22
|
+
* @returns {Promise<Record<string, ISchema>>} 解析后的 UI Schema 对象
|
|
23
|
+
*/
|
|
24
|
+
async function resolveUiSchema<TModel extends FlowModel = FlowModel>(
|
|
25
|
+
uiSchema:
|
|
26
|
+
| Record<string, ISchema>
|
|
27
|
+
| ((ctx: FlowRuntimeContext<TModel>) => Record<string, ISchema> | Promise<Record<string, ISchema>>)
|
|
28
|
+
| undefined,
|
|
29
|
+
ctx: FlowRuntimeContext<TModel>,
|
|
30
|
+
): Promise<Record<string, ISchema>> {
|
|
31
|
+
if (!uiSchema) {
|
|
32
|
+
return {};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (typeof uiSchema === 'function') {
|
|
36
|
+
try {
|
|
37
|
+
const result = await uiSchema(ctx);
|
|
38
|
+
return result || {};
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.error('Error resolving uiSchema function:', error);
|
|
41
|
+
return {};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return uiSchema;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 解析 uiMode,支持静态值和函数形式
|
|
50
|
+
* 函数可以接收 FlowRuntimeContext
|
|
51
|
+
* @param {StepUIMode | ((ctx: FlowRuntimeContext<TModel>) => StepUIMode | Promise<StepUIMode>)} uiMode UI模式定义
|
|
52
|
+
* @param {FlowRuntimeContext<TModel>} ctx 上下文
|
|
53
|
+
* @returns {Promise<StepUIMode>} 解析后的 UI 模式
|
|
54
|
+
*/
|
|
55
|
+
export async function resolveUiMode<TModel extends FlowModel = FlowModel>(
|
|
56
|
+
uiMode: StepUIMode | ((ctx: FlowRuntimeContext<TModel>) => StepUIMode | Promise<StepUIMode>) | undefined,
|
|
57
|
+
ctx: FlowRuntimeContext<TModel>,
|
|
58
|
+
): Promise<StepUIMode> {
|
|
59
|
+
if (!uiMode) {
|
|
60
|
+
return 'dialog';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (typeof uiMode === 'function') {
|
|
64
|
+
try {
|
|
65
|
+
const result = await uiMode(ctx);
|
|
66
|
+
return result || 'dialog';
|
|
67
|
+
} catch (error) {
|
|
68
|
+
console.error('Error resolving uiMode function:', error);
|
|
69
|
+
return 'dialog';
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return uiMode;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// 模块级全局缓存,与 useCompile 保持一致
|
|
77
|
+
const compileCache = {};
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 编译 UI Schema 中的表达式
|
|
81
|
+
*
|
|
82
|
+
* @param scope 编译作用域,包含可用的变量和函数(如 t, randomString 等)
|
|
83
|
+
* @param uiSchema 待编译的 UI Schema
|
|
84
|
+
* @param options 编译选项
|
|
85
|
+
* @returns 编译后的 UI Schema
|
|
86
|
+
*/
|
|
87
|
+
export function compileUiSchema(scope: Record<string, any>, uiSchema: any, options: { noCache?: boolean } = {}): any {
|
|
88
|
+
const { noCache = false } = options;
|
|
89
|
+
|
|
90
|
+
const hasVariable = (source: string): boolean => {
|
|
91
|
+
const reg = /\{\{.*?\}\}/g;
|
|
92
|
+
return reg.test(source);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const compile = (source: any): any => {
|
|
96
|
+
let shouldCompile = false;
|
|
97
|
+
let cacheKey: string;
|
|
98
|
+
|
|
99
|
+
// source is expression, for example: {{ t('Add new') }}
|
|
100
|
+
if (typeof source === 'string' && source.startsWith('{{')) {
|
|
101
|
+
shouldCompile = true;
|
|
102
|
+
cacheKey = source;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// source is Component Object, for example: { 'x-component': "Cascader", type: "array", title: "所属地区(行政区划)" }
|
|
106
|
+
if (source && typeof source === 'object' && !Array.isArray(source)) {
|
|
107
|
+
try {
|
|
108
|
+
cacheKey = JSON.stringify(source);
|
|
109
|
+
} catch (e) {
|
|
110
|
+
console.warn('Failed to stringify:', e);
|
|
111
|
+
return source;
|
|
112
|
+
}
|
|
113
|
+
if (compileCache[cacheKey]) return compileCache[cacheKey];
|
|
114
|
+
shouldCompile = hasVariable(cacheKey);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// source is Array, for example: [{ 'title': "{{ t('Admin') }}", name: 'admin' }, { 'title': "{{ t('Root') }}", name: 'root' }]
|
|
118
|
+
if (Array.isArray(source)) {
|
|
119
|
+
try {
|
|
120
|
+
cacheKey = JSON.stringify(source);
|
|
121
|
+
} catch (e) {
|
|
122
|
+
console.warn('Failed to stringify:', e);
|
|
123
|
+
return source;
|
|
124
|
+
}
|
|
125
|
+
if (compileCache[cacheKey]) return compileCache[cacheKey];
|
|
126
|
+
shouldCompile = hasVariable(cacheKey);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (shouldCompile) {
|
|
130
|
+
if (!cacheKey) {
|
|
131
|
+
try {
|
|
132
|
+
return Schema.compile(source, scope);
|
|
133
|
+
} catch (error) {
|
|
134
|
+
console.warn('Failed to compile with Formily Schema.compile:', error);
|
|
135
|
+
return source;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
try {
|
|
139
|
+
if (noCache) {
|
|
140
|
+
return Schema.compile(source, scope);
|
|
141
|
+
}
|
|
142
|
+
compileCache[cacheKey] = compileCache[cacheKey] || Schema.compile(source, scope);
|
|
143
|
+
return compileCache[cacheKey];
|
|
144
|
+
} catch (e) {
|
|
145
|
+
console.log('compileUiSchema error', source, e);
|
|
146
|
+
try {
|
|
147
|
+
return Schema.compile(source, scope);
|
|
148
|
+
} catch (error) {
|
|
149
|
+
return source;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// source is: plain object、string、number、boolean、undefined、null
|
|
155
|
+
return source;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
return compile(uiSchema);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* 解析并合并步骤的完整uiSchema
|
|
163
|
+
* 这个函数提取了在多个组件中重复使用的uiSchema解析和合并逻辑
|
|
164
|
+
* @param model 模型实例
|
|
165
|
+
* @param flow 流程定义
|
|
166
|
+
* @param step 步骤定义
|
|
167
|
+
* @returns 合并后的uiSchema对象,如果为空则返回null
|
|
168
|
+
*/
|
|
169
|
+
export async function resolveStepUiSchema<TModel extends FlowModel = FlowModel>(
|
|
170
|
+
model: TModel,
|
|
171
|
+
flow: any,
|
|
172
|
+
step: StepDefinition,
|
|
173
|
+
): Promise<Record<string, ISchema> | null> {
|
|
174
|
+
// 创建运行时上下文
|
|
175
|
+
const flowRuntimeContext = new FlowRuntimeContext(model, flow.key, 'settings');
|
|
176
|
+
setupRuntimeContextSteps(flowRuntimeContext, flow.steps, model, flow.key);
|
|
177
|
+
flowRuntimeContext.defineProperty('currentStep', { value: step });
|
|
178
|
+
|
|
179
|
+
// 获取步骤的uiSchema
|
|
180
|
+
let stepUiSchema = step.uiSchema;
|
|
181
|
+
|
|
182
|
+
if (step.use) {
|
|
183
|
+
try {
|
|
184
|
+
const action = model.flowEngine?.getAction?.(step.use);
|
|
185
|
+
if (action && action.uiSchema) {
|
|
186
|
+
stepUiSchema = stepUiSchema || action.uiSchema;
|
|
187
|
+
}
|
|
188
|
+
} catch (error) {
|
|
189
|
+
console.warn(`Failed to get action ${step.use}:`, error);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const resolvedStepUiSchema = await resolveUiSchema(stepUiSchema || {}, flowRuntimeContext);
|
|
194
|
+
|
|
195
|
+
// 如果解析后没有可配置的UI Schema,返回null
|
|
196
|
+
if (Object.keys(resolvedStepUiSchema).length === 0) {
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return resolvedStepUiSchema;
|
|
201
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { FlowContext } from '../flowContext';
|
|
11
|
+
|
|
12
|
+
export type RecordRef = {
|
|
13
|
+
collection?: string;
|
|
14
|
+
id?: any; // primary key value
|
|
15
|
+
filterByTk?: any; // alias for id
|
|
16
|
+
dataSourceKey?: string;
|
|
17
|
+
sourceId?: any;
|
|
18
|
+
fields?: string[];
|
|
19
|
+
appends?: string[];
|
|
20
|
+
record?: any; // full record object (try to infer pk from it)
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// Arbitrary key input and flattened output (dot-joined keys)
|
|
24
|
+
export type BuildServerContextParamsInput = Record<string, any>;
|
|
25
|
+
export type ServerContextParams = Record<string, NormalizedRecordParams>;
|
|
26
|
+
|
|
27
|
+
export type NormalizedRecordParams = {
|
|
28
|
+
collection: string;
|
|
29
|
+
filterByTk: any;
|
|
30
|
+
dataSourceKey?: string;
|
|
31
|
+
fields?: string[];
|
|
32
|
+
appends?: string[];
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
function pickDefined<T extends object>(obj: T): T {
|
|
36
|
+
const out: any = {};
|
|
37
|
+
Object.entries(obj || {}).forEach(([k, v]) => {
|
|
38
|
+
if (typeof v !== 'undefined' && v !== null) out[k] = v;
|
|
39
|
+
});
|
|
40
|
+
return out as T;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function resolvePrimaryKey(ctx: FlowContext, dataSourceKey: string, collection: string): string | undefined {
|
|
44
|
+
try {
|
|
45
|
+
const ds = ctx.dataSourceManager?.getDataSource?.(dataSourceKey || 'main');
|
|
46
|
+
const col = ds?.collectionManager?.getCollection?.(collection);
|
|
47
|
+
const pk = col?.getPrimaryKey?.();
|
|
48
|
+
return pk || 'id';
|
|
49
|
+
} catch (e) {
|
|
50
|
+
return 'id';
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function normalizeOne(ctx: FlowContext, ref?: RecordRef): NormalizedRecordParams | undefined {
|
|
55
|
+
if (!ref) return undefined;
|
|
56
|
+
const dataSourceKey = ref.dataSourceKey || 'main';
|
|
57
|
+
const collection = ref.collection || ref.record?.__collectionName;
|
|
58
|
+
if (!collection) return undefined;
|
|
59
|
+
const pk = resolvePrimaryKey(ctx, dataSourceKey, collection) || 'id';
|
|
60
|
+
const filterByTk =
|
|
61
|
+
typeof ref.filterByTk !== 'undefined' ? ref.filterByTk : typeof ref.id !== 'undefined' ? ref.id : ref.record?.[pk];
|
|
62
|
+
if (typeof filterByTk === 'undefined') return undefined;
|
|
63
|
+
return pickDefined({
|
|
64
|
+
collection,
|
|
65
|
+
filterByTk,
|
|
66
|
+
dataSourceKey,
|
|
67
|
+
fields: ref.fields,
|
|
68
|
+
appends: ref.appends,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function buildServerContextParams(
|
|
73
|
+
ctx: FlowContext,
|
|
74
|
+
input: BuildServerContextParamsInput = {},
|
|
75
|
+
): ServerContextParams | undefined {
|
|
76
|
+
// Helper: detect a record-like object
|
|
77
|
+
const isRecordRef = (val: any) => {
|
|
78
|
+
if (!val || typeof val !== 'object') return false;
|
|
79
|
+
return (
|
|
80
|
+
typeof (val as any).collection === 'string' &&
|
|
81
|
+
(typeof (val as any).filterByTk !== 'undefined' || typeof (val as any).id !== 'undefined' || (val as any).record)
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const out: Record<string, NormalizedRecordParams> = {};
|
|
86
|
+
|
|
87
|
+
const visit = (src: any, path: string[]) => {
|
|
88
|
+
if (isRecordRef(src)) {
|
|
89
|
+
const norm = normalizeOne(ctx, src as RecordRef);
|
|
90
|
+
if (norm) {
|
|
91
|
+
const key = path.join('.');
|
|
92
|
+
out[key] = norm;
|
|
93
|
+
}
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (Array.isArray(src)) {
|
|
97
|
+
for (let i = 0; i < src.length; i++) {
|
|
98
|
+
visit(src[i], [...path, String(i)]);
|
|
99
|
+
}
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (src && typeof src === 'object') {
|
|
103
|
+
for (const [k, v] of Object.entries(src)) {
|
|
104
|
+
visit(v, [...path, k]);
|
|
105
|
+
}
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
visit(input, []);
|
|
111
|
+
return Object.keys(out).length ? out : undefined;
|
|
112
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { FlowRuntimeContext } from '../flowContext';
|
|
11
|
+
import { FlowModel } from '../models/flowModel';
|
|
12
|
+
import { DefaultStructure, StepDefinition } from '../types';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 为 FlowRuntimeContext 设置 steps 属性及其 meta 信息
|
|
16
|
+
* @param ctx FlowRuntimeContext 实例
|
|
17
|
+
* @param flowSteps 流定义
|
|
18
|
+
* @param model FlowModel 实例
|
|
19
|
+
* @param flowKey key
|
|
20
|
+
*/
|
|
21
|
+
export function setupRuntimeContextSteps(
|
|
22
|
+
ctx: FlowRuntimeContext<any>,
|
|
23
|
+
flowSteps: Record<string, StepDefinition<FlowModel<DefaultStructure>>>,
|
|
24
|
+
model: FlowModel,
|
|
25
|
+
flowKey: string,
|
|
26
|
+
): void {
|
|
27
|
+
const steps: Record<string, any> = {};
|
|
28
|
+
const stepsMetaProperties: Record<string, any> = {};
|
|
29
|
+
|
|
30
|
+
// 构建 meta 信息和步骤对象
|
|
31
|
+
for (const stepKey in flowSteps) {
|
|
32
|
+
if (Object.prototype.hasOwnProperty.call(flowSteps, stepKey)) {
|
|
33
|
+
const flowStep = flowSteps[stepKey];
|
|
34
|
+
|
|
35
|
+
// 根据 uiSchema 构建细化的 params meta
|
|
36
|
+
const paramsProperties: Record<string, any> = {};
|
|
37
|
+
|
|
38
|
+
if (flowStep.uiSchema && typeof flowStep.uiSchema === 'object') {
|
|
39
|
+
for (const [paramKey, paramSchema] of Object.entries(flowStep.uiSchema)) {
|
|
40
|
+
if (paramSchema && typeof paramSchema === 'object') {
|
|
41
|
+
const schema = paramSchema as any;
|
|
42
|
+
paramsProperties[paramKey] = {
|
|
43
|
+
type: schema.type || 'any',
|
|
44
|
+
title: schema.title || schema['x-decorator-props']?.label || paramKey,
|
|
45
|
+
interface: schema['x-component'],
|
|
46
|
+
uiSchema: schema,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 如果没有参数属性,则隐藏整个step
|
|
53
|
+
const hasParams = Object.keys(paramsProperties).length > 0;
|
|
54
|
+
|
|
55
|
+
stepsMetaProperties[stepKey] = {
|
|
56
|
+
type: 'object',
|
|
57
|
+
title: ctx.t(flowStep.title) || stepKey,
|
|
58
|
+
display: hasParams ? 'default' : 'none',
|
|
59
|
+
properties: hasParams
|
|
60
|
+
? {
|
|
61
|
+
params: {
|
|
62
|
+
type: 'object',
|
|
63
|
+
title: 'Parameters',
|
|
64
|
+
display: 'flatten',
|
|
65
|
+
properties: paramsProperties,
|
|
66
|
+
},
|
|
67
|
+
}
|
|
68
|
+
: undefined,
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// 始终创建步骤对象,确保运行时能够访问
|
|
72
|
+
steps[stepKey] = {
|
|
73
|
+
get params() {
|
|
74
|
+
return model.getStepParams(flowKey, stepKey) || {};
|
|
75
|
+
},
|
|
76
|
+
get uiSchema() {
|
|
77
|
+
return flowStep.uiSchema;
|
|
78
|
+
},
|
|
79
|
+
result: undefined, // result 会在运行时被设置
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// 定义 steps 属性
|
|
85
|
+
// 暂时隐藏 settings 对应的变量选择项:不提供 meta,仅保留运行时访问能力
|
|
86
|
+
ctx.defineProperty('steps', {
|
|
87
|
+
get: () => steps,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { TFuncKey, TOptions } from 'i18next';
|
|
11
|
+
import type { FlowModel } from '../models';
|
|
12
|
+
import { FLOW_ENGINE_NAMESPACE } from './constants';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 获取带有 flow-engine 命名空间的翻译函数
|
|
16
|
+
* @param model FlowModel 实例
|
|
17
|
+
* @returns 翻译函数,自动使用 flow-engine 命名空间
|
|
18
|
+
*/
|
|
19
|
+
export function getT(model: FlowModel): (key: string, options?: any) => string {
|
|
20
|
+
if (model.flowEngine?.translate) {
|
|
21
|
+
return (key: string, options?: any) => {
|
|
22
|
+
// 自动添加 flow-engine 命名空间
|
|
23
|
+
return model.flowEngine.translate(key, { ns: [FLOW_ENGINE_NAMESPACE, 'client'], nsMode: 'fallback', ...options });
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
// 回退到原始键值
|
|
27
|
+
return (key: string) => key;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function escapeT(text: TFuncKey | TFuncKey[], options?: TOptions) {
|
|
31
|
+
if (options) {
|
|
32
|
+
return `{{t(${JSON.stringify(text)}, ${JSON.stringify(options)})}}`;
|
|
33
|
+
}
|
|
34
|
+
return `{{t(${JSON.stringify(text)})}}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { escapeT as tExpr };
|