@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,309 @@
|
|
|
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
|
+
var __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
17
|
+
var __export = (target, all) => {
|
|
18
|
+
for (var name in all)
|
|
19
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
+
};
|
|
21
|
+
var __copyProps = (to, from, except, desc) => {
|
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(from))
|
|
24
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
+
mod
|
|
36
|
+
));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
var params_resolvers_exports = {};
|
|
39
|
+
__export(params_resolvers_exports, {
|
|
40
|
+
enqueueVariablesResolve: () => enqueueVariablesResolve,
|
|
41
|
+
preprocessExpression: () => preprocessExpression,
|
|
42
|
+
resolveCreateModelOptions: () => resolveCreateModelOptions,
|
|
43
|
+
resolveDefaultParams: () => resolveDefaultParams,
|
|
44
|
+
resolveExpressions: () => resolveExpressions
|
|
45
|
+
});
|
|
46
|
+
module.exports = __toCommonJS(params_resolvers_exports);
|
|
47
|
+
var import_lodash = __toESM(require("lodash"));
|
|
48
|
+
var import_client = require("@nocobase/utils/client");
|
|
49
|
+
async function resolveDefaultParams(defaultParams, ctx) {
|
|
50
|
+
if (!defaultParams) {
|
|
51
|
+
return {};
|
|
52
|
+
}
|
|
53
|
+
if (typeof defaultParams === "function") {
|
|
54
|
+
try {
|
|
55
|
+
const result = await defaultParams(ctx);
|
|
56
|
+
return result || {};
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.error("Error resolving defaultParams function:", error);
|
|
59
|
+
return {};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return defaultParams;
|
|
63
|
+
}
|
|
64
|
+
__name(resolveDefaultParams, "resolveDefaultParams");
|
|
65
|
+
async function resolveCreateModelOptions(createModelOptions, ctx, extra) {
|
|
66
|
+
if (!createModelOptions) {
|
|
67
|
+
return {};
|
|
68
|
+
}
|
|
69
|
+
if (typeof createModelOptions === "function") {
|
|
70
|
+
try {
|
|
71
|
+
const result = await createModelOptions(ctx, extra);
|
|
72
|
+
return result || {};
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error("Error resolving createModelOptions function:", error);
|
|
75
|
+
return {};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return createModelOptions;
|
|
79
|
+
}
|
|
80
|
+
__name(resolveCreateModelOptions, "resolveCreateModelOptions");
|
|
81
|
+
const VAR_AGGREGATOR = { queue: [], timer: null, inflightByRun: /* @__PURE__ */ new Map() };
|
|
82
|
+
const BATCH_FLUSH_DELAY_MS = 10;
|
|
83
|
+
function sortKeysDeep(input) {
|
|
84
|
+
if (Array.isArray(input)) return input.map(sortKeysDeep);
|
|
85
|
+
if (import_lodash.default.isPlainObject(input)) {
|
|
86
|
+
const entries = Object.entries(input).map(([k, v]) => [k, sortKeysDeep(v)]);
|
|
87
|
+
const sortedEntries = import_lodash.default.sortBy(entries, ([k]) => k);
|
|
88
|
+
return Object.fromEntries(sortedEntries);
|
|
89
|
+
}
|
|
90
|
+
return input;
|
|
91
|
+
}
|
|
92
|
+
__name(sortKeysDeep, "sortKeysDeep");
|
|
93
|
+
function stableStringifyOrdered(obj) {
|
|
94
|
+
try {
|
|
95
|
+
return JSON.stringify(sortKeysDeep(obj));
|
|
96
|
+
} catch {
|
|
97
|
+
try {
|
|
98
|
+
return JSON.stringify(obj);
|
|
99
|
+
} catch {
|
|
100
|
+
return String(obj);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
__name(stableStringifyOrdered, "stableStringifyOrdered");
|
|
105
|
+
function enqueueVariablesResolve(ctx, payload) {
|
|
106
|
+
const agg = VAR_AGGREGATOR;
|
|
107
|
+
const runId = ctx.runId || "GLOBAL";
|
|
108
|
+
const dedupKey = stableStringifyOrdered(payload);
|
|
109
|
+
let runMap = agg.inflightByRun.get(runId);
|
|
110
|
+
if (!runMap) {
|
|
111
|
+
runMap = /* @__PURE__ */ new Map();
|
|
112
|
+
agg.inflightByRun.set(runId, runMap);
|
|
113
|
+
}
|
|
114
|
+
const existing = runMap.get(dedupKey);
|
|
115
|
+
if (existing) return existing;
|
|
116
|
+
let resolveFn;
|
|
117
|
+
let rejectFn;
|
|
118
|
+
const p = new Promise((resolve, reject) => {
|
|
119
|
+
resolveFn = resolve;
|
|
120
|
+
rejectFn = reject;
|
|
121
|
+
});
|
|
122
|
+
runMap.set(dedupKey, p);
|
|
123
|
+
const id = `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
124
|
+
const item = { id, ctx, payload, resolve: resolveFn, reject: rejectFn, runId, dedupKey };
|
|
125
|
+
agg.queue.push(item);
|
|
126
|
+
const flush = /* @__PURE__ */ __name(async () => {
|
|
127
|
+
var _a, _b, _c, _d, _e, _f;
|
|
128
|
+
const items = agg.queue.splice(0, agg.queue.length);
|
|
129
|
+
agg.timer = null;
|
|
130
|
+
if (!items.length) return;
|
|
131
|
+
const api = (_a = items[0].ctx) == null ? void 0 : _a.api;
|
|
132
|
+
if (!api) {
|
|
133
|
+
for (const it of items) {
|
|
134
|
+
try {
|
|
135
|
+
it.resolve(it.payload.template);
|
|
136
|
+
} catch (e) {
|
|
137
|
+
it.reject(e);
|
|
138
|
+
} finally {
|
|
139
|
+
(_b = agg.inflightByRun.get(it.runId)) == null ? void 0 : _b.delete(it.dedupKey);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
const batch = items.map((it) => ({
|
|
146
|
+
id: it.id,
|
|
147
|
+
template: it.payload.template,
|
|
148
|
+
contextParams: it.payload.contextParams || {}
|
|
149
|
+
}));
|
|
150
|
+
const res = await api.request({ method: "POST", url: "variables:resolve", data: { values: { batch } } });
|
|
151
|
+
const top = res.data ?? res;
|
|
152
|
+
const root = top.data ?? top;
|
|
153
|
+
const arr1 = root == null ? void 0 : root.results;
|
|
154
|
+
const resultsArr = Array.isArray(arr1) ? arr1 : Array.isArray(root) ? root : [];
|
|
155
|
+
const map = /* @__PURE__ */ new Map();
|
|
156
|
+
for (const r of resultsArr) {
|
|
157
|
+
const k = (r == null ? void 0 : r.id) != null ? String(r.id) : "";
|
|
158
|
+
if (k) map.set(k, r == null ? void 0 : r.data);
|
|
159
|
+
}
|
|
160
|
+
for (const it of items) {
|
|
161
|
+
try {
|
|
162
|
+
const k = String(it.id);
|
|
163
|
+
const resolved = map.has(k) ? map.get(k) : it.payload.template;
|
|
164
|
+
it.resolve(resolved);
|
|
165
|
+
} catch (e) {
|
|
166
|
+
it.reject(e);
|
|
167
|
+
} finally {
|
|
168
|
+
(_c = agg.inflightByRun.get(it.runId)) == null ? void 0 : _c.delete(it.dedupKey);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
} catch (e) {
|
|
172
|
+
for (const it of items) {
|
|
173
|
+
try {
|
|
174
|
+
(_e = (_d = ctx == null ? void 0 : ctx.logger) == null ? void 0 : _d.warn) == null ? void 0 : _e.call(_d, { err: e }, "variables:resolve(batch) failed, fallback");
|
|
175
|
+
it.resolve(it.payload.template);
|
|
176
|
+
} catch (err) {
|
|
177
|
+
it.reject(err);
|
|
178
|
+
} finally {
|
|
179
|
+
(_f = agg.inflightByRun.get(it.runId)) == null ? void 0 : _f.delete(it.dedupKey);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}, "flush");
|
|
184
|
+
if (!agg.timer) {
|
|
185
|
+
agg.timer = setTimeout(flush, BATCH_FLUSH_DELAY_MS);
|
|
186
|
+
}
|
|
187
|
+
return p;
|
|
188
|
+
}
|
|
189
|
+
__name(enqueueVariablesResolve, "enqueueVariablesResolve");
|
|
190
|
+
async function resolveExpressions(params, ctx) {
|
|
191
|
+
const compile = /* @__PURE__ */ __name(async (source) => {
|
|
192
|
+
if (typeof source === "string" && /\{\{.*?\}\}/.test(source)) {
|
|
193
|
+
return await compileExpression(source, ctx);
|
|
194
|
+
}
|
|
195
|
+
if (Array.isArray(source)) {
|
|
196
|
+
return Promise.all(source.map(compile));
|
|
197
|
+
}
|
|
198
|
+
if (source && typeof source === "object") {
|
|
199
|
+
const result = {};
|
|
200
|
+
for (const [key, value] of Object.entries(source)) {
|
|
201
|
+
result[key] = await compile(value);
|
|
202
|
+
}
|
|
203
|
+
return result;
|
|
204
|
+
}
|
|
205
|
+
return source;
|
|
206
|
+
}, "compile");
|
|
207
|
+
return compile(params);
|
|
208
|
+
}
|
|
209
|
+
__name(resolveExpressions, "resolveExpressions");
|
|
210
|
+
async function processExpression(expression, ctx) {
|
|
211
|
+
const processedExpr = await preprocessExpression(expression.trim(), ctx);
|
|
212
|
+
const result = await ctx.runjs(`return ${processedExpr}`, { t: ctx.t });
|
|
213
|
+
return (result == null ? void 0 : result.success) ? result.value : void 0;
|
|
214
|
+
}
|
|
215
|
+
__name(processExpression, "processExpression");
|
|
216
|
+
async function preprocessExpression(expression, ctx) {
|
|
217
|
+
const pathRegex = /ctx\.([a-zA-Z_$][a-zA-Z0-9_$]*(?:(?:\.[a-zA-Z_$][a-zA-Z0-9_$]*)|(?:\[[^\]]+\]))*)(?!\s*\()/g;
|
|
218
|
+
const pathMatches = [];
|
|
219
|
+
const firstLevelKeys = /* @__PURE__ */ new Set();
|
|
220
|
+
let match;
|
|
221
|
+
while ((match = pathRegex.exec(expression)) !== null) {
|
|
222
|
+
const fullPath = match[0];
|
|
223
|
+
const pathAfterCtx = match[1];
|
|
224
|
+
const firstKeyMatch = pathAfterCtx.match(/^([a-zA-Z_$][a-zA-Z0-9_$]*)/);
|
|
225
|
+
if (firstKeyMatch) {
|
|
226
|
+
const firstKey = firstKeyMatch[1];
|
|
227
|
+
const restPath = pathAfterCtx.substring(firstKey.length);
|
|
228
|
+
pathMatches.push({
|
|
229
|
+
fullPath,
|
|
230
|
+
firstKey,
|
|
231
|
+
restPath
|
|
232
|
+
// 单层路径时为空字符串,多层路径可能包含数组索引
|
|
233
|
+
});
|
|
234
|
+
firstLevelKeys.add(firstKey);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (pathMatches.length === 0) {
|
|
238
|
+
return expression;
|
|
239
|
+
}
|
|
240
|
+
const recordProxyMap = /* @__PURE__ */ new Map();
|
|
241
|
+
for (const firstKey of firstLevelKeys) {
|
|
242
|
+
try {
|
|
243
|
+
const rawValue = await ctx[firstKey];
|
|
244
|
+
const isRecordProxy = rawValue && rawValue.__isRecordProxy__ === true;
|
|
245
|
+
recordProxyMap.set(firstKey, isRecordProxy);
|
|
246
|
+
} catch (error) {
|
|
247
|
+
recordProxyMap.set(firstKey, false);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
pathMatches.sort((a, b) => b.fullPath.length - a.fullPath.length);
|
|
251
|
+
let processedExpr = expression;
|
|
252
|
+
for (const { fullPath, firstKey, restPath } of pathMatches) {
|
|
253
|
+
const isRecordProxy = recordProxyMap.get(firstKey) || false;
|
|
254
|
+
let processedPath;
|
|
255
|
+
if (restPath === "") {
|
|
256
|
+
processedPath = `await ctx.${firstKey}`;
|
|
257
|
+
} else {
|
|
258
|
+
processedPath = isRecordProxy ? `await (await ctx.${firstKey})${restPath}` : `(await ctx.${firstKey})${restPath}`;
|
|
259
|
+
}
|
|
260
|
+
const escapedFullPath = fullPath.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
261
|
+
const regex = new RegExp(`\\b${escapedFullPath}\\b`, "g");
|
|
262
|
+
processedExpr = processedExpr.replace(regex, processedPath);
|
|
263
|
+
}
|
|
264
|
+
return processedExpr;
|
|
265
|
+
}
|
|
266
|
+
__name(preprocessExpression, "preprocessExpression");
|
|
267
|
+
async function compileExpression(expression, ctx) {
|
|
268
|
+
const matchDotOnly = /* @__PURE__ */ __name((expr) => {
|
|
269
|
+
const m = expr.trim().match(/^ctx\.([a-zA-Z_$][a-zA-Z0-9_$]*(?:\.[a-zA-Z_$][a-zA-Z0-9_$]*)*)$/);
|
|
270
|
+
return m ? m[1] : null;
|
|
271
|
+
}, "matchDotOnly");
|
|
272
|
+
const resolveDotOnlyPath = /* @__PURE__ */ __name(async (dotPath) => {
|
|
273
|
+
const segs = dotPath.split(".");
|
|
274
|
+
const first = segs.shift();
|
|
275
|
+
if (!first) return void 0;
|
|
276
|
+
const base = await ctx[first];
|
|
277
|
+
if (segs.length === 0) return base;
|
|
278
|
+
return (0, import_client.getValuesByPath)(base, segs.join("."));
|
|
279
|
+
}, "resolveDotOnlyPath");
|
|
280
|
+
const singleMatch = expression.match(/^\{\{\s*(.+)\s*\}\}$/);
|
|
281
|
+
if (singleMatch) {
|
|
282
|
+
const inner = singleMatch[1];
|
|
283
|
+
const dotPath = matchDotOnly(inner);
|
|
284
|
+
if (dotPath) {
|
|
285
|
+
return await resolveDotOnlyPath(dotPath);
|
|
286
|
+
}
|
|
287
|
+
return await processExpression(inner, ctx);
|
|
288
|
+
}
|
|
289
|
+
const matches = [...expression.matchAll(/\{\{\s*(.+?)\s*\}\}/g)];
|
|
290
|
+
let result = expression;
|
|
291
|
+
for (const [fullMatch, innerExpr] of matches) {
|
|
292
|
+
const dotPath = matchDotOnly(innerExpr);
|
|
293
|
+
const value = dotPath ? await resolveDotOnlyPath(dotPath) : await processExpression(innerExpr, ctx);
|
|
294
|
+
if (value !== void 0) {
|
|
295
|
+
const replacement = typeof value === "object" && value !== null ? JSON.stringify(value) : String(value);
|
|
296
|
+
result = result.replace(fullMatch, replacement);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return result;
|
|
300
|
+
}
|
|
301
|
+
__name(compileExpression, "compileExpression");
|
|
302
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
303
|
+
0 && (module.exports = {
|
|
304
|
+
enqueueVariablesResolve,
|
|
305
|
+
preprocessExpression,
|
|
306
|
+
resolveCreateModelOptions,
|
|
307
|
+
resolveDefaultParams,
|
|
308
|
+
resolveExpressions
|
|
309
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
export interface ViewParam {
|
|
10
|
+
/** 视图唯一标识符,一般为某个 Model 实例的 uid */
|
|
11
|
+
viewUid: string;
|
|
12
|
+
/** 标签页唯一标识符 */
|
|
13
|
+
tabUid?: string;
|
|
14
|
+
/** 弹窗记录的 id */
|
|
15
|
+
filterByTk?: string;
|
|
16
|
+
/** source Id */
|
|
17
|
+
sourceId?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 解析路径名为视图参数数组
|
|
21
|
+
*
|
|
22
|
+
* 支持解析包含多个视图的路径,每个视图可以包含 tab、filterByTk、sourceId 等参数
|
|
23
|
+
*
|
|
24
|
+
* @param pathname - 要解析的路径名,格式如 '/admin/xxx/view/xxx/tab/xxx'
|
|
25
|
+
* @returns 视图参数数组,每个元素对应一个视图
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* parsePathnameToViewParams('/admin/xxx') // [{ viewUid: 'xxx' }]
|
|
30
|
+
* parsePathnameToViewParams('/admin/xxx/tab/yyy') // [{ viewUid: 'xxx', tabUid: 'yyy' }]
|
|
31
|
+
* parsePathnameToViewParams('/admin/xxx/view/yyy') // [{ viewUid: 'xxx' }, { viewUid: 'yyy' }]
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare const parsePathnameToViewParams: (pathname: string) => ViewParam[];
|
|
@@ -0,0 +1,84 @@
|
|
|
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
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
15
|
+
var __export = (target, all) => {
|
|
16
|
+
for (var name in all)
|
|
17
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18
|
+
};
|
|
19
|
+
var __copyProps = (to, from, except, desc) => {
|
|
20
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
+
for (let key of __getOwnPropNames(from))
|
|
22
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
23
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
|
+
}
|
|
25
|
+
return to;
|
|
26
|
+
};
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var parsePathnameToViewParams_exports = {};
|
|
29
|
+
__export(parsePathnameToViewParams_exports, {
|
|
30
|
+
parsePathnameToViewParams: () => parsePathnameToViewParams
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(parsePathnameToViewParams_exports);
|
|
33
|
+
const parsePathnameToViewParams = /* @__PURE__ */ __name((pathname) => {
|
|
34
|
+
if (!pathname || pathname === "/") {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
const segments = pathname.replace(/^\/+/, "").split("/").filter(Boolean);
|
|
38
|
+
if (segments.length < 2) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
const result = [];
|
|
42
|
+
let currentView = null;
|
|
43
|
+
let i = 0;
|
|
44
|
+
while (i < segments.length) {
|
|
45
|
+
const segment = segments[i];
|
|
46
|
+
if (segment === "admin" || segment === "view") {
|
|
47
|
+
if (currentView) {
|
|
48
|
+
result.push(currentView);
|
|
49
|
+
}
|
|
50
|
+
if (i + 1 < segments.length) {
|
|
51
|
+
currentView = { viewUid: segments[i + 1] };
|
|
52
|
+
i += 2;
|
|
53
|
+
} else {
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
} else if (currentView && i + 1 < segments.length) {
|
|
57
|
+
const value = segments[i + 1];
|
|
58
|
+
switch (segment) {
|
|
59
|
+
case "tab":
|
|
60
|
+
currentView.tabUid = value;
|
|
61
|
+
break;
|
|
62
|
+
case "filterbytk":
|
|
63
|
+
currentView.filterByTk = value;
|
|
64
|
+
break;
|
|
65
|
+
case "sourceid":
|
|
66
|
+
currentView.sourceId = value;
|
|
67
|
+
break;
|
|
68
|
+
default:
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
i += 2;
|
|
72
|
+
} else {
|
|
73
|
+
i++;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (currentView) {
|
|
77
|
+
result.push(currentView);
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
}, "parsePathnameToViewParams");
|
|
81
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
82
|
+
0 && (module.exports = {
|
|
83
|
+
parsePathnameToViewParams
|
|
84
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
* 统一的安全全局对象代理:window/document
|
|
11
|
+
* - 默认仅允许常用的定时器、console、Math、Date、addEventListener(绑定原 window)
|
|
12
|
+
* - document 仅允许 createElement/querySelector/querySelectorAll
|
|
13
|
+
* - 不允许随意访问未声明的属性,最小权限原则
|
|
14
|
+
*/
|
|
15
|
+
export declare function createSafeWindow(extra?: Record<string, any>): {};
|
|
16
|
+
export declare function createSafeDocument(extra?: Record<string, any>): {};
|
|
@@ -0,0 +1,179 @@
|
|
|
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
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
15
|
+
var __export = (target, all) => {
|
|
16
|
+
for (var name in all)
|
|
17
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18
|
+
};
|
|
19
|
+
var __copyProps = (to, from, except, desc) => {
|
|
20
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
+
for (let key of __getOwnPropNames(from))
|
|
22
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
23
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
|
+
}
|
|
25
|
+
return to;
|
|
26
|
+
};
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var safeGlobals_exports = {};
|
|
29
|
+
__export(safeGlobals_exports, {
|
|
30
|
+
createSafeDocument: () => createSafeDocument,
|
|
31
|
+
createSafeWindow: () => createSafeWindow
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(safeGlobals_exports);
|
|
34
|
+
function createSafeWindow(extra) {
|
|
35
|
+
const getSafeBaseHref = /* @__PURE__ */ __name(() => `${window.location.origin}${window.location.pathname}`, "getSafeBaseHref");
|
|
36
|
+
const safeOpen = /* @__PURE__ */ __name((url, target, features) => {
|
|
37
|
+
const isSafeUrl = /* @__PURE__ */ __name((u) => {
|
|
38
|
+
try {
|
|
39
|
+
const parsed = new URL(u, getSafeBaseHref());
|
|
40
|
+
const protocol = parsed.protocol.toLowerCase();
|
|
41
|
+
if (protocol === "about:") return parsed.href === "about:blank";
|
|
42
|
+
return protocol === "http:" || protocol === "https:";
|
|
43
|
+
} catch {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}, "isSafeUrl");
|
|
47
|
+
if (!isSafeUrl(url)) {
|
|
48
|
+
throw new Error("Unsafe URL: window.open only allows http/https/about:blank.");
|
|
49
|
+
}
|
|
50
|
+
const sanitizedTarget = "_blank";
|
|
51
|
+
const enforceFeatures = /* @__PURE__ */ __name((f) => {
|
|
52
|
+
const set = /* @__PURE__ */ new Set();
|
|
53
|
+
if (f) {
|
|
54
|
+
f.split(",").map((s) => s.trim()).filter(Boolean).forEach((part) => {
|
|
55
|
+
const key = part.split("=")[0].trim().toLowerCase();
|
|
56
|
+
if (key !== "noopener" && key !== "noreferrer") set.add(part);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
set.add("noopener");
|
|
60
|
+
set.add("noreferrer");
|
|
61
|
+
return Array.from(set).join(",");
|
|
62
|
+
}, "enforceFeatures");
|
|
63
|
+
const sanitizedFeatures = enforceFeatures(features);
|
|
64
|
+
const newWin = window.open.call(window, url, sanitizedTarget, sanitizedFeatures);
|
|
65
|
+
if (newWin && "opener" in newWin) {
|
|
66
|
+
try {
|
|
67
|
+
newWin.opener = null;
|
|
68
|
+
} catch {
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return newWin;
|
|
72
|
+
}, "safeOpen");
|
|
73
|
+
const guardedNavigate = /* @__PURE__ */ __name((rawUrl, opts) => {
|
|
74
|
+
const parsed = new URL(rawUrl, getSafeBaseHref());
|
|
75
|
+
const protocol = parsed.protocol.toLowerCase();
|
|
76
|
+
const isAboutBlank = protocol === "about:" && parsed.href === "about:blank";
|
|
77
|
+
const isHttp = protocol === "http:" || protocol === "https:";
|
|
78
|
+
if (!isHttp && !isAboutBlank) {
|
|
79
|
+
throw new Error("Unsafe URL: only http/https/about:blank are allowed.");
|
|
80
|
+
}
|
|
81
|
+
if (isAboutBlank) {
|
|
82
|
+
return (opts == null ? void 0 : opts.replace) ? window.location.replace("about:blank") : window.location.assign("about:blank");
|
|
83
|
+
}
|
|
84
|
+
const sameOrigin = parsed.protocol === window.location.protocol && parsed.hostname === window.location.hostname && parsed.port === window.location.port;
|
|
85
|
+
if (sameOrigin) {
|
|
86
|
+
return (opts == null ? void 0 : opts.replace) ? window.location.replace(parsed.href) : window.location.assign(parsed.href);
|
|
87
|
+
}
|
|
88
|
+
const win = safeOpen(parsed.href);
|
|
89
|
+
if (!win) throw new Error("Popup blocked: cross-origin navigation is opened in a new tab.");
|
|
90
|
+
}, "guardedNavigate");
|
|
91
|
+
const safeLocation = new Proxy(
|
|
92
|
+
{},
|
|
93
|
+
{
|
|
94
|
+
get(_t, prop) {
|
|
95
|
+
switch (prop) {
|
|
96
|
+
case "origin":
|
|
97
|
+
return window.location.origin;
|
|
98
|
+
case "protocol":
|
|
99
|
+
return window.location.protocol;
|
|
100
|
+
case "host":
|
|
101
|
+
return window.location.host;
|
|
102
|
+
case "hostname":
|
|
103
|
+
return window.location.hostname;
|
|
104
|
+
case "port":
|
|
105
|
+
return window.location.port;
|
|
106
|
+
case "pathname":
|
|
107
|
+
return window.location.pathname;
|
|
108
|
+
case "assign":
|
|
109
|
+
return (u) => guardedNavigate(u, { replace: false });
|
|
110
|
+
case "replace":
|
|
111
|
+
return (u) => guardedNavigate(u, { replace: true });
|
|
112
|
+
case "reload":
|
|
113
|
+
throw new Error("Access to location.reload is not allowed.");
|
|
114
|
+
case "href":
|
|
115
|
+
throw new Error("Reading location.href is not allowed.");
|
|
116
|
+
default:
|
|
117
|
+
throw new Error(`Access to location property "${prop}" is not allowed.`);
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
set(_t, prop, value) {
|
|
121
|
+
if (prop === "href") {
|
|
122
|
+
guardedNavigate(String(value), { replace: false });
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
throw new Error("Mutation on location is not allowed.");
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
const allowedGlobals = {
|
|
130
|
+
// 需绑定到原始 window,避免严格模式下触发 Illegal invocation
|
|
131
|
+
setTimeout: window.setTimeout.bind(window),
|
|
132
|
+
clearTimeout: window.clearTimeout.bind(window),
|
|
133
|
+
setInterval: window.setInterval.bind(window),
|
|
134
|
+
clearInterval: window.clearInterval.bind(window),
|
|
135
|
+
console,
|
|
136
|
+
Math,
|
|
137
|
+
Date,
|
|
138
|
+
// 事件侦听仅绑定到真实 window,便于少量需要的全局监听
|
|
139
|
+
addEventListener: addEventListener.bind(window),
|
|
140
|
+
// 安全的 window.open 代理
|
|
141
|
+
open: safeOpen,
|
|
142
|
+
// 安全的 location 代理
|
|
143
|
+
location: safeLocation,
|
|
144
|
+
...extra || {}
|
|
145
|
+
};
|
|
146
|
+
return new Proxy(
|
|
147
|
+
{},
|
|
148
|
+
{
|
|
149
|
+
get(_target, prop) {
|
|
150
|
+
if (prop in allowedGlobals) return allowedGlobals[prop];
|
|
151
|
+
throw new Error(`Access to global property "${prop}" is not allowed.`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
__name(createSafeWindow, "createSafeWindow");
|
|
157
|
+
function createSafeDocument(extra) {
|
|
158
|
+
const allowed = {
|
|
159
|
+
createElement: document.createElement.bind(document),
|
|
160
|
+
querySelector: document.querySelector.bind(document),
|
|
161
|
+
querySelectorAll: document.querySelectorAll.bind(document),
|
|
162
|
+
...extra || {}
|
|
163
|
+
};
|
|
164
|
+
return new Proxy(
|
|
165
|
+
{},
|
|
166
|
+
{
|
|
167
|
+
get(_target, prop) {
|
|
168
|
+
if (prop in allowed) return allowed[prop];
|
|
169
|
+
throw new Error(`Access to document property "${prop}" is not allowed.`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
__name(createSafeDocument, "createSafeDocument");
|
|
175
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
176
|
+
0 && (module.exports = {
|
|
177
|
+
createSafeDocument,
|
|
178
|
+
createSafeWindow
|
|
179
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
import type { ISchema } from '@formily/json-schema';
|
|
10
|
+
import type { FlowModel } from '../models';
|
|
11
|
+
import { FlowRuntimeContext } from '../flowContext';
|
|
12
|
+
import type { StepDefinition, StepUIMode } from '../types';
|
|
13
|
+
/**
|
|
14
|
+
* 解析 uiMode,支持静态值和函数形式
|
|
15
|
+
* 函数可以接收 FlowRuntimeContext
|
|
16
|
+
* @param {StepUIMode | ((ctx: FlowRuntimeContext<TModel>) => StepUIMode | Promise<StepUIMode>)} uiMode UI模式定义
|
|
17
|
+
* @param {FlowRuntimeContext<TModel>} ctx 上下文
|
|
18
|
+
* @returns {Promise<StepUIMode>} 解析后的 UI 模式
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveUiMode<TModel extends FlowModel = FlowModel>(uiMode: StepUIMode | ((ctx: FlowRuntimeContext<TModel>) => StepUIMode | Promise<StepUIMode>) | undefined, ctx: FlowRuntimeContext<TModel>): Promise<StepUIMode>;
|
|
21
|
+
/**
|
|
22
|
+
* 编译 UI Schema 中的表达式
|
|
23
|
+
*
|
|
24
|
+
* @param scope 编译作用域,包含可用的变量和函数(如 t, randomString 等)
|
|
25
|
+
* @param uiSchema 待编译的 UI Schema
|
|
26
|
+
* @param options 编译选项
|
|
27
|
+
* @returns 编译后的 UI Schema
|
|
28
|
+
*/
|
|
29
|
+
export declare function compileUiSchema(scope: Record<string, any>, uiSchema: any, options?: {
|
|
30
|
+
noCache?: boolean;
|
|
31
|
+
}): any;
|
|
32
|
+
/**
|
|
33
|
+
* 解析并合并步骤的完整uiSchema
|
|
34
|
+
* 这个函数提取了在多个组件中重复使用的uiSchema解析和合并逻辑
|
|
35
|
+
* @param model 模型实例
|
|
36
|
+
* @param flow 流程定义
|
|
37
|
+
* @param step 步骤定义
|
|
38
|
+
* @returns 合并后的uiSchema对象,如果为空则返回null
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveStepUiSchema<TModel extends FlowModel = FlowModel>(model: TModel, flow: any, step: StepDefinition): Promise<Record<string, ISchema> | null>;
|