@nocobase/flow-engine 2.0.0-alpha.2
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 +94 -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 +64 -0
- package/lib/components/FlowModelRenderer.js +254 -0
- package/lib/components/FormItem.d.ts +18 -0
- package/lib/components/FormItem.js +147 -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/getMousePositionOnElement.d.ts +50 -0
- package/lib/components/dnd/getMousePositionOnElement.js +95 -0
- package/lib/components/dnd/index.d.ts +24 -0
- package/lib/components/dnd/index.js +164 -0
- package/lib/components/dnd/moveBlock.d.ts +33 -0
- package/lib/components/dnd/moveBlock.js +302 -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 +206 -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 +322 -0
- package/lib/components/variables/VariableTag.d.ts +11 -0
- package/lib/components/variables/VariableTag.js +148 -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 +733 -0
- package/lib/data-source/jioToJoiSchema.d.ts +19 -0
- package/lib/data-source/jioToJoiSchema.js +114 -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 +26 -0
- package/lib/executor/FlowExecutor.js +262 -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 +215 -0
- package/lib/flowContext.js +1266 -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 +62 -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 +27 -0
- package/lib/index.js +73 -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 +50 -0
- package/lib/models/CollectionFieldModel.js +242 -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 +344 -0
- package/lib/models/flowModel.js +1133 -0
- package/lib/models/forkFlowModel.d.ts +83 -0
- package/lib/models/forkFlowModel.js +257 -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 +114 -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/FlowRunJSContext.d.ts +38 -0
- package/lib/runjs-context/contexts/FlowRunJSContext.js +217 -0
- package/lib/runjs-context/contexts/FormJSFieldItemRunJSContext.d.ts +16 -0
- package/lib/runjs-context/contexts/FormJSFieldItemRunJSContext.js +66 -0
- package/lib/runjs-context/contexts/JSBlockRunJSContext.d.ts +16 -0
- package/lib/runjs-context/contexts/JSBlockRunJSContext.js +78 -0
- package/lib/runjs-context/contexts/JSCollectionActionRunJSContext.d.ts +12 -0
- package/lib/runjs-context/contexts/JSCollectionActionRunJSContext.js +59 -0
- package/lib/runjs-context/contexts/JSFieldRunJSContext.d.ts +16 -0
- package/lib/runjs-context/contexts/JSFieldRunJSContext.js +70 -0
- package/lib/runjs-context/contexts/JSItemRunJSContext.d.ts +16 -0
- package/lib/runjs-context/contexts/JSItemRunJSContext.js +66 -0
- package/lib/runjs-context/contexts/JSRecordActionRunJSContext.d.ts +12 -0
- package/lib/runjs-context/contexts/JSRecordActionRunJSContext.js +61 -0
- package/lib/runjs-context/contexts/LinkageRunJSContext.d.ts +12 -0
- package/lib/runjs-context/contexts/LinkageRunJSContext.js +62 -0
- package/lib/runjs-context/helpers.d.ts +17 -0
- package/lib/runjs-context/helpers.js +79 -0
- package/lib/runjs-context/index.d.ts +19 -0
- package/lib/runjs-context/index.js +57 -0
- package/lib/runjs-context/registry.d.ts +17 -0
- package/lib/runjs-context/registry.js +93 -0
- package/lib/runjs-context/snippets/global/api-request-get.snippet.d.ts +16 -0
- package/lib/runjs-context/snippets/global/api-request-get.snippet.js +42 -0
- package/lib/runjs-context/snippets/global/api-request-post.snippet.d.ts +16 -0
- package/lib/runjs-context/snippets/global/api-request-post.snippet.js +42 -0
- package/lib/runjs-context/snippets/global/console-log-ctx.snippet.d.ts +16 -0
- package/lib/runjs-context/snippets/global/console-log-ctx.snippet.js +41 -0
- package/lib/runjs-context/snippets/global/copy-record-json.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/copy-record-json.snippet.js +42 -0
- package/lib/runjs-context/snippets/global/copy-to-clipboard.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/copy-to-clipboard.snippet.js +42 -0
- package/lib/runjs-context/snippets/global/log-json-record.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/log-json-record.snippet.js +42 -0
- package/lib/runjs-context/snippets/global/message-error.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/message-error.snippet.js +41 -0
- package/lib/runjs-context/snippets/global/message-success.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/message-success.snippet.js +41 -0
- package/lib/runjs-context/snippets/global/notification-open.snippet.d.ts +16 -0
- package/lib/runjs-context/snippets/global/notification-open.snippet.js +43 -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 +47 -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 +47 -0
- package/lib/runjs-context/snippets/global/requireAsync.snippet.d.ts +16 -0
- package/lib/runjs-context/snippets/global/requireAsync.snippet.js +46 -0
- package/lib/runjs-context/snippets/global/sleep.snippet.d.ts +16 -0
- package/lib/runjs-context/snippets/global/sleep.snippet.js +43 -0
- package/lib/runjs-context/snippets/global/try-catch-async.snippet.d.ts +16 -0
- package/lib/runjs-context/snippets/global/try-catch-async.snippet.js +44 -0
- package/lib/runjs-context/snippets/global/view-navigation-push.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/global/view-navigation-push.snippet.js +44 -0
- package/lib/runjs-context/snippets/global/window-open.snippet.d.ts +16 -0
- package/lib/runjs-context/snippets/global/window-open.snippet.js +41 -0
- package/lib/runjs-context/snippets/index.d.ts +11 -0
- package/lib/runjs-context/snippets/index.js +94 -0
- package/lib/runjs-context/snippets/libs/echarts-init.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/libs/echarts-init.snippet.js +46 -0
- package/lib/runjs-context/snippets/scene/actions/collection-selected-count.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/actions/collection-selected-count.snippet.js +44 -0
- package/lib/runjs-context/snippets/scene/actions/iterate-selected-rows.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/actions/iterate-selected-rows.snippet.js +43 -0
- package/lib/runjs-context/snippets/scene/actions/record-id-message.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/actions/record-id-message.snippet.js +43 -0
- package/lib/runjs-context/snippets/scene/actions/run-action-basic.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/actions/run-action-basic.snippet.js +40 -0
- package/lib/runjs-context/snippets/scene/jsblock/add-event-listener.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsblock/add-event-listener.snippet.js +46 -0
- package/lib/runjs-context/snippets/scene/jsblock/append-style.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsblock/append-style.snippet.js +42 -0
- package/lib/runjs-context/snippets/scene/jsblock/jsx-mount.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsblock/jsx-mount.snippet.js +46 -0
- package/lib/runjs-context/snippets/scene/jsblock/jsx-unmount.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsblock/jsx-unmount.snippet.js +41 -0
- package/lib/runjs-context/snippets/scene/jsblock/render-basic.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsblock/render-basic.snippet.js +41 -0
- package/lib/runjs-context/snippets/scene/jsblock/render-button-handler.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsblock/render-button-handler.snippet.js +46 -0
- package/lib/runjs-context/snippets/scene/jsblock/render-card.snippet.d.ts +11 -0
- package/lib/runjs-context/snippets/scene/jsblock/render-card.snippet.js +45 -0
- package/lib/runjs-context/snippets/scene/jsblock/render-react.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsblock/render-react.snippet.js +56 -0
- package/lib/runjs-context/snippets/scene/jsfield/color-by-value.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsfield/color-by-value.snippet.js +42 -0
- package/lib/runjs-context/snippets/scene/jsfield/format-number.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsfield/format-number.snippet.js +41 -0
- package/lib/runjs-context/snippets/scene/jsfield/innerHTML-value.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsfield/innerHTML-value.snippet.js +40 -0
- package/lib/runjs-context/snippets/scene/jsitem/render-basic.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/jsitem/render-basic.snippet.js +44 -0
- package/lib/runjs-context/snippets/scene/linkage/set-disabled.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/linkage/set-disabled.snippet.js +60 -0
- package/lib/runjs-context/snippets/scene/linkage/set-field-value.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/linkage/set-field-value.snippet.js +59 -0
- package/lib/runjs-context/snippets/scene/linkage/set-required.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/linkage/set-required.snippet.js +60 -0
- package/lib/runjs-context/snippets/scene/linkage/toggle-visible.snippet.d.ts +15 -0
- package/lib/runjs-context/snippets/scene/linkage/toggle-visible.snippet.js +60 -0
- package/lib/runjs-context/snippets/types.d.ts +16 -0
- package/lib/runjs-context/snippets/types.js +24 -0
- package/lib/types.d.ts +398 -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 +117 -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 +28 -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 +51 -0
- package/lib/utils/variablesParams.js +150 -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 +167 -0
- package/lib/views/ViewNavigation.d.ts +45 -0
- package/lib/views/ViewNavigation.js +97 -0
- package/lib/views/createViewMeta.d.ts +16 -0
- package/lib/views/createViewMeta.js +171 -0
- package/lib/views/index.d.ts +13 -0
- package/lib/views/index.js +48 -0
- package/lib/views/useDialog.d.ts +32 -0
- package/lib/views/useDialog.js +199 -0
- package/lib/views/useDrawer.d.ts +33 -0
- package/lib/views/useDrawer.js +206 -0
- package/lib/views/usePage.d.ts +32 -0
- package/lib/views/usePage.js +193 -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 +40 -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__/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__/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 +60 -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 +62 -0
- package/src/components/FlowContextSelector.tsx +255 -0
- package/src/components/FlowErrorFallback.tsx +316 -0
- package/src/components/FlowModelRenderer.tsx +428 -0
- package/src/components/FormItem.tsx +130 -0
- package/src/components/__tests__/flow-model-render-error-fallback.test.tsx +226 -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/getMousePositionOnElement.ts +115 -0
- package/src/components/dnd/index.tsx +128 -0
- package/src/components/dnd/moveBlock.ts +379 -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 +217 -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 +342 -0
- package/src/components/variables/VariableTag.tsx +123 -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/index.ts +812 -0
- package/src/data-source/jioToJoiSchema.ts +103 -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 +256 -0
- package/src/executor/__tests__/eventStep.test.ts +157 -0
- package/src/executor/__tests__/flowExecutor.test.ts +163 -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 +1639 -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 +51 -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 +38 -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 +269 -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 +2746 -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 +1398 -0
- package/src/models/forkFlowModel.ts +287 -0
- package/src/models/index.ts +17 -0
- package/src/provider.tsx +101 -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/FlowRunJSContext.ts +190 -0
- package/src/runjs-context/contexts/FormJSFieldItemRunJSContext.ts +39 -0
- package/src/runjs-context/contexts/JSBlockRunJSContext.ts +52 -0
- package/src/runjs-context/contexts/JSCollectionActionRunJSContext.ts +32 -0
- package/src/runjs-context/contexts/JSFieldRunJSContext.ts +43 -0
- package/src/runjs-context/contexts/JSItemRunJSContext.ts +39 -0
- package/src/runjs-context/contexts/JSRecordActionRunJSContext.ts +34 -0
- package/src/runjs-context/contexts/LinkageRunJSContext.ts +35 -0
- package/src/runjs-context/helpers.ts +56 -0
- package/src/runjs-context/index.ts +20 -0
- package/src/runjs-context/registry.ts +65 -0
- package/src/runjs-context/snippets/global/api-request-get.snippet.ts +20 -0
- package/src/runjs-context/snippets/global/api-request-post.snippet.ts +20 -0
- package/src/runjs-context/snippets/global/console-log-ctx.snippet.ts +19 -0
- package/src/runjs-context/snippets/global/copy-record-json.snippet.ts +21 -0
- package/src/runjs-context/snippets/global/copy-to-clipboard.snippet.ts +21 -0
- package/src/runjs-context/snippets/global/log-json-record.snippet.ts +21 -0
- package/src/runjs-context/snippets/global/message-error.snippet.ts +20 -0
- package/src/runjs-context/snippets/global/message-success.snippet.ts +20 -0
- package/src/runjs-context/snippets/global/notification-open.snippet.ts +21 -0
- package/src/runjs-context/snippets/global/open-view-dialog.snippet.ts +26 -0
- package/src/runjs-context/snippets/global/open-view-drawer.snippet.ts +26 -0
- package/src/runjs-context/snippets/global/requireAsync.snippet.ts +24 -0
- package/src/runjs-context/snippets/global/sleep.snippet.ts +21 -0
- package/src/runjs-context/snippets/global/try-catch-async.snippet.ts +22 -0
- package/src/runjs-context/snippets/global/view-navigation-push.snippet.ts +23 -0
- package/src/runjs-context/snippets/global/window-open.snippet.ts +19 -0
- package/src/runjs-context/snippets/index.ts +59 -0
- package/src/runjs-context/snippets/libs/echarts-init.snippet.ts +24 -0
- package/src/runjs-context/snippets/scene/actions/collection-selected-count.snippet.ts +22 -0
- package/src/runjs-context/snippets/scene/actions/iterate-selected-rows.snippet.ts +21 -0
- package/src/runjs-context/snippets/scene/actions/record-id-message.snippet.ts +21 -0
- package/src/runjs-context/snippets/scene/actions/run-action-basic.snippet.ts +18 -0
- package/src/runjs-context/snippets/scene/jsblock/add-event-listener.snippet.ts +29 -0
- package/src/runjs-context/snippets/scene/jsblock/append-style.snippet.ts +20 -0
- package/src/runjs-context/snippets/scene/jsblock/jsx-mount.snippet.ts +24 -0
- package/src/runjs-context/snippets/scene/jsblock/jsx-unmount.snippet.ts +19 -0
- package/src/runjs-context/snippets/scene/jsblock/render-basic.snippet.ts +24 -0
- package/src/runjs-context/snippets/scene/jsblock/render-button-handler.snippet.ts +24 -0
- package/src/runjs-context/snippets/scene/jsblock/render-card.snippet.ts +30 -0
- package/src/runjs-context/snippets/scene/jsblock/render-react.snippet.ts +34 -0
- package/src/runjs-context/snippets/scene/jsfield/color-by-value.snippet.ts +20 -0
- package/src/runjs-context/snippets/scene/jsfield/format-number.snippet.ts +19 -0
- package/src/runjs-context/snippets/scene/jsfield/innerHTML-value.snippet.ts +18 -0
- package/src/runjs-context/snippets/scene/jsitem/render-basic.snippet.ts +27 -0
- package/src/runjs-context/snippets/scene/linkage/set-disabled.snippet.ts +38 -0
- package/src/runjs-context/snippets/scene/linkage/set-field-value.snippet.ts +37 -0
- package/src/runjs-context/snippets/scene/linkage/set-required.snippet.ts +38 -0
- package/src/runjs-context/snippets/scene/linkage/toggle-visible.snippet.ts +38 -0
- package/src/runjs-context/snippets/types.ts +17 -0
- package/src/types.ts +474 -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 +63 -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 +111 -0
- package/src/utils/setupRuntimeContextSteps.ts +89 -0
- package/src/utils/translation.ts +37 -0
- package/src/utils/variablesParams.ts +175 -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 +157 -0
- package/src/views/index.tsx +14 -0
- package/src/views/useDialog.tsx +192 -0
- package/src/views/useDrawer.tsx +205 -0
- package/src/views/usePage.tsx +182 -0
- package/src/views/usePatchElement.tsx +27 -0
- package/src/views/usePopover.tsx +131 -0
|
@@ -0,0 +1,566 @@
|
|
|
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 { describe, test, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
11
|
+
import { FlowSettings } from '../flowSettings';
|
|
12
|
+
import { DefaultSettingsIcon } from '../components/settings/wrappers/contextual/DefaultSettingsIcon';
|
|
13
|
+
import { FlowModel } from '../models';
|
|
14
|
+
import { FlowEngine } from '../flowEngine';
|
|
15
|
+
|
|
16
|
+
// Mock external dependencies
|
|
17
|
+
vi.mock('../components/settings/wrappers/contextual/StepSettingsDialog', () => ({
|
|
18
|
+
openStepSettingsDialog: vi.fn().mockResolvedValue({ success: true, data: 'test-result' }),
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
vi.mock('../components/settings/wrappers/contextual/DefaultSettingsIcon', () => ({
|
|
22
|
+
DefaultSettingsIcon: vi.fn(() => 'DefaultSettingsIcon'),
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
vi.mock('../components/dnd', () => ({
|
|
26
|
+
DragHandler: vi.fn(() => 'DragHandler'),
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
// Mock dynamic imports
|
|
30
|
+
vi.mock('@formily/antd-v5', () => ({
|
|
31
|
+
ArrayBase: vi.fn(() => 'ArrayBase'),
|
|
32
|
+
ArrayCards: vi.fn(() => 'ArrayCards'),
|
|
33
|
+
ArrayCollapse: vi.fn(() => 'ArrayCollapse'),
|
|
34
|
+
ArrayItems: vi.fn(() => 'ArrayItems'),
|
|
35
|
+
ArrayTable: vi.fn(() => 'ArrayTable'),
|
|
36
|
+
ArrayTabs: vi.fn(() => 'ArrayTabs'),
|
|
37
|
+
Cascader: vi.fn(() => 'Cascader'),
|
|
38
|
+
Checkbox: vi.fn(() => 'Checkbox'),
|
|
39
|
+
DatePicker: vi.fn(() => 'DatePicker'),
|
|
40
|
+
Editable: vi.fn(() => 'Editable'),
|
|
41
|
+
Form: vi.fn(() => 'Form'),
|
|
42
|
+
FormDialog: vi.fn(() => 'FormDialog'),
|
|
43
|
+
FormDrawer: vi.fn(() => 'FormDrawer'),
|
|
44
|
+
FormButtonGroup: vi.fn(() => 'FormButtonGroup'),
|
|
45
|
+
FormCollapse: vi.fn(() => 'FormCollapse'),
|
|
46
|
+
FormGrid: vi.fn(() => 'FormGrid'),
|
|
47
|
+
FormItem: vi.fn(() => 'FormItem'),
|
|
48
|
+
FormLayout: vi.fn(() => 'FormLayout'),
|
|
49
|
+
FormStep: vi.fn(() => 'FormStep'),
|
|
50
|
+
FormTab: vi.fn(() => 'FormTab'),
|
|
51
|
+
Input: vi.fn(() => 'Input'),
|
|
52
|
+
NumberPicker: vi.fn(() => 'NumberPicker'),
|
|
53
|
+
Password: vi.fn(() => 'Password'),
|
|
54
|
+
PreviewText: vi.fn(() => 'PreviewText'),
|
|
55
|
+
Radio: vi.fn(() => 'Radio'),
|
|
56
|
+
Reset: vi.fn(() => 'Reset'),
|
|
57
|
+
Select: vi.fn(() => 'Select'),
|
|
58
|
+
SelectTable: vi.fn(() => 'SelectTable'),
|
|
59
|
+
Space: vi.fn(() => 'Space'),
|
|
60
|
+
Submit: vi.fn(() => 'Submit'),
|
|
61
|
+
Switch: vi.fn(() => 'Switch'),
|
|
62
|
+
TimePicker: vi.fn(() => 'TimePicker'),
|
|
63
|
+
Transfer: vi.fn(() => 'Transfer'),
|
|
64
|
+
TreeSelect: vi.fn(() => 'TreeSelect'),
|
|
65
|
+
Upload: vi.fn(() => 'Upload'),
|
|
66
|
+
}));
|
|
67
|
+
|
|
68
|
+
vi.mock('antd', () => {
|
|
69
|
+
const Collapse = Object.assign((props: any) => 'Collapse', { Panel: (props: any) => 'Panel' });
|
|
70
|
+
const FormItem = vi.fn(({ children }: any) => children ?? 'FormItem');
|
|
71
|
+
const Form = Object.assign(
|
|
72
|
+
vi.fn(() => 'Form'),
|
|
73
|
+
{
|
|
74
|
+
Item: FormItem,
|
|
75
|
+
useForm: () => [{ setFieldsValue: vi.fn() }],
|
|
76
|
+
},
|
|
77
|
+
);
|
|
78
|
+
const Input: any = vi.fn(() => 'Input');
|
|
79
|
+
Input.TextArea = vi.fn(() => 'TextArea');
|
|
80
|
+
const InputNumber = vi.fn(() => 'InputNumber');
|
|
81
|
+
const Select = vi.fn(() => 'Select');
|
|
82
|
+
const Switch = vi.fn(() => 'Switch');
|
|
83
|
+
const Alert = vi.fn(() => 'Alert');
|
|
84
|
+
return {
|
|
85
|
+
Button: vi.fn(() => 'Button'),
|
|
86
|
+
Collapse,
|
|
87
|
+
Result: vi.fn(() => 'Result'),
|
|
88
|
+
Form,
|
|
89
|
+
Input,
|
|
90
|
+
InputNumber,
|
|
91
|
+
Select,
|
|
92
|
+
Switch,
|
|
93
|
+
Alert,
|
|
94
|
+
Typography: {
|
|
95
|
+
Paragraph: vi.fn(({ children }: any) => children ?? 'Paragraph'),
|
|
96
|
+
Text: vi.fn(({ children }: any) => children ?? 'Text'),
|
|
97
|
+
},
|
|
98
|
+
} as any;
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
describe('FlowSettings', () => {
|
|
102
|
+
let flowSettings: FlowSettings;
|
|
103
|
+
let consoleSpy: any;
|
|
104
|
+
let engine: FlowEngine;
|
|
105
|
+
|
|
106
|
+
beforeEach(() => {
|
|
107
|
+
engine = new FlowEngine();
|
|
108
|
+
flowSettings = new FlowSettings(engine);
|
|
109
|
+
consoleSpy = {
|
|
110
|
+
log: vi.spyOn(console, 'log').mockImplementation(() => {}),
|
|
111
|
+
warn: vi.spyOn(console, 'warn').mockImplementation(() => {}),
|
|
112
|
+
error: vi.spyOn(console, 'error').mockImplementation(() => {}),
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
afterEach(() => {
|
|
117
|
+
vi.clearAllMocks();
|
|
118
|
+
consoleSpy.log.mockRestore();
|
|
119
|
+
consoleSpy.warn.mockRestore();
|
|
120
|
+
consoleSpy.error.mockRestore();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe('Constructor & Initialization', () => {
|
|
124
|
+
test('should initialize with default values', () => {
|
|
125
|
+
expect(flowSettings.enabled).toBe(false);
|
|
126
|
+
expect(flowSettings.components).toEqual({});
|
|
127
|
+
expect(flowSettings.scopes).toEqual({});
|
|
128
|
+
expect(flowSettings.toolbarItems).toHaveLength(1);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test('should add default toolbar items during construction', () => {
|
|
132
|
+
const toolbarItems = flowSettings.getToolbarItems();
|
|
133
|
+
|
|
134
|
+
expect(toolbarItems).toHaveLength(1);
|
|
135
|
+
|
|
136
|
+
const settingsItem = toolbarItems.find((item) => item.key === 'settings-menu');
|
|
137
|
+
|
|
138
|
+
expect(settingsItem).toBeDefined();
|
|
139
|
+
expect(settingsItem?.component).toBe(DefaultSettingsIcon);
|
|
140
|
+
expect(settingsItem?.sort).toBe(0);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test('should set up observable properties', () => {
|
|
144
|
+
// Test that enabled property is reactive
|
|
145
|
+
const initialEnabled = flowSettings.enabled;
|
|
146
|
+
flowSettings.enable();
|
|
147
|
+
expect(flowSettings.enabled).not.toBe(initialEnabled);
|
|
148
|
+
expect(flowSettings.enabled).toBe(true);
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
describe('Component Registration', () => {
|
|
153
|
+
test('should register single component', () => {
|
|
154
|
+
const TestComponent = () => 'TestComponent';
|
|
155
|
+
flowSettings.registerComponents({ TestComponent });
|
|
156
|
+
|
|
157
|
+
expect(flowSettings.components.TestComponent).toBe(TestComponent);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
test('should register multiple components', () => {
|
|
161
|
+
const Component1 = () => 'Component1';
|
|
162
|
+
const Component2 = () => 'Component2';
|
|
163
|
+
|
|
164
|
+
flowSettings.registerComponents({ Component1, Component2 });
|
|
165
|
+
|
|
166
|
+
expect(flowSettings.components.Component1).toBe(Component1);
|
|
167
|
+
expect(flowSettings.components.Component2).toBe(Component2);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
test('should warn when overwriting existing component', () => {
|
|
171
|
+
const Component1 = () => 'Component1';
|
|
172
|
+
const Component1Updated = () => 'Component1Updated';
|
|
173
|
+
|
|
174
|
+
flowSettings.registerComponents({ Component1 });
|
|
175
|
+
flowSettings.registerComponents({ Component1: Component1Updated });
|
|
176
|
+
|
|
177
|
+
expect(consoleSpy.warn).toHaveBeenCalledWith(
|
|
178
|
+
"FlowSettings: Component with name 'Component1' is already registered and will be overwritten.",
|
|
179
|
+
);
|
|
180
|
+
expect(flowSettings.components.Component1).toBe(Component1Updated);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
test('should handle empty components object', () => {
|
|
184
|
+
flowSettings.registerComponents({});
|
|
185
|
+
expect(Object.keys(flowSettings.components)).toHaveLength(0);
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
describe('Scope Registration', () => {
|
|
190
|
+
test('should register single scope', () => {
|
|
191
|
+
const testHook = () => 'testHook';
|
|
192
|
+
flowSettings.registerScopes({ testHook });
|
|
193
|
+
|
|
194
|
+
expect(flowSettings.scopes.testHook).toBe(testHook);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
test('should register multiple scopes', () => {
|
|
198
|
+
const hook1 = () => 'hook1';
|
|
199
|
+
const variable1 = 'variable1';
|
|
200
|
+
const function1 = () => 'function1';
|
|
201
|
+
|
|
202
|
+
flowSettings.registerScopes({ hook1, variable1, function1 });
|
|
203
|
+
|
|
204
|
+
expect(flowSettings.scopes.hook1).toBe(hook1);
|
|
205
|
+
expect(flowSettings.scopes.variable1).toBe(variable1);
|
|
206
|
+
expect(flowSettings.scopes.function1).toBe(function1);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
test('should warn when overwriting existing scope', () => {
|
|
210
|
+
const scope1 = () => 'scope1';
|
|
211
|
+
const scope1Updated = () => 'scope1Updated';
|
|
212
|
+
|
|
213
|
+
flowSettings.registerScopes({ scope1 });
|
|
214
|
+
flowSettings.registerScopes({ scope1: scope1Updated });
|
|
215
|
+
|
|
216
|
+
expect(consoleSpy.warn).toHaveBeenCalledWith(
|
|
217
|
+
"FlowSettings: Scope with name 'scope1' is already registered and will be overwritten.",
|
|
218
|
+
);
|
|
219
|
+
expect(flowSettings.scopes.scope1).toBe(scope1Updated);
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
test('should handle empty scopes object', () => {
|
|
223
|
+
flowSettings.registerScopes({});
|
|
224
|
+
expect(Object.keys(flowSettings.scopes)).toHaveLength(0);
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
describe('Enable/Disable Functionality', () => {
|
|
229
|
+
test('should enable flow settings', () => {
|
|
230
|
+
expect(flowSettings.enabled).toBe(false);
|
|
231
|
+
|
|
232
|
+
flowSettings.enable();
|
|
233
|
+
|
|
234
|
+
expect(flowSettings.enabled).toBe(true);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
test('should disable flow settings', () => {
|
|
238
|
+
flowSettings.enable();
|
|
239
|
+
expect(flowSettings.enabled).toBe(true);
|
|
240
|
+
|
|
241
|
+
flowSettings.disable();
|
|
242
|
+
|
|
243
|
+
expect(flowSettings.enabled).toBe(false);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
test('should handle multiple enable/disable calls', () => {
|
|
247
|
+
flowSettings.enable();
|
|
248
|
+
flowSettings.enable();
|
|
249
|
+
expect(flowSettings.enabled).toBe(true);
|
|
250
|
+
|
|
251
|
+
flowSettings.disable();
|
|
252
|
+
flowSettings.disable();
|
|
253
|
+
expect(flowSettings.enabled).toBe(false);
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
describe('Resource Loading', () => {
|
|
258
|
+
test('should load Antd components successfully', async () => {
|
|
259
|
+
await flowSettings.load();
|
|
260
|
+
|
|
261
|
+
// Verify all expected components are registered
|
|
262
|
+
const expectedComponents = [
|
|
263
|
+
'Form',
|
|
264
|
+
'FormDialog',
|
|
265
|
+
'FormDrawer',
|
|
266
|
+
'FormItem',
|
|
267
|
+
'FormLayout',
|
|
268
|
+
'FormGrid',
|
|
269
|
+
'FormStep',
|
|
270
|
+
'FormTab',
|
|
271
|
+
'FormCollapse',
|
|
272
|
+
'FormButtonGroup',
|
|
273
|
+
'Input',
|
|
274
|
+
'NumberPicker',
|
|
275
|
+
'Password',
|
|
276
|
+
'Select',
|
|
277
|
+
'SelectTable',
|
|
278
|
+
'Cascader',
|
|
279
|
+
'TreeSelect',
|
|
280
|
+
'Transfer',
|
|
281
|
+
'DatePicker',
|
|
282
|
+
'TimePicker',
|
|
283
|
+
'Checkbox',
|
|
284
|
+
'Radio',
|
|
285
|
+
'Switch',
|
|
286
|
+
'ArrayBase',
|
|
287
|
+
'ArrayCards',
|
|
288
|
+
'ArrayCollapse',
|
|
289
|
+
'ArrayItems',
|
|
290
|
+
'ArrayTable',
|
|
291
|
+
'ArrayTabs',
|
|
292
|
+
'Upload',
|
|
293
|
+
'Space',
|
|
294
|
+
'Editable',
|
|
295
|
+
'PreviewText',
|
|
296
|
+
'Button',
|
|
297
|
+
'Submit',
|
|
298
|
+
'Reset',
|
|
299
|
+
];
|
|
300
|
+
|
|
301
|
+
expectedComponents.forEach((componentName) => {
|
|
302
|
+
expect(flowSettings.components[componentName]).toBeDefined();
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
describe('Toolbar Item Management', () => {
|
|
308
|
+
describe('addToolbarItem', () => {
|
|
309
|
+
test('should add new toolbar item', () => {
|
|
310
|
+
const TestIcon = () => 'TestIcon';
|
|
311
|
+
const config = {
|
|
312
|
+
key: 'test-item',
|
|
313
|
+
component: TestIcon,
|
|
314
|
+
sort: 10,
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
flowSettings.addToolbarItem(config);
|
|
318
|
+
|
|
319
|
+
const items = flowSettings.getToolbarItems();
|
|
320
|
+
const testItem = items.find((item) => item.key === 'test-item');
|
|
321
|
+
|
|
322
|
+
expect(testItem).toBeDefined();
|
|
323
|
+
expect(testItem?.component).toBe(TestIcon);
|
|
324
|
+
expect(testItem?.sort).toBe(10);
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
test('should replace existing toolbar item with same key', () => {
|
|
328
|
+
const TestIcon1 = () => 'TestIcon1';
|
|
329
|
+
const TestIcon2 = () => 'TestIcon2';
|
|
330
|
+
|
|
331
|
+
flowSettings.addToolbarItem({
|
|
332
|
+
key: 'duplicate-key',
|
|
333
|
+
component: TestIcon1,
|
|
334
|
+
sort: 10,
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
flowSettings.addToolbarItem({
|
|
338
|
+
key: 'duplicate-key',
|
|
339
|
+
component: TestIcon2,
|
|
340
|
+
sort: 20,
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
expect(consoleSpy.warn).toHaveBeenCalledWith(
|
|
344
|
+
"FlowSettings: Toolbar item with key 'duplicate-key' already exists and will be replaced.",
|
|
345
|
+
);
|
|
346
|
+
|
|
347
|
+
const items = flowSettings.getToolbarItems();
|
|
348
|
+
const duplicateItems = items.filter((item) => item.key === 'duplicate-key');
|
|
349
|
+
|
|
350
|
+
expect(duplicateItems).toHaveLength(1);
|
|
351
|
+
expect(duplicateItems[0].component).toBe(TestIcon2);
|
|
352
|
+
expect(duplicateItems[0].sort).toBe(20);
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
test('should sort toolbar items by sort field (descending)', () => {
|
|
356
|
+
const Icon1 = () => 'Icon1';
|
|
357
|
+
const Icon2 = () => 'Icon2';
|
|
358
|
+
const Icon3 = () => 'Icon3';
|
|
359
|
+
|
|
360
|
+
flowSettings.addToolbarItem({ key: 'item1', component: Icon1, sort: 10 });
|
|
361
|
+
flowSettings.addToolbarItem({ key: 'item2', component: Icon2, sort: 30 });
|
|
362
|
+
flowSettings.addToolbarItem({ key: 'item3', component: Icon3, sort: 20 });
|
|
363
|
+
|
|
364
|
+
const items = flowSettings.getToolbarItems();
|
|
365
|
+
const customItems = items.filter((item) => ['item1', 'item2', 'item3'].includes(item.key));
|
|
366
|
+
|
|
367
|
+
expect(customItems[0].key).toBe('item2'); // sort: 30
|
|
368
|
+
expect(customItems[1].key).toBe('item3'); // sort: 20
|
|
369
|
+
expect(customItems[2].key).toBe('item1'); // sort: 10
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
test('should handle items with undefined sort', () => {
|
|
373
|
+
const TestIcon = () => 'TestIcon';
|
|
374
|
+
|
|
375
|
+
flowSettings.addToolbarItem({
|
|
376
|
+
key: 'no-sort-item',
|
|
377
|
+
component: TestIcon,
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
const items = flowSettings.getToolbarItems();
|
|
381
|
+
const item = items.find((item) => item.key === 'no-sort-item');
|
|
382
|
+
|
|
383
|
+
expect(item).toBeDefined();
|
|
384
|
+
expect(item?.sort).toBeUndefined();
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
describe('addToolbarItems', () => {
|
|
389
|
+
test('should add multiple toolbar items', () => {
|
|
390
|
+
const Icon1 = () => 'Icon1';
|
|
391
|
+
const Icon2 = () => 'Icon2';
|
|
392
|
+
|
|
393
|
+
const configs = [
|
|
394
|
+
{ key: 'multi-item1', component: Icon1, sort: 10 },
|
|
395
|
+
{ key: 'multi-item2', component: Icon2, sort: 20 },
|
|
396
|
+
];
|
|
397
|
+
|
|
398
|
+
flowSettings.addToolbarItems(configs);
|
|
399
|
+
|
|
400
|
+
const items = flowSettings.getToolbarItems();
|
|
401
|
+
|
|
402
|
+
expect(items.find((item) => item.key === 'multi-item1')).toBeDefined();
|
|
403
|
+
expect(items.find((item) => item.key === 'multi-item2')).toBeDefined();
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
test('should handle empty array', () => {
|
|
407
|
+
const initialLength = flowSettings.getToolbarItems().length;
|
|
408
|
+
|
|
409
|
+
flowSettings.addToolbarItems([]);
|
|
410
|
+
|
|
411
|
+
expect(flowSettings.getToolbarItems()).toHaveLength(initialLength);
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
describe('removeToolbarItem', () => {
|
|
416
|
+
test('should remove existing toolbar item', () => {
|
|
417
|
+
const TestIcon = () => 'TestIcon';
|
|
418
|
+
|
|
419
|
+
flowSettings.addToolbarItem({
|
|
420
|
+
key: 'remove-test',
|
|
421
|
+
component: TestIcon,
|
|
422
|
+
sort: 10,
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
let items = flowSettings.getToolbarItems();
|
|
426
|
+
expect(items.find((item) => item.key === 'remove-test')).toBeDefined();
|
|
427
|
+
|
|
428
|
+
flowSettings.removeToolbarItem('remove-test');
|
|
429
|
+
|
|
430
|
+
items = flowSettings.getToolbarItems();
|
|
431
|
+
expect(items.find((item) => item.key === 'remove-test')).toBeUndefined();
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
test('should handle removal of non-existent item', () => {
|
|
435
|
+
const initialLength = flowSettings.getToolbarItems().length;
|
|
436
|
+
|
|
437
|
+
flowSettings.removeToolbarItem('non-existent-key');
|
|
438
|
+
|
|
439
|
+
expect(flowSettings.getToolbarItems()).toHaveLength(initialLength);
|
|
440
|
+
});
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
describe('getToolbarItems', () => {
|
|
444
|
+
test('should return copy of toolbar items', () => {
|
|
445
|
+
const items1 = flowSettings.getToolbarItems();
|
|
446
|
+
const items2 = flowSettings.getToolbarItems();
|
|
447
|
+
|
|
448
|
+
expect(items1).not.toBe(items2); // Different references
|
|
449
|
+
expect(items1).toEqual(items2); // Same content
|
|
450
|
+
});
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
describe('clearToolbarItems', () => {
|
|
454
|
+
test('should clear all toolbar items', () => {
|
|
455
|
+
const TestIcon = () => 'TestIcon';
|
|
456
|
+
|
|
457
|
+
flowSettings.addToolbarItem({
|
|
458
|
+
key: 'clear-test',
|
|
459
|
+
component: TestIcon,
|
|
460
|
+
sort: 10,
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
expect(flowSettings.getToolbarItems().length).toBeGreaterThan(0);
|
|
464
|
+
|
|
465
|
+
flowSettings.clearToolbarItems();
|
|
466
|
+
|
|
467
|
+
expect(flowSettings.getToolbarItems()).toHaveLength(0);
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
test('should handle clearing empty toolbar items', () => {
|
|
471
|
+
flowSettings.clearToolbarItems();
|
|
472
|
+
flowSettings.clearToolbarItems();
|
|
473
|
+
|
|
474
|
+
expect(flowSettings.getToolbarItems()).toHaveLength(0);
|
|
475
|
+
});
|
|
476
|
+
});
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
describe('Step Settings Dialog', () => {
|
|
480
|
+
test('should call openStepSettingsDialog with correct parameters', async () => {
|
|
481
|
+
const { openStepSettingsDialog } = await import('../components/settings/wrappers/contextual/StepSettingsDialog');
|
|
482
|
+
|
|
483
|
+
const props = {
|
|
484
|
+
model: new FlowModel({ uid: 'test-model', flowEngine: new FlowEngine() }),
|
|
485
|
+
flowKey: 'test-flow',
|
|
486
|
+
stepKey: 'test-step',
|
|
487
|
+
dialogWidth: 800,
|
|
488
|
+
dialogTitle: 'Test Dialog',
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
const result = await flowSettings.openStepSettingsDialog(props);
|
|
492
|
+
|
|
493
|
+
expect(openStepSettingsDialog).toHaveBeenCalledWith(props);
|
|
494
|
+
expect(result).toEqual({ success: true, data: 'test-result' });
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
test('should handle dialog errors', async () => {
|
|
498
|
+
const { openStepSettingsDialog } = await import('../components/settings/wrappers/contextual/StepSettingsDialog');
|
|
499
|
+
|
|
500
|
+
(openStepSettingsDialog as any).mockRejectedValueOnce(new Error('Dialog error'));
|
|
501
|
+
|
|
502
|
+
const props = {
|
|
503
|
+
model: new FlowModel({ uid: 'test-model', flowEngine: new FlowEngine() }),
|
|
504
|
+
flowKey: 'test-flow',
|
|
505
|
+
stepKey: 'test-step',
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
await expect(flowSettings.openStepSettingsDialog(props)).rejects.toThrow('Dialog error');
|
|
509
|
+
});
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
describe('Complex Integration Scenarios', () => {
|
|
513
|
+
test('should maintain state consistency during multiple operations', () => {
|
|
514
|
+
// Initialize with components and scopes
|
|
515
|
+
const TestComponent = () => 'TestComponent';
|
|
516
|
+
const testScope = () => 'testScope';
|
|
517
|
+
|
|
518
|
+
flowSettings.registerComponents({ TestComponent });
|
|
519
|
+
flowSettings.registerScopes({ testScope });
|
|
520
|
+
|
|
521
|
+
// Add toolbar items
|
|
522
|
+
flowSettings.addToolbarItem({
|
|
523
|
+
key: 'integration-test',
|
|
524
|
+
component: TestComponent,
|
|
525
|
+
sort: 15,
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
// Enable/disable
|
|
529
|
+
flowSettings.enable();
|
|
530
|
+
expect(flowSettings.enabled).toBe(true);
|
|
531
|
+
|
|
532
|
+
// Verify all state is maintained
|
|
533
|
+
expect(flowSettings.components.TestComponent).toBe(TestComponent);
|
|
534
|
+
expect(flowSettings.scopes.testScope).toBe(testScope);
|
|
535
|
+
expect(flowSettings.getToolbarItems().find((item) => item.key === 'integration-test')).toBeDefined();
|
|
536
|
+
|
|
537
|
+
flowSettings.disable();
|
|
538
|
+
expect(flowSettings.enabled).toBe(false);
|
|
539
|
+
|
|
540
|
+
// State should still be maintained after disable
|
|
541
|
+
expect(flowSettings.components.TestComponent).toBe(TestComponent);
|
|
542
|
+
expect(flowSettings.scopes.testScope).toBe(testScope);
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
test('should handle complex toolbar sorting scenarios', () => {
|
|
546
|
+
// Clear default items for this test
|
|
547
|
+
flowSettings.clearToolbarItems();
|
|
548
|
+
|
|
549
|
+
const items = [
|
|
550
|
+
{ key: 'item-a', component: () => 'A', sort: 10 },
|
|
551
|
+
{ key: 'item-b', component: () => 'B' }, // no sort (should be 0)
|
|
552
|
+
{ key: 'item-c', component: () => 'C', sort: 30 },
|
|
553
|
+
{ key: 'item-d', component: () => 'D', sort: 10 }, // duplicate sort
|
|
554
|
+
{ key: 'item-e', component: () => 'E', sort: 5 },
|
|
555
|
+
];
|
|
556
|
+
|
|
557
|
+
items.forEach((item) => flowSettings.addToolbarItem(item));
|
|
558
|
+
|
|
559
|
+
const sortedItems = flowSettings.getToolbarItems();
|
|
560
|
+
const keys = sortedItems.map((item) => item.key);
|
|
561
|
+
|
|
562
|
+
// Expected order: item-c (30), then items with sort 10 (order of insertion: item-a, item-d), item-e (5), item-b (0)
|
|
563
|
+
expect(keys).toEqual(['item-c', 'item-a', 'item-d', 'item-e', 'item-b']);
|
|
564
|
+
});
|
|
565
|
+
});
|
|
566
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
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 { describe, it, expect } from 'vitest';
|
|
11
|
+
import { FlowModel } from '@nocobase/flow-engine';
|
|
12
|
+
|
|
13
|
+
describe('GlobalFlowRegistry (class-level flows)', () => {
|
|
14
|
+
class BaseModel extends FlowModel {}
|
|
15
|
+
class ChildModel extends BaseModel {}
|
|
16
|
+
|
|
17
|
+
it('adds and gets class-level flows via FlowDefinition', () => {
|
|
18
|
+
const gr = ChildModel.globalFlowRegistry;
|
|
19
|
+
const def = gr.addFlow('alpha', {
|
|
20
|
+
key: 'alpha',
|
|
21
|
+
title: 'Alpha',
|
|
22
|
+
steps: {
|
|
23
|
+
s1: {
|
|
24
|
+
title: 'S1',
|
|
25
|
+
// inline handler for testing
|
|
26
|
+
handler: (ctx: any, params: any) => 'ok',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
expect(def).toBeTruthy();
|
|
32
|
+
const got = gr.getFlow('alpha');
|
|
33
|
+
expect(got).toBeTruthy();
|
|
34
|
+
expect(got?.key).toBe('alpha');
|
|
35
|
+
expect(got?.title).toBe('Alpha');
|
|
36
|
+
|
|
37
|
+
const flows = gr.getFlows();
|
|
38
|
+
expect(flows instanceof Map).toBe(true);
|
|
39
|
+
expect(flows.has('alpha')).toBe(true);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('inherits parent flows and allows child overrides (child first)', () => {
|
|
43
|
+
const parentGR = BaseModel.globalFlowRegistry;
|
|
44
|
+
const childGR = ChildModel.globalFlowRegistry;
|
|
45
|
+
|
|
46
|
+
parentGR.addFlow('common', {
|
|
47
|
+
key: 'common',
|
|
48
|
+
title: 'FromParent',
|
|
49
|
+
steps: {
|
|
50
|
+
p: { title: 'P', handler: (ctx: any, params: any) => {} },
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// 子类能看到父类的 flow
|
|
55
|
+
let def = childGR.getFlow('common');
|
|
56
|
+
expect(def).toBeTruthy();
|
|
57
|
+
expect(def?.title).toBe('FromParent');
|
|
58
|
+
|
|
59
|
+
// 子类覆盖同名 flow
|
|
60
|
+
childGR.addFlow('common', {
|
|
61
|
+
key: 'common',
|
|
62
|
+
title: 'FromChild',
|
|
63
|
+
steps: { c: { title: 'C', handler: (ctx: any, params: any) => {} } },
|
|
64
|
+
});
|
|
65
|
+
def = childGR.getFlow('common');
|
|
66
|
+
expect(def?.title).toBe('FromChild');
|
|
67
|
+
|
|
68
|
+
// 父类仍保持不变
|
|
69
|
+
const parentDef = parentGR.getFlow('common');
|
|
70
|
+
expect(parentDef?.title).toBe('FromParent');
|
|
71
|
+
|
|
72
|
+
// getFlows 包含父类 + 子类(子类覆盖父类)
|
|
73
|
+
const flows = childGR.getFlows();
|
|
74
|
+
expect(flows.has('common')).toBe(true);
|
|
75
|
+
expect(flows.get('common')?.title).toBe('FromChild');
|
|
76
|
+
});
|
|
77
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
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 { describe, expect, it } from 'vitest';
|
|
11
|
+
import { isFieldInterfaceMatch } from '../data-source';
|
|
12
|
+
|
|
13
|
+
describe('isFieldInterfaceMatch', () => {
|
|
14
|
+
it('should return true when fieldInterfaces is "*" (string)', () => {
|
|
15
|
+
expect(isFieldInterfaceMatch('*', 'a')).toBe(true);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should return false when fieldInterfaces is a string not matching target', () => {
|
|
19
|
+
expect(isFieldInterfaceMatch('b', 'a')).toBe(false);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should return true when fieldInterfaces is a string matching target', () => {
|
|
23
|
+
expect(isFieldInterfaceMatch('a', 'a')).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should return false when fieldInterfaces is array not containing target', () => {
|
|
27
|
+
expect(isFieldInterfaceMatch(['b', 'c'], 'a')).toBe(false);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should return true when fieldInterfaces is array containing target', () => {
|
|
31
|
+
expect(isFieldInterfaceMatch(['a', 'b'], 'a')).toBe(true);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should return true when fieldInterfaces is array containing "*"', () => {
|
|
35
|
+
expect(isFieldInterfaceMatch(['*', 'b'], 'a')).toBe(true);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should return false when fieldInterfaces is null', () => {
|
|
39
|
+
expect(isFieldInterfaceMatch(null, 'a')).toBe(false);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should return false when fieldInterfaces is undefined', () => {
|
|
43
|
+
expect(isFieldInterfaceMatch(undefined, 'a')).toBe(false);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should return false when targetInterface is empty string', () => {
|
|
47
|
+
expect(isFieldInterfaceMatch('a', '')).toBe(false);
|
|
48
|
+
expect(isFieldInterfaceMatch(['a', 'b'], '')).toBe(false);
|
|
49
|
+
expect(isFieldInterfaceMatch('*', '')).toBe(true); // '*' 匹配任何字符串,包括空字符串
|
|
50
|
+
});
|
|
51
|
+
});
|