@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,482 @@
|
|
|
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 _ from 'lodash';
|
|
11
|
+
import { FlowContext, FlowModelContext, FlowRuntimeContext } from '../flowContext';
|
|
12
|
+
import { getValuesByPath } from '@nocobase/utils/client';
|
|
13
|
+
import type { FlowModel } from '../models';
|
|
14
|
+
import type { ServerContextParams } from './serverContextParams';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 解析 defaultParams,支持静态值和函数形式
|
|
18
|
+
* @param {Record<string, any> | ((ctx: any) => Record<string, any> | Promise<Record<string, any>>)} defaultParams 默认参数
|
|
19
|
+
* @param {FlowRuntimeContext<TModel>} ctx 上下文
|
|
20
|
+
* @returns {Promise<Record<string, any>>} 解析后的参数对象
|
|
21
|
+
*/
|
|
22
|
+
export async function resolveDefaultParams<TModel extends FlowModel = FlowModel>(
|
|
23
|
+
defaultParams: Record<string, any> | ((ctx: any) => Record<string, any> | Promise<Record<string, any>>) | undefined,
|
|
24
|
+
ctx: FlowContext,
|
|
25
|
+
): Promise<Record<string, any>> {
|
|
26
|
+
if (!defaultParams) {
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (typeof defaultParams === 'function') {
|
|
31
|
+
try {
|
|
32
|
+
const result = await defaultParams(ctx);
|
|
33
|
+
return result || {};
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.error('Error resolving defaultParams function:', error);
|
|
36
|
+
return {};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return defaultParams;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 解析 FlowModelMeta 中的 createModelOptions,支持静态值和函数形式
|
|
45
|
+
* @param defaultOptions - 可以是静态对象或返回对象的函数
|
|
46
|
+
* @param ctx - 模型上下文实例,用于传递给函数形式
|
|
47
|
+
* @returns 解析后的选项对象
|
|
48
|
+
*/
|
|
49
|
+
export async function resolveCreateModelOptions(
|
|
50
|
+
createModelOptions:
|
|
51
|
+
| Record<string, any>
|
|
52
|
+
| ((ctx: FlowModelContext, extra?: any) => Record<string, any> | Promise<Record<string, any>>)
|
|
53
|
+
| undefined,
|
|
54
|
+
ctx: FlowModelContext,
|
|
55
|
+
extra?: any,
|
|
56
|
+
): Promise<Record<string, any>> {
|
|
57
|
+
if (!createModelOptions) {
|
|
58
|
+
return {};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (typeof createModelOptions === 'function') {
|
|
62
|
+
try {
|
|
63
|
+
const result = await createModelOptions(ctx, extra);
|
|
64
|
+
return result || {};
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.error('Error resolving createModelOptions function:', error);
|
|
67
|
+
return {};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return createModelOptions;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type JSONValue = string | { [key: string]: JSONValue } | JSONValue[];
|
|
75
|
+
|
|
76
|
+
// =========================
|
|
77
|
+
// variables:resolve 微批 + 去重(前端)
|
|
78
|
+
// =========================
|
|
79
|
+
|
|
80
|
+
type BatchPayload = {
|
|
81
|
+
template: JSONValue;
|
|
82
|
+
contextParams?: ServerContextParams | undefined;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
type QueueItem = {
|
|
86
|
+
id: string;
|
|
87
|
+
ctx: FlowRuntimeContext;
|
|
88
|
+
payload: BatchPayload;
|
|
89
|
+
resolve: (v: unknown) => void;
|
|
90
|
+
reject: (e: unknown) => void;
|
|
91
|
+
runId: string;
|
|
92
|
+
dedupKey: string;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
type Aggregator = {
|
|
96
|
+
queue: QueueItem[];
|
|
97
|
+
timer: ReturnType<typeof setTimeout> | null;
|
|
98
|
+
inflightByRun: Map<string, Map<string, Promise<unknown>>>;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const VAR_AGGREGATOR: Aggregator = { queue: [], timer: null, inflightByRun: new Map() };
|
|
102
|
+
const BATCH_FLUSH_DELAY_MS = 10;
|
|
103
|
+
|
|
104
|
+
// 使用 lodash 对象操作,按键名递归排序,便于稳定 stringify
|
|
105
|
+
function sortKeysDeep(input: any): any {
|
|
106
|
+
if (Array.isArray(input)) return input.map(sortKeysDeep);
|
|
107
|
+
if (_.isPlainObject(input)) {
|
|
108
|
+
const entries = Object.entries(input).map(([k, v]) => [k, sortKeysDeep(v)] as [string, unknown]);
|
|
109
|
+
const sortedEntries = _.sortBy(entries, ([k]) => k);
|
|
110
|
+
return Object.fromEntries(sortedEntries);
|
|
111
|
+
}
|
|
112
|
+
return input;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function stableStringifyOrdered(obj: unknown): string {
|
|
116
|
+
try {
|
|
117
|
+
return JSON.stringify(sortKeysDeep(obj));
|
|
118
|
+
} catch {
|
|
119
|
+
try {
|
|
120
|
+
return JSON.stringify(obj as Record<string, unknown>);
|
|
121
|
+
} catch {
|
|
122
|
+
return String(obj);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function enqueueVariablesResolve(ctx: FlowRuntimeContext, payload: BatchPayload): Promise<unknown> {
|
|
128
|
+
const agg = VAR_AGGREGATOR;
|
|
129
|
+
const runId = ctx.runId || 'GLOBAL';
|
|
130
|
+
const dedupKey = stableStringifyOrdered(payload);
|
|
131
|
+
|
|
132
|
+
let runMap = agg.inflightByRun.get(runId);
|
|
133
|
+
if (!runMap) {
|
|
134
|
+
runMap = new Map<string, Promise<unknown>>();
|
|
135
|
+
agg.inflightByRun.set(runId, runMap);
|
|
136
|
+
}
|
|
137
|
+
const existing = runMap.get(dedupKey);
|
|
138
|
+
if (existing) return existing;
|
|
139
|
+
|
|
140
|
+
let resolveFn!: (v: unknown) => void;
|
|
141
|
+
let rejectFn!: (e: unknown) => void;
|
|
142
|
+
const p = new Promise<unknown>((resolve, reject) => {
|
|
143
|
+
resolveFn = resolve;
|
|
144
|
+
rejectFn = reject;
|
|
145
|
+
});
|
|
146
|
+
runMap.set(dedupKey, p);
|
|
147
|
+
|
|
148
|
+
const id = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
149
|
+
const item: QueueItem = { id, ctx, payload, resolve: resolveFn, reject: rejectFn, runId, dedupKey };
|
|
150
|
+
agg.queue.push(item);
|
|
151
|
+
|
|
152
|
+
const flush = async () => {
|
|
153
|
+
const items = agg.queue.splice(0, agg.queue.length);
|
|
154
|
+
agg.timer = null;
|
|
155
|
+
if (!items.length) return;
|
|
156
|
+
const api = items[0].ctx?.api;
|
|
157
|
+
if (!api) {
|
|
158
|
+
// 无 API 客户端,直接回退原模板
|
|
159
|
+
for (const it of items) {
|
|
160
|
+
try {
|
|
161
|
+
it.resolve(it.payload.template);
|
|
162
|
+
} catch (e) {
|
|
163
|
+
it.reject(e);
|
|
164
|
+
} finally {
|
|
165
|
+
agg.inflightByRun.get(it.runId)?.delete(it.dedupKey);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
try {
|
|
171
|
+
const batch = items.map((it) => ({
|
|
172
|
+
id: it.id,
|
|
173
|
+
template: it.payload.template,
|
|
174
|
+
contextParams: it.payload.contextParams || {},
|
|
175
|
+
}));
|
|
176
|
+
const res = await api.request({ method: 'POST', url: 'variables:resolve', data: { values: { batch } } });
|
|
177
|
+
// 兼容形态:{ data: { data: { results } } } | { data: { results } } | { results }
|
|
178
|
+
const top = (res as { data?: unknown }).data ?? res;
|
|
179
|
+
const root = (top as { data?: unknown }).data ?? top;
|
|
180
|
+
const arr1 = (root as any)?.results;
|
|
181
|
+
const resultsArr: Array<{ id?: unknown; data?: unknown }> = Array.isArray(arr1)
|
|
182
|
+
? (arr1 as Array<{ id?: unknown; data?: unknown }>)
|
|
183
|
+
: Array.isArray(root)
|
|
184
|
+
? (root as Array<{ id?: unknown; data?: unknown }>)
|
|
185
|
+
: [];
|
|
186
|
+
const map = new Map<string, unknown>();
|
|
187
|
+
for (const r of resultsArr) {
|
|
188
|
+
const k = r?.id != null ? String(r.id) : '';
|
|
189
|
+
if (k) map.set(k, r?.data);
|
|
190
|
+
}
|
|
191
|
+
for (const it of items) {
|
|
192
|
+
try {
|
|
193
|
+
const k = String(it.id);
|
|
194
|
+
const resolved = map.has(k) ? map.get(k) : it.payload.template;
|
|
195
|
+
it.resolve(resolved);
|
|
196
|
+
} catch (e) {
|
|
197
|
+
it.reject(e);
|
|
198
|
+
} finally {
|
|
199
|
+
agg.inflightByRun.get(it.runId)?.delete(it.dedupKey);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
} catch (e) {
|
|
203
|
+
for (const it of items) {
|
|
204
|
+
try {
|
|
205
|
+
ctx?.logger?.warn?.({ err: e }, 'variables:resolve(batch) failed, fallback');
|
|
206
|
+
it.resolve(it.payload.template);
|
|
207
|
+
} catch (err) {
|
|
208
|
+
it.reject(err);
|
|
209
|
+
} finally {
|
|
210
|
+
agg.inflightByRun.get(it.runId)?.delete(it.dedupKey);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
if (!agg.timer) {
|
|
216
|
+
agg.timer = setTimeout(flush, BATCH_FLUSH_DELAY_MS);
|
|
217
|
+
}
|
|
218
|
+
return p;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* 解析参数中的 {{xxx}} 表达式,自动处理异步属性访问
|
|
223
|
+
*/
|
|
224
|
+
export async function resolveExpressions<TModel extends FlowModel = FlowModel>(
|
|
225
|
+
params: JSONValue,
|
|
226
|
+
ctx: FlowContext,
|
|
227
|
+
): Promise<any> {
|
|
228
|
+
const compile = async (source: any): Promise<any> => {
|
|
229
|
+
/**
|
|
230
|
+
* 检测字符串中是否包含表达式
|
|
231
|
+
*
|
|
232
|
+
* 正则解析:/\{\{.*?\}\}/
|
|
233
|
+
* - \{\{ 匹配字面量 "{{"
|
|
234
|
+
* - .*? 非贪婪匹配:0 或多个任意字符
|
|
235
|
+
* - \}\} 匹配字面量 "}}"
|
|
236
|
+
*
|
|
237
|
+
* 功能:快速检测字符串是否包含 {{ }} 表达式,无需捕获内容
|
|
238
|
+
*
|
|
239
|
+
* 匹配示例:
|
|
240
|
+
* ✅ "{{ ctx.user }}" -> 包含表达式
|
|
241
|
+
* ✅ "Hello {{ name }}" -> 包含表达式
|
|
242
|
+
* ✅ "{{ a }} and {{ b }}" -> 包含表达式
|
|
243
|
+
* ❌ "Hello world" -> 不包含表达式
|
|
244
|
+
*/
|
|
245
|
+
if (typeof source === 'string' && /\{\{.*?\}\}/.test(source)) {
|
|
246
|
+
return await compileExpression(source, ctx);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
if (Array.isArray(source)) {
|
|
250
|
+
return Promise.all(source.map(compile));
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (source && typeof source === 'object') {
|
|
254
|
+
const result = {};
|
|
255
|
+
for (const [key, value] of Object.entries(source)) {
|
|
256
|
+
result[key] = await compile(value);
|
|
257
|
+
}
|
|
258
|
+
return result;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return source;
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
return compile(params);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* 统一的表达式解析函数 - 基于字符串预处理的 await 插入策略
|
|
269
|
+
*
|
|
270
|
+
* 核心理念:
|
|
271
|
+
* 1. 保持原始表达式的计算顺序和运算符优先级
|
|
272
|
+
* 2. 通过字符串预处理插入 await,而非变量替换
|
|
273
|
+
* 3. 动态检测 RecordProxy 实例
|
|
274
|
+
*
|
|
275
|
+
* @param expression 表达式内容(不包含 {{ }}),如:'ctx.user.name' 或 'ctx.aa.bb + ctx.cc'
|
|
276
|
+
* @param ctx FlowContext 上下文对象
|
|
277
|
+
* @returns 解析结果,失败时抛出异常
|
|
278
|
+
*/
|
|
279
|
+
async function processExpression(expression: string, ctx: FlowContext): Promise<any> {
|
|
280
|
+
const processedExpr = await preprocessExpression(expression.trim(), ctx);
|
|
281
|
+
const result = await ctx.runjs(`return ${processedExpr}`, { t: ctx.t });
|
|
282
|
+
return result?.success ? result.value : undefined;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* 预处理表达式字符串,插入必要的 await 和 RecordProxy 检查
|
|
287
|
+
*
|
|
288
|
+
* 1. 统一提取所有一层 ctx 路径(如 ctx.record, ctx.user)
|
|
289
|
+
* 2. 批量 await 获取这些值,判断是否为 RecordProxy 实例
|
|
290
|
+
* 3. 根据预处理结果决定每个多层路径的 await 插入方式
|
|
291
|
+
* 4. 避免重复解析,提高性能
|
|
292
|
+
*
|
|
293
|
+
* @param expression 原始表达式
|
|
294
|
+
* @param ctx FlowContext
|
|
295
|
+
* @returns 预处理后的表达式字符串
|
|
296
|
+
*/
|
|
297
|
+
export async function preprocessExpression(expression: string, ctx: FlowContext): Promise<string> {
|
|
298
|
+
/**
|
|
299
|
+
* 匹配所有 ctx 路径表达式(排除函数调用)
|
|
300
|
+
*
|
|
301
|
+
* 正则解析:
|
|
302
|
+
* - ctx\. 匹配字面量 "ctx."
|
|
303
|
+
* - ([a-zA-Z_$][a-zA-Z0-9_$]* 第一个标识符(首字符:字母/下划线/$,后续:字母/数字/下划线/$)
|
|
304
|
+
* - (?: 开始非捕获组(可重复的路径组件)
|
|
305
|
+
* (?:\.[a-zA-Z_$][a-zA-Z0-9_$]*)| 点号属性访问:.property
|
|
306
|
+
* (?:\[[^\]]+\]) 数组索引访问:[0] 或 [key]
|
|
307
|
+
* )* 结束非捕获组,0或多次重复
|
|
308
|
+
* ) 结束主捕获组
|
|
309
|
+
* (?!\s*\() 负前瞻:确保后面不跟空格和左括号(排除函数调用)
|
|
310
|
+
* /g 全局匹配标志
|
|
311
|
+
*
|
|
312
|
+
* 匹配示例:
|
|
313
|
+
* ✅ ctx.user -> 捕获: "user"
|
|
314
|
+
* ✅ ctx.user.name -> 捕获: "user.name"
|
|
315
|
+
* ✅ ctx.items[0] -> 捕获: "items[0]"
|
|
316
|
+
* ✅ ctx.items[0].name -> 捕获: "items[0].name"
|
|
317
|
+
* ✅ ctx.data[key].value -> 捕获: "data[key].value"
|
|
318
|
+
* ❌ ctx.method() -> 不匹配(函数调用)
|
|
319
|
+
* ❌ ctx.method ( -> 不匹配(函数调用)
|
|
320
|
+
*/
|
|
321
|
+
const pathRegex = /ctx\.([a-zA-Z_$][a-zA-Z0-9_$]*(?:(?:\.[a-zA-Z_$][a-zA-Z0-9_$]*)|(?:\[[^\]]+\]))*)(?!\s*\()/g;
|
|
322
|
+
|
|
323
|
+
const pathMatches: Array<{ fullPath: string; firstKey: string; restPath: string }> = [];
|
|
324
|
+
const firstLevelKeys = new Set<string>();
|
|
325
|
+
|
|
326
|
+
// 收集所有需要处理的路径和一层键
|
|
327
|
+
let match;
|
|
328
|
+
while ((match = pathRegex.exec(expression)) !== null) {
|
|
329
|
+
const fullPath = match[0]; // 'ctx.record' 或 'ctx.items[0].name'
|
|
330
|
+
const pathAfterCtx = match[1]; // 'record' 或 'items[0].name'
|
|
331
|
+
|
|
332
|
+
// 提取第一层键(标识符)和剩余路径
|
|
333
|
+
const firstKeyMatch = pathAfterCtx.match(/^([a-zA-Z_$][a-zA-Z0-9_$]*)/);
|
|
334
|
+
if (firstKeyMatch) {
|
|
335
|
+
const firstKey = firstKeyMatch[1];
|
|
336
|
+
const restPath = pathAfterCtx.substring(firstKey.length); // 可能包含 [0].name 等
|
|
337
|
+
|
|
338
|
+
pathMatches.push({
|
|
339
|
+
fullPath,
|
|
340
|
+
firstKey,
|
|
341
|
+
restPath, // 单层路径时为空字符串,多层路径可能包含数组索引
|
|
342
|
+
});
|
|
343
|
+
firstLevelKeys.add(firstKey);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (pathMatches.length === 0) {
|
|
348
|
+
return expression;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// 批量获取一层路径的值并检测 RecordProxy
|
|
352
|
+
const recordProxyMap = new Map<string, boolean>();
|
|
353
|
+
|
|
354
|
+
for (const firstKey of firstLevelKeys) {
|
|
355
|
+
try {
|
|
356
|
+
// 检查原始值是否为 RecordProxy 实例(不通过 await)
|
|
357
|
+
const rawValue = await ctx[firstKey];
|
|
358
|
+
const isRecordProxy = rawValue && rawValue.__isRecordProxy__ === true;
|
|
359
|
+
recordProxyMap.set(firstKey, isRecordProxy);
|
|
360
|
+
} catch (error) {
|
|
361
|
+
recordProxyMap.set(firstKey, false);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// 按路径长度排序,长路径优先处理(避免替换冲突)
|
|
366
|
+
pathMatches.sort((a, b) => b.fullPath.length - a.fullPath.length);
|
|
367
|
+
|
|
368
|
+
// 根据预处理结果生成优化后的表达式
|
|
369
|
+
let processedExpr = expression;
|
|
370
|
+
|
|
371
|
+
for (const { fullPath, firstKey, restPath } of pathMatches) {
|
|
372
|
+
const isRecordProxy = recordProxyMap.get(firstKey) || false;
|
|
373
|
+
|
|
374
|
+
let processedPath: string;
|
|
375
|
+
if (restPath === '') {
|
|
376
|
+
// 单层路径:ctx.a -> await ctx.a
|
|
377
|
+
processedPath = `await ctx.${firstKey}`;
|
|
378
|
+
} else {
|
|
379
|
+
// 多层路径:支持 .property、[index]、?.property 等语法
|
|
380
|
+
// 例如:ctx.items[0].name -> (await ctx.items)[0].name
|
|
381
|
+
// ctx.user?.name -> (await ctx.user)?.name
|
|
382
|
+
// ctx.record.author.name -> await (await ctx.record).author.name (RecordProxy)
|
|
383
|
+
processedPath = isRecordProxy
|
|
384
|
+
? `await (await ctx.${firstKey})${restPath}` // RecordProxy:整个路径需要 await
|
|
385
|
+
: `(await ctx.${firstKey})${restPath}`; // 普通对象:只在第一层加 await
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* 精确替换路径表达式(避免误替换)
|
|
390
|
+
*
|
|
391
|
+
* 注意:对于包含数组索引等特殊字符的路径,需要转义所有正则特殊字符
|
|
392
|
+
*
|
|
393
|
+
* 替换示例:
|
|
394
|
+
* - fullPath: "ctx.items[0].name"
|
|
395
|
+
* - 转义后: "ctx\\.items\\[0\\]\\.name"
|
|
396
|
+
* - 正则: /\bctx\.items\[0\]\.name\b/g
|
|
397
|
+
*/
|
|
398
|
+
const escapedFullPath = fullPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
399
|
+
const regex = new RegExp(`\\b${escapedFullPath}\\b`, 'g');
|
|
400
|
+
processedExpr = processedExpr.replace(regex, processedPath);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
return processedExpr;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* 编译表达式,使用统一的解析逻辑
|
|
408
|
+
*/
|
|
409
|
+
async function compileExpression<TModel extends FlowModel = FlowModel>(expression: string, ctx: FlowContext) {
|
|
410
|
+
// 仅点号路径匹配:ctx.a.b.c(不支持括号/函数/索引),用于数组聚合取值
|
|
411
|
+
const matchDotOnly = (expr: string): string | null => {
|
|
412
|
+
const m = expr.trim().match(/^ctx\.([a-zA-Z_$][a-zA-Z0-9_$]*(?:\.[a-zA-Z_$][a-zA-Z0-9_$]*)*)$/);
|
|
413
|
+
return m ? m[1] : null;
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
// 基于 getValuesByPath 的聚合取值:支持数组扁平化,仅支持 '.' 访问
|
|
417
|
+
const resolveDotOnlyPath = async (dotPath: string): Promise<any> => {
|
|
418
|
+
const segs = dotPath.split('.');
|
|
419
|
+
const first = segs.shift();
|
|
420
|
+
if (!first) return undefined;
|
|
421
|
+
const base = await (ctx as any)[first];
|
|
422
|
+
if (segs.length === 0) return base;
|
|
423
|
+
return getValuesByPath(base as object, segs.join('.'));
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* 单个表达式模式匹配
|
|
428
|
+
*
|
|
429
|
+
* 正则解析:/^\{\{\s*(.+)\s*\}\}$/
|
|
430
|
+
* - ^ 字符串开始
|
|
431
|
+
* - \{\{ 匹配字面量 "{{"
|
|
432
|
+
* - \s* 匹配 0 或多个空白字符
|
|
433
|
+
* - (.+) 捕获组:匹配 1 或多个任意字符(表达式内容)
|
|
434
|
+
* - \s* 匹配 0 或多个空白字符
|
|
435
|
+
* - \}\} 匹配字面量 "}}"
|
|
436
|
+
* - $ 字符串结束
|
|
437
|
+
*
|
|
438
|
+
* 匹配示例:
|
|
439
|
+
* ✅ "{{ ctx.user.name }}" -> 捕获: "ctx.user.name"
|
|
440
|
+
* ✅ "{{ctx.user}}" -> 捕获: "ctx.user"
|
|
441
|
+
* ❌ "Hello {{ ctx.user }}" -> 不匹配(不是纯表达式)
|
|
442
|
+
*/
|
|
443
|
+
const singleMatch = expression.match(/^\{\{\s*(.+)\s*\}\}$/);
|
|
444
|
+
if (singleMatch) {
|
|
445
|
+
const inner = singleMatch[1];
|
|
446
|
+
const dotPath = matchDotOnly(inner);
|
|
447
|
+
if (dotPath) {
|
|
448
|
+
return await resolveDotOnlyPath(dotPath);
|
|
449
|
+
}
|
|
450
|
+
return await processExpression(inner, ctx);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* 模板字符串中的多个表达式匹配
|
|
455
|
+
*
|
|
456
|
+
* 正则解析:/\{\{\s*(.+?)\s*\}\}/g
|
|
457
|
+
* - \{\{ 匹配字面量 "{{"
|
|
458
|
+
* - \s* 匹配 0 或多个空白字符
|
|
459
|
+
* - (.+?) 捕获组:非贪婪匹配 1 或多个任意字符(表达式内容)
|
|
460
|
+
* - \s* 匹配 0 或多个空白字符
|
|
461
|
+
* - \}\} 匹配字面量 "}}"
|
|
462
|
+
* - /g 全局匹配标志
|
|
463
|
+
*
|
|
464
|
+
* 匹配示例:
|
|
465
|
+
* ✅ "Hello {{ user.name }}, age: {{ user.age }}"
|
|
466
|
+
* -> 匹配: ["{{ user.name }}", "{{ user.age }}"]
|
|
467
|
+
* -> 捕获: ["user.name", "user.age"]
|
|
468
|
+
*/
|
|
469
|
+
const matches = [...expression.matchAll(/\{\{\s*(.+?)\s*\}\}/g)];
|
|
470
|
+
let result = expression;
|
|
471
|
+
|
|
472
|
+
for (const [fullMatch, innerExpr] of matches) {
|
|
473
|
+
const dotPath = matchDotOnly(innerExpr);
|
|
474
|
+
const value = dotPath ? await resolveDotOnlyPath(dotPath) : await processExpression(innerExpr, ctx);
|
|
475
|
+
if (value !== undefined) {
|
|
476
|
+
const replacement = typeof value === 'object' && value !== null ? JSON.stringify(value) : String(value);
|
|
477
|
+
result = result.replace(fullMatch, replacement);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
return result;
|
|
482
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
export interface ViewParam {
|
|
11
|
+
/** 视图唯一标识符,一般为某个 Model 实例的 uid */
|
|
12
|
+
viewUid: string;
|
|
13
|
+
/** 标签页唯一标识符 */
|
|
14
|
+
tabUid?: string;
|
|
15
|
+
/** 弹窗记录的 id */
|
|
16
|
+
filterByTk?: string;
|
|
17
|
+
/** source Id */
|
|
18
|
+
sourceId?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 解析路径名为视图参数数组
|
|
23
|
+
*
|
|
24
|
+
* 支持解析包含多个视图的路径,每个视图可以包含 tab、filterByTk、sourceId 等参数
|
|
25
|
+
*
|
|
26
|
+
* @param pathname - 要解析的路径名,格式如 '/admin/xxx/view/xxx/tab/xxx'
|
|
27
|
+
* @returns 视图参数数组,每个元素对应一个视图
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* parsePathnameToViewParams('/admin/xxx') // [{ viewUid: 'xxx' }]
|
|
32
|
+
* parsePathnameToViewParams('/admin/xxx/tab/yyy') // [{ viewUid: 'xxx', tabUid: 'yyy' }]
|
|
33
|
+
* parsePathnameToViewParams('/admin/xxx/view/yyy') // [{ viewUid: 'xxx' }, { viewUid: 'yyy' }]
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export const parsePathnameToViewParams = (pathname: string): ViewParam[] => {
|
|
37
|
+
if (!pathname || pathname === '/') {
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// 移除开头的斜杠并分割路径
|
|
42
|
+
const segments = pathname.replace(/^\/+/, '').split('/').filter(Boolean);
|
|
43
|
+
|
|
44
|
+
if (segments.length < 2) {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const result: ViewParam[] = [];
|
|
49
|
+
let currentView: ViewParam | null = null;
|
|
50
|
+
let i = 0;
|
|
51
|
+
|
|
52
|
+
while (i < segments.length) {
|
|
53
|
+
const segment = segments[i];
|
|
54
|
+
|
|
55
|
+
// 处理 admin 或 view 关键字
|
|
56
|
+
if (segment === 'admin' || segment === 'view') {
|
|
57
|
+
// 如果有当前视图,先保存到结果中
|
|
58
|
+
if (currentView) {
|
|
59
|
+
result.push(currentView);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 获取视图 UID
|
|
63
|
+
if (i + 1 < segments.length) {
|
|
64
|
+
currentView = { viewUid: segments[i + 1] };
|
|
65
|
+
i += 2; // 跳过 admin/view 和 viewUid
|
|
66
|
+
} else {
|
|
67
|
+
// 没有 viewUid,跳出循环
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// 处理参数
|
|
72
|
+
else if (currentView && i + 1 < segments.length) {
|
|
73
|
+
const value = segments[i + 1];
|
|
74
|
+
|
|
75
|
+
switch (segment) {
|
|
76
|
+
case 'tab':
|
|
77
|
+
currentView.tabUid = value;
|
|
78
|
+
break;
|
|
79
|
+
case 'filterbytk':
|
|
80
|
+
currentView.filterByTk = value;
|
|
81
|
+
break;
|
|
82
|
+
case 'sourceid':
|
|
83
|
+
currentView.sourceId = value;
|
|
84
|
+
break;
|
|
85
|
+
default:
|
|
86
|
+
// 未知参数,跳过
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
i += 2; // 跳过参数名和参数值
|
|
91
|
+
} else {
|
|
92
|
+
// 无法处理的情况,跳过当前段
|
|
93
|
+
i++;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// 保存最后一个视图
|
|
98
|
+
if (currentView) {
|
|
99
|
+
result.push(currentView);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return result;
|
|
103
|
+
};
|